<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[279216] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/279216">279216</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-06-24 01:31:48 -0700 (Thu, 24 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] Implement returnEarlyFromInfiniteLoopsForFuzzing for 32bits
https://bugs.webkit.org/show_bug.cgi?id=227290

JSTests:

Patch by Xan Lopez <xan@igalia.com> on 2021-06-24
Reviewed by Mark Lam.

Now that we can return early from infinite (actual or just
extremely long running) loops on 32bits, we can pass these tests.

* stress/construct-return-early-from-infinite-loop-for-fuzzer.js: unskip for 32bits.
* stress/early-return-from-builtin2.js: ditto.
* stress/validate-does-gc-with-return-early-from-infinite-loop-2.js: ditto.
* stress/validate-does-gc-with-return-early-from-infinite-loop.js: ditto.

Source/JavaScriptCore:

Patch by Xan López <xan@igalia.com> on 2021-06-24
Reviewed by Mark Lam.

Mostly a matter of changing the counter type to uintptr_t and
making the baseline/dfg/ftl code generation work on both 32 and
64bits, most of it can be shared with minor tweaks.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileLoopHint):
* dfg/DFGSpeculativeJIT.h:
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_loop_hint):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LowLevelInterpreter32_64.asm:
* runtime/VM.cpp:
(JSC::VM::addLoopHintExecutionCounter):
(JSC::VM::getLoopHintExecutionCounter):
* runtime/VM.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestsstressconstructreturnearlyfrominfiniteloopforfuzzerjs">trunk/JSTests/stress/construct-return-early-from-infinite-loop-for-fuzzer.js</a></li>
<li><a href="#trunkJSTestsstressearlyreturnfrombuiltin2js">trunk/JSTests/stress/early-return-from-builtin2.js</a></li>
<li><a href="#trunkJSTestsstressvalidatedoesgcwithreturnearlyfrominfiniteloop2js">trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop-2.js</a></li>
<li><a href="#trunkJSTestsstressvalidatedoesgcwithreturnearlyfrominfiniteloopjs">trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITh">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp">trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorejitJITOpcodescpp">trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLLIntSlowPathscpp">trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm">trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMcpp">trunk/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeVMh">trunk/Source/JavaScriptCore/runtime/VM.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog  2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/JSTests/ChangeLog     2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2021-06-24  Xan Lopez  <xan@igalia.com>
+
+        [JSC] Implement returnEarlyFromInfiniteLoopsForFuzzing for 32bits
+        https://bugs.webkit.org/show_bug.cgi?id=227290
+
+        Reviewed by Mark Lam.
+
+        Now that we can return early from infinite (actual or just
+        extremely long running) loops on 32bits, we can pass these tests.
+
+        * stress/construct-return-early-from-infinite-loop-for-fuzzer.js: unskip for 32bits.
+        * stress/early-return-from-builtin2.js: ditto.
+        * stress/validate-does-gc-with-return-early-from-infinite-loop-2.js: ditto.
+        * stress/validate-does-gc-with-return-early-from-infinite-loop.js: ditto.
+
</ins><span class="cx"> 2021-06-23  Saam Barati  <sbarati@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Bound stress/put-by-id-flags with a fixed number of iterations
</span></span></pre></div>
<a id="trunkJSTestsstressconstructreturnearlyfrominfiniteloopforfuzzerjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/construct-return-early-from-infinite-loop-for-fuzzer.js (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/construct-return-early-from-infinite-loop-for-fuzzer.js     2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/JSTests/stress/construct-return-early-from-infinite-loop-for-fuzzer.js        2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,4 +1,3 @@
</span><del>-//@ skip if $architecture != "arm64" and $architecture != "x86-64"
</del><span class="cx"> //@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=1")
</span><span class="cx"> 
</span><span class="cx"> function foo() {
</span></span></pre></div>
<a id="trunkJSTestsstressearlyreturnfrombuiltin2js"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/early-return-from-builtin2.js (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/early-return-from-builtin2.js       2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/JSTests/stress/early-return-from-builtin2.js  2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,4 +1,3 @@
</span><del>-//@ skip if $architecture != "arm64" and $architecture != "x86-64"
</del><span class="cx"> //@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=1", "--earlyReturnFromInfiniteLoopsLimit=1000", "--jitPolicyScale=0", "--maximumFunctionForCallInlineCandidateBytecodeCost=1000", "--useConcurrentJIT=0", "--useFTLJIT=0")
</span><span class="cx"> const a = [null, 0, 0, 0, 0, 0, 0];
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkJSTestsstressvalidatedoesgcwithreturnearlyfrominfiniteloop2js"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop-2.js (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop-2.js  2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop-2.js     2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,4 +1,3 @@
</span><del>-//@ skip if $architecture != "arm64" and $architecture != "x86-64"
</del><span class="cx"> //@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=true", "--earlyReturnFromInfiniteLoopsLimit=100000", "--useConcurrentJIT=false", "--useFTLJIT=false", "--validateDoesGC=true")
</span><span class="cx"> 
</span><span class="cx"> if ($vm.useJIT()) {
</span></span></pre></div>
<a id="trunkJSTestsstressvalidatedoesgcwithreturnearlyfrominfiniteloopjs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop.js (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop.js    2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/JSTests/stress/validate-does-gc-with-return-early-from-infinite-loop.js       2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,4 +1,3 @@
</span><del>-//@ skip if $architecture != "arm64" and $architecture != "x86-64"
</del><span class="cx"> //@ runDefault("--returnEarlyFromInfiniteLoopsForFuzzing=true", "--earlyReturnFromInfiniteLoopsLimit=1000000", "--useConcurrentJIT=false", "--validateDoesGC=true")
</span><span class="cx"> 
</span><span class="cx"> if ($vm.useJIT()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/ChangeLog       2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2021-06-24  Xan López  <xan@igalia.com>
+
+        [JSC] Implement returnEarlyFromInfiniteLoopsForFuzzing for 32bits
+        https://bugs.webkit.org/show_bug.cgi?id=227290
+
+        Reviewed by Mark Lam.
+
+        Mostly a matter of changing the counter type to uintptr_t and
+        making the baseline/dfg/ftl code generation work on both 32 and
+        64bits, most of it can be shared with minor tweaks.
+
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileLoopHint):
+        * dfg/DFGSpeculativeJIT.h:
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq):
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_loop_hint):
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        * llint/LowLevelInterpreter32_64.asm:
+        * runtime/VM.cpp:
+        (JSC::VM::addLoopHintExecutionCounter):
+        (JSC::VM::getLoopHintExecutionCounter):
+        * runtime/VM.h:
+
</ins><span class="cx"> 2021-06-23  Mark Lam  <mark.lam@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Base Options::useWebAssemblyFastMemory's default value on Gigacage::hasCapacityToUseLargeGigacage.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp    2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp       2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -2096,6 +2096,54 @@
</span><span class="cx">     info.noticeOSRBirth(*m_stream, node, virtualRegister);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SpeculativeJIT::compileLoopHint(Node* node)
+{
+    if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing())) {
+        bool emitEarlyReturn = true;
+        node->origin.semantic.walkUpInlineStack([&](CodeOrigin origin) {
+            CodeBlock* baselineCodeBlock = m_jit.graph().baselineCodeBlockFor(origin);
+            if (!baselineCodeBlock->loopHintsAreEligibleForFuzzingEarlyReturn())
+                emitEarlyReturn = false;
+        });
+        if (emitEarlyReturn) {
+            CodeBlock* baselineCodeBlock = m_jit.graph().baselineCodeBlockFor(node->origin.semantic);
+            BytecodeIndex bytecodeIndex = node->origin.semantic.bytecodeIndex();
+            const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex.offset()).ptr();
+
+            uintptr_t* ptr = vm().getLoopHintExecutionCounter(instruction);
+            m_jit.pushToSave(GPRInfo::regT0);
+            m_jit.loadPtr(ptr, GPRInfo::regT0);
+            auto skipEarlyReturn = m_jit.branchPtr(CCallHelpers::Below, GPRInfo::regT0, CCallHelpers::TrustedImmPtr(Options::earlyReturnFromInfiniteLoopsLimit()));
+
+            if constexpr (validateDFGDoesGC) {
+                if (Options::validateDoesGC()) {
+                    // We need to mock what a Return does: claims to GC.
+                    m_jit.move(CCallHelpers::TrustedImmPtr(vm().heap.addressOfDoesGC()), GPRInfo::regT0);
+                    m_jit.store32(CCallHelpers::TrustedImm32(DoesGCCheck::encode(true, DoesGCCheck::Special::Uninitialized)), CCallHelpers::Address(GPRInfo::regT0));
+                }
+            }
+
+            m_jit.popToRestore(GPRInfo::regT0);
+#if USE(JSVALUE64)
+            JSValueRegs resultRegs(GPRInfo::returnValueGPR);
+#else
+            JSValueRegs resultRegs(GPRInfo::returnValueGPR2, GPRInfo::returnValueGPR);
+#endif
+            m_jit.moveValue(baselineCodeBlock->globalObject(), resultRegs);
+            m_jit.emitRestoreCalleeSaves();
+            m_jit.emitFunctionEpilogue();
+            m_jit.ret();
+
+            skipEarlyReturn.link(&m_jit);
+            m_jit.addPtr(CCallHelpers::TrustedImm32(1), GPRInfo::regT0);
+            m_jit.storePtr(GPRInfo::regT0, ptr);
+            m_jit.popToRestore(GPRInfo::regT0);
+        }
+    }
+
+    noResult(node);
+}
+
</ins><span class="cx"> void SpeculativeJIT::compileMovHint(Node* node)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(node->containsMovHint());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h      2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h 2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -714,6 +714,7 @@
</span><span class="cx">     
</span><span class="cx">     void compileCheckTraps(Node*);
</span><span class="cx"> 
</span><ins>+    void compileLoopHint(Node*);
</ins><span class="cx">     void compileMovHint(Node*);
</span><span class="cx">     void compileMovHintAndCheck(Node*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT32_64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp       2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp  2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -4207,10 +4207,12 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case PhantomLocal:
</span><del>-    case LoopHint:
</del><span class="cx">         // This is a no-op.
</span><span class="cx">         noResult(node);
</span><span class="cx">         break;
</span><ins>+    case LoopHint:
+        compileLoopHint(node);
+        break;
</ins><span class="cx">         
</span><span class="cx">     case MaterializeNewObject:
</span><span class="cx">         compileMaterializeNewObject(node);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp  2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp     2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -5251,46 +5251,7 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case LoopHint:
</span><del>-        if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing())) {
-            bool emitEarlyReturn = true;
-            node->origin.semantic.walkUpInlineStack([&](CodeOrigin origin) {
-                CodeBlock* baselineCodeBlock = m_jit.graph().baselineCodeBlockFor(origin);
-                if (!baselineCodeBlock->loopHintsAreEligibleForFuzzingEarlyReturn())
-                    emitEarlyReturn = false;
-            });
-            if (emitEarlyReturn) {
-                CodeBlock* baselineCodeBlock = m_jit.graph().baselineCodeBlockFor(node->origin.semantic);
-                BytecodeIndex bytecodeIndex = node->origin.semantic.bytecodeIndex();
-                const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex.offset()).ptr();
-
-                uint64_t* ptr = vm().getLoopHintExecutionCounter(instruction);
-                m_jit.pushToSave(GPRInfo::regT0);
-                m_jit.load64(ptr, GPRInfo::regT0);
-                auto skipEarlyReturn = m_jit.branch64(CCallHelpers::Below, GPRInfo::regT0, CCallHelpers::TrustedImm64(Options::earlyReturnFromInfiniteLoopsLimit()));
-
-                if constexpr (validateDFGDoesGC) {
-                    if (Options::validateDoesGC()) {
-                        // We need to mock what a Return does: claims to GC.
-                        m_jit.move(CCallHelpers::TrustedImmPtr(vm().heap.addressOfDoesGC()), GPRInfo::regT0);
-                        m_jit.store32(CCallHelpers::TrustedImm32(DoesGCCheck::encode(true, DoesGCCheck::Special::Uninitialized)), CCallHelpers::Address(GPRInfo::regT0));
-                    }
-                }
-
-                m_jit.popToRestore(GPRInfo::regT0);
-                m_jit.moveValue(baselineCodeBlock->globalObject(), JSValueRegs { GPRInfo::returnValueGPR });
-                m_jit.emitRestoreCalleeSaves();
-                m_jit.emitFunctionEpilogue();
-                m_jit.ret();
-
-                skipEarlyReturn.link(&m_jit);
-                m_jit.add64(CCallHelpers::TrustedImm32(1), GPRInfo::regT0);
-                m_jit.store64(GPRInfo::regT0, ptr);
-                m_jit.popToRestore(GPRInfo::regT0);
-            }
-        }
-
-        // This is a no-op.
-        noResult(node);
</del><ins>+        compileLoopHint(node);
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case Unreachable:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp      2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp 2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -15475,7 +15475,7 @@
</span><span class="cx">         BytecodeIndex bytecodeIndex = m_origin.semantic.bytecodeIndex();
</span><span class="cx">         const Instruction* instruction = baselineCodeBlock->instructions().at(bytecodeIndex.offset()).ptr();
</span><span class="cx">         VM* vm = &this->vm();
</span><del>-        uint64_t* ptr = vm->getLoopHintExecutionCounter(instruction);
</del><ins>+        uintptr_t* ptr = vm->getLoopHintExecutionCounter(instruction);
</ins><span class="cx"> 
</span><span class="cx">         PatchpointValue* patchpoint = m_out.patchpoint(Void);
</span><span class="cx">         patchpoint->effects = Effects::none();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorejitJITOpcodescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp   2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp      2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1430,13 +1430,17 @@
</span><span class="cx"> 
</span><span class="cx"> void JIT::emit_op_loop_hint(const Instruction* instruction)
</span><span class="cx"> {
</span><del>-#if USE(JSVALUE64)
</del><span class="cx">     if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing() && m_codeBlock->loopHintsAreEligibleForFuzzingEarlyReturn())) {
</span><del>-        uint64_t* ptr = vm().getLoopHintExecutionCounter(instruction);
-        load64(ptr, regT0);
-        auto skipEarlyReturn = branch64(Below, regT0, TrustedImm64(Options::earlyReturnFromInfiniteLoopsLimit()));
</del><ins>+        uintptr_t* ptr = vm().getLoopHintExecutionCounter(instruction);
+        loadPtr(ptr, regT0);
+        auto skipEarlyReturn = branchPtr(Below, regT0, TrustedImmPtr(Options::earlyReturnFromInfiniteLoopsLimit()));
</ins><span class="cx"> 
</span><del>-        moveValue(m_codeBlock->globalObject(), JSValueRegs { GPRInfo::returnValueGPR });
</del><ins>+#if USE(JSVALUE64)
+        JSValueRegs resultRegs(GPRInfo::returnValueGPR);
+#else
+        JSValueRegs resultRegs(GPRInfo::returnValueGPR2, GPRInfo::returnValueGPR);
+#endif
+        moveValue(m_codeBlock->globalObject(), resultRegs);
</ins><span class="cx">         checkStackPointerAlignment();
</span><span class="cx">         emitRestoreCalleeSaves();
</span><span class="cx">         emitFunctionEpilogue();
</span><span class="lines">@@ -1443,10 +1447,9 @@
</span><span class="cx">         ret();
</span><span class="cx"> 
</span><span class="cx">         skipEarlyReturn.link(this);
</span><del>-        add64(TrustedImm32(1), regT0);
-        store64(regT0, ptr);
</del><ins>+        addPtr(TrustedImm32(1), regT0);
+        storePtr(regT0, ptr);
</ins><span class="cx">     }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     // Emit the JIT optimization check: 
</span><span class="cx">     if (canBeOptimized()) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLLIntSlowPathscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp     2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp        2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -464,7 +464,7 @@
</span><span class="cx">             codeBlock->llintExecuteCounter());
</span><span class="cx"> 
</span><span class="cx">     if (UNLIKELY(Options::returnEarlyFromInfiniteLoopsForFuzzing() && codeBlock->loopHintsAreEligibleForFuzzingEarlyReturn())) {
</span><del>-        uint64_t* ptr = vm.getLoopHintExecutionCounter(pc);
</del><ins>+        uintptr_t* ptr = vm.getLoopHintExecutionCounter(pc);
</ins><span class="cx">         *ptr += codeBlock->llintExecuteCounter().m_activeThreshold;
</span><span class="cx">         if (*ptr >= Options::earlyReturnFromInfiniteLoopsLimit())
</span><span class="cx">             LLINT_RETURN_TWO(LLInt::fuzzerReturnEarlyFromLoopHintEntrypoint().code().executableAddress(), callFrame->topOfFrame());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorellintLowLevelInterpreter32_64asm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm   2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm      2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -2993,7 +2993,9 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> op(fuzzer_return_early_from_loop_hint, macro ()
</span><del>-    notSupported()
</del><ins>+    move UndefinedTag, r1
+    move 0, r0
+    doReturn()
</ins><span class="cx"> end)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp       2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp  2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1687,9 +1687,9 @@
</span><span class="cx"> void VM::addLoopHintExecutionCounter(const Instruction* instruction)
</span><span class="cx"> {
</span><span class="cx">     Locker locker { m_loopHintExecutionCountLock };
</span><del>-    auto addResult = m_loopHintExecutionCounts.add(instruction, std::pair<unsigned, std::unique_ptr<uint64_t>>(0, nullptr));
</del><ins>+    auto addResult = m_loopHintExecutionCounts.add(instruction, std::pair<unsigned, std::unique_ptr<uintptr_t>>(0, nullptr));
</ins><span class="cx">     if (addResult.isNewEntry) {
</span><del>-        auto ptr = WTF::makeUniqueWithoutFastMallocCheck<uint64_t>();
</del><ins>+        auto ptr = WTF::makeUniqueWithoutFastMallocCheck<uintptr_t>();
</ins><span class="cx">         *ptr = 0;
</span><span class="cx">         addResult.iterator->value.second = WTFMove(ptr);
</span><span class="cx">     }
</span><span class="lines">@@ -1696,7 +1696,7 @@
</span><span class="cx">     ++addResult.iterator->value.first;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-uint64_t* VM::getLoopHintExecutionCounter(const Instruction* instruction)
</del><ins>+uintptr_t* VM::getLoopHintExecutionCounter(const Instruction* instruction)
</ins><span class="cx"> {
</span><span class="cx">     Locker locker { m_loopHintExecutionCountLock };
</span><span class="cx">     auto iter = m_loopHintExecutionCounts.find(instruction);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (279215 => 279216)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h 2021-06-24 08:13:11 UTC (rev 279215)
+++ trunk/Source/JavaScriptCore/runtime/VM.h    2021-06-24 08:31:48 UTC (rev 279216)
</span><span class="lines">@@ -1162,7 +1162,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     void addLoopHintExecutionCounter(const Instruction*);
</span><del>-    uint64_t* getLoopHintExecutionCounter(const Instruction*);
</del><ins>+    uintptr_t* getLoopHintExecutionCounter(const Instruction*);
</ins><span class="cx">     void removeLoopHintExecutionCounter(const Instruction*);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -1286,7 +1286,7 @@
</span><span class="cx">     bool m_executionForbidden { false };
</span><span class="cx"> 
</span><span class="cx">     Lock m_loopHintExecutionCountLock;
</span><del>-    HashMap<const Instruction*, std::pair<unsigned, std::unique_ptr<uint64_t>>> m_loopHintExecutionCounts;
</del><ins>+    HashMap<const Instruction*, std::pair<unsigned, std::unique_ptr<uintptr_t>>> m_loopHintExecutionCounts;
</ins><span class="cx"> 
</span><span class="cx">     VM* m_prev; // Required by DoublyLinkedListNode.
</span><span class="cx">     VM* m_next; // Required by DoublyLinkedListNode.
</span></span></pre>
</div>
</div>

</body>
</html>