haikuwebkit/Source/WTF/wtf/WordLock.h

109 lines
3.3 KiB
C
Raw Permalink Normal View History

Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
/*
Use constexpr instead of const in symbol definitions that are obviously constexpr. https://bugs.webkit.org/show_bug.cgi?id=201879 Rubber-stamped by Joseph Pecoraro. Source/bmalloc: * bmalloc/AvailableMemory.cpp: * bmalloc/IsoTLS.h: * bmalloc/Map.h: * bmalloc/Mutex.cpp: (bmalloc::Mutex::lockSlowCase): * bmalloc/PerThread.h: * bmalloc/Vector.h: * bmalloc/Zone.h: Source/JavaScriptCore: const may require external storage (at the compiler's whim) though these currently do not. constexpr makes it clear that the value is a literal constant that can be inlined. In most cases in the code, when we say static const, we actually mean static constexpr. I'm changing the code to reflect this. * API/JSAPIValueWrapper.h: * API/JSCallbackConstructor.h: * API/JSCallbackObject.h: * API/JSContextRef.cpp: * API/JSWrapperMap.mm: * API/tests/CompareAndSwapTest.cpp: * API/tests/TypedArrayCTest.cpp: * API/tests/testapi.mm: (testObjectiveCAPIMain): * KeywordLookupGenerator.py: (Trie.printAsC): * assembler/ARMv7Assembler.h: * assembler/AssemblerBuffer.h: * assembler/AssemblerCommon.h: * assembler/MacroAssembler.h: * assembler/MacroAssemblerARM64.h: * assembler/MacroAssemblerARM64E.h: * assembler/MacroAssemblerARMv7.h: * assembler/MacroAssemblerCodeRef.h: * assembler/MacroAssemblerMIPS.h: * assembler/MacroAssemblerX86.h: * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::absDouble): (JSC::MacroAssemblerX86Common::negateDouble): * assembler/MacroAssemblerX86_64.h: * assembler/X86Assembler.h: * b3/B3Bank.h: * b3/B3CheckSpecial.h: * b3/B3DuplicateTails.cpp: * b3/B3EliminateCommonSubexpressions.cpp: * b3/B3FixSSA.cpp: * b3/B3FoldPathConstants.cpp: * b3/B3InferSwitches.cpp: * b3/B3Kind.h: * b3/B3LowerToAir.cpp: * b3/B3NativeTraits.h: * b3/B3ReduceDoubleToFloat.cpp: * b3/B3ReduceLoopStrength.cpp: * b3/B3ReduceStrength.cpp: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirAllocateStackByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirCCallSpecial.h: * b3/air/AirEmitShuffle.cpp: * b3/air/AirFixObviousSpills.cpp: * b3/air/AirFormTable.h: * b3/air/AirLowerAfterRegAlloc.cpp: * b3/air/AirPrintSpecial.h: * b3/air/AirStackAllocation.cpp: * b3/air/AirTmp.h: * b3/testb3_6.cpp: (testInterpreter): * bytecode/AccessCase.cpp: * bytecode/CallLinkStatus.cpp: * bytecode/CallVariant.h: * bytecode/CodeBlock.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/DirectEvalCodeCache.h: * bytecode/ExecutableToCodeBlockEdge.h: * bytecode/GetterSetterAccessCase.cpp: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/ObjectPropertyConditionSet.cpp: * bytecode/PolymorphicAccess.cpp: * bytecode/PropertyCondition.h: * bytecode/SpeculatedType.h: * bytecode/StructureStubInfo.cpp: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::typeProfilerExpressionInfoForBytecodeOffset): * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedEvalCodeBlock.h: * bytecode/UnlinkedFunctionCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.h: * bytecode/UnlinkedModuleProgramCodeBlock.h: * bytecode/UnlinkedProgramCodeBlock.h: * bytecode/ValueProfile.h: * bytecode/VirtualRegister.h: * bytecode/Watchpoint.h: * bytecompiler/BytecodeGenerator.h: * bytecompiler/Label.h: * bytecompiler/NodesCodegen.cpp: (JSC::ThisNode::emitBytecode): * bytecompiler/RegisterID.h: * debugger/Breakpoint.h: * debugger/DebuggerParseData.cpp: * debugger/DebuggerPrimitives.h: * debugger/DebuggerScope.h: * dfg/DFGAbstractHeap.h: * dfg/DFGAbstractValue.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCommon.h: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGEdgeDominates.h: * dfg/DFGEpoch.h: * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledNodesAtNodeIndex): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGHeapLocation.h: * dfg/DFGInPlaceAbstractState.cpp: * dfg/DFGIntegerCheckCombiningPhase.cpp: * dfg/DFGIntegerRangeOptimizationPhase.cpp: * dfg/DFGInvalidationPointInjectionPhase.cpp: * dfg/DFGLICMPhase.cpp: * dfg/DFGLazyNode.h: * dfg/DFGMinifiedID.h: * dfg/DFGMovHintRemovalPhase.cpp: * dfg/DFGNodeFlowProjection.h: * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPhantomInsertionPhase.cpp: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGRegisterBank.h: * dfg/DFGSSAConversionPhase.cpp: * dfg/DFGSSALoweringPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoubleRep): (JSC::DFG::compileClampDoubleToByte): (JSC::DFG::SpeculativeJIT::compileArithRounding): (JSC::DFG::compileArithPowIntegerFastPath): (JSC::DFG::SpeculativeJIT::compileArithPow): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): * dfg/DFGStackLayoutPhase.cpp: * dfg/DFGStoreBarrierInsertionPhase.cpp: * dfg/DFGStrengthReductionPhase.cpp: * dfg/DFGStructureAbstractValue.h: * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVariableEventStream.cpp: (JSC::DFG::VariableEventStream::reconstruct const): * dfg/DFGWatchpointCollectionPhase.cpp: * disassembler/ARM64/A64DOpcode.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArithRandom): * ftl/FTLSlowPathCall.cpp: * ftl/FTLSlowPathCallKey.h: * heap/CellContainer.h: * heap/CellState.h: * heap/ConservativeRoots.h: * heap/GCSegmentedArray.h: * heap/HandleBlock.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/HeapSnapshot.h: * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IncrementalSweeper.cpp: * heap/LargeAllocation.h: * heap/MarkedBlock.cpp: * heap/Strong.h: * heap/VisitRaceKey.h: * heap/Weak.h: * heap/WeakBlock.h: * inspector/JSInjectedScriptHost.h: * inspector/JSInjectedScriptHostPrototype.h: * inspector/JSJavaScriptCallFrame.h: * inspector/JSJavaScriptCallFramePrototype.h: * inspector/agents/InspectorConsoleAgent.cpp: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_versions): * inspector/scripts/tests/generic/expected/version.json-result: * interpreter/Interpreter.h: * interpreter/ShadowChicken.cpp: * jit/BinarySwitch.cpp: * jit/CallFrameShuffler.h: * jit/ExecutableAllocator.h: * jit/FPRInfo.h: * jit/GPRInfo.h: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * jit/TempRegisterSet.h: * jsc.cpp: * parser/ASTBuilder.h: * parser/Nodes.h: * parser/SourceCodeKey.h: * parser/SyntaxChecker.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/AbstractModuleRecord.cpp: * runtime/ArrayBufferNeuteringWatchpointSet.h: * runtime/ArrayConstructor.h: * runtime/ArrayConventions.h: * runtime/ArrayIteratorPrototype.h: * runtime/ArrayPrototype.cpp: (JSC::setLength): * runtime/AsyncFromSyncIteratorPrototype.h: * runtime/AsyncGeneratorFunctionPrototype.h: * runtime/AsyncGeneratorPrototype.h: * runtime/AsyncIteratorPrototype.h: * runtime/AtomicsObject.cpp: * runtime/BigIntConstructor.h: * runtime/BigIntPrototype.h: * runtime/BooleanPrototype.h: * runtime/ClonedArguments.h: * runtime/CodeCache.h: * runtime/ControlFlowProfiler.h: * runtime/CustomGetterSetter.h: * runtime/DateConstructor.h: * runtime/DatePrototype.h: * runtime/DefinePropertyAttributes.h: * runtime/ErrorPrototype.h: * runtime/EvalExecutable.h: * runtime/Exception.h: * runtime/ExceptionHelpers.cpp: (JSC::invalidParameterInSourceAppender): (JSC::invalidParameterInstanceofSourceAppender): * runtime/ExceptionHelpers.h: * runtime/ExecutableBase.h: * runtime/FunctionExecutable.h: * runtime/FunctionRareData.h: * runtime/GeneratorPrototype.h: * runtime/GenericArguments.h: * runtime/GenericOffset.h: * runtime/GetPutInfo.h: * runtime/GetterSetter.h: * runtime/GlobalExecutable.h: * runtime/Identifier.h: * runtime/InspectorInstrumentationObject.h: * runtime/InternalFunction.h: * runtime/IntlCollatorConstructor.h: * runtime/IntlCollatorPrototype.h: * runtime/IntlDateTimeFormatConstructor.h: * runtime/IntlDateTimeFormatPrototype.h: * runtime/IntlNumberFormatConstructor.h: * runtime/IntlNumberFormatPrototype.h: * runtime/IntlObject.h: * runtime/IntlPluralRulesConstructor.h: * runtime/IntlPluralRulesPrototype.h: * runtime/IteratorPrototype.h: * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): * runtime/JSArray.h: * runtime/JSArrayBuffer.h: * runtime/JSArrayBufferView.h: * runtime/JSBigInt.h: * runtime/JSCJSValue.h: * runtime/JSCell.h: * runtime/JSCustomGetterSetterFunction.h: * runtime/JSDataView.h: * runtime/JSDataViewPrototype.h: * runtime/JSDestructibleObject.h: * runtime/JSFixedArray.h: * runtime/JSGenericTypedArrayView.h: * runtime/JSGlobalLexicalEnvironment.h: * runtime/JSGlobalObject.h: * runtime/JSImmutableButterfly.h: * runtime/JSInternalPromiseConstructor.h: * runtime/JSInternalPromiseDeferred.h: * runtime/JSInternalPromisePrototype.h: * runtime/JSLexicalEnvironment.h: * runtime/JSModuleEnvironment.h: * runtime/JSModuleLoader.h: * runtime/JSModuleNamespaceObject.h: * runtime/JSNonDestructibleProxy.h: * runtime/JSONObject.cpp: * runtime/JSONObject.h: * runtime/JSObject.h: * runtime/JSPromiseConstructor.h: * runtime/JSPromiseDeferred.h: * runtime/JSPromisePrototype.h: * runtime/JSPropertyNameEnumerator.h: * runtime/JSProxy.h: * runtime/JSScope.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/JSSegmentedVariableObject.h: * runtime/JSSourceCode.h: * runtime/JSString.cpp: * runtime/JSString.h: * runtime/JSSymbolTableObject.h: * runtime/JSTemplateObjectDescriptor.h: * runtime/JSTypeInfo.h: * runtime/MapPrototype.h: * runtime/MinimumReservedZoneSize.h: * runtime/ModuleProgramExecutable.h: * runtime/NativeExecutable.h: * runtime/NativeFunction.h: * runtime/NativeStdFunctionCell.h: * runtime/NumberConstructor.h: * runtime/NumberPrototype.h: * runtime/ObjectConstructor.h: * runtime/ObjectPrototype.h: * runtime/ProgramExecutable.h: * runtime/PromiseDeferredTimer.cpp: * runtime/PropertyMapHashTable.h: * runtime/PropertyNameArray.h: (JSC::PropertyNameArray::add): * runtime/PrototypeKey.h: * runtime/ProxyConstructor.h: * runtime/ProxyObject.cpp: (JSC::ProxyObject::performGetOwnPropertyNames): * runtime/ProxyRevoke.h: * runtime/ReflectObject.h: * runtime/RegExp.h: * runtime/RegExpCache.h: * runtime/RegExpConstructor.h: * runtime/RegExpKey.h: * runtime/RegExpObject.h: * runtime/RegExpPrototype.h: * runtime/RegExpStringIteratorPrototype.h: * runtime/SamplingProfiler.cpp: * runtime/ScopedArgumentsTable.h: * runtime/ScriptExecutable.h: * runtime/SetPrototype.h: * runtime/SmallStrings.h: * runtime/SparseArrayValueMap.h: * runtime/StringConstructor.h: * runtime/StringIteratorPrototype.h: * runtime/StringObject.h: * runtime/StringPrototype.h: * runtime/Structure.h: * runtime/StructureChain.h: * runtime/StructureRareData.h: * runtime/StructureTransitionTable.h: * runtime/Symbol.h: * runtime/SymbolConstructor.h: * runtime/SymbolPrototype.h: * runtime/SymbolTable.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.cpp: * runtime/TypeProfiler.h: * runtime/TypeProfilerLog.cpp: * runtime/VarOffset.h: * testRegExp.cpp: * tools/HeapVerifier.cpp: (JSC::HeapVerifier::checkIfRecorded): * tools/JSDollarVM.cpp: * wasm/WasmB3IRGenerator.cpp: * wasm/WasmBBQPlan.cpp: * wasm/WasmFaultSignalHandler.cpp: * wasm/WasmFunctionParser.h: * wasm/WasmOMGForOSREntryPlan.cpp: * wasm/WasmOMGPlan.cpp: * wasm/WasmPlan.cpp: * wasm/WasmSignature.cpp: * wasm/WasmSignature.h: * wasm/WasmWorklist.cpp: * wasm/js/JSWebAssembly.h: * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/WebAssemblyCompileErrorConstructor.h: * wasm/js/WebAssemblyCompileErrorPrototype.h: * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyInstanceConstructor.h: * wasm/js/WebAssemblyInstancePrototype.h: * wasm/js/WebAssemblyLinkErrorConstructor.h: * wasm/js/WebAssemblyLinkErrorPrototype.h: * wasm/js/WebAssemblyMemoryConstructor.h: * wasm/js/WebAssemblyMemoryPrototype.h: * wasm/js/WebAssemblyModuleConstructor.h: * wasm/js/WebAssemblyModulePrototype.h: * wasm/js/WebAssemblyRuntimeErrorConstructor.h: * wasm/js/WebAssemblyRuntimeErrorPrototype.h: * wasm/js/WebAssemblyTableConstructor.h: * wasm/js/WebAssemblyTablePrototype.h: * wasm/js/WebAssemblyToJSCallee.h: * yarr/Yarr.h: * yarr/YarrParser.h: * yarr/generateYarrCanonicalizeUnicode: Source/WebCore: No new tests. Covered by existing tests. * bindings/js/JSDOMConstructorBase.h: * bindings/js/JSDOMWindowProperties.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GeneratePrototypeDeclaration): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: * bindings/scripts/test/JS/JSTestEnabledBySetting.h: * bindings/scripts/test/JS/JSTestEnabledForContext.h: * bindings/scripts/test/JS/JSTestEventTarget.h: * bindings/scripts/test/JS/JSTestGlobalObject.h: * bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedGetterCallWith.h: * bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestObj.h: * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestPluginInterface.h: * bindings/scripts/test/JS/JSTestTypedefs.h: * bridge/objc/objc_runtime.h: * bridge/runtime_array.h: * bridge/runtime_method.h: * bridge/runtime_object.h: Source/WebKit: * WebProcess/Plugins/Netscape/JSNPObject.h: Source/WTF: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Brigand.h: * wtf/CheckedArithmetic.h: * wtf/CrossThreadCopier.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DateMath.cpp: (WTF::daysFrom1970ToYear): * wtf/DeferrableRefCounted.h: * wtf/GetPtr.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashTable.h: * wtf/HashTraits.h: * wtf/JSONValues.cpp: * wtf/JSONValues.h: * wtf/ListHashSet.h: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockAlgorithmInlines.h: (WTF::Hooks>::lockSlow): * wtf/Logger.h: * wtf/LoggerHelper.h: (WTF::LoggerHelper::childLogIdentifier const): * wtf/MainThread.cpp: * wtf/MetaAllocatorPtr.h: * wtf/MonotonicTime.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::NaturalLoops): * wtf/ObjectIdentifier.h: * wtf/RAMSize.cpp: * wtf/Ref.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/SchedulePair.h: * wtf/StackShot.h: * wtf/StdLibExtras.h: * wtf/TinyPtrSet.h: * wtf/URL.cpp: * wtf/URLHash.h: * wtf/URLParser.cpp: (WTF::URLParser::defaultPortForProtocol): * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.h: * wtf/WeakHashSet.h: * wtf/WordLock.h: * wtf/cocoa/CPUTimeCocoa.cpp: * wtf/cocoa/MemoryPressureHandlerCocoa.mm: * wtf/persistence/PersistentDecoder.h: * wtf/persistence/PersistentEncoder.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringBuilder.cpp: (WTF::expandedCapacity): * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/StringToIntegerConversion.h: (WTF::toIntegralType): * wtf/text/SymbolRegistry.h: * wtf/text/TextStream.cpp: (WTF::hasFractions): * wtf/text/WTFString.h: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: Canonical link: https://commits.webkit.org/215538@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 00:36:19 +00:00
* Copyright (C) 2015-2019 Apple Inc. All rights reserved.
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
Use pragma once in WTF https://bugs.webkit.org/show_bug.cgi?id=190527 Reviewed by Chris Dumez. Source/WTF: We also need to consistently include wtf headers from within wtf so we can build wtf without symbol redefinition errors from including the copy in Source and the copy in the build directory. * wtf/ASCIICType.h: * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/Atomics.h: * wtf/AutomaticThread.cpp: * wtf/AutomaticThread.h: * wtf/BackwardsGraph.h: * wtf/Bag.h: * wtf/BagToHashMap.h: * wtf/BitVector.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Box.h: * wtf/BubbleSort.h: * wtf/BumpPointerAllocator.h: * wtf/ByteOrder.h: * wtf/CPUTime.cpp: * wtf/CallbackAggregator.h: * wtf/CheckedArithmetic.h: * wtf/CheckedBoolean.h: * wtf/ClockType.cpp: * wtf/ClockType.h: * wtf/CommaPrinter.h: * wtf/CompilationThread.cpp: * wtf/CompilationThread.h: * wtf/Compiler.h: * wtf/ConcurrentPtrHashSet.cpp: * wtf/ConcurrentVector.h: * wtf/Condition.h: * wtf/CountingLock.cpp: * wtf/CrossThreadTaskHandler.cpp: * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/CryptographicallyRandomNumber.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DataLog.h: * wtf/DateMath.cpp: * wtf/DateMath.h: * wtf/DecimalNumber.cpp: * wtf/DecimalNumber.h: * wtf/Deque.h: * wtf/DisallowCType.h: * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/FastBitVector.cpp: * wtf/FastMalloc.cpp: * wtf/FastMalloc.h: * wtf/FeatureDefines.h: * wtf/FilePrintStream.cpp: * wtf/FilePrintStream.h: * wtf/FlipBytes.h: * wtf/FunctionDispatcher.cpp: * wtf/FunctionDispatcher.h: * wtf/GetPtr.h: * wtf/Gigacage.cpp: * wtf/GlobalVersion.cpp: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.cpp: * wtf/GregorianDateTime.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashMethod.h: * wtf/HashSet.h: * wtf/HashTable.cpp: * wtf/HashTraits.h: * wtf/Indenter.h: * wtf/IndexSparseSet.h: * wtf/InlineASM.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/JSONValues.cpp: * wtf/JSValueMalloc.cpp: * wtf/LEBDecoder.h: * wtf/Language.cpp: * wtf/ListDump.h: * wtf/Lock.cpp: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockedPrintStream.cpp: * wtf/Locker.h: * wtf/MD5.cpp: * wtf/MD5.h: * wtf/MainThread.cpp: * wtf/MainThread.h: * wtf/MallocPtr.h: * wtf/MathExtras.h: * wtf/MediaTime.cpp: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.cpp: * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: * wtf/MetaAllocator.h: * wtf/MetaAllocatorHandle.h: * wtf/MonotonicTime.cpp: * wtf/MonotonicTime.h: * wtf/NakedPtr.h: * wtf/NoLock.h: * wtf/NoTailCalls.h: * wtf/Noncopyable.h: * wtf/NumberOfCores.cpp: * wtf/NumberOfCores.h: * wtf/OSAllocator.h: * wtf/OSAllocatorPosix.cpp: * wtf/OSRandomSource.cpp: * wtf/OSRandomSource.h: * wtf/ObjcRuntimeExtras.h: * wtf/OrderMaker.h: * wtf/PackedIntVector.h: * wtf/PageAllocation.h: * wtf/PageBlock.cpp: * wtf/PageBlock.h: * wtf/PageReservation.h: * wtf/ParallelHelperPool.cpp: * wtf/ParallelHelperPool.h: * wtf/ParallelJobs.h: * wtf/ParallelJobsLibdispatch.h: * wtf/ParallelVectorIterator.h: * wtf/ParkingLot.cpp: * wtf/ParkingLot.h: * wtf/Platform.h: * wtf/PointerComparison.h: * wtf/Poisoned.cpp: * wtf/PrintStream.cpp: * wtf/PrintStream.h: * wtf/ProcessID.h: * wtf/ProcessPrivilege.cpp: * wtf/RAMSize.cpp: * wtf/RAMSize.h: * wtf/RandomDevice.cpp: * wtf/RandomNumber.cpp: * wtf/RandomNumber.h: * wtf/RandomNumberSeed.h: * wtf/RangeSet.h: * wtf/RawPointer.h: * wtf/ReadWriteLock.cpp: * wtf/RedBlackTree.h: * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefCountedLeakCounter.cpp: * wtf/RefCountedLeakCounter.h: * wtf/RefCounter.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/RunLoop.cpp: * wtf/RunLoop.h: * wtf/RunLoopTimer.h: * wtf/RunLoopTimerCF.cpp: * wtf/SHA1.cpp: * wtf/SHA1.h: * wtf/SaturatedArithmetic.h: (saturatedSubtraction): * wtf/SchedulePair.h: * wtf/SchedulePairCF.cpp: * wtf/SchedulePairMac.mm: * wtf/ScopedLambda.h: * wtf/Seconds.cpp: * wtf/Seconds.h: * wtf/SegmentedVector.h: * wtf/SentinelLinkedList.h: * wtf/SharedTask.h: * wtf/SimpleStats.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SixCharacterHash.cpp: * wtf/SixCharacterHash.h: * wtf/SmallPtrSet.h: * wtf/Spectrum.h: * wtf/StackBounds.cpp: * wtf/StackBounds.h: * wtf/StackStats.cpp: * wtf/StackStats.h: * wtf/StackTrace.cpp: * wtf/StdLibExtras.h: * wtf/StreamBuffer.h: * wtf/StringHashDumpContext.h: * wtf/StringPrintStream.cpp: * wtf/StringPrintStream.h: * wtf/ThreadGroup.cpp: * wtf/ThreadMessage.cpp: * wtf/ThreadSpecific.h: * wtf/Threading.cpp: * wtf/Threading.h: * wtf/ThreadingPrimitives.h: * wtf/ThreadingPthreads.cpp: * wtf/TimeWithDynamicClockType.cpp: * wtf/TimeWithDynamicClockType.h: * wtf/TimingScope.cpp: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/TriState.h: * wtf/TypeCasts.h: * wtf/UUID.cpp: * wtf/UnionFind.h: * wtf/VMTags.h: * wtf/ValueCheck.h: * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.cpp: * wtf/WallTime.h: * wtf/WeakPtr.h: * wtf/WeakRandom.h: * wtf/WordLock.cpp: * wtf/WordLock.h: * wtf/WorkQueue.cpp: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: * wtf/cf/LanguageCF.cpp: * wtf/cf/RunLoopCF.cpp: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryFootprintCocoa.cpp: * wtf/cocoa/WorkQueueCocoa.cpp: * wtf/dtoa.cpp: * wtf/dtoa.h: * wtf/ios/WebCoreThread.cpp: * wtf/ios/WebCoreThread.h: * wtf/mac/AppKitCompatibilityDeclarations.h: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mbmalloc.cpp: * wtf/persistence/PersistentCoders.cpp: * wtf/persistence/PersistentDecoder.cpp: * wtf/persistence/PersistentEncoder.cpp: * wtf/spi/cf/CFBundleSPI.h: * wtf/spi/darwin/CommonCryptoSPI.h: * wtf/text/ASCIIFastPath.h: * wtf/text/ASCIILiteral.cpp: * wtf/text/AtomicString.cpp: * wtf/text/AtomicString.h: * wtf/text/AtomicStringHash.h: * wtf/text/AtomicStringImpl.cpp: * wtf/text/AtomicStringImpl.h: * wtf/text/AtomicStringTable.cpp: * wtf/text/AtomicStringTable.h: * wtf/text/Base64.cpp: * wtf/text/CString.cpp: * wtf/text/CString.h: * wtf/text/ConversionMode.h: * wtf/text/ExternalStringImpl.cpp: * wtf/text/IntegerToStringConversion.h: * wtf/text/LChar.h: * wtf/text/LineEnding.cpp: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.cpp: * wtf/text/StringBuilder.h: * wtf/text/StringBuilderJSON.cpp: * wtf/text/StringCommon.h: * wtf/text/StringConcatenate.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.cpp: * wtf/text/StringImpl.h: * wtf/text/StringOperators.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: * wtf/text/SymbolImpl.cpp: * wtf/text/SymbolRegistry.cpp: * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.cpp: * wtf/text/TextBreakIterator.h: * wtf/text/TextBreakIteratorInternalICU.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.cpp: * wtf/text/UniquedStringImpl.h: * wtf/text/WTFString.cpp: * wtf/text/WTFString.h: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/StringViewCocoa.mm: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: * wtf/text/icu/UTextProvider.cpp: * wtf/text/icu/UTextProvider.h: * wtf/text/icu/UTextProviderLatin1.cpp: * wtf/text/icu/UTextProviderLatin1.h: * wtf/text/icu/UTextProviderUTF16.cpp: * wtf/text/icu/UTextProviderUTF16.h: * wtf/threads/BinarySemaphore.cpp: * wtf/threads/BinarySemaphore.h: * wtf/threads/Signals.cpp: * wtf/unicode/CharacterNames.h: * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: * wtf/unicode/UTF8.cpp: * wtf/unicode/UTF8.h: Tools: Put WorkQueue in namespace DRT so it does not conflict with WTF::WorkQueue. * DumpRenderTree/TestRunner.cpp: (TestRunner::queueLoadHTMLString): (TestRunner::queueLoadAlternateHTMLString): (TestRunner::queueBackNavigation): (TestRunner::queueForwardNavigation): (TestRunner::queueLoadingScript): (TestRunner::queueNonLoadingScript): (TestRunner::queueReload): * DumpRenderTree/WorkQueue.cpp: (WorkQueue::singleton): Deleted. (WorkQueue::WorkQueue): Deleted. (WorkQueue::queue): Deleted. (WorkQueue::dequeue): Deleted. (WorkQueue::count): Deleted. (WorkQueue::clear): Deleted. (WorkQueue::processWork): Deleted. * DumpRenderTree/WorkQueue.h: (WorkQueue::setFrozen): Deleted. * DumpRenderTree/WorkQueueItem.h: * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): * DumpRenderTree/mac/FrameLoadDelegate.mm: (-[FrameLoadDelegate processWork:]): (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]): * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): * DumpRenderTree/win/DumpRenderTree.cpp: (runTest): * DumpRenderTree/win/FrameLoadDelegate.cpp: (FrameLoadDelegate::processWork): (FrameLoadDelegate::locationChangeDone): * DumpRenderTree/win/TestRunnerWin.cpp: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): Canonical link: https://commits.webkit.org/205473@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237099 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-15 14:24:49 +00:00
#pragma once
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
#include <wtf/Atomics.h>
#include <wtf/Compiler.h>
#include <wtf/Locker.h>
#include <wtf/Noncopyable.h>
WTF::Lock should not suffer from the thundering herd https://bugs.webkit.org/show_bug.cgi?id=147947 Reviewed by Geoffrey Garen. Source/WTF: This changes Lock::unlockSlow() to use unparkOne() instead of unparkAll(). The problem with doing this is that it's not obvious after calling unparkOne() if there are any other threads that are still parked on the lock's queue. If we assume that there are and leave the hasParkedBit set, then future calls to unlock() will take the slow path. We don't want that if there aren't actually any threads parked. On the other hand, if we assume that there aren't any threads parked and clear the hasParkedBit, then if there actually were some threads parked, then they may never be awoken since future calls to unlock() won't take slow path and so won't call unparkOne(). In other words, we need a way to be very precise about when we clear the hasParkedBit and we need to do it in a race-free way: it can't be the case that we clear the bit just as some thread gets parked on the queue. A similar problem arises in futexes, and one of the solutions is to have a thread that acquires a lock after parking sets the hasParkedBit. This is what Rusty Russel's usersem does. It's a subtle algorithm. Also, it means that if a thread barges in before the unparked thread runs, then that barging thread will not know that there are threads parked. This could increase the severity of barging. Since ParkingLot is a user-level API, we don't have to worry about the kernel-user security issues and so we can expose callbacks while ParkingLot is holding its internal locks. This change does exactly that for unparkOne(). The new variant of unparkOne() will call a user function while the queue from which we are unparking is locked. The callback is told basic stats about the queue: did we unpark a thread this time, and could there be more threads to unpark in the future. The callback runs while it's impossible for the queue state to change, since the ParkingLot's internal locks for the queue is held. This means that Lock::unlockSlow() can either clear, or leave, the hasParkedBit while releasing the lock inside the callback from unparkOne(). This takes care of the thundering herd problem while also reducing the greed that arises from barging threads. This required some careful reworking of the ParkingLot algorithm. The first thing I noticed was that the ThreadData::shouldPark flag was useless, since it's set exactly when ThreadData::address is non-null. Then I had to make sure that dequeue() could lazily create both hashtables and buckets, since the "callback is called while queue is locked" invariant requires that we didn't exit early due to the hashtable or bucket not being present. Note that all of this is done in such a way that the old unparkOne() and unparkAll() don't have to create any buckets, though they now may create the hashtable. We don't care as much about the hashtable being created by unpark since it's just such an unlikely scenario and it would only happen once. This change reduces the kernel CPU usage of WTF::Lock for the long critical section test by about 8x and makes it always perform as well as WTF::WordLock and WTF::Mutex for that benchmark. * benchmarks/LockSpeedTest.cpp: * wtf/Lock.cpp: (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::isLocked): (WTF::LockBase::isFullyReset): * wtf/ParkingLot.cpp: (WTF::ParkingLot::parkConditionally): (WTF::ParkingLot::unparkOne): (WTF::ParkingLot::unparkAll): * wtf/ParkingLot.h: * wtf/WordLock.h: (WTF::WordLock::isLocked): (WTF::WordLock::isFullyReset): Tools: Add testing that checks that locks return to a pristine state after contention is over. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::LockInspector::isFullyReset): (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166072@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-13 03:51:25 +00:00
namespace TestWebKitAPI {
struct LockInspector;
};
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
namespace WTF {
// A WordLock is a fully adaptive mutex that uses sizeof(void*) storage. It has a fast path that is
// similar to a spinlock, and a slow path that is similar to std::mutex. In most cases, you should use
// Lock instead. WordLock sits lower in the stack and is used to implement Lock, so Lock is the main
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
// client of WordLock.
// NOTE: This is also a great lock to use if you are very low in the stack. For example,
// PrintStream uses this so that ParkingLot and Lock can use PrintStream. This means that if you
// try to use dataLog to debug this code, you will have a bad time.
[WTF][JSC] Make JSC and WTF aggressively-fast-malloced https://bugs.webkit.org/show_bug.cgi?id=200611 Reviewed by Saam Barati. Source/JavaScriptCore: This patch aggressively puts many classes into FastMalloc. In JSC side, we grep `std::make_unique` etc. to find potentially system-malloc-allocated classes. After this patch, all the JSC related allocations in JetStream2 cli is done from bmalloc. In the future, it would be nice that we add `WTF::makeUnique<T>` helper function and throw a compile error if `T` is not FastMalloc annotated[1]. Putting WebKit classes in FastMalloc has many benefits. 1. Simply, it is fast. 2. vmmap can tell the amount of memory used for WebKit. 3. bmalloc can isolate WebKit memory allocation from the rest of the world. This is useful since we can know more about what component is corrupting the memory from the memory corruption crash. [1]: https://bugs.webkit.org/show_bug.cgi?id=200620 * API/ObjCCallbackFunction.mm: * assembler/AbstractMacroAssembler.h: * b3/B3PhiChildren.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirDisassembler.h: * bytecode/AccessCaseSnippetParams.h: * bytecode/CallVariant.h: * bytecode/DeferredSourceDump.h: * bytecode/ExecutionCounter.h: * bytecode/GetByIdStatus.h: * bytecode/GetByIdVariant.h: * bytecode/InByIdStatus.h: * bytecode/InByIdVariant.h: * bytecode/InstanceOfStatus.h: * bytecode/InstanceOfVariant.h: * bytecode/PutByIdStatus.h: * bytecode/PutByIdVariant.h: * bytecode/ValueProfile.h: * dfg/DFGAbstractInterpreter.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::newVariableAccessData): * dfg/DFGFlowIndexing.h: * dfg/DFGFlowMap.h: * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMaximalFlushInsertionPhase.cpp: (JSC::DFG::MaximalFlushInsertionPhase::newVariableAccessData): * dfg/DFGOSRExit.h: * dfg/DFGSpeculativeJIT.h: * dfg/DFGVariableAccessData.h: * disassembler/ARM64/A64DOpcode.h: * inspector/remote/socket/RemoteInspectorMessageParser.h: * inspector/remote/socket/RemoteInspectorSocket.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/PCToCodeOriginMap.h: * runtime/BasicBlockLocation.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/JSRunLoopTimer.h: * runtime/PromiseDeferredTimer.h: (JSC::PromiseDeferredTimer::create): PromiseDeferredTimer should be allocated as `Ref<>` instead of `std::unique_ptr` since it is inheriting ThreadSafeRefCounted<>. Holding such a class with std::unique_ptr could lead to potentially dangerous operations (like, someone holds it with Ref<> while it is deleted by std::unique_ptr<>). * runtime/RandomizingFuzzerAgent.h: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: * tools/SigillCrashAnalyzer.cpp: * wasm/WasmFormat.h: * wasm/WasmMemory.cpp: * wasm/WasmSignature.h: * yarr/YarrJIT.h: Source/WebCore: Changed the accessor since we changed std::unique_ptr to Ref for this field. No behavior change. * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::addTimerSetNotification): (WebCore::WorkerScriptController::removeTimerSetNotification): Source/WTF: WTF has many data structures, in particular, containers. And these containers can be allocated like `std::make_unique<Container>()`. Without WTF_MAKE_FAST_ALLOCATED, this container itself is allocated from the system malloc. This patch attaches WTF_MAKE_FAST_ALLOCATED more aggressively not to allocate them from the system malloc. And we add some `final` to containers and classes that would be never inherited. * wtf/Assertions.cpp: * wtf/Atomics.h: * wtf/AutodrainedPool.h: * wtf/Bag.h: (WTF::Bag::Bag): Deleted. (WTF::Bag::~Bag): Deleted. (WTF::Bag::clear): Deleted. (WTF::Bag::add): Deleted. (WTF::Bag::iterator::iterator): Deleted. (WTF::Bag::iterator::operator! const): Deleted. (WTF::Bag::iterator::operator* const): Deleted. (WTF::Bag::iterator::operator++): Deleted. (WTF::Bag::iterator::operator== const): Deleted. (WTF::Bag::iterator::operator!= const): Deleted. (WTF::Bag::begin): Deleted. (WTF::Bag::begin const): Deleted. (WTF::Bag::end const): Deleted. (WTF::Bag::isEmpty const): Deleted. (WTF::Bag::unwrappedHead const): Deleted. * wtf/BitVector.h: (WTF::BitVector::BitVector): Deleted. (WTF::BitVector::~BitVector): Deleted. (WTF::BitVector::operator=): Deleted. (WTF::BitVector::size const): Deleted. (WTF::BitVector::ensureSize): Deleted. (WTF::BitVector::quickGet const): Deleted. (WTF::BitVector::quickSet): Deleted. (WTF::BitVector::quickClear): Deleted. (WTF::BitVector::get const): Deleted. (WTF::BitVector::contains const): Deleted. (WTF::BitVector::set): Deleted. (WTF::BitVector::add): Deleted. (WTF::BitVector::ensureSizeAndSet): Deleted. (WTF::BitVector::clear): Deleted. (WTF::BitVector::remove): Deleted. (WTF::BitVector::merge): Deleted. (WTF::BitVector::filter): Deleted. (WTF::BitVector::exclude): Deleted. (WTF::BitVector::bitCount const): Deleted. (WTF::BitVector::isEmpty const): Deleted. (WTF::BitVector::findBit const): Deleted. (WTF::BitVector::isEmptyValue const): Deleted. (WTF::BitVector::isDeletedValue const): Deleted. (WTF::BitVector::isEmptyOrDeletedValue const): Deleted. (WTF::BitVector::operator== const): Deleted. (WTF::BitVector::hash const): Deleted. (WTF::BitVector::iterator::iterator): Deleted. (WTF::BitVector::iterator::operator* const): Deleted. (WTF::BitVector::iterator::operator++): Deleted. (WTF::BitVector::iterator::isAtEnd const): Deleted. (WTF::BitVector::iterator::operator== const): Deleted. (WTF::BitVector::iterator::operator!= const): Deleted. (WTF::BitVector::begin const): Deleted. (WTF::BitVector::end const): Deleted. (WTF::BitVector::bitsInPointer): Deleted. (WTF::BitVector::maxInlineBits): Deleted. (WTF::BitVector::byteCount): Deleted. (WTF::BitVector::makeInlineBits): Deleted. (WTF::BitVector::cleanseInlineBits): Deleted. (WTF::BitVector::bitCount): Deleted. (WTF::BitVector::findBitFast const): Deleted. (WTF::BitVector::findBitSimple const): Deleted. (WTF::BitVector::OutOfLineBits::numBits const): Deleted. (WTF::BitVector::OutOfLineBits::numWords const): Deleted. (WTF::BitVector::OutOfLineBits::bits): Deleted. (WTF::BitVector::OutOfLineBits::bits const): Deleted. (WTF::BitVector::OutOfLineBits::OutOfLineBits): Deleted. (WTF::BitVector::isInline const): Deleted. (WTF::BitVector::outOfLineBits const): Deleted. (WTF::BitVector::outOfLineBits): Deleted. (WTF::BitVector::bits): Deleted. (WTF::BitVector::bits const): Deleted. * wtf/Bitmap.h: (WTF::Bitmap::size): Deleted. (WTF::Bitmap::iterator::iterator): Deleted. (WTF::Bitmap::iterator::operator* const): Deleted. (WTF::Bitmap::iterator::operator++): Deleted. (WTF::Bitmap::iterator::operator== const): Deleted. (WTF::Bitmap::iterator::operator!= const): Deleted. (WTF::Bitmap::begin const): Deleted. (WTF::Bitmap::end const): Deleted. * wtf/Box.h: * wtf/BumpPointerAllocator.h: * wtf/CPUTime.h: * wtf/CheckedBoolean.h: * wtf/CommaPrinter.h: (WTF::CommaPrinter::CommaPrinter): Deleted. (WTF::CommaPrinter::dump const): Deleted. (WTF::CommaPrinter::didPrint const): Deleted. * wtf/CompactPointerTuple.h: (WTF::CompactPointerTuple::encodeType): Deleted. (WTF::CompactPointerTuple::decodeType): Deleted. (WTF::CompactPointerTuple::CompactPointerTuple): Deleted. (WTF::CompactPointerTuple::pointer const): Deleted. (WTF::CompactPointerTuple::setPointer): Deleted. (WTF::CompactPointerTuple::type const): Deleted. (WTF::CompactPointerTuple::setType): Deleted. * wtf/CompilationThread.h: (WTF::CompilationScope::CompilationScope): Deleted. (WTF::CompilationScope::~CompilationScope): Deleted. (WTF::CompilationScope::leaveEarly): Deleted. * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): (WTF::Detail::CallableWrapper<CompletionHandler<Out): (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::CompletionHandler<void): Deleted. * wtf/ConcurrentBuffer.h: (WTF::ConcurrentBuffer::ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::~ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::growExact): Deleted. (WTF::ConcurrentBuffer::grow): Deleted. (WTF::ConcurrentBuffer::array const): Deleted. (WTF::ConcurrentBuffer::operator[]): Deleted. (WTF::ConcurrentBuffer::operator[] const): Deleted. (WTF::ConcurrentBuffer::createArray): Deleted. * wtf/ConcurrentPtrHashSet.h: (WTF::ConcurrentPtrHashSet::contains): Deleted. (WTF::ConcurrentPtrHashSet::add): Deleted. (WTF::ConcurrentPtrHashSet::size const): Deleted. (WTF::ConcurrentPtrHashSet::Table::maxLoad const): Deleted. (WTF::ConcurrentPtrHashSet::hash): Deleted. (WTF::ConcurrentPtrHashSet::cast): Deleted. (WTF::ConcurrentPtrHashSet::containsImpl const): Deleted. (WTF::ConcurrentPtrHashSet::addImpl): Deleted. * wtf/ConcurrentVector.h: (WTF::ConcurrentVector::~ConcurrentVector): Deleted. (WTF::ConcurrentVector::size const): Deleted. (WTF::ConcurrentVector::isEmpty const): Deleted. (WTF::ConcurrentVector::at): Deleted. (WTF::ConcurrentVector::at const): Deleted. (WTF::ConcurrentVector::operator[]): Deleted. (WTF::ConcurrentVector::operator[] const): Deleted. (WTF::ConcurrentVector::first): Deleted. (WTF::ConcurrentVector::first const): Deleted. (WTF::ConcurrentVector::last): Deleted. (WTF::ConcurrentVector::last const): Deleted. (WTF::ConcurrentVector::takeLast): Deleted. (WTF::ConcurrentVector::append): Deleted. (WTF::ConcurrentVector::alloc): Deleted. (WTF::ConcurrentVector::removeLast): Deleted. (WTF::ConcurrentVector::grow): Deleted. (WTF::ConcurrentVector::begin): Deleted. (WTF::ConcurrentVector::end): Deleted. (WTF::ConcurrentVector::segmentExistsFor): Deleted. (WTF::ConcurrentVector::segmentFor): Deleted. (WTF::ConcurrentVector::subscriptFor): Deleted. (WTF::ConcurrentVector::ensureSegmentsFor): Deleted. (WTF::ConcurrentVector::ensureSegment): Deleted. (WTF::ConcurrentVector::allocateSegment): Deleted. * wtf/Condition.h: (WTF::Condition::waitUntil): Deleted. (WTF::Condition::waitFor): Deleted. (WTF::Condition::wait): Deleted. (WTF::Condition::notifyOne): Deleted. (WTF::Condition::notifyAll): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::LockHooks::lockHook): Deleted. (WTF::CountingLock::LockHooks::unlockHook): Deleted. (WTF::CountingLock::LockHooks::parkHook): Deleted. (WTF::CountingLock::LockHooks::handoffHook): Deleted. (WTF::CountingLock::tryLock): Deleted. (WTF::CountingLock::lock): Deleted. (WTF::CountingLock::unlock): Deleted. (WTF::CountingLock::isHeld const): Deleted. (WTF::CountingLock::isLocked const): Deleted. (WTF::CountingLock::Count::operator bool const): Deleted. (WTF::CountingLock::Count::operator== const): Deleted. (WTF::CountingLock::Count::operator!= const): Deleted. (WTF::CountingLock::tryOptimisticRead): Deleted. (WTF::CountingLock::validate): Deleted. (WTF::CountingLock::doOptimizedRead): Deleted. (WTF::CountingLock::tryOptimisticFencelessRead): Deleted. (WTF::CountingLock::fencelessValidate): Deleted. (WTF::CountingLock::doOptimizedFencelessRead): Deleted. (WTF::CountingLock::getCount): Deleted. * wtf/CrossThreadQueue.h: * wtf/CrossThreadTask.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/DataMutex.h: * wtf/DateMath.h: * wtf/Deque.h: (WTF::Deque::size const): Deleted. (WTF::Deque::isEmpty const): Deleted. (WTF::Deque::begin): Deleted. (WTF::Deque::end): Deleted. (WTF::Deque::begin const): Deleted. (WTF::Deque::end const): Deleted. (WTF::Deque::rbegin): Deleted. (WTF::Deque::rend): Deleted. (WTF::Deque::rbegin const): Deleted. (WTF::Deque::rend const): Deleted. (WTF::Deque::first): Deleted. (WTF::Deque::first const): Deleted. (WTF::Deque::last): Deleted. (WTF::Deque::last const): Deleted. (WTF::Deque::append): Deleted. * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/Expected.h: * wtf/FastBitVector.h: * wtf/FileMetadata.h: * wtf/FileSystem.h: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.h: (WTF::GregorianDateTime::GregorianDateTime): Deleted. (WTF::GregorianDateTime::year const): Deleted. (WTF::GregorianDateTime::month const): Deleted. (WTF::GregorianDateTime::yearDay const): Deleted. (WTF::GregorianDateTime::monthDay const): Deleted. (WTF::GregorianDateTime::weekDay const): Deleted. (WTF::GregorianDateTime::hour const): Deleted. (WTF::GregorianDateTime::minute const): Deleted. (WTF::GregorianDateTime::second const): Deleted. (WTF::GregorianDateTime::utcOffset const): Deleted. (WTF::GregorianDateTime::isDST const): Deleted. (WTF::GregorianDateTime::setYear): Deleted. (WTF::GregorianDateTime::setMonth): Deleted. (WTF::GregorianDateTime::setYearDay): Deleted. (WTF::GregorianDateTime::setMonthDay): Deleted. (WTF::GregorianDateTime::setWeekDay): Deleted. (WTF::GregorianDateTime::setHour): Deleted. (WTF::GregorianDateTime::setMinute): Deleted. (WTF::GregorianDateTime::setSecond): Deleted. (WTF::GregorianDateTime::setUtcOffset): Deleted. (WTF::GregorianDateTime::setIsDST): Deleted. (WTF::GregorianDateTime::operator tm const): Deleted. (WTF::GregorianDateTime::copyFrom): Deleted. * wtf/HashTable.h: * wtf/Hasher.h: * wtf/HexNumber.h: * wtf/Indenter.h: * wtf/IndexMap.h: * wtf/IndexSet.h: * wtf/IndexSparseSet.h: * wtf/IndexedContainerIterator.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/KeyValuePair.h: * wtf/ListHashSet.h: (WTF::ListHashSet::begin): Deleted. (WTF::ListHashSet::end): Deleted. (WTF::ListHashSet::begin const): Deleted. (WTF::ListHashSet::end const): Deleted. (WTF::ListHashSet::random): Deleted. (WTF::ListHashSet::random const): Deleted. (WTF::ListHashSet::rbegin): Deleted. (WTF::ListHashSet::rend): Deleted. (WTF::ListHashSet::rbegin const): Deleted. (WTF::ListHashSet::rend const): Deleted. * wtf/Liveness.h: * wtf/LocklessBag.h: (WTF::LocklessBag::LocklessBag): Deleted. (WTF::LocklessBag::add): Deleted. (WTF::LocklessBag::iterate): Deleted. (WTF::LocklessBag::consumeAll): Deleted. (WTF::LocklessBag::consumeAllWithNode): Deleted. (WTF::LocklessBag::~LocklessBag): Deleted. * wtf/LoggingHashID.h: * wtf/MD5.h: * wtf/MachSendRight.h: * wtf/MainThreadData.h: * wtf/Markable.h: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.h: * wtf/MessageQueue.h: (WTF::MessageQueue::MessageQueue): Deleted. * wtf/MetaAllocator.h: * wtf/MonotonicTime.h: (WTF::MonotonicTime::MonotonicTime): Deleted. (WTF::MonotonicTime::fromRawSeconds): Deleted. (WTF::MonotonicTime::infinity): Deleted. (WTF::MonotonicTime::nan): Deleted. (WTF::MonotonicTime::secondsSinceEpoch const): Deleted. (WTF::MonotonicTime::approximateMonotonicTime const): Deleted. (WTF::MonotonicTime::operator bool const): Deleted. (WTF::MonotonicTime::operator+ const): Deleted. (WTF::MonotonicTime::operator- const): Deleted. (WTF::MonotonicTime::operator% const): Deleted. (WTF::MonotonicTime::operator+=): Deleted. (WTF::MonotonicTime::operator-=): Deleted. (WTF::MonotonicTime::operator== const): Deleted. (WTF::MonotonicTime::operator!= const): Deleted. (WTF::MonotonicTime::operator< const): Deleted. (WTF::MonotonicTime::operator> const): Deleted. (WTF::MonotonicTime::operator<= const): Deleted. (WTF::MonotonicTime::operator>= const): Deleted. (WTF::MonotonicTime::isolatedCopy const): Deleted. (WTF::MonotonicTime::encode const): Deleted. (WTF::MonotonicTime::decode): Deleted. * wtf/NaturalLoops.h: * wtf/NoLock.h: * wtf/OSAllocator.h: * wtf/OptionSet.h: * wtf/Optional.h: * wtf/OrderMaker.h: * wtf/Packed.h: (WTF::alignof): * wtf/PackedIntVector.h: (WTF::PackedIntVector::PackedIntVector): Deleted. (WTF::PackedIntVector::operator=): Deleted. (WTF::PackedIntVector::size const): Deleted. (WTF::PackedIntVector::ensureSize): Deleted. (WTF::PackedIntVector::resize): Deleted. (WTF::PackedIntVector::clearAll): Deleted. (WTF::PackedIntVector::get const): Deleted. (WTF::PackedIntVector::set): Deleted. (WTF::PackedIntVector::mask): Deleted. * wtf/PageBlock.h: * wtf/ParallelJobsOpenMP.h: * wtf/ParkingLot.h: * wtf/PriorityQueue.h: (WTF::PriorityQueue::size const): Deleted. (WTF::PriorityQueue::isEmpty const): Deleted. (WTF::PriorityQueue::enqueue): Deleted. (WTF::PriorityQueue::peek const): Deleted. (WTF::PriorityQueue::dequeue): Deleted. (WTF::PriorityQueue::decreaseKey): Deleted. (WTF::PriorityQueue::increaseKey): Deleted. (WTF::PriorityQueue::begin const): Deleted. (WTF::PriorityQueue::end const): Deleted. (WTF::PriorityQueue::isValidHeap const): Deleted. (WTF::PriorityQueue::parentOf): Deleted. (WTF::PriorityQueue::leftChildOf): Deleted. (WTF::PriorityQueue::rightChildOf): Deleted. (WTF::PriorityQueue::siftUp): Deleted. (WTF::PriorityQueue::siftDown): Deleted. * wtf/RandomDevice.h: * wtf/Range.h: * wtf/RangeSet.h: (WTF::RangeSet::RangeSet): Deleted. (WTF::RangeSet::~RangeSet): Deleted. (WTF::RangeSet::add): Deleted. (WTF::RangeSet::contains const): Deleted. (WTF::RangeSet::overlaps const): Deleted. (WTF::RangeSet::clear): Deleted. (WTF::RangeSet::dump const): Deleted. (WTF::RangeSet::dumpRaw const): Deleted. (WTF::RangeSet::begin const): Deleted. (WTF::RangeSet::end const): Deleted. (WTF::RangeSet::addAll): Deleted. (WTF::RangeSet::compact): Deleted. (WTF::RangeSet::overlapsNonEmpty): Deleted. (WTF::RangeSet::subsumesNonEmpty): Deleted. (WTF::RangeSet::findRange const): Deleted. * wtf/RecursableLambda.h: * wtf/RedBlackTree.h: (WTF::RedBlackTree::Node::successor const): Deleted. (WTF::RedBlackTree::Node::predecessor const): Deleted. (WTF::RedBlackTree::Node::successor): Deleted. (WTF::RedBlackTree::Node::predecessor): Deleted. (WTF::RedBlackTree::Node::reset): Deleted. (WTF::RedBlackTree::Node::parent const): Deleted. (WTF::RedBlackTree::Node::setParent): Deleted. (WTF::RedBlackTree::Node::left const): Deleted. (WTF::RedBlackTree::Node::setLeft): Deleted. (WTF::RedBlackTree::Node::right const): Deleted. (WTF::RedBlackTree::Node::setRight): Deleted. (WTF::RedBlackTree::Node::color const): Deleted. (WTF::RedBlackTree::Node::setColor): Deleted. (WTF::RedBlackTree::RedBlackTree): Deleted. (WTF::RedBlackTree::insert): Deleted. (WTF::RedBlackTree::remove): Deleted. (WTF::RedBlackTree::findExact const): Deleted. (WTF::RedBlackTree::findLeastGreaterThanOrEqual const): Deleted. (WTF::RedBlackTree::findGreatestLessThanOrEqual const): Deleted. (WTF::RedBlackTree::first const): Deleted. (WTF::RedBlackTree::last const): Deleted. (WTF::RedBlackTree::size): Deleted. (WTF::RedBlackTree::isEmpty): Deleted. (WTF::RedBlackTree::treeMinimum): Deleted. (WTF::RedBlackTree::treeMaximum): Deleted. (WTF::RedBlackTree::treeInsert): Deleted. (WTF::RedBlackTree::leftRotate): Deleted. (WTF::RedBlackTree::rightRotate): Deleted. (WTF::RedBlackTree::removeFixup): Deleted. * wtf/ResourceUsage.h: * wtf/RunLoop.cpp: * wtf/RunLoopTimer.h: * wtf/SHA1.h: * wtf/Seconds.h: (WTF::Seconds::Seconds): Deleted. (WTF::Seconds::value const): Deleted. (WTF::Seconds::minutes const): Deleted. (WTF::Seconds::seconds const): Deleted. (WTF::Seconds::milliseconds const): Deleted. (WTF::Seconds::microseconds const): Deleted. (WTF::Seconds::nanoseconds const): Deleted. (WTF::Seconds::minutesAs const): Deleted. (WTF::Seconds::secondsAs const): Deleted. (WTF::Seconds::millisecondsAs const): Deleted. (WTF::Seconds::microsecondsAs const): Deleted. (WTF::Seconds::nanosecondsAs const): Deleted. (WTF::Seconds::fromMinutes): Deleted. (WTF::Seconds::fromHours): Deleted. (WTF::Seconds::fromMilliseconds): Deleted. (WTF::Seconds::fromMicroseconds): Deleted. (WTF::Seconds::fromNanoseconds): Deleted. (WTF::Seconds::infinity): Deleted. (WTF::Seconds::nan): Deleted. (WTF::Seconds::operator bool const): Deleted. (WTF::Seconds::operator+ const): Deleted. (WTF::Seconds::operator- const): Deleted. (WTF::Seconds::operator* const): Deleted. (WTF::Seconds::operator/ const): Deleted. (WTF::Seconds::operator% const): Deleted. (WTF::Seconds::operator+=): Deleted. (WTF::Seconds::operator-=): Deleted. (WTF::Seconds::operator*=): Deleted. (WTF::Seconds::operator/=): Deleted. (WTF::Seconds::operator%=): Deleted. (WTF::Seconds::operator== const): Deleted. (WTF::Seconds::operator!= const): Deleted. (WTF::Seconds::operator< const): Deleted. (WTF::Seconds::operator> const): Deleted. (WTF::Seconds::operator<= const): Deleted. (WTF::Seconds::operator>= const): Deleted. (WTF::Seconds::isolatedCopy const): Deleted. (WTF::Seconds::encode const): Deleted. (WTF::Seconds::decode): Deleted. * wtf/SegmentedVector.h: (WTF::SegmentedVector::~SegmentedVector): Deleted. (WTF::SegmentedVector::size const): Deleted. (WTF::SegmentedVector::isEmpty const): Deleted. (WTF::SegmentedVector::at): Deleted. (WTF::SegmentedVector::at const): Deleted. (WTF::SegmentedVector::operator[]): Deleted. (WTF::SegmentedVector::operator[] const): Deleted. (WTF::SegmentedVector::first): Deleted. (WTF::SegmentedVector::first const): Deleted. (WTF::SegmentedVector::last): Deleted. (WTF::SegmentedVector::last const): Deleted. (WTF::SegmentedVector::takeLast): Deleted. (WTF::SegmentedVector::append): Deleted. (WTF::SegmentedVector::alloc): Deleted. (WTF::SegmentedVector::removeLast): Deleted. (WTF::SegmentedVector::grow): Deleted. (WTF::SegmentedVector::clear): Deleted. (WTF::SegmentedVector::begin): Deleted. (WTF::SegmentedVector::end): Deleted. (WTF::SegmentedVector::shrinkToFit): Deleted. (WTF::SegmentedVector::deleteAllSegments): Deleted. (WTF::SegmentedVector::segmentExistsFor): Deleted. (WTF::SegmentedVector::segmentFor): Deleted. (WTF::SegmentedVector::subscriptFor): Deleted. (WTF::SegmentedVector::ensureSegmentsFor): Deleted. (WTF::SegmentedVector::ensureSegment): Deleted. (WTF::SegmentedVector::allocateSegment): Deleted. * wtf/SetForScope.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SmallPtrSet.h: * wtf/SpanningTree.h: * wtf/Spectrum.h: * wtf/StackBounds.h: * wtf/StackShot.h: * wtf/StackShotProfiler.h: * wtf/StackStats.h: * wtf/StackTrace.h: * wtf/StreamBuffer.h: * wtf/SynchronizedFixedQueue.h: (WTF::SynchronizedFixedQueue::create): Deleted. (WTF::SynchronizedFixedQueue::open): Deleted. (WTF::SynchronizedFixedQueue::close): Deleted. (WTF::SynchronizedFixedQueue::isOpen): Deleted. (WTF::SynchronizedFixedQueue::enqueue): Deleted. (WTF::SynchronizedFixedQueue::dequeue): Deleted. (WTF::SynchronizedFixedQueue::SynchronizedFixedQueue): Deleted. * wtf/SystemTracing.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::create): Deleted. (WTF::ThreadGroup::threads const): Deleted. (WTF::ThreadGroup::getLock): Deleted. (WTF::ThreadGroup::weakFromThis): Deleted. * wtf/ThreadSpecific.h: * wtf/ThreadingPrimitives.h: (WTF::Mutex::impl): Deleted. * wtf/TimeWithDynamicClockType.h: (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): Deleted. (WTF::TimeWithDynamicClockType::fromRawSeconds): Deleted. (WTF::TimeWithDynamicClockType::secondsSinceEpoch const): Deleted. (WTF::TimeWithDynamicClockType::clockType const): Deleted. (WTF::TimeWithDynamicClockType::withSameClockAndRawSeconds const): Deleted. (WTF::TimeWithDynamicClockType::operator bool const): Deleted. (WTF::TimeWithDynamicClockType::operator+ const): Deleted. (WTF::TimeWithDynamicClockType::operator- const): Deleted. (WTF::TimeWithDynamicClockType::operator+=): Deleted. (WTF::TimeWithDynamicClockType::operator-=): Deleted. (WTF::TimeWithDynamicClockType::operator== const): Deleted. (WTF::TimeWithDynamicClockType::operator!= const): Deleted. * wtf/TimingScope.h: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/URLParser.cpp: * wtf/URLParser.h: * wtf/Unexpected.h: * wtf/Variant.h: * wtf/WTFSemaphore.h: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::signal): Deleted. (WTF::Semaphore::waitUntil): Deleted. (WTF::Semaphore::waitFor): Deleted. (WTF::Semaphore::wait): Deleted. * wtf/WallTime.h: (WTF::WallTime::WallTime): Deleted. (WTF::WallTime::fromRawSeconds): Deleted. (WTF::WallTime::infinity): Deleted. (WTF::WallTime::nan): Deleted. (WTF::WallTime::secondsSinceEpoch const): Deleted. (WTF::WallTime::approximateWallTime const): Deleted. (WTF::WallTime::operator bool const): Deleted. (WTF::WallTime::operator+ const): Deleted. (WTF::WallTime::operator- const): Deleted. (WTF::WallTime::operator+=): Deleted. (WTF::WallTime::operator-=): Deleted. (WTF::WallTime::operator== const): Deleted. (WTF::WallTime::operator!= const): Deleted. (WTF::WallTime::operator< const): Deleted. (WTF::WallTime::operator> const): Deleted. (WTF::WallTime::operator<= const): Deleted. (WTF::WallTime::operator>= const): Deleted. (WTF::WallTime::isolatedCopy const): Deleted. * wtf/WeakHashSet.h: (WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::get const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator* const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator++): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator== const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const): Deleted. (WTF::WeakHashSet::WeakHashSet): Deleted. (WTF::WeakHashSet::begin const): Deleted. (WTF::WeakHashSet::end const): Deleted. (WTF::WeakHashSet::add): Deleted. (WTF::WeakHashSet::remove): Deleted. (WTF::WeakHashSet::contains const): Deleted. (WTF::WeakHashSet::capacity const): Deleted. (WTF::WeakHashSet::computesEmpty const): Deleted. (WTF::WeakHashSet::hasNullReferences const): Deleted. (WTF::WeakHashSet::computeSize const): Deleted. (WTF::WeakHashSet::checkConsistency const): Deleted. * wtf/WeakRandom.h: (WTF::WeakRandom::WeakRandom): Deleted. (WTF::WeakRandom::setSeed): Deleted. (WTF::WeakRandom::seed const): Deleted. (WTF::WeakRandom::get): Deleted. (WTF::WeakRandom::getUint32): Deleted. (WTF::WeakRandom::lowOffset): Deleted. (WTF::WeakRandom::highOffset): Deleted. (WTF::WeakRandom::nextState): Deleted. (WTF::WeakRandom::generate): Deleted. (WTF::WeakRandom::advance): Deleted. * wtf/WordLock.h: (WTF::WordLock::lock): Deleted. (WTF::WordLock::unlock): Deleted. (WTF::WordLock::isHeld const): Deleted. (WTF::WordLock::isLocked const): Deleted. (WTF::WordLock::isFullyReset const): Deleted. * wtf/generic/MainThreadGeneric.cpp: * wtf/glib/GMutexLocker.h: * wtf/linux/CurrentProcessMemoryStatus.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::~Semaphore): Deleted. (WTF::Semaphore::wait): Deleted. (WTF::Semaphore::post): Deleted. * wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::operator const char* const): Deleted. (WTF::ASCIILiteral::fromLiteralUnsafe): Deleted. (WTF::ASCIILiteral::null): Deleted. (WTF::ASCIILiteral::characters const): Deleted. (WTF::ASCIILiteral::ASCIILiteral): Deleted. * wtf/text/AtomString.h: (WTF::AtomString::operator=): Deleted. (WTF::AtomString::isHashTableDeletedValue const): Deleted. (WTF::AtomString::existingHash const): Deleted. (WTF::AtomString::operator const String& const): Deleted. (WTF::AtomString::string const): Deleted. (WTF::AtomString::impl const): Deleted. (WTF::AtomString::is8Bit const): Deleted. (WTF::AtomString::characters8 const): Deleted. (WTF::AtomString::characters16 const): Deleted. (WTF::AtomString::length const): Deleted. (WTF::AtomString::operator[] const): Deleted. (WTF::AtomString::contains const): Deleted. (WTF::AtomString::containsIgnoringASCIICase const): Deleted. (WTF::AtomString::find const): Deleted. (WTF::AtomString::findIgnoringASCIICase const): Deleted. (WTF::AtomString::startsWith const): Deleted. (WTF::AtomString::startsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::endsWith const): Deleted. (WTF::AtomString::endsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::toInt const): Deleted. (WTF::AtomString::toDouble const): Deleted. (WTF::AtomString::toFloat const): Deleted. (WTF::AtomString::percentage const): Deleted. (WTF::AtomString::isNull const): Deleted. (WTF::AtomString::isEmpty const): Deleted. (WTF::AtomString::operator NSString * const): Deleted. * wtf/text/AtomStringImpl.h: (WTF::AtomStringImpl::lookUp): Deleted. (WTF::AtomStringImpl::add): Deleted. (WTF::AtomStringImpl::addWithStringTableProvider): Deleted. * wtf/text/CString.h: (WTF::CStringBuffer::data): Deleted. (WTF::CStringBuffer::length const): Deleted. (WTF::CStringBuffer::CStringBuffer): Deleted. (WTF::CStringBuffer::mutableData): Deleted. (WTF::CString::CString): Deleted. (WTF::CString::data const): Deleted. (WTF::CString::length const): Deleted. (WTF::CString::isNull const): Deleted. (WTF::CString::buffer const): Deleted. (WTF::CString::isHashTableDeletedValue const): Deleted. * wtf/text/ExternalStringImpl.h: (WTF::ExternalStringImpl::freeExternalBuffer): Deleted. * wtf/text/LineBreakIteratorPoolICU.h: * wtf/text/NullTextBreakIterator.h: * wtf/text/OrdinalNumber.h: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.h: * wtf/text/StringConcatenateNumbers.h: * wtf/text/StringHasher.h: * wtf/text/StringImpl.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: (WTF::StringView::left const): Deleted. (WTF::StringView::right const): Deleted. (WTF::StringView::underlyingStringIsValid const): Deleted. (WTF::StringView::setUnderlyingString): Deleted. * wtf/text/SymbolImpl.h: (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl): Deleted. (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&): Deleted. (WTF::PrivateSymbolImpl::PrivateSymbolImpl): Deleted. (WTF::RegisteredSymbolImpl::symbolRegistry const): Deleted. (WTF::RegisteredSymbolImpl::clearSymbolRegistry): Deleted. (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl): Deleted. * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.h: * wtf/text/WTFString.h: (WTF::String::swap): Deleted. (WTF::String::adopt): Deleted. (WTF::String::isNull const): Deleted. (WTF::String::isEmpty const): Deleted. (WTF::String::impl const): Deleted. (WTF::String::releaseImpl): Deleted. (WTF::String::length const): Deleted. (WTF::String::characters8 const): Deleted. (WTF::String::characters16 const): Deleted. (WTF::String::is8Bit const): Deleted. (WTF::String::sizeInBytes const): Deleted. (WTF::String::operator[] const): Deleted. (WTF::String::find const): Deleted. (WTF::String::findIgnoringASCIICase const): Deleted. (WTF::String::reverseFind const): Deleted. (WTF::String::contains const): Deleted. (WTF::String::containsIgnoringASCIICase const): Deleted. (WTF::String::startsWith const): Deleted. (WTF::String::startsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixStartingAt const): Deleted. (WTF::String::endsWith const): Deleted. (WTF::String::endsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixEndingAt const): Deleted. (WTF::String::append): Deleted. (WTF::String::left const): Deleted. (WTF::String::right const): Deleted. (WTF::String::createUninitialized): Deleted. (WTF::String::fromUTF8WithLatin1Fallback): Deleted. (WTF::String::isAllASCII const): Deleted. (WTF::String::isAllLatin1 const): Deleted. (WTF::String::isSpecialCharacter const): Deleted. (WTF::String::isHashTableDeletedValue const): Deleted. (WTF::String::hash const): Deleted. (WTF::String::existingHash const): Deleted. * wtf/text/cf/TextBreakIteratorCF.h: * wtf/text/icu/TextBreakIteratorICU.h: * wtf/text/icu/UTextProviderLatin1.h: * wtf/threads/BinarySemaphore.h: (WTF::BinarySemaphore::waitFor): Deleted. (WTF::BinarySemaphore::wait): Deleted. * wtf/unicode/Collator.h: * wtf/win/GDIObject.h: * wtf/win/PathWalker.h: * wtf/win/Win32Handle.h: Canonical link: https://commits.webkit.org/214396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 20:57:15 +00:00
class WordLock final {
[WTF] Remove XXXLockBase since constexpr constructor can initialize static variables without calling global constructors https://bugs.webkit.org/show_bug.cgi?id=180495 Reviewed by Mark Lam. Very nice feature of C++11 is that constexpr constructor can initialize static global variables without calling global constructors. We do not need to have XXXLockBase with derived XXXLock class since StaticXXXLock can have constructors as long as it is constexpr. We remove bunch of these classes, and set `XXXLock() = default;` explicitly for readability. C++11's default constructor is constexpr as long as its member's default constructor / default initializer is constexpr. * wtf/Condition.h: (WTF::ConditionBase::construct): Deleted. (WTF::ConditionBase::waitUntil): Deleted. (WTF::ConditionBase::waitFor): Deleted. (WTF::ConditionBase::wait): Deleted. (WTF::ConditionBase::notifyOne): Deleted. (WTF::ConditionBase::notifyAll): Deleted. (WTF::Condition::Condition): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::CountingLock): Deleted. (WTF::CountingLock::~CountingLock): Deleted. * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): (WTF::Lock::safepointSlow): (WTF::LockBase::lockSlow): Deleted. (WTF::LockBase::unlockSlow): Deleted. (WTF::LockBase::unlockFairlySlow): Deleted. (WTF::LockBase::safepointSlow): Deleted. * wtf/Lock.h: (WTF::LockBase::construct): Deleted. (WTF::LockBase::lock): Deleted. (WTF::LockBase::tryLock): Deleted. (WTF::LockBase::try_lock): Deleted. (WTF::LockBase::unlock): Deleted. (WTF::LockBase::unlockFairly): Deleted. (WTF::LockBase::safepoint): Deleted. (WTF::LockBase::isHeld const): Deleted. (WTF::LockBase::isLocked const): Deleted. (WTF::LockBase::isFullyReset const): Deleted. (WTF::Lock::Lock): Deleted. * wtf/ReadWriteLock.cpp: (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::readUnlock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::writeUnlock): (WTF::ReadWriteLockBase::construct): Deleted. (WTF::ReadWriteLockBase::readLock): Deleted. (WTF::ReadWriteLockBase::readUnlock): Deleted. (WTF::ReadWriteLockBase::writeLock): Deleted. (WTF::ReadWriteLockBase::writeUnlock): Deleted. * wtf/ReadWriteLock.h: (WTF::ReadWriteLock::read): (WTF::ReadWriteLock::write): (WTF::ReadWriteLockBase::ReadLock::tryLock): Deleted. (WTF::ReadWriteLockBase::ReadLock::lock): Deleted. (WTF::ReadWriteLockBase::ReadLock::unlock): Deleted. (WTF::ReadWriteLockBase::WriteLock::tryLock): Deleted. (WTF::ReadWriteLockBase::WriteLock::lock): Deleted. (WTF::ReadWriteLockBase::WriteLock::unlock): Deleted. (WTF::ReadWriteLockBase::read): Deleted. (WTF::ReadWriteLockBase::write): Deleted. (WTF::ReadWriteLock::ReadWriteLock): Deleted. * wtf/RecursiveLockAdapter.h: (WTF::RecursiveLockAdapter::RecursiveLockAdapter): Deleted. * wtf/WordLock.cpp: (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): (WTF::WordLockBase::lockSlow): Deleted. (WTF::WordLockBase::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): Deleted. (WTF::WordLockBase::unlock): Deleted. (WTF::WordLockBase::isHeld const): Deleted. (WTF::WordLockBase::isLocked const): Deleted. (WTF::WordLockBase::isFullyReset const): Deleted. (WTF::WordLock::WordLock): Deleted. * wtf/WorkQueue.cpp: Canonical link: https://commits.webkit.org/196438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-07 03:52:09 +00:00
WTF_MAKE_NONCOPYABLE(WordLock);
WTF_MAKE_FAST_ALLOCATED;
public:
Use WordLock instead of std::mutex for Threading https://bugs.webkit.org/show_bug.cgi?id=185121 Reviewed by Geoffrey Garen. Source/bmalloc: Add constexpr to explicitly describe that bmalloc::Mutex constructor is constexpr. * bmalloc/Mutex.h: Source/JavaScriptCore: ThreadGroup starts using WordLock. * heap/MachineStackMarker.h: (JSC::MachineThreads::getLock): Source/WTF: Before r231151, WordLock depends on ThreadSpecific. It means that our Threading implementation cannot use this lock since Threading primitives could touch these locks after ThreadSpecific for that WordLock is destroyed. Now WordLock is changed not to use ThreadSpecific. So it does not depend on our Threading mechanism and our Threading can start using WordLock internally. This patch changes WTF::Thread and WTF::ThreadGroup to use WordLock instead of std::mutex. And add constexpr to explicitly describe that Lock, Condition, and WordLock constructors are constexpr. * wtf/Condition.h: * wtf/Lock.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::getLock): * wtf/Threading.cpp: (WTF::Thread::didExit): (WTF::Thread::addToThreadGroup): (WTF::Thread::removeFromThreadGroup): * wtf/Threading.h: * wtf/ThreadingPthreads.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::signal): (WTF::Thread::establishPlatformSpecificHandle): * wtf/ThreadingWin.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::establishPlatformSpecificHandle): (WTF::Thread::initializeTLSKey): (WTF::Thread::currentDying): (WTF::Thread::get): (WTF::Thread::initializeTLS): (WTF::Thread::destructTLS): (WTF::threadMapMutex): Deleted. * wtf/WordLock.h: Tools: * TestWebKitAPI/Tests/WTF/Signals.cpp: (TEST): Canonical link: https://commits.webkit.org/200620@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-04-30 17:30:26 +00:00
constexpr WordLock() = default;
[WTF] Remove XXXLockBase since constexpr constructor can initialize static variables without calling global constructors https://bugs.webkit.org/show_bug.cgi?id=180495 Reviewed by Mark Lam. Very nice feature of C++11 is that constexpr constructor can initialize static global variables without calling global constructors. We do not need to have XXXLockBase with derived XXXLock class since StaticXXXLock can have constructors as long as it is constexpr. We remove bunch of these classes, and set `XXXLock() = default;` explicitly for readability. C++11's default constructor is constexpr as long as its member's default constructor / default initializer is constexpr. * wtf/Condition.h: (WTF::ConditionBase::construct): Deleted. (WTF::ConditionBase::waitUntil): Deleted. (WTF::ConditionBase::waitFor): Deleted. (WTF::ConditionBase::wait): Deleted. (WTF::ConditionBase::notifyOne): Deleted. (WTF::ConditionBase::notifyAll): Deleted. (WTF::Condition::Condition): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::CountingLock): Deleted. (WTF::CountingLock::~CountingLock): Deleted. * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): (WTF::Lock::safepointSlow): (WTF::LockBase::lockSlow): Deleted. (WTF::LockBase::unlockSlow): Deleted. (WTF::LockBase::unlockFairlySlow): Deleted. (WTF::LockBase::safepointSlow): Deleted. * wtf/Lock.h: (WTF::LockBase::construct): Deleted. (WTF::LockBase::lock): Deleted. (WTF::LockBase::tryLock): Deleted. (WTF::LockBase::try_lock): Deleted. (WTF::LockBase::unlock): Deleted. (WTF::LockBase::unlockFairly): Deleted. (WTF::LockBase::safepoint): Deleted. (WTF::LockBase::isHeld const): Deleted. (WTF::LockBase::isLocked const): Deleted. (WTF::LockBase::isFullyReset const): Deleted. (WTF::Lock::Lock): Deleted. * wtf/ReadWriteLock.cpp: (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::readUnlock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::writeUnlock): (WTF::ReadWriteLockBase::construct): Deleted. (WTF::ReadWriteLockBase::readLock): Deleted. (WTF::ReadWriteLockBase::readUnlock): Deleted. (WTF::ReadWriteLockBase::writeLock): Deleted. (WTF::ReadWriteLockBase::writeUnlock): Deleted. * wtf/ReadWriteLock.h: (WTF::ReadWriteLock::read): (WTF::ReadWriteLock::write): (WTF::ReadWriteLockBase::ReadLock::tryLock): Deleted. (WTF::ReadWriteLockBase::ReadLock::lock): Deleted. (WTF::ReadWriteLockBase::ReadLock::unlock): Deleted. (WTF::ReadWriteLockBase::WriteLock::tryLock): Deleted. (WTF::ReadWriteLockBase::WriteLock::lock): Deleted. (WTF::ReadWriteLockBase::WriteLock::unlock): Deleted. (WTF::ReadWriteLockBase::read): Deleted. (WTF::ReadWriteLockBase::write): Deleted. (WTF::ReadWriteLock::ReadWriteLock): Deleted. * wtf/RecursiveLockAdapter.h: (WTF::RecursiveLockAdapter::RecursiveLockAdapter): Deleted. * wtf/WordLock.cpp: (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): (WTF::WordLockBase::lockSlow): Deleted. (WTF::WordLockBase::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): Deleted. (WTF::WordLockBase::unlock): Deleted. (WTF::WordLockBase::isHeld const): Deleted. (WTF::WordLockBase::isLocked const): Deleted. (WTF::WordLockBase::isFullyReset const): Deleted. (WTF::WordLock::WordLock): Deleted. * wtf/WorkQueue.cpp: Canonical link: https://commits.webkit.org/196438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-07 03:52:09 +00:00
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
void lock()
{
if (LIKELY(m_word.compareExchangeWeak(0, isLockedBit, std::memory_order_acquire))) {
// WordLock acquired!
return;
}
lockSlow();
}
void unlock()
{
if (LIKELY(m_word.compareExchangeWeak(isLockedBit, 0, std::memory_order_release))) {
// WordLock released, and nobody was waiting!
return;
}
unlockSlow();
}
bool isHeld() const
{
return m_word.load(std::memory_order_acquire) & isLockedBit;
}
bool isLocked() const
{
return isHeld();
}
Silence leaks in ParkingLot https://bugs.webkit.org/show_bug.cgi?id=155510 Reviewed by Alexey Proskuryakov. ParkingLot has a concurrent hashtable that it reallocates on demand. It will not reallocate it in steady state. The hashtable is sized to accommodate the high watermark of the number of active threads - so long as the program doesn't just keep starting an unbounded number of threads that are all active, the hashtable will stop resizing. Each resize operation is designed to stay out of the way of the data-access-parallel normal path, in which two threads operating on different lock addresses don't have to synchronize. To do this, it simply drops the old hashtable without deleting it, so that threads that were still using it don't crash. They will realize that they have the wrong hashtable before doing anything bad, but we don't have a way of proving when all of those threads are no longer going to read from the old hashtables. So, we just leak them. This is a bounded leak, since the hashtable resizes exponentially. Thus the total memory utilization of all hashtables, including the leaked ones, converges to a linear function of the current hashtable's size (it's 2 * size of current hashtable). But this leak is a problem for leaks tools, which will always report this leak. This is not useful. It's better to silence the leak. That's what this patch does by ensuring that all hashtables, including leaked ones, end up in a global vector. This is perf-neutral. This requires making a StaticWordLock variant of WordLock. That's probably the biggest part of this change. * wtf/ParkingLot.cpp: * wtf/WordLock.cpp: (WTF::WordLockBase::lockSlow): (WTF::WordLockBase::unlockSlow): (WTF::WordLock::lockSlow): Deleted. (WTF::WordLock::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): (WTF::WordLockBase::isLocked): (WTF::WordLock::WordLock): (WTF::WordLock::lock): Deleted. (WTF::WordLock::isLocked): Deleted. Canonical link: https://commits.webkit.org/173707@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-17 18:54:15 +00:00
protected:
WTF::Lock should not suffer from the thundering herd https://bugs.webkit.org/show_bug.cgi?id=147947 Reviewed by Geoffrey Garen. Source/WTF: This changes Lock::unlockSlow() to use unparkOne() instead of unparkAll(). The problem with doing this is that it's not obvious after calling unparkOne() if there are any other threads that are still parked on the lock's queue. If we assume that there are and leave the hasParkedBit set, then future calls to unlock() will take the slow path. We don't want that if there aren't actually any threads parked. On the other hand, if we assume that there aren't any threads parked and clear the hasParkedBit, then if there actually were some threads parked, then they may never be awoken since future calls to unlock() won't take slow path and so won't call unparkOne(). In other words, we need a way to be very precise about when we clear the hasParkedBit and we need to do it in a race-free way: it can't be the case that we clear the bit just as some thread gets parked on the queue. A similar problem arises in futexes, and one of the solutions is to have a thread that acquires a lock after parking sets the hasParkedBit. This is what Rusty Russel's usersem does. It's a subtle algorithm. Also, it means that if a thread barges in before the unparked thread runs, then that barging thread will not know that there are threads parked. This could increase the severity of barging. Since ParkingLot is a user-level API, we don't have to worry about the kernel-user security issues and so we can expose callbacks while ParkingLot is holding its internal locks. This change does exactly that for unparkOne(). The new variant of unparkOne() will call a user function while the queue from which we are unparking is locked. The callback is told basic stats about the queue: did we unpark a thread this time, and could there be more threads to unpark in the future. The callback runs while it's impossible for the queue state to change, since the ParkingLot's internal locks for the queue is held. This means that Lock::unlockSlow() can either clear, or leave, the hasParkedBit while releasing the lock inside the callback from unparkOne(). This takes care of the thundering herd problem while also reducing the greed that arises from barging threads. This required some careful reworking of the ParkingLot algorithm. The first thing I noticed was that the ThreadData::shouldPark flag was useless, since it's set exactly when ThreadData::address is non-null. Then I had to make sure that dequeue() could lazily create both hashtables and buckets, since the "callback is called while queue is locked" invariant requires that we didn't exit early due to the hashtable or bucket not being present. Note that all of this is done in such a way that the old unparkOne() and unparkAll() don't have to create any buckets, though they now may create the hashtable. We don't care as much about the hashtable being created by unpark since it's just such an unlikely scenario and it would only happen once. This change reduces the kernel CPU usage of WTF::Lock for the long critical section test by about 8x and makes it always perform as well as WTF::WordLock and WTF::Mutex for that benchmark. * benchmarks/LockSpeedTest.cpp: * wtf/Lock.cpp: (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::isLocked): (WTF::LockBase::isFullyReset): * wtf/ParkingLot.cpp: (WTF::ParkingLot::parkConditionally): (WTF::ParkingLot::unparkOne): (WTF::ParkingLot::unparkAll): * wtf/ParkingLot.h: * wtf/WordLock.h: (WTF::WordLock::isLocked): (WTF::WordLock::isFullyReset): Tools: Add testing that checks that locks return to a pristine state after contention is over. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::LockInspector::isFullyReset): (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166072@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-13 03:51:25 +00:00
friend struct TestWebKitAPI::LockInspector;
Use constexpr instead of const in symbol definitions that are obviously constexpr. https://bugs.webkit.org/show_bug.cgi?id=201879 Rubber-stamped by Joseph Pecoraro. Source/bmalloc: * bmalloc/AvailableMemory.cpp: * bmalloc/IsoTLS.h: * bmalloc/Map.h: * bmalloc/Mutex.cpp: (bmalloc::Mutex::lockSlowCase): * bmalloc/PerThread.h: * bmalloc/Vector.h: * bmalloc/Zone.h: Source/JavaScriptCore: const may require external storage (at the compiler's whim) though these currently do not. constexpr makes it clear that the value is a literal constant that can be inlined. In most cases in the code, when we say static const, we actually mean static constexpr. I'm changing the code to reflect this. * API/JSAPIValueWrapper.h: * API/JSCallbackConstructor.h: * API/JSCallbackObject.h: * API/JSContextRef.cpp: * API/JSWrapperMap.mm: * API/tests/CompareAndSwapTest.cpp: * API/tests/TypedArrayCTest.cpp: * API/tests/testapi.mm: (testObjectiveCAPIMain): * KeywordLookupGenerator.py: (Trie.printAsC): * assembler/ARMv7Assembler.h: * assembler/AssemblerBuffer.h: * assembler/AssemblerCommon.h: * assembler/MacroAssembler.h: * assembler/MacroAssemblerARM64.h: * assembler/MacroAssemblerARM64E.h: * assembler/MacroAssemblerARMv7.h: * assembler/MacroAssemblerCodeRef.h: * assembler/MacroAssemblerMIPS.h: * assembler/MacroAssemblerX86.h: * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::absDouble): (JSC::MacroAssemblerX86Common::negateDouble): * assembler/MacroAssemblerX86_64.h: * assembler/X86Assembler.h: * b3/B3Bank.h: * b3/B3CheckSpecial.h: * b3/B3DuplicateTails.cpp: * b3/B3EliminateCommonSubexpressions.cpp: * b3/B3FixSSA.cpp: * b3/B3FoldPathConstants.cpp: * b3/B3InferSwitches.cpp: * b3/B3Kind.h: * b3/B3LowerToAir.cpp: * b3/B3NativeTraits.h: * b3/B3ReduceDoubleToFloat.cpp: * b3/B3ReduceLoopStrength.cpp: * b3/B3ReduceStrength.cpp: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirAllocateStackByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirCCallSpecial.h: * b3/air/AirEmitShuffle.cpp: * b3/air/AirFixObviousSpills.cpp: * b3/air/AirFormTable.h: * b3/air/AirLowerAfterRegAlloc.cpp: * b3/air/AirPrintSpecial.h: * b3/air/AirStackAllocation.cpp: * b3/air/AirTmp.h: * b3/testb3_6.cpp: (testInterpreter): * bytecode/AccessCase.cpp: * bytecode/CallLinkStatus.cpp: * bytecode/CallVariant.h: * bytecode/CodeBlock.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/DirectEvalCodeCache.h: * bytecode/ExecutableToCodeBlockEdge.h: * bytecode/GetterSetterAccessCase.cpp: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/ObjectPropertyConditionSet.cpp: * bytecode/PolymorphicAccess.cpp: * bytecode/PropertyCondition.h: * bytecode/SpeculatedType.h: * bytecode/StructureStubInfo.cpp: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::typeProfilerExpressionInfoForBytecodeOffset): * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedEvalCodeBlock.h: * bytecode/UnlinkedFunctionCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.h: * bytecode/UnlinkedModuleProgramCodeBlock.h: * bytecode/UnlinkedProgramCodeBlock.h: * bytecode/ValueProfile.h: * bytecode/VirtualRegister.h: * bytecode/Watchpoint.h: * bytecompiler/BytecodeGenerator.h: * bytecompiler/Label.h: * bytecompiler/NodesCodegen.cpp: (JSC::ThisNode::emitBytecode): * bytecompiler/RegisterID.h: * debugger/Breakpoint.h: * debugger/DebuggerParseData.cpp: * debugger/DebuggerPrimitives.h: * debugger/DebuggerScope.h: * dfg/DFGAbstractHeap.h: * dfg/DFGAbstractValue.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCommon.h: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGEdgeDominates.h: * dfg/DFGEpoch.h: * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledNodesAtNodeIndex): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGHeapLocation.h: * dfg/DFGInPlaceAbstractState.cpp: * dfg/DFGIntegerCheckCombiningPhase.cpp: * dfg/DFGIntegerRangeOptimizationPhase.cpp: * dfg/DFGInvalidationPointInjectionPhase.cpp: * dfg/DFGLICMPhase.cpp: * dfg/DFGLazyNode.h: * dfg/DFGMinifiedID.h: * dfg/DFGMovHintRemovalPhase.cpp: * dfg/DFGNodeFlowProjection.h: * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPhantomInsertionPhase.cpp: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGRegisterBank.h: * dfg/DFGSSAConversionPhase.cpp: * dfg/DFGSSALoweringPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoubleRep): (JSC::DFG::compileClampDoubleToByte): (JSC::DFG::SpeculativeJIT::compileArithRounding): (JSC::DFG::compileArithPowIntegerFastPath): (JSC::DFG::SpeculativeJIT::compileArithPow): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): * dfg/DFGStackLayoutPhase.cpp: * dfg/DFGStoreBarrierInsertionPhase.cpp: * dfg/DFGStrengthReductionPhase.cpp: * dfg/DFGStructureAbstractValue.h: * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVariableEventStream.cpp: (JSC::DFG::VariableEventStream::reconstruct const): * dfg/DFGWatchpointCollectionPhase.cpp: * disassembler/ARM64/A64DOpcode.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArithRandom): * ftl/FTLSlowPathCall.cpp: * ftl/FTLSlowPathCallKey.h: * heap/CellContainer.h: * heap/CellState.h: * heap/ConservativeRoots.h: * heap/GCSegmentedArray.h: * heap/HandleBlock.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/HeapSnapshot.h: * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IncrementalSweeper.cpp: * heap/LargeAllocation.h: * heap/MarkedBlock.cpp: * heap/Strong.h: * heap/VisitRaceKey.h: * heap/Weak.h: * heap/WeakBlock.h: * inspector/JSInjectedScriptHost.h: * inspector/JSInjectedScriptHostPrototype.h: * inspector/JSJavaScriptCallFrame.h: * inspector/JSJavaScriptCallFramePrototype.h: * inspector/agents/InspectorConsoleAgent.cpp: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_versions): * inspector/scripts/tests/generic/expected/version.json-result: * interpreter/Interpreter.h: * interpreter/ShadowChicken.cpp: * jit/BinarySwitch.cpp: * jit/CallFrameShuffler.h: * jit/ExecutableAllocator.h: * jit/FPRInfo.h: * jit/GPRInfo.h: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * jit/TempRegisterSet.h: * jsc.cpp: * parser/ASTBuilder.h: * parser/Nodes.h: * parser/SourceCodeKey.h: * parser/SyntaxChecker.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/AbstractModuleRecord.cpp: * runtime/ArrayBufferNeuteringWatchpointSet.h: * runtime/ArrayConstructor.h: * runtime/ArrayConventions.h: * runtime/ArrayIteratorPrototype.h: * runtime/ArrayPrototype.cpp: (JSC::setLength): * runtime/AsyncFromSyncIteratorPrototype.h: * runtime/AsyncGeneratorFunctionPrototype.h: * runtime/AsyncGeneratorPrototype.h: * runtime/AsyncIteratorPrototype.h: * runtime/AtomicsObject.cpp: * runtime/BigIntConstructor.h: * runtime/BigIntPrototype.h: * runtime/BooleanPrototype.h: * runtime/ClonedArguments.h: * runtime/CodeCache.h: * runtime/ControlFlowProfiler.h: * runtime/CustomGetterSetter.h: * runtime/DateConstructor.h: * runtime/DatePrototype.h: * runtime/DefinePropertyAttributes.h: * runtime/ErrorPrototype.h: * runtime/EvalExecutable.h: * runtime/Exception.h: * runtime/ExceptionHelpers.cpp: (JSC::invalidParameterInSourceAppender): (JSC::invalidParameterInstanceofSourceAppender): * runtime/ExceptionHelpers.h: * runtime/ExecutableBase.h: * runtime/FunctionExecutable.h: * runtime/FunctionRareData.h: * runtime/GeneratorPrototype.h: * runtime/GenericArguments.h: * runtime/GenericOffset.h: * runtime/GetPutInfo.h: * runtime/GetterSetter.h: * runtime/GlobalExecutable.h: * runtime/Identifier.h: * runtime/InspectorInstrumentationObject.h: * runtime/InternalFunction.h: * runtime/IntlCollatorConstructor.h: * runtime/IntlCollatorPrototype.h: * runtime/IntlDateTimeFormatConstructor.h: * runtime/IntlDateTimeFormatPrototype.h: * runtime/IntlNumberFormatConstructor.h: * runtime/IntlNumberFormatPrototype.h: * runtime/IntlObject.h: * runtime/IntlPluralRulesConstructor.h: * runtime/IntlPluralRulesPrototype.h: * runtime/IteratorPrototype.h: * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): * runtime/JSArray.h: * runtime/JSArrayBuffer.h: * runtime/JSArrayBufferView.h: * runtime/JSBigInt.h: * runtime/JSCJSValue.h: * runtime/JSCell.h: * runtime/JSCustomGetterSetterFunction.h: * runtime/JSDataView.h: * runtime/JSDataViewPrototype.h: * runtime/JSDestructibleObject.h: * runtime/JSFixedArray.h: * runtime/JSGenericTypedArrayView.h: * runtime/JSGlobalLexicalEnvironment.h: * runtime/JSGlobalObject.h: * runtime/JSImmutableButterfly.h: * runtime/JSInternalPromiseConstructor.h: * runtime/JSInternalPromiseDeferred.h: * runtime/JSInternalPromisePrototype.h: * runtime/JSLexicalEnvironment.h: * runtime/JSModuleEnvironment.h: * runtime/JSModuleLoader.h: * runtime/JSModuleNamespaceObject.h: * runtime/JSNonDestructibleProxy.h: * runtime/JSONObject.cpp: * runtime/JSONObject.h: * runtime/JSObject.h: * runtime/JSPromiseConstructor.h: * runtime/JSPromiseDeferred.h: * runtime/JSPromisePrototype.h: * runtime/JSPropertyNameEnumerator.h: * runtime/JSProxy.h: * runtime/JSScope.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/JSSegmentedVariableObject.h: * runtime/JSSourceCode.h: * runtime/JSString.cpp: * runtime/JSString.h: * runtime/JSSymbolTableObject.h: * runtime/JSTemplateObjectDescriptor.h: * runtime/JSTypeInfo.h: * runtime/MapPrototype.h: * runtime/MinimumReservedZoneSize.h: * runtime/ModuleProgramExecutable.h: * runtime/NativeExecutable.h: * runtime/NativeFunction.h: * runtime/NativeStdFunctionCell.h: * runtime/NumberConstructor.h: * runtime/NumberPrototype.h: * runtime/ObjectConstructor.h: * runtime/ObjectPrototype.h: * runtime/ProgramExecutable.h: * runtime/PromiseDeferredTimer.cpp: * runtime/PropertyMapHashTable.h: * runtime/PropertyNameArray.h: (JSC::PropertyNameArray::add): * runtime/PrototypeKey.h: * runtime/ProxyConstructor.h: * runtime/ProxyObject.cpp: (JSC::ProxyObject::performGetOwnPropertyNames): * runtime/ProxyRevoke.h: * runtime/ReflectObject.h: * runtime/RegExp.h: * runtime/RegExpCache.h: * runtime/RegExpConstructor.h: * runtime/RegExpKey.h: * runtime/RegExpObject.h: * runtime/RegExpPrototype.h: * runtime/RegExpStringIteratorPrototype.h: * runtime/SamplingProfiler.cpp: * runtime/ScopedArgumentsTable.h: * runtime/ScriptExecutable.h: * runtime/SetPrototype.h: * runtime/SmallStrings.h: * runtime/SparseArrayValueMap.h: * runtime/StringConstructor.h: * runtime/StringIteratorPrototype.h: * runtime/StringObject.h: * runtime/StringPrototype.h: * runtime/Structure.h: * runtime/StructureChain.h: * runtime/StructureRareData.h: * runtime/StructureTransitionTable.h: * runtime/Symbol.h: * runtime/SymbolConstructor.h: * runtime/SymbolPrototype.h: * runtime/SymbolTable.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.cpp: * runtime/TypeProfiler.h: * runtime/TypeProfilerLog.cpp: * runtime/VarOffset.h: * testRegExp.cpp: * tools/HeapVerifier.cpp: (JSC::HeapVerifier::checkIfRecorded): * tools/JSDollarVM.cpp: * wasm/WasmB3IRGenerator.cpp: * wasm/WasmBBQPlan.cpp: * wasm/WasmFaultSignalHandler.cpp: * wasm/WasmFunctionParser.h: * wasm/WasmOMGForOSREntryPlan.cpp: * wasm/WasmOMGPlan.cpp: * wasm/WasmPlan.cpp: * wasm/WasmSignature.cpp: * wasm/WasmSignature.h: * wasm/WasmWorklist.cpp: * wasm/js/JSWebAssembly.h: * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/WebAssemblyCompileErrorConstructor.h: * wasm/js/WebAssemblyCompileErrorPrototype.h: * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyInstanceConstructor.h: * wasm/js/WebAssemblyInstancePrototype.h: * wasm/js/WebAssemblyLinkErrorConstructor.h: * wasm/js/WebAssemblyLinkErrorPrototype.h: * wasm/js/WebAssemblyMemoryConstructor.h: * wasm/js/WebAssemblyMemoryPrototype.h: * wasm/js/WebAssemblyModuleConstructor.h: * wasm/js/WebAssemblyModulePrototype.h: * wasm/js/WebAssemblyRuntimeErrorConstructor.h: * wasm/js/WebAssemblyRuntimeErrorPrototype.h: * wasm/js/WebAssemblyTableConstructor.h: * wasm/js/WebAssemblyTablePrototype.h: * wasm/js/WebAssemblyToJSCallee.h: * yarr/Yarr.h: * yarr/YarrParser.h: * yarr/generateYarrCanonicalizeUnicode: Source/WebCore: No new tests. Covered by existing tests. * bindings/js/JSDOMConstructorBase.h: * bindings/js/JSDOMWindowProperties.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GeneratePrototypeDeclaration): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: * bindings/scripts/test/JS/JSTestEnabledBySetting.h: * bindings/scripts/test/JS/JSTestEnabledForContext.h: * bindings/scripts/test/JS/JSTestEventTarget.h: * bindings/scripts/test/JS/JSTestGlobalObject.h: * bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedGetterCallWith.h: * bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestObj.h: * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestPluginInterface.h: * bindings/scripts/test/JS/JSTestTypedefs.h: * bridge/objc/objc_runtime.h: * bridge/runtime_array.h: * bridge/runtime_method.h: * bridge/runtime_object.h: Source/WebKit: * WebProcess/Plugins/Netscape/JSNPObject.h: Source/WTF: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Brigand.h: * wtf/CheckedArithmetic.h: * wtf/CrossThreadCopier.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DateMath.cpp: (WTF::daysFrom1970ToYear): * wtf/DeferrableRefCounted.h: * wtf/GetPtr.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashTable.h: * wtf/HashTraits.h: * wtf/JSONValues.cpp: * wtf/JSONValues.h: * wtf/ListHashSet.h: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockAlgorithmInlines.h: (WTF::Hooks>::lockSlow): * wtf/Logger.h: * wtf/LoggerHelper.h: (WTF::LoggerHelper::childLogIdentifier const): * wtf/MainThread.cpp: * wtf/MetaAllocatorPtr.h: * wtf/MonotonicTime.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::NaturalLoops): * wtf/ObjectIdentifier.h: * wtf/RAMSize.cpp: * wtf/Ref.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/SchedulePair.h: * wtf/StackShot.h: * wtf/StdLibExtras.h: * wtf/TinyPtrSet.h: * wtf/URL.cpp: * wtf/URLHash.h: * wtf/URLParser.cpp: (WTF::URLParser::defaultPortForProtocol): * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.h: * wtf/WeakHashSet.h: * wtf/WordLock.h: * wtf/cocoa/CPUTimeCocoa.cpp: * wtf/cocoa/MemoryPressureHandlerCocoa.mm: * wtf/persistence/PersistentDecoder.h: * wtf/persistence/PersistentEncoder.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringBuilder.cpp: (WTF::expandedCapacity): * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/StringToIntegerConversion.h: (WTF::toIntegralType): * wtf/text/SymbolRegistry.h: * wtf/text/TextStream.cpp: (WTF::hasFractions): * wtf/text/WTFString.h: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: Canonical link: https://commits.webkit.org/215538@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 00:36:19 +00:00
static constexpr uintptr_t isLockedBit = 1;
static constexpr uintptr_t isQueueLockedBit = 2;
static constexpr uintptr_t queueHeadMask = 3;
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
WTF_EXPORT_PRIVATE void lockSlow();
WTF_EXPORT_PRIVATE void unlockSlow();
WTF::Lock should not suffer from the thundering herd https://bugs.webkit.org/show_bug.cgi?id=147947 Reviewed by Geoffrey Garen. Source/WTF: This changes Lock::unlockSlow() to use unparkOne() instead of unparkAll(). The problem with doing this is that it's not obvious after calling unparkOne() if there are any other threads that are still parked on the lock's queue. If we assume that there are and leave the hasParkedBit set, then future calls to unlock() will take the slow path. We don't want that if there aren't actually any threads parked. On the other hand, if we assume that there aren't any threads parked and clear the hasParkedBit, then if there actually were some threads parked, then they may never be awoken since future calls to unlock() won't take slow path and so won't call unparkOne(). In other words, we need a way to be very precise about when we clear the hasParkedBit and we need to do it in a race-free way: it can't be the case that we clear the bit just as some thread gets parked on the queue. A similar problem arises in futexes, and one of the solutions is to have a thread that acquires a lock after parking sets the hasParkedBit. This is what Rusty Russel's usersem does. It's a subtle algorithm. Also, it means that if a thread barges in before the unparked thread runs, then that barging thread will not know that there are threads parked. This could increase the severity of barging. Since ParkingLot is a user-level API, we don't have to worry about the kernel-user security issues and so we can expose callbacks while ParkingLot is holding its internal locks. This change does exactly that for unparkOne(). The new variant of unparkOne() will call a user function while the queue from which we are unparking is locked. The callback is told basic stats about the queue: did we unpark a thread this time, and could there be more threads to unpark in the future. The callback runs while it's impossible for the queue state to change, since the ParkingLot's internal locks for the queue is held. This means that Lock::unlockSlow() can either clear, or leave, the hasParkedBit while releasing the lock inside the callback from unparkOne(). This takes care of the thundering herd problem while also reducing the greed that arises from barging threads. This required some careful reworking of the ParkingLot algorithm. The first thing I noticed was that the ThreadData::shouldPark flag was useless, since it's set exactly when ThreadData::address is non-null. Then I had to make sure that dequeue() could lazily create both hashtables and buckets, since the "callback is called while queue is locked" invariant requires that we didn't exit early due to the hashtable or bucket not being present. Note that all of this is done in such a way that the old unparkOne() and unparkAll() don't have to create any buckets, though they now may create the hashtable. We don't care as much about the hashtable being created by unpark since it's just such an unlikely scenario and it would only happen once. This change reduces the kernel CPU usage of WTF::Lock for the long critical section test by about 8x and makes it always perform as well as WTF::WordLock and WTF::Mutex for that benchmark. * benchmarks/LockSpeedTest.cpp: * wtf/Lock.cpp: (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::isLocked): (WTF::LockBase::isFullyReset): * wtf/ParkingLot.cpp: (WTF::ParkingLot::parkConditionally): (WTF::ParkingLot::unparkOne): (WTF::ParkingLot::unparkAll): * wtf/ParkingLot.h: * wtf/WordLock.h: (WTF::WordLock::isLocked): (WTF::WordLock::isFullyReset): Tools: Add testing that checks that locks return to a pristine state after contention is over. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::LockInspector::isFullyReset): (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166072@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-13 03:51:25 +00:00
// Method used for testing only.
bool isFullyReset() const
{
return !m_word.load();
}
[WTF] Remove XXXLockBase since constexpr constructor can initialize static variables without calling global constructors https://bugs.webkit.org/show_bug.cgi?id=180495 Reviewed by Mark Lam. Very nice feature of C++11 is that constexpr constructor can initialize static global variables without calling global constructors. We do not need to have XXXLockBase with derived XXXLock class since StaticXXXLock can have constructors as long as it is constexpr. We remove bunch of these classes, and set `XXXLock() = default;` explicitly for readability. C++11's default constructor is constexpr as long as its member's default constructor / default initializer is constexpr. * wtf/Condition.h: (WTF::ConditionBase::construct): Deleted. (WTF::ConditionBase::waitUntil): Deleted. (WTF::ConditionBase::waitFor): Deleted. (WTF::ConditionBase::wait): Deleted. (WTF::ConditionBase::notifyOne): Deleted. (WTF::ConditionBase::notifyAll): Deleted. (WTF::Condition::Condition): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::CountingLock): Deleted. (WTF::CountingLock::~CountingLock): Deleted. * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): (WTF::Lock::safepointSlow): (WTF::LockBase::lockSlow): Deleted. (WTF::LockBase::unlockSlow): Deleted. (WTF::LockBase::unlockFairlySlow): Deleted. (WTF::LockBase::safepointSlow): Deleted. * wtf/Lock.h: (WTF::LockBase::construct): Deleted. (WTF::LockBase::lock): Deleted. (WTF::LockBase::tryLock): Deleted. (WTF::LockBase::try_lock): Deleted. (WTF::LockBase::unlock): Deleted. (WTF::LockBase::unlockFairly): Deleted. (WTF::LockBase::safepoint): Deleted. (WTF::LockBase::isHeld const): Deleted. (WTF::LockBase::isLocked const): Deleted. (WTF::LockBase::isFullyReset const): Deleted. (WTF::Lock::Lock): Deleted. * wtf/ReadWriteLock.cpp: (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::readUnlock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::writeUnlock): (WTF::ReadWriteLockBase::construct): Deleted. (WTF::ReadWriteLockBase::readLock): Deleted. (WTF::ReadWriteLockBase::readUnlock): Deleted. (WTF::ReadWriteLockBase::writeLock): Deleted. (WTF::ReadWriteLockBase::writeUnlock): Deleted. * wtf/ReadWriteLock.h: (WTF::ReadWriteLock::read): (WTF::ReadWriteLock::write): (WTF::ReadWriteLockBase::ReadLock::tryLock): Deleted. (WTF::ReadWriteLockBase::ReadLock::lock): Deleted. (WTF::ReadWriteLockBase::ReadLock::unlock): Deleted. (WTF::ReadWriteLockBase::WriteLock::tryLock): Deleted. (WTF::ReadWriteLockBase::WriteLock::lock): Deleted. (WTF::ReadWriteLockBase::WriteLock::unlock): Deleted. (WTF::ReadWriteLockBase::read): Deleted. (WTF::ReadWriteLockBase::write): Deleted. (WTF::ReadWriteLock::ReadWriteLock): Deleted. * wtf/RecursiveLockAdapter.h: (WTF::RecursiveLockAdapter::RecursiveLockAdapter): Deleted. * wtf/WordLock.cpp: (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): (WTF::WordLockBase::lockSlow): Deleted. (WTF::WordLockBase::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): Deleted. (WTF::WordLockBase::unlock): Deleted. (WTF::WordLockBase::isHeld const): Deleted. (WTF::WordLockBase::isLocked const): Deleted. (WTF::WordLockBase::isFullyReset const): Deleted. (WTF::WordLock::WordLock): Deleted. * wtf/WorkQueue.cpp: Canonical link: https://commits.webkit.org/196438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-07 03:52:09 +00:00
Atomic<uintptr_t> m_word { 0 };
Silence leaks in ParkingLot https://bugs.webkit.org/show_bug.cgi?id=155510 Reviewed by Alexey Proskuryakov. ParkingLot has a concurrent hashtable that it reallocates on demand. It will not reallocate it in steady state. The hashtable is sized to accommodate the high watermark of the number of active threads - so long as the program doesn't just keep starting an unbounded number of threads that are all active, the hashtable will stop resizing. Each resize operation is designed to stay out of the way of the data-access-parallel normal path, in which two threads operating on different lock addresses don't have to synchronize. To do this, it simply drops the old hashtable without deleting it, so that threads that were still using it don't crash. They will realize that they have the wrong hashtable before doing anything bad, but we don't have a way of proving when all of those threads are no longer going to read from the old hashtables. So, we just leak them. This is a bounded leak, since the hashtable resizes exponentially. Thus the total memory utilization of all hashtables, including the leaked ones, converges to a linear function of the current hashtable's size (it's 2 * size of current hashtable). But this leak is a problem for leaks tools, which will always report this leak. This is not useful. It's better to silence the leak. That's what this patch does by ensuring that all hashtables, including leaked ones, end up in a global vector. This is perf-neutral. This requires making a StaticWordLock variant of WordLock. That's probably the biggest part of this change. * wtf/ParkingLot.cpp: * wtf/WordLock.cpp: (WTF::WordLockBase::lockSlow): (WTF::WordLockBase::unlockSlow): (WTF::WordLock::lockSlow): Deleted. (WTF::WordLock::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): (WTF::WordLockBase::isLocked): (WTF::WordLock::WordLock): (WTF::WordLock::lock): Deleted. (WTF::WordLock::isLocked): Deleted. Canonical link: https://commits.webkit.org/173707@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-17 18:54:15 +00:00
};
[WTF] Remove XXXLockBase since constexpr constructor can initialize static variables without calling global constructors https://bugs.webkit.org/show_bug.cgi?id=180495 Reviewed by Mark Lam. Very nice feature of C++11 is that constexpr constructor can initialize static global variables without calling global constructors. We do not need to have XXXLockBase with derived XXXLock class since StaticXXXLock can have constructors as long as it is constexpr. We remove bunch of these classes, and set `XXXLock() = default;` explicitly for readability. C++11's default constructor is constexpr as long as its member's default constructor / default initializer is constexpr. * wtf/Condition.h: (WTF::ConditionBase::construct): Deleted. (WTF::ConditionBase::waitUntil): Deleted. (WTF::ConditionBase::waitFor): Deleted. (WTF::ConditionBase::wait): Deleted. (WTF::ConditionBase::notifyOne): Deleted. (WTF::ConditionBase::notifyAll): Deleted. (WTF::Condition::Condition): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::CountingLock): Deleted. (WTF::CountingLock::~CountingLock): Deleted. * wtf/Lock.cpp: (WTF::Lock::lockSlow): (WTF::Lock::unlockSlow): (WTF::Lock::unlockFairlySlow): (WTF::Lock::safepointSlow): (WTF::LockBase::lockSlow): Deleted. (WTF::LockBase::unlockSlow): Deleted. (WTF::LockBase::unlockFairlySlow): Deleted. (WTF::LockBase::safepointSlow): Deleted. * wtf/Lock.h: (WTF::LockBase::construct): Deleted. (WTF::LockBase::lock): Deleted. (WTF::LockBase::tryLock): Deleted. (WTF::LockBase::try_lock): Deleted. (WTF::LockBase::unlock): Deleted. (WTF::LockBase::unlockFairly): Deleted. (WTF::LockBase::safepoint): Deleted. (WTF::LockBase::isHeld const): Deleted. (WTF::LockBase::isLocked const): Deleted. (WTF::LockBase::isFullyReset const): Deleted. (WTF::Lock::Lock): Deleted. * wtf/ReadWriteLock.cpp: (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::readUnlock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::writeUnlock): (WTF::ReadWriteLockBase::construct): Deleted. (WTF::ReadWriteLockBase::readLock): Deleted. (WTF::ReadWriteLockBase::readUnlock): Deleted. (WTF::ReadWriteLockBase::writeLock): Deleted. (WTF::ReadWriteLockBase::writeUnlock): Deleted. * wtf/ReadWriteLock.h: (WTF::ReadWriteLock::read): (WTF::ReadWriteLock::write): (WTF::ReadWriteLockBase::ReadLock::tryLock): Deleted. (WTF::ReadWriteLockBase::ReadLock::lock): Deleted. (WTF::ReadWriteLockBase::ReadLock::unlock): Deleted. (WTF::ReadWriteLockBase::WriteLock::tryLock): Deleted. (WTF::ReadWriteLockBase::WriteLock::lock): Deleted. (WTF::ReadWriteLockBase::WriteLock::unlock): Deleted. (WTF::ReadWriteLockBase::read): Deleted. (WTF::ReadWriteLockBase::write): Deleted. (WTF::ReadWriteLock::ReadWriteLock): Deleted. * wtf/RecursiveLockAdapter.h: (WTF::RecursiveLockAdapter::RecursiveLockAdapter): Deleted. * wtf/WordLock.cpp: (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): (WTF::WordLockBase::lockSlow): Deleted. (WTF::WordLockBase::unlockSlow): Deleted. * wtf/WordLock.h: (WTF::WordLockBase::lock): Deleted. (WTF::WordLockBase::unlock): Deleted. (WTF::WordLockBase::isHeld const): Deleted. (WTF::WordLockBase::isLocked const): Deleted. (WTF::WordLockBase::isFullyReset const): Deleted. (WTF::WordLock::WordLock): Deleted. * wtf/WorkQueue.cpp: Canonical link: https://commits.webkit.org/196438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225617 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-07 03:52:09 +00:00
using WordLockHolder = Locker<WordLock>;
Always use a byte-sized lock implementation https://bugs.webkit.org/show_bug.cgi?id=147908 Reviewed by Geoffrey Garen. Source/JavaScriptCore: * runtime/ConcurrentJITLock.h: Lock is now byte-sized and ByteLock is gone, so use Lock. Source/WTF: At the start of my locking algorithm crusade, I implemented Lock, which is a sizeof(void*) lock implementation with some nice theoretical properties and good performance. Then I added the ParkingLot abstraction and ByteLock. ParkingLot uses Lock in its implementation. ByteLock uses ParkingLot to create a sizeof(char) lock implementation that performs like Lock. It turns out that ByteLock is always at least as good as Lock, and sometimes a lot better: it requires 8x less memory on 64-bit systems. It's hard to construct a benchmark where ByteLock is significantly slower than Lock, and when you do construct such a benchmark, tweaking it a bit can also create a scenario where ByteLock is significantly faster than Lock. So, the thing that we call "Lock" should really use ByteLock's algorithm, since it is more compact and just as fast. That's what this patch does. But we still need to keep the old Lock algorithm, because it's used to implement ParkingLot, which in turn is used to implement ByteLock. So this patch does this transformation: - Move the algorithm in Lock into files called WordLock.h|cpp. Make ParkingLot use WordLock. - Move the algorithm in ByteLock into Lock.h|cpp. Make everyone who used ByteLock use Lock instead. All other users of Lock now get the byte-sized lock implementation. - Remove the old ByteLock files. * WTF.vcxproj/WTF.vcxproj: * WTF.xcodeproj/project.pbxproj: * benchmarks/LockSpeedTest.cpp: (main): * wtf/WordLock.cpp: Added. (WTF::WordLock::lockSlow): (WTF::WordLock::unlockSlow): * wtf/WordLock.h: Added. (WTF::WordLock::WordLock): (WTF::WordLock::lock): (WTF::WordLock::unlock): (WTF::WordLock::isHeld): (WTF::WordLock::isLocked): * wtf/ByteLock.cpp: Removed. * wtf/ByteLock.h: Removed. * wtf/CMakeLists.txt: * wtf/Lock.cpp: (WTF::LockBase::lockSlow): (WTF::LockBase::unlockSlow): * wtf/Lock.h: (WTF::LockBase::lock): (WTF::LockBase::unlock): (WTF::LockBase::isHeld): (WTF::LockBase::isLocked): (WTF::Lock::Lock): * wtf/ParkingLot.cpp: Tools: All previous tests of Lock are now tests of WordLock. All previous tests of ByteLock are now tests of Lock. * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::runLockTest): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/166025@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-08-12 04:20:24 +00:00
} // namespace WTF
using WTF::WordLock;
using WTF::WordLockHolder;