Title: [188475] trunk/Source
Revision
188475
Author
[email protected]
Date
2015-08-14 09:53:37 -0700 (Fri, 14 Aug 2015)

Log Message

Unreviewed, rolling out r188444.
https://bugs.webkit.org/show_bug.cgi?id=148029

Broke GTK and EFL (see bug #148027) (Requested by philn on
#webkit).

Reverted changeset:

"Use WTF::Lock and WTF::Condition instead of WTF::Mutex,
WTF::ThreadCondition, std::mutex, and std::condition_variable"
https://bugs.webkit.org/show_bug.cgi?id=147999
http://trac.webkit.org/changeset/188444

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (188474 => 188475)


--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,14 +36,18 @@
 #import "JSWrapperMap.h"
 #import "SlotVisitorInlines.h"
 #import <mutex>
-#import <wtf/Lock.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/spi/cocoa/NSMapTableSPI.h>
 
 static NSMapTable *globalWrapperCache = 0;
 
-static StaticLock wrapperCacheMutex;
+static std::mutex& wrapperCacheMutex()
+{
+    static NeverDestroyed<std::mutex> mutex;
 
+    return mutex;
+}
+
 static void initWrapperCache()
 {
     ASSERT(!globalWrapperCache);
@@ -68,13 +72,13 @@
 
 + (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<std::mutex> lock(wrapperCacheMutex());
     NSMapInsert(wrapperCache(), group, wrapper);
 }
 
 + (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group
 {
-    std::lock_guard<StaticLock> lock(wrapperCacheMutex);
+    std::lock_guard<std::mutex> lock(wrapperCacheMutex());
     return static_cast<JSVirtualMachine *>(NSMapGet(wrapperCache(), group));
 }
 

Modified: trunk/Source/_javascript_Core/ChangeLog (188474 => 188475)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,3 +1,18 @@
+2015-08-14  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r188444.
+        https://bugs.webkit.org/show_bug.cgi?id=148029
+
+        Broke GTK and EFL (see bug #148027) (Requested by philn on
+        #webkit).
+
+        Reverted changeset:
+
+        "Use WTF::Lock and WTF::Condition instead of WTF::Mutex,
+        WTF::ThreadCondition, std::mutex, and std::condition_variable"
+        https://bugs.webkit.org/show_bug.cgi?id=147999
+        http://trac.webkit.org/changeset/188444
+
 2015-08-13  Filip Pizlo  <[email protected]>
 
         Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable

Modified: trunk/Source/_javascript_Core/bytecode/SamplingTool.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/bytecode/SamplingTool.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/bytecode/SamplingTool.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2009, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -285,7 +285,7 @@
 
 #if ENABLE(CODEBLOCK_SAMPLING)
     if (CodeBlock* codeBlock = sample.codeBlock()) {
-        LockHolder locker(m_scriptSampleMapMutex);
+        MutexLocker locker(m_scriptSampleMapMutex);
         ScriptSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable());
         ASSERT(record);
         record->sample(codeBlock, sample.vPC());
@@ -301,7 +301,7 @@
 void SamplingTool::notifyOfScope(VM& vm, ScriptExecutable* script)
 {
 #if ENABLE(CODEBLOCK_SAMPLING)
-    LockHolder locker(m_scriptSampleMapMutex);
+    MutexLocker locker(m_scriptSampleMapMutex);
     m_scopeSampleMap->set(script, adoptPtr(new ScriptSampleRecord(vm, script)));
 #else
     UNUSED_PARAM(vm);

Modified: trunk/Source/_javascript_Core/bytecode/SamplingTool.h (188474 => 188475)


--- trunk/Source/_javascript_Core/bytecode/SamplingTool.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/bytecode/SamplingTool.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,7 +35,6 @@
 #include <wtf/Assertions.h>
 #include <wtf/Atomics.h>
 #include <wtf/HashMap.h>
-#include <wtf/Lock.h>
 #include <wtf/MainThread.h>
 #include <wtf/Spectrum.h>
 #include <wtf/Threading.h>
@@ -339,7 +338,7 @@
         unsigned m_opcodeSamplesInCTIFunctions[numOpcodeIDs];
         
 #if ENABLE(CODEBLOCK_SAMPLING)
-        Lock m_scriptSampleMapMutex;
+        Mutex m_scriptSampleMapMutex;
         std::unique_ptr<ScriptSampleRecordMap> m_scopeSampleMap;
 #endif
     };

Modified: trunk/Source/_javascript_Core/dfg/DFGThreadData.h (188474 => 188475)


--- trunk/Source/_javascript_Core/dfg/DFGThreadData.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/dfg/DFGThreadData.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -28,8 +28,8 @@
 
 #if ENABLE(DFG_JIT)
 
-#include <wtf/Lock.h>
 #include <wtf/Threading.h>
+#include <wtf/ThreadingPrimitives.h>
 
 namespace JSC { namespace DFG {
 
@@ -48,7 +48,7 @@
     
     Worklist* m_worklist;
     ThreadIdentifier m_identifier;
-    Lock m_rightToRun;
+    Mutex m_rightToRun;
     Safepoint* m_safepoint;
 };
 

Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -46,10 +46,10 @@
 Worklist::~Worklist()
 {
     {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         for (unsigned i = m_threads.size(); i--;)
             m_queue.append(nullptr); // Use null plan to indicate that we want the thread to terminate.
-        m_planEnqueued.notifyAll();
+        m_planEnqueued.broadcast();
     }
     for (unsigned i = m_threads.size(); i--;)
         waitForThreadCompletion(m_threads[i]->m_identifier);
@@ -77,7 +77,7 @@
 
 bool Worklist::isActiveForVM(VM& vm) const
 {
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     PlanMap::const_iterator end = m_plans.end();
     for (PlanMap::const_iterator iter = m_plans.begin(); iter != end; ++iter) {
         if (&iter->value->vm == &vm)
@@ -89,7 +89,7 @@
 void Worklist::enqueue(PassRefPtr<Plan> passedPlan)
 {
     RefPtr<Plan> plan = passedPlan;
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     if (Options::verboseCompilationQueue()) {
         dump(locker, WTF::dataFile());
         dataLog(": Enqueueing plan to optimize ", plan->key(), "\n");
@@ -97,12 +97,12 @@
     ASSERT(m_plans.find(plan->key()) == m_plans.end());
     m_plans.add(plan->key(), plan);
     m_queue.append(plan);
-    m_planEnqueued.notifyOne();
+    m_planEnqueued.signal();
 }
 
 Worklist::State Worklist::compilationState(CompilationKey key)
 {
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     PlanMap::iterator iter = m_plans.find(key);
     if (iter == m_plans.end())
         return NotKnown;
@@ -118,7 +118,7 @@
     // After we release this lock, we know that although other VMs may still
     // be adding plans, our VM will not be.
     
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     
     if (Options::verboseCompilationQueue()) {
         dump(locker, WTF::dataFile());
@@ -147,7 +147,7 @@
 void Worklist::removeAllReadyPlansForVM(VM& vm, Vector<RefPtr<Plan>, 8>& myReadyPlans)
 {
     DeferGC deferGC(vm.heap);
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     for (size_t i = 0; i < m_readyPlans.size(); ++i) {
         RefPtr<Plan> plan = m_readyPlans[i];
         if (&plan->vm != &vm)
@@ -192,7 +192,7 @@
     }
     
     if (!!requestedKey && resultingState == NotKnown) {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         if (m_plans.contains(requestedKey))
             resultingState = Compiling;
     }
@@ -225,7 +225,7 @@
 {
     VM* vm = visitor.heap()->vm();
     {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         for (PlanMap::iterator iter = m_plans.begin(); iter != m_plans.end(); ++iter) {
             Plan* plan = iter->value.get();
             if (&plan->vm != vm)
@@ -248,7 +248,7 @@
 void Worklist::removeDeadPlans(VM& vm)
 {
     {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         HashSet<CompilationKey> deadPlanKeys;
         for (PlanMap::iterator iter = m_plans.begin(); iter != m_plans.end(); ++iter) {
             Plan* plan = iter->value.get();
@@ -295,17 +295,17 @@
 
 size_t Worklist::queueLength()
 {
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     return m_queue.size();
 }
 
 void Worklist::dump(PrintStream& out) const
 {
-    LockHolder locker(m_lock);
+    MutexLocker locker(m_lock);
     dump(locker, out);
 }
 
-void Worklist::dump(const LockHolder&, PrintStream& out) const
+void Worklist::dump(const MutexLocker&, PrintStream& out) const
 {
     out.print(
         "Worklist(", RawPointer(this), ")[Queue Length = ", m_queue.size(),
@@ -325,7 +325,7 @@
     for (;;) {
         RefPtr<Plan> plan;
         {
-            LockHolder locker(m_lock);
+            MutexLocker locker(m_lock);
             while (m_queue.isEmpty())
                 m_planEnqueued.wait(m_lock);
             
@@ -341,9 +341,9 @@
         }
         
         {
-            LockHolder locker(data->m_rightToRun);
+            MutexLocker locker(data->m_rightToRun);
             {
-                LockHolder locker(m_lock);
+                MutexLocker locker(m_lock);
                 if (plan->stage == Plan::Cancelled) {
                     m_numberOfActiveThreads--;
                     continue;
@@ -359,7 +359,7 @@
             RELEASE_ASSERT(!plan->vm.heap.isCollecting());
             
             {
-                LockHolder locker(m_lock);
+                MutexLocker locker(m_lock);
                 if (plan->stage == Plan::Cancelled) {
                     m_numberOfActiveThreads--;
                     continue;
@@ -370,7 +370,7 @@
         }
 
         {
-            LockHolder locker(m_lock);
+            MutexLocker locker(m_lock);
             
             // We could have been cancelled between releasing rightToRun and acquiring m_lock.
             // This would mean that we might be in the middle of GC right now.
@@ -388,7 +388,7 @@
             
             m_readyPlans.append(plan);
             
-            m_planCompiled.notifyAll();
+            m_planCompiled.broadcast();
             m_numberOfActiveThreads--;
         }
     }

Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.h (188474 => 188475)


--- trunk/Source/_javascript_Core/dfg/DFGWorklist.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -30,11 +30,10 @@
 
 #include "DFGPlan.h"
 #include "DFGThreadData.h"
-#include <wtf/Condition.h>
 #include <wtf/Deque.h>
 #include <wtf/HashMap.h>
-#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/ThreadingPrimitives.h>
 
 namespace JSC {
 
@@ -86,7 +85,7 @@
     
     void removeAllReadyPlansForVM(VM&, Vector<RefPtr<Plan>, 8>&);
 
-    void dump(const LockHolder&, PrintStream&) const;
+    void dump(const MutexLocker&, PrintStream&) const;
     
     CString m_threadName;
     
@@ -104,11 +103,11 @@
     // be completed.
     Vector<RefPtr<Plan>, 16> m_readyPlans;
 
-    Lock m_suspensionLock;
+    Mutex m_suspensionLock;
     
-    mutable Lock m_lock;
-    Condition m_planEnqueued;
-    Condition m_planCompiled;
+    mutable Mutex m_lock;
+    ThreadCondition m_planEnqueued;
+    ThreadCondition m_planCompiled;
     
     Vector<std::unique_ptr<ThreadData>> m_threads;
     unsigned m_numberOfActiveThreads;

Modified: trunk/Source/_javascript_Core/disassembler/Disassembler.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/disassembler/Disassembler.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/disassembler/Disassembler.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -27,13 +27,12 @@
 #include "Disassembler.h"
 
 #include "MacroAssemblerCodeRef.h"
-#include <wtf/Condition.h>
 #include <wtf/DataLog.h>
 #include <wtf/Deque.h>
-#include <wtf/Lock.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/StringPrintStream.h>
 #include <wtf/Threading.h>
+#include <wtf/ThreadingPrimitives.h>
 
 namespace JSC {
 
@@ -79,14 +78,14 @@
     
     void enqueue(std::unique_ptr<DisassemblyTask> task)
     {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         m_queue.append(WTF::move(task));
-        m_condition.notifyAll();
+        m_condition.broadcast();
     }
     
     void waitUntilEmpty()
     {
-        LockHolder locker(m_lock);
+        MutexLocker locker(m_lock);
         while (!m_queue.isEmpty() || m_working)
             m_condition.wait(m_lock);
     }
@@ -97,9 +96,9 @@
         for (;;) {
             std::unique_ptr<DisassemblyTask> task;
             {
-                LockHolder locker(m_lock);
+                MutexLocker locker(m_lock);
                 m_working = false;
-                m_condition.notifyAll();
+                m_condition.broadcast();
                 while (m_queue.isEmpty())
                     m_condition.wait(m_lock);
                 task = m_queue.takeFirst();
@@ -113,8 +112,8 @@
         }
     }
     
-    Lock m_lock;
-    Condition m_condition;
+    Mutex m_lock;
+    ThreadCondition m_condition;
     Deque<std::unique_ptr<DisassemblyTask>> m_queue;
     bool m_working { false };
 };

Modified: trunk/Source/_javascript_Core/heap/CopiedSpace.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/CopiedSpace.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/CopiedSpace.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -198,12 +198,12 @@
     }
 
     {
-        LockHolder locker(m_loanedBlocksLock);
+        MutexLocker locker(m_loanedBlocksLock);
         ASSERT(m_numberOfLoanedBlocks > 0);
         ASSERT(m_inCopyingPhase);
         m_numberOfLoanedBlocks--;
         if (!m_numberOfLoanedBlocks)
-            m_loanedBlocksCondition.notifyOne();
+            m_loanedBlocksCondition.signal();
     }
 }
 
@@ -231,7 +231,7 @@
 void CopiedSpace::doneCopying()
 {
     {
-        LockHolder locker(m_loanedBlocksLock);
+        MutexLocker locker(m_loanedBlocksLock);
         while (m_numberOfLoanedBlocks > 0)
             m_loanedBlocksCondition.wait(m_loanedBlocksLock);
     }

Modified: trunk/Source/_javascript_Core/heap/CopiedSpace.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/CopiedSpace.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/CopiedSpace.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -31,13 +31,13 @@
 #include "TinyBloomFilter.h"
 #include <wtf/Assertions.h>
 #include <wtf/CheckedBoolean.h>
-#include <wtf/Condition.h>
 #include <wtf/DoublyLinkedList.h>
 #include <wtf/HashSet.h>
 #include <wtf/Lock.h>
 #include <wtf/OSAllocator.h>
 #include <wtf/PageBlock.h>
 #include <wtf/StdLibExtras.h>
+#include <wtf/ThreadingPrimitives.h>
 
 namespace JSC {
 
@@ -138,8 +138,8 @@
     bool m_inCopyingPhase;
     bool m_shouldDoCopyPhase;
 
-    Lock m_loanedBlocksLock; 
-    Condition m_loanedBlocksCondition;
+    Mutex m_loanedBlocksLock; 
+    ThreadCondition m_loanedBlocksCondition;
     size_t m_numberOfLoanedBlocks;
     
     size_t m_bytesRemovedFromOldSpaceDueToReallocation;

Modified: trunk/Source/_javascript_Core/heap/CopiedSpaceInlines.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/CopiedSpaceInlines.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/CopiedSpaceInlines.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -113,12 +113,12 @@
     CopiedBlock::destroy(block);
 
     {
-        LockHolder locker(m_loanedBlocksLock);
+        MutexLocker locker(m_loanedBlocksLock);
         ASSERT(m_numberOfLoanedBlocks > 0);
         ASSERT(m_inCopyingPhase);
         m_numberOfLoanedBlocks--;
         if (!m_numberOfLoanedBlocks)
-            m_loanedBlocksCondition.notifyOne();
+            m_loanedBlocksCondition.signal();
     }
 }
 
@@ -128,7 +128,7 @@
     CopiedBlock* block = CopiedBlock::createNoZeroFill();
 
     {
-        LockHolder locker(m_loanedBlocksLock);
+        MutexLocker locker(m_loanedBlocksLock);
         m_numberOfLoanedBlocks++;
     }
 

Modified: trunk/Source/_javascript_Core/heap/GCThread.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/GCThread.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/GCThread.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -69,12 +69,12 @@
 
 GCPhase GCThread::waitForNextPhase()
 {
-    std::unique_lock<Lock> lock(m_shared.m_phaseMutex);
+    std::unique_lock<std::mutex> lock(m_shared.m_phaseMutex);
     m_shared.m_phaseConditionVariable.wait(lock, [this] { return !m_shared.m_gcThreadsShouldWait; });
 
     m_shared.m_numberOfActiveGCThreads--;
     if (!m_shared.m_numberOfActiveGCThreads)
-        m_shared.m_activityConditionVariable.notifyOne();
+        m_shared.m_activityConditionVariable.notify_one();
 
     m_shared.m_phaseConditionVariable.wait(lock, [this] { return m_shared.m_currentPhase != NoPhase; });
     m_shared.m_numberOfActiveGCThreads++;
@@ -90,7 +90,7 @@
     // Wait for the main thread to finish creating and initializing us. The main thread grabs this lock before 
     // creating this thread. We aren't guaranteed to have a valid threadID until the main thread releases this lock.
     {
-        std::lock_guard<Lock> lock(m_shared.m_phaseMutex);
+        std::lock_guard<std::mutex> lock(m_shared.m_phaseMutex);
     }
     {
         ParallelModeEnabler enabler(*m_slotVisitor);

Modified: trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/GCThreadSharedData.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -83,7 +83,7 @@
 {
 #if ENABLE(PARALLEL_GC)
     // Grab the lock so the new GC threads can be properly initialized before they start running.
-    std::unique_lock<Lock> lock(m_phaseMutex);
+    std::unique_lock<std::mutex> lock(m_phaseMutex);
     for (unsigned i = 1; i < Options::numberOfGCMarkers(); ++i) {
         m_numberOfActiveGCThreads++;
         GCThread* newThread = new GCThread(*this, std::make_unique<SlotVisitor>(*this), std::make_unique<CopyVisitor>(*this));
@@ -102,13 +102,13 @@
 #if ENABLE(PARALLEL_GC)    
     // Destroy our marking threads.
     {
-        std::lock_guard<Lock> markingLock(m_markingMutex);
-        std::lock_guard<Lock> phaseLock(m_phaseMutex);
+        std::lock_guard<std::mutex> markingLock(m_markingMutex);
+        std::lock_guard<std::mutex> phaseLock(m_phaseMutex);
         ASSERT(m_currentPhase == NoPhase);
         m_parallelMarkersShouldExit = true;
         m_gcThreadsShouldWait = false;
         m_currentPhase = Exit;
-        m_phaseConditionVariable.notifyAll();
+        m_phaseConditionVariable.notify_all();
     }
     for (unsigned i = 0; i < m_gcThreads.size(); ++i) {
         waitForThreadCompletion(m_gcThreads[i]->threadID());
@@ -131,21 +131,21 @@
 
 void GCThreadSharedData::startNextPhase(GCPhase phase)
 {
-    std::lock_guard<Lock> lock(m_phaseMutex);
+    std::lock_guard<std::mutex> lock(m_phaseMutex);
     ASSERT(!m_gcThreadsShouldWait);
     ASSERT(m_currentPhase == NoPhase);
     m_gcThreadsShouldWait = true;
     m_currentPhase = phase;
-    m_phaseConditionVariable.notifyAll();
+    m_phaseConditionVariable.notify_all();
 }
 
 void GCThreadSharedData::endCurrentPhase()
 {
     ASSERT(m_gcThreadsShouldWait);
-    std::unique_lock<Lock> lock(m_phaseMutex);
+    std::unique_lock<std::mutex> lock(m_phaseMutex);
     m_currentPhase = NoPhase;
     m_gcThreadsShouldWait = false;
-    m_phaseConditionVariable.notifyAll();
+    m_phaseConditionVariable.notify_all();
     m_activityConditionVariable.wait(lock, [this] { return !m_numberOfActiveGCThreads; });
 }
 
@@ -158,7 +158,7 @@
         ASSERT(m_opaqueRoots.isEmpty());
 #endif
 }
-    std::lock_guard<Lock> lock(m_markingMutex);
+    std::lock_guard<std::mutex> lock(m_markingMutex);
     m_parallelMarkersShouldExit = false;
     startNextPhase(Mark);
 }
@@ -166,9 +166,9 @@
 void GCThreadSharedData::didFinishMarking()
 {
     {
-        std::lock_guard<Lock> lock(m_markingMutex);
+        std::lock_guard<std::mutex> lock(m_markingMutex);
         m_parallelMarkersShouldExit = true;
-        m_markingConditionVariable.notifyAll();
+        m_markingConditionVariable.notify_all();
     }
 
     ASSERT(m_currentPhase == Mark);

Modified: trunk/Source/_javascript_Core/heap/GCThreadSharedData.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/GCThreadSharedData.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/GCThreadSharedData.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,7 +32,6 @@
 #include "UnconditionalFinalizer.h"
 #include "WeakReferenceHarvester.h"
 #include <condition_variable>
-#include <wtf/Condition.h>
 #include <wtf/HashSet.h>
 #include <wtf/Lock.h>
 #include <wtf/Vector.h>
@@ -89,13 +88,13 @@
 
     Vector<GCThread*> m_gcThreads;
 
-    Lock m_markingMutex;
-    Condition m_markingConditionVariable;
+    std::mutex m_markingMutex;
+    std::condition_variable m_markingConditionVariable;
     MarkStackArray m_sharedMarkStack;
     unsigned m_numberOfActiveParallelMarkers;
     bool m_parallelMarkersShouldExit;
 
-    Lock m_opaqueRootsMutex;
+    std::mutex m_opaqueRootsMutex;
     HashSet<void*> m_opaqueRoots;
 
     Lock m_copyLock;
@@ -103,9 +102,9 @@
     size_t m_copyIndex;
     static const size_t s_blockFragmentLength = 32;
 
-    Lock m_phaseMutex;
-    Condition m_phaseConditionVariable;
-    Condition m_activityConditionVariable;
+    std::mutex m_phaseMutex;
+    std::condition_variable m_phaseConditionVariable;
+    std::condition_variable m_activityConditionVariable;
     unsigned m_numberOfActiveGCThreads;
     bool m_gcThreadsShouldWait;
     GCPhase m_currentPhase;

Modified: trunk/Source/_javascript_Core/heap/HeapTimer.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/HeapTimer.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/HeapTimer.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,7 +26,6 @@
 #ifndef HeapTimer_h
 #define HeapTimer_h
 
-#include <wtf/Lock.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Threading.h>
 
@@ -60,7 +59,7 @@
     RetainPtr<CFRunLoopRef> m_runLoop;
     CFRunLoopTimerContext m_context;
 
-    Lock m_shutdownMutex;
+    Mutex m_shutdownMutex;
 #elif PLATFORM(EFL)
     static bool timerEvent(void*);
     Ecore_Timer* add(double delay, void* agent);

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -103,18 +103,18 @@
         }
 
     private:
-        LockHolder m_locker;
+        MutexLocker m_locker;
     };
 
     void add(MachineThreads* machineThreads)
     {
-        LockHolder managerLock(m_lock);
+        MutexLocker managerLock(m_lock);
         m_set.add(machineThreads);
     }
 
     void remove(MachineThreads* machineThreads)
     {
-        LockHolder managerLock(m_lock);
+        MutexLocker managerLock(m_lock);
         auto recordedMachineThreads = m_set.take(machineThreads);
         RELEASE_ASSERT(recordedMachineThreads = machineThreads);
     }
@@ -129,7 +129,7 @@
 
     ActiveMachineThreadsManager() { }
     
-    Lock m_lock;
+    Mutex m_lock;
     MachineThreadsSet m_set;
 
     friend ActiveMachineThreadsManager& activeMachineThreadsManager();
@@ -263,7 +263,7 @@
     activeMachineThreadsManager().remove(this);
     threadSpecificKeyDelete(m_threadSpecific);
 
-    LockHolder registeredThreadsLock(m_registeredThreadsMutex);
+    MutexLocker registeredThreadsLock(m_registeredThreadsMutex);
     for (Thread* t = m_registeredThreads; t;) {
         Thread* next = t->next;
         delete t;
@@ -294,7 +294,7 @@
     threadSpecificSet(m_threadSpecific, this);
     Thread* thread = Thread::createForCurrentThread();
 
-    LockHolder lock(m_registeredThreadsMutex);
+    MutexLocker lock(m_registeredThreadsMutex);
 
     thread->next = m_registeredThreads;
     m_registeredThreads = thread;
@@ -318,7 +318,7 @@
 template<typename PlatformThread>
 void MachineThreads::removeThreadIfFound(PlatformThread platformThread)
 {
-    LockHolder lock(m_registeredThreadsMutex);
+    MutexLocker lock(m_registeredThreadsMutex);
     Thread* t = m_registeredThreads;
     if (*t == platformThread) {
         m_registeredThreads = m_registeredThreads->next;
@@ -566,7 +566,7 @@
     thread->freeRegisters(registers);
 }
 
-bool MachineThreads::tryCopyOtherThreadStacks(LockHolder&, void* buffer, size_t capacity, size_t* size)
+bool MachineThreads::tryCopyOtherThreadStacks(MutexLocker&, void* buffer, size_t capacity, size_t* size)
 {
     // Prevent two VMs from suspending each other's threads at the same time,
     // which can cause deadlock: <rdar://problem/20300842>.
@@ -660,7 +660,7 @@
     size_t size;
     size_t capacity = 0;
     void* buffer = nullptr;
-    LockHolder lock(m_registeredThreadsMutex);
+    MutexLocker lock(m_registeredThreadsMutex);
     while (!tryCopyOtherThreadStacks(lock, buffer, capacity, &size))
         growBuffer(size, &buffer, &capacity);
 

Modified: trunk/Source/_javascript_Core/heap/MachineStackMarker.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/MachineStackMarker.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 1999-2000 Harri Porten ([email protected])
  *  Copyright (C) 2001 Peter Kelly ([email protected])
- *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2015 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -23,9 +23,9 @@
 #define MachineThreads_h
 
 #include <setjmp.h>
-#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/ThreadSpecific.h>
+#include <wtf/ThreadingPrimitives.h>
 
 namespace JSC {
 
@@ -52,14 +52,14 @@
         void gatherFromCurrentThread(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&, void* stackOrigin, void* stackTop, RegisterState& calleeSavedRegisters);
 
         void tryCopyOtherThreadStack(Thread*, void*, size_t capacity, size_t*);
-        bool tryCopyOtherThreadStacks(LockHolder&, void*, size_t capacity, size_t*);
+        bool tryCopyOtherThreadStacks(MutexLocker&, void*, size_t capacity, size_t*);
 
         static void removeThread(void*);
 
         template<typename PlatformThread>
         void removeThreadIfFound(PlatformThread);
 
-        Lock m_registeredThreadsMutex;
+        Mutex m_registeredThreadsMutex;
         Thread* m_registeredThreads;
         WTF::ThreadSpecificKey m_threadSpecific;
 #if !ASSERT_DISABLED

Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/SlotVisitor.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,28 +1,3 @@
-/*
- * Copyright (C) 2012, 2015 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. AND ITS CONTRIBUTORS ``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 ITS 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.
- */
-
 #include "config.h"
 #include "SlotVisitor.h"
 #include "SlotVisitorInlines.h"
@@ -37,7 +12,6 @@
 #include "JSObject.h"
 #include "JSString.h"
 #include "JSCInlines.h"
-#include <wtf/Lock.h>
 #include <wtf/StackStats.h>
 
 namespace JSC {
@@ -147,7 +121,7 @@
 
     // If we're contending on the lock, be conservative and assume that another
     // thread is already donating.
-    std::unique_lock<Lock> lock(m_shared.m_markingMutex, std::try_to_lock);
+    std::unique_lock<std::mutex> lock(m_shared.m_markingMutex, std::try_to_lock);
     if (!lock.owns_lock())
         return;
 
@@ -155,7 +129,7 @@
     m_stack.donateSomeCellsTo(m_shared.m_sharedMarkStack);
 
     if (m_shared.m_numberOfActiveParallelMarkers < Options::numberOfGCMarkers())
-        m_shared.m_markingConditionVariable.notifyAll();
+        m_shared.m_markingConditionVariable.notify_all();
 }
 
 void SlotVisitor::drain()
@@ -210,12 +184,12 @@
     
 #if ENABLE(PARALLEL_GC)
     {
-        std::lock_guard<Lock> lock(m_shared.m_markingMutex);
+        std::lock_guard<std::mutex> lock(m_shared.m_markingMutex);
         m_shared.m_numberOfActiveParallelMarkers++;
     }
     while (true) {
         {
-            std::unique_lock<Lock> lock(m_shared.m_markingMutex);
+            std::unique_lock<std::mutex> lock(m_shared.m_markingMutex);
             m_shared.m_numberOfActiveParallelMarkers--;
 
             // How we wait differs depending on drain mode.
@@ -226,7 +200,7 @@
                     // Did we reach termination?
                     if (!m_shared.m_numberOfActiveParallelMarkers && m_shared.m_sharedMarkStack.isEmpty()) {
                         // Let any sleeping slaves know it's time for them to return;
-                        m_shared.m_markingConditionVariable.notifyAll();
+                        m_shared.m_markingConditionVariable.notify_all();
                         return;
                     }
                     
@@ -242,7 +216,7 @@
                 
                 // Did we detect termination? If so, let the master know.
                 if (!m_shared.m_numberOfActiveParallelMarkers && m_shared.m_sharedMarkStack.isEmpty())
-                    m_shared.m_markingConditionVariable.notifyAll();
+                    m_shared.m_markingConditionVariable.notify_all();
 
                 m_shared.m_markingConditionVariable.wait(lock, [this] { return !m_shared.m_sharedMarkStack.isEmpty() || m_shared.m_parallelMarkersShouldExit; });
                 
@@ -266,7 +240,7 @@
     StackStats::probe();
     ASSERT(!m_opaqueRoots.isEmpty()); // Should only be called when opaque roots are non-empty.
     {
-        std::lock_guard<Lock> lock(m_shared.m_opaqueRootsMutex);
+        std::lock_guard<std::mutex> lock(m_shared.m_opaqueRootsMutex);
         for (auto* root : m_opaqueRoots)
             m_shared.m_opaqueRoots.add(root);
     }

Modified: trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h (188474 => 188475)


--- trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/heap/SlotVisitorInlines.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -188,7 +188,7 @@
 {
     if (m_opaqueRoots.contains(root))
         return TrueTriState;
-    std::lock_guard<Lock> lock(m_shared.m_opaqueRootsMutex);
+    std::lock_guard<std::mutex> lock(m_shared.m_opaqueRootsMutex);
     if (m_shared.m_opaqueRoots.contains(root))
         return TrueTriState;
     return MixedTriState;

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h (188474 => 188475)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -31,7 +31,6 @@
 #import "InspectorFrontendChannel.h"
 #import "RemoteInspectorDebuggable.h"
 #import <mutex>
-#import <wtf/Lock.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/ThreadSafeRefCounted.h>
 
@@ -92,7 +91,7 @@
     void sendMessageToBackend(NSString *);
     virtual bool sendMessageToFrontend(const String&) override;
 
-    Lock& queueMutex() { return m_queueMutex; }
+    std::mutex& queueMutex() { return m_queueMutex; }
     RemoteInspectorQueue queue() const { return m_queue; }
     void clearQueue() { m_queue.clear(); }
 
@@ -106,14 +105,14 @@
     // This connection from the RemoteInspector singleton to the Debuggable
     // can be used on multiple threads. So any access to the debuggable
     // itself must take this mutex to ensure m_debuggable is valid.
-    Lock m_debuggableMutex;
+    std::mutex m_debuggableMutex;
 
     // If a debuggable has a specific run loop it wants to evaluate on
     // we setup our run loop sources on that specific run loop.
     RetainPtr<CFRunLoopRef> m_runLoop;
     RetainPtr<CFRunLoopSourceRef> m_runLoopSource;
     RemoteInspectorQueue m_queue;
-    Lock m_queueMutex;
+    std::mutex m_queueMutex;
 
     RemoteInspectorDebuggable* m_debuggable;
     RetainPtr<NSString> m_connectionIdentifier;

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm (188474 => 188475)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorDebuggableConnection.mm	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2013 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -39,19 +39,20 @@
 
 namespace Inspector {
 
-static StaticLock rwiQueueMutex;
+static std::mutex* rwiQueueMutex;
 static CFRunLoopSourceRef rwiRunLoopSource;
 static RemoteInspectorQueue* rwiQueue;
 
 static void RemoteInspectorHandleRunSourceGlobal(void*)
 {
     ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain());
+    ASSERT(rwiQueueMutex);
     ASSERT(rwiRunLoopSource);
     ASSERT(rwiQueue);
 
     RemoteInspectorQueue queueCopy;
     {
-        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        std::lock_guard<std::mutex> lock(*rwiQueueMutex);
         queueCopy = *rwiQueue;
         rwiQueue->clear();
     }
@@ -62,11 +63,12 @@
 
 static void RemoteInspectorQueueTaskOnGlobalQueue(void (^task)())
 {
+    ASSERT(rwiQueueMutex);
     ASSERT(rwiRunLoopSource);
     ASSERT(rwiQueue);
 
     {
-        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        std::lock_guard<std::mutex> lock(*rwiQueueMutex);
         rwiQueue->append(RemoteInspectorBlock(task));
     }
 
@@ -79,6 +81,7 @@
     static dispatch_once_t pred;
     dispatch_once(&pred, ^{
         rwiQueue = new RemoteInspectorQueue;
+        rwiQueueMutex = std::make_unique<std::mutex>().release();
 
         CFRunLoopSourceContext runLoopSourceContext = {0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteInspectorHandleRunSourceGlobal};
         rwiRunLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 1, &runLoopSourceContext);
@@ -95,7 +98,7 @@
 
     RemoteInspectorQueue queueCopy;
     {
-        std::lock_guard<Lock> lock(debuggableConnection->queueMutex());
+        std::lock_guard<std::mutex> lock(debuggableConnection->queueMutex());
         queueCopy = debuggableConnection->queue();
         debuggableConnection->clearQueue();
     }
@@ -149,7 +152,7 @@
 
 bool RemoteInspectorDebuggableConnection::setup(bool isAutomaticInspection, bool automaticallyPause)
 {
-    std::lock_guard<Lock> lock(m_debuggableMutex);
+    std::lock_guard<std::mutex> lock(m_debuggableMutex);
 
     if (!m_debuggable)
         return false;
@@ -157,7 +160,7 @@
     ref();
     dispatchAsyncOnDebuggable(^{
         {
-            std::lock_guard<Lock> lock(m_debuggableMutex);
+            std::lock_guard<std::mutex> lock(m_debuggableMutex);
             if (!m_debuggable || !m_debuggable->remoteDebuggingAllowed() || m_debuggable->hasLocalDebugger()) {
                 RemoteInspector::singleton().setupFailed(identifier());
                 m_debuggable = nullptr;
@@ -177,7 +180,7 @@
 
 void RemoteInspectorDebuggableConnection::closeFromDebuggable()
 {
-    std::lock_guard<Lock> lock(m_debuggableMutex);
+    std::lock_guard<std::mutex> lock(m_debuggableMutex);
 
     m_debuggable = nullptr;
 }
@@ -187,7 +190,7 @@
     ref();
     dispatchAsyncOnDebuggable(^{
         {
-            std::lock_guard<Lock> lock(m_debuggableMutex);
+            std::lock_guard<std::mutex> lock(m_debuggableMutex);
 
             if (m_debuggable) {
                 if (m_connected)
@@ -207,7 +210,7 @@
         {
             RemoteInspectorDebuggable* debuggable = nullptr;
             {
-                std::lock_guard<Lock> lock(m_debuggableMutex);
+                std::lock_guard<std::mutex> lock(m_debuggableMutex);
                 if (!m_debuggable)
                     return;
                 debuggable = m_debuggable;
@@ -260,7 +263,7 @@
     ASSERT(m_runLoop);
 
     {
-        std::lock_guard<Lock> lock(m_queueMutex);
+        std::lock_guard<std::mutex> lock(m_queueMutex);
         m_queue.append(RemoteInspectorBlock(block));
     }
 

Modified: trunk/Source/_javascript_Core/interpreter/JSStack.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/interpreter/JSStack.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/interpreter/JSStack.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2013, 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,14 +33,17 @@
 #include "Interpreter.h"
 #include "JSCInlines.h"
 #include "Options.h"
-#include <wtf/Lock.h>
 
 namespace JSC {
 
 #if !ENABLE(JIT)
 static size_t committedBytesCount = 0;
 
-static StaticLock stackStatisticsMutex;
+static Mutex& stackStatisticsMutex()
+{
+    DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
+    return staticMutex;
+}    
 #endif // !ENABLE(JIT)
 
 JSStack::JSStack(VM& vm)
@@ -136,9 +139,14 @@
     m_commitTop = highAddressWithReservedZone;
 }
 
+void JSStack::initializeThreading()
+{
+    stackStatisticsMutex();
+}
+
 void JSStack::addToCommittedByteCount(long byteCount)
 {
-    LockHolder locker(stackStatisticsMutex);
+    MutexLocker locker(stackStatisticsMutex());
     ASSERT(static_cast<long>(committedBytesCount) + byteCount > -1);
     committedBytesCount += byteCount;
 }
@@ -168,7 +176,7 @@
 size_t JSStack::committedByteCount()
 {
 #if !ENABLE(JIT)
-    LockHolder locker(stackStatisticsMutex);
+    MutexLocker locker(stackStatisticsMutex());
     return committedBytesCount;
 #else
     // When using the C stack, we don't know how many stack pages are actually

Modified: trunk/Source/_javascript_Core/interpreter/JSStack.h (188474 => 188475)


--- trunk/Source/_javascript_Core/interpreter/JSStack.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/interpreter/JSStack.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -82,6 +82,7 @@
         void gatherConservativeRoots(ConservativeRoots&) { }
         void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&) { }
         void sanitizeStack() { }
+        static void initializeThreading() { }
 #else
         ~JSStack();
 
@@ -96,6 +97,8 @@
 
         size_t size() const { return highAddress() - lowAddress(); }
 
+        static void initializeThreading();
+
         void setReservedZoneSize(size_t);
 
         inline Register* topOfStack();

Modified: trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/jit/ExecutableAllocator.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -31,10 +31,10 @@
 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND)
 #include "CodeProfiling.h"
 #include <wtf/HashSet.h>
-#include <wtf/Lock.h>
 #include <wtf/MetaAllocator.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/PageReservation.h>
+#include <wtf/ThreadingPrimitives.h>
 #include <wtf/VMTags.h>
 #endif
 
@@ -56,7 +56,7 @@
     DemandExecutableAllocator()
         : MetaAllocator(jitAllocationGranule)
     {
-        std::lock_guard<StaticLock> lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         allocators().add(this);
         // Don't preallocate any memory here.
     }
@@ -64,7 +64,7 @@
     virtual ~DemandExecutableAllocator()
     {
         {
-            std::lock_guard<StaticLock> lock(allocatorsMutex());
+            std::lock_guard<std::mutex> lock(allocatorsMutex());
             allocators().remove(this);
         }
         for (unsigned i = 0; i < reservations.size(); ++i)
@@ -74,7 +74,7 @@
     static size_t bytesAllocatedByAllAllocators()
     {
         size_t total = 0;
-        std::lock_guard<StaticLock> lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             total += (*allocator)->bytesAllocated();
         return total;
@@ -83,7 +83,7 @@
     static size_t bytesCommittedByAllocactors()
     {
         size_t total = 0;
-        std::lock_guard<StaticLock> lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             total += (*allocator)->bytesCommitted();
         return total;
@@ -92,7 +92,7 @@
 #if ENABLE(META_ALLOCATOR_PROFILE)
     static void dumpProfileFromAllAllocators()
     {
-        std::lock_guard<StaticLock> lock(allocatorsMutex());
+        std::lock_guard<std::mutex> lock(allocatorsMutex());
         for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator)
             (*allocator)->dumpProfile();
     }
@@ -138,9 +138,9 @@
         return sAllocators;
     }
 
-    static StaticLock& allocatorsMutex()
+    static std::mutex& allocatorsMutex()
     {
-        static StaticLock mutex;
+        static NeverDestroyed<std::mutex> mutex;
 
         return mutex;
     }

Modified: trunk/Source/_javascript_Core/jit/JITThunks.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/jit/JITThunks.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/jit/JITThunks.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -66,7 +66,7 @@
 
 MacroAssemblerCodeRef JITThunks::ctiStub(VM* vm, ThunkGenerator generator)
 {
-    LockHolder locker(m_lock);
+    Locker locker(m_lock);
     CTIStubMap::AddResult entry = m_ctiStubMap.add(generator, MacroAssemblerCodeRef());
     if (entry.isNewEntry) {
         // Compilation thread can only retrieve existing entries.

Modified: trunk/Source/_javascript_Core/jit/JITThunks.h (188474 => 188475)


--- trunk/Source/_javascript_Core/jit/JITThunks.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/jit/JITThunks.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -63,6 +63,10 @@
     void clearHostFunctionStubs();
 
 private:
+    // Main thread can hold this lock for a while, so use an adaptive mutex.
+    typedef Mutex Lock;
+    typedef MutexLocker Locker;
+
     void finalize(Handle<Unknown>, void* context) override;
     
     typedef HashMap<ThunkGenerator, MacroAssemblerCodeRef> CTIStubMap;

Modified: trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/profiler/ProfilerDatabase.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -57,7 +57,7 @@
 
 Bytecodes* Database::ensureBytecodesFor(CodeBlock* codeBlock)
 {
-    LockHolder locker(m_lock);
+    Locker locker(m_lock);
     
     codeBlock = codeBlock->baselineVersion();
     
@@ -75,7 +75,7 @@
 
 void Database::notifyDestruction(CodeBlock* codeBlock)
 {
-    LockHolder locker(m_lock);
+    Locker locker(m_lock);
     
     m_bytecodesMap.remove(codeBlock);
 }

Modified: trunk/Source/_javascript_Core/profiler/ProfilerDatabase.h (188474 => 188475)


--- trunk/Source/_javascript_Core/profiler/ProfilerDatabase.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/profiler/ProfilerDatabase.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -32,7 +32,6 @@
 #include "ProfilerCompilationKind.h"
 #include <wtf/FastMalloc.h>
 #include <wtf/HashMap.h>
-#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/SegmentedVector.h>
@@ -71,6 +70,21 @@
     void registerToSaveAtExit(const char* filename);
     
 private:
+    // Use a full-blown adaptive mutex because:
+    // - There is only one ProfilerDatabase per VM. The size overhead of the system's
+    //   mutex is negligible if you only have one of them.
+    // - It's locked infrequently - once per bytecode generation, compilation, and
+    //   code block collection - so the fact that the fast path still requires a
+    //   function call is neglible.
+    // - It tends to be held for a while. Currently, we hold it while generating
+    //   Profiler::Bytecodes for a CodeBlock. That's uncommon and shouldn't affect
+    //   performance, but if we did have contention, we would want a sensible,
+    //   power-aware backoff. An adaptive mutex will do this as a matter of course,
+    //   but a spinlock won't.
+    typedef Mutex Lock;
+    typedef MutexLocker Locker;
+    
+
     void addDatabaseToAtExit();
     void removeDatabaseFromAtExit();
     void performAtExitSave() const;

Modified: trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/runtime/InitializeThreading.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,6 +56,7 @@
     std::call_once(initializeThreadingOnceFlag, []{
         WTF::double_conversion::initialize();
         WTF::initializeThreading();
+        GlobalJSLock::initialize();
         Options::initialize();
         if (Options::recordGCPauseTimes())
             HeapStatistics::initialize();
@@ -65,6 +66,7 @@
 #if ENABLE(ASSEMBLER)
         ExecutableAllocator::initializeAllocator();
 #endif
+        JSStack::initializeThreading();
         LLInt::initialize();
 #ifndef NDEBUG
         DisallowGC::initialize();

Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (188474 => 188475)


--- trunk/Source/_javascript_Core/runtime/JSLock.cpp	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp	2015-08-14 16:53:37 UTC (rev 188475)
@@ -30,18 +30,23 @@
 
 namespace JSC {
 
-StaticLock GlobalJSLock::s_sharedInstanceMutex;
+std::mutex* GlobalJSLock::s_sharedInstanceMutex;
 
 GlobalJSLock::GlobalJSLock()
 {
-    s_sharedInstanceMutex.lock();
+    s_sharedInstanceMutex->lock();
 }
 
 GlobalJSLock::~GlobalJSLock()
 {
-    s_sharedInstanceMutex.unlock();
+    s_sharedInstanceMutex->unlock();
 }
 
+void GlobalJSLock::initialize()
+{
+    s_sharedInstanceMutex = new std::mutex();
+}
+
 JSLockHolder::JSLockHolder(ExecState* exec)
     : m_vm(&exec->vm())
 {

Modified: trunk/Source/_javascript_Core/runtime/JSLock.h (188474 => 188475)


--- trunk/Source/_javascript_Core/runtime/JSLock.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/_javascript_Core/runtime/JSLock.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -24,7 +24,6 @@
 #include <mutex>
 #include <thread>
 #include <wtf/Assertions.h>
-#include <wtf/Lock.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RefPtr.h>
 #include <wtf/ThreadSafeRefCounted.h>
@@ -61,8 +60,10 @@
 public:
     JS_EXPORT_PRIVATE GlobalJSLock();
     JS_EXPORT_PRIVATE ~GlobalJSLock();
+
+    static void initialize();
 private:
-    static StaticLock s_sharedInstanceMutex;
+    static std::mutex* s_sharedInstanceMutex;
 };
 
 class JSLockHolder {
@@ -132,7 +133,7 @@
     unsigned dropAllLocks(DropAllLocks*);
     void grabAllLocks(DropAllLocks*, unsigned lockCount);
 
-    Lock m_lock;
+    std::mutex m_lock;
     std::thread::id m_ownerThreadID;
     intptr_t m_lockCount;
     unsigned m_lockDropDepth;

Modified: trunk/Source/WTF/ChangeLog (188474 => 188475)


--- trunk/Source/WTF/ChangeLog	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/WTF/ChangeLog	2015-08-14 16:53:37 UTC (rev 188475)
@@ -1,3 +1,18 @@
+2015-08-14  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r188444.
+        https://bugs.webkit.org/show_bug.cgi?id=148029
+
+        Broke GTK and EFL (see bug #148027) (Requested by philn on
+        #webkit).
+
+        Reverted changeset:
+
+        "Use WTF::Lock and WTF::Condition instead of WTF::Mutex,
+        WTF::ThreadCondition, std::mutex, and std::condition_variable"
+        https://bugs.webkit.org/show_bug.cgi?id=147999
+        http://trac.webkit.org/changeset/188444
+
 2015-08-13  Filip Pizlo  <[email protected]>
 
         Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable

Modified: trunk/Source/WTF/wtf/Condition.h (188474 => 188475)


--- trunk/Source/WTF/wtf/Condition.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/WTF/wtf/Condition.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -109,7 +109,5 @@
 
 } // namespace WTF
 
-using WTF::Condition;
-
 #endif // WTF_Condition_h
 

Modified: trunk/Source/WTF/wtf/Lock.h (188474 => 188475)


--- trunk/Source/WTF/wtf/Lock.h	2015-08-14 16:49:54 UTC (rev 188474)
+++ trunk/Source/WTF/wtf/Lock.h	2015-08-14 16:53:37 UTC (rev 188475)
@@ -56,23 +56,6 @@
         lockSlow();
     }
 
-    bool tryLock()
-    {
-        for (;;) {
-            uint8_t currentByteValue = m_byte.load();
-            if (currentByteValue & isHeldBit)
-                return false;
-            if (m_byte.compareExchangeWeak(currentByteValue, currentByteValue | isHeldBit))
-                return true;
-        }
-    }
-
-    // Need this version for std::unique_lock.
-    bool try_lock()
-    {
-        return tryLock();
-    }
-
     void unlock()
     {
         if (LIKELY(m_byte.compareExchangeWeak(isHeldBit, 0, std::memory_order_release))) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to