Title: [213238] trunk/Source/_javascript_Core
Revision
213238
Author
[email protected]
Date
2017-03-01 12:15:08 -0800 (Wed, 01 Mar 2017)

Log Message

[Re-landing] Change JSLock to stash PlatformThread instead of std::thread::id.
https://bugs.webkit.org/show_bug.cgi?id=168996

Reviewed by Filip Pizlo and Saam Barati.

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.

Update: Since we don't have a canonical "uninitialized" value for PlatformThread,
we now have a JSLock::m_hasOwnerThread flag that is set to true if and only the
m_ownerThread value is valid.  JSLock::currentThreadIsHoldingLock() now checks
JSLock::m_hasOwnerThread before doing the thread identity comparison.

* _javascript_Core.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::JSLock):
(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:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (213237 => 213238)


--- trunk/Source/_javascript_Core/ChangeLog	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-03-01 20:15:08 UTC (rev 213238)
@@ -1,3 +1,57 @@
+2017-03-01  Mark Lam  <[email protected]>
+
+        [Re-landing] Change JSLock to stash PlatformThread instead of std::thread::id.
+        https://bugs.webkit.org/show_bug.cgi?id=168996
+
+        Reviewed by Filip Pizlo and Saam Barati.
+
+        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.
+
+        Update: Since we don't have a canonical "uninitialized" value for PlatformThread,
+        we now have a JSLock::m_hasOwnerThread flag that is set to true if and only the
+        m_ownerThread value is valid.  JSLock::currentThreadIsHoldingLock() now checks
+        JSLock::m_hasOwnerThread before doing the thread identity comparison.
+
+        * _javascript_Core.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::JSLock):
+        (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-03-01  Saam Barati  <[email protected]>
 
         Implement a mega-disassembler that'll be used in the FTL

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (213237 => 213238)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-03-01 20:15:08 UTC (rev 213238)
@@ -2423,6 +2423,7 @@
 		FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
 		FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */ = {isa = PBXBuildFile; fileRef = FEE43FCD1E6641400077D6D1 /* PlatformThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
 		FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
@@ -5003,6 +5004,7 @@
 		FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = "<group>"; };
 		FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PingPongStackOverflowTest.cpp; path = API/tests/PingPongStackOverflowTest.cpp; sourceTree = "<group>"; };
 		FEDA50D51B97F4D9009A3B4F /* PingPongStackOverflowTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingPongStackOverflowTest.h; path = API/tests/PingPongStackOverflowTest.h; sourceTree = "<group>"; };
+		FEE43FCD1E6641400077D6D1 /* PlatformThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformThread.h; sourceTree = "<group>"; };
 		FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
 		FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
 		FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = "<group>"; };
@@ -6732,6 +6734,7 @@
 				F692A8780255597D01FF60F7 /* Operations.h */,
 				0FE228EA1436AB2300196C48 /* Options.cpp */,
 				0FE228EB1436AB2300196C48 /* Options.h */,
+				FEE43FCD1E6641400077D6D1 /* PlatformThread.h */,
 				868916A9155F285400CB2B9A /* PrivateName.h */,
 				147341DF1DC2CE9600AA29BA /* ProgramExecutable.cpp */,
 				147341D31DC02E6D00AA29BA /* ProgramExecutable.h */,
@@ -9174,6 +9177,7 @@
 				0F4A38FA1C8E13DF00190318 /* SuperSampler.h in Headers */,
 				705B41AC1A6E501E00716757 /* Symbol.h in Headers */,
 				705B41AE1A6E501E00716757 /* SymbolConstructor.h in Headers */,
+				FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */,
 				996B73271BDA08EF00331B84 /* SymbolConstructor.lut.h in Headers */,
 				705B41B01A6E501E00716757 /* SymbolObject.h in Headers */,
 				705B41B21A6E501E00716757 /* SymbolPrototype.h in Headers */,

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -179,17 +179,6 @@
     return *manager;
 }
     
-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
-}
-
 MachineThreads::MachineThreads()
     : m_registeredThreads(0)
     , m_threadSpecificForMachineThreads(0)
@@ -214,7 +203,7 @@
 Thread* MachineThreads::Thread::createForCurrentThread()
 {
     auto stackBounds = wtfThreadData().stack();
-    return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end());
+    return new Thread(currentPlatformThread(), stackBounds.origin(), stackBounds.end());
 }
 
 bool MachineThreads::Thread::operator==(const PlatformThread& other) const
@@ -250,7 +239,7 @@
 Thread* MachineThreads::machineThreadForCurrentThread()
 {
     LockHolder lock(m_registeredThreadsMutex);
-    PlatformThread platformThread = getCurrentPlatformThread();
+    PlatformThread platformThread = currentPlatformThread();
     for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
         if (*thread == platformThread)
             return thread;
@@ -282,7 +271,7 @@
             return;
 #endif
 
-        machineThreads->removeThreadIfFound(getCurrentPlatformThread());
+        machineThreads->removeThreadIfFound(currentPlatformThread());
     }
 }
 
@@ -375,7 +364,7 @@
     ASSERT(threadIsSuspended);
     return threadIsSuspended;
 #elif USE(PTHREADS)
