<!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>[162666] branches/jsCStack/Source/JavaScriptCore</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/162666">162666</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-23 17:18:19 -0800 (Thu, 23 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>3x splay regression in FTL with experimental coverage that is entirely due to Bartlett weirdness
https://bugs.webkit.org/show_bug.cgi?id=127463

Reviewed by Mark Hahnenberg.
        
This turned out to be entirely due to misuse of the scratch buffer in an FTL thunk.
We need to mark a scratch buffer as unused after we're done with it or else the GC
will have a bad time.
        
But, this also introduces some debugging-related things that were useful on my
journey.
        
Finally, this turns all experimental FTL coverage into non-experimental coverage for
now. I'm keeping the option because we will probably make other things &quot;experimental&quot;
in the near future, if they cause regressions.

* dfg/DFGTierUpCheckInjectionPhase.cpp:
(JSC::DFG::TierUpCheckInjectionPhase::run): Made it possible to disable FTL OSR entry.
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile): Make the new NodeTypes non-experimental.
* ftl/FTLThunks.cpp:
(JSC::FTL::osrExitGenerationThunkGenerator): Fix the actual bug.
* llint/LowLevelInterpreter.asm:
* runtime/Options.h:
* runtime/VM.cpp:
(JSC::logSanitizeStack):
* runtime/VM.h:
(JSC::sanitizeStackForVM): This is all about making it possible to print things when the stack is sanitized.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchesjsCStackSourceJavaScriptCoreChangeLog">branches/jsCStack/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoredfgDFGTierUpCheckInjectionPhasecpp">branches/jsCStack/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreftlFTLThunkscpp">branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreterasm">branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeOptionsh">branches/jsCStack/Source/JavaScriptCore/runtime/Options.h</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMcpp">branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp</a></li>
<li><a href="#branchesjsCStackSourceJavaScriptCoreruntimeVMh">branches/jsCStack/Source/JavaScriptCore/runtime/VM.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchesjsCStackSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ChangeLog (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/ChangeLog        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2014-01-23  Filip Pizlo  &lt;fpizlo@apple.com&gt;
+
+        3x splay regression in FTL with experimental coverage that is entirely due to Bartlett weirdness
+        https://bugs.webkit.org/show_bug.cgi?id=127463
+
+        Reviewed by Mark Hahnenberg.
+        
+        This turned out to be entirely due to misuse of the scratch buffer in an FTL thunk.
+        We need to mark a scratch buffer as unused after we're done with it or else the GC
+        will have a bad time.
+        
+        But, this also introduces some debugging-related things that were useful on my
+        journey.
+        
+        Finally, this turns all experimental FTL coverage into non-experimental coverage for
+        now. I'm keeping the option because we will probably make other things &quot;experimental&quot;
+        in the near future, if they cause regressions.
+
+        * dfg/DFGTierUpCheckInjectionPhase.cpp:
+        (JSC::DFG::TierUpCheckInjectionPhase::run): Made it possible to disable FTL OSR entry.
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile): Make the new NodeTypes non-experimental.
+        * ftl/FTLThunks.cpp:
+        (JSC::FTL::osrExitGenerationThunkGenerator): Fix the actual bug.
+        * llint/LowLevelInterpreter.asm:
+        * runtime/Options.h:
+        * runtime/VM.cpp:
+        (JSC::logSanitizeStack):
+        * runtime/VM.h:
+        (JSC::sanitizeStackForVM): This is all about making it possible to print things when the stack is sanitized.
+
</ins><span class="cx"> 2014-01-23  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge branch up to ToT r161658.
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoredfgDFGTierUpCheckInjectionPhasecpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -58,6 +58,9 @@
</span><span class="cx">         if (level == FTL::CannotCompile)
</span><span class="cx">             return false;
</span><span class="cx">         
</span><ins>+        if (!Options::enableOSREntryToFTL())
+            level = FTL::CanCompile;
+        
</ins><span class="cx">         InsertionSet insertionSet(m_graph);
</span><span class="cx">         for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
</span><span class="cx">             BasicBlock* block = m_graph.block(blockIndex);
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLCapabilitiescpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLCapabilities.cpp        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -125,6 +125,11 @@
</span><span class="cx">     case CountExecution:
</span><span class="cx">     case CheckExecutable:
</span><span class="cx">     case GetScope:
</span><ins>+    case AllocationProfileWatchpoint:
+    case CheckArgumentsNotCreated:
+    case GetCallee:
+    case ToString:
+    case MakeRope:
</ins><span class="cx">         // These are OK.
</span><span class="cx">         break;
</span><span class="cx">     case GetById:
</span><span class="lines">@@ -238,14 +243,6 @@
</span><span class="cx">             return CannotCompile;
</span><span class="cx">         }
</span><span class="cx">         break;
</span><del>-    case AllocationProfileWatchpoint:
-    case CheckArgumentsNotCreated:
-    case GetCallee:
-    case ToString:
-    case MakeRope:
-        if (!Options::enableExperimentalFTLCoverage())
-            return CannotCompile;
-        break;
</del><span class="cx">     default:
</span><span class="cx">         // Don't know how to handle anything else.
</span><span class="cx">         return CannotCompile;
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreftlFTLThunkscpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/ftl/FTLThunks.cpp        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -71,10 +71,13 @@
</span><span class="cx">     
</span><span class="cx">     jit.move(GPRInfo::returnValueGPR, GPRInfo::regT0);
</span><span class="cx">     
</span><ins>+    // Make sure we tell the GC that we're not using the scratch buffer anymore.
+    jit.move(MacroAssembler::TrustedImmPtr(scratchBuffer-&gt;activeLengthPtr()), GPRInfo::regT1);
+    jit.storePtr(MacroAssembler::TrustedImmPtr(0), GPRInfo::regT1);
+    
</ins><span class="cx">     // Prepare for tail call.
</span><span class="cx">     jit.pop(GPRInfo::regT1);
</span><span class="cx">     jit.pop(GPRInfo::regT1);
</span><del>-    // FIXME: CStack - Need to address the right way to adjust CFR and SP
</del><span class="cx">     jit.pop(MacroAssembler::framePointerRegister);
</span><span class="cx">     
</span><span class="cx">     // At this point we're sitting on the return address - so if we did a jump right now, the
</span><span class="lines">@@ -82,7 +85,6 @@
</span><span class="cx">     // restore all registers.
</span><span class="cx">     
</span><span class="cx">     jit.restoreReturnAddressBeforeReturn(GPRInfo::regT0);
</span><del>-    // FIXME: CStack - Through here
</del><span class="cx"> 
</span><span class="cx">     restoreAllRegisters(jit, buffer);
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCorellintLowLevelInterpreterasm"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/llint/LowLevelInterpreter.asm        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -609,8 +609,8 @@
</span><span class="cx"> 
</span><span class="cx"> if C_LOOP
</span><span class="cx"> else
</span><del>-# void sanitizeStackForVM(VM* vm)
-_sanitizeStackForVM:
</del><ins>+# void sanitizeStackForVMImpl(VM* vm)
+_sanitizeStackForVMImpl:
</ins><span class="cx">     if X86_64
</span><span class="cx">         const vm = t4
</span><span class="cx">         const address = t1
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/Options.h (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/Options.h        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/Options.h        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -129,8 +129,10 @@
</span><span class="cx">     v(bool, verboseFTLFailure, false) \
</span><span class="cx">     v(bool, alwaysComputeHash, false) \
</span><span class="cx">     v(bool, testTheFTL, false) \
</span><ins>+    v(bool, verboseSanitizeStack, false) \
</ins><span class="cx">     \
</span><span class="cx">     v(bool, enableOSREntryToDFG, true) \
</span><ins>+    v(bool, enableOSREntryToFTL, true) \
</ins><span class="cx">     \
</span><span class="cx">     v(bool, useExperimentalFTL, false) \
</span><span class="cx">     v(bool, enableExperimentalFTLCoverage, false) \
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VM.cpp        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -772,12 +772,17 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if ENABLE(LLINT_C_LOOP)
-void sanitizeStackForVM(VM* vm)
</del><ins>+void logSanitizeStack(VM* vm)
</ins><span class="cx"> {
</span><del>-    vm-&gt;interpreter-&gt;stack().sanitizeStack();
</del><ins>+    if (Options::verboseSanitizeStack() &amp;&amp; vm-&gt;topCallFrame) {
+        int dummy;
+        dataLog(
+            &quot;Sanitizing stack with top call frame at &quot;, RawPointer(vm-&gt;topCallFrame),
+            &quot;, current stack pointer at &quot;, RawPointer(&amp;dummy), &quot;, in &quot;,
+            pointerDump(vm-&gt;topCallFrame-&gt;codeBlock()), &quot; and last code origin = &quot;,
+            vm-&gt;topCallFrame-&gt;codeOrigin(), &quot;\n&quot;);
+    }
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> #if ENABLE(REGEXP_TRACING)
</span><span class="cx"> void VM::addRegExpToTrace(RegExp* regExp)
</span></span></pre></div>
<a id="branchesjsCStackSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: branches/jsCStack/Source/JavaScriptCore/runtime/VM.h (162665 => 162666)</h4>
<pre class="diff"><span>
<span class="info">--- branches/jsCStack/Source/JavaScriptCore/runtime/VM.h        2014-01-24 01:15:11 UTC (rev 162665)
+++ branches/jsCStack/Source/JavaScriptCore/runtime/VM.h        2014-01-24 01:18:19 UTC (rev 162666)
</span><span class="lines">@@ -558,13 +558,21 @@
</span><span class="cx">         return &amp;m_vm-&gt;heap;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if ENABLE(LLINT)
</del><ins>+#if !ENABLE(LLINT_C_LOOP)
+    extern &quot;C&quot; void sanitizeStackForVMImpl(VM*);
+#endif
+
+    void logSanitizeStack(VM*);
+
+    ALWAYS_INLINE void sanitizeStackForVM(VM* vm)
+    {
+        logSanitizeStack(vm);
</ins><span class="cx"> #if ENABLE(LLINT_C_LOOP)
</span><del>-    void sanitizeStackForVM(VM*);
</del><ins>+        vm-&gt;interpreter-&gt;stack().sanitizeStack();
</ins><span class="cx"> #else
</span><del>-    extern &quot;C&quot; void sanitizeStackForVM(VM*);
</del><ins>+        sanitizeStackForVMImpl(vm);
</ins><span class="cx"> #endif
</span><del>-#endif
</del><ins>+    }
</ins><span class="cx"> 
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>