Skip to content

Commit

Permalink
[JSC] Use int32 serialization for double stringifying in JSStringJoiner
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=257995
rdar://110682175

Reviewed by Mark Lam.

Add int32 fast path for double stringifying in JSStringJoiner.

* Source/JavaScriptCore/runtime/ArrayPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSStringJoiner.h:
(JSC::JSStringJoiner::appendNumber):

Canonical link: https://commits.webkit.org/265102@main
  • Loading branch information
Constellation committed Jun 13, 2023
1 parent 4274ce7 commit ad54954
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ JSC_DEFINE_HOST_FUNCTION(arrayProtoFuncToString, (JSGlobalObject* globalObject,
RETURN_IF_EXCEPTION(scope, encodedJSValue());

Integrity::auditStructureID(thisObject->structureID());
if (!canUseDefaultArrayJoinForToString(thisObject)) {
if (UNLIKELY(!canUseDefaultArrayJoinForToString(thisObject))) {
// 2. Let func be the result of calling the [[Get]] internal method of array with argument "join".
JSValue function = thisObject->get(globalObject, vm.propertyNames->join);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
Expand Down
5 changes: 4 additions & 1 deletion Source/JavaScriptCore/runtime/JSStringJoiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ ALWAYS_INLINE void JSStringJoiner::appendNumber(VM& vm, int32_t value)

ALWAYS_INLINE void JSStringJoiner::appendNumber(VM& vm, double value)
{
append8Bit(vm.numericStrings.add(value));
if (canBeStrictInt32(value))
appendNumber(vm, static_cast<int32_t>(value));
else
append8Bit(vm.numericStrings.add(value));
}

} // namespace JSC

0 comments on commit ad54954

Please sign in to comment.