haikuwebkit/Source/WTF/wtf/ReadWriteLock.h

91 lines
3.2 KiB
C
Raw Permalink Normal View History

REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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.
*/
#pragma once
Drop CheckedLock / CheckedCondition aliases https://bugs.webkit.org/show_bug.cgi?id=226176 Reviewed by Kate Cheney. Drop CheckedLock / CheckedCondition aliases now that they are the default. Source/JavaScriptCore: * API/JSVirtualMachine.mm: * API/glib/JSCVirtualMachine.cpp: * assembler/PerfLog.h: * assembler/testmasm.cpp: * bytecode/StructureStubInfo.h: * bytecode/SuperSampler.cpp: * dfg/DFGCommon.cpp: * dfg/DFGCommonData.cpp: * dfg/DFGPlan.h: * dfg/DFGThreadData.h: * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::Worklist): * dfg/DFGWorklist.h: * disassembler/Disassembler.cpp: * dynbench.cpp: * heap/BlockDirectory.cpp: (JSC::BlockDirectory::parallelNotEmptyBlockSource): * heap/BlockDirectory.h: (JSC::BlockDirectory::bitvectorLock): * heap/CodeBlockSet.h: (JSC::CodeBlockSet::getLock): * heap/Heap.cpp: (JSC::Heap::Heap): * heap/Heap.h: * heap/IsoSubspacePerVM.h: * heap/MarkedSpace.h: (JSC::MarkedSpace::directoryLock): * heap/MarkingConstraintSolver.h: * heap/SlotVisitor.cpp: (JSC::SlotVisitor::donateKnownParallel): * heap/SlotVisitor.h: * inspector/remote/socket/RemoteInspectorConnectionClient.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::getLock const): (JSC::dumpJITMemory): * jit/ExecutableAllocator.h: (JSC::ExecutableAllocatorBase::getLock const): * jit/JITWorklist.cpp: (JSC::JITWorklist::JITWorklist): * jit/JITWorklist.h: * jsc.cpp: * profiler/ProfilerDatabase.h: * runtime/ConcurrentJSLock.h: * runtime/DeferredWorkTimer.h: * runtime/JSLock.h: * runtime/SamplingProfiler.cpp: (JSC::FrameWalker::FrameWalker): (JSC::CFrameWalker::CFrameWalker): (JSC::SamplingProfiler::takeSample): * runtime/SamplingProfiler.h: (JSC::SamplingProfiler::getLock): * runtime/VM.h: * runtime/VMTraps.cpp: (JSC::VMTraps::invalidateCodeBlocksOnStack): (JSC::VMTraps::VMTraps): * runtime/VMTraps.h: * tools/FunctionOverrides.h: * tools/VMInspector.cpp: (JSC::ensureIsSafeToLock): * tools/VMInspector.h: (JSC::VMInspector::getLock): * wasm/WasmCalleeRegistry.h: (JSC::Wasm::CalleeRegistry::getLock): * wasm/WasmPlan.h: * wasm/WasmStreamingCompiler.h: * wasm/WasmThunks.h: * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::Worklist): * wasm/WasmWorklist.h: Source/WebCore: * Modules/indexeddb/IDBObjectStore.h: * Modules/indexeddb/IDBTransaction.h: * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBSerializationContext.cpp: * Modules/indexeddb/server/IDBServer.cpp: * Modules/mediastream/RTCDataChannel.cpp: * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransform.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.h: * Modules/speech/SpeechRecognitionCaptureSourceImpl.h: * Modules/webaudio/AudioParamTimeline.h: * Modules/webaudio/MediaElementAudioSourceNode.h: * Modules/webdatabase/Database.cpp: * Modules/webdatabase/Database.h: * Modules/webdatabase/DatabaseManager.h: * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.h: * Modules/webdatabase/DatabaseTracker.cpp: (WebCore::DatabaseTracker::openDatabaseMutex): * Modules/webdatabase/DatabaseTracker.h: * Modules/webdatabase/OriginLock.cpp: * Modules/webdatabase/SQLCallbackWrapper.h: * Modules/webdatabase/SQLTransaction.h: * Modules/webgpu/WebGPUDevice.cpp: (WebCore::WebGPUDevice::instancesLock): * Modules/webgpu/WebGPUDevice.h: * Modules/webgpu/WebGPUPipeline.cpp: (WebCore::WebGPUPipeline::instancesLock): * Modules/webgpu/WebGPUPipeline.h: * Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::allActiveWebSocketsLock): * Modules/websockets/WebSocket.h: * accessibility/isolatedtree/AXIsolatedTree.cpp: * accessibility/isolatedtree/AXIsolatedTree.h: * bindings/js/JSDOMGlobalObject.h: * bridge/objc/WebScriptObject.mm: * crypto/CryptoAlgorithmRegistry.h: * dom/MessagePort.cpp: * dom/Node.cpp: * dom/ScriptExecutionContext.cpp: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::createMediaPlayer): * html/canvas/CanvasRenderingContext.cpp: (WebCore::CanvasRenderingContext::instancesLock): * html/canvas/CanvasRenderingContext.h: * html/canvas/WebGLContextGroup.cpp: (WebCore::WebGLContextGroup::objectGraphLockForAContext): * html/canvas/WebGLContextGroup.h: * html/canvas/WebGLContextObject.cpp: (WebCore::WebGLContextObject::objectGraphLockForContext): * html/canvas/WebGLContextObject.h: * html/canvas/WebGLObject.h: * html/canvas/WebGLProgram.cpp: (WebCore::WebGLProgram::instancesLock): * html/canvas/WebGLProgram.h: * html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::objectGraphLock): * html/canvas/WebGLRenderingContextBase.h: * html/canvas/WebGLSharedObject.cpp: (WebCore::WebGLSharedObject::objectGraphLockForContext): * html/canvas/WebGLSharedObject.h: * inspector/agents/WebHeapAgent.cpp: * page/ResourceUsageThread.h: * page/SecurityPolicy.cpp: * page/WheelEventTestMonitor.h: * page/scrolling/ScrollingTree.h: (WebCore::ScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/ScrollingTreeLatchingController.h: * page/scrolling/ThreadedScrollingTree.h: (WebCore::ThreadedScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/mac/ScrollingTreeMac.h: * platform/AbortableTaskQueue.h: * platform/GenericTaskQueue.cpp: * platform/GenericTaskQueue.h: * platform/LegacySchemeRegistry.cpp: * platform/audio/AudioDestination.h: * platform/audio/HRTFDatabaseLoader.h: * platform/audio/ReverbConvolver.cpp: (WebCore::ReverbConvolver::backgroundThreadEntry): * platform/audio/cocoa/AudioDestinationCocoa.h: * platform/audio/gstreamer/AudioSourceProviderGStreamer.h: * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp: * platform/audio/mac/FFTFrameMac.cpp: * platform/encryptedmedia/CDMProxy.h: * platform/graphics/MediaPlayer.cpp: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::lock): (WebCore::ShadowBlur::drawRectShadowWithTiling): (WebCore::ShadowBlur::drawInsetShadowWithTiling): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: * platform/graphics/cg/IOSurfacePool.h: * platform/graphics/cg/SubimageCacheWithTimer.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/ImageDecoderGStreamer.h: * platform/graphics/gstreamer/MainThreadNotifier.h: * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: * platform/graphics/gstreamer/VideoSinkGStreamer.cpp: * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp: * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: (WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK): * platform/image-decoders/ScalableImageDecoder.h: * platform/ios/QuickLook.mm: * platform/ios/WebSQLiteDatabaseTrackerClient.mm: * platform/ios/wak/WebCoreThreadRun.cpp: * platform/mediarecorder/MediaRecorderPrivateMock.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediastream/RealtimeMediaSource.h: * platform/mediastream/RealtimeOutgoingAudioSource.h: * platform/mediastream/RealtimeOutgoingVideoSource.h: * platform/mediastream/cocoa/AudioMediaStreamTrackRendererUnit.h: * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h: * platform/network/cf/LoaderRunLoopCF.cpp: (WebCore::loaderRunLoop): * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/network/mac/UTIUtilities.mm: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteDatabaseTracker.cpp: * platform/text/TextEncodingRegistry.cpp: * storage/StorageQuotaManager.h: * workers/WorkerGlobalScope.cpp: * workers/WorkerOrWorkletScriptController.h: * workers/WorkerOrWorkletThread.cpp: (WebCore::WorkerOrWorkletThread::workerOrWorkletThreadsLock): * workers/WorkerOrWorkletThread.h: * worklets/PaintWorkletGlobalScope.h: Source/WebKit: * GPUProcess/graphics/RemoteGraphicsContextGL.cpp: (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer): * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h: * NetworkProcess/IndexedDB/WebIDBServer.cpp: * NetworkProcess/NetworkProcess.h: * NetworkProcess/WebStorage/StorageManagerSet.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: * NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h: * NetworkProcess/glib/DNSCache.h: * Platform/IPC/Connection.cpp: * Platform/IPC/Connection.h: * Platform/IPC/StreamConnectionWorkQueue.h: * Platform/IPC/StreamServerConnection.h: * Shared/BlockingResponseMap.h: * Shared/Cocoa/XPCEndpointClient.h: * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h: * Shared/mac/MediaFormatReader/MediaFormatReader.h: * Shared/mac/MediaFormatReader/MediaSampleCursor.h: * Shared/mac/MediaFormatReader/MediaTrackReader.h: * UIProcess/API/glib/IconDatabase.h: * UIProcess/WebURLSchemeTask.h: * UIProcess/mac/DisplayLink.h: * UIProcess/mac/WKPrintingView.mm: (-[WKPrintingView knowsPageRange:]): * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: * WebProcess/GPU/webrtc/LibWebRTCCodecs.h: * WebProcess/Network/WebSocketStream.cpp: * WebProcess/Plugins/PluginProcessConnectionManager.h: * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebPage/ViewUpdateDispatcher.h: Source/WebKitLegacy: * Storage/StorageAreaSync.h: Source/WebKitLegacy/mac: * DOM/DOMInternal.mm: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: (WTF::AutomaticThreadCondition::wait): (WTF::AutomaticThreadCondition::waitFor): (WTF::AutomaticThread::AutomaticThread): * wtf/AutomaticThread.h: * wtf/CMakeLists.txt: * wtf/CheckedCondition.h: Removed. * wtf/CheckedLock.h: Removed. * wtf/Condition.h: * wtf/CrossThreadQueue.h: * wtf/CrossThreadTaskHandler.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/FastMalloc.cpp: * wtf/Forward.h: * wtf/Language.cpp: * wtf/Lock.cpp: (WTF::UncheckedLock::lockSlow): (WTF::UncheckedLock::unlockSlow): (WTF::UncheckedLock::unlockFairlySlow): (WTF::UncheckedLock::safepointSlow): * wtf/Lock.h: (WTF::WTF_ASSERTS_ACQUIRED_LOCK): * wtf/Logger.cpp: * wtf/Logger.h: (WTF::Logger::WTF_RETURNS_LOCK): * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocator::MetaAllocator): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/MetaAllocator.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: (WTF::ParallelHelperPool::ParallelHelperPool): * wtf/ParallelHelperPool.h: * wtf/ParallelJobsGeneric.h: * wtf/ParallelVectorIterator.h: * wtf/ReadWriteLock.h: * wtf/RecursiveLockAdapter.h: * wtf/RunLoop.h: * wtf/SynchronizedFixedQueue.h: * wtf/Threading.cpp: (WTF::Thread::allThreadsLock): * wtf/Threading.h: * wtf/TimingScope.cpp: * wtf/URL.cpp: * wtf/WTFSemaphore.h: * wtf/WorkQueue.cpp: (WTF::WorkQueue::concurrentApply): * wtf/WorkerPool.cpp: (WTF::WorkerPool::WorkerPool): * wtf/WorkerPool.h: * wtf/cf/LanguageCF.cpp: * wtf/text/AtomStringImpl.cpp: (WTF::AtomStringTableLocker::AtomStringTableLocker): * wtf/text/StringView.cpp: * wtf/threads/BinarySemaphore.h: * wtf/unicode/icu/CollatorICU.cpp: Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/CheckedConditionTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/CheckedLockTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/Condition.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp: (WTR::AXThread::createThreadIfNeeded): Canonical link: https://commits.webkit.org/238085@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 18:29:01 +00:00
#include <wtf/Condition.h>
#include <wtf/Lock.h>
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
namespace WTF {
// This is a traditional read-write lock implementation that enables concurrency between readers so long as
// the read critical section is long. Concurrent readers will experience contention on read().lock() and
// read().unlock() if the work inside the critical section is short. The more cores participate in reading,
// the longer the read critical section has to be for this locking scheme to be profitable.
[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
class ReadWriteLock {
WTF_MAKE_NONCOPYABLE(ReadWriteLock);
WTF_MAKE_FAST_ALLOCATED;
public:
ReadWriteLock() = default;
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
// It's easiest to read lock like this:
//
Stop using holdLock() in WTF as it is not compatible with Clang thread safety analysis https://bugs.webkit.org/show_bug.cgi?id=226117 Reviewed by Darin Adler. Stop using holdLock() in WTF as it is not compatible with Clang thread safety analysis (WTF::CheckedLock) and use the Locker constructor instead. This is a step towards getting rid of holdLock() completely. * benchmarks/ConditionSpeedTest.cpp: * wtf/ConcurrentPtrHashSet.cpp: (WTF::ConcurrentPtrHashSet::deleteOldTables): (WTF::ConcurrentPtrHashSet::clear): (WTF::ConcurrentPtrHashSet::containsImplSlow const): (WTF::ConcurrentPtrHashSet::sizeSlow const): (WTF::ConcurrentPtrHashSet::resizeIfNecessary): * wtf/CountingLock.h: * wtf/HashTable.cpp: (WTF::HashTableStats::recordCollisionAtCount): (WTF::HashTableStats::dumpStats): * wtf/HashTable.h: (WTF::invalidateIterators): (WTF::addIterator): (WTF::removeIterator): * wtf/LockedPrintStream.cpp: (WTF::LockedPrintStream::vprintf): (WTF::LockedPrintStream::flush): * wtf/MetaAllocator.cpp: (WTF::MetaAllocatorHandle::~MetaAllocatorHandle): * wtf/MetaAllocator.h: (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/ReadWriteLock.h: * wtf/StackShotProfiler.h: (WTF::StackShotProfiler::profile): (WTF::StackShotProfiler::run): * wtf/StackStats.cpp: (WTF::StackStats::CheckPoint::CheckPoint): (WTF::StackStats::CheckPoint::~CheckPoint): (WTF::StackStats::probe): (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint): (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint): * wtf/ThreadGroup.cpp: (WTF::ThreadGroup::~ThreadGroup): (WTF::ThreadGroup::add): * wtf/ThreadMessage.cpp: (WTF::sendMessageScoped): * wtf/Threading.cpp: (WTF::Thread::didExit): (WTF::Thread::addToThreadGroup): (WTF::Thread::removeFromThreadGroup): (WTF::Thread::numberOfThreadGroups): * wtf/TimingScope.cpp: * wtf/WTFConfig.cpp: (WTF::Config::permanentlyFreeze): * wtf/WTFSemaphore.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::signal): (WTF::Thread::establishPlatformSpecificHandle): * wtf/threads/BinarySemaphore.cpp: (WTF::BinarySemaphore::signal): (WTF::BinarySemaphore::waitUntil): * wtf/threads/Signals.cpp: (WTF::SignalHandlers::add): (WTF::registerThreadForMachExceptionHandling): (WTF::activateSignalHandlersFor): * wtf/win/LanguageWin.cpp: (WTF::platformLanguage): * wtf/win/ThreadingWin.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::establishPlatformSpecificHandle): Canonical link: https://commits.webkit.org/238033@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-22 00:11:37 +00:00
// Locker locker { rwLock.read() };
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
//
// It's easiest to write lock like this:
//
Stop using holdLock() in WTF as it is not compatible with Clang thread safety analysis https://bugs.webkit.org/show_bug.cgi?id=226117 Reviewed by Darin Adler. Stop using holdLock() in WTF as it is not compatible with Clang thread safety analysis (WTF::CheckedLock) and use the Locker constructor instead. This is a step towards getting rid of holdLock() completely. * benchmarks/ConditionSpeedTest.cpp: * wtf/ConcurrentPtrHashSet.cpp: (WTF::ConcurrentPtrHashSet::deleteOldTables): (WTF::ConcurrentPtrHashSet::clear): (WTF::ConcurrentPtrHashSet::containsImplSlow const): (WTF::ConcurrentPtrHashSet::sizeSlow const): (WTF::ConcurrentPtrHashSet::resizeIfNecessary): * wtf/CountingLock.h: * wtf/HashTable.cpp: (WTF::HashTableStats::recordCollisionAtCount): (WTF::HashTableStats::dumpStats): * wtf/HashTable.h: (WTF::invalidateIterators): (WTF::addIterator): (WTF::removeIterator): * wtf/LockedPrintStream.cpp: (WTF::LockedPrintStream::vprintf): (WTF::LockedPrintStream::flush): * wtf/MetaAllocator.cpp: (WTF::MetaAllocatorHandle::~MetaAllocatorHandle): * wtf/MetaAllocator.h: (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/ReadWriteLock.h: * wtf/StackShotProfiler.h: (WTF::StackShotProfiler::profile): (WTF::StackShotProfiler::run): * wtf/StackStats.cpp: (WTF::StackStats::CheckPoint::CheckPoint): (WTF::StackStats::CheckPoint::~CheckPoint): (WTF::StackStats::probe): (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint): (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint): * wtf/ThreadGroup.cpp: (WTF::ThreadGroup::~ThreadGroup): (WTF::ThreadGroup::add): * wtf/ThreadMessage.cpp: (WTF::sendMessageScoped): * wtf/Threading.cpp: (WTF::Thread::didExit): (WTF::Thread::addToThreadGroup): (WTF::Thread::removeFromThreadGroup): (WTF::Thread::numberOfThreadGroups): * wtf/TimingScope.cpp: * wtf/WTFConfig.cpp: (WTF::Config::permanentlyFreeze): * wtf/WTFSemaphore.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::signal): (WTF::Thread::establishPlatformSpecificHandle): * wtf/threads/BinarySemaphore.cpp: (WTF::BinarySemaphore::signal): (WTF::BinarySemaphore::waitUntil): * wtf/threads/Signals.cpp: (WTF::SignalHandlers::add): (WTF::registerThreadForMachExceptionHandling): (WTF::activateSignalHandlersFor): * wtf/win/LanguageWin.cpp: (WTF::platformLanguage): * wtf/win/ThreadingWin.cpp: (WTF::Thread::changePriority): (WTF::Thread::waitForCompletion): (WTF::Thread::detach): (WTF::Thread::establishPlatformSpecificHandle): Canonical link: https://commits.webkit.org/238033@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277900 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-22 00:11:37 +00:00
// Locker locker { rwLock.write() };
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
//
WTF_EXPORT_PRIVATE void readLock();
WTF_EXPORT_PRIVATE void readUnlock();
WTF_EXPORT_PRIVATE void writeLock();
WTF_EXPORT_PRIVATE void writeUnlock();
class ReadLock;
class WriteLock;
ReadLock& read();
WriteLock& write();
private:
Drop CheckedLock / CheckedCondition aliases https://bugs.webkit.org/show_bug.cgi?id=226176 Reviewed by Kate Cheney. Drop CheckedLock / CheckedCondition aliases now that they are the default. Source/JavaScriptCore: * API/JSVirtualMachine.mm: * API/glib/JSCVirtualMachine.cpp: * assembler/PerfLog.h: * assembler/testmasm.cpp: * bytecode/StructureStubInfo.h: * bytecode/SuperSampler.cpp: * dfg/DFGCommon.cpp: * dfg/DFGCommonData.cpp: * dfg/DFGPlan.h: * dfg/DFGThreadData.h: * dfg/DFGWorklist.cpp: (JSC::DFG::Worklist::Worklist): * dfg/DFGWorklist.h: * disassembler/Disassembler.cpp: * dynbench.cpp: * heap/BlockDirectory.cpp: (JSC::BlockDirectory::parallelNotEmptyBlockSource): * heap/BlockDirectory.h: (JSC::BlockDirectory::bitvectorLock): * heap/CodeBlockSet.h: (JSC::CodeBlockSet::getLock): * heap/Heap.cpp: (JSC::Heap::Heap): * heap/Heap.h: * heap/IsoSubspacePerVM.h: * heap/MarkedSpace.h: (JSC::MarkedSpace::directoryLock): * heap/MarkingConstraintSolver.h: * heap/SlotVisitor.cpp: (JSC::SlotVisitor::donateKnownParallel): * heap/SlotVisitor.h: * inspector/remote/socket/RemoteInspectorConnectionClient.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::getLock const): (JSC::dumpJITMemory): * jit/ExecutableAllocator.h: (JSC::ExecutableAllocatorBase::getLock const): * jit/JITWorklist.cpp: (JSC::JITWorklist::JITWorklist): * jit/JITWorklist.h: * jsc.cpp: * profiler/ProfilerDatabase.h: * runtime/ConcurrentJSLock.h: * runtime/DeferredWorkTimer.h: * runtime/JSLock.h: * runtime/SamplingProfiler.cpp: (JSC::FrameWalker::FrameWalker): (JSC::CFrameWalker::CFrameWalker): (JSC::SamplingProfiler::takeSample): * runtime/SamplingProfiler.h: (JSC::SamplingProfiler::getLock): * runtime/VM.h: * runtime/VMTraps.cpp: (JSC::VMTraps::invalidateCodeBlocksOnStack): (JSC::VMTraps::VMTraps): * runtime/VMTraps.h: * tools/FunctionOverrides.h: * tools/VMInspector.cpp: (JSC::ensureIsSafeToLock): * tools/VMInspector.h: (JSC::VMInspector::getLock): * wasm/WasmCalleeRegistry.h: (JSC::Wasm::CalleeRegistry::getLock): * wasm/WasmPlan.h: * wasm/WasmStreamingCompiler.h: * wasm/WasmThunks.h: * wasm/WasmWorklist.cpp: (JSC::Wasm::Worklist::Worklist): * wasm/WasmWorklist.h: Source/WebCore: * Modules/indexeddb/IDBObjectStore.h: * Modules/indexeddb/IDBTransaction.h: * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBSerializationContext.cpp: * Modules/indexeddb/server/IDBServer.cpp: * Modules/mediastream/RTCDataChannel.cpp: * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransform.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.h: * Modules/speech/SpeechRecognitionCaptureSourceImpl.h: * Modules/webaudio/AudioParamTimeline.h: * Modules/webaudio/MediaElementAudioSourceNode.h: * Modules/webdatabase/Database.cpp: * Modules/webdatabase/Database.h: * Modules/webdatabase/DatabaseManager.h: * Modules/webdatabase/DatabaseTask.h: * Modules/webdatabase/DatabaseThread.h: * Modules/webdatabase/DatabaseTracker.cpp: (WebCore::DatabaseTracker::openDatabaseMutex): * Modules/webdatabase/DatabaseTracker.h: * Modules/webdatabase/OriginLock.cpp: * Modules/webdatabase/SQLCallbackWrapper.h: * Modules/webdatabase/SQLTransaction.h: * Modules/webgpu/WebGPUDevice.cpp: (WebCore::WebGPUDevice::instancesLock): * Modules/webgpu/WebGPUDevice.h: * Modules/webgpu/WebGPUPipeline.cpp: (WebCore::WebGPUPipeline::instancesLock): * Modules/webgpu/WebGPUPipeline.h: * Modules/websockets/WebSocket.cpp: (WebCore::WebSocket::allActiveWebSocketsLock): * Modules/websockets/WebSocket.h: * accessibility/isolatedtree/AXIsolatedTree.cpp: * accessibility/isolatedtree/AXIsolatedTree.h: * bindings/js/JSDOMGlobalObject.h: * bridge/objc/WebScriptObject.mm: * crypto/CryptoAlgorithmRegistry.h: * dom/MessagePort.cpp: * dom/Node.cpp: * dom/ScriptExecutionContext.cpp: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::createMediaPlayer): * html/canvas/CanvasRenderingContext.cpp: (WebCore::CanvasRenderingContext::instancesLock): * html/canvas/CanvasRenderingContext.h: * html/canvas/WebGLContextGroup.cpp: (WebCore::WebGLContextGroup::objectGraphLockForAContext): * html/canvas/WebGLContextGroup.h: * html/canvas/WebGLContextObject.cpp: (WebCore::WebGLContextObject::objectGraphLockForContext): * html/canvas/WebGLContextObject.h: * html/canvas/WebGLObject.h: * html/canvas/WebGLProgram.cpp: (WebCore::WebGLProgram::instancesLock): * html/canvas/WebGLProgram.h: * html/canvas/WebGLRenderingContextBase.cpp: (WebCore::WebGLRenderingContextBase::objectGraphLock): * html/canvas/WebGLRenderingContextBase.h: * html/canvas/WebGLSharedObject.cpp: (WebCore::WebGLSharedObject::objectGraphLockForContext): * html/canvas/WebGLSharedObject.h: * inspector/agents/WebHeapAgent.cpp: * page/ResourceUsageThread.h: * page/SecurityPolicy.cpp: * page/WheelEventTestMonitor.h: * page/scrolling/ScrollingTree.h: (WebCore::ScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/ScrollingTreeLatchingController.h: * page/scrolling/ThreadedScrollingTree.h: (WebCore::ThreadedScrollingTree::WTF_RETURNS_LOCK): * page/scrolling/mac/ScrollingTreeMac.h: * platform/AbortableTaskQueue.h: * platform/GenericTaskQueue.cpp: * platform/GenericTaskQueue.h: * platform/LegacySchemeRegistry.cpp: * platform/audio/AudioDestination.h: * platform/audio/HRTFDatabaseLoader.h: * platform/audio/ReverbConvolver.cpp: (WebCore::ReverbConvolver::backgroundThreadEntry): * platform/audio/cocoa/AudioDestinationCocoa.h: * platform/audio/gstreamer/AudioSourceProviderGStreamer.h: * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp: * platform/audio/mac/FFTFrameMac.cpp: * platform/encryptedmedia/CDMProxy.h: * platform/graphics/MediaPlayer.cpp: * platform/graphics/ShadowBlur.cpp: (WebCore::ScratchBuffer::lock): (WebCore::ShadowBlur::drawRectShadowWithTiling): (WebCore::ShadowBlur::drawInsetShadowWithTiling): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: * platform/graphics/cg/IOSurfacePool.h: * platform/graphics/cg/SubimageCacheWithTimer.h: * platform/graphics/cocoa/FontCacheCoreText.cpp: * platform/graphics/gstreamer/ImageDecoderGStreamer.h: * platform/graphics/gstreamer/MainThreadNotifier.h: * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: * platform/graphics/gstreamer/VideoSinkGStreamer.cpp: * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp: * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h: (WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK): * platform/image-decoders/ScalableImageDecoder.h: * platform/ios/QuickLook.mm: * platform/ios/WebSQLiteDatabaseTrackerClient.mm: * platform/ios/wak/WebCoreThreadRun.cpp: * platform/mediarecorder/MediaRecorderPrivateMock.h: * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h: * platform/mediastream/RealtimeMediaSource.h: * platform/mediastream/RealtimeOutgoingAudioSource.h: * platform/mediastream/RealtimeOutgoingVideoSource.h: * platform/mediastream/cocoa/AudioMediaStreamTrackRendererUnit.h: * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h: * platform/network/cf/LoaderRunLoopCF.cpp: (WebCore::loaderRunLoop): * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/network/mac/UTIUtilities.mm: * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.h: * platform/sql/SQLiteDatabase.cpp: * platform/sql/SQLiteDatabase.h: * platform/sql/SQLiteDatabaseTracker.cpp: * platform/text/TextEncodingRegistry.cpp: * storage/StorageQuotaManager.h: * workers/WorkerGlobalScope.cpp: * workers/WorkerOrWorkletScriptController.h: * workers/WorkerOrWorkletThread.cpp: (WebCore::WorkerOrWorkletThread::workerOrWorkletThreadsLock): * workers/WorkerOrWorkletThread.h: * worklets/PaintWorkletGlobalScope.h: Source/WebKit: * GPUProcess/graphics/RemoteGraphicsContextGL.cpp: (WebKit::RemoteGraphicsContextGL::paintPixelBufferToImageBuffer): * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: * NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h: * NetworkProcess/IndexedDB/WebIDBServer.cpp: * NetworkProcess/NetworkProcess.h: * NetworkProcess/WebStorage/StorageManagerSet.h: * NetworkProcess/cache/NetworkCacheStorage.cpp: * NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h: * NetworkProcess/glib/DNSCache.h: * Platform/IPC/Connection.cpp: * Platform/IPC/Connection.h: * Platform/IPC/StreamConnectionWorkQueue.h: * Platform/IPC/StreamServerConnection.h: * Shared/BlockingResponseMap.h: * Shared/Cocoa/XPCEndpointClient.h: * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h: * Shared/mac/MediaFormatReader/MediaFormatReader.h: * Shared/mac/MediaFormatReader/MediaSampleCursor.h: * Shared/mac/MediaFormatReader/MediaTrackReader.h: * UIProcess/API/glib/IconDatabase.h: * UIProcess/WebURLSchemeTask.h: * UIProcess/mac/DisplayLink.h: * UIProcess/mac/WKPrintingView.mm: (-[WKPrintingView knowsPageRange:]): * WebProcess/GPU/graphics/RemoteImageBufferProxy.h: * WebProcess/GPU/webrtc/LibWebRTCCodecs.h: * WebProcess/Network/WebSocketStream.cpp: * WebProcess/Plugins/PluginProcessConnectionManager.h: * WebProcess/WebPage/EventDispatcher.h: * WebProcess/WebPage/ViewUpdateDispatcher.h: Source/WebKitLegacy: * Storage/StorageAreaSync.h: Source/WebKitLegacy/mac: * DOM/DOMInternal.mm: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: (WTF::AutomaticThreadCondition::wait): (WTF::AutomaticThreadCondition::waitFor): (WTF::AutomaticThread::AutomaticThread): * wtf/AutomaticThread.h: * wtf/CMakeLists.txt: * wtf/CheckedCondition.h: Removed. * wtf/CheckedLock.h: Removed. * wtf/Condition.h: * wtf/CrossThreadQueue.h: * wtf/CrossThreadTaskHandler.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/FastMalloc.cpp: * wtf/Forward.h: * wtf/Language.cpp: * wtf/Lock.cpp: (WTF::UncheckedLock::lockSlow): (WTF::UncheckedLock::unlockSlow): (WTF::UncheckedLock::unlockFairlySlow): (WTF::UncheckedLock::safepointSlow): * wtf/Lock.h: (WTF::WTF_ASSERTS_ACQUIRED_LOCK): * wtf/Logger.cpp: * wtf/Logger.h: (WTF::Logger::WTF_RETURNS_LOCK): * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::release): (WTF::MetaAllocator::MetaAllocator): (WTF::MetaAllocator::allocate): (WTF::MetaAllocator::currentStatistics): * wtf/MetaAllocator.h: * wtf/OSLogPrintStream.h: * wtf/ParallelHelperPool.cpp: (WTF::ParallelHelperPool::ParallelHelperPool): * wtf/ParallelHelperPool.h: * wtf/ParallelJobsGeneric.h: * wtf/ParallelVectorIterator.h: * wtf/ReadWriteLock.h: * wtf/RecursiveLockAdapter.h: * wtf/RunLoop.h: * wtf/SynchronizedFixedQueue.h: * wtf/Threading.cpp: (WTF::Thread::allThreadsLock): * wtf/Threading.h: * wtf/TimingScope.cpp: * wtf/URL.cpp: * wtf/WTFSemaphore.h: * wtf/WorkQueue.cpp: (WTF::WorkQueue::concurrentApply): * wtf/WorkerPool.cpp: (WTF::WorkerPool::WorkerPool): * wtf/WorkerPool.h: * wtf/cf/LanguageCF.cpp: * wtf/text/AtomStringImpl.cpp: (WTF::AtomStringTableLocker::AtomStringTableLocker): * wtf/text/StringView.cpp: * wtf/threads/BinarySemaphore.h: * wtf/unicode/icu/CollatorICU.cpp: Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/CheckedConditionTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/CheckedLockTest.cpp: Removed. * TestWebKitAPI/Tests/WTF/Condition.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/Lock.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/MetaAllocator.cpp: * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp: (WTR::AXThread::createThreadIfNeeded): Canonical link: https://commits.webkit.org/238085@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-24 18:29:01 +00:00
Lock m_lock;
Condition m_cond;
Use CheckedLock more in WTF https://bugs.webkit.org/show_bug.cgi?id=226045 Reviewed by Darin Adler. Use CheckedLock more in WTF to benefit from Clang Thread Safety Analysis. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled const): (WTF::CrossThreadQueue<DataType>::isEmpty const): * wtf/CrossThreadTaskHandler.cpp: (WTF::CrossThreadTaskHandler::postTaskReply): (WTF::CrossThreadTaskHandler::handleTaskRepliesOnMainThread): * wtf/CrossThreadTaskHandler.h: (WTF::CrossThreadTaskHandler::WTF_GUARDED_BY_LOCK): * wtf/CryptographicallyRandomNumber.cpp: * wtf/FastMalloc.cpp: (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): * wtf/MessageQueue.h: (WTF::MessageQueue<DataType>::append): (WTF::MessageQueue<DataType>::appendAndKill): (WTF::MessageQueue<DataType>::appendAndCheckEmpty): (WTF::MessageQueue<DataType>::prepend): (WTF::MessageQueue<DataType>::waitForMessageFilteredWithTimeout): (WTF::MessageQueue<DataType>::tryGetMessage): (WTF::MessageQueue<DataType>::takeAllMessages): (WTF::MessageQueue<DataType>::tryGetMessageIgnoringKilled): (WTF::MessageQueue<DataType>::removeIf): (WTF::MessageQueue<DataType>::isEmpty): (WTF::MessageQueue<DataType>::kill): (WTF::MessageQueue<DataType>::killed const): * wtf/OSLogPrintStream.cpp: (WTF::OSLogPrintStream::vprintf): * wtf/OSLogPrintStream.h: * wtf/ParallelJobsGeneric.h: (WTF::ParallelEnvironment::ThreadPrivate::WTF_GUARDED_BY_LOCK): * wtf/ParallelVectorIterator.h: (WTF::ParallelVectorIterator::iterate): (WTF::ParallelVectorIterator::WTF_GUARDED_BY_LOCK): * wtf/ReadWriteLock.cpp: (WTF::ReadWriteLock::readLock): (WTF::ReadWriteLock::readUnlock): (WTF::ReadWriteLock::writeLock): (WTF::ReadWriteLock::writeUnlock): * wtf/ReadWriteLock.h: (WTF::ReadWriteLock::WTF_GUARDED_BY_LOCK): Canonical link: https://commits.webkit.org/237989@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277847 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-21 02:43:18 +00:00
bool m_isWriteLocked WTF_GUARDED_BY_LOCK(m_lock) { false };
unsigned m_numReaders WTF_GUARDED_BY_LOCK(m_lock) { 0 };
unsigned m_numWaitingWriters WTF_GUARDED_BY_LOCK(m_lock) { 0 };
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +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
class ReadWriteLock::ReadLock : public ReadWriteLock {
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
public:
bool tryLock() { return false; }
void lock() { readLock(); }
void unlock() { readUnlock(); }
};
[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
class ReadWriteLock::WriteLock : public ReadWriteLock {
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
public:
bool tryLock() { return false; }
void lock() { writeLock(); }
void unlock() { writeUnlock(); }
};
[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
inline ReadWriteLock::ReadLock& ReadWriteLock::read() { return *static_cast<ReadLock*>(this); }
inline ReadWriteLock::WriteLock& ReadWriteLock::write() { return *static_cast<WriteLock*>(this); }
REGRESSION (r219895-219897): Number of leaks on Open Source went from 9240 to 235983 and is now at 302372 https://bugs.webkit.org/show_bug.cgi?id=175083 Reviewed by Oliver Hunt. Source/JavaScriptCore: This fixes the leak by making MarkedBlock::specializedSweep call destructors when the block is empty, even if we are using the pop path. Also, this fixes HeapCellInlines.h to no longer include MarkedBlockInlines.h. That's pretty important, since MarkedBlockInlines.h is the GC's internal guts - we don't want to have to recompile the world just because we changed it. Finally, this adds a new testing SPI for waiting for all VMs to finish destructing. This makes it easier to debug leaks. * bytecode/AccessCase.cpp: * bytecode/PolymorphicAccess.cpp: * heap/HeapCell.cpp: (JSC::HeapCell::isLive): * heap/HeapCellInlines.h: (JSC::HeapCell::isLive): Deleted. * heap/MarkedAllocator.cpp: (JSC::MarkedAllocator::tryAllocateWithoutCollecting): (JSC::MarkedAllocator::endMarking): * heap/MarkedBlockInlines.h: (JSC::MarkedBlock::Handle::specializedSweep): * jit/AssemblyHelpers.cpp: * jit/Repatch.cpp: * runtime/TestRunnerUtils.h: * runtime/VM.cpp: (JSC::waitForVMDestruction): (JSC::VM::~VM): Source/WTF: Adds a classic ReadWriteLock class. I wrote my own because I can never remember if the pthread one is guaranted to bias in favor of writers or not. * WTF.xcodeproj/project.pbxproj: * wtf/Condition.h: (WTF::ConditionBase::construct): (WTF::Condition::Condition): * wtf/Lock.h: (WTF::LockBase::construct): (WTF::Lock::Lock): * wtf/ReadWriteLock.cpp: Added. (WTF::ReadWriteLockBase::construct): (WTF::ReadWriteLockBase::readLock): (WTF::ReadWriteLockBase::readUnlock): (WTF::ReadWriteLockBase::writeLock): (WTF::ReadWriteLockBase::writeUnlock): * wtf/ReadWriteLock.h: Added. (WTF::ReadWriteLockBase::ReadLock::tryLock): (WTF::ReadWriteLockBase::ReadLock::lock): (WTF::ReadWriteLockBase::ReadLock::unlock): (WTF::ReadWriteLockBase::WriteLock::tryLock): (WTF::ReadWriteLockBase::WriteLock::lock): (WTF::ReadWriteLockBase::WriteLock::unlock): (WTF::ReadWriteLockBase::read): (WTF::ReadWriteLockBase::write): (WTF::ReadWriteLock::ReadWriteLock): Tools: Leaks results are super confusing if leaks runs while some VMs are destructing. This calls a new SPI to wait for VM destructions to finish before running the next test. This makes it easier to understand leaks results from workers tests, and leads to fewer reported leaks. * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): Canonical link: https://commits.webkit.org/191978@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-06 04:43:37 +00:00
} // namespace WTF
using WTF::ReadWriteLock;