Skip to content

Commit 83f518b

Browse files
committed
Stop using holdLock() in JSC as it is not compatible with Clang thread safety analysis
https://bugs.webkit.org/show_bug.cgi?id=226116 Reviewed by Mark Lam. Stop using holdLock() in JSC as it is not compatible with Clang thread safety analysis (WTF::CheckedLock). Use the Locker constructor instead. I'll eventually get rid of the holdLock() definition once I have managed to get rid of all its usages. * API/JSVirtualMachine.mm: (+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]): (+[JSVMWrapperCache wrapperForJSContextGroupRef:]): (-[JSVirtualMachine addExternalRememberedObject:]): (-[JSVirtualMachine addManagedReference:withOwner:]): (-[JSVirtualMachine removeManagedReference:withOwner:]): (scanExternalObjectGraph): (scanExternalRememberedSet): * API/glib/JSCVirtualMachine.cpp: (addWrapper): (removeWrapper): * API/tests/ExecutionTimeLimitTest.cpp: (testExecutionTimeLimit): * assembler/PerfLog.cpp: (JSC::PerfLog::PerfLog): (JSC::PerfLog::log): * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::visitAggregateImpl): (JSC::StructureStubInfo::visitWeakReferences): * bytecode/StructureStubInfo.h: (JSC::StructureStubInfo::considerCaching): (JSC::StructureStubInfo::clearBufferedStructures): * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildrenImpl): * bytecode/UnlinkedCodeBlockGenerator.cpp: (JSC::UnlinkedCodeBlockGenerator::finalize): * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * heap/BlockDirectory.cpp: (JSC::BlockDirectory::~BlockDirectory): (JSC::BlockDirectory::removeBlock): (JSC::BlockDirectory::stopAllocatingForGood): (JSC::BlockDirectory::parallelNotEmptyBlockSource): * heap/CodeBlockSet.cpp: (JSC::CodeBlockSet::add): (JSC::CodeBlockSet::remove): * heap/CodeBlockSetInlines.h: (JSC::CodeBlockSet::iterate): * heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::allocatorForSlow): * heap/Heap.cpp: (JSC::Heap::lastChanceToFinalize): (JSC::Heap::runNotRunningPhase): (JSC::Heap::runEndPhase): (JSC::Heap::finishRelinquishingConn): (JSC::visitSamplingProfiler): (JSC::Heap::setBonusVisitorTask): (JSC::Heap::runTaskInParallel): * heap/HeapSnapshotBuilder.cpp: (JSC::HeapSnapshotBuilder::buildSnapshot): (JSC::HeapSnapshotBuilder::analyzeNode): (JSC::HeapSnapshotBuilder::analyzeEdge): (JSC::HeapSnapshotBuilder::analyzePropertyNameEdge): (JSC::HeapSnapshotBuilder::analyzeVariableNameEdge): (JSC::HeapSnapshotBuilder::analyzeIndexEdge): (JSC::HeapSnapshotBuilder::setOpaqueRootReachabilityReasonForCell): * heap/IsoAlignedMemoryAllocator.cpp: (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::IsoAlignedMemoryAllocator::freeAlignedMemory): * heap/IsoCellSet.cpp: (JSC::IsoCellSet::parallelNotEmptyMarkedBlockSource): (JSC::IsoCellSet::addSlow): (JSC::IsoCellSet::didRemoveBlock): (JSC::IsoCellSet::sweepToFreeList): * heap/IsoCellSetInlines.h: (JSC::IsoCellSet::forEachMarkedCellInParallel): * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): * heap/IsoSubspacePerVM.cpp: (JSC::IsoSubspacePerVM::forVM): * heap/LocalAllocator.cpp: (JSC::LocalAllocator::LocalAllocator): (JSC::LocalAllocator::~LocalAllocator): * heap/MachineStackMarker.cpp: (JSC::MachineThreads::tryCopyOtherThreadStacks): (JSC::MachineThreads::gatherConservativeRoots): * heap/MarkedBlock.cpp: (JSC::MarkedBlock::Handle::stopAllocating): (JSC::MarkedBlock::Handle::resumeAllocating): (JSC::MarkedBlock::aboutToMarkSlow): (JSC::MarkedBlock::Handle::didConsumeFreeList): (JSC::MarkedBlock::noteMarkedSlow): (JSC::MarkedBlock::Handle::dumpState): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::isLive): * heap/MarkingConstraint.cpp: (JSC::MarkingConstraint::doParallelWork): * heap/MarkingConstraintSolver.cpp: (JSC::MarkingConstraintSolver::addParallelTask): (JSC::MarkingConstraintSolver::runExecutionThread): * heap/ParallelSourceAdapter.h: * heap/SlotVisitor.cpp: (JSC::SlotVisitor::updateMutatorIsStopped): (JSC::SlotVisitor::drain): (JSC::SlotVisitor::performIncrementOfDraining): (JSC::SlotVisitor::drainFromShared): (JSC::SlotVisitor::drainInParallelPassively): (JSC::SlotVisitor::waitForTermination): (JSC::SlotVisitor::donateAll): (JSC::SlotVisitor::didRace): * heap/Subspace.cpp: (JSC::Subspace::parallelDirectorySource): * heap/SubspaceInlines.h: (JSC::Subspace::forEachMarkedCellInParallel): * inspector/JSInjectedScriptHost.cpp: * jit/ExecutableAllocator.cpp: * jsc.cpp: (Worker::Worker): (Worker::~Worker): (Worker::dequeue): (Workers::broadcast): (Workers::report): (Workers::tryGetReport): (Workers::getReport): (JSC_DEFINE_HOST_FUNCTION): * runtime/DeferredWorkTimer.cpp: (JSC::DeferredWorkTimer::doWork): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::finishCreation): * runtime/EvalExecutable.cpp: (JSC::EvalExecutable::visitChildrenImpl): * runtime/FileBasedFuzzerAgentBase.cpp: (JSC::FileBasedFuzzerAgentBase::getPrediction): * runtime/FunctionExecutable.cpp: (JSC::FunctionExecutable::visitChildrenImpl): * runtime/JSArray.cpp: (JSC::JSArray::shiftCountWithArrayStorage): (JSC::JSArray::unshiftCountWithArrayStorage): * runtime/JSArrayBufferView.cpp: (JSC::JSArrayBufferView::detach): (JSC::JSArrayBufferView::slowDownAndWasteMemory): * runtime/JSCell.h: * runtime/JSFinalizationRegistry.cpp: (JSC::JSFinalizationRegistry::visitChildrenImpl): (JSC::JSFinalizationRegistry::finalizeUnconditionally): (JSC::JSFinalizationRegistry::takeDeadHoldingsValue): (JSC::JSFinalizationRegistry::registerTarget): (JSC::JSFinalizationRegistry::unregister): * runtime/JSGenericTypedArrayViewInlines.h: (JSC::JSGenericTypedArrayView<Adaptor>::visitChildrenImpl): * runtime/JSGlobalObject.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/JSModuleNamespaceObject.cpp: (JSC::JSModuleNamespaceObject::finishCreation): (JSC::JSModuleNamespaceObject::visitChildrenImpl): * runtime/JSObject.cpp: (JSC::JSObject::visitButterflyImpl): * runtime/JSRunLoopTimer.cpp: (JSC::JSRunLoopTimer::Manager::timerDidFire): (JSC::JSRunLoopTimer::Manager::registerVM): (JSC::JSRunLoopTimer::Manager::unregisterVM): (JSC::JSRunLoopTimer::Manager::scheduleTimer): (JSC::JSRunLoopTimer::Manager::cancelTimer): (JSC::JSRunLoopTimer::Manager::timeUntilFire): (JSC::JSRunLoopTimer::timerDidFire): (JSC::JSRunLoopTimer::setTimeUntilFire): (JSC::JSRunLoopTimer::cancelTimer): (JSC::JSRunLoopTimer::addTimerSetNotification): (JSC::JSRunLoopTimer::removeTimerSetNotification): * runtime/JSSegmentedVariableObject.cpp: (JSC::JSSegmentedVariableObject::findVariableIndex): (JSC::JSSegmentedVariableObject::addVariables): (JSC::JSSegmentedVariableObject::visitChildrenImpl): * runtime/ModuleProgramExecutable.cpp: (JSC::ModuleProgramExecutable::visitChildrenImpl): * runtime/NarrowingNumberPredictionFuzzerAgent.cpp: (JSC::NarrowingNumberPredictionFuzzerAgent::getPrediction): * runtime/ProgramExecutable.cpp: (JSC::ProgramExecutable::visitChildrenImpl): * runtime/RandomizingFuzzerAgent.cpp: (JSC::RandomizingFuzzerAgent::getPrediction): * runtime/RegExp.cpp: (JSC::RegExp::compile): (JSC::RegExp::matchConcurrently): (JSC::RegExp::compileMatchOnly): (JSC::RegExp::deleteCode): * runtime/SamplingProfiler.cpp: (JSC::SamplingProfiler::takeSample): (JSC::SamplingProfiler::stackTracesAsJSON): (JSC::SamplingProfiler::reportTopFunctions): (JSC::SamplingProfiler::reportTopBytecodes): * runtime/ScriptExecutable.cpp: (JSC::ScriptExecutable::createTemplateObject): * runtime/SparseArrayValueMap.cpp: (JSC::SparseArrayValueMap::add): (JSC::SparseArrayValueMap::remove): (JSC::SparseArrayValueMap::getConcurrently): (JSC::SparseArrayValueMap::visitChildrenImpl): * runtime/Structure.cpp: (JSC::Structure::changePrototypeTransition): (JSC::Structure::toDictionaryTransition): (JSC::Structure::nonPropertyTransitionSlow): (JSC::Structure::setBrandTransition): * runtime/StructureCache.cpp: (JSC::StructureCache::createEmptyStructure): (JSC::StructureCache::emptyObjectStructureConcurrently): * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): (JSC::VM::gatherScratchBufferRoots): (JSC::VM::scratchBufferForSize): (JSC::VM::clearScratchBuffers): (JSC::VM::addLoopHintExecutionCounter): (JSC::VM::getLoopHintExecutionCounter): (JSC::VM::removeLoopHintExecutionCounter): * runtime/VMTraps.cpp: (JSC::VMTraps::tryInstallTrapBreakpoints): (JSC::VMTraps::invalidateCodeBlocksOnStack): (JSC::VMTraps::willDestroyVM): (JSC::VMTraps::fireTrap): (JSC::VMTraps::handleTraps): (JSC::VMTraps::takeTopPriorityTrap): * runtime/WeakMapImpl.cpp: (JSC::WeakMapImpl<BucketType>::visitOutputConstraints): * runtime/WeakMapImpl.h: (JSC::WeakMapImpl::finishCreation): * runtime/WeakMapImplInlines.h: (JSC::WeakMapImpl<WeakMapBucket>::rehash): * runtime/WideningNumberPredictionFuzzerAgent.cpp: (JSC::WideningNumberPredictionFuzzerAgent::getPrediction): * tools/CompilerTimingScope.cpp: * tools/FunctionOverrides.cpp: (JSC::FunctionOverrides::FunctionOverrides): (JSC::FunctionOverrides::reinstallOverrides): (JSC::FunctionOverrides::initializeOverrideFor): * tools/Integrity.cpp: (JSC::Integrity::Random::reloadAndCheckShouldAuditSlow): * tools/VMInspector.cpp: (JSC::VMInspector::add): (JSC::VMInspector::remove): (JSC::VMInspector::codeBlockForMachinePC): * wasm/WasmBBQPlan.cpp: (JSC::Wasm::BBQPlan::work): (JSC::Wasm::BBQPlan::compileFunction): * wasm/WasmCalleeRegistry.h: (JSC::Wasm::CalleeRegistry::registerCallee): (JSC::Wasm::CalleeRegistry::unregisterCallee): * wasm/WasmCodeBlock.cpp: (JSC::Wasm::CodeBlock::CodeBlock): (JSC::Wasm::CodeBlock::waitUntilFinished): (JSC::Wasm::CodeBlock::compileAsync): * wasm/WasmContext.cpp: (JSC::Wasm::Context::scratchBufferForSize): * wasm/WasmEntryPlan.cpp: (JSC::Wasm::EntryPlan::parseAndValidateModule): (JSC::Wasm::EntryPlan::prepare): (JSC::Wasm::EntryPlan::compileFunctions): * wasm/WasmEntryPlan.h: (JSC::Wasm::EntryPlan::tryReserveCapacity): * wasm/WasmFaultSignalHandler.cpp: (JSC::Wasm::trapHandler): * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::setFunctionWrapper): * wasm/WasmLLIntPlan.cpp: (JSC::Wasm::LLIntPlan::compileFunction): (JSC::Wasm::LLIntPlan::completeInStreaming): (JSC::Wasm::LLIntPlan::didCompileFunctionInStreaming): (JSC::Wasm::LLIntPlan::didFailInStreaming): * wasm/WasmMachineThreads.cpp: (JSC::Wasm::resetInstructionCacheOnAllThreads): * wasm/WasmMemory.cpp: (JSC::Wasm::Memory::growShared): * wasm/WasmModule.cpp: (JSC::Wasm::Module::getOrCreateCodeBlock): * wasm/WasmOMGForOSREntryPlan.cpp: (JSC::Wasm::OMGForOSREntryPlan::work): * wasm/WasmOMGPlan.cpp: (JSC::Wasm::OMGPlan::work): * wasm/WasmOperations.cpp: (JSC::Wasm::triggerOMGReplacementCompile): (JSC::Wasm::JSC_DEFINE_JIT_OPERATION): * wasm/WasmSignatureInlines.h: (JSC::Wasm::SignatureInformation::get): * wasm/WasmSlowPaths.cpp: (JSC::LLInt::jitCompileAndSetHeuristics): (JSC::LLInt::WASM_SLOW_PATH_DECL): * wasm/WasmStreamingCompiler.cpp: (JSC::Wasm::StreamingCompiler::didCompileFunction): (JSC::Wasm::StreamingCompiler::finalize): (JSC::Wasm::StreamingCompiler::fail): (JSC::Wasm::StreamingCompiler::cancel): * wasm/WasmStreamingPlan.cpp: (JSC::Wasm::StreamingPlan::work): * wasm/WasmTable.cpp: (JSC::Wasm::Table::grow): (JSC::Wasm::Table::visitAggregateImpl): * wasm/WasmThunks.cpp: (JSC::Wasm::Thunks::stub): (JSC::Wasm::Thunks::existingStub): * wasm/WasmWorklist.cpp: * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::visitChildrenImpl): Canonical link: https://commits.webkit.org/238042@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277909 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 9252a1c commit 83f518b

