<!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>[213302] trunk/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/213302">213302</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2017-03-02 14:06:04 -0800 (Thu, 02 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add Options::alwaysCheckTraps() and Options::usePollingTraps() options.
https://bugs.webkit.org/show_bug.cgi?id=169088

Reviewed by Keith Miller.

Options::alwaysCheckTraps() forces the op_check_traps bytecode to always be
generated.  This is useful for testing purposes until we have signal based
traps, at which point, we will always emit the op_check_traps bytecode and remove
this option.

Options::usePollingTraps() enables the use of polling VM traps all the time.
This will be useful for benchmark comparisons, (between polling and non-polling
traps), as well as for forcing polling traps later for ports that don't support
signal based traps.

Note: signal based traps are not fully implemented yet.  As a result, if the VM
watchdog is in use, we will force Options::usePollingTraps() to be true.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitCheckTraps):
* dfg/DFGClobberize.h:
(JSC::DFG::clobberize):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCheckTraps):
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileCheckTraps):
* runtime/Options.cpp:
(JSC::recomputeDependentOptions):
* runtime/Options.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp">trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGClobberizeh">trunk/Source/JavaScriptCore/dfg/DFGClobberize.h</a></li>
<li><a href="#trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp">trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp</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="#trunkSourceJavaScriptCoreruntimeOptionsh">trunk/Source/JavaScriptCore/runtime/Options.h</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="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2017-03-02  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Add Options::alwaysCheckTraps() and Options::usePollingTraps() options.
+        https://bugs.webkit.org/show_bug.cgi?id=169088
+
+        Reviewed by Keith Miller.
+
+        Options::alwaysCheckTraps() forces the op_check_traps bytecode to always be
+        generated.  This is useful for testing purposes until we have signal based
+        traps, at which point, we will always emit the op_check_traps bytecode and remove
+        this option.
+
+        Options::usePollingTraps() enables the use of polling VM traps all the time.
+        This will be useful for benchmark comparisons, (between polling and non-polling
+        traps), as well as for forcing polling traps later for ports that don't support
+        signal based traps.
+
+        Note: signal based traps are not fully implemented yet.  As a result, if the VM
+        watchdog is in use, we will force Options::usePollingTraps() to be true.
+
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::emitCheckTraps):
+        * dfg/DFGClobberize.h:
+        (JSC::DFG::clobberize):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileCheckTraps):
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::compileNode):
+        (JSC::FTL::DFG::LowerDFGToB3::compileCheckTraps):
+        * runtime/Options.cpp:
+        (JSC::recomputeDependentOptions):
+        * runtime/Options.h:
+
</ins><span class="cx"> 2017-03-02  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix addressing mode for B3WasmAddress
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerBytecodeGeneratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -1274,7 +1274,7 @@
</span><span class="cx"> 
</span><span class="cx"> void BytecodeGenerator::emitCheckTraps()
</span><span class="cx"> {
</span><del>-    if (vm()-&gt;watchdog() || vm()-&gt;needAsynchronousTerminationSupport())
</del><ins>+    if (Options::alwaysCheckTraps() || vm()-&gt;watchdog() || vm()-&gt;needAsynchronousTerminationSupport())
</ins><span class="cx">         emitOpcode(op_check_traps);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGClobberizeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGClobberize.h (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/dfg/DFGClobberize.h        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -434,6 +434,14 @@
</span><span class="cx">         write(JSCell_cellState);
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    case CheckTraps:
+        if (Options::usePollingTraps()) {
+            read(InternalState);
+            write(InternalState);
+        } else
+            write(Watchpoint_fire);
+        return;
+
</ins><span class="cx">     case InvalidationPoint:
</span><span class="cx">         write(SideState);
</span><span class="cx">         def(HeapLocation(InvalidationPointLoc, Watchpoint_fire), LazyNode(node));
</span><span class="lines">@@ -1411,7 +1419,6 @@
</span><span class="cx">         return;
</span><span class="cx">         
</span><span class="cx">     case CountExecution:
</span><del>-    case CheckTraps:
</del><span class="cx">         read(InternalState);
</span><span class="cx">         write(InternalState);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJITcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -1898,6 +1898,7 @@
</span><span class="cx">     
</span><span class="cx"> void SpeculativeJIT::compileCheckTraps(Node*)
</span><span class="cx"> {
</span><ins>+    ASSERT(Options::usePollingTraps());
</ins><span class="cx">     GPRTemporary unused(this);
</span><span class="cx">     GPRReg unusedGPR = unused.gpr();
</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 (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -5544,7 +5544,10 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case CheckTraps:
</span><del>-        compileCheckTraps(node);
</del><ins>+        if (Options::usePollingTraps())
+            compileCheckTraps(node);
+        else
+            noResult(node); // This is a no-op.
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case CountExecution:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoredfgDFGSpeculativeJIT64cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -5328,7 +5328,10 @@
</span><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case CheckTraps:
</span><del>-        compileCheckTraps(node);
</del><ins>+        if (Options::usePollingTraps())
+            compileCheckTraps(node);
+        else
+            noResult(node); // This is a no-op.
</ins><span class="cx">         break;
</span><span class="cx"> 
</span><span class="cx">     case Phantom:
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLowerDFGToB3cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -1023,7 +1023,8 @@
</span><span class="cx">             compileMaterializeCreateActivation();
</span><span class="cx">             break;
</span><span class="cx">         case CheckTraps:
</span><del>-            compileCheckTraps();
</del><ins>+            if (Options::usePollingTraps())
+                compileCheckTraps();
</ins><span class="cx">             break;
</span><span class="cx">         case CreateRest:
</span><span class="cx">             compileCreateRest();
</span><span class="lines">@@ -8986,6 +8987,7 @@
</span><span class="cx"> 
</span><span class="cx">     void compileCheckTraps()
</span><span class="cx">     {
</span><ins>+        ASSERT(Options::usePollingTraps());
</ins><span class="cx">         LBasicBlock needTrapHandling = m_out.newBlock();
</span><span class="cx">         LBasicBlock continuation = m_out.newBlock();
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Options.h (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Options.h        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/runtime/Options.h        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -406,6 +406,8 @@
</span><span class="cx">     v(bool, useSigillCrashAnalyzer, false, Configurable, &quot;logs data about SIGILL crashes&quot;) \
</span><span class="cx">     \
</span><span class="cx">     v(unsigned, watchdog, 0, Normal, &quot;watchdog timeout (0 = Disabled, N = a timeout period of N milliseconds)&quot;) \
</span><ins>+    v(bool, alwaysCheckTraps, false, Normal, &quot;always emit op_check_traps bytecode&quot;) \
+    v(bool, usePollingTraps, false, Normal, &quot;use polling (instead of signalling) VM traps&quot;) \
</ins><span class="cx">     \
</span><span class="cx">     v(bool, useICStats, false, Normal, nullptr) \
</span><span class="cx">     \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -462,6 +462,8 @@
</span><span class="cx"> Watchdog&amp; VM::ensureWatchdog()
</span><span class="cx"> {
</span><span class="cx">     if (!m_watchdog) {
</span><ins>+        Options::usePollingTraps() = true; // Force polling traps on until we have support for signal based traps.
+
</ins><span class="cx">         m_watchdog = adoptRef(new Watchdog(this));
</span><span class="cx">         
</span><span class="cx">         // The LLINT peeks into the Watchdog object directly. In order to do that,
</span><span class="lines">@@ -973,4 +975,10 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void VM::setNeedAsynchronousTerminationSupport()
+{
+    Options::usePollingTraps() = true; // Force polling traps on until we have support for signal based traps.
+    m_needAsynchronousTerminationSupport = true;
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (213301 => 213302)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-02 21:55:55 UTC (rev 213301)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-02 22:06:04 UTC (rev 213302)
</span><span class="lines">@@ -680,7 +680,7 @@
</span><span class="cx">     void notifyNeedWatchdogCheck() { m_traps.fireTrap(VMTraps::NeedWatchdogCheck); }
</span><span class="cx"> 
</span><span class="cx">     bool needAsynchronousTerminationSupport() const { return m_needAsynchronousTerminationSupport; }
</span><del>-    void setNeedAsynchronousTerminationSupport() { m_needAsynchronousTerminationSupport = true; }
</del><ins>+    JS_EXPORT_PRIVATE void setNeedAsynchronousTerminationSupport();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     friend class LLIntOffsetsExtractor;
</span></span></pre>
</div>
</div>

</body>
</html>