Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (213230 => 213231)
--- trunk/Source/_javascript_Core/ChangeLog 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-03-01 18:51:02 UTC (rev 213231)
@@ -1,5 +1,47 @@
2017-03-01 Mark Lam <[email protected]>
+ REGRESSION (r213202?): Assertion failed: (!"initialized()"), function operator().
+ https://bugs.webkit.org/show_bug.cgi?id=169042
+
+ Not reviewed.
+
+ Rolling out r213229 and r213202.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * heap/MachineStackMarker.cpp:
+ (JSC::getCurrentPlatformThread):
+ (JSC::MachineThreads::Thread::createForCurrentThread):
+ (JSC::MachineThreads::machineThreadForCurrentThread):
+ (JSC::MachineThreads::removeThread):
+ (JSC::MachineThreads::Thread::suspend):
+ (JSC::MachineThreads::tryCopyOtherThreadStacks):
+ * heap/MachineStackMarker.h:
+ * runtime/JSCellInlines.h:
+ (JSC::JSCell::classInfo):
+ * runtime/JSLock.cpp:
+ (JSC::JSLock::JSLock):
+ (JSC::JSLock::lock):
+ (JSC::JSLock::unlock):
+ (JSC::JSLock::currentThreadIsHoldingLock):
+ * runtime/JSLock.h:
+ (JSC::JSLock::ownerThread):
+ (JSC::JSLock::currentThreadIsHoldingLock): Deleted.
+ * runtime/PlatformThread.h: Removed.
+ * 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 Mark Lam <[email protected]>
+
REGRESSION (r213202?): Assertion failed: (!"initialized()"), function operator()
https://bugs.webkit.org/show_bug.cgi?id=169042
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (213230 => 213231)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-03-01 18:51:02 UTC (rev 213231)
@@ -2423,7 +2423,6 @@
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 */
@@ -5004,7 +5003,6 @@
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>"; };
@@ -6734,7 +6732,6 @@
F692A8780255597D01FF60F7 /* Operations.h */,
0FE228EA1436AB2300196C48 /* Options.cpp */,
0FE228EB1436AB2300196C48 /* Options.h */,
- FEE43FCD1E6641400077D6D1 /* PlatformThread.h */,
868916A9155F285400CB2B9A /* PrivateName.h */,
147341DF1DC2CE9600AA29BA /* ProgramExecutable.cpp */,
147341D31DC02E6D00AA29BA /* ProgramExecutable.h */,
@@ -9177,7 +9174,6 @@
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 (213230 => 213231)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -179,6 +179,17 @@
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)
@@ -203,7 +214,7 @@
Thread* MachineThreads::Thread::createForCurrentThread()
{
auto stackBounds = wtfThreadData().stack();
- return new Thread(currentPlatformThread(), stackBounds.origin(), stackBounds.end());
+ return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end());
}
bool MachineThreads::Thread::operator==(const PlatformThread& other) const
@@ -239,7 +250,7 @@
Thread* MachineThreads::machineThreadForCurrentThread()
{
LockHolder lock(m_registeredThreadsMutex);
- PlatformThread platformThread = currentPlatformThread();
+ PlatformThread platformThread = getCurrentPlatformThread();
for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
if (*thread == platformThread)
return thread;
@@ -271,7 +282,7 @@
return;
#endif
- machineThreads->removeThreadIfFound(currentPlatformThread());
+ machineThreads->removeThreadIfFound(getCurrentPlatformThread());
}
}
@@ -364,7 +375,7 @@
ASSERT(threadIsSuspended);
return threadIsSuspended;
#elif USE(PTHREADS)
- ASSERT_WITH_MESSAGE(currentPlatformThread() != platformThread, "Currently we don't support suspend the current thread itself.");
+ ASSERT_WITH_MESSAGE(getCurrentPlatformThread() != 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.
@@ -937,7 +948,7 @@
*size = 0;
- PlatformThread platformThread = currentPlatformThread();
+ PlatformThread currentPlatformThread = getCurrentPlatformThread();
int numberOfThreads = 0; // Using 0 to denote that we haven't counted the number of threads yet.
int index = 1;
Thread* threadsToBeDeleted = nullptr;
@@ -944,7 +955,7 @@
Thread* previousThread = nullptr;
for (Thread* thread = m_registeredThreads; thread; index++) {
- if (*thread != platformThread) {
+ if (*thread != currentPlatformThread) {
bool success = thread->suspend();
#if OS(DARWIN)
if (!success) {
@@ -988,12 +999,12 @@
}
for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
- if (*thread != platformThread)
+ if (*thread != currentPlatformThread)
tryCopyOtherThreadStack(thread, buffer, capacity, size);
}
for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
- if (*thread != platformThread)
+ if (*thread != currentPlatformThread)
thread->resume();
}
Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (213230 => 213231)
--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h 2017-03-01 18:51:02 UTC (rev 213231)
@@ -21,7 +21,6 @@
#pragma once
-#include "PlatformThread.h"
#include "RegisterState.h"
#include <wtf/Lock.h>
#include <wtf/Noncopyable.h>
@@ -28,6 +27,10 @@
#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>
@@ -40,6 +43,14 @@
#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 (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/JSCellInlines.h 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/JSCellInlines.h 2017-03-01 18:51:02 UTC (rev 213231)
@@ -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 !currentThreadIsHoldingAPILock()
- // to allow the GC thread or JIT threads to pass this assertion.
- ASSERT(vm.heap.mutatorState() != MutatorState::Sweeping || !vm.currentThreadIsHoldingAPILock());
+ // 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());
return structure(vm)->classInfo();
}
Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/JSLock.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -75,7 +75,8 @@
}
JSLock::JSLock(VM* vm)
- : m_lockCount(0)
+ : m_ownerThreadID(std::thread::id())
+ , m_lockCount(0)
, m_lockDropDepth(0)
, m_vm(vm)
, m_entryAtomicStringTable(nullptr)
@@ -109,7 +110,7 @@
m_lock.lock();
}
- m_ownerThread = currentPlatformThread();
+ m_ownerThreadID = std::this_thread::get_id();
ASSERT(!m_lockCount);
m_lockCount = lockCount;
@@ -167,7 +168,7 @@
m_lockCount -= unlockCount;
if (!m_lockCount) {
- m_ownerThread = { };
+ m_ownerThreadID = std::thread::id();
m_lock.unlock();
}
}
@@ -201,6 +202,11 @@
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 (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/JSLock.h 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/JSLock.h 2017-03-01 18:51:02 UTC (rev 213231)
@@ -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,8 @@
VM* vm() { return m_vm; }
- std::optional<PlatformThread> ownerThread() const { return m_ownerThread; }
- bool currentThreadIsHoldingLock() { return m_ownerThread && m_ownerThread == currentPlatformThread(); }
+ std::thread::id ownerThread() const { return m_ownerThreadID; }
+ JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock();
void willDestroyVM(VM*);
@@ -126,7 +126,7 @@
void grabAllLocks(DropAllLocks*, unsigned lockCount);
Lock m_lock;
- std::optional<PlatformThread> m_ownerThread;
+ std::thread::id m_ownerThreadID;
intptr_t m_lockCount;
unsigned m_lockDropDepth;
bool m_shouldReleaseHeapAccess;
Deleted: trunk/Source/_javascript_Core/runtime/PlatformThread.h (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/PlatformThread.h 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/PlatformThread.h 2017-03-01 18:51:02 UTC (rev 213231)
@@ -1,59 +0,0 @@
-/*
- * 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 (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/VM.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -392,7 +392,7 @@
// Clear this first to ensure that nobody tries to remove themselves from it.
m_perBytecodeProfiler = nullptr;
- ASSERT(currentThreadIsHoldingAPILock());
+ ASSERT(m_apiLock->currentThreadIsHoldingLock());
m_apiLock->willDestroyVM(this);
heap.lastChanceToFinalize();
Modified: trunk/Source/_javascript_Core/runtime/VM.h (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/VM.h 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2017-03-01 18:51:02 UTC (rev 213231)
@@ -611,6 +611,8 @@
RTTraceList* m_rtTraceList;
#endif
+ std::thread::id ownerThread() const { return m_apiLock->ownerThread(); }
+
JS_EXPORT_PRIVATE void resetDateCache();
RegExpCache* regExpCache() { return m_regExpCache; }
@@ -723,8 +725,6 @@
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 (213230 => 213231)
--- trunk/Source/_javascript_Core/runtime/Watchdog.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/runtime/Watchdog.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -55,7 +55,7 @@
void Watchdog::setTimeLimit(std::chrono::microseconds limit,
ShouldTerminateCallback callback, void* data1, void* data2)
{
- ASSERT(m_vm->currentThreadIsHoldingAPILock());
+ ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
m_timeLimit = limit;
m_callback = callback;
@@ -68,7 +68,7 @@
bool Watchdog::shouldTerminate(ExecState* exec)
{
- ASSERT(m_vm->currentThreadIsHoldingAPILock());
+ ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
// 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->currentThreadIsHoldingAPILock());
+ ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
ASSERT(hasTimeLimit());
ASSERT(timeLimit <= m_timeLimit);
@@ -168,7 +168,7 @@
void Watchdog::stopTimer()
{
ASSERT(m_hasEnteredVM);
- ASSERT(m_vm->currentThreadIsHoldingAPILock());
+ ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
m_cpuDeadline = noTimeLimit;
}
Modified: trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp (213230 => 213231)
--- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -44,7 +44,7 @@
bool JSDollarVMPrototype::currentThreadOwnsJSLock(ExecState* exec)
{
- return exec->vm().currentThreadIsHoldingAPILock();
+ return exec->vm().apiLock().currentThreadIsHoldingLock();
}
static bool ensureCurrentThreadOwnsJSLock(ExecState* exec)
Modified: trunk/Source/_javascript_Core/tools/VMInspector.cpp (213230 => 213231)
--- trunk/Source/_javascript_Core/tools/VMInspector.cpp 2017-03-01 18:47:49 UTC (rev 213230)
+++ trunk/Source/_javascript_Core/tools/VMInspector.cpp 2017-03-01 18:51:02 UTC (rev 213231)
@@ -139,7 +139,7 @@
CodeBlock* codeBlock = nullptr;
bool hasTimeout = false;
iterate([&] (VM& vm) {
- if (!vm.currentThreadIsHoldingAPILock())
+ if (!vm.apiLock().currentThreadIsHoldingLock())
return FunctorStatus::Continue;
// It is safe to call Heap::forEachCodeBlockIgnoringJITPlans here because: