Changeset 188444 in webkit
- Timestamp:
- Aug 13, 2015, 11:46:46 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSVirtualMachine.mm
r174110 r188444 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 #import "SlotVisitorInlines.h" 38 38 #import <mutex> 39 #import <wtf/Lock.h> 39 40 #import <wtf/NeverDestroyed.h> 40 41 #import <wtf/spi/cocoa/NSMapTableSPI.h> … … 42 43 static NSMapTable *globalWrapperCache = 0; 43 44 44 static std::mutex& wrapperCacheMutex() 45 { 46 static NeverDestroyed<std::mutex> mutex; 47 48 return mutex; 49 } 45 static StaticLock wrapperCacheMutex; 50 46 51 47 static void initWrapperCache() … … 73 69 + (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group 74 70 { 75 std::lock_guard< std::mutex> lock(wrapperCacheMutex());71 std::lock_guard<StaticLock> lock(wrapperCacheMutex); 76 72 NSMapInsert(wrapperCache(), group, wrapper); 77 73 } … … 79 75 + (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group 80 76 { 81 std::lock_guard< std::mutex> lock(wrapperCacheMutex());77 std::lock_guard<StaticLock> lock(wrapperCacheMutex); 82 78 return static_cast<JSVirtualMachine *>(NSMapGet(wrapperCache(), group)); 83 79 } -
trunk/Source/JavaScriptCore/ChangeLog
r188436 r188444 1 2015-08-13 Filip Pizlo <[email protected]> 2 3 Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable 4 https://bugs.webkit.org/show_bug.cgi?id=147999 5 6 Reviewed by Geoffrey Garen. 7 8 * API/JSVirtualMachine.mm: 9 (initWrapperCache): 10 (+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]): 11 (+[JSVMWrapperCache wrapperForJSContextGroupRef:]): 12 (wrapperCacheMutex): Deleted. 13 * bytecode/SamplingTool.cpp: 14 (JSC::SamplingTool::doRun): 15 (JSC::SamplingTool::notifyOfScope): 16 * bytecode/SamplingTool.h: 17 * dfg/DFGThreadData.h: 18 * dfg/DFGWorklist.cpp: 19 (JSC::DFG::Worklist::~Worklist): 20 (JSC::DFG::Worklist::isActiveForVM): 21 (JSC::DFG::Worklist::enqueue): 22 (JSC::DFG::Worklist::compilationState): 23 (JSC::DFG::Worklist::waitUntilAllPlansForVMAreReady): 24 (JSC::DFG::Worklist::removeAllReadyPlansForVM): 25 (JSC::DFG::Worklist::completeAllReadyPlansForVM): 26 (JSC::DFG::Worklist::visitWeakReferences): 27 (JSC::DFG::Worklist::removeDeadPlans): 28 (JSC::DFG::Worklist::queueLength): 29 (JSC::DFG::Worklist::dump): 30 (JSC::DFG::Worklist::runThread): 31 * dfg/DFGWorklist.h: 32 * disassembler/Disassembler.cpp: 33 * heap/CopiedSpace.cpp: 34 (JSC::CopiedSpace::doneFillingBlock): 35 (JSC::CopiedSpace::doneCopying): 36 * heap/CopiedSpace.h: 37 * heap/CopiedSpaceInlines.h: 38 (JSC::CopiedSpace::recycleBorrowedBlock): 39 (JSC::CopiedSpace::allocateBlockForCopyingPhase): 40 * heap/GCThread.cpp: 41 (JSC::GCThread::waitForNextPhase): 42 (JSC::GCThread::gcThreadMain): 43 * heap/GCThreadSharedData.cpp: 44 (JSC::GCThreadSharedData::GCThreadSharedData): 45 (JSC::GCThreadSharedData::~GCThreadSharedData): 46 (JSC::GCThreadSharedData::startNextPhase): 47 (JSC::GCThreadSharedData::endCurrentPhase): 48 (JSC::GCThreadSharedData::didStartMarking): 49 (JSC::GCThreadSharedData::didFinishMarking): 50 * heap/GCThreadSharedData.h: 51 * heap/HeapTimer.h: 52 * heap/MachineStackMarker.cpp: 53 (JSC::ActiveMachineThreadsManager::Locker::Locker): 54 (JSC::ActiveMachineThreadsManager::add): 55 (JSC::ActiveMachineThreadsManager::remove): 56 (JSC::ActiveMachineThreadsManager::ActiveMachineThreadsManager): 57 (JSC::MachineThreads::~MachineThreads): 58 (JSC::MachineThreads::addCurrentThread): 59 (JSC::MachineThreads::removeThreadIfFound): 60 (JSC::MachineThreads::tryCopyOtherThreadStack): 61 (JSC::MachineThreads::tryCopyOtherThreadStacks): 62 (JSC::MachineThreads::gatherConservativeRoots): 63 * heap/MachineStackMarker.h: 64 * heap/SlotVisitor.cpp: 65 (JSC::SlotVisitor::donateKnownParallel): 66 (JSC::SlotVisitor::drain): 67 (JSC::SlotVisitor::drainFromShared): 68 (JSC::SlotVisitor::mergeOpaqueRoots): 69 * heap/SlotVisitorInlines.h: 70 (JSC::SlotVisitor::containsOpaqueRootTriState): 71 * inspector/remote/RemoteInspectorDebuggableConnection.h: 72 * inspector/remote/RemoteInspectorDebuggableConnection.mm: 73 (Inspector::RemoteInspectorHandleRunSourceGlobal): 74 (Inspector::RemoteInspectorQueueTaskOnGlobalQueue): 75 (Inspector::RemoteInspectorInitializeGlobalQueue): 76 (Inspector::RemoteInspectorHandleRunSourceWithInfo): 77 (Inspector::RemoteInspectorDebuggableConnection::setup): 78 (Inspector::RemoteInspectorDebuggableConnection::closeFromDebuggable): 79 (Inspector::RemoteInspectorDebuggableConnection::close): 80 (Inspector::RemoteInspectorDebuggableConnection::sendMessageToBackend): 81 (Inspector::RemoteInspectorDebuggableConnection::queueTaskOnPrivateRunLoop): 82 * interpreter/JSStack.cpp: 83 (JSC::JSStack::JSStack): 84 (JSC::JSStack::releaseExcessCapacity): 85 (JSC::JSStack::addToCommittedByteCount): 86 (JSC::JSStack::committedByteCount): 87 (JSC::stackStatisticsMutex): Deleted. 88 (JSC::JSStack::initializeThreading): Deleted. 89 * interpreter/JSStack.h: 90 (JSC::JSStack::gatherConservativeRoots): 91 (JSC::JSStack::sanitizeStack): 92 (JSC::JSStack::size): 93 (JSC::JSStack::initializeThreading): Deleted. 94 * jit/ExecutableAllocator.cpp: 95 (JSC::DemandExecutableAllocator::DemandExecutableAllocator): 96 (JSC::DemandExecutableAllocator::~DemandExecutableAllocator): 97 (JSC::DemandExecutableAllocator::bytesAllocatedByAllAllocators): 98 (JSC::DemandExecutableAllocator::bytesCommittedByAllocactors): 99 (JSC::DemandExecutableAllocator::dumpProfileFromAllAllocators): 100 (JSC::DemandExecutableAllocator::allocators): 101 (JSC::DemandExecutableAllocator::allocatorsMutex): 102 * jit/JITThunks.cpp: 103 (JSC::JITThunks::ctiStub): 104 * jit/JITThunks.h: 105 * profiler/ProfilerDatabase.cpp: 106 (JSC::Profiler::Database::ensureBytecodesFor): 107 (JSC::Profiler::Database::notifyDestruction): 108 * profiler/ProfilerDatabase.h: 109 * runtime/InitializeThreading.cpp: 110 (JSC::initializeThreading): 111 * runtime/JSLock.cpp: 112 (JSC::GlobalJSLock::GlobalJSLock): 113 (JSC::GlobalJSLock::~GlobalJSLock): 114 (JSC::JSLockHolder::JSLockHolder): 115 (JSC::GlobalJSLock::initialize): Deleted. 116 * runtime/JSLock.h: 117 1 118 2015-08-13 Commit Queue <[email protected]> 2 119 -
trunk/Source/JavaScriptCore/bytecode/SamplingTool.cpp
r188002 r188444 1 1 /* 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 286 286 #if ENABLE(CODEBLOCK_SAMPLING) 287 287 if (CodeBlock* codeBlock = sample.codeBlock()) { 288 MutexLocker locker(m_scriptSampleMapMutex);288 LockHolder locker(m_scriptSampleMapMutex); 289 289 ScriptSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable()); 290 290 ASSERT(record); … … 302 302 { 303 303 #if ENABLE(CODEBLOCK_SAMPLING) 304 MutexLocker locker(m_scriptSampleMapMutex);304 LockHolder locker(m_scriptSampleMapMutex); 305 305 m_scopeSampleMap->set(script, adoptPtr(new ScriptSampleRecord(vm, script))); 306 306 #else -
trunk/Source/JavaScriptCore/bytecode/SamplingTool.h
r188002 r188444 1 1 /* 2 * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 #include <wtf/Atomics.h> 37 37 #include <wtf/HashMap.h> 38 #include <wtf/Lock.h> 38 39 #include <wtf/MainThread.h> 39 40 #include <wtf/Spectrum.h> … … 339 340 340 341 #if ENABLE(CODEBLOCK_SAMPLING) 341 Mutexm_scriptSampleMapMutex;342 Lock m_scriptSampleMapMutex; 342 343 std::unique_ptr<ScriptSampleRecordMap> m_scopeSampleMap; 343 344 #endif -
trunk/Source/JavaScriptCore/dfg/DFGThreadData.h
r188002 r188444 1 1 /* 2 * Copyright (C) 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2014, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if ENABLE(DFG_JIT) 30 30 31 #include <wtf/Lock.h> 31 32 #include <wtf/Threading.h> 32 #include <wtf/ThreadingPrimitives.h>33 33 34 34 namespace JSC { namespace DFG { … … 49 49 Worklist* m_worklist; 50 50 ThreadIdentifier m_identifier; 51 Mutexm_rightToRun;51 Lock m_rightToRun; 52 52 Safepoint* m_safepoint; 53 53 }; -
trunk/Source/JavaScriptCore/dfg/DFGWorklist.cpp
r188002 r188444 47 47 { 48 48 { 49 MutexLocker locker(m_lock);49 LockHolder locker(m_lock); 50 50 for (unsigned i = m_threads.size(); i--;) 51 51 m_queue.append(nullptr); // Use null plan to indicate that we want the thread to terminate. 52 m_planEnqueued. broadcast();52 m_planEnqueued.notifyAll(); 53 53 } 54 54 for (unsigned i = m_threads.size(); i--;) … … 78 78 bool Worklist::isActiveForVM(VM& vm) const 79 79 { 80 MutexLocker locker(m_lock);80 LockHolder locker(m_lock); 81 81 PlanMap::const_iterator end = m_plans.end(); 82 82 for (PlanMap::const_iterator iter = m_plans.begin(); iter != end; ++iter) { … … 90 90 { 91 91 RefPtr<Plan> plan = passedPlan; 92 MutexLocker locker(m_lock);92 LockHolder locker(m_lock); 93 93 if (Options::verboseCompilationQueue()) { 94 94 dump(locker, WTF::dataFile()); … … 98 98 m_plans.add(plan->key(), plan); 99 99 m_queue.append(plan); 100 m_planEnqueued. signal();100 m_planEnqueued.notifyOne(); 101 101 } 102 102 103 103 Worklist::State Worklist::compilationState(CompilationKey key) 104 104 { 105 MutexLocker locker(m_lock);105 LockHolder locker(m_lock); 106 106 PlanMap::iterator iter = m_plans.find(key); 107 107 if (iter == m_plans.end()) … … 119 119 // be adding plans, our VM will not be. 120 120 121 MutexLocker locker(m_lock);121 LockHolder locker(m_lock); 122 122 123 123 if (Options::verboseCompilationQueue()) { … … 148 148 { 149 149 DeferGC deferGC(vm.heap); 150 MutexLocker locker(m_lock);150 LockHolder locker(m_lock); 151 151 for (size_t i = 0; i < m_readyPlans.size(); ++i) { 152 152 RefPtr<Plan> plan = m_readyPlans[i]; … … 193 193 194 194 if (!!requestedKey && resultingState == NotKnown) { 195 MutexLocker locker(m_lock);195 LockHolder locker(m_lock); 196 196 if (m_plans.contains(requestedKey)) 197 197 resultingState = Compiling; … … 226 226 VM* vm = visitor.heap()->vm(); 227 227 { 228 MutexLocker locker(m_lock);228 LockHolder locker(m_lock); 229 229 for (PlanMap::iterator iter = m_plans.begin(); iter != m_plans.end(); ++iter) { 230 230 Plan* plan = iter->value.get(); … … 249 249 { 250 250 { 251 MutexLocker locker(m_lock);251 LockHolder locker(m_lock); 252 252 HashSet<CompilationKey> deadPlanKeys; 253 253 for (PlanMap::iterator iter = m_plans.begin(); iter != m_plans.end(); ++iter) { … … 296 296 size_t Worklist::queueLength() 297 297 { 298 MutexLocker locker(m_lock);298 LockHolder locker(m_lock); 299 299 return m_queue.size(); 300 300 } … … 302 302 void Worklist::dump(PrintStream& out) const 303 303 { 304 MutexLocker locker(m_lock);304 LockHolder locker(m_lock); 305 305 dump(locker, out); 306 306 } 307 307 308 void Worklist::dump(const MutexLocker&, PrintStream& out) const308 void Worklist::dump(const LockHolder&, PrintStream& out) const 309 309 { 310 310 out.print( … … 326 326 RefPtr<Plan> plan; 327 327 { 328 MutexLocker locker(m_lock);328 LockHolder locker(m_lock); 329 329 while (m_queue.isEmpty()) 330 330 m_planEnqueued.wait(m_lock); … … 342 342 343 343 { 344 MutexLocker locker(data->m_rightToRun);344 LockHolder locker(data->m_rightToRun); 345 345 { 346 MutexLocker locker(m_lock);346 LockHolder locker(m_lock); 347 347 if (plan->stage == Plan::Cancelled) { 348 348 m_numberOfActiveThreads--; … … 360 360 361 361 { 362 MutexLocker locker(m_lock);362 LockHolder locker(m_lock); 363 363 if (plan->stage == Plan::Cancelled) { 364 364 m_numberOfActiveThreads--; … … 371 371 372 372 { 373 MutexLocker locker(m_lock);373 LockHolder locker(m_lock); 374 374 375 375 // We could have been cancelled between releasing rightToRun and acquiring m_lock. … … 389 389 m_readyPlans.append(plan); 390 390 391 m_planCompiled. broadcast();391 m_planCompiled.notifyAll(); 392 392 m_numberOfActiveThreads--; 393 393 } -
trunk/Source/JavaScriptCore/dfg/DFGWorklist.h
r188002 r188444 31 31 #include "DFGPlan.h" 32 32 #include "DFGThreadData.h" 33 #include <wtf/Condition.h> 33 34 #include <wtf/Deque.h> 34 35 #include <wtf/HashMap.h> 36 #include <wtf/Lock.h> 35 37 #include <wtf/Noncopyable.h> 36 #include <wtf/ThreadingPrimitives.h>37 38 38 39 namespace JSC { … … 86 87 void removeAllReadyPlansForVM(VM&, Vector<RefPtr<Plan>, 8>&); 87 88 88 void dump(const MutexLocker&, PrintStream&) const;89 void dump(const LockHolder&, PrintStream&) const; 89 90 90 91 CString m_threadName; … … 104 105 Vector<RefPtr<Plan>, 16> m_readyPlans; 105 106 106 Mutexm_suspensionLock;107 Lock m_suspensionLock; 107 108 108 mutable Mutexm_lock;109 ThreadCondition m_planEnqueued;110 ThreadCondition m_planCompiled;109 mutable Lock m_lock; 110 Condition m_planEnqueued; 111 Condition m_planCompiled; 111 112 112 113 Vector<std::unique_ptr<ThreadData>> m_threads; -
trunk/Source/JavaScriptCore/disassembler/Disassembler.cpp
r188002 r188444 28 28 29 29 #include "MacroAssemblerCodeRef.h" 30 #include <wtf/Condition.h> 30 31 #include <wtf/DataLog.h> 31 32 #include <wtf/Deque.h> 33 #include <wtf/Lock.h> 32 34 #include <wtf/NeverDestroyed.h> 33 35 #include <wtf/StringPrintStream.h> 34 36 #include <wtf/Threading.h> 35 #include <wtf/ThreadingPrimitives.h>36 37 37 38 namespace JSC { … … 79 80 void enqueue(std::unique_ptr<DisassemblyTask> task) 80 81 { 81 MutexLocker locker(m_lock);82 LockHolder locker(m_lock); 82 83 m_queue.append(WTF::move(task)); 83 m_condition. broadcast();84 m_condition.notifyAll(); 84 85 } 85 86 86 87 void waitUntilEmpty() 87 88 { 88 MutexLocker locker(m_lock);89 LockHolder locker(m_lock); 89 90 while (!m_queue.isEmpty() || m_working) 90 91 m_condition.wait(m_lock); … … 97 98 std::unique_ptr<DisassemblyTask> task; 98 99 { 99 MutexLocker locker(m_lock);100 LockHolder locker(m_lock); 100 101 m_working = false; 101 m_condition. broadcast();102 m_condition.notifyAll(); 102 103 while (m_queue.isEmpty()) 103 104 m_condition.wait(m_lock); … … 113 114 } 114 115 115 Mutexm_lock;116 ThreadCondition m_condition;116 Lock m_lock; 117 Condition m_condition; 117 118 Deque<std::unique_ptr<DisassemblyTask>> m_queue; 118 119 bool m_working { false }; -
trunk/Source/JavaScriptCore/heap/CopiedSpace.cpp
r188169 r188444 199 199 200 200 { 201 MutexLocker locker(m_loanedBlocksLock);201 LockHolder locker(m_loanedBlocksLock); 202 202 ASSERT(m_numberOfLoanedBlocks > 0); 203 203 ASSERT(m_inCopyingPhase); 204 204 m_numberOfLoanedBlocks--; 205 205 if (!m_numberOfLoanedBlocks) 206 m_loanedBlocksCondition. signal();206 m_loanedBlocksCondition.notifyOne(); 207 207 } 208 208 } … … 232 232 { 233 233 { 234 MutexLocker locker(m_loanedBlocksLock);234 LockHolder locker(m_loanedBlocksLock); 235 235 while (m_numberOfLoanedBlocks > 0) 236 236 m_loanedBlocksCondition.wait(m_loanedBlocksLock); -
trunk/Source/JavaScriptCore/heap/CopiedSpace.h
r188169 r188444 32 32 #include <wtf/Assertions.h> 33 33 #include <wtf/CheckedBoolean.h> 34 #include <wtf/Condition.h> 34 35 #include <wtf/DoublyLinkedList.h> 35 36 #include <wtf/HashSet.h> … … 38 39 #include <wtf/PageBlock.h> 39 40 #include <wtf/StdLibExtras.h> 40 #include <wtf/ThreadingPrimitives.h>41 41 42 42 namespace JSC { … … 139 139 bool m_shouldDoCopyPhase; 140 140 141 Mutexm_loanedBlocksLock;142 ThreadCondition m_loanedBlocksCondition;141 Lock m_loanedBlocksLock; 142 Condition m_loanedBlocksCondition; 143 143 size_t m_numberOfLoanedBlocks; 144 144 -
trunk/Source/JavaScriptCore/heap/CopiedSpaceInlines.h
r188169 r188444 114 114 115 115 { 116 MutexLocker locker(m_loanedBlocksLock);116 LockHolder locker(m_loanedBlocksLock); 117 117 ASSERT(m_numberOfLoanedBlocks > 0); 118 118 ASSERT(m_inCopyingPhase); 119 119 m_numberOfLoanedBlocks--; 120 120 if (!m_numberOfLoanedBlocks) 121 m_loanedBlocksCondition. signal();121 m_loanedBlocksCondition.notifyOne(); 122 122 } 123 123 } … … 129 129 130 130 { 131 MutexLocker locker(m_loanedBlocksLock);131 LockHolder locker(m_loanedBlocksLock); 132 132 m_numberOfLoanedBlocks++; 133 133 } -
trunk/Source/JavaScriptCore/heap/GCThread.cpp
r183005 r188444 70 70 GCPhase GCThread::waitForNextPhase() 71 71 { 72 std::unique_lock< std::mutex> lock(m_shared.m_phaseMutex);72 std::unique_lock<Lock> lock(m_shared.m_phaseMutex); 73 73 m_shared.m_phaseConditionVariable.wait(lock, [this] { return !m_shared.m_gcThreadsShouldWait; }); 74 74 75 75 m_shared.m_numberOfActiveGCThreads--; 76 76 if (!m_shared.m_numberOfActiveGCThreads) 77 m_shared.m_activityConditionVariable.notify _one();77 m_shared.m_activityConditionVariable.notifyOne(); 78 78 79 79 m_shared.m_phaseConditionVariable.wait(lock, [this] { return m_shared.m_currentPhase != NoPhase; }); … … 91 91 // creating this thread. We aren't guaranteed to have a valid threadID until the main thread releases this lock. 92 92 { 93 std::lock_guard< std::mutex> lock(m_shared.m_phaseMutex);93 std::lock_guard<Lock> lock(m_shared.m_phaseMutex); 94 94 } 95 95 { -
trunk/Source/JavaScriptCore/heap/GCThreadSharedData.cpp
r188169 r188444 1 1 /* 2 * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 84 84 #if ENABLE(PARALLEL_GC) 85 85 // Grab the lock so the new GC threads can be properly initialized before they start running. 86 std::unique_lock< std::mutex> lock(m_phaseMutex);86 std::unique_lock<Lock> lock(m_phaseMutex); 87 87 for (unsigned i = 1; i < Options::numberOfGCMarkers(); ++i) { 88 88 m_numberOfActiveGCThreads++; … … 103 103 // Destroy our marking threads. 104 104 { 105 std::lock_guard< std::mutex> markingLock(m_markingMutex);106 std::lock_guard< std::mutex> phaseLock(m_phaseMutex);105 std::lock_guard<Lock> markingLock(m_markingMutex); 106 std::lock_guard<Lock> phaseLock(m_phaseMutex); 107 107 ASSERT(m_currentPhase == NoPhase); 108 108 m_parallelMarkersShouldExit = true; 109 109 m_gcThreadsShouldWait = false; 110 110 m_currentPhase = Exit; 111 m_phaseConditionVariable.notify _all();111 m_phaseConditionVariable.notifyAll(); 112 112 } 113 113 for (unsigned i = 0; i < m_gcThreads.size(); ++i) { … … 132 132 void GCThreadSharedData::startNextPhase(GCPhase phase) 133 133 { 134 std::lock_guard< std::mutex> lock(m_phaseMutex);134 std::lock_guard<Lock> lock(m_phaseMutex); 135 135 ASSERT(!m_gcThreadsShouldWait); 136 136 ASSERT(m_currentPhase == NoPhase); 137 137 m_gcThreadsShouldWait = true; 138 138 m_currentPhase = phase; 139 m_phaseConditionVariable.notify _all();139 m_phaseConditionVariable.notifyAll(); 140 140 } 141 141 … … 143 143 { 144 144 ASSERT(m_gcThreadsShouldWait); 145 std::unique_lock< std::mutex> lock(m_phaseMutex);145 std::unique_lock<Lock> lock(m_phaseMutex); 146 146 m_currentPhase = NoPhase; 147 147 m_gcThreadsShouldWait = false; 148 m_phaseConditionVariable.notify _all();148 m_phaseConditionVariable.notifyAll(); 149 149 m_activityConditionVariable.wait(lock, [this] { return !m_numberOfActiveGCThreads; }); 150 150 } … … 159 159 #endif 160 160 } 161 std::lock_guard< std::mutex> lock(m_markingMutex);161 std::lock_guard<Lock> lock(m_markingMutex); 162 162 m_parallelMarkersShouldExit = false; 163 163 startNextPhase(Mark); … … 167 167 { 168 168 { 169 std::lock_guard< std::mutex> lock(m_markingMutex);169 std::lock_guard<Lock> lock(m_markingMutex); 170 170 m_parallelMarkersShouldExit = true; 171 m_markingConditionVariable.notify _all();171 m_markingConditionVariable.notifyAll(); 172 172 } 173 173 -
trunk/Source/JavaScriptCore/heap/GCThreadSharedData.h
r188169 r188444 1 1 /* 2 * Copyright (C) 2009, 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "WeakReferenceHarvester.h" 34 34 #include <condition_variable> 35 #include <wtf/Condition.h> 35 36 #include <wtf/HashSet.h> 36 37 #include <wtf/Lock.h> … … 89 90 Vector<GCThread*> m_gcThreads; 90 91 91 std::mutexm_markingMutex;92 std::condition_variablem_markingConditionVariable;92 Lock m_markingMutex; 93 Condition m_markingConditionVariable; 93 94 MarkStackArray m_sharedMarkStack; 94 95 unsigned m_numberOfActiveParallelMarkers; 95 96 bool m_parallelMarkersShouldExit; 96 97 97 std::mutexm_opaqueRootsMutex;98 Lock m_opaqueRootsMutex; 98 99 HashSet<void*> m_opaqueRoots; 99 100 … … 103 104 static const size_t s_blockFragmentLength = 32; 104 105 105 std::mutexm_phaseMutex;106 std::condition_variablem_phaseConditionVariable;107 std::condition_variablem_activityConditionVariable;106 Lock m_phaseMutex; 107 Condition m_phaseConditionVariable; 108 Condition m_activityConditionVariable; 108 109 unsigned m_numberOfActiveGCThreads; 109 110 bool m_gcThreadsShouldWait; -
trunk/Source/JavaScriptCore/heap/HeapTimer.h
r188002 r188444 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define HeapTimer_h 28 28 29 #include <wtf/Lock.h> 29 30 #include <wtf/RetainPtr.h> 30 31 #include <wtf/Threading.h> … … 60 61 CFRunLoopTimerContext m_context; 61 62 62 Mutexm_shutdownMutex;63 Lock m_shutdownMutex; 63 64 #elif PLATFORM(EFL) 64 65 static bool timerEvent(void*); -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.cpp
r188311 r188444 104 104 105 105 private: 106 MutexLocker m_locker;106 LockHolder m_locker; 107 107 }; 108 108 109 109 void add(MachineThreads* machineThreads) 110 110 { 111 MutexLocker managerLock(m_lock);111 LockHolder managerLock(m_lock); 112 112 m_set.add(machineThreads); 113 113 } … … 115 115 void remove(MachineThreads* machineThreads) 116 116 { 117 MutexLocker managerLock(m_lock);117 LockHolder managerLock(m_lock); 118 118 auto recordedMachineThreads = m_set.take(machineThreads); 119 119 RELEASE_ASSERT(recordedMachineThreads = machineThreads); … … 130 130 ActiveMachineThreadsManager() { } 131 131 132 Mutexm_lock;132 Lock m_lock; 133 133 MachineThreadsSet m_set; 134 134 … … 264 264 threadSpecificKeyDelete(m_threadSpecific); 265 265 266 MutexLocker registeredThreadsLock(m_registeredThreadsMutex);266 LockHolder registeredThreadsLock(m_registeredThreadsMutex); 267 267 for (Thread* t = m_registeredThreads; t;) { 268 268 Thread* next = t->next; … … 295 295 Thread* thread = Thread::createForCurrentThread(); 296 296 297 MutexLocker lock(m_registeredThreadsMutex);297 LockHolder lock(m_registeredThreadsMutex); 298 298 299 299 thread->next = m_registeredThreads; … … 319 319 void MachineThreads::removeThreadIfFound(PlatformThread platformThread) 320 320 { 321 MutexLocker lock(m_registeredThreadsMutex);321 LockHolder lock(m_registeredThreadsMutex); 322 322 Thread* t = m_registeredThreads; 323 323 if (*t == platformThread) { … … 567 567 } 568 568 569 bool MachineThreads::tryCopyOtherThreadStacks( MutexLocker&, void* buffer, size_t capacity, size_t* size)569 bool MachineThreads::tryCopyOtherThreadStacks(LockHolder&, void* buffer, size_t capacity, size_t* size) 570 570 { 571 571 // Prevent two VMs from suspending each other's threads at the same time, … … 661 661 size_t capacity = 0; 662 662 void* buffer = nullptr; 663 MutexLocker lock(m_registeredThreadsMutex);663 LockHolder lock(m_registeredThreadsMutex); 664 664 while (!tryCopyOtherThreadStacks(lock, buffer, capacity, &size)) 665 665 growBuffer(size, &buffer, &capacity); -
trunk/Source/JavaScriptCore/heap/MachineStackMarker.h
r188002 r188444 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2015 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 24 24 25 25 #include <setjmp.h> 26 #include <wtf/Lock.h> 26 27 #include <wtf/Noncopyable.h> 27 28 #include <wtf/ThreadSpecific.h> 28 #include <wtf/ThreadingPrimitives.h>29 29 30 30 namespace JSC { … … 53 53 54 54 void tryCopyOtherThreadStack(Thread*, void*, size_t capacity, size_t*); 55 bool tryCopyOtherThreadStacks( MutexLocker&, void*, size_t capacity, size_t*);55 bool tryCopyOtherThreadStacks(LockHolder&, void*, size_t capacity, size_t*); 56 56 57 57 static void removeThread(void*); … … 60 60 void removeThreadIfFound(PlatformThread); 61 61 62 Mutexm_registeredThreadsMutex;62 Lock m_registeredThreadsMutex; 63 63 Thread* m_registeredThreads; 64 64 WTF::ThreadSpecificKey m_threadSpecific; -
trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp
r179348 r188444 1 /* 2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 1 26 #include "config.h" 2 27 #include "SlotVisitor.h" … … 13 38 #include "JSString.h" 14 39 #include "JSCInlines.h" 40 #include <wtf/Lock.h> 15 41 #include <wtf/StackStats.h> 16 42 … … 122 148 // If we're contending on the lock, be conservative and assume that another 123 149 // thread is already donating. 124 std::unique_lock< std::mutex> lock(m_shared.m_markingMutex, std::try_to_lock);150 std::unique_lock<Lock> lock(m_shared.m_markingMutex, std::try_to_lock); 125 151 if (!lock.owns_lock()) 126 152 return; … … 130 156 131 157 if (m_shared.m_numberOfActiveParallelMarkers < Options::numberOfGCMarkers()) 132 m_shared.m_markingConditionVariable.notify _all();158 m_shared.m_markingConditionVariable.notifyAll(); 133 159 } 134 160 … … 185 211 #if ENABLE(PARALLEL_GC) 186 212 { 187 std::lock_guard< std::mutex> lock(m_shared.m_markingMutex);213 std::lock_guard<Lock> lock(m_shared.m_markingMutex); 188 214 m_shared.m_numberOfActiveParallelMarkers++; 189 215 } 190 216 while (true) { 191 217 { 192 std::unique_lock< std::mutex> lock(m_shared.m_markingMutex);218 std::unique_lock<Lock> lock(m_shared.m_markingMutex); 193 219 m_shared.m_numberOfActiveParallelMarkers--; 194 220 … … 201 227 if (!m_shared.m_numberOfActiveParallelMarkers && m_shared.m_sharedMarkStack.isEmpty()) { 202 228 // Let any sleeping slaves know it's time for them to return; 203 m_shared.m_markingConditionVariable.notify _all();229 m_shared.m_markingConditionVariable.notifyAll(); 204 230 return; 205 231 } … … 217 243 // Did we detect termination? If so, let the master know. 218 244 if (!m_shared.m_numberOfActiveParallelMarkers && m_shared.m_sharedMarkStack.isEmpty()) 219 m_shared.m_markingConditionVariable.notify _all();245 m_shared.m_markingConditionVariable.notifyAll(); 220 246 221 247 m_shared.m_markingConditionVariable.wait(lock, [this] { return !m_shared.m_sharedMarkStack.isEmpty() || m_shared.m_parallelMarkersShouldExit; }); … … 241 267 ASSERT(!m_opaqueRoots.isEmpty()); // Should only be called when opaque roots are non-empty. 242 268 { 243 std::lock_guard< std::mutex> lock(m_shared.m_opaqueRootsMutex);269 std::lock_guard<Lock> lock(m_shared.m_opaqueRootsMutex); 244 270 for (auto* root : m_opaqueRoots) 245 271 m_shared.m_opaqueRoots.add(root); -
trunk/Source/JavaScriptCore/heap/SlotVisitorInlines.h
r188169 r188444 189 189 if (m_opaqueRoots.contains(root)) 190 190 return TrueTriState; 191 std::lock_guard< std::mutex> lock(m_shared.m_opaqueRootsMutex);191 std::lock_guard<Lock> lock(m_shared.m_opaqueRootsMutex); 192 192 if (m_shared.m_opaqueRoots.contains(root)) 193 193 return TrueTriState; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h
r183319 r188444 32 32 #import "RemoteInspectorDebuggable.h" 33 33 #import <mutex> 34 #import <wtf/Lock.h> 34 35 #import <wtf/RetainPtr.h> 35 36 #import <wtf/ThreadSafeRefCounted.h> … … 92 93 virtual bool sendMessageToFrontend(const String&) override; 93 94 94 std::mutex& queueMutex() { return m_queueMutex; }95 Lock& queueMutex() { return m_queueMutex; } 95 96 RemoteInspectorQueue queue() const { return m_queue; } 96 97 void clearQueue() { m_queue.clear(); } … … 106 107 // can be used on multiple threads. So any access to the debuggable 107 108 // itself must take this mutex to ensure m_debuggable is valid. 108 std::mutexm_debuggableMutex;109 Lock m_debuggableMutex; 109 110 110 111 // If a debuggable has a specific run loop it wants to evaluate on … … 113 114 RetainPtr<CFRunLoopSourceRef> m_runLoopSource; 114 115 RemoteInspectorQueue m_queue; 115 std::mutexm_queueMutex;116 Lock m_queueMutex; 116 117 117 118 RemoteInspectorDebuggable* m_debuggable; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.mm
r183319 r188444 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All Rights Reserved.2 * Copyright (C) 2013, 2015 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 40 40 namespace Inspector { 41 41 42 static std::mutex*rwiQueueMutex;42 static StaticLock rwiQueueMutex; 43 43 static CFRunLoopSourceRef rwiRunLoopSource; 44 44 static RemoteInspectorQueue* rwiQueue; … … 47 47 { 48 48 ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain()); 49 ASSERT(rwiQueueMutex);50 49 ASSERT(rwiRunLoopSource); 51 50 ASSERT(rwiQueue); … … 53 52 RemoteInspectorQueue queueCopy; 54 53 { 55 std::lock_guard< std::mutex> lock(*rwiQueueMutex);54 std::lock_guard<StaticLock> lock(rwiQueueMutex); 56 55 queueCopy = *rwiQueue; 57 56 rwiQueue->clear(); … … 64 63 static void RemoteInspectorQueueTaskOnGlobalQueue(void (^task)()) 65 64 { 66 ASSERT(rwiQueueMutex);67 65 ASSERT(rwiRunLoopSource); 68 66 ASSERT(rwiQueue); 69 67 70 68 { 71 std::lock_guard< std::mutex> lock(*rwiQueueMutex);69 std::lock_guard<StaticLock> lock(rwiQueueMutex); 72 70 rwiQueue->append(RemoteInspectorBlock(task)); 73 71 } … … 82 80 dispatch_once(&pred, ^{ 83 81 rwiQueue = new RemoteInspectorQueue; 84 rwiQueueMutex = std::make_unique<std::mutex>().release();85 82 86 83 CFRunLoopSourceContext runLoopSourceContext = {0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteInspectorHandleRunSourceGlobal}; … … 99 96 RemoteInspectorQueue queueCopy; 100 97 { 101 std::lock_guard< std::mutex> lock(debuggableConnection->queueMutex());98 std::lock_guard<Lock> lock(debuggableConnection->queueMutex()); 102 99 queueCopy = debuggableConnection->queue(); 103 100 debuggableConnection->clearQueue(); … … 153 150 bool RemoteInspectorDebuggableConnection::setup(bool isAutomaticInspection, bool automaticallyPause) 154 151 { 155 std::lock_guard< std::mutex> lock(m_debuggableMutex);152 std::lock_guard<Lock> lock(m_debuggableMutex); 156 153 157 154 if (!m_debuggable) … … 161 158 dispatchAsyncOnDebuggable(^{ 162 159 { 163 std::lock_guard< std::mutex> lock(m_debuggableMutex);160 std::lock_guard<Lock> lock(m_debuggableMutex); 164 161 if (!m_debuggable || !m_debuggable->remoteDebuggingAllowed() || m_debuggable->hasLocalDebugger()) { 165 162 RemoteInspector::singleton().setupFailed(identifier()); … … 181 178 void RemoteInspectorDebuggableConnection::closeFromDebuggable() 182 179 { 183 std::lock_guard< std::mutex> lock(m_debuggableMutex);180 std::lock_guard<Lock> lock(m_debuggableMutex); 184 181 185 182 m_debuggable = nullptr; … … 191 188 dispatchAsyncOnDebuggable(^{ 192 189 { 193 std::lock_guard< std::mutex> lock(m_debuggableMutex);190 std::lock_guard<Lock> lock(m_debuggableMutex); 194 191 195 192 if (m_debuggable) { … … 211 208 RemoteInspectorDebuggable* debuggable = nullptr; 212 209 { 213 std::lock_guard< std::mutex> lock(m_debuggableMutex);210 std::lock_guard<Lock> lock(m_debuggableMutex); 214 211 if (!m_debuggable) 215 212 return; … … 264 261 265 262 { 266 std::lock_guard< std::mutex> lock(m_queueMutex);263 std::lock_guard<Lock> lock(m_queueMutex); 267 264 m_queue.append(RemoteInspectorBlock(block)); 268 265 } -
trunk/Source/JavaScriptCore/interpreter/JSStack.cpp
r188002 r188444 1 1 /* 2 * Copyright (C) 2008, 2013, 2014 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2013, 2014, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 34 34 #include "JSCInlines.h" 35 35 #include "Options.h" 36 #include <wtf/Lock.h> 36 37 37 38 namespace JSC { … … 40 41 static size_t committedBytesCount = 0; 41 42 42 static Mutex& stackStatisticsMutex() 43 { 44 DEPRECATED_DEFINE_STATIC_LOCAL(Mutex, staticMutex, ()); 45 return staticMutex; 46 } 43 static StaticLock stackStatisticsMutex; 47 44 #endif // !ENABLE(JIT) 48 45 … … 140 137 } 141 138 142 void JSStack::initializeThreading()143 {144 stackStatisticsMutex();145 }146 147 139 void JSStack::addToCommittedByteCount(long byteCount) 148 140 { 149 MutexLocker locker(stackStatisticsMutex());141 LockHolder locker(stackStatisticsMutex); 150 142 ASSERT(static_cast<long>(committedBytesCount) + byteCount > -1); 151 143 committedBytesCount += byteCount; … … 177 169 { 178 170 #if !ENABLE(JIT) 179 MutexLocker locker(stackStatisticsMutex());171 LockHolder locker(stackStatisticsMutex); 180 172 return committedBytesCount; 181 173 #else -
trunk/Source/JavaScriptCore/interpreter/JSStack.h
r178856 r188444 83 83 void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&) { } 84 84 void sanitizeStack() { } 85 static void initializeThreading() { }86 85 #else 87 86 ~JSStack(); … … 97 96 98 97 size_t size() const { return highAddress() - lowAddress(); } 99 100 static void initializeThreading();101 98 102 99 void setReservedZoneSize(size_t); -
trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp
r185532 r188444 32 32 #include "CodeProfiling.h" 33 33 #include <wtf/HashSet.h> 34 #include <wtf/Lock.h> 34 35 #include <wtf/MetaAllocator.h> 35 36 #include <wtf/NeverDestroyed.h> 36 37 #include <wtf/PageReservation.h> 37 #include <wtf/ThreadingPrimitives.h>38 38 #include <wtf/VMTags.h> 39 39 #endif … … 57 57 : MetaAllocator(jitAllocationGranule) 58 58 { 59 std::lock_guard< std::mutex> lock(allocatorsMutex());59 std::lock_guard<StaticLock> lock(allocatorsMutex()); 60 60 allocators().add(this); 61 61 // Don't preallocate any memory here. … … 65 65 { 66 66 { 67 std::lock_guard< std::mutex> lock(allocatorsMutex());67 std::lock_guard<StaticLock> lock(allocatorsMutex()); 68 68 allocators().remove(this); 69 69 } … … 75 75 { 76 76 size_t total = 0; 77 std::lock_guard< std::mutex> lock(allocatorsMutex());77 std::lock_guard<StaticLock> lock(allocatorsMutex()); 78 78 for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) 79 79 total += (*allocator)->bytesAllocated(); … … 84 84 { 85 85 size_t total = 0; 86 std::lock_guard< std::mutex> lock(allocatorsMutex());86 std::lock_guard<StaticLock> lock(allocatorsMutex()); 87 87 for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) 88 88 total += (*allocator)->bytesCommitted(); … … 93 93 static void dumpProfileFromAllAllocators() 94 94 { 95 std::lock_guard< std::mutex> lock(allocatorsMutex());95 std::lock_guard<StaticLock> lock(allocatorsMutex()); 96 96 for (HashSet<DemandExecutableAllocator*>::const_iterator allocator = allocators().begin(); allocator != allocators().end(); ++allocator) 97 97 (*allocator)->dumpProfile(); … … 139 139 } 140 140 141 static std::mutex& allocatorsMutex()142 { 143 static NeverDestroyed<std::mutex>mutex;141 static StaticLock& allocatorsMutex() 142 { 143 static StaticLock mutex; 144 144 145 145 return mutex; -
trunk/Source/JavaScriptCore/jit/JITThunks.cpp
r181250 r188444 1 1 /* 2 * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2013, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 67 67 MacroAssemblerCodeRef JITThunks::ctiStub(VM* vm, ThunkGenerator generator) 68 68 { 69 Lock er locker(m_lock);69 LockHolder locker(m_lock); 70 70 CTIStubMap::AddResult entry = m_ctiStubMap.add(generator, MacroAssemblerCodeRef()); 71 71 if (entry.isNewEntry) { -
trunk/Source/JavaScriptCore/jit/JITThunks.h
r188002 r188444 64 64 65 65 private: 66 // Main thread can hold this lock for a while, so use an adaptive mutex.67 typedef Mutex Lock;68 typedef MutexLocker Locker;69 70 66 void finalize(Handle<Unknown>, void* context) override; 71 67 -
trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp
r188169 r188444 58 58 Bytecodes* Database::ensureBytecodesFor(CodeBlock* codeBlock) 59 59 { 60 Lock er locker(m_lock);60 LockHolder locker(m_lock); 61 61 62 62 codeBlock = codeBlock->baselineVersion(); … … 76 76 void Database::notifyDestruction(CodeBlock* codeBlock) 77 77 { 78 Lock er locker(m_lock);78 LockHolder locker(m_lock); 79 79 80 80 m_bytecodesMap.remove(codeBlock); -
trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.h
r188002 r188444 33 33 #include <wtf/FastMalloc.h> 34 34 #include <wtf/HashMap.h> 35 #include <wtf/Lock.h> 35 36 #include <wtf/Noncopyable.h> 36 37 #include <wtf/PassRefPtr.h> … … 71 72 72 73 private: 73 // Use a full-blown adaptive mutex because:74 // - There is only one ProfilerDatabase per VM. The size overhead of the system's75 // mutex is negligible if you only have one of them.76 // - It's locked infrequently - once per bytecode generation, compilation, and77 // code block collection - so the fact that the fast path still requires a78 // function call is neglible.79 // - It tends to be held for a while. Currently, we hold it while generating80 // Profiler::Bytecodes for a CodeBlock. That's uncommon and shouldn't affect81 // performance, but if we did have contention, we would want a sensible,82 // power-aware backoff. An adaptive mutex will do this as a matter of course,83 // but a spinlock won't.84 typedef Mutex Lock;85 typedef MutexLocker Locker;86 87 88 74 void addDatabaseToAtExit(); 89 75 void removeDatabaseFromAtExit(); -
trunk/Source/JavaScriptCore/runtime/InitializeThreading.cpp
r170147 r188444 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 57 57 WTF::double_conversion::initialize(); 58 58 WTF::initializeThreading(); 59 GlobalJSLock::initialize();60 59 Options::initialize(); 61 60 if (Options::recordGCPauseTimes()) … … 67 66 ExecutableAllocator::initializeAllocator(); 68 67 #endif 69 JSStack::initializeThreading();70 68 LLInt::initialize(); 71 69 #ifndef NDEBUG -
trunk/Source/JavaScriptCore/runtime/JSLock.cpp
r187026 r188444 31 31 namespace JSC { 32 32 33 std::mutex*GlobalJSLock::s_sharedInstanceMutex;33 StaticLock GlobalJSLock::s_sharedInstanceMutex; 34 34 35 35 GlobalJSLock::GlobalJSLock() 36 36 { 37 s_sharedInstanceMutex ->lock();37 s_sharedInstanceMutex.lock(); 38 38 } 39 39 40 40 GlobalJSLock::~GlobalJSLock() 41 41 { 42 s_sharedInstanceMutex->unlock(); 43 } 44 45 void GlobalJSLock::initialize() 46 { 47 s_sharedInstanceMutex = new std::mutex(); 42 s_sharedInstanceMutex.unlock(); 48 43 } 49 44 -
trunk/Source/JavaScriptCore/runtime/JSLock.h
r187026 r188444 25 25 #include <thread> 26 26 #include <wtf/Assertions.h> 27 #include <wtf/Lock.h> 27 28 #include <wtf/Noncopyable.h> 28 29 #include <wtf/RefPtr.h> … … 61 62 JS_EXPORT_PRIVATE GlobalJSLock(); 62 63 JS_EXPORT_PRIVATE ~GlobalJSLock(); 63 64 static void initialize();65 64 private: 66 static std::mutex*s_sharedInstanceMutex;65 static StaticLock s_sharedInstanceMutex; 67 66 }; 68 67 … … 134 133 void grabAllLocks(DropAllLocks*, unsigned lockCount); 135 134 136 std::mutexm_lock;135 Lock m_lock; 137 136 std::thread::id m_ownerThreadID; 138 137 intptr_t m_lockCount; -
trunk/Source/WTF/ChangeLog
r188436 r188444 1 2015-08-13 Filip Pizlo <[email protected]> 2 3 Use WTF::Lock and WTF::Condition instead of WTF::Mutex, WTF::ThreadCondition, std::mutex, and std::condition_variable 4 https://bugs.webkit.org/show_bug.cgi?id=147999 5 6 Reviewed by Geoffrey Garen. 7 8 * wtf/Condition.h: "using WTF::Condition". 9 * wtf/Lock.h: 10 (WTF::LockBase::lock): 11 (WTF::LockBase::tryLock): Add tryLock() because it turns out that we use it sometimes. 12 (WTF::LockBase::try_lock): unique_lock needs this. 13 (WTF::LockBase::unlock): 14 1 15 2015-08-13 Commit Queue <[email protected]> 2 16 -
trunk/Source/WTF/wtf/Condition.h
r188400 r188444 110 110 } // namespace WTF 111 111 112 using WTF::Condition; 113 112 114 #endif // WTF_Condition_h 113 115 -
trunk/Source/WTF/wtf/Lock.h
r188374 r188444 55 55 56 56 lockSlow(); 57 } 58 59 bool tryLock() 60 { 61 for (;;) { 62 uint8_t currentByteValue = m_byte.load(); 63 if (currentByteValue & isHeldBit) 64 return false; 65 if (m_byte.compareExchangeWeak(currentByteValue, currentByteValue | isHeldBit)) 66 return true; 67 } 68 } 69 70 // Need this version for std::unique_lock. 71 bool try_lock() 72 { 73 return tryLock(); 57 74 } 58 75
Note:
See TracChangeset
for help on using the changeset viewer.