92 files changed

Lines changed: 567 additions & 260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/API/JSVirtualMachine.mm‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ @implementation JSVMWrapperCache
6969

7070
+ (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group
7171
{
72-
auto locker = holdLock(wrapperCacheMutex);
72+
Locker locker { wrapperCacheMutex };
7373
NSMapInsert(wrapperCache(), group, (__bridge void*)wrapper);
7474
}
7575

7676
+ (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group
7777
{
78-
auto locker = holdLock(wrapperCacheMutex);
78+
Locker locker { wrapperCacheMutex };
7979
return (__bridge JSVirtualMachine *)NSMapGet(wrapperCache(), group);
8080
}
8181

@@ -156,7 +156,7 @@ - (bool)isOldExternalObject:(id)object
156156

157157
- (void)addExternalRememberedObject:(id)object
158158
{
159-
auto locker = holdLock(m_externalDataMutex);
159+
Locker locker { m_externalDataMutex };
160160
ASSERT([self isOldExternalObject:object]);
161161
[m_externalRememberedSet setObject:@YES forKey:object];
162162
}
@@ -176,7 +176,7 @@ - (void)addManagedReference:(id)object withOwner:(id)owner
176176
if ([self isOldExternalObject:owner] && ![self isOldExternalObject:object])
177177
[self addExternalRememberedObject:owner];
178178

179-
auto externalDataMutexLocker = holdLock(m_externalDataMutex);
179+
Locker externalDataMutexLocker { m_externalDataMutex };
180180
RetainPtr<NSMapTable> ownedObjects = [m_externalObjectGraph objectForKey:owner];
181181
if (!ownedObjects) {
182182
NSPointerFunctionsOptions weakIDOptions = NSPointerFunctionsWeakMemory | NSPointerFunctionsObjectPersonality;
@@ -203,7 +203,7 @@ - (void)removeManagedReference:(id)object withOwner:(id)owner
203203

204204
JSC::JSLockHolder locker(toJS(m_group));
205205

206-
auto externalDataMutexLocker = holdLock(m_externalDataMutex);
206+
Locker externalDataMutexLocker { m_externalDataMutex };
207207
NSMapTable *ownedObjects = [m_externalObjectGraph objectForKey:owner];
208208
if (!ownedObjects)
209209
return;
@@ -341,7 +341,7 @@ static void scanExternalObjectGraph(JSC::VM& vm, JSC::AbstractSlotVisitor& visit
341341
if (lockAcquired)
342342
appendOwnedObjects();
343343
else {
344-
auto locker = holdLock(externalDataMutex);
344+
Locker locker { externalDataMutex };
345345
appendOwnedObjects();
346346
}
347347
}
@@ -361,7 +361,7 @@ void scanExternalRememberedSet(JSC::VM& vm, JSC::AbstractSlotVisitor& visitor)
361361
if (!virtualMachine)
362362
return;
363363
Lock& externalDataMutex = [virtualMachine externalDataMutex];
364-
auto locker = holdLock(externalDataMutex);
364+
Locker locker { externalDataMutex };
365365
NSMapTable *externalObjectGraph = [virtualMachine externalObjectGraph];
366366
NSMapTable *externalRememberedSet = [virtualMachine externalRememberedSet];
367367
for (id key in externalRememberedSet) {

‎Source/JavaScriptCore/API/glib/JSCVirtualMachine.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ static HashMap<JSContextGroupRef, JSCVirtualMachine*>& wrapperMap()
6262

6363
static void addWrapper(JSContextGroupRef group, JSCVirtualMachine* vm)
6464
{
65-
auto locker = holdLock(wrapperCacheMutex);
65+
Locker locker { wrapperCacheMutex };
6666
ASSERT(!wrapperMap().contains(group));
6767
wrapperMap().set(group, vm);
6868
}
6969

7070
static void removeWrapper(JSContextGroupRef group)
7171
{
72-
auto locker = holdLock(wrapperCacheMutex);
72+
Locker locker { wrapperCacheMutex };
7373
ASSERT(wrapperMap().contains(group));
7474
wrapperMap().remove(group);
7575
}

‎Source/JavaScriptCore/API/tests/ExecutionTimeLimitTest.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ int testExecutionTimeLimit()
505505
startTimeRef = CPUTime::forCurrentThread();
506506
JSEvaluateScript(contextRef, scriptRef, nullptr, nullptr, 1, &exceptionRef);
507507
endTimeRef = CPUTime::forCurrentThread();
508-
auto locker = WTF::holdLock(syncLockRef);
508+
Locker locker { syncLockRef };
509509
didSynchronizeRef = true;
510510
synchronizeRef.notifyAll();
511511
});
512512

513-
auto locker = holdLock(syncLock);
513+
Locker locker { syncLock };
514514
synchronize.wait(syncLock, [&] { return didSynchronize; });
515515

516516
if (((endTime - startTime) < timeAfterWatchdogShouldHaveFired) && dispatchTerminateCallbackCalled)

0 commit comments

Comments
 (0)