<!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>[213202] 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/213202">213202</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2017-02-28 18:54:18 -0800 (Tue, 28 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Change JSLock to stash PlatformThread instead of std::thread::id.
https://bugs.webkit.org/show_bug.cgi?id=168996

Reviewed by Filip Pizlo.

PlatformThread is more useful because it allows us to:
1. find the MachineThreads::Thread which is associated with it.
2. suspend / resume threads.
3. send a signal to a thread.

We can't do those with std::thread::id.  We will need one or more of these
capabilities to implement non-polling VM traps later.

* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/MachineStackMarker.cpp:
(JSC::MachineThreads::Thread::createForCurrentThread):
(JSC::MachineThreads::machineThreadForCurrentThread):
(JSC::MachineThreads::removeThread):
(JSC::MachineThreads::Thread::suspend):
(JSC::MachineThreads::tryCopyOtherThreadStacks):
(JSC::getCurrentPlatformThread): Deleted.
* heap/MachineStackMarker.h:
* runtime/JSCellInlines.h:
(JSC::JSCell::classInfo):
* runtime/JSLock.cpp:
(JSC::JSLock::lock):
(JSC::JSLock::unlock):
(JSC::JSLock::currentThreadIsHoldingLock): Deleted.
* runtime/JSLock.h:
(JSC::JSLock::ownerThread):
(JSC::JSLock::currentThreadIsHoldingLock):
* runtime/PlatformThread.h: Added.
(JSC::currentPlatformThread):
* runtime/VM.cpp:
(JSC::VM::~VM):
* runtime/VM.h:
(JSC::VM::ownerThread):
* runtime/Watchdog.cpp:
(JSC::Watchdog::setTimeLimit):
(JSC::Watchdog::shouldTerminate):
(JSC::Watchdog::startTimer):
(JSC::Watchdog::stopTimer):
* tools/JSDollarVMPrototype.cpp:
(JSC::JSDollarVMPrototype::currentThreadOwnsJSLock):
* tools/VMInspector.cpp:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMachineStackMarkercpp">trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapMachineStackMarkerh">trunk/Source/JavaScriptCore/heap/MachineStackMarker.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSCellInlinesh">trunk/Source/JavaScriptCore/runtime/JSCellInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSLockcpp">trunk/Source/JavaScriptCore/runtime/JSLock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSLockh">trunk/Source/JavaScriptCore/runtime/JSLock.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>
<li><a href="#trunkSourceJavaScriptCoreruntimeWatchdogcpp">trunk/Source/JavaScriptCore/runtime/Watchdog.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretoolsJSDollarVMPrototypecpp">trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretoolsVMInspectorcpp">trunk/Source/JavaScriptCore/tools/VMInspector.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreruntimePlatformThreadh">trunk/Source/JavaScriptCore/runtime/PlatformThread.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -1,5 +1,53 @@
</span><span class="cx"> 2017-02-28  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Change JSLock to stash PlatformThread instead of std::thread::id.
+        https://bugs.webkit.org/show_bug.cgi?id=168996
+
+        Reviewed by Filip Pizlo.
+
+        PlatformThread is more useful because it allows us to:
+        1. find the MachineThreads::Thread which is associated with it.
+        2. suspend / resume threads.
+        3. send a signal to a thread.
+
+        We can't do those with std::thread::id.  We will need one or more of these
+        capabilities to implement non-polling VM traps later.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * heap/MachineStackMarker.cpp:
+        (JSC::MachineThreads::Thread::createForCurrentThread):
+        (JSC::MachineThreads::machineThreadForCurrentThread):
+        (JSC::MachineThreads::removeThread):
+        (JSC::MachineThreads::Thread::suspend):
+        (JSC::MachineThreads::tryCopyOtherThreadStacks):
+        (JSC::getCurrentPlatformThread): Deleted.
+        * heap/MachineStackMarker.h:
+        * runtime/JSCellInlines.h:
+        (JSC::JSCell::classInfo):
+        * runtime/JSLock.cpp:
+        (JSC::JSLock::lock):
+        (JSC::JSLock::unlock):
+        (JSC::JSLock::currentThreadIsHoldingLock): Deleted.
+        * runtime/JSLock.h:
+        (JSC::JSLock::ownerThread):
+        (JSC::JSLock::currentThreadIsHoldingLock):
+        * runtime/PlatformThread.h: Added.
+        (JSC::currentPlatformThread):
+        * runtime/VM.cpp:
+        (JSC::VM::~VM):
+        * runtime/VM.h:
+        (JSC::VM::ownerThread):
+        * runtime/Watchdog.cpp:
+        (JSC::Watchdog::setTimeLimit):
+        (JSC::Watchdog::shouldTerminate):
+        (JSC::Watchdog::startTimer):
+        (JSC::Watchdog::stopTimer):
+        * tools/JSDollarVMPrototype.cpp:
+        (JSC::JSDollarVMPrototype::currentThreadOwnsJSLock):
+        * tools/VMInspector.cpp:
+
+2017-02-28  Mark Lam  &lt;mark.lam@apple.com&gt;
+
</ins><span class="cx">         Enable the SigillCrashAnalyzer by default for iOS.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=168989
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -2421,6 +2421,7 @@
</span><span class="cx">                 FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
</span><span class="cx">                 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */ = {isa = PBXBuildFile; fileRef = FEE43FCD1E6641400077D6D1 /* PlatformThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
</span><span class="cx">                 FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx"> /* End PBXBuildFile section */
</span><span class="lines">@@ -4999,6 +5000,7 @@
</span><span class="cx">                 FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PingPongStackOverflowTest.cpp; path = API/tests/PingPongStackOverflowTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEDA50D51B97F4D9009A3B4F /* PingPongStackOverflowTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingPongStackOverflowTest.h; path = API/tests/PingPongStackOverflowTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                FEE43FCD1E6641400077D6D1 /* PlatformThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformThread.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -6728,6 +6730,7 @@
</span><span class="cx">                                 F692A8780255597D01FF60F7 /* Operations.h */,
</span><span class="cx">                                 0FE228EA1436AB2300196C48 /* Options.cpp */,
</span><span class="cx">                                 0FE228EB1436AB2300196C48 /* Options.h */,
</span><ins>+                                FEE43FCD1E6641400077D6D1 /* PlatformThread.h */,
</ins><span class="cx">                                 868916A9155F285400CB2B9A /* PrivateName.h */,
</span><span class="cx">                                 147341DF1DC2CE9600AA29BA /* ProgramExecutable.cpp */,
</span><span class="cx">                                 147341D31DC02E6D00AA29BA /* ProgramExecutable.h */,
</span><span class="lines">@@ -9167,6 +9170,7 @@
</span><span class="cx">                                 0F4A38FA1C8E13DF00190318 /* SuperSampler.h in Headers */,
</span><span class="cx">                                 705B41AC1A6E501E00716757 /* Symbol.h in Headers */,
</span><span class="cx">                                 705B41AE1A6E501E00716757 /* SymbolConstructor.h in Headers */,
</span><ins>+                                FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */,
</ins><span class="cx">                                 996B73271BDA08EF00331B84 /* SymbolConstructor.lut.h in Headers */,
</span><span class="cx">                                 705B41B01A6E501E00716757 /* SymbolObject.h in Headers */,
</span><span class="cx">                                 705B41B21A6E501E00716757 /* SymbolPrototype.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMachineStackMarkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -179,17 +179,6 @@
</span><span class="cx">     return *manager;
</span><span class="cx"> }
</span><span class="cx">     
</span><del>-static inline PlatformThread getCurrentPlatformThread()
-{
-#if OS(DARWIN)
-    return pthread_mach_thread_np(pthread_self());
-#elif OS(WINDOWS)
-    return GetCurrentThreadId();
-#elif USE(PTHREADS)
-    return pthread_self();
-#endif
-}
-
</del><span class="cx"> MachineThreads::MachineThreads()
</span><span class="cx">     : m_registeredThreads(0)
</span><span class="cx">     , m_threadSpecificForMachineThreads(0)
</span><span class="lines">@@ -214,7 +203,7 @@
</span><span class="cx"> Thread* MachineThreads::Thread::createForCurrentThread()
</span><span class="cx"> {
</span><span class="cx">     auto stackBounds = wtfThreadData().stack();
</span><del>-    return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end());
</del><ins>+    return new Thread(currentPlatformThread(), stackBounds.origin(), stackBounds.end());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MachineThreads::Thread::operator==(const PlatformThread&amp; other) const
</span><span class="lines">@@ -250,7 +239,7 @@
</span><span class="cx"> Thread* MachineThreads::machineThreadForCurrentThread()
</span><span class="cx"> {
</span><span class="cx">     LockHolder lock(m_registeredThreadsMutex);
</span><del>-    PlatformThread platformThread = getCurrentPlatformThread();
</del><ins>+    PlatformThread platformThread = currentPlatformThread();
</ins><span class="cx">     for (Thread* thread = m_registeredThreads; thread; thread = thread-&gt;next) {
</span><span class="cx">         if (*thread == platformThread)
</span><span class="cx">             return thread;
</span><span class="lines">@@ -282,7 +271,7 @@
</span><span class="cx">             return;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        machineThreads-&gt;removeThreadIfFound(getCurrentPlatformThread());
</del><ins>+        machineThreads-&gt;removeThreadIfFound(currentPlatformThread());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -375,7 +364,7 @@
</span><span class="cx">     ASSERT(threadIsSuspended);
</span><span class="cx">     return threadIsSuspended;
</span><span class="cx"> #elif USE(PTHREADS)
</span><del>-    ASSERT_WITH_MESSAGE(getCurrentPlatformThread() != platformThread, &quot;Currently we don't support suspend the current thread itself.&quot;);
</del><ins>+    ASSERT_WITH_MESSAGE(currentPlatformThread() != platformThread, &quot;Currently we don't support suspend the current thread itself.&quot;);
</ins><span class="cx">     {
</span><span class="cx">         // During suspend, suspend or resume should not be executed from the other threads.
</span><span class="cx">         // We use global lock instead of per thread lock.
</span><span class="lines">@@ -948,7 +937,7 @@
</span><span class="cx"> 
</span><span class="cx">     *size = 0;
</span><span class="cx"> 
</span><del>-    PlatformThread currentPlatformThread = getCurrentPlatformThread();
</del><ins>+    PlatformThread platformThread = currentPlatformThread();
</ins><span class="cx">     int numberOfThreads = 0; // Using 0 to denote that we haven't counted the number of threads yet.
</span><span class="cx">     int index = 1;
</span><span class="cx">     Thread* threadsToBeDeleted = nullptr;
</span><span class="lines">@@ -955,7 +944,7 @@
</span><span class="cx"> 
</span><span class="cx">     Thread* previousThread = nullptr;
</span><span class="cx">     for (Thread* thread = m_registeredThreads; thread; index++) {
</span><del>-        if (*thread != currentPlatformThread) {
</del><ins>+        if (*thread != platformThread) {
</ins><span class="cx">             bool success = thread-&gt;suspend();
</span><span class="cx"> #if OS(DARWIN)
</span><span class="cx">             if (!success) {
</span><span class="lines">@@ -999,12 +988,12 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (Thread* thread = m_registeredThreads; thread; thread = thread-&gt;next) {
</span><del>-        if (*thread != currentPlatformThread)
</del><ins>+        if (*thread != platformThread)
</ins><span class="cx">             tryCopyOtherThreadStack(thread, buffer, capacity, size);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (Thread* thread = m_registeredThreads; thread; thread = thread-&gt;next) {
</span><del>-        if (*thread != currentPlatformThread)
</del><ins>+        if (*thread != platformThread)
</ins><span class="cx">             thread-&gt;resume();
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapMachineStackMarkerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/MachineStackMarker.h (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/MachineStackMarker.h        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/heap/MachineStackMarker.h        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -21,6 +21,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include &quot;PlatformThread.h&quot;
</ins><span class="cx"> #include &quot;RegisterState.h&quot;
</span><span class="cx"> #include &lt;wtf/Lock.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="lines">@@ -27,10 +28,6 @@
</span><span class="cx"> #include &lt;wtf/ScopedLambda.h&gt;
</span><span class="cx"> #include &lt;wtf/ThreadSpecific.h&gt;
</span><span class="cx"> 
</span><del>-#if OS(DARWIN)
-#include &lt;mach/thread_act.h&gt;
-#endif
-
</del><span class="cx"> #if USE(PTHREADS) &amp;&amp; !OS(WINDOWS) &amp;&amp; !OS(DARWIN)
</span><span class="cx"> #include &lt;semaphore.h&gt;
</span><span class="cx"> #include &lt;signal.h&gt;
</span><span class="lines">@@ -43,14 +40,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if OS(DARWIN)
-typedef mach_port_t PlatformThread;
-#elif OS(WINDOWS)
-typedef DWORD PlatformThread;
-#elif USE(PTHREADS)
-typedef pthread_t PlatformThread;
-#endif // OS(DARWIN)
-
</del><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> class CodeBlockSet;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSCellInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSCellInlines.h (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSCellInlines.h        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/JSCellInlines.h        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -278,9 +278,9 @@
</span><span class="cx">     // What we really want to assert here is that we're not currently destructing this object (which makes its classInfo
</span><span class="cx">     // invalid). If mutatorState() == MutatorState::Running, then we're not currently sweeping, and therefore cannot be
</span><span class="cx">     // destructing the object. The GC thread or JIT threads, unlike the mutator thread, are able to access classInfo
</span><del>-    // independent of whether the mutator thread is sweeping or not. Hence, we also check for ownerThread() !=
-    // std::this_thread::get_id() to allow the GC thread or JIT threads to pass this assertion.
-    ASSERT(vm.heap.mutatorState() != MutatorState::Sweeping || vm.apiLock().ownerThread() != std::this_thread::get_id());
</del><ins>+    // independent of whether the mutator thread is sweeping or not. Hence, we also check for !currentThreadIsHoldingAPILock()
+    // to allow the GC thread or JIT threads to pass this assertion.
+    ASSERT(vm.heap.mutatorState() != MutatorState::Sweeping || !vm.currentThreadIsHoldingAPILock());
</ins><span class="cx">     return structure(vm)-&gt;classInfo();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSLockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSLock.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSLock.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/JSLock.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -75,8 +75,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSLock::JSLock(VM* vm)
</span><del>-    : m_ownerThreadID(std::thread::id())
-    , m_lockCount(0)
</del><ins>+    : m_lockCount(0)
</ins><span class="cx">     , m_lockDropDepth(0)
</span><span class="cx">     , m_vm(vm)
</span><span class="cx">     , m_entryAtomicStringTable(nullptr)
</span><span class="lines">@@ -110,7 +109,7 @@
</span><span class="cx">         m_lock.lock();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_ownerThreadID = std::this_thread::get_id();
</del><ins>+    m_ownerThread = currentPlatformThread();
</ins><span class="cx">     ASSERT(!m_lockCount);
</span><span class="cx">     m_lockCount = lockCount;
</span><span class="cx"> 
</span><span class="lines">@@ -168,7 +167,7 @@
</span><span class="cx">     m_lockCount -= unlockCount;
</span><span class="cx"> 
</span><span class="cx">     if (!m_lockCount) {
</span><del>-        m_ownerThreadID = std::thread::id();
</del><ins>+        m_ownerThread = { };
</ins><span class="cx">         m_lock.unlock();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -202,11 +201,6 @@
</span><span class="cx">     exec-&gt;vm().apiLock().unlock();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool JSLock::currentThreadIsHoldingLock()
-{
-    return m_ownerThreadID == std::this_thread::get_id();
-}
-
</del><span class="cx"> // This function returns the number of locks that were dropped.
</span><span class="cx"> unsigned JSLock::dropAllLocks(DropAllLocks* dropper)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSLockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSLock.h (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSLock.h        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/JSLock.h        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -20,8 +20,8 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><ins>+#include &quot;PlatformThread.h&quot;
</ins><span class="cx"> #include &lt;mutex&gt;
</span><del>-#include &lt;thread&gt;
</del><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><span class="cx"> #include &lt;wtf/Lock.h&gt;
</span><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="lines">@@ -93,8 +93,8 @@
</span><span class="cx"> 
</span><span class="cx">     VM* vm() { return m_vm; }
</span><span class="cx"> 
</span><del>-    std::thread::id ownerThread() const { return m_ownerThreadID; }
-    JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock();
</del><ins>+    std::optional&lt;PlatformThread&gt; ownerThread() const { return m_ownerThread; }
+    bool currentThreadIsHoldingLock() { return m_ownerThread == currentPlatformThread(); }
</ins><span class="cx"> 
</span><span class="cx">     void willDestroyVM(VM*);
</span><span class="cx"> 
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">     void grabAllLocks(DropAllLocks*, unsigned lockCount);
</span><span class="cx"> 
</span><span class="cx">     Lock m_lock;
</span><del>-    std::thread::id m_ownerThreadID;
</del><ins>+    std::optional&lt;PlatformThread&gt; m_ownerThread;
</ins><span class="cx">     intptr_t m_lockCount;
</span><span class="cx">     unsigned m_lockDropDepth;
</span><span class="cx">     bool m_shouldReleaseHeapAccess;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimePlatformThreadh"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/runtime/PlatformThread.h (0 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/PlatformThread.h                                (rev 0)
+++ trunk/Source/JavaScriptCore/runtime/PlatformThread.h        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if OS(DARWIN) || OS(UNIX)
+#include &lt;pthread.h&gt;
+#endif
+
+#if OS(DARWIN)
+#include &lt;mach/thread_act.h&gt;
+#elif OS(WINDOWS)
+#include &lt;windows.h&gt;
+#endif
+
+namespace JSC {
+
+#if OS(DARWIN)
+typedef mach_port_t PlatformThread;
+#elif OS(WINDOWS)
+typedef DWORD PlatformThread;
+#elif USE(PTHREADS)
+typedef pthread_t PlatformThread;
+#endif // OS(DARWIN)
+    
+inline PlatformThread currentPlatformThread()
+{
+#if OS(DARWIN)
+    return pthread_mach_thread_np(pthread_self());
+#elif OS(WINDOWS)
+    return GetCurrentThreadId();
+#elif USE(PTHREADS)
+    return pthread_self();
+#endif
+}
+
+} // namespace JSC
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/VM.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -392,7 +392,7 @@
</span><span class="cx">     // Clear this first to ensure that nobody tries to remove themselves from it.
</span><span class="cx">     m_perBytecodeProfiler = nullptr;
</span><span class="cx"> 
</span><del>-    ASSERT(m_apiLock-&gt;currentThreadIsHoldingLock());
</del><ins>+    ASSERT(currentThreadIsHoldingAPILock());
</ins><span class="cx">     m_apiLock-&gt;willDestroyVM(this);
</span><span class="cx">     heap.lastChanceToFinalize();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeVMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/VM.h (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/VM.h        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -611,8 +611,6 @@
</span><span class="cx">     RTTraceList* m_rtTraceList;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    std::thread::id ownerThread() const { return m_apiLock-&gt;ownerThread(); }
-
</del><span class="cx">     JS_EXPORT_PRIVATE void resetDateCache();
</span><span class="cx"> 
</span><span class="cx">     RegExpCache* regExpCache() { return m_regExpCache; }
</span><span class="lines">@@ -725,6 +723,8 @@
</span><span class="cx">     bool isSafeToRecurseSoftCLoop() const;
</span><span class="cx"> #endif // !ENABLE(JIT)
</span><span class="cx"> 
</span><ins>+    std::optional&lt;PlatformThread&gt; ownerThread() const { return m_apiLock-&gt;ownerThread(); }
+
</ins><span class="cx">     JS_EXPORT_PRIVATE void throwException(ExecState*, Exception*);
</span><span class="cx">     JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
</span><span class="cx">     JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeWatchdogcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Watchdog.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Watchdog.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/runtime/Watchdog.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> void Watchdog::setTimeLimit(std::chrono::microseconds limit,
</span><span class="cx">     ShouldTerminateCallback callback, void* data1, void* data2)
</span><span class="cx"> {
</span><del>-    ASSERT(m_vm-&gt;ownerThread() == std::this_thread::get_id());
</del><ins>+    ASSERT(m_vm-&gt;currentThreadIsHoldingAPILock());
</ins><span class="cx"> 
</span><span class="cx">     m_timeLimit = limit;
</span><span class="cx">     m_callback = callback;
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool Watchdog::shouldTerminate(ExecState* exec)
</span><span class="cx"> {
</span><del>-    ASSERT(m_vm-&gt;ownerThread() == std::this_thread::get_id());
</del><ins>+    ASSERT(m_vm-&gt;currentThreadIsHoldingAPILock());
</ins><span class="cx">     // FIXME: Will unindent the following before landing. Leaving indented for now to minimize the code diff.
</span><span class="cx">     {
</span><span class="cx">         if (currentWallClockTime() &lt; m_wallClockDeadline)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx"> void Watchdog::startTimer(std::chrono::microseconds timeLimit)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_hasEnteredVM);
</span><del>-    ASSERT(m_vm-&gt;ownerThread() == std::this_thread::get_id());
</del><ins>+    ASSERT(m_vm-&gt;currentThreadIsHoldingAPILock());
</ins><span class="cx">     ASSERT(hasTimeLimit());
</span><span class="cx">     ASSERT(timeLimit &lt;= m_timeLimit);
</span><span class="cx"> 
</span><span class="lines">@@ -168,7 +168,7 @@
</span><span class="cx"> void Watchdog::stopTimer()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_hasEnteredVM);
</span><del>-    ASSERT(m_vm-&gt;ownerThread() == std::this_thread::get_id());
</del><ins>+    ASSERT(m_vm-&gt;currentThreadIsHoldingAPILock());
</ins><span class="cx">     m_cpuDeadline = noTimeLimit;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretoolsJSDollarVMPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     
</span><span class="cx"> bool JSDollarVMPrototype::currentThreadOwnsJSLock(ExecState* exec)
</span><span class="cx"> {
</span><del>-    return exec-&gt;vm().apiLock().currentThreadIsHoldingLock();
</del><ins>+    return exec-&gt;vm().currentThreadIsHoldingAPILock();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool ensureCurrentThreadOwnsJSLock(ExecState* exec)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretoolsVMInspectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tools/VMInspector.cpp (213201 => 213202)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tools/VMInspector.cpp        2017-03-01 02:19:43 UTC (rev 213201)
+++ trunk/Source/JavaScriptCore/tools/VMInspector.cpp        2017-03-01 02:54:18 UTC (rev 213202)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">     CodeBlock* codeBlock = nullptr;
</span><span class="cx">     bool hasTimeout = false;
</span><span class="cx">     iterate([&amp;] (VM&amp; vm) {
</span><del>-        if (!vm.apiLock().currentThreadIsHoldingLock())
</del><ins>+        if (!vm.currentThreadIsHoldingAPILock())
</ins><span class="cx">             return FunctorStatus::Continue;
</span><span class="cx"> 
</span><span class="cx">         // It is safe to call Heap::forEachCodeBlockIgnoringJITPlans here because:
</span></span></pre>
</div>
</div>

</body>
</html>