-    ASSERT_WITH_MESSAGE(getCurrentPlatformThread() != platformThread, "Currently we don't support suspend the current thread itself.");
+    ASSERT_WITH_MESSAGE(currentPlatformThread() != platformThread, "Currently we don't support suspend the current thread itself.");
     {
         // During suspend, suspend or resume should not be executed from the other threads.
         // We use global lock instead of per thread lock.
@@ -948,7 +937,7 @@
 
     *size = 0;
 
-    PlatformThread currentPlatformThread = getCurrentPlatformThread();
+    PlatformThread platformThread = currentPlatformThread();
     int numberOfThreads = 0; // Using 0 to denote that we haven't counted the number of threads yet.
     int index = 1;
     Thread* threadsToBeDeleted = nullptr;
@@ -955,7 +944,7 @@
 
     Thread* previousThread = nullptr;
     for (Thread* thread = m_registeredThreads; thread; index++) {
-        if (*thread != currentPlatformThread) {
+        if (*thread != platformThread) {
             bool success = thread->suspend();
 #if OS(DARWIN)
             if (!success) {
@@ -999,12 +988,12 @@
     }
 
     for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
-        if (*thread != currentPlatformThread)
+        if (*thread != platformThread)
             tryCopyOtherThreadStack(thread, buffer, capacity, size);
     }
 
     for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
-        if (*thread != currentPlatformThread)
+        if (*thread != platformThread)
             thread->resume();
     }
 

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (213237 => 213238)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2017-03-01 20:15:08 UTC (rev 213238)
@@ -21,6 +21,7 @@
 
 #pragma once
 
+#include "PlatformThread.h"
 #include "RegisterState.h"
 #include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
@@ -27,10 +28,6 @@
 #include <wtf/ScopedLambda.h>
 #include <wtf/ThreadSpecific.h>
 
-#if OS(DARWIN)
-#include <mach/thread_act.h>
-#endif
-
 #if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
 #include <semaphore.h>
 #include <signal.h>
@@ -43,14 +40,6 @@
 #endif
 #endif
 
-#if OS(DARWIN)
-typedef mach_port_t PlatformThread;
-#elif OS(WINDOWS)
-typedef DWORD PlatformThread;
-#elif USE(PTHREADS)
-typedef pthread_t PlatformThread;
-#endif // OS(DARWIN)
-
 namespace JSC {
 
 class CodeBlockSet;

Modified: trunk/Source/_javascript_Core/runtime/JSCellInlines.h (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/JSCellInlines.h	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/JSCellInlines.h	2017-03-01 20:15:08 UTC (rev 213238)
@@ -278,9 +278,9 @@
     // What we really want to assert here is that we're not currently destructing this object (which makes its classInfo
     // invalid). If mutatorState() == MutatorState::Running, then we're not currently sweeping, and therefore cannot be
     // destructing the object. The GC thread or JIT threads, unlike the mutator thread, are able to access classInfo
-    // 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());
+    // 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());
     return structure(vm)->classInfo();
 }
 

Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/JSLock.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -75,8 +75,7 @@
 }
 
 JSLock::JSLock(VM* vm)
-    : m_ownerThreadID(std::thread::id())
-    , m_lockCount(0)
+    : m_lockCount(0)
     , m_lockDropDepth(0)
     , m_vm(vm)
     , m_entryAtomicStringTable(nullptr)
@@ -110,7 +109,9 @@
         m_lock.lock();
     }
 
-    m_ownerThreadID = std::this_thread::get_id();
+    m_ownerThread = currentPlatformThread();
+    WTF::storeStoreFence();
+    m_hasOwnerThread = true;
     ASSERT(!m_lockCount);
     m_lockCount = lockCount;
 
@@ -168,7 +169,7 @@
     m_lockCount -= unlockCount;
 
     if (!m_lockCount) {
-        m_ownerThreadID = std::thread::id();
+        m_hasOwnerThread = false;
         m_lock.unlock();
     }
 }
@@ -202,11 +203,6 @@
     exec->vm().apiLock().unlock();
 }
 
