haikuwebkit/Source/WTF/wtf/CrossThreadQueue.h

124 lines
3.3 KiB
C
Raw Permalink Normal View History

Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
/*
* Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <limits>
#include <wtf/Assertions.h>
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>
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
#include <wtf/Deque.h>
#include <wtf/Lock.h>
#include <wtf/Noncopyable.h>
namespace WTF {
template<typename DataType>
[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 CrossThreadQueue final {
WTF_MAKE_FAST_ALLOCATED;
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
WTF_MAKE_NONCOPYABLE(CrossThreadQueue);
public:
CrossThreadQueue() = default;
void append(DataType&&);
DataType waitForMessage();
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<DataType> tryGetMessage();
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
void kill();
bool isKilled() const;
bool isEmpty() const;
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
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
mutable Lock m_lock;
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
Deque<DataType> m_queue WTF_GUARDED_BY_LOCK(m_lock);
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
Condition m_condition;
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_killed WTF_GUARDED_BY_LOCK(m_lock) { false };
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
};
template<typename DataType>
void CrossThreadQueue<DataType>::append(DataType&& message)
{
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
Locker locker { m_lock };
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
ASSERT(!m_killed);
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
m_queue.append(WTFMove(message));
m_condition.notifyOne();
}
template<typename DataType>
DataType CrossThreadQueue<DataType>::waitForMessage()
{
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
Locker locker { m_lock };
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
auto found = m_queue.end();
while (!m_killed && found == m_queue.end()) {
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
found = m_queue.begin();
if (found != m_queue.end())
break;
WTF::ParkingLot should stop using std::chrono because std::chrono::duration casts are prone to overflows https://bugs.webkit.org/show_bug.cgi?id=152045 Reviewed by Andy Estes. Source/JavaScriptCore: Probably the nicest example of why this patch is a good idea is the change in AtomicsObject.cpp. * jit/ICStats.cpp: (JSC::ICStats::ICStats): * runtime/AtomicsObject.cpp: (JSC::atomicsFuncWait): Source/WebCore: No new layout tests because no new behavior. The new WTF time classes have some unit tests in TestWebKitAPI. * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::blobSize): * platform/MainThreadSharedTimer.h: * platform/SharedTimer.h: * platform/ThreadTimers.cpp: (WebCore::ThreadTimers::updateSharedTimer): * platform/cf/MainThreadSharedTimerCF.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/efl/MainThreadSharedTimerEfl.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/glib/MainThreadSharedTimerGLib.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * platform/win/MainThreadSharedTimerWin.cpp: (WebCore::MainThreadSharedTimer::setFireInterval): * workers/WorkerRunLoop.cpp: (WebCore::WorkerRunLoop::runInMode): Source/WebKit2: * Platform/IPC/Connection.cpp: (IPC::Connection::SyncMessageState::wait): (IPC::Connection::sendMessage): (IPC::Connection::timeoutRespectingIgnoreTimeoutsForTesting): (IPC::Connection::waitForMessage): (IPC::Connection::sendSyncMessage): (IPC::Connection::waitForSyncReply): * Platform/IPC/Connection.h: (IPC::Connection::sendSync): (IPC::Connection::waitForAndDispatchImmediately): * Platform/IPC/MessageSender.h: (IPC::MessageSender::sendSync): * UIProcess/ChildProcessProxy.h: (WebKit::ChildProcessProxy::sendSync): * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::sendProcessWillSuspendImminently): * UIProcess/Storage/StorageManager.cpp: (WebKit::StorageManager::applicationWillTerminate): * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::sendProcessWillSuspendImminently): * UIProcess/WebResourceLoadStatisticsStore.cpp: (WebKit::WebResourceLoadStatisticsStore::applicationWillTerminate): * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h: * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm: (-[WKOneShotDisplayLinkHandler displayLinkFired:]): (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree): (WebKit::RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay): (WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateActivityState): * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm: (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateActivityState): * UIProcess/mac/WKImmediateActionController.mm: (-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]): * UIProcess/mac/WebPageProxyMac.mm: (WebKit::WebPageProxy::stringSelectionForPasteboard): (WebKit::WebPageProxy::dataSelectionForPasteboard): (WebKit::WebPageProxy::readSelectionFromPasteboard): (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent): (WebKit::WebPageProxy::acceptsFirstMouse): * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::runBeforeUnloadConfirmPanel): (WebKit::WebChromeClient::runJavaScriptAlert): (WebKit::WebChromeClient::runJavaScriptConfirm): (WebKit::WebChromeClient::runJavaScriptPrompt): (WebKit::WebChromeClient::print): (WebKit::WebChromeClient::exceededDatabaseQuota): (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::postSynchronousMessageForTesting): Source/WTF: We used to use 'double' for all time measurements. Sometimes it was milliseconds, sometimes it was seconds. Sometimes we measured a span of time, sometimes we spoke of time since some epoch. When we spoke of time since epoch, we either used a monotonic clock or a wall clock. The type - always 'double' - never told us what kind of time we had, even though there were roughly six of them (sec interval, ms interval, sec since epoch on wall, ms since epoch on wall, sec since epoch monotonic, ms since epoch monotonic). At some point, we thought that it would be a good idea to replace these doubles with std::chrono. But since replacing some things with std::chrono, we found it to be terribly inconvenient: - Outrageous API. I never want to say std::chrono::milliseconds(blah). I never want to say std::chrono::steady_clock::timepoint. The syntax for duration_cast is ugly, and ideally duration_cast would not even be a thing. - No overflow protection. std::chrono uses integers by default and using anything else is clumsy. But the integer math is done without regard for the rough edges of integer math, so any cast between std::chrono types risks overflow. Any comparison risks overflow because it may do conversions silently. We have even found bugs where some C++ implementations had more overflows than others, which ends up being a special kind of hell. In many cases, the overflow also has nasal demons. It's an error to represent time using integers. It would have been excusable back when floating point math was not guaranteed to be supported on all platforms, but that would have been a long time ago. Time is a continuous, infinite concept and it's a perfect fit for floating point: - Floating point preserves precision under multiplication in all but extreme cases, so using floating point for time means that unit conversions are almost completely lossless. This means that we don't have to think very hard about what units to use. In this patch, we use seconds almost everywhere. We only convert at boundaries, like an API boundary that wants something other than seconds. - Floating point makes it easy to reason about infinity, which is something that time code wants to do a lot. Example: when would you like to timeout? Infinity please! This is the most elegant way of having an API support both a timeout variant and a no-timeout variant. - Floating point does well-understood things when math goes wrong, and these things are pretty well optimized to match what a mathematician would do when computing with real numbers represented using scientific notation with a finite number of significant digits. This means that time math under floating point looks like normal math. On the other hand, std::chrono time math looks like garbage because you have to always check for multiple possible UB corners whenever you touch large integers. Integers that represent time are very likely to be large and you don't have to do much to overflow them. At this time, based on the number of bugs we have already seen due to chrono overflows, I am not certain that we even understand what are all of the corner cases that we should even check for. This patch introduces a new set of timekeeping classes that are all based on double, and all internally use seconds. These classes support algebraic typing. The classes are: - Seconds: this is for measuring a duration. - WallTime: time since epoch according to a wall clock (aka real time clock). - MonotonicTime: time since epoch according to a monotonic clock. - ClockType: enum that says either Wall or Monotonic. - TimeWithDynamicClockType: a tuple of double and ClockType, which represents either a wall time or a monotonic time. All of these classes behave like C++ values and are cheap to copy around since they are very nearly POD. This supports comprehensive conversions between the various time types. Most of this is by way of algebra. Here are just some of the rules we recognize: WallTime = WallTime + Seconds Seconds = WallTime - WallTime MonotonicTime = MonotonicTime + Seconds etc... We support negative, infinite, and NaN times because math. We support conversions between MonotonicTime and WallTime, like: WallTime wt = mt.approximateWallTime() This is called this "approximate" because the only way to do it is to get the current time on both clocks and convert relative to that. Many of our APIs would be happy using whatever notion of time the user wanted to use. For those APIs, which includes Condition and ParkingLot, we have TimeWithDynamicClockType. You can automatically convert WallTime or MonotonicTime to TimeWithDynamicClockType. This means that if you use a WallTime with Condition::waitUntil, then Condition's internal logic for when it should wake up makes its decision based on the current WallTime - but if you use MonotonicTime then waitUntil will make its decision based on current MonotonicTime. This is a greater level of flexibility than chrono allowed, since chrono did not have the concept of a dynamic clock type. This patch does not include conversions between std::chrono and these new time classes, because past experience shows that we're quite bad at getting conversions between std::chrono and anything else right. Also, I didn't need such conversion code because this patch only converts code that transitively touches ParkingLot and Condition. It was easy to get all of that code onto the new time classes. * WTF.xcodeproj/project.pbxproj: * wtf/AutomaticThread.cpp: (WTF::AutomaticThread::start): * wtf/CMakeLists.txt: * wtf/ClockType.cpp: Added. (WTF::printInternal): * wtf/ClockType.h: Added. * wtf/Condition.h: (WTF::ConditionBase::waitUntil): (WTF::ConditionBase::waitFor): (WTF::ConditionBase::wait): (WTF::ConditionBase::waitUntilWallClockSeconds): Deleted. (WTF::ConditionBase::waitUntilMonotonicClockSeconds): Deleted. (WTF::ConditionBase::waitForSeconds): Deleted. (WTF::ConditionBase::waitForSecondsImpl): Deleted. (WTF::ConditionBase::waitForImpl): Deleted. (WTF::ConditionBase::absoluteFromRelative): Deleted. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::waitForMessage): * wtf/CurrentTime.cpp: (WTF::sleep): * wtf/MessageQueue.h: (WTF::MessageQueue::infiniteTime): Deleted. * wtf/MonotonicTime.cpp: Added. (WTF::MonotonicTime::now): (WTF::MonotonicTime::approximateWallTime): (WTF::MonotonicTime::dump): (WTF::MonotonicTime::sleep): * wtf/MonotonicTime.h: Added. (WTF::MonotonicTime::MonotonicTime): (WTF::MonotonicTime::fromRawDouble): (WTF::MonotonicTime::infinity): (WTF::MonotonicTime::secondsSinceEpoch): (WTF::MonotonicTime::approximateMonotonicTime): (WTF::MonotonicTime::operator bool): (WTF::MonotonicTime::operator+): (WTF::MonotonicTime::operator-): (WTF::MonotonicTime::operator+=): (WTF::MonotonicTime::operator-=): (WTF::MonotonicTime::operator==): (WTF::MonotonicTime::operator!=): (WTF::MonotonicTime::operator<): (WTF::MonotonicTime::operator>): (WTF::MonotonicTime::operator<=): (WTF::MonotonicTime::operator>=): * wtf/ParkingLot.cpp: (WTF::ParkingLot::parkConditionallyImpl): (WTF::ParkingLot::unparkOne): (WTF::ParkingLot::unparkOneImpl): (WTF::ParkingLot::unparkCount): * wtf/ParkingLot.h: (WTF::ParkingLot::parkConditionally): (WTF::ParkingLot::compareAndPark): * wtf/Seconds.cpp: Added. (WTF::Seconds::operator+): (WTF::Seconds::operator-): (WTF::Seconds::dump): (WTF::Seconds::sleep): * wtf/Seconds.h: Added. (WTF::Seconds::Seconds): (WTF::Seconds::value): (WTF::Seconds::seconds): (WTF::Seconds::milliseconds): (WTF::Seconds::microseconds): (WTF::Seconds::nanoseconds): (WTF::Seconds::fromMilliseconds): (WTF::Seconds::fromMicroseconds): (WTF::Seconds::fromNanoseconds): (WTF::Seconds::infinity): (WTF::Seconds::operator bool): (WTF::Seconds::operator+): (WTF::Seconds::operator-): (WTF::Seconds::operator*): (WTF::Seconds::operator/): (WTF::Seconds::operator+=): (WTF::Seconds::operator-=): (WTF::Seconds::operator*=): (WTF::Seconds::operator/=): (WTF::Seconds::operator==): (WTF::Seconds::operator!=): (WTF::Seconds::operator<): (WTF::Seconds::operator>): (WTF::Seconds::operator<=): (WTF::Seconds::operator>=): * wtf/TimeWithDynamicClockType.cpp: Added. (WTF::TimeWithDynamicClockType::now): (WTF::TimeWithDynamicClockType::nowWithSameClock): (WTF::TimeWithDynamicClockType::wallTime): (WTF::TimeWithDynamicClockType::monotonicTime): (WTF::TimeWithDynamicClockType::approximateWallTime): (WTF::TimeWithDynamicClockType::approximateMonotonicTime): (WTF::TimeWithDynamicClockType::operator-): (WTF::TimeWithDynamicClockType::operator<): (WTF::TimeWithDynamicClockType::operator>): (WTF::TimeWithDynamicClockType::operator<=): (WTF::TimeWithDynamicClockType::operator>=): (WTF::TimeWithDynamicClockType::dump): (WTF::TimeWithDynamicClockType::sleep): * wtf/TimeWithDynamicClockType.h: Added. (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): (WTF::TimeWithDynamicClockType::fromRawDouble): (WTF::TimeWithDynamicClockType::secondsSinceEpoch): (WTF::TimeWithDynamicClockType::clockType): (WTF::TimeWithDynamicClockType::withSameClockAndRawDouble): (WTF::TimeWithDynamicClockType::operator bool): (WTF::TimeWithDynamicClockType::operator+): (WTF::TimeWithDynamicClockType::operator-): (WTF::TimeWithDynamicClockType::operator+=): (WTF::TimeWithDynamicClockType::operator-=): (WTF::TimeWithDynamicClockType::operator==): (WTF::TimeWithDynamicClockType::operator!=): * wtf/WallTime.cpp: Added. (WTF::WallTime::now): (WTF::WallTime::approximateMonotonicTime): (WTF::WallTime::dump): (WTF::WallTime::sleep): * wtf/WallTime.h: Added. (WTF::WallTime::WallTime): (WTF::WallTime::fromRawDouble): (WTF::WallTime::infinity): (WTF::WallTime::secondsSinceEpoch): (WTF::WallTime::approximateWallTime): (WTF::WallTime::operator bool): (WTF::WallTime::operator+): (WTF::WallTime::operator-): (WTF::WallTime::operator+=): (WTF::WallTime::operator-=): (WTF::WallTime::operator==): (WTF::WallTime::operator!=): (WTF::WallTime::operator<): (WTF::WallTime::operator>): (WTF::WallTime::operator<=): (WTF::WallTime::operator>=): * wtf/threads/BinarySemaphore.cpp: (WTF::BinarySemaphore::wait): * wtf/threads/BinarySemaphore.h: Tools: * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Condition.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/SynchronizedFixedQueue.cpp: (TestWebKitAPI::ToUpperConverter::stopProducing): (TestWebKitAPI::ToUpperConverter::stopConsuming): * TestWebKitAPI/Tests/WTF/Time.cpp: Added. (WTF::operator<<): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/182152@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208415 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-11-05 03:02:39 +00:00
m_condition.wait(m_lock);
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
}
WebAudio tests are crashing in debug when enabling the GPU process https://bugs.webkit.org/show_bug.cgi?id=217663 Reviewed by Geoff Garen. Source/WebCore: No new tests, unskipped existing tests. * WebCore.xcodeproj/project.pbxproj: * platform/audio/PushPullFIFO.h: Export PushPullFIFO so that it can be used at WebKit layer. Source/WebKit: WebAudio tests were crashing in debug when enabling the GPU process because it did audio processing on the WebContent process's main thread. To address the issue, I made RemoteAudioDestinationProxy a ThreadMessageReceiver so that it receives IPC on an audio thread instead of the main thread. IPC messages are processed directly on the AudioWorklet thread when active or on an audio thread constructed by RemoteAudioDestinationProxy otherwise. * GPUProcess/media/RemoteAudioDestinationManager.cpp: (WebKit::RemoteAudioDestination::RemoteAudioDestination): Use a PushPullFIFO structure in render() to avoid hanging the audio rendering thread on a semaphore. Hanging the rendering thread was terrible for performance and was also a source of deadlock since the underlying framework is holding a lock while render() is called. We could process a RemoteAudioDestination::CreateAudioDestination sync IPC on the main thread and deadlock on that lock. * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: * GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererManager.h: * GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.h: * NetworkProcess/IndexedDB/WebIDBServer.h: * NetworkProcess/webrtc/NetworkRTCProvider.h: * WebProcess/Network/webrtc/LibWebRTCNetwork.h: * WebProcess/cocoa/RemoteCaptureSampleManager.h: Use ThreadMessageReceiverRefCounted instead of ThreadMessageReceiver since those classes do not provide their own RefCounting. * Platform/IPC/Connection.cpp: (IPC::Connection::addWorkQueueMessageReceiver): (IPC::Connection::removeWorkQueueMessageReceiver): (IPC::Connection::addThreadMessageReceiver): (IPC::Connection::removeThreadMessageReceiver): (IPC::Connection::processIncomingMessage): (IPC::Connection::dispatchMessageToWorkQueueReceiver): (IPC::Connection::dispatchMessageToThreadReceiver): * Platform/IPC/Connection.h: (IPC::Connection::ThreadMessageReceiver::ref): (IPC::Connection::ThreadMessageReceiver::deref): - Add support for passing a destinationID when registering a WorkQueueMessageReceiver or a ThreadMessageReceiver, similarly to regular MessageReceivers. This was needed here since The GPUProcess sends IPC messages to the RemoteAudioDestinationProxy with a given destinationID and since RemoteAudioDestinationProxy is now a ThreadMessageReceiver. - Stop having ThreadMessageReceiver subclass ThreadSafeRefCounted since RemoteAudioDestinationProxy already subclasses ThreadSafeRefCounted indirectly. A new ThreadMessageReceiverRefCounted class was added for convenience for existing code that relied on its refcounting. * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp: (WebKit::RemoteAudioDestinationProxy::RemoteAudioDestinationProxy): (WebKit::RemoteAudioDestinationProxy::~RemoteAudioDestinationProxy): (WebKit::RemoteAudioDestinationProxy::start): (WebKit::RemoteAudioDestinationProxy::stop): (WebKit::RemoteAudioDestinationProxy::renderBuffer): (WebKit::RemoteAudioDestinationProxy::didChangeIsPlaying): (WebKit::RemoteAudioDestinationProxy::dispatchToThread): * WebProcess/GPU/media/RemoteAudioDestinationProxy.h: Use a PushPullFIFO container in render() to avoid handing the audio rendering thread on a semaphore while the Render IPC is getting processed by the WebProcess. Source/WTF: * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::waitForMessage): If CrossThreadQueue::kill() gets called while another thread is waiting on a CrossThreadQueue::waitForMessage() call, make it so that waitForMessage() returns a default-constructed DataType instead of crashing trying to dequeue (since the queue is empty). LayoutTests: Unskip webaudio tests when the GPU process is enabled. * gpu-process/TestExpectations: Canonical link: https://commits.webkit.org/230420@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-13 21:53:22 +00:00
if (m_killed)
return { };
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
return m_queue.takeFirst();
}
template<typename DataType>
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<DataType> CrossThreadQueue<DataType>::tryGetMessage()
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
{
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
Locker locker { m_lock };
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
if (m_queue.isEmpty())
return { };
return m_queue.takeFirst();
}
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
template<typename DataType>
void CrossThreadQueue<DataType>::kill()
{
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
Locker locker { m_lock };
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
m_killed = true;
m_condition.notifyAll();
}
template<typename DataType>
bool CrossThreadQueue<DataType>::isKilled() const
{
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
Locker locker { m_lock };
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
return m_killed;
}
template<typename DataType>
bool CrossThreadQueue<DataType>::isEmpty() const
{
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
Locker locker { m_lock };
Cleanup lifetime issues of UniqueIDBDatabase and IDBBackingStore. <rdar://problem/32908525> and https://bugs.webkit.org/show_bug.cgi?id=174244 Reviewed by David Kilzer and Alex Christensen. Source/WebCore: No targeted test possible, implicitly covered by all IDB tests. The original idea behind UniqueIDBDatabase lifetime was that they are ThreadSafeRefCounted and we take protector Refs when any operation that needs it alive is in flight. This added variability to their lifetime which made it difficult to enforce a few different design invariants, namely: - UniqueIBDDatabase objects are always created and destroyed only on the main thread. - IDBBackingStore objects are always created and destroyed only on the database thread. This patch removes the ref counting and instead ties UniqueIDBDatabase lifetime to a std::unique_ptr that is owned by the IDBServer. Whenever any operations on the UniqueIDBDatabase are in flight it is kept alive by virtue of that unique_ptr in the IDBServer. Once a UniqueIDBDatabase is completely done with all of its work, the following happens: - On the main thread the IDBServer removes the unique_ptr owning the UniqueIDBDatabase from its map. - It hands the unique_ptr to the UniqueIDBDatabase itself, which schedules one final database thread task. - That database thread task is to destroy the IDBBackingStore, kill its message queues, and then message back to the main thread for one final task. - That main thread task is to release the unique_ptr, resulting in destruction of the UniqueIDBDatabase object. This is safe, predictable, solves the lifetime issues that r218516 originally tried to solve, and solves the lifetime issues that r218516 introduced. (This patch also adds many more assertions to cover various design invariants throughout the lifecycle of a particular UniqueIDBDatabase) ASSERT that IDBBackingStores are only ever created and destroyed on the background thread: * Modules/indexeddb/server/IDBBackingStore.h: (WebCore::IDBServer::IDBBackingStore::~IDBBackingStore): (WebCore::IDBServer::IDBBackingStore::IDBBackingStore): Transition UniqueIDBDatabase ownership from a RefPtr to a std::unique_ptr: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndTakeUniqueIDBDatabase): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesModifiedSince): (WebCore::IDBServer::IDBServer::closeAndDeleteDatabasesForOrigins): (WebCore::IDBServer::IDBServer::closeUniqueIDBDatabase): Deleted. * Modules/indexeddb/server/IDBServer.h: Make all the other changes mentioned above: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::~UniqueIDBDatabase): Bulk up on ASSERTs (WebCore::IDBServer::UniqueIDBDatabase::openDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabase::performUnconditionalDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::scheduleShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::shutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didShutdownForClose): (WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::handleCurrentOperation): (WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor): (WebCore::IDBServer::UniqueIDBDatabase::performPrefetchCursor): (WebCore::IDBServer::UniqueIDBDatabase::operationAndTransactionTimerFired): (WebCore::IDBServer::UniqueIDBDatabase::activateTransactionInBackingStore): (WebCore::IDBServer::UniqueIDBDatabase::transactionCompleted): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::executeNextDatabaseTaskReply): (WebCore::IDBServer::UniqueIDBDatabase::maybeFinishHardClose): (WebCore::IDBServer::UniqueIDBDatabase::isDoneWithHardClose): (WebCore::IDBServer::UniqueIDBDatabase::immediateCloseForUserDelete): (WebCore::IDBServer::UniqueIDBDatabase::didPerformUnconditionalDeleteBackingStore): Deleted. * Modules/indexeddb/server/UniqueIDBDatabase.h: (WebCore::IDBServer::UniqueIDBDatabase::create): Deleted. Source/WTF: Add proper "kill" support to CrossThreadQueue, as well as isEmpty() support. * wtf/CrossThreadQueue.h: (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::kill): (WTF::CrossThreadQueue<DataType>::isKilled): (WTF::CrossThreadQueue<DataType>::isEmpty): (WTF::CrossThreadQueue::isKilled): Deleted. Canonical link: https://commits.webkit.org/191141@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219298 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-10 17:43:38 +00:00
return m_queue.isEmpty();
}
Make createCrossThreadTask() functions return on the stack instead of the heap. https://bugs.webkit.org/show_bug.cgi?id=158215 Reviewed by Darin Adler. Source/WebCore: No new tests (Refactor, no change in behavior). * Modules/indexeddb/client/IDBConnectionProxy.h: * Modules/indexeddb/server/IDBServer.cpp: (WebCore::IDBServer::IDBServer::postDatabaseTask): (WebCore::IDBServer::IDBServer::postDatabaseTaskReply): (WebCore::IDBServer::IDBServer::databaseRunLoop): * Modules/indexeddb/server/IDBServer.h: * Modules/indexeddb/server/UniqueIDBDatabase.cpp: (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTask): (WebCore::IDBServer::UniqueIDBDatabase::postDatabaseTaskReply): * Modules/indexeddb/server/UniqueIDBDatabase.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::postCrossThreadTask): * fileapi/ThreadableBlobRegistry.cpp: (WebCore::threadableQueue): Source/WebKit2: * DatabaseProcess/DatabaseProcess.cpp: (WebKit::DatabaseProcess::postDatabaseTask): (WebKit::DatabaseProcess::performNextDatabaseTask): (WebKit::DatabaseProcess::fetchWebsiteData): * DatabaseProcess/DatabaseProcess.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadCopier.cpp: * wtf/CrossThreadQueue.h: Added. A lightweight of MessageQueue that deals directly in objects instead of in std::unique_ptrs. (WTF::CrossThreadQueue::isKilled): (WTF::CrossThreadQueue<DataType>::append): (WTF::CrossThreadQueue<DataType>::waitForMessage): (WTF::CrossThreadQueue<DataType>::tryGetMessage): * wtf/CrossThreadTask.h: (WTF::createCrossThreadTask): (WTF::CrossThreadTask::CrossThreadTask): Deleted. Canonical link: https://commits.webkit.org/176314@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-31 19:33:22 +00:00
} // namespace WTF
using WTF::CrossThreadQueue;