<!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>[189928] trunk/Source</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/189928">189928</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-09-17 13:26:16 -0700 (Thu, 17 Sep 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>stress/exit-from-getter.js.ftl-eager occasionally traps in debug
https://bugs.webkit.org/show_bug.cgi?id=149096
Reviewed by Geoffrey Garen.
JS calls to getters/setters in get/put inline caches need to reset SP after the call, as our
calling convention requires.
* bytecode/PolymorphicAccess.cpp:
(JSC::AccessCase::generate): Fix the bug.
* ftl/FTLLink.cpp:
(JSC::FTL::link): Adds some verbiage about why the FTL stack offset logic is correct.
* tests/stress/getter-arity.js: Added. Other tests would flaky crash before the patch. This test instacrashes before the patch.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodePolymorphicAccesscpp">trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreftlFTLLinkcpp">trunk/Source/JavaScriptCore/ftl/FTLLink.cpp</a></li>
<li><a href="#trunkSourceWTFbenchmarksLockSpeedTestcpp">trunk/Source/WTF/benchmarks/LockSpeedTest.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoretestsstressgetterarityjs">trunk/Source/JavaScriptCore/tests/stress/getter-arity.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (189927 => 189928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-09-17 20:18:10 UTC (rev 189927)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-09-17 20:26:16 UTC (rev 189928)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-09-17 Filip Pizlo <fpizlo@apple.com>
+
+ stress/exit-from-getter.js.ftl-eager occasionally traps in debug
+ https://bugs.webkit.org/show_bug.cgi?id=149096
+
+ Reviewed by Geoffrey Garen.
+
+ JS calls to getters/setters in get/put inline caches need to reset SP after the call, as our
+ calling convention requires.
+
+ * bytecode/PolymorphicAccess.cpp:
+ (JSC::AccessCase::generate): Fix the bug.
+ * ftl/FTLLink.cpp:
+ (JSC::FTL::link): Adds some verbiage about why the FTL stack offset logic is correct.
+ * tests/stress/getter-arity.js: Added. Other tests would flaky crash before the patch. This test instacrashes before the patch.
+
</ins><span class="cx"> 2015-09-17 Saam barati <sbarati@apple.com>
</span><span class="cx">
</span><span class="cx"> Interpreter::unwind() shouldn't be responsible for filtering out uncatchable exceptions
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodePolymorphicAccesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp (189927 => 189928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp        2015-09-17 20:18:10 UTC (rev 189927)
+++ trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp        2015-09-17 20:26:16 UTC (rev 189928)
</span><span class="lines">@@ -625,6 +625,11 @@
</span><span class="cx">
</span><span class="cx"> done.link(&jit);
</span><span class="cx">
</span><ins>+ jit.addPtr(
+ CCallHelpers::TrustedImm32(
+ jit.codeBlock()->stackPointerOffset() * sizeof(Register)),
+ GPRInfo::callFrameRegister, CCallHelpers::stackPointerRegister);
+
</ins><span class="cx"> state.callbacks.append(
</span><span class="cx"> [=, &vm] (LinkBuffer& linkBuffer) {
</span><span class="cx"> m_rareData->callLinkInfo->setCallLocations(
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreftlFTLLinkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ftl/FTLLink.cpp (189927 => 189928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ftl/FTLLink.cpp        2015-09-17 20:18:10 UTC (rev 189927)
+++ trunk/Source/JavaScriptCore/ftl/FTLLink.cpp        2015-09-17 20:26:16 UTC (rev 189928)
</span><span class="lines">@@ -52,7 +52,31 @@
</span><span class="cx">
</span><span class="cx"> // LLVM will create its own jump tables as needed.
</span><span class="cx"> codeBlock->clearSwitchJumpTables();
</span><del>-
</del><ins>+
+ // What LLVM's stackmaps call stackSizeForLocals and what we call frameRegisterCount have a simple
+ // relationship, though it's not obvious from reading the code. The easiest way to understand them
+ // is to look at stackOffset, i.e. what you have to add to FP to get SP. For LLVM that is just:
+ //
+ // stackOffset == -state.jitCode->stackmaps.stackSizeForLocals()
+ //
+ // The way we define frameRegisterCount is that it satisfies this equality:
+ //
+ // stackOffset == virtualRegisterForLocal(frameRegisterCount - 1).offset() * sizeof(Register)
+ //
+ // We can simplify this when we apply virtualRegisterForLocal():
+ //
+ // stackOffset == (-1 - (frameRegisterCount - 1)) * sizeof(Register)
+ // stackOffset == (-1 - frameRegisterCount + 1) * sizeof(Register)
+ // stackOffset == -frameRegisterCount * sizeof(Register)
+ //
+ // Therefore we just have:
+ //
+ // frameRegisterCount == -stackOffset / sizeof(Register)
+ //
+ // If we substitute what we have above, we get:
+ //
+ // frameRegisterCount == -(-state.jitCode->stackmaps.stackSizeForLocals()) / sizeof(Register)
+ // frameRegisterCount == state.jitCode->stackmaps.stackSizeForLocals() / sizeof(Register)
</ins><span class="cx"> state.jitCode->common.frameRegisterCount = state.jitCode->stackmaps.stackSizeForLocals() / sizeof(void*);
</span><span class="cx">
</span><span class="cx"> state.jitCode->common.requiredRegisterCountForExit = graph.requiredRegisterCountForExit();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressgetterarityjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/getter-arity.js (0 => 189928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/getter-arity.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/getter-arity.js        2015-09-17 20:26:16 UTC (rev 189928)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+var o = {};
+o.__defineGetter__("f", function(a, b, c, d, e, f) { return 42; });
+for (var i = 0; i < 10000; ++i) {
+ var result = o.f;
+ if (result != 42)
+ throw "Error: bad result: " + result;
+}
</ins></span></pre></div>
<a id="trunkSourceWTFbenchmarksLockSpeedTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/benchmarks/LockSpeedTest.cpp (189927 => 189928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/benchmarks/LockSpeedTest.cpp        2015-09-17 20:18:10 UTC (rev 189927)
+++ trunk/Source/WTF/benchmarks/LockSpeedTest.cpp        2015-09-17 20:26:16 UTC (rev 189928)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><span class="cx">
</span><ins>+#include <thread>
</ins><span class="cx"> #include <unistd.h>
</span><span class="cx"> #include <wtf/CurrentTime.h>
</span><span class="cx"> #include <wtf/Lock.h>
</span><span class="lines">@@ -67,15 +68,42 @@
</span><span class="cx"> Atomic<unsigned> m_lock;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+class ByteSpinLock {
+public:
+ ByteSpinLock()
+ {
+ m_lock.store(0, std::memory_order_relaxed);
+ }
+
+ void lock()
+ {
+ while (!m_lock.compareExchangeWeak(0, 1, std::memory_order_acquire))
+ std::this_thread::yield();
+ }
+
+ void unlock()
+ {
+ m_lock.store(0, std::memory_order_release);
+ }
+
+ bool isLocked() const
+ {
+ return m_lock.load(std::memory_order_acquire);
+ }
+
+private:
+ Atomic<uint8_t> m_lock;
+};
+
</ins><span class="cx"> unsigned numThreadGroups;
</span><span class="cx"> unsigned numThreadsPerGroup;
</span><del>-unsigned workPerCriticalSection;
</del><ins>+int workPerCriticalSection;
</ins><span class="cx"> unsigned numNoiseThreads;
</span><span class="cx"> unsigned numIterations;
</span><span class="cx">
</span><span class="cx"> NO_RETURN void usage()
</span><span class="cx"> {
</span><del>- printf("Usage: LockSpeedTest spinlock|wordlock|lock|mutex|all <num thread groups> <num threads per group> <work per critical section> <num noise threads> <num iterations>\n");
</del><ins>+ printf("Usage: LockSpeedTest spinlock|bytespinlock|wordlock|lock|mutex|all <num thread groups> <num threads per group> <work per critical section> <num noise threads> <num iterations>\n");
</ins><span class="cx"> exit(1);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -110,9 +138,13 @@
</span><span class="cx"> [threadGroupIndex, &locks, &words] () {
</span><span class="cx"> for (unsigned i = numIterations; i--;) {
</span><span class="cx"> locks[threadGroupIndex].lock();
</span><del>- for (unsigned j = workPerCriticalSection; j--;) {
- words[threadGroupIndex]++;
- words[threadGroupIndex] *= 1.01;
</del><ins>+ if (workPerCriticalSection < 0)
+ sleep(-workPerCriticalSection);
+ else {
+ for (unsigned j = workPerCriticalSection; j--;) {
+ words[threadGroupIndex]++;
+ words[threadGroupIndex] *= 1.01;
+ }
</ins><span class="cx"> }
</span><span class="cx"> locks[threadGroupIndex].unlock();
</span><span class="cx"> }
</span><span class="lines">@@ -143,7 +175,7 @@
</span><span class="cx"> if (argc != 7
</span><span class="cx"> || sscanf(argv[2], "%u", &numThreadGroups) != 1
</span><span class="cx"> || sscanf(argv[3], "%u", &numThreadsPerGroup) != 1
</span><del>- || sscanf(argv[4], "%u", &workPerCriticalSection) != 1
</del><ins>+ || sscanf(argv[4], "%d", &workPerCriticalSection) != 1
</ins><span class="cx"> || sscanf(argv[5], "%u", &numNoiseThreads) != 1
</span><span class="cx"> || sscanf(argv[6], "%u", &numIterations) != 1)
</span><span class="cx"> usage();
</span><span class="lines">@@ -153,6 +185,10 @@
</span><span class="cx"> runBenchmark<SpinLock>("SpinLock");
</span><span class="cx"> didRun = true;
</span><span class="cx"> }
</span><ins>+ if (!strcmp(argv[1], "bytespinlock") || !strcmp(argv[1], "all")) {
+ runBenchmark<SpinLock>("ByteSpinLock");
+ didRun = true;
+ }
</ins><span class="cx"> if (!strcmp(argv[1], "wordlock") || !strcmp(argv[1], "all")) {
</span><span class="cx"> runBenchmark<WordLock>("WTF WordLock");
</span><span class="cx"> didRun = true;
</span></span></pre>
</div>
</div>
</body>
</html>