Skip to content

Commit be58304

Browse files
committed
[JSC] Identifier::add should not ref and deref the returned AtomStringImpl
https://bugs.webkit.org/show_bug.cgi?id=328788 Reviewed by Yusuke Suzuki. `Identifier::add` and `add8` dereference the temporary RefPtr returned by `AtomStringImpl::add` and build a Ref from the reference, which costs one extra atomic ref and deref per call. Use `releaseNonNull()` instead. * Source/JavaScriptCore/runtime/Identifier.cpp: (JSC::Identifier::add8): * Source/JavaScriptCore/runtime/IdentifierInlines.h: (JSC::Identifier::add): Canonical link: https://commits.webkit.org/324790@main
1 parent 969d069 commit be58304

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎Source/JavaScriptCore/runtime/Identifier.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Ref<AtomStringImpl> Identifier::add8(VM& vm, std::span<const char16_t> s)
3737
}
3838
if (s.empty())
3939
return *static_cast<AtomStringImpl*>(StringImpl::empty());
40-
return *AtomStringImpl::add(s);
40+
return AtomStringImpl::add(s).releaseNonNull();
4141
}
4242

4343
Identifier Identifier::from(VM& vm, unsigned value)

‎Source/JavaScriptCore/runtime/IdentifierInlines.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ Ref<AtomStringImpl> Identifier::add(VM& vm, std::span<const T> string)
105105
if (string.empty())
106106
return *static_cast<AtomStringImpl*>(StringImpl::empty());
107107

108-
return *AtomStringImpl::add(string);
108+
return AtomStringImpl::add(string).releaseNonNull();
109109
}
110110

111111
inline Ref<AtomStringImpl> Identifier::add(VM& vm, StringImpl* r)
112112
{
113113
#ifndef NDEBUG
114114
checkCurrentAtomStringTable(vm);
115115
#endif
116-
return *AtomStringImpl::addWithStringTableProvider(vm, r);
116+
return AtomStringImpl::addWithStringTableProvider(vm, r).releaseNonNull();
117117
}
118118

119119
inline Identifier Identifier::createLatin1(VM& vm, std::span<const char16_t> string)

0 commit comments

Comments
 (0)