Changeset 213231 in webkit


Ignore:
Timestamp:
Mar 1, 2017 10:51:02 AM (7 years ago)
Author:
mark.lam@apple.com
Message:

REGRESSION (r213202?): Assertion failed: (!"initialized()"), function operator().
https://bugs.webkit.org/show_bug.cgi?id=169042

Not reviewed.

Rolling out r213229 and r213202.

  • JavaScriptCore.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:
Location:
trunk/Source/JavaScriptCore
Files:
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r213229 r213231  
     12017-03-01  Mark Lam  <mark.lam@apple.com>
     2
     3        REGRESSION (r213202?): Assertion failed: (!"initialized()"), function operator().
     4        https://bugs.webkit.org/show_bug.cgi?id=169042
     5
     6        Not reviewed.
     7
     8        Rolling out r213229 and r213202.
     9
     10        * JavaScriptCore.xcodeproj/project.pbxproj:
     11        * heap/MachineStackMarker.cpp:
     12        (JSC::getCurrentPlatformThread):
     13        (JSC::MachineThreads::Thread::createForCurrentThread):
     14        (JSC::MachineThreads::machineThreadForCurrentThread):
     15        (JSC::MachineThreads::removeThread):
     16        (JSC::MachineThreads::Thread::suspend):
     17        (JSC::MachineThreads::tryCopyOtherThreadStacks):
     18        * heap/MachineStackMarker.h:
     19        * runtime/JSCellInlines.h:
     20        (JSC::JSCell::classInfo):
     21        * runtime/JSLock.cpp:
     22        (JSC::JSLock::JSLock):
     23        (JSC::JSLock::lock):
     24        (JSC::JSLock::unlock):
     25        (JSC::JSLock::currentThreadIsHoldingLock):
     26        * runtime/JSLock.h:
     27        (JSC::JSLock::ownerThread):
     28        (JSC::JSLock::currentThreadIsHoldingLock): Deleted.
     29        * runtime/PlatformThread.h: Removed.
     30        * runtime/VM.cpp:
     31        (JSC::VM::~VM):
     32        * runtime/VM.h:
     33        (JSC::VM::ownerThread):
     34        * runtime/Watchdog.cpp:
     35        (JSC::Watchdog::setTimeLimit):
     36        (JSC::Watchdog::shouldTerminate):
     37        (JSC::Watchdog::startTimer):
     38        (JSC::Watchdog::stopTimer):
     39        * tools/JSDollarVMPrototype.cpp:
     40        (JSC::JSDollarVMPrototype::currentThreadOwnsJSLock):
     41        * tools/VMInspector.cpp:
     42
    1432017-03-01  Mark Lam  <mark.lam@apple.com>
    244
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r213209 r213231  
    24242424                FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
    24252425                FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2426                 FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */ = {isa = PBXBuildFile; fileRef = FEE43FCD1E6641400077D6D1 /* PlatformThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
    24272426                FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
    24282427                FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    50055004                FEDA50D41B97F442009A3B4F /* PingPongStackOverflowTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PingPongStackOverflowTest.cpp; path = API/tests/PingPongStackOverflowTest.cpp; sourceTree = "<group>"; };
    50065005                FEDA50D51B97F4D9009A3B4F /* PingPongStackOverflowTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingPongStackOverflowTest.h; path = API/tests/PingPongStackOverflowTest.h; sourceTree = "<group>"; };
    5007                 FEE43FCD1E6641400077D6D1 /* PlatformThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformThread.h; sourceTree = "<group>"; };
    50085006                FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
    50095007                FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
     
    67356733                                0FE228EA1436AB2300196C48 /* Options.cpp */,
    67366734                                0FE228EB1436AB2300196C48 /* Options.h */,
    6737                                 FEE43FCD1E6641400077D6D1 /* PlatformThread.h */,
    67386735                                868916A9155F285400CB2B9A /* PrivateName.h */,
    67396736                                147341DF1DC2CE9600AA29BA /* ProgramExecutable.cpp */,
     
    91789175                                705B41AC1A6E501E00716757 /* Symbol.h in Headers */,
    91799176                                705B41AE1A6E501E00716757 /* SymbolConstructor.h in Headers */,
    9180                                 FEE43FCE1E6641710077D6D1 /* PlatformThread.h in Headers */,
    91819177                                996B73271BDA08EF00331B84 /* SymbolConstructor.lut.h in Headers */,
    91829178                                705B41B01A6E501E00716757 /* SymbolObject.h in Headers */,
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp

    r213202 r213231  
    180180}
    181181   
     182static inline PlatformThread getCurrentPlatformThread()
     183{
     184#if OS(DARWIN)
     185    return pthread_mach_thread_np(pthread_self());
     186#elif OS(WINDOWS)
     187    return GetCurrentThreadId();
     188#elif USE(PTHREADS)
     189    return pthread_self();
     190#endif
     191}
     192
    182193MachineThreads::MachineThreads()
    183194    : m_registeredThreads(0)
     
    204215{
    205216    auto stackBounds = wtfThreadData().stack();
    206     return new Thread(currentPlatformThread(), stackBounds.origin(), stackBounds.end());
     217    return new Thread(getCurrentPlatformThread(), stackBounds.origin(), stackBounds.end());
    207218}
    208219
     
    240251{
    241252    LockHolder lock(m_registeredThreadsMutex);
    242     PlatformThread platformThread = currentPlatformThread();
     253    PlatformThread platformThread = getCurrentPlatformThread();
    243254    for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
    244255        if (*thread == platformThread)
     
    272283#endif
    273284
    274         machineThreads->removeThreadIfFound(currentPlatformThread());
     285        machineThreads->removeThreadIfFound(getCurrentPlatformThread());
    275286    }
    276287}
     
    365376    return threadIsSuspended;
    366377#elif USE(PTHREADS)
    367     ASSERT_WITH_MESSAGE(currentPlatformThread() != platformThread, "Currently we don't support suspend the current thread itself.");
     378    ASSERT_WITH_MESSAGE(getCurrentPlatformThread() != platformThread, "Currently we don't support suspend the current thread itself.");
    368379    {
    369380        // During suspend, suspend or resume should not be executed from the other threads.
     
    938949    *size = 0;
    939950
    940     PlatformThread platformThread = currentPlatformThread();
     951    PlatformThread currentPlatformThread = getCurrentPlatformThread();
    941952    int numberOfThreads = 0; // Using 0 to denote that we haven't counted the number of threads yet.
    942953    int index = 1;
     
    945956    Thread* previousThread = nullptr;
    946957    for (Thread* thread = m_registeredThreads; thread; index++) {
    947         if (*thread != platformThread) {
     958        if (*thread != currentPlatformThread) {
    948959            bool success = thread->suspend();
    949960#if OS(DARWIN)
     
    9891000
    9901001    for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
    991         if (*thread != platformThread)
     1002        if (*thread != currentPlatformThread)
    9921003            tryCopyOtherThreadStack(thread, buffer, capacity, size);
    9931004    }
    9941005
    9951006    for (Thread* thread = m_registeredThreads; thread; thread = thread->next) {
    996         if (*thread != platformThread)
     1007        if (*thread != currentPlatformThread)
    9971008            thread->resume();
    9981009    }
  • trunk/Source/JavaScriptCore/heap/MachineStackMarker.h

    r213202 r213231  
    2222#pragma once
    2323
    24 #include "PlatformThread.h"
    2524#include "RegisterState.h"
    2625#include <wtf/Lock.h>
     
    2827#include <wtf/ScopedLambda.h>
    2928#include <wtf/ThreadSpecific.h>
     29
     30#if OS(DARWIN)
     31#include <mach/thread_act.h>
     32#endif
    3033
    3134#if USE(PTHREADS) && !OS(WINDOWS) && !OS(DARWIN)
     
    4043#endif
    4144#endif
     45
     46#if OS(DARWIN)
     47typedef mach_port_t PlatformThread;
     48#elif OS(WINDOWS)
     49typedef DWORD PlatformThread;
     50#elif USE(PTHREADS)
     51typedef pthread_t PlatformThread;
     52#endif // OS(DARWIN)
    4253
    4354namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r213202 r213231  
    279279    // invalid). If mutatorState() == MutatorState::Running, then we're not currently sweeping, and therefore cannot be
    280280    // destructing the object. The GC thread or JIT threads, unlike the mutator thread, are able to access classInfo
    281     // independent of whether the mutator thread is sweeping or not. Hence, we also check for !currentThreadIsHoldingAPILock()
    282     // to allow the GC thread or JIT threads to pass this assertion.
    283     ASSERT(vm.heap.mutatorState() != MutatorState::Sweeping || !vm.currentThreadIsHoldingAPILock());
     281    // independent of whether the mutator thread is sweeping or not. Hence, we also check for ownerThread() !=
     282    // std::this_thread::get_id() to allow the GC thread or JIT threads to pass this assertion.
     283    ASSERT(vm.heap.mutatorState() != MutatorState::Sweeping || vm.apiLock().ownerThread() != std::this_thread::get_id());
    284284    return structure(vm)->classInfo();
    285285}
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r213202 r213231  
    7676
    7777JSLock::JSLock(VM* vm)
    78     : m_lockCount(0)
     78    : m_ownerThreadID(std::thread::id())
     79    , m_lockCount(0)
    7980    , m_lockDropDepth(0)
    8081    , m_vm(vm)
     
    110111    }
    111112
    112     m_ownerThread = currentPlatformThread();
     113    m_ownerThreadID = std::this_thread::get_id();
    113114    ASSERT(!m_lockCount);
    114115    m_lockCount = lockCount;
     
    168169
    169170    if (!m_lockCount) {
    170         m_ownerThread = { };
     171        m_ownerThreadID = std::thread::id();
    171172        m_lock.unlock();
    172173    }
     
    200201{
    201202    exec->vm().apiLock().unlock();
     203}
     204
     205bool JSLock::currentThreadIsHoldingLock()
     206{
     207    return m_ownerThreadID == std::this_thread::get_id();
    202208}
    203209
  • trunk/Source/JavaScriptCore/runtime/JSLock.h

    r213229 r213231  
    2121#pragma once
    2222
    23 #include "PlatformThread.h"
    2423#include <mutex>
     24#include <thread>
    2525#include <wtf/Assertions.h>
    2626#include <wtf/Lock.h>
     
    9494    VM* vm() { return m_vm; }
    9595
    96     std::optional<PlatformThread> ownerThread() const { return m_ownerThread; }
    97     bool currentThreadIsHoldingLock() { return m_ownerThread && m_ownerThread == currentPlatformThread(); }
     96    std::thread::id ownerThread() const { return m_ownerThreadID; }
     97    JS_EXPORT_PRIVATE bool currentThreadIsHoldingLock();
    9898
    9999    void willDestroyVM(VM*);
     
    127127
    128128    Lock m_lock;
    129     std::optional<PlatformThread> m_ownerThread;
     129    std::thread::id m_ownerThreadID;
    130130    intptr_t m_lockCount;
    131131    unsigned m_lockDropDepth;
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r213202 r213231  
    393393    m_perBytecodeProfiler = nullptr;
    394394
    395     ASSERT(currentThreadIsHoldingAPILock());
     395    ASSERT(m_apiLock->currentThreadIsHoldingLock());
    396396    m_apiLock->willDestroyVM(this);
    397397    heap.lastChanceToFinalize();
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r213202 r213231  
    612612#endif
    613613
     614    std::thread::id ownerThread() const { return m_apiLock->ownerThread(); }
     615
    614616    JS_EXPORT_PRIVATE void resetDateCache();
    615617
     
    723725    bool isSafeToRecurseSoftCLoop() const;
    724726#endif // !ENABLE(JIT)
    725 
    726     std::optional<PlatformThread> ownerThread() const { return m_apiLock->ownerThread(); }
    727727
    728728    JS_EXPORT_PRIVATE void throwException(ExecState*, Exception*);
  • trunk/Source/JavaScriptCore/runtime/Watchdog.cpp

    r213202 r213231  
    5656    ShouldTerminateCallback callback, void* data1, void* data2)
    5757{
    58     ASSERT(m_vm->currentThreadIsHoldingAPILock());
     58    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
    5959
    6060    m_timeLimit = limit;
     
    6969bool Watchdog::shouldTerminate(ExecState* exec)
    7070{
    71     ASSERT(m_vm->currentThreadIsHoldingAPILock());
     71    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
    7272    // FIXME: Will unindent the following before landing. Leaving indented for now to minimize the code diff.
    7373    {
     
    139139{
    140140    ASSERT(m_hasEnteredVM);
    141     ASSERT(m_vm->currentThreadIsHoldingAPILock());
     141    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
    142142    ASSERT(hasTimeLimit());
    143143    ASSERT(timeLimit <= m_timeLimit);
     
    169169{
    170170    ASSERT(m_hasEnteredVM);
    171     ASSERT(m_vm->currentThreadIsHoldingAPILock());
     171    ASSERT(m_vm->ownerThread() == std::this_thread::get_id());
    172172    m_cpuDeadline = noTimeLimit;
    173173}
  • trunk/Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp

    r213202 r213231  
    4545bool JSDollarVMPrototype::currentThreadOwnsJSLock(ExecState* exec)
    4646{
    47     return exec->vm().currentThreadIsHoldingAPILock();
     47    return exec->vm().apiLock().currentThreadIsHoldingLock();
    4848}
    4949
  • trunk/Source/JavaScriptCore/tools/VMInspector.cpp

    r213202 r213231  
    140140    bool hasTimeout = false;
    141141    iterate([&] (VM& vm) {
    142         if (!vm.currentThreadIsHoldingAPILock())
     142        if (!vm.apiLock().currentThreadIsHoldingLock())
    143143            return FunctorStatus::Continue;
    144144
Note: See TracChangeset for help on using the changeset viewer.