Skip to content

Commit

Permalink
[JSC] Fix StrCat(ToPrimitive(x), ...) in attemptToMakeFastStringAdd
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259074
rdar://112016271

Reviewed by Yusuke Suzuki.

Previously, we introduced a fast path [1] for string catenation with
ToPrimitive. And the path doesn't need canOptimizeStringObjectAccess
to be true. This patch reorders the if checks in attemptToMakeFastStringAdd
to avoid canOptimizeStringObjectAccess assertion.

[1] https://commits.webkit.org/265636@main

* JSTests/stress/strcat-str-str-bigint.js: Added.
(foo):
* Source/JavaScriptCore/dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::attemptToMakeFastStringAdd):

Canonical link: https://commits.webkit.org/265927@main
  • Loading branch information
hyjorc1 authored and Mark Lam committed Jul 11, 2023
1 parent 5419922 commit 80a97a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions JSTests/stress/strcat-str-str-bigint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function foo() {
'' + '' + 1n;
}

for (let i = 0; i < 100; i++) {
foo();
}
8 changes: 4 additions & 4 deletions Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,10 @@ class FixupPhase : public Phase {
convertStringAddUse<Int32Use>(node, edge);
return;
}
if (edge->op() == ToPrimitive) {
convertStringAddUse<KnownPrimitiveUse>(node, edge);
return;
}
if (!Options::useConcurrentJIT())
ASSERT(m_graph.canOptimizeStringObjectAccess(node->origin.semantic));
if (edge->shouldSpeculateStringObject()) {
Expand All @@ -3765,10 +3769,6 @@ class FixupPhase : public Phase {
convertStringAddUse<StringOrStringObjectUse>(node, edge);
return;
}
if (edge->op() == ToPrimitive) {
convertStringAddUse<KnownPrimitiveUse>(node, edge);
return;
}
RELEASE_ASSERT_NOT_REACHED();
});

Expand Down

0 comments on commit 80a97a5

Please sign in to comment.