-bool JSLock::currentThreadIsHoldingLock()
-{
-    return m_ownerThreadID == std::this_thread::get_id();
-}
-
 // This function returns the number of locks that were dropped.
 unsigned JSLock::dropAllLocks(DropAllLocks* dropper)
 {

Modified: trunk/Source/_javascript_Core/runtime/JSLock.h (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/JSLock.h	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/JSLock.h	2017-03-01 20:15:08 UTC (rev 213238)
@@ -20,8 +20,8 @@
 
 #pragma once
 
+#include "PlatformThread.h"
 #include <mutex>
-#include <thread>
 #include <wtf/Assertions.h>
 #include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
@@ -93,8 +93,13 @@
 
     VM* vm() { return m_vm; }
 
-    std::thread::id ownerThread() const { return m_ownerThreadID; }
-    JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock();
+    std::optional<PlatformThread> ownerThread() const
+    {
+        if (m_hasOwnerThread)
+            return m_ownerThread;
+        return { };
+    }
+    bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread == currentPlatformThread(); }
 
     void willDestroyVM(VM*);
 
@@ -126,7 +131,12 @@
     void grabAllLocks(DropAllLocks*, unsigned lockCount);
 
     Lock m_lock;
-    std::thread::id m_ownerThreadID;
+    // We cannot make m_ownerThread an optional (instead of pairing it with an explicit
+    // m_hasOwnerThread) because currentThreadIsHoldingLock() may be called from a
+    // different thread, and an optional is vulnerable to races.
+    // See https://bugs.webkit.org/show_bug.cgi?id=169042#c6
+    bool m_hasOwnerThread { false };
+    PlatformThread m_ownerThread;
     intptr_t m_lockCount;
     unsigned m_lockDropDepth;
     bool m_shouldReleaseHeapAccess;

Added: trunk/Source/_javascript_Core/runtime/PlatformThread.h (0 => 213238)


--- trunk/Source/_javascript_Core/runtime/PlatformThread.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/runtime/PlatformThread.h	2017-03-01 20:15:08 UTC (rev 213238)
@@ -0,0 +1,59 @@
+/*
+ * 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 <pthread.h>
+#endif
+
+#if OS(DARWIN)
+#include <mach/thread_act.h>
+#elif OS(WINDOWS)
+#include <windows.h>
+#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

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -392,7 +392,7 @@
     // Clear this first to ensure that nobody tries to remove themselves from it.
     m_perBytecodeProfiler = nullptr;
 
-    ASSERT(m_apiLock->currentThreadIsHoldingLock());
+    ASSERT(currentThreadIsHoldingAPILock());
     m_apiLock->willDestroyVM(this);
     heap.lastChanceToFinalize();
 

Modified: trunk/Source/_javascript_Core/runtime/VM.h (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/VM.h	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2017-03-01 20:15:08 UTC (rev 213238)
@@ -611,8 +611,6 @@
     RTTraceList* m_rtTraceList;
 #endif
 
-    std::thread::id ownerThread() const { return m_apiLock->ownerThread(); }
-
     JS_EXPORT_PRIVATE void resetDateCache();
 
     RegExpCache* regExpCache() { return m_regExpCache; }
@@ -725,6 +723,8 @@
     bool isSafeToRecurseSoftCLoop() const;
 #endif // !ENABLE(JIT)
 
+    std::optional<PlatformThread> ownerThread() const { return m_apiLock->ownerThread(); }
+
     JS_EXPORT_PRIVATE void throwException(ExecState*, Exception*);
     JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
     JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);

Modified: trunk/Source/_javascript_Core/runtime/Watchdog.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/runtime/Watchdog.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -55,7 +55,7 @@
 void Watchdog::setTimeLimit(std::chrono::microseconds limit,
     ShouldTerminateCallback callback, void* data1, void* data2)
 {
-    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
+    ASSERT(m_vm->currentThreadIsHoldingAPILock());
 
     m_timeLimit = limit;
     m_callback = callback;
@@ -68,7 +68,7 @@
 
 bool Watchdog::shouldTerminate(ExecState* exec)
 {
-    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
+    ASSERT(m_vm->currentThreadIsHoldingAPILock());
     // FIXME: Will unindent the following before landing. Leaving indented for now to minimize the code diff.
     {
         if (currentWallClockTime() < m_wallClockDeadline)
@@ -138,7 +138,7 @@
 void Watchdog::startTimer(std::chrono::microseconds timeLimit)
 {
     ASSERT(m_hasEnteredVM);
-    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
+    ASSERT(m_vm->currentThreadIsHoldingAPILock());
     ASSERT(hasTimeLimit());
     ASSERT(timeLimit <= m_timeLimit);
 
@@ -168,7 +168,7 @@
 void Watchdog::stopTimer()
 {
     ASSERT(m_hasEnteredVM);
-    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
+    ASSERT(m_vm->currentThreadIsHoldingAPILock());
     m_cpuDeadline = noTimeLimit;
 }
 

Modified: trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -44,7 +44,7 @@
     
 bool JSDollarVMPrototype::currentThreadOwnsJSLock(ExecState* exec)
 {
-    return exec->vm().apiLock().currentThreadIsHoldingLock();
+    return exec->vm().currentThreadIsHoldingAPILock();
 }
 
 static bool ensureCurrentThreadOwnsJSLock(ExecState* exec)

Modified: trunk/Source/_javascript_Core/tools/VMInspector.cpp (213237 => 213238)


--- trunk/Source/_javascript_Core/tools/VMInspector.cpp	2017-03-01 20:03:18 UTC (rev 213237)
+++ trunk/Source/_javascript_Core/tools/VMInspector.cpp	2017-03-01 20:15:08 UTC (rev 213238)
@@ -139,7 +139,7 @@
     CodeBlock* codeBlock = nullptr;
     bool hasTimeout = false;
     iterate([&] (VM& vm) {
-        if (!vm.apiLock().currentThreadIsHoldingLock())
+        if (!vm.currentThreadIsHoldingAPILock())
             return FunctorStatus::Continue;
 
         // It is safe to call Heap::forEachCodeBlockIgnoringJITPlans here because:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to