WTF shouldn't have both Thread and ThreadIdentifier
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 06:13:05 +0000 (06:13 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 06:13:05 +0000 (06:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180308

Reviewed by Darin Adler.

Source/JavaScriptCore:

* heap/MachineStackMarker.cpp:
(JSC::MachineThreads::tryCopyOtherThreadStacks):
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::llint_trace_operand):
(JSC::LLInt::llint_trace_value):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
(JSC::LLInt::traceFunctionPrologue):
* runtime/ExceptionScope.cpp:
(JSC::ExceptionScope::unexpectedExceptionMessage):
* runtime/JSLock.h:
(JSC::JSLock::currentThreadIsHoldingLock):
* runtime/VM.cpp:
(JSC::VM::throwException):
* runtime/VM.h:
(JSC::VM::throwingThread const):
(JSC::VM::clearException):
* tools/HeapVerifier.cpp:
(JSC::HeapVerifier::printVerificationHeader):

Source/WebCore:

No behavior change.

* Modules/indexeddb/IDBActiveDOMObject.h:
(WebCore::IDBActiveDOMObject::originThread const):
(WebCore::IDBActiveDOMObject::performCallbackOnOriginThread):
(WebCore::IDBActiveDOMObject::callFunctionOnOriginThread):
(WebCore::IDBActiveDOMObject::originThreadID const): Deleted.
* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::IDBCursor):
(WebCore::IDBCursor::~IDBCursor):
(WebCore::IDBCursor::sourcesDeleted const):
(WebCore::IDBCursor::transaction const):
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::advance):
(WebCore::IDBCursor::continueFunction):
(WebCore::IDBCursor::uncheckedIterateCursor):
(WebCore::IDBCursor::deleteFunction):
(WebCore::IDBCursor::setGetResult):
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::~IDBDatabase):
(WebCore::IDBDatabase::hasPendingActivity const):
(WebCore::IDBDatabase::name const):
(WebCore::IDBDatabase::version const):
(WebCore::IDBDatabase::objectStoreNames const):
(WebCore::IDBDatabase::renameObjectStore):
(WebCore::IDBDatabase::renameIndex):
(WebCore::IDBDatabase::createObjectStore):
(WebCore::IDBDatabase::transaction):
(WebCore::IDBDatabase::deleteObjectStore):
(WebCore::IDBDatabase::close):
(WebCore::IDBDatabase::connectionToServerLost):
(WebCore::IDBDatabase::maybeCloseInServer):
(WebCore::IDBDatabase::activeDOMObjectName const):
(WebCore::IDBDatabase::canSuspendForDocumentSuspension const):
(WebCore::IDBDatabase::stop):
(WebCore::IDBDatabase::startVersionChangeTransaction):
(WebCore::IDBDatabase::didStartTransaction):
(WebCore::IDBDatabase::willCommitTransaction):
(WebCore::IDBDatabase::didCommitTransaction):
(WebCore::IDBDatabase::willAbortTransaction):
(WebCore::IDBDatabase::didAbortTransaction):
(WebCore::IDBDatabase::didCommitOrAbortTransaction):
(WebCore::IDBDatabase::fireVersionChangeEvent):
(WebCore::IDBDatabase::dispatchEvent):
(WebCore::IDBDatabase::didCreateIndexInfo):
(WebCore::IDBDatabase::didDeleteIndexInfo):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::~IDBIndex):
(WebCore::IDBIndex::name const):
(WebCore::IDBIndex::setName):
(WebCore::IDBIndex::objectStore):
(WebCore::IDBIndex::keyPath const):
(WebCore::IDBIndex::unique const):
(WebCore::IDBIndex::multiEntry const):
(WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::openKeyCursor):
(WebCore::IDBIndex::doCount):
(WebCore::IDBIndex::doGet):
(WebCore::IDBIndex::doGetKey):
(WebCore::IDBIndex::getAll):
(WebCore::IDBIndex::getAllKeys):
(WebCore::IDBIndex::markAsDeleted):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::IDBObjectStore):
(WebCore::IDBObjectStore::~IDBObjectStore):
(WebCore::IDBObjectStore::name const):
(WebCore::IDBObjectStore::setName):
(WebCore::IDBObjectStore::keyPath const):
(WebCore::IDBObjectStore::indexNames const):
(WebCore::IDBObjectStore::transaction):
(WebCore::IDBObjectStore::autoIncrement const):
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::openKeyCursor):
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::getKey):
(WebCore::IDBObjectStore::putOrAdd):
(WebCore::IDBObjectStore::doDelete):
(WebCore::IDBObjectStore::clear):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::deleteIndex):
(WebCore::IDBObjectStore::doCount):
(WebCore::IDBObjectStore::getAll):
(WebCore::IDBObjectStore::getAllKeys):
(WebCore::IDBObjectStore::markAsDeleted):
(WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
(WebCore::IDBOpenDBRequest::onError):
(WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
(WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
(WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
(WebCore::IDBOpenDBRequest::dispatchEvent):
(WebCore::IDBOpenDBRequest::onSuccess):
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
(WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
(WebCore::IDBOpenDBRequest::requestCompleted):
(WebCore::IDBOpenDBRequest::requestBlocked):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::~IDBRequest):
(WebCore:: const):
(WebCore::IDBRequest::setSource):
(WebCore::IDBRequest::setVersionChangeTransaction):
(WebCore::IDBRequest::transaction const):
(WebCore::IDBRequest::sourceObjectStoreIdentifier const):
(WebCore::IDBRequest::sourceIndexIdentifier const):
(WebCore::IDBRequest::requestedObjectStoreRecordType const):
(WebCore::IDBRequest::requestedIndexRecordType const):
(WebCore::IDBRequest::eventTargetInterface const):
(WebCore::IDBRequest::activeDOMObjectName const):
(WebCore::IDBRequest::canSuspendForDocumentSuspension const):
(WebCore::IDBRequest::hasPendingActivity const):
(WebCore::IDBRequest::stop):
(WebCore::IDBRequest::enqueueEvent):
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::uncaughtExceptionInEventHandler):
(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):
(WebCore::IDBRequest::setResultToUndefined):
(WebCore::IDBRequest::resultCursor):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::didOpenOrIterateCursor):
(WebCore::IDBRequest::completeRequestAndDispatchEvent):
(WebCore::IDBRequest::onError):
(WebCore::IDBRequest::onSuccess):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::IDBTransaction):
(WebCore::IDBTransaction::~IDBTransaction):
(WebCore::IDBTransaction::objectStoreNames const):
(WebCore::IDBTransaction::db):
(WebCore::IDBTransaction::error const):
(WebCore::IDBTransaction::objectStore):
(WebCore::IDBTransaction::abortDueToFailedRequest):
(WebCore::IDBTransaction::transitionedToFinishing):
(WebCore::IDBTransaction::abort):
(WebCore::IDBTransaction::internalAbort):
(WebCore::IDBTransaction::abortOnServerAndCancelRequests):
(WebCore::IDBTransaction::activeDOMObjectName const):
(WebCore::IDBTransaction::canSuspendForDocumentSuspension const):
(WebCore::IDBTransaction::hasPendingActivity const):
(WebCore::IDBTransaction::stop):
(WebCore::IDBTransaction::isActive const):
(WebCore::IDBTransaction::isFinishedOrFinishing const):
(WebCore::IDBTransaction::addRequest):
(WebCore::IDBTransaction::removeRequest):
(WebCore::IDBTransaction::scheduleOperation):
(WebCore::IDBTransaction::schedulePendingOperationTimer):
(WebCore::IDBTransaction::pendingOperationTimerFired):
(WebCore::IDBTransaction::operationCompletedOnServer):
(WebCore::IDBTransaction::scheduleCompletedOperationTimer):
(WebCore::IDBTransaction::completedOperationTimerFired):
(WebCore::IDBTransaction::commit):
(WebCore::IDBTransaction::commitOnServer):
(WebCore::IDBTransaction::finishAbortOrCommit):
(WebCore::IDBTransaction::didStart):
(WebCore::IDBTransaction::notifyDidAbort):
(WebCore::IDBTransaction::didAbort):
(WebCore::IDBTransaction::didCommit):
(WebCore::IDBTransaction::fireOnComplete):
(WebCore::IDBTransaction::fireOnAbort):
(WebCore::IDBTransaction::enqueueEvent):
(WebCore::IDBTransaction::dispatchEvent):
(WebCore::IDBTransaction::createObjectStore):
(WebCore::IDBTransaction::createObjectStoreOnServer):
(WebCore::IDBTransaction::didCreateObjectStoreOnServer):
(WebCore::IDBTransaction::renameObjectStore):
(WebCore::IDBTransaction::renameObjectStoreOnServer):
(WebCore::IDBTransaction::didRenameObjectStoreOnServer):
(WebCore::IDBTransaction::createIndex):
(WebCore::IDBTransaction::createIndexOnServer):
(WebCore::IDBTransaction::didCreateIndexOnServer):
(WebCore::IDBTransaction::renameIndex):
(WebCore::IDBTransaction::renameIndexOnServer):
(WebCore::IDBTransaction::didRenameIndexOnServer):
(WebCore::IDBTransaction::requestOpenCursor):
(WebCore::IDBTransaction::doRequestOpenCursor):
(WebCore::IDBTransaction::openCursorOnServer):
(WebCore::IDBTransaction::didOpenCursorOnServer):
(WebCore::IDBTransaction::iterateCursor):
(WebCore::IDBTransaction::iterateCursorOnServer):
(WebCore::IDBTransaction::didIterateCursorOnServer):
(WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
(WebCore::IDBTransaction::requestGetAllIndexRecords):
(WebCore::IDBTransaction::getAllRecordsOnServer):
(WebCore::IDBTransaction::didGetAllRecordsOnServer):
(WebCore::IDBTransaction::requestGetRecord):
(WebCore::IDBTransaction::requestGetValue):
(WebCore::IDBTransaction::requestGetKey):
(WebCore::IDBTransaction::requestIndexRecord):
(WebCore::IDBTransaction::getRecordOnServer):
(WebCore::IDBTransaction::didGetRecordOnServer):
(WebCore::IDBTransaction::requestCount):
(WebCore::IDBTransaction::getCountOnServer):
(WebCore::IDBTransaction::didGetCountOnServer):
(WebCore::IDBTransaction::requestDeleteRecord):
(WebCore::IDBTransaction::deleteRecordOnServer):
(WebCore::IDBTransaction::didDeleteRecordOnServer):
(WebCore::IDBTransaction::requestClearObjectStore):
(WebCore::IDBTransaction::clearObjectStoreOnServer):
(WebCore::IDBTransaction::didClearObjectStoreOnServer):
(WebCore::IDBTransaction::requestPutOrAdd):
(WebCore::IDBTransaction::putOrAddOnServer):
(WebCore::IDBTransaction::didPutOrAddOnServer):
(WebCore::IDBTransaction::deleteObjectStore):
(WebCore::IDBTransaction::deleteObjectStoreOnServer):
(WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
(WebCore::IDBTransaction::deleteIndex):
(WebCore::IDBTransaction::deleteIndexOnServer):
(WebCore::IDBTransaction::didDeleteIndexOnServer):
(WebCore::IDBTransaction::operationCompletedOnClient):
(WebCore::IDBTransaction::establishOnServer):
(WebCore::IDBTransaction::activate):
(WebCore::IDBTransaction::deactivate):
* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::removeItemsMatchingCurrentThread):
* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::~TransactionOperation):
(WebCore::IDBClient::TransactionOperation::perform):
(WebCore::IDBClient::TransactionOperation::transitionToCompleteOnThisThread):
(WebCore::IDBClient::TransactionOperation::transitionToComplete):
(WebCore::IDBClient::TransactionOperation::doComplete):
(WebCore::IDBClient::TransactionOperation::originThread const):
(WebCore::IDBClient::TransactionOperation::originThreadID const): Deleted.
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::AudioContext):
(WebCore::AudioContext::lock):
(WebCore::AudioContext::tryLock):
(WebCore::AudioContext::unlock):
(WebCore::AudioContext::isAudioThread const):
(WebCore::AudioContext::isGraphOwner const):
* Modules/webaudio/AudioContext.h:
(WebCore::AudioContext::setAudioThread):
(WebCore::AudioContext::audioThread const):
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::render):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::performClose):
(WebCore::Database::securityOrigin):
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
(WebCore::DatabaseDetails::thread const):
(WebCore::DatabaseDetails::threadID const): Deleted.
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::detailsForNameAndOrigin):
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::databaseThread):
(WebCore::DatabaseThread::recordDatabaseOpen):
(WebCore::DatabaseThread::recordDatabaseClosed):
* Modules/webdatabase/DatabaseThread.h:
(WebCore::DatabaseThread::getThread):
(WebCore::DatabaseThread::getThreadID): Deleted.
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::checkAndHandleClosedDatabase):
* Modules/webdatabase/SQLTransactionBackend.cpp:
(WebCore::SQLTransactionBackend::doCleanup):
(WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown):
* bindings/js/JSCallbackData.h:
(WebCore::JSCallbackData::JSCallbackData):
(WebCore::JSCallbackData::~JSCallbackData):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::createdMessagePort):
(WebCore::ScriptExecutionContext::destroyedMessagePort):
* page/ResourceUsageOverlay.h:
* page/scrolling/ScrollingThread.cpp:
(WebCore::ScrollingThread::isCurrentThread):
* platform/Supplementable.h:
(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::removeSupplement):
(WebCore::Supplementable::requireSupplement):
(WebCore::Supplementable::Supplementable): Deleted.
* platform/Timer.cpp:
(WebCore::TimerBase::TimerBase):
(WebCore::TimerBase::start):
(WebCore::TimerBase::stop):
(WebCore::TimerBase::setNextFireTime):
* platform/Timer.h:
(WebCore::TimerBase::isActive const):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::shouldAutoActivateFontIfNeeded):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
(WebCore::TextureMapperPlatformLayerProxy::invalidate):
(WebCore::TextureMapperPlatformLayerProxy::getAvailableBuffer):
(WebCore::TextureMapperPlatformLayerProxy::appendToUnusedBuffers):
(WebCore::TextureMapperPlatformLayerProxy::swapBuffer):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
(): Deleted.
* platform/ios/wak/WebCoreThread.mm:
(RunWebThread):
(StartWebThread):
* platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open):
(WebCore::SQLiteDatabase::close):
* platform/sql/SQLiteDatabase.h:
(WebCore::SQLiteDatabase::sqlite3Handle const):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::~WorkerGlobalScope):
(WebCore::WorkerGlobalScope::isContextThread const):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
(WebCore::WorkerMessagingProxy::~WorkerMessagingProxy):
* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::runInMode):
(WebCore::WorkerRunLoop::runCleanupTasks):
* workers/WorkerThread.h:
(WebCore::WorkerThread::thread const):
(WebCore::WorkerThread::threadID const): Deleted.
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::~ServiceWorkerContainer):
(WebCore::ServiceWorkerContainer::scheduleJob):
(WebCore::ServiceWorkerContainer::jobFailedWithException):
(WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
(WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
(WebCore::ServiceWorkerContainer::startScriptFetchForJob):
(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
(WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
(WebCore::ServiceWorkerContainer::jobDidFinish):
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
(WebCore::ServiceWorkerContainer::scheduleTaskToFireControllerChangeEvent):
(WebCore::ServiceWorkerContainer::contextIdentifier):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::~ServiceWorkerJob):
(WebCore::ServiceWorkerJob::failedWithException):
(WebCore::ServiceWorkerJob::resolvedWithRegistration):
(WebCore::ServiceWorkerJob::resolvedWithUnregistrationResult):
(WebCore::ServiceWorkerJob::startScriptFetch):
(WebCore::ServiceWorkerJob::fetchScriptWithContext):
(WebCore::ServiceWorkerJob::didReceiveResponse):
(WebCore::ServiceWorkerJob::notifyFinished):
* workers/service/ServiceWorkerJob.h:
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::matchFunc):
(WebCore::openFunc):
(WebCore::initializeXMLParser):
(WebCore::XMLParserContext::createStringParser):
(WebCore::XMLParserContext::createMemoryParser):

Source/WebKit:

* UIProcess/API/glib/IconDatabase.cpp:
* UIProcess/GenericCallback.h:
(WebKit::GenericCallback::~GenericCallback):
(WebKit::GenericCallback::performCallbackWithReturnValue):

Source/WTF:

We should use a pointer of WTF::Thread instead of ThreadIdentifier.

One problem is that Windows support library uses WTF::createThread,
which returns ThreadIdentifier. So we cannot drop ThreadIdentifier
in Windows environment. This patch keeps ThreadIdentifier in Windows.

* wtf/MainThread.cpp:
(WTF::initializeMainThread):
(WTF::isMainThread):
(WTF::canAccessThreadLocalDataForThread):
* wtf/MainThread.h:
* wtf/ParkingLot.cpp:
(WTF::ParkingLot::parkConditionallyImpl):
(WTF::ParkingLot::unparkOne):
(WTF::ParkingLot::unparkOneImpl):
(WTF::ParkingLot::unparkCount):
* wtf/RecursiveLockAdapter.h:
(WTF::RecursiveLockAdapter::lock):
(WTF::RecursiveLockAdapter::unlock):
(WTF::RecursiveLockAdapter::tryLock):
* wtf/Threading.cpp:
(WTF::Thread::dump const):
* wtf/Threading.h:
(WTF::Thread::id const):
(WTF::Thread::operator==): Deleted.
(WTF::Thread::operator!=): Deleted.
(WTF::currentThread): Deleted.
* wtf/ThreadingPrimitives.h:
* wtf/ThreadingPthreads.cpp:
(WTF::Thread::waitForCompletion):
(WTF::Thread::detach):
(WTF::Thread::initializeCurrentTLS):
(WTF::Thread::suspend):
(WTF::Thread::establishPlatformSpecificHandle):
(WTF::Thread::currentID): Deleted.
* wtf/ThreadingWin.cpp:
(WTF::Thread::waitForCompletion):
(WTF::Thread::suspend):
(WTF::Thread::currentDying):
* wtf/mac/MainThreadMac.mm:
(WTF::initializeApplicationUIThread):
(WTF::initializeWebThreadPlatform):
(WTF::canAccessThreadLocalDataForThread):
(WTF::initializeApplicationUIThreadIdentifier): Deleted.
(WTF::initializeWebThreadIdentifier): Deleted.

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpRenderTree):
(runThread): Deleted.
(runPthread): Deleted.
(testThreadIdentifierMap): Deleted.
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/ParkingLot.cpp:
* TestWebKitAPI/Tests/WTF/Threading.cpp: Added.
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225470 268f45cc-cd09-0410-ab3c-d52691b4dbfc

72 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/MachineStackMarker.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/runtime/ExceptionScope.cpp
Source/JavaScriptCore/runtime/JSLock.h
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/JavaScriptCore/tools/HeapVerifier.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/MainThread.cpp
Source/WTF/wtf/MainThread.h
Source/WTF/wtf/ParkingLot.cpp
Source/WTF/wtf/RecursiveLockAdapter.h
Source/WTF/wtf/Threading.cpp
Source/WTF/wtf/Threading.h
Source/WTF/wtf/ThreadingPrimitives.h
Source/WTF/wtf/ThreadingPthreads.cpp
Source/WTF/wtf/ThreadingWin.cpp
Source/WTF/wtf/mac/MainThreadMac.mm
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBActiveDOMObject.h
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp
Source/WebCore/Modules/indexeddb/client/TransactionOperation.h
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/webaudio/AudioDestinationNode.cpp
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/DatabaseDetails.h
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
Source/WebCore/Modules/webdatabase/DatabaseThread.cpp
Source/WebCore/Modules/webdatabase/DatabaseThread.h
Source/WebCore/Modules/webdatabase/SQLTransaction.cpp
Source/WebCore/Modules/webdatabase/SQLTransactionBackend.cpp
Source/WebCore/bindings/js/JSCallbackData.h
Source/WebCore/bindings/js/ScheduledAction.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/page/ResourceUsageOverlay.h
Source/WebCore/page/scrolling/ScrollingThread.cpp
Source/WebCore/platform/Supplementable.h
Source/WebCore/platform/Timer.cpp
Source/WebCore/platform/Timer.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.h
Source/WebCore/platform/ios/wak/WebCoreThread.mm
Source/WebCore/platform/sql/SQLiteDatabase.cpp
Source/WebCore/platform/sql/SQLiteDatabase.h
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerRunLoop.cpp
Source/WebCore/workers/WorkerThread.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerJob.cpp
Source/WebCore/workers/service/ServiceWorkerJob.h
Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/glib/IconDatabase.cpp
Source/WebKit/UIProcess/GenericCallback.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/ParkingLot.cpp
Tools/TestWebKitAPI/Tests/WTF/Threading.cpp [new file with mode: 0644]

index 01a699e..4564946 100644 (file)
@@ -1,3 +1,29 @@
+2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        WTF shouldn't have both Thread and ThreadIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=180308
+
+        Reviewed by Darin Adler.
+
+        * heap/MachineStackMarker.cpp:
+        (JSC::MachineThreads::tryCopyOtherThreadStacks):
+        * llint/LLIntSlowPaths.cpp:
+        (JSC::LLInt::llint_trace_operand):
+        (JSC::LLInt::llint_trace_value):
+        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+        (JSC::LLInt::traceFunctionPrologue):
+        * runtime/ExceptionScope.cpp:
+        (JSC::ExceptionScope::unexpectedExceptionMessage):
+        * runtime/JSLock.h:
+        (JSC::JSLock::currentThreadIsHoldingLock):
+        * runtime/VM.cpp:
+        (JSC::VM::throwException):
+        * runtime/VM.h:
+        (JSC::VM::throwingThread const):
+        (JSC::VM::clearException):
+        * tools/HeapVerifier.cpp:
+        (JSC::HeapVerifier::printVerificationHeader):
+
 2017-12-03  Caio Lima  <ticaiolima@gmail.com>
 
         Rename DestroyFunc to avoid redefinition on unified build
index 1de8caa..e6af53b 100644 (file)
@@ -151,7 +151,7 @@ bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void
     {
         unsigned index = 0;
         for (auto& thread : threads) {
-            if (thread.get() != currentThread) {
+            if (thread.ptr() != &currentThread) {
                 auto result = thread->suspend();
                 if (result)
                     isSuspended.set(index);
@@ -160,8 +160,8 @@ bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void
                     // These threads will be removed from the ThreadGroup. Thus, we do not do anything here except for reporting.
                     ASSERT(result.error() != KERN_SUCCESS);
                     WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
-                        "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] id %u.",
-                        result.error(), index, threads.size(), thread.ptr(), thread->id());
+                        "JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p].",
+                        result.error(), index, threads.size(), thread.ptr());
 #endif
                 }
             }
index 21e902d..7a15e22 100644 (file)
@@ -191,8 +191,8 @@ namespace JSC { namespace LLInt {
 extern "C" SlowPathReturnType llint_trace_operand(ExecState* exec, Instruction* pc, int fromWhere, int operand)
 {
     LLINT_BEGIN();
-    dataLogF("<%d> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
-            currentThread(),
+    dataLogF("<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
+            &Thread::current(),
             exec->codeBlock(),
             exec,
             static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -215,8 +215,8 @@ extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc
     } u;
     u.asValue = JSValue::encode(value);
     dataLogF(
-        "<%d> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
-        currentThread(),
+        "<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
+        &Thread::current(),
         exec->codeBlock(),
         exec,
         static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -232,7 +232,7 @@ extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc
 
 LLINT_SLOW_PATH_DECL(trace_prologue)
 {
-    dataLogF("<%d> %p / %p: in prologue of ", currentThread(), exec->codeBlock(), exec);
+    dataLogF("<%p> %p / %p: in prologue of ", &Thread::current(), exec->codeBlock(), exec);
     dataLog(*exec->codeBlock(), "\n");
     LLINT_END_IMPL();
 }
@@ -242,7 +242,7 @@ static void traceFunctionPrologue(ExecState* exec, const char* comment, CodeSpec
     JSFunction* callee = jsCast<JSFunction*>(exec->jsCallee());
     FunctionExecutable* executable = callee->jsExecutable();
     CodeBlock* codeBlock = executable->codeBlockFor(kind);
-    dataLogF("<%d> %p / %p: in %s of ", currentThread(), codeBlock, exec, comment);
+    dataLogF("<%p> %p / %p: in %s of ", &Thread::current(), codeBlock, exec, comment);
     dataLog(*codeBlock);
     dataLogF(" function %p, executable %p; numVars = %u, numParameters = %u, numCalleeLocals = %u, caller = %p.\n",
         callee, executable, codeBlock->m_numVars, codeBlock->numParameters(), codeBlock->m_numCalleeLocals, exec->callerFrame());
@@ -275,8 +275,8 @@ LLINT_SLOW_PATH_DECL(trace_arityCheck_for_construct)
 LLINT_SLOW_PATH_DECL(trace)
 {
     OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
-    dataLogF("<%d> %p / %p: executing bc#%zu, %s, pc = %p\n",
-            currentThread(),
+    dataLogF("<%p> %p / %p: executing bc#%zu, %s, pc = %p\n",
+            &Thread::current(),
             exec->codeBlock(),
             exec,
             static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -294,8 +294,8 @@ LLINT_SLOW_PATH_DECL(trace)
 
 LLINT_SLOW_PATH_DECL(special_trace)
 {
-    dataLogF("<%d> %p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
-            currentThread(),
+    dataLogF("<%p> %p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
+            &Thread::current(),
             exec->codeBlock(),
             exec,
             static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
index 690bc12..7d1c06a 100644 (file)
@@ -55,14 +55,14 @@ CString ExceptionScope::unexpectedExceptionMessage()
 {
     StringPrintStream out;
 
-    out.println("Unexpected exception observed on thread ", currentThread(), " at:");
+    out.println("Unexpected exception observed on thread ", Thread::current(), " at:");
     auto currentStack = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit(), 1);
     currentStack->dump(out, "    ");
 
     if (!m_vm.nativeStackTraceOfLastThrow())
         return CString();
     
-    out.println("The exception was thrown from thread ", m_vm.throwingThread(), " at:");
+    out.println("The exception was thrown from thread ", *m_vm.throwingThread(), " at:");
     m_vm.nativeStackTraceOfLastThrow()->dump(out, "    ");
 
     return out.toCString();
index dea0502..bedf2b5 100644 (file)
@@ -98,7 +98,7 @@ public:
             return m_ownerThread;
         return std::nullopt;
     }
-    bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread->id() == currentThread(); }
+    bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread.get() == &Thread::current(); }
 
     void willDestroyVM(VM*);
 
index 5abdfbb..68fbce7 100644 (file)
@@ -689,7 +689,7 @@ void VM::throwException(ExecState* exec, Exception* exception)
 
 #if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     m_nativeStackTraceOfLastThrow = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit());
-    m_throwingThread = currentThread();
+    m_throwingThread = &Thread::current();
 #endif
 }
 
index 366873b..a6c2d53 100644 (file)
@@ -711,7 +711,7 @@ public:
 
 #if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
     StackTrace* nativeStackTraceOfLastThrow() const { return m_nativeStackTraceOfLastThrow.get(); }
-    ThreadIdentifier throwingThread() const { return m_throwingThread; }
+    Thread* throwingThread() const { return m_throwingThread.get(); }
 #endif
 
 #if USE(CF)
@@ -754,7 +754,7 @@ private:
 #if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
         m_needExceptionCheck = false;
         m_nativeStackTraceOfLastThrow = nullptr;
-        m_throwingThread = 0;
+        m_throwingThread = nullptr;
 #endif
         m_exception = nullptr;
     }
@@ -806,7 +806,7 @@ private:
     mutable bool m_needExceptionCheck { false };
     std::unique_ptr<StackTrace> m_nativeStackTraceOfLastThrow;
     std::unique_ptr<StackTrace> m_nativeStackTraceOfLastSimulatedThrow;
-    ThreadIdentifier m_throwingThread;
+    RefPtr<Thread> m_throwingThread;
 #endif
 
     bool m_failNextNewCodeBlock { false };
index 9a2d2ac..cd91ee1 100644 (file)
@@ -143,7 +143,7 @@ void HeapVerifier::printVerificationHeader()
     RELEASE_ASSERT(m_heap->collectionScope());
     CollectionScope scope = currentCycle().scope;
     MonotonicTime gcCycleTimestamp = currentCycle().timestamp;
-    dataLog("Verifying heap in [p", getCurrentProcessID(), ", t", currentThread(), "] vm ",
+    dataLog("Verifying heap in [p", getCurrentProcessID(), ", ", Thread::current(), "] vm ",
         RawPointer(m_heap->vm()), " on ", scope, " GC @ ", gcCycleTimestamp, "\n");
 }
 
index cf6c4dc..d28d79b 100644 (file)
@@ -1,3 +1,56 @@
+2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        WTF shouldn't have both Thread and ThreadIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=180308
+
+        Reviewed by Darin Adler.
+
+        We should use a pointer of WTF::Thread instead of ThreadIdentifier.
+
+        One problem is that Windows support library uses WTF::createThread,
+        which returns ThreadIdentifier. So we cannot drop ThreadIdentifier
+        in Windows environment. This patch keeps ThreadIdentifier in Windows.
+
+        * wtf/MainThread.cpp:
+        (WTF::initializeMainThread):
+        (WTF::isMainThread):
+        (WTF::canAccessThreadLocalDataForThread):
+        * wtf/MainThread.h:
+        * wtf/ParkingLot.cpp:
+        (WTF::ParkingLot::parkConditionallyImpl):
+        (WTF::ParkingLot::unparkOne):
+        (WTF::ParkingLot::unparkOneImpl):
+        (WTF::ParkingLot::unparkCount):
+        * wtf/RecursiveLockAdapter.h:
+        (WTF::RecursiveLockAdapter::lock):
+        (WTF::RecursiveLockAdapter::unlock):
+        (WTF::RecursiveLockAdapter::tryLock):
+        * wtf/Threading.cpp:
+        (WTF::Thread::dump const):
+        * wtf/Threading.h:
+        (WTF::Thread::id const):
+        (WTF::Thread::operator==): Deleted.
+        (WTF::Thread::operator!=): Deleted.
+        (WTF::currentThread): Deleted.
+        * wtf/ThreadingPrimitives.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::Thread::waitForCompletion):
+        (WTF::Thread::detach):
+        (WTF::Thread::initializeCurrentTLS):
+        (WTF::Thread::suspend):
+        (WTF::Thread::establishPlatformSpecificHandle):
+        (WTF::Thread::currentID): Deleted.
+        * wtf/ThreadingWin.cpp:
+        (WTF::Thread::waitForCompletion):
+        (WTF::Thread::suspend):
+        (WTF::Thread::currentDying):
+        * wtf/mac/MainThreadMac.mm:
+        (WTF::initializeApplicationUIThread):
+        (WTF::initializeWebThreadPlatform):
+        (WTF::canAccessThreadLocalDataForThread):
+        (WTF::initializeApplicationUIThreadIdentifier): Deleted.
+        (WTF::initializeWebThreadIdentifier): Deleted.
+
 2017-12-03  Darin Adler  <darin@apple.com>
 
         Add WTF::Hasher, an easier to use replacement for WTF::IntegerHasher
index 2c41627..d8592b7 100644 (file)
@@ -44,7 +44,7 @@ namespace WTF {
 
 static bool callbacksPaused; // This global variable is only accessed from main thread.
 #if !PLATFORM(COCOA)
-static ThreadIdentifier mainThreadIdentifier;
+static Thread* mainThread { nullptr };
 #endif
 
 static StaticLock mainThreadFunctionQueueMutex;
@@ -62,7 +62,7 @@ void initializeMainThread()
     std::call_once(initializeKey, [] {
         initializeThreading();
 #if !PLATFORM(COCOA)
-        mainThreadIdentifier = currentThread();
+        mainThread = &Thread::current();
 #endif
         initializeMainThreadPlatform();
         initializeGCThreads();
@@ -72,7 +72,7 @@ void initializeMainThread()
 #if !PLATFORM(COCOA)
 bool isMainThread()
 {
-    return currentThread() == mainThreadIdentifier;
+    return mainThread == &Thread::current();
 }
 #endif
 
@@ -98,9 +98,9 @@ void initializeWebThread()
 #endif // PLATFORM(COCOA)
 
 #if !USE(WEB_THREAD)
-bool canAccessThreadLocalDataForThread(ThreadIdentifier threadId)
+bool canAccessThreadLocalDataForThread(Thread& thread)
 {
-    return threadId == currentThread();
+    return &thread == &Thread::current();
 }
 #endif
 
index c95f92f..ed1d495 100644 (file)
@@ -39,6 +39,7 @@
 namespace WTF {
 
 class PrintStream;
+class Thread;
 
 // Must be called from the main thread.
 WTF_EXPORT_PRIVATE void initializeMainThread();
@@ -54,14 +55,13 @@ WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
 
 WTF_EXPORT_PRIVATE bool isMainThread();
 
-WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(ThreadIdentifier);
+WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(Thread&);
 
 #if USE(WEB_THREAD)
 WTF_EXPORT_PRIVATE bool isWebThread();
 WTF_EXPORT_PRIVATE bool isUIThread();
 WTF_EXPORT_PRIVATE void initializeWebThread();
-WTF_EXPORT_PRIVATE void initializeApplicationUIThreadIdentifier();
-WTF_EXPORT_PRIVATE void initializeWebThreadIdentifier();
+WTF_EXPORT_PRIVATE void initializeApplicationUIThread();
 void initializeWebThreadPlatform();
 #else
 inline bool isWebThread() { return isMainThread(); }
@@ -113,8 +113,7 @@ using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
 #endif
 #if USE(WEB_THREAD)
 using WTF::initializeWebThread;
-using WTF::initializeApplicationUIThreadIdentifier;
-using WTF::initializeWebThreadIdentifier;
+using WTF::initializeApplicationUIThread;
 #endif
 
 #endif // MainThread_h
index f8fed88..b14d7a2 100644 (file)
@@ -81,7 +81,7 @@ public:
     void enqueue(ThreadData* data)
     {
         if (verbose)
-            dataLog(toString(currentThread(), ": enqueueing ", RawPointer(data), " with address = ", RawPointer(data->address), " onto ", RawPointer(this), "\n"));
+            dataLog(toString(Thread::current(), ": enqueueing ", RawPointer(data), " with address = ", RawPointer(data->address), " onto ", RawPointer(this), "\n"));
         ASSERT(data->address);
         ASSERT(!data->nextInQueue);
         
@@ -99,11 +99,11 @@ public:
     void genericDequeue(const Functor& functor)
     {
         if (verbose)
-            dataLog(toString(currentThread(), ": dequeueing from bucket at ", RawPointer(this), "\n"));
+            dataLog(toString(Thread::current(), ": dequeueing from bucket at ", RawPointer(this), "\n"));
         
         if (!queueHead) {
             if (verbose)
-                dataLog(toString(currentThread(), ": empty.\n"));
+                dataLog(toString(Thread::current(), ": empty.\n"));
             return;
         }
 
@@ -143,14 +143,14 @@ public:
         while (shouldContinue) {
             ThreadData* current = *currentPtr;
             if (verbose)
-                dataLog(toString(currentThread(), ": got thread ", RawPointer(current), "\n"));
+                dataLog(toString(Thread::current(), ": got thread ", RawPointer(current), "\n"));
             if (!current)
                 break;
             DequeueResult result = functor(current, timeToBeFair);
             switch (result) {
             case DequeueResult::Ignore:
                 if (verbose)
-                    dataLog(toString(currentThread(), ": currentPtr = ", RawPointer(currentPtr), ", *currentPtr = ", RawPointer(*currentPtr), "\n"));
+                    dataLog(toString(Thread::current(), ": currentPtr = ", RawPointer(currentPtr), ", *currentPtr = ", RawPointer(*currentPtr), "\n"));
                 previous = current;
                 currentPtr = &(*currentPtr)->nextInQueue;
                 break;
@@ -159,7 +159,7 @@ public:
                 FALLTHROUGH;
             case DequeueResult::RemoveAndContinue:
                 if (verbose)
-                    dataLog(toString(currentThread(), ": dequeueing ", RawPointer(current), " from ", RawPointer(this), "\n"));
+                    dataLog(toString(Thread::current(), ": dequeueing ", RawPointer(current), " from ", RawPointer(this), "\n"));
                 if (current == queueTail)
                     queueTail = previous;
                 didDequeue = true;
@@ -271,7 +271,7 @@ Hashtable* ensureHashtable()
             currentHashtable = Hashtable::create(maxLoadFactor);
             if (hashtable.compareExchangeWeak(nullptr, currentHashtable)) {
                 if (verbose)
-                    dataLog(toString(currentThread(), ": created initial hashtable ", RawPointer(currentHashtable), "\n"));
+                    dataLog(toString(Thread::current(), ": created initial hashtable ", RawPointer(currentHashtable), "\n"));
                 return currentHashtable;
             }
 
@@ -346,7 +346,7 @@ void ensureHashtableSize(unsigned numThreads)
     Hashtable* oldHashtable = hashtable.load();
     if (oldHashtable && static_cast<double>(oldHashtable->size) / static_cast<double>(numThreads) >= maxLoadFactor) {
         if (verbose)
-            dataLog(toString(currentThread(), ": no need to rehash because ", oldHashtable->size, " / ", numThreads, " >= ", maxLoadFactor, "\n"));
+            dataLog(toString(Thread::current(), ": no need to rehash because ", oldHashtable->size, " / ", numThreads, " >= ", maxLoadFactor, "\n"));
         return;
     }
 
@@ -358,7 +358,7 @@ void ensureHashtableSize(unsigned numThreads)
     oldHashtable = hashtable.load();
     if (oldHashtable && static_cast<double>(oldHashtable->size) / static_cast<double>(numThreads) >= maxLoadFactor) {
         if (verbose)
-            dataLog(toString(currentThread(), ": after locking, no need to rehash because ", oldHashtable->size, " / ", numThreads, " >= ", maxLoadFactor, "\n"));
+            dataLog(toString(Thread::current(), ": after locking, no need to rehash because ", oldHashtable->size, " / ", numThreads, " >= ", maxLoadFactor, "\n"));
         unlockHashtable(bucketsToUnlock);
         return;
     }
@@ -378,14 +378,14 @@ void ensureHashtableSize(unsigned numThreads)
     
     Hashtable* newHashtable = Hashtable::create(newSize);
     if (verbose)
-        dataLog(toString(currentThread(), ": created new hashtable: ", RawPointer(newHashtable), "\n"));
+        dataLog(toString(Thread::current(), ": created new hashtable: ", RawPointer(newHashtable), "\n"));
     for (ThreadData* threadData : threadDatas) {
         if (verbose)
-            dataLog(toString(currentThread(), ": rehashing thread data ", RawPointer(threadData), " with address = ", RawPointer(threadData->address), "\n"));
+            dataLog(toString(Thread::current(), ": rehashing thread data ", RawPointer(threadData), " with address = ", RawPointer(threadData->address), "\n"));
         unsigned hash = hashAddress(threadData->address);
         unsigned index = hash % newHashtable->size;
         if (verbose)
-            dataLog(toString(currentThread(), ": index = ", index, "\n"));
+            dataLog(toString(Thread::current(), ": index = ", index, "\n"));
         Bucket* bucket = newHashtable->data[index].load();
         if (!bucket) {
             if (reusableBuckets.isEmpty())
@@ -485,7 +485,7 @@ bool enqueue(const void* address, const Functor& functor)
             break;
         }
         if (verbose)
-            dataLog(toString(currentThread(), ": enqueueing onto bucket ", RawPointer(bucket), " with index ", index, " for address ", RawPointer(address), " with hash ", hash, "\n"));
+            dataLog(toString(Thread::current(), ": enqueueing onto bucket ", RawPointer(bucket), " with index ", index, " for address ", RawPointer(address), " with hash ", hash, "\n"));
         bucket->lock.lock();
 
         // At this point the hashtable could have rehashed under us.
@@ -498,7 +498,7 @@ bool enqueue(const void* address, const Functor& functor)
         bool result;
         if (threadData) {
             if (verbose)
-                dataLog(toString(currentThread(), ": proceeding to enqueue ", RawPointer(threadData), "\n"));
+                dataLog(toString(Thread::current(), ": proceeding to enqueue ", RawPointer(threadData), "\n"));
             bucket->enqueue(threadData);
             result = true;
         } else
@@ -567,7 +567,7 @@ NEVER_INLINE ParkingLot::ParkResult ParkingLot::parkConditionallyImpl(
     const TimeWithDynamicClockType& timeout)
 {
     if (verbose)
-        dataLog(toString(currentThread(), ": parking.\n"));
+        dataLog(toString(Thread::current(), ": parking.\n"));
     
     ThreadData* me = myThreadData();
     me->token = 0;
@@ -661,7 +661,7 @@ NEVER_INLINE ParkingLot::ParkResult ParkingLot::parkConditionallyImpl(
 NEVER_INLINE ParkingLot::UnparkResult ParkingLot::unparkOne(const void* address)
 {
     if (verbose)
-        dataLog(toString(currentThread(), ": unparking one.\n"));
+        dataLog(toString(Thread::current(), ": unparking one.\n"));
     
     UnparkResult result;
 
@@ -706,7 +706,7 @@ NEVER_INLINE void ParkingLot::unparkOneImpl(
     const ScopedLambda<intptr_t(ParkingLot::UnparkResult)>& callback)
 {
     if (verbose)
-        dataLog(toString(currentThread(), ": unparking one the hard way.\n"));
+        dataLog(toString(Thread::current(), ": unparking one the hard way.\n"));
     
     RefPtr<ThreadData> threadData;
     bool timeToBeFair = false;
@@ -751,7 +751,7 @@ NEVER_INLINE unsigned ParkingLot::unparkCount(const void* address, unsigned coun
         return 0;
     
     if (verbose)
-        dataLog(toString(currentThread(), ": unparking count = ", count, " from ", RawPointer(address), ".\n"));
+        dataLog(toString(Thread::current(), ": unparking count = ", count, " from ", RawPointer(address), ".\n"));
     
     Vector<RefPtr<ThreadData>, 8> threadDatas;
     dequeue(
@@ -761,7 +761,7 @@ NEVER_INLINE unsigned ParkingLot::unparkCount(const void* address, unsigned coun
         BucketMode::IgnoreEmpty,
         [&] (ThreadData* element, bool) {
             if (verbose)
-                dataLog(toString(currentThread(), ": Observing element with address = ", RawPointer(element->address), "\n"));
+                dataLog(toString(Thread::current(), ": Observing element with address = ", RawPointer(element->address), "\n"));
             if (element->address != address)
                 return DequeueResult::Ignore;
             threadDatas.append(element);
@@ -773,7 +773,7 @@ NEVER_INLINE unsigned ParkingLot::unparkCount(const void* address, unsigned coun
 
     for (RefPtr<ThreadData>& threadData : threadDatas) {
         if (verbose)
-            dataLog(toString(currentThread(), ": unparking ", RawPointer(threadData.get()), " with address ", RawPointer(threadData->address), "\n"));
+            dataLog(toString(Thread::current(), ": unparking ", RawPointer(threadData.get()), " with address ", RawPointer(threadData->address), "\n"));
         ASSERT(threadData->address);
         {
             MutexLocker locker(threadData->parkingLock);
@@ -783,7 +783,7 @@ NEVER_INLINE unsigned ParkingLot::unparkCount(const void* address, unsigned coun
     }
 
     if (verbose)
-        dataLog(toString(currentThread(), ": done unparking.\n"));
+        dataLog(toString(Thread::current(), ": done unparking.\n"));
     
     return threadDatas.size();
 }
index 97a243b..d4feb37 100644 (file)
@@ -38,8 +38,8 @@ public:
     
     void lock()
     {
-        ThreadIdentifier me = currentThread();
-        if (me == m_owner) {
+        Thread& me = Thread::current();
+        if (&me == m_owner) {
             m_recursionCount++;
             return;
         }
@@ -47,7 +47,7 @@ public:
         m_lock.lock();
         ASSERT(!m_owner);
         ASSERT(!m_recursionCount);
-        m_owner = me;
+        m_owner = &me;
         m_recursionCount = 1;
     }
     
@@ -55,14 +55,14 @@ public:
     {
         if (--m_recursionCount)
             return;
-        m_owner = 0;
+        m_owner = nullptr;
         m_lock.unlock();
     }
     
     bool tryLock()
     {
-        ThreadIdentifier me = currentThread();
-        if (me == m_owner) {
+        Thread& me = Thread::current();
+        if (&me == m_owner) {
             m_recursionCount++;
             return true;
         }
@@ -72,7 +72,7 @@ public:
         
         ASSERT(!m_owner);
         ASSERT(!m_recursionCount);
-        m_owner = me;
+        m_owner = &me;
         m_recursionCount = 1;
         return true;
     }
@@ -83,7 +83,7 @@ public:
     }
     
 private:
-    ThreadIdentifier m_owner { 0 };
+    Thread* m_owner { nullptr }; // Use Thread* instead of RefPtr<Thread> since m_owner thread is always alive while m_onwer is set.
     unsigned m_recursionCount { 0 };
     LockType m_lock;
 };
index 0be5a10..c56f156 100644 (file)
@@ -273,7 +273,7 @@ qos_class_t Thread::adjustedQOSClass(qos_class_t originalClass)
 
 void Thread::dump(PrintStream& out) const
 {
-    out.print(m_id);
+    out.print("Thread:", RawPointer(this));
 }
 
 #if !HAVE(FAST_TLS)
index ee1303a..c74394b 100644 (file)
@@ -80,7 +80,9 @@ public:
     friend class ThreadGroup;
     friend class AtomicStringTable;
     friend WTF_EXPORT_PRIVATE void initializeThreading();
+#if OS(WINDOWS)
     friend WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
+#endif
 
     WTF_EXPORT_PRIVATE ~Thread();
 
@@ -91,12 +93,16 @@ public:
     // Returns Thread object.
     static Thread& current();
 
+#if OS(WINDOWS)
     // Returns ThreadIdentifier directly. It is useful if the user only cares about identity
     // of threads. At that time, users should know that holding this ThreadIdentifier does not ensure
     // that the thread information is alive. While Thread::current() is not safe if it is called
     // from the destructor of the other TLS data, currentID() always returns meaningful thread ID.
     WTF_EXPORT_PRIVATE static ThreadIdentifier currentID();
 
+    ThreadIdentifier id() const { return m_id; }
+#endif
+
     WTF_EXPORT_PRIVATE void changePriority(int);
     WTF_EXPORT_PRIVATE int waitForCompletion();
     WTF_EXPORT_PRIVATE void detach();
@@ -137,18 +143,6 @@ public:
 
     WTF_EXPORT_PRIVATE void dump(PrintStream& out) const;
 
-    ThreadIdentifier id() const { return m_id; }
-
-    bool operator==(const Thread& thread)
-    {
-        return id() == thread.id();
-    }
-
-    bool operator!=(const Thread& thread)
-    {
-        return id() != thread.id();
-    }
-
     static void initializePlatformThreading();
 
     const StackBounds& stack() const
@@ -280,7 +274,6 @@ protected:
 
     // WordLock & Lock rely on ThreadSpecific. But Thread object can be destroyed even after ThreadSpecific things are destroyed.
     std::mutex m_mutex;
-    ThreadIdentifier m_id { 0 };
     JoinableState m_joinableState { Joinable };
     bool m_isShuttingDown { false };
     bool m_didExit { false };
@@ -288,7 +281,9 @@ protected:
     StackBounds m_stack { StackBounds::emptyBounds() };
     Vector<std::weak_ptr<ThreadGroup>> m_threadGroups;
     PlatformThreadHandle m_handle;
-#if OS(DARWIN)
+#if OS(WINDOWS)
+    ThreadIdentifier m_id { 0 };
+#elif OS(DARWIN)
     mach_port_t m_platformThread;
 #elif USE(PTHREADS)
     PlatformRegisters* m_platformRegisters { nullptr };
@@ -307,11 +302,6 @@ protected:
     void* m_savedLastStackTop;
 };
 
-inline ThreadIdentifier currentThread()
-{
-    return Thread::currentID();
-}
-
 inline Thread* Thread::currentMayBeNull()
 {
 #if !HAVE(FAST_TLS)
@@ -345,11 +335,10 @@ inline Thread& Thread::current()
 
 } // namespace WTF
 
-using WTF::ThreadIdentifier;
 using WTF::Thread;
-using WTF::currentThread;
 
 #if OS(WINDOWS)
+using WTF::ThreadIdentifier;
 using WTF::createThread;
 using WTF::waitForThreadCompletion;
 #endif
index 6e88aa6..4ace28f 100644 (file)
@@ -45,7 +45,6 @@
 
 namespace WTF {
 
-using ThreadIdentifier = uint32_t;
 using ThreadFunction = void (*)(void* argument);
 
 #if USE(PTHREADS)
@@ -53,6 +52,7 @@ using PlatformThreadHandle = pthread_t;
 using PlatformMutex = pthread_mutex_t;
 using PlatformCondition = pthread_cond_t;
 #elif OS(WINDOWS)
+using ThreadIdentifier = uint32_t;
 using PlatformThreadHandle = HANDLE;
 struct PlatformMutex {
     CRITICAL_SECTION m_internalMutex;
index 83b9d50..cfc62aa 100644 (file)
@@ -280,9 +280,9 @@ int Thread::waitForCompletion()
     int joinResult = pthread_join(handle, 0);
 
     if (joinResult == EDEADLK)
-        LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", m_id);
+        LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this);
     else if (joinResult)
-        LOG_ERROR("ThreadIdentifier %u was unable to be joined.\n", m_id);
+        LOG_ERROR("Thread %p was unable to be joined.\n", this);
 
     std::lock_guard<std::mutex> locker(m_mutex);
     ASSERT(joinableState() == Joinable);
@@ -300,7 +300,7 @@ void Thread::detach()
     std::lock_guard<std::mutex> locker(m_mutex);
     int detachResult = pthread_detach(m_handle);
     if (detachResult)
-        LOG_ERROR("ThreadIdentifier %u was unable to be detached\n", m_id);
+        LOG_ERROR("Thread %p was unable to be detached\n", this);
 
     if (!hasExited())
         didBecomeDetached();
@@ -308,7 +308,7 @@ void Thread::detach()
 
 Thread& Thread::initializeCurrentTLS()
 {
-    // Not a WTF-created thread, ThreadIdentifier is not established yet.
+    // Not a WTF-created thread, Thread is not established yet.
     Ref<Thread> thread = adoptRef(*new Thread());
     thread->establishPlatformSpecificHandle(pthread_self());
     thread->initializeInThread();
@@ -317,11 +317,6 @@ Thread& Thread::initializeCurrentTLS()
     return initializeTLS(WTFMove(thread));
 }
 
-ThreadIdentifier Thread::currentID()
-{
-    return current().id();
-}
-
 bool Thread::signal(int signalNumber)
 {
     std::lock_guard<std::mutex> locker(m_mutex);
@@ -333,7 +328,7 @@ bool Thread::signal(int signalNumber)
 
 auto Thread::suspend() -> Expected<void, PlatformSuspendError>
 {
-    RELEASE_ASSERT_WITH_MESSAGE(id() != currentThread(), "We do not support suspending the current thread itself.");
+    RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself.");
     // During suspend, suspend or resume should not be executed from the other threads.
     // We use global lock instead of per thread lock.
     // Consider the following case, there are threads A and B.
@@ -451,13 +446,9 @@ void Thread::establishPlatformSpecificHandle(pthread_t handle)
 {
     std::lock_guard<std::mutex> locker(m_mutex);
     m_handle = handle;
-    if (!m_id) {
-        static std::atomic<ThreadIdentifier> provider { 0 };
-        m_id = ++provider;
 #if OS(DARWIN)
-        m_platformThread = pthread_mach_thread_np(handle);
+    m_platformThread = pthread_mach_thread_np(handle);
 #endif
-    }
 }
 
 #if !HAVE(FAST_TLS)
index bec0d34..a815904 100644 (file)
@@ -185,7 +185,7 @@ int Thread::waitForCompletion()
 
     DWORD joinResult = WaitForSingleObject(handle, INFINITE);
     if (joinResult == WAIT_FAILED)
-        LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", m_id);
+        LOG_ERROR("Thread %p was found to be deadlocked trying to quit", this);
 
     std::lock_guard<std::mutex> locker(m_mutex);
     ASSERT(joinableState() == Joinable);
@@ -216,7 +216,7 @@ void Thread::detach()
 
 auto Thread::suspend() -> Expected<void, PlatformSuspendError>
 {
-    RELEASE_ASSERT_WITH_MESSAGE(id() != currentThread(), "We do not support suspending the current thread itself.");
+    RELEASE_ASSERT_WITH_MESSAGE(this != &Thread::current(), "We do not support suspending the current thread itself.");
     LockHolder locker(globalSuspendLock);
     DWORD result = SuspendThread(m_handle);
     if (result != (DWORD)-1)
@@ -293,7 +293,7 @@ Thread* Thread::currentDying()
     ASSERT(s_key != InvalidThreadSpecificKey);
     // After FLS is destroyed, this map offers the value until the second thread exit callback is called.
     std::lock_guard<std::mutex> locker(threadMapMutex());
-    return threadMap().get(currentThread());
+    return threadMap().get(currentID());
 }
 
 // FIXME: Remove this workaround code once <rdar://problem/31793213> is fixed.
index 31d814b..299b999 100644 (file)
@@ -66,8 +66,8 @@ static pthread_t mainThreadPthread;
 static NSThread* mainThreadNSThread;
 
 #if USE(WEB_THREAD)
-static ThreadIdentifier sApplicationUIThreadIdentifier;
-static ThreadIdentifier sWebThreadIdentifier;
+static Thread* sApplicationUIThread;
+static Thread* sWebThread;
 #endif
 
 void initializeMainThreadPlatform()
@@ -173,16 +173,10 @@ bool isWebThread()
     return pthread_equal(pthread_self(), mainThreadPthread);
 }
 
-void initializeApplicationUIThreadIdentifier()
+void initializeApplicationUIThread()
 {
     ASSERT(pthread_main_np());
-    sApplicationUIThreadIdentifier = currentThread();
-}
-
-void initializeWebThreadIdentifier()
-{
-    ASSERT(!pthread_main_np());
-    sWebThreadIdentifier = currentThread();
+    sApplicationUIThread = &Thread::current();
 }
 
 void initializeWebThreadPlatform()
@@ -192,16 +186,18 @@ void initializeWebThreadPlatform()
     mainThreadEstablishedAsPthreadMain = false;
     mainThreadPthread = pthread_self();
     mainThreadNSThread = [[NSThread currentThread] retain];
+
+    sWebThread = &Thread::current();
 }
 
-bool canAccessThreadLocalDataForThread(ThreadIdentifier threadId)
+bool canAccessThreadLocalDataForThread(Thread& thread)
 {
-    ThreadIdentifier currentThreadId = currentThread();
-    if (threadId == currentThreadId)
+    Thread& currentThread = Thread::current();
+    if (&thread == &currentThread)
         return true;
 
-    if (threadId == sWebThreadIdentifier || threadId == sApplicationUIThreadIdentifier)
-        return (currentThreadId == sWebThreadIdentifier || currentThreadId == sApplicationUIThreadIdentifier) && webThreadIsUninitializedOrLockedOrDisabled();
+    if (&thread == sWebThread || &thread == sApplicationUIThread)
+        return (&currentThread == sWebThread || &currentThread == sApplicationUIThread) && webThreadIsUninitializedOrLockedOrDisabled();
 
     return false;
 }
index e166cf1..09babf5 100644 (file)
@@ -1,3 +1,355 @@
+2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        WTF shouldn't have both Thread and ThreadIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=180308
+
+        Reviewed by Darin Adler.
+
+        No behavior change.
+
+        * Modules/indexeddb/IDBActiveDOMObject.h:
+        (WebCore::IDBActiveDOMObject::originThread const):
+        (WebCore::IDBActiveDOMObject::performCallbackOnOriginThread):
+        (WebCore::IDBActiveDOMObject::callFunctionOnOriginThread):
+        (WebCore::IDBActiveDOMObject::originThreadID const): Deleted.
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::IDBCursor):
+        (WebCore::IDBCursor::~IDBCursor):
+        (WebCore::IDBCursor::sourcesDeleted const):
+        (WebCore::IDBCursor::transaction const):
+        (WebCore::IDBCursor::update):
+        (WebCore::IDBCursor::advance):
+        (WebCore::IDBCursor::continueFunction):
+        (WebCore::IDBCursor::uncheckedIterateCursor):
+        (WebCore::IDBCursor::deleteFunction):
+        (WebCore::IDBCursor::setGetResult):
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::~IDBDatabase):
+        (WebCore::IDBDatabase::hasPendingActivity const):
+        (WebCore::IDBDatabase::name const):
+        (WebCore::IDBDatabase::version const):
+        (WebCore::IDBDatabase::objectStoreNames const):
+        (WebCore::IDBDatabase::renameObjectStore):
+        (WebCore::IDBDatabase::renameIndex):
+        (WebCore::IDBDatabase::createObjectStore):
+        (WebCore::IDBDatabase::transaction):
+        (WebCore::IDBDatabase::deleteObjectStore):
+        (WebCore::IDBDatabase::close):
+        (WebCore::IDBDatabase::connectionToServerLost):
+        (WebCore::IDBDatabase::maybeCloseInServer):
+        (WebCore::IDBDatabase::activeDOMObjectName const):
+        (WebCore::IDBDatabase::canSuspendForDocumentSuspension const):
+        (WebCore::IDBDatabase::stop):
+        (WebCore::IDBDatabase::startVersionChangeTransaction):
+        (WebCore::IDBDatabase::didStartTransaction):
+        (WebCore::IDBDatabase::willCommitTransaction):
+        (WebCore::IDBDatabase::didCommitTransaction):
+        (WebCore::IDBDatabase::willAbortTransaction):
+        (WebCore::IDBDatabase::didAbortTransaction):
+        (WebCore::IDBDatabase::didCommitOrAbortTransaction):
+        (WebCore::IDBDatabase::fireVersionChangeEvent):
+        (WebCore::IDBDatabase::dispatchEvent):
+        (WebCore::IDBDatabase::didCreateIndexInfo):
+        (WebCore::IDBDatabase::didDeleteIndexInfo):
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::IDBIndex):
+        (WebCore::IDBIndex::~IDBIndex):
+        (WebCore::IDBIndex::name const):
+        (WebCore::IDBIndex::setName):
+        (WebCore::IDBIndex::objectStore):
+        (WebCore::IDBIndex::keyPath const):
+        (WebCore::IDBIndex::unique const):
+        (WebCore::IDBIndex::multiEntry const):
+        (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
+        (WebCore::IDBIndex::openCursor):
+        (WebCore::IDBIndex::openKeyCursor):
+        (WebCore::IDBIndex::doCount):
+        (WebCore::IDBIndex::doGet):
+        (WebCore::IDBIndex::doGetKey):
+        (WebCore::IDBIndex::getAll):
+        (WebCore::IDBIndex::getAllKeys):
+        (WebCore::IDBIndex::markAsDeleted):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::IDBObjectStore):
+        (WebCore::IDBObjectStore::~IDBObjectStore):
+        (WebCore::IDBObjectStore::name const):
+        (WebCore::IDBObjectStore::setName):
+        (WebCore::IDBObjectStore::keyPath const):
+        (WebCore::IDBObjectStore::indexNames const):
+        (WebCore::IDBObjectStore::transaction):
+        (WebCore::IDBObjectStore::autoIncrement const):
+        (WebCore::IDBObjectStore::openCursor):
+        (WebCore::IDBObjectStore::openKeyCursor):
+        (WebCore::IDBObjectStore::get):
+        (WebCore::IDBObjectStore::getKey):
+        (WebCore::IDBObjectStore::putOrAdd):
+        (WebCore::IDBObjectStore::doDelete):
+        (WebCore::IDBObjectStore::clear):
+        (WebCore::IDBObjectStore::createIndex):
+        (WebCore::IDBObjectStore::index):
+        (WebCore::IDBObjectStore::deleteIndex):
+        (WebCore::IDBObjectStore::doCount):
+        (WebCore::IDBObjectStore::getAll):
+        (WebCore::IDBObjectStore::getAllKeys):
+        (WebCore::IDBObjectStore::markAsDeleted):
+        (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
+        (WebCore::IDBOpenDBRequest::onError):
+        (WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
+        (WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
+        (WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
+        (WebCore::IDBOpenDBRequest::dispatchEvent):
+        (WebCore::IDBOpenDBRequest::onSuccess):
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
+        (WebCore::IDBOpenDBRequest::requestCompleted):
+        (WebCore::IDBOpenDBRequest::requestBlocked):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::~IDBRequest):
+        (WebCore:: const):
+        (WebCore::IDBRequest::setSource):
+        (WebCore::IDBRequest::setVersionChangeTransaction):
+        (WebCore::IDBRequest::transaction const):
+        (WebCore::IDBRequest::sourceObjectStoreIdentifier const):
+        (WebCore::IDBRequest::sourceIndexIdentifier const):
+        (WebCore::IDBRequest::requestedObjectStoreRecordType const):
+        (WebCore::IDBRequest::requestedIndexRecordType const):
+        (WebCore::IDBRequest::eventTargetInterface const):
+        (WebCore::IDBRequest::activeDOMObjectName const):
+        (WebCore::IDBRequest::canSuspendForDocumentSuspension const):
+        (WebCore::IDBRequest::hasPendingActivity const):
+        (WebCore::IDBRequest::stop):
+        (WebCore::IDBRequest::enqueueEvent):
+        (WebCore::IDBRequest::dispatchEvent):
+        (WebCore::IDBRequest::uncaughtExceptionInEventHandler):
+        (WebCore::IDBRequest::setResult):
+        (WebCore::IDBRequest::setResultToStructuredClone):
+        (WebCore::IDBRequest::setResultToUndefined):
+        (WebCore::IDBRequest::resultCursor):
+        (WebCore::IDBRequest::willIterateCursor):
+        (WebCore::IDBRequest::didOpenOrIterateCursor):
+        (WebCore::IDBRequest::completeRequestAndDispatchEvent):
+        (WebCore::IDBRequest::onError):
+        (WebCore::IDBRequest::onSuccess):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::IDBTransaction):
+        (WebCore::IDBTransaction::~IDBTransaction):
+        (WebCore::IDBTransaction::objectStoreNames const):
+        (WebCore::IDBTransaction::db):
+        (WebCore::IDBTransaction::error const):
+        (WebCore::IDBTransaction::objectStore):
+        (WebCore::IDBTransaction::abortDueToFailedRequest):
+        (WebCore::IDBTransaction::transitionedToFinishing):
+        (WebCore::IDBTransaction::abort):
+        (WebCore::IDBTransaction::internalAbort):
+        (WebCore::IDBTransaction::abortOnServerAndCancelRequests):
+        (WebCore::IDBTransaction::activeDOMObjectName const):
+        (WebCore::IDBTransaction::canSuspendForDocumentSuspension const):
+        (WebCore::IDBTransaction::hasPendingActivity const):
+        (WebCore::IDBTransaction::stop):
+        (WebCore::IDBTransaction::isActive const):
+        (WebCore::IDBTransaction::isFinishedOrFinishing const):
+        (WebCore::IDBTransaction::addRequest):
+        (WebCore::IDBTransaction::removeRequest):
+        (WebCore::IDBTransaction::scheduleOperation):
+        (WebCore::IDBTransaction::schedulePendingOperationTimer):
+        (WebCore::IDBTransaction::pendingOperationTimerFired):
+        (WebCore::IDBTransaction::operationCompletedOnServer):
+        (WebCore::IDBTransaction::scheduleCompletedOperationTimer):
+        (WebCore::IDBTransaction::completedOperationTimerFired):
+        (WebCore::IDBTransaction::commit):
+        (WebCore::IDBTransaction::commitOnServer):
+        (WebCore::IDBTransaction::finishAbortOrCommit):
+        (WebCore::IDBTransaction::didStart):
+        (WebCore::IDBTransaction::notifyDidAbort):
+        (WebCore::IDBTransaction::didAbort):
+        (WebCore::IDBTransaction::didCommit):
+        (WebCore::IDBTransaction::fireOnComplete):
+        (WebCore::IDBTransaction::fireOnAbort):
+        (WebCore::IDBTransaction::enqueueEvent):
+        (WebCore::IDBTransaction::dispatchEvent):
+        (WebCore::IDBTransaction::createObjectStore):
+        (WebCore::IDBTransaction::createObjectStoreOnServer):
+        (WebCore::IDBTransaction::didCreateObjectStoreOnServer):
+        (WebCore::IDBTransaction::renameObjectStore):
+        (WebCore::IDBTransaction::renameObjectStoreOnServer):
+        (WebCore::IDBTransaction::didRenameObjectStoreOnServer):
+        (WebCore::IDBTransaction::createIndex):
+        (WebCore::IDBTransaction::createIndexOnServer):
+        (WebCore::IDBTransaction::didCreateIndexOnServer):
+        (WebCore::IDBTransaction::renameIndex):
+        (WebCore::IDBTransaction::renameIndexOnServer):
+        (WebCore::IDBTransaction::didRenameIndexOnServer):
+        (WebCore::IDBTransaction::requestOpenCursor):
+        (WebCore::IDBTransaction::doRequestOpenCursor):
+        (WebCore::IDBTransaction::openCursorOnServer):
+        (WebCore::IDBTransaction::didOpenCursorOnServer):
+        (WebCore::IDBTransaction::iterateCursor):
+        (WebCore::IDBTransaction::iterateCursorOnServer):
+        (WebCore::IDBTransaction::didIterateCursorOnServer):
+        (WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
+        (WebCore::IDBTransaction::requestGetAllIndexRecords):
+        (WebCore::IDBTransaction::getAllRecordsOnServer):
+        (WebCore::IDBTransaction::didGetAllRecordsOnServer):
+        (WebCore::IDBTransaction::requestGetRecord):
+        (WebCore::IDBTransaction::requestGetValue):
+        (WebCore::IDBTransaction::requestGetKey):
+        (WebCore::IDBTransaction::requestIndexRecord):
+        (WebCore::IDBTransaction::getRecordOnServer):
+        (WebCore::IDBTransaction::didGetRecordOnServer):
+        (WebCore::IDBTransaction::requestCount):
+        (WebCore::IDBTransaction::getCountOnServer):
+        (WebCore::IDBTransaction::didGetCountOnServer):
+        (WebCore::IDBTransaction::requestDeleteRecord):
+        (WebCore::IDBTransaction::deleteRecordOnServer):
+        (WebCore::IDBTransaction::didDeleteRecordOnServer):
+        (WebCore::IDBTransaction::requestClearObjectStore):
+        (WebCore::IDBTransaction::clearObjectStoreOnServer):
+        (WebCore::IDBTransaction::didClearObjectStoreOnServer):
+        (WebCore::IDBTransaction::requestPutOrAdd):
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        (WebCore::IDBTransaction::didPutOrAddOnServer):
+        (WebCore::IDBTransaction::deleteObjectStore):
+        (WebCore::IDBTransaction::deleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::deleteIndex):
+        (WebCore::IDBTransaction::deleteIndexOnServer):
+        (WebCore::IDBTransaction::didDeleteIndexOnServer):
+        (WebCore::IDBTransaction::operationCompletedOnClient):
+        (WebCore::IDBTransaction::establishOnServer):
+        (WebCore::IDBTransaction::activate):
+        (WebCore::IDBTransaction::deactivate):
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::removeItemsMatchingCurrentThread):
+        * Modules/indexeddb/client/TransactionOperation.h:
+        (WebCore::IDBClient::TransactionOperation::~TransactionOperation):
+        (WebCore::IDBClient::TransactionOperation::perform):
+        (WebCore::IDBClient::TransactionOperation::transitionToCompleteOnThisThread):
+        (WebCore::IDBClient::TransactionOperation::transitionToComplete):
+        (WebCore::IDBClient::TransactionOperation::doComplete):
+        (WebCore::IDBClient::TransactionOperation::originThread const):
+        (WebCore::IDBClient::TransactionOperation::originThreadID const): Deleted.
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::AudioContext):
+        (WebCore::AudioContext::lock):
+        (WebCore::AudioContext::tryLock):
+        (WebCore::AudioContext::unlock):
+        (WebCore::AudioContext::isAudioThread const):
+        (WebCore::AudioContext::isGraphOwner const):
+        * Modules/webaudio/AudioContext.h:
+        (WebCore::AudioContext::setAudioThread):
+        (WebCore::AudioContext::audioThread const):
+        * Modules/webaudio/AudioDestinationNode.cpp:
+        (WebCore::AudioDestinationNode::render):
+        * Modules/webdatabase/Database.cpp:
+        (WebCore::Database::performClose):
+        (WebCore::Database::securityOrigin):
+        * Modules/webdatabase/DatabaseDetails.h:
+        (WebCore::DatabaseDetails::DatabaseDetails):
+        (WebCore::DatabaseDetails::operator=):
+        (WebCore::DatabaseDetails::thread const):
+        (WebCore::DatabaseDetails::threadID const): Deleted.
+        * Modules/webdatabase/DatabaseManager.cpp:
+        (WebCore::DatabaseManager::detailsForNameAndOrigin):
+        * Modules/webdatabase/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::databaseThread):
+        (WebCore::DatabaseThread::recordDatabaseOpen):
+        (WebCore::DatabaseThread::recordDatabaseClosed):
+        * Modules/webdatabase/DatabaseThread.h:
+        (WebCore::DatabaseThread::getThread):
+        (WebCore::DatabaseThread::getThreadID): Deleted.
+        * Modules/webdatabase/SQLTransaction.cpp:
+        (WebCore::SQLTransaction::checkAndHandleClosedDatabase):
+        * Modules/webdatabase/SQLTransactionBackend.cpp:
+        (WebCore::SQLTransactionBackend::doCleanup):
+        (WebCore::SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown):
+        * bindings/js/JSCallbackData.h:
+        (WebCore::JSCallbackData::JSCallbackData):
+        (WebCore::JSCallbackData::~JSCallbackData):
+        * bindings/js/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::execute):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::createdMessagePort):
+        (WebCore::ScriptExecutionContext::destroyedMessagePort):
+        * page/ResourceUsageOverlay.h:
+        * page/scrolling/ScrollingThread.cpp:
+        (WebCore::ScrollingThread::isCurrentThread):
+        * platform/Supplementable.h:
+        (WebCore::Supplementable::provideSupplement):
+        (WebCore::Supplementable::removeSupplement):
+        (WebCore::Supplementable::requireSupplement):
+        (WebCore::Supplementable::Supplementable): Deleted.
+        * platform/Timer.cpp:
+        (WebCore::TimerBase::TimerBase):
+        (WebCore::TimerBase::start):
+        (WebCore::TimerBase::stop):
+        (WebCore::TimerBase::setNextFireTime):
+        * platform/Timer.h:
+        (WebCore::TimerBase::isActive const):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::shouldAutoActivateFontIfNeeded):
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
+        (WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
+        (WebCore::TextureMapperPlatformLayerProxy::invalidate):
+        (WebCore::TextureMapperPlatformLayerProxy::getAvailableBuffer):
+        (WebCore::TextureMapperPlatformLayerProxy::appendToUnusedBuffers):
+        (WebCore::TextureMapperPlatformLayerProxy::swapBuffer):
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
+        (): Deleted.
+        * platform/ios/wak/WebCoreThread.mm:
+        (RunWebThread):
+        (StartWebThread):
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::SQLiteDatabase::open):
+        (WebCore::SQLiteDatabase::close):
+        * platform/sql/SQLiteDatabase.h:
+        (WebCore::SQLiteDatabase::sqlite3Handle const):
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::~WorkerGlobalScope):
+        (WebCore::WorkerGlobalScope::isContextThread const):
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
+        (WebCore::WorkerMessagingProxy::~WorkerMessagingProxy):
+        * workers/WorkerRunLoop.cpp:
+        (WebCore::WorkerRunLoop::runInMode):
+        (WebCore::WorkerRunLoop::runCleanupTasks):
+        * workers/WorkerThread.h:
+        (WebCore::WorkerThread::thread const):
+        (WebCore::WorkerThread::threadID const): Deleted.
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::~ServiceWorkerContainer):
+        (WebCore::ServiceWorkerContainer::scheduleJob):
+        (WebCore::ServiceWorkerContainer::jobFailedWithException):
+        (WebCore::ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent):
+        (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+        (WebCore::ServiceWorkerContainer::jobResolvedWithUnregistrationResult):
+        (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
+        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
+        (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
+        (WebCore::ServiceWorkerContainer::jobDidFinish):
+        (WebCore::ServiceWorkerContainer::addRegistration):
+        (WebCore::ServiceWorkerContainer::removeRegistration):
+        (WebCore::ServiceWorkerContainer::scheduleTaskToFireControllerChangeEvent):
+        (WebCore::ServiceWorkerContainer::contextIdentifier):
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerJob.cpp:
+        (WebCore::ServiceWorkerJob::~ServiceWorkerJob):
+        (WebCore::ServiceWorkerJob::failedWithException):
+        (WebCore::ServiceWorkerJob::resolvedWithRegistration):
+        (WebCore::ServiceWorkerJob::resolvedWithUnregistrationResult):
+        (WebCore::ServiceWorkerJob::startScriptFetch):
+        (WebCore::ServiceWorkerJob::fetchScriptWithContext):
+        (WebCore::ServiceWorkerJob::didReceiveResponse):
+        (WebCore::ServiceWorkerJob::notifyFinished):
+        * workers/service/ServiceWorkerJob.h:
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::matchFunc):
+        (WebCore::openFunc):
+        (WebCore::initializeXMLParser):
+        (WebCore::XMLParserContext::createStringParser):
+        (WebCore::XMLParserContext::createMemoryParser):
+
 2017-12-03  Youenn Fablet  <youenn@apple.com>
 
         WebSocketChannel should ensure its client is live when calling it in error case
index 13f3121..2b42c06 100644 (file)
@@ -35,10 +35,10 @@ namespace WebCore {
 
 class IDBActiveDOMObject : public ActiveDOMObject {
 public:
-    ThreadIdentifier originThreadID() const { return m_originThreadID; }
+    Thread& originThread() const { return m_originThread.get(); }
 
     void contextDestroyed() final {
-        ASSERT(currentThread() == m_originThreadID);
+        ASSERT(m_originThread.ptr() == &Thread::current());
 
         Locker<Lock> lock(m_scriptExecutionContextLock);
         ActiveDOMObject::contextDestroyed();
@@ -47,9 +47,9 @@ public:
     template<typename T, typename... Parameters, typename... Arguments>
     void performCallbackOnOriginThread(T& object, void (T::*method)(Parameters...), Arguments&&... arguments)
     {
-        ASSERT(originThreadID() == object.originThreadID());
+        ASSERT(&originThread() == &object.originThread());
 
-        if (object.originThreadID() == currentThread()) {
+        if (&object.originThread() == &Thread::current()) {
             (object.*method)(arguments...);
             return;
         }
@@ -65,7 +65,7 @@ public:
 
     void callFunctionOnOriginThread(WTF::Function<void ()>&& function)
     {
-        if (originThreadID() == currentThread()) {
+        if (&originThread() == &Thread::current()) {
             function();
             return;
         }
@@ -87,7 +87,7 @@ protected:
     }
 
 private:
-    ThreadIdentifier m_originThreadID { currentThread() };
+    Ref<Thread> m_originThread { Thread::current() };
     Lock m_scriptExecutionContextLock;
 };
 
index 62fa151..4112ead 100644 (file)
@@ -61,7 +61,7 @@ IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, c
     , m_info(info)
     , m_source(&objectStore)
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     suspendIfNeeded();
 }
@@ -71,19 +71,19 @@ IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCurs
     , m_info(info)
     , m_source(&index)
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     suspendIfNeeded();
 }
 
 IDBCursor::~IDBCursor()
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 }
 
 bool IDBCursor::sourcesDeleted() const
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     return WTF::switchOn(m_source,
         [] (const RefPtr<IDBObjectStore>& objectStore) { return objectStore->isDeleted(); },
@@ -101,14 +101,14 @@ IDBObjectStore& IDBCursor::effectiveObjectStore() const
 
 IDBTransaction& IDBCursor::transaction() const
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
     return effectiveObjectStore().transaction();
 }
 
 ExceptionOr<Ref<IDBRequest>> IDBCursor::update(ExecState& state, JSValue value)
 {
     LOG(IndexedDB, "IDBCursor::update");
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     if (sourcesDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor's source or effective object store has been deleted.") };
@@ -149,7 +149,7 @@ ExceptionOr<Ref<IDBRequest>> IDBCursor::update(ExecState& state, JSValue value)
 ExceptionOr<void> IDBCursor::advance(unsigned count)
 {
     LOG(IndexedDB, "IDBCursor::advance");
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     if (!m_request)
         return Exception { InvalidStateError };
@@ -234,7 +234,7 @@ ExceptionOr<void> IDBCursor::continueFunction(ExecState& execState, JSValue keyV
 ExceptionOr<void> IDBCursor::continueFunction(const IDBKeyData& key)
 {
     LOG(IndexedDB, "IDBCursor::continueFunction (to key %s)", key.loggingString().utf8().data());
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     if (!m_request)
         return Exception { InvalidStateError };
@@ -268,7 +268,7 @@ ExceptionOr<void> IDBCursor::continueFunction(const IDBKeyData& key)
 
 void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count)
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     ++m_outstandingRequestCount;
 
@@ -278,7 +278,7 @@ void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count)
 
 void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, const IDBKeyData& primaryKey)
 {
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     ++m_outstandingRequestCount;
 
@@ -289,7 +289,7 @@ void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, const IDBKeyData&
 ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(ExecState& state)
 {
     LOG(IndexedDB, "IDBCursor::deleteFunction");
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     if (sourcesDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor's source or effective object store has been deleted.") };
@@ -320,7 +320,7 @@ ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(ExecState& state
 void IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
 {
     LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().substring(0, 100).utf8().data());
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
+    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
 
     auto* context = request.scriptExecutionContext();
     if (!context)
index 8f6e775..1093219 100644 (file)
@@ -64,7 +64,7 @@ IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnecti
 
 IDBDatabase::~IDBDatabase()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_closedInServer)
         m_connectionProxy->databaseConnectionClosed(*this);
@@ -74,7 +74,7 @@ IDBDatabase::~IDBDatabase()
 
 bool IDBDatabase::hasPendingActivity() const
 {
-    ASSERT(currentThread() == originThreadID() || mayBeGCThread());
+    ASSERT(&originThread() == &Thread::current() || mayBeGCThread());
 
     if (m_closedInServer)
         return false;
@@ -87,19 +87,19 @@ bool IDBDatabase::hasPendingActivity() const
 
 const String IDBDatabase::name() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     return m_info.name();
 }
 
 uint64_t IDBDatabase::version() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     return m_info.version();
 }
 
 RefPtr<DOMStringList> IDBDatabase::objectStoreNames() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     RefPtr<DOMStringList> objectStoreNames = DOMStringList::create();
     for (auto& name : m_info.objectStoreNames())
@@ -110,7 +110,7 @@ RefPtr<DOMStringList> IDBDatabase::objectStoreNames() const
 
 void IDBDatabase::renameObjectStore(IDBObjectStore& objectStore, const String& newName)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(m_versionChangeTransaction);
     ASSERT(m_info.hasObjectStore(objectStore.info().name()));
 
@@ -121,7 +121,7 @@ void IDBDatabase::renameObjectStore(IDBObjectStore& objectStore, const String& n
 
 void IDBDatabase::renameIndex(IDBIndex& index, const String& newName)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(m_versionChangeTransaction);
     ASSERT(m_info.hasObjectStore(index.objectStore().info().name()));
     ASSERT(m_info.infoForExistingObjectStore(index.objectStore().info().name())->hasIndex(index.info().name()));
@@ -135,7 +135,7 @@ ExceptionOr<Ref<IDBObjectStore>> IDBDatabase::createObjectStore(const String& na
 {
     LOG(IndexedDB, "IDBDatabase::createObjectStore - (%s %s)", m_info.name().utf8().data(), name.utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_versionChangeTransaction || m_versionChangeTransaction->isVersionChange());
 
     if (!m_versionChangeTransaction)
@@ -165,7 +165,7 @@ ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfString
 {
     LOG(IndexedDB, "IDBDatabase::transaction");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_closePending)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.") };
@@ -215,7 +215,7 @@ ExceptionOr<void> IDBDatabase::deleteObjectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBDatabase::deleteObjectStore");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_versionChangeTransaction)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'deleteObjectStore' on 'IDBDatabase': The database is not running a version change transaction.") };
@@ -236,7 +236,7 @@ void IDBDatabase::close()
 {
     LOG(IndexedDB, "IDBDatabase::close - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_closePending) {
         m_closePending = true;
@@ -259,7 +259,7 @@ void IDBDatabase::connectionToServerLost(const IDBError& error)
 {
     LOG(IndexedDB, "IDBDatabase::connectionToServerLost - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     m_closePending = true;
     m_closedInServer = true;
@@ -284,7 +284,7 @@ void IDBDatabase::maybeCloseInServer()
 {
     LOG(IndexedDB, "IDBDatabase::maybeCloseInServer - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_closedInServer)
         return;
@@ -301,13 +301,13 @@ void IDBDatabase::maybeCloseInServer()
 
 const char* IDBDatabase::activeDOMObjectName() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     return "IDBDatabase";
 }
 
 bool IDBDatabase::canSuspendForDocumentSuspension() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     // FIXME: This value will sometimes be false when database operations are actually in progress.
     // Such database operations do not yet exist.
@@ -318,7 +318,7 @@ void IDBDatabase::stop()
 {
     LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     removeAllEventListeners();
 
@@ -341,7 +341,7 @@ Ref<IDBTransaction> IDBDatabase::startVersionChangeTransaction(const IDBTransact
 {
     LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction %s", info.identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_versionChangeTransaction);
     ASSERT(info.mode() == IDBTransactionMode::Versionchange);
     ASSERT(!m_closePending);
@@ -359,7 +359,7 @@ void IDBDatabase::didStartTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didStartTransaction %s", transaction.info().identifier().loggingString().utf8().data());
     ASSERT(!m_versionChangeTransaction);
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     // It is possible for the client to have aborted a transaction before the server replies back that it has started.
     if (m_abortingTransactions.contains(transaction.info().identifier()))
@@ -372,7 +372,7 @@ void IDBDatabase::willCommitTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::willCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
     ASSERT(refTransaction);
@@ -383,7 +383,7 @@ void IDBDatabase::didCommitTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_versionChangeTransaction == &transaction)
         m_info.setVersion(transaction.info().newVersion());
@@ -395,7 +395,7 @@ void IDBDatabase::willAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::willAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
     if (!refTransaction)
@@ -415,7 +415,7 @@ void IDBDatabase::didAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (transaction.isVersionChange()) {
         ASSERT(transaction.originalDatabaseInfo());
@@ -431,7 +431,7 @@ void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_versionChangeTransaction == &transaction)
         m_versionChangeTransaction = nullptr;
@@ -461,7 +461,7 @@ void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIde
     uint64_t currentVersion = m_info.version();
     LOG(IndexedDB, "IDBDatabase::fireVersionChangeEvent - current version %" PRIu64 ", requested version %" PRIu64 ", connection %" PRIu64 " (%p)", currentVersion, requestedVersion, m_databaseConnectionIdentifier, this);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!scriptExecutionContext() || m_closePending) {
         connectionProxy().didFireVersionChangeEvent(m_databaseConnectionIdentifier, requestIdentifier);
@@ -476,7 +476,7 @@ void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIde
 void IDBDatabase::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBDatabase::dispatchEvent (%" PRIu64 ") (%p)", m_databaseConnectionIdentifier, this);
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto protectedThis = makeRef(*this);
 
@@ -488,7 +488,7 @@ void IDBDatabase::dispatchEvent(Event& event)
 
 void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
     ASSERT(objectStore);
@@ -497,7 +497,7 @@ void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
 
 void IDBDatabase::didDeleteIndexInfo(const IDBIndexInfo& info)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
     ASSERT(objectStore);
index 497dec1..1e0ab99 100644 (file)
@@ -48,14 +48,14 @@ IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, ID
     , m_originalInfo(info)
     , m_objectStore(objectStore)
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     suspendIfNeeded();
 }
 
 IDBIndex::~IDBIndex()
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 }
 
 const char* IDBIndex::activeDOMObjectName() const
@@ -75,13 +75,13 @@ bool IDBIndex::hasPendingActivity() const
 
 const String& IDBIndex::name() const
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
     return m_info.name();
 }
 
 ExceptionOr<void> IDBIndex::setName(const String& name)
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed set property 'name' on 'IDBIndex': The index has been deleted.") };
@@ -109,31 +109,31 @@ ExceptionOr<void> IDBIndex::setName(const String& name)
 
 IDBObjectStore& IDBIndex::objectStore()
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
     return m_objectStore;
 }
 
 const IDBKeyPath& IDBIndex::keyPath() const
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
     return m_info.keyPath();
 }
 
 bool IDBIndex::unique() const
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
     return m_info.unique();
 }
 
 bool IDBIndex::multiEntry() const
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
     return m_info.multiEntry();
 }
 
 void IDBIndex::rollbackInfoForVersionChangeAbort()
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     // Only rollback to the original info if this index still exists in the rolled-back database info.
     auto* objectStoreInfo = m_objectStore.transaction().database().info().infoForExistingObjectStore(m_objectStore.info().identifier());
@@ -152,7 +152,7 @@ void IDBIndex::rollbackInfoForVersionChangeAbort()
 ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBIndex::openCursor");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -173,7 +173,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, IDBKeyRa
 ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue key, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBIndex::openCursor");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     auto keyRange = IDBKeyRange::only(execState, key);
     if (keyRange.hasException())
@@ -185,7 +185,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue
 ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBIndex::openKeyCursor");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -227,7 +227,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::count(ExecState& execState, JSValue key)
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doCount(ExecState& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -262,7 +262,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::get(ExecState& execState, JSValue key)
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGet(ExecState& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -297,7 +297,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getKey(ExecState& execState, JSValue key)
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(ExecState& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -315,7 +315,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(ExecState& execState, const IDBK
 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(ExecState& execState, RefPtr<IDBKeyRange> range, std::optional<uint32_t> count)
 {
     LOG(IndexedDB, "IDBIndex::getAll");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getAll' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -338,7 +338,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(ExecState& execState, JSValue key,
 ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange> range, std::optional<uint32_t> count)
 {
     LOG(IndexedDB, "IDBIndex::getAllKeys");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getAllKeys' on 'IDBIndex': The index or its object store has been deleted.") };
@@ -360,7 +360,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(ExecState& execState, JSValue
 
 void IDBIndex::markAsDeleted()
 {
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
 
     ASSERT(!m_deleted);
     m_deleted = true;
index 08a784b..2858957 100644 (file)
@@ -61,14 +61,14 @@ IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectS
     , m_originalInfo(info)
     , m_transaction(transaction)
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     suspendIfNeeded();
 }
 
 IDBObjectStore::~IDBObjectStore()
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 }
 
 const char* IDBObjectStore::activeDOMObjectName() const
@@ -88,13 +88,13 @@ bool IDBObjectStore::hasPendingActivity() const
 
 const String& IDBObjectStore::name() const
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
     return m_info.name();
 }
 
 ExceptionOr<void> IDBObjectStore::setName(const String& name)
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed set property 'name' on 'IDBObjectStore': The object store has been deleted.") };
@@ -119,13 +119,13 @@ ExceptionOr<void> IDBObjectStore::setName(const String& name)
 
 const std::optional<IDBKeyPath>& IDBObjectStore::keyPath() const
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
     return m_info.keyPath();
 }
 
 RefPtr<DOMStringList> IDBObjectStore::indexNames() const
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     RefPtr<DOMStringList> indexNames = DOMStringList::create();
 
@@ -140,20 +140,20 @@ RefPtr<DOMStringList> IDBObjectStore::indexNames() const
 
 IDBTransaction& IDBObjectStore::transaction()
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
     return m_transaction;
 }
 
 bool IDBObjectStore::autoIncrement() const
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
     return m_info.autoIncrement();
 }
 
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBObjectStore::openCursor");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The object store has been deleted.") };
@@ -177,7 +177,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, JS
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBObjectStore::openCursor");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBObjectStore': The object store has been deleted.") };
@@ -201,7 +201,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState,
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(ExecState& execState, JSValue key)
 {
     LOG(IndexedDB, "IDBObjectStore::get");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.") };
@@ -219,7 +219,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(ExecState& execState, JSValue k
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(ExecState& execState, IDBKeyRange* keyRange)
 {
     LOG(IndexedDB, "IDBObjectStore::get");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted.") };
@@ -237,7 +237,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(ExecState& execState, IDBKeyRan
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(ExecState& execState, JSValue key)
 {
     LOG(IndexedDB, "IDBObjectStore::getKey");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getKey' on 'IDBObjectStore': The object store has been deleted.") };
@@ -255,7 +255,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(ExecState& execState, JSValu
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(ExecState& execState, IDBKeyRange* keyRange)
 {
     LOG(IndexedDB, "IDBObjectStore::getKey");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getKey' on 'IDBObjectStore': The object store has been deleted.") };
@@ -297,7 +297,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::putOrAdd(ExecState& state, JSValue
     auto scope = DECLARE_CATCH_SCOPE(vm);
 
     LOG(IndexedDB, "IDBObjectStore::putOrAdd");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     auto context = scriptExecutionContextFromExecState(&state);
     if (!context)
@@ -369,7 +369,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(ExecState& execState
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doDelete(ExecState& execState, IDBKeyRange* keyRange)
 {
     LOG(IndexedDB, "IDBObjectStore::deleteFunction");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -403,7 +403,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(ExecState& execState
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::clear(ExecState& execState)
 {
     LOG(IndexedDB, "IDBObjectStore::clear");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -425,7 +425,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::clear(ExecState& execState)
 ExceptionOr<Ref<IDBIndex>> IDBObjectStore::createIndex(ExecState&, const String& name, IDBKeyPath&& keyPath, const IndexParameters& parameters)
 {
     LOG(IndexedDB, "IDBObjectStore::createIndex %s (keyPath: %s, unique: %i, multiEntry: %i)", name.utf8().data(), loggingString(keyPath).utf8().data(), parameters.unique, parameters.multiEntry);
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (!m_transaction.isVersionChange())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'createIndex' on 'IDBObjectStore': The database is not running a version change transaction.") };
@@ -466,7 +466,7 @@ ExceptionOr<Ref<IDBIndex>> IDBObjectStore::createIndex(ExecState&, const String&
 ExceptionOr<Ref<IDBIndex>> IDBObjectStore::index(const String& indexName)
 {
     LOG(IndexedDB, "IDBObjectStore::index");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (!scriptExecutionContext())
         return Exception { InvalidStateError }; // FIXME: Is this code tested? Is iteven reachable?
@@ -498,7 +498,7 @@ ExceptionOr<Ref<IDBIndex>> IDBObjectStore::index(const String& indexName)
 ExceptionOr<void> IDBObjectStore::deleteIndex(const String& name)
 {
     LOG(IndexedDB, "IDBObjectStore::deleteIndex %s", name.utf8().data());
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'deleteIndex' on 'IDBObjectStore': The object store has been deleted.") };
@@ -551,7 +551,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::count(ExecState& execState, IDBKeyR
 
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doCount(ExecState& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -573,7 +573,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doCount(ExecState& execState, const
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAll(ExecState& execState, RefPtr<IDBKeyRange> range, std::optional<uint32_t> count)
 {
     LOG(IndexedDB, "IDBObjectStore::getAll");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getAll' on 'IDBObjectStore': The object store has been deleted.") };
@@ -596,7 +596,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAll(ExecState& execState, JSValu
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(ExecState& execState, RefPtr<IDBKeyRange> range, std::optional<uint32_t> count)
 {
     LOG(IndexedDB, "IDBObjectStore::getAllKeys");
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     if (m_deleted)
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'getAllKeys' on 'IDBObjectStore': The object store has been deleted.") };
@@ -618,13 +618,13 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(ExecState& execState, JS
 
 void IDBObjectStore::markAsDeleted()
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
     m_deleted = true;
 }
 
 void IDBObjectStore::rollbackForVersionChangeAbort()
 {
-    ASSERT(currentThread() == m_transaction.database().originThreadID());
+    ASSERT(&m_transaction.database().originThread() == &Thread::current());
 
     String currentName = m_info.name();
     m_info = m_originalInfo;
index 78da970..57db0a0 100644 (file)
@@ -63,12 +63,12 @@ IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, IDBClient::I
 
 IDBOpenDBRequest::~IDBOpenDBRequest()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 }
 
 void IDBOpenDBRequest::onError(const IDBResultData& data)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     m_domError = data.error().toDOMException();
     enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, true, true, *this));
@@ -76,7 +76,7 @@ void IDBOpenDBRequest::onError(const IDBResultData& data)
 
 void IDBOpenDBRequest::versionChangeTransactionDidFinish()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     // 3.3.7 "versionchange" transaction steps
     // When the transaction is finished, after firing complete/abort on the transaction, immediately set request's transaction property to null.
@@ -87,7 +87,7 @@ void IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()
 {
     LOG(IndexedDB, "IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit() - %s", resourceIdentifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(hasPendingActivity());
     m_transaction->addRequest(*this);
 
@@ -101,7 +101,7 @@ void IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()
 {
     LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion() - %s", resourceIdentifier().loggingString().utf8().data());
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(hasPendingActivity());
 
     IDBError idbError(AbortError);
@@ -119,7 +119,7 @@ void IDBOpenDBRequest::cancelForStop()
 
 void IDBOpenDBRequest::dispatchEvent(Event& event)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto protectedThis = makeRef(*this);
 
@@ -133,7 +133,7 @@ void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     setResult(IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData));
     m_readyState = ReadyState::Done;
@@ -143,7 +143,7 @@ void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
 
 void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData);
     Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
@@ -166,7 +166,7 @@ void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
 
 void IDBOpenDBRequest::onDeleteDatabaseSuccess(const IDBResultData& resultData)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     uint64_t oldVersion = resultData.databaseInfo().version();
 
@@ -182,7 +182,7 @@ void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
 {
     LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     // If an Open request was completed after the page has navigated, leaving this request
     // with a stopped script execution context, we need to message back to the server so it
@@ -222,7 +222,7 @@ void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
 
 void IDBOpenDBRequest::requestBlocked(uint64_t oldVersion, uint64_t newVersion)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     LOG(IndexedDB, "IDBOpenDBRequest::requestBlocked");
     enqueueEvent(IDBVersionChangeEvent::create(oldVersion, newVersion, eventNames().blockedEvent));
index cdc9baf..c9cadec 100644 (file)
@@ -143,7 +143,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, Indexed
 
 IDBRequest::~IDBRequest()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_result) {
         WTF::switchOn(m_result.value(),
@@ -163,7 +163,7 @@ ExceptionOr<std::optional<IDBRequest::Result>> IDBRequest::result() const
 
 ExceptionOr<DOMException*> IDBRequest::error() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!isDone())
         return Exception { InvalidStateError, ASCIILiteral("Failed to read the 'error' property from 'IDBRequest': The request has not finished.") };
@@ -173,7 +173,7 @@ ExceptionOr<DOMException*> IDBRequest::error() const
 
 void IDBRequest::setSource(IDBCursor& cursor)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_cursorRequestNotifier);
 
     m_source = Source { &cursor };
@@ -185,7 +185,7 @@ void IDBRequest::setSource(IDBCursor& cursor)
 
 void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_transaction);
     ASSERT(transaction.isVersionChange());
     ASSERT(!transaction.isFinishedOrFinishing());
@@ -195,13 +195,13 @@ void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
 
 RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     return m_shouldExposeTransactionToDOM ? m_transaction : nullptr;
 }
 
 uint64_t IDBRequest::sourceObjectStoreIdentifier() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_source)
         return 0;
@@ -215,7 +215,7 @@ uint64_t IDBRequest::sourceObjectStoreIdentifier() const
 
 uint64_t IDBRequest::sourceIndexIdentifier() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_source)
         return 0;
@@ -229,14 +229,14 @@ uint64_t IDBRequest::sourceIndexIdentifier() const
 
 IndexedDB::ObjectStoreRecordType IDBRequest::requestedObjectStoreRecordType() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     return m_requestedObjectStoreRecordType;
 }
 
 IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(m_source);
     ASSERT(WTF::holds_alternative<RefPtr<IDBIndex>>(m_source.value()));
 
@@ -245,33 +245,33 @@ IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
 
 EventTargetInterface IDBRequest::eventTargetInterface() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     return IDBRequestEventTargetInterfaceType;
 }
 
 const char* IDBRequest::activeDOMObjectName() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     return "IDBRequest";
 }
 
 bool IDBRequest::canSuspendForDocumentSuspension() const
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     return false;
 }
 
 bool IDBRequest::hasPendingActivity() const
 {
-    ASSERT(currentThread() == originThreadID() || mayBeGCThread());
+    ASSERT(&originThread() == &Thread::current() || mayBeGCThread());
     return m_hasPendingActivity;
 }
 
 void IDBRequest::stop()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_contextStopped);
 
     cancelForStop();
@@ -288,7 +288,7 @@ void IDBRequest::cancelForStop()
 
 void IDBRequest::enqueueEvent(Ref<Event>&& event)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     if (!scriptExecutionContext() || m_contextStopped)
         return;
 
@@ -300,7 +300,7 @@ void IDBRequest::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBRequest::dispatchEvent - %s (%p)", event.type().string().utf8().data(), this);
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(m_hasPendingActivity);
     ASSERT(!m_contextStopped);
 
@@ -347,7 +347,7 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 {
     LOG(IndexedDB, "IDBRequest::uncaughtExceptionInEventHandler");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (m_transaction && m_idbError.code() != AbortError)
         m_transaction->abortDueToFailedRequest(DOMException::create(AbortError, ASCIILiteral("IDBTransaction will abort due to uncaught exception in an event handler")));
@@ -355,7 +355,7 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 
 void IDBRequest::setResult(const IDBKeyData& keyData)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -374,7 +374,7 @@ void IDBRequest::setResult(const IDBKeyData& keyData)
 
 void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -393,7 +393,7 @@ void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
 
 void IDBRequest::setResult(const Vector<IDBValue>& values)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -412,7 +412,7 @@ void IDBRequest::setResult(const Vector<IDBValue>& values)
 
 void IDBRequest::setResult(uint64_t number)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -423,7 +423,7 @@ void IDBRequest::setResult(uint64_t number)
 
 void IDBRequest::setResultToStructuredClone(const IDBValue& value)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     LOG(IndexedDB, "IDBRequest::setResultToStructuredClone");
 
@@ -444,7 +444,7 @@ void IDBRequest::setResultToStructuredClone(const IDBValue& value)
 
 void IDBRequest::setResultToUndefined()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -455,7 +455,7 @@ void IDBRequest::setResultToUndefined()
 
 IDBCursor* IDBRequest::resultCursor()
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     if (!m_result)
         return nullptr;
@@ -468,7 +468,7 @@ IDBCursor* IDBRequest::resultCursor()
 
 void IDBRequest::willIterateCursor(IDBCursor& cursor)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(isDone());
     ASSERT(scriptExecutionContext());
     ASSERT(m_transaction);
@@ -490,7 +490,7 @@ void IDBRequest::willIterateCursor(IDBCursor& cursor)
 
 void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(m_pendingCursor);
 
     m_result = std::nullopt;
@@ -509,7 +509,7 @@ void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
 
 void IDBRequest::completeRequestAndDispatchEvent(const IDBResultData& resultData)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     m_readyState = ReadyState::Done;
 
@@ -524,7 +524,7 @@ void IDBRequest::onError()
 {
     LOG(IndexedDB, "IDBRequest::onError");
 
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!m_idbError.isNull());
 
     m_domError = m_idbError.toDOMException();
@@ -534,14 +534,14 @@ void IDBRequest::onError()
 void IDBRequest::onSuccess()
 {
     LOG(IndexedDB, "IDBRequest::onSuccess");
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     enqueueEvent(Event::create(eventNames().successEvent, false, false));
 }
 
 void IDBRequest::setResult(Ref<IDBDatabase>&& database)
 {
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
 
     m_result = Result { RefPtr<IDBDatabase> { WTFMove(database) } };
 }
index c1e1def..a9d640e 100644 (file)
@@ -80,7 +80,7 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo&
 
 {
     LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (m_info.mode() == IDBTransactionMode::Versionchange) {
         ASSERT(m_openDBRequest);
@@ -106,7 +106,7 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo&
 
 IDBTransaction::~IDBTransaction()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 }
 
 IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy()
@@ -116,7 +116,7 @@ IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy()
 
 Ref<DOMStringList> IDBTransaction::objectStoreNames() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     const Vector<String> names = isVersionChange() ? m_database->info().objectStoreNames() : m_info.objectStores();
 
@@ -130,20 +130,20 @@ Ref<DOMStringList> IDBTransaction::objectStoreNames() const
 
 IDBDatabase* IDBTransaction::db()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     return m_database.ptr();
 }
 
 DOMException* IDBTransaction::error() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     return m_domError.get();
 }
 
 ExceptionOr<Ref<IDBObjectStore>> IDBTransaction::objectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBTransaction::objectStore");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!scriptExecutionContext())
         return Exception { InvalidStateError };
@@ -183,7 +183,7 @@ ExceptionOr<Ref<IDBObjectStore>> IDBTransaction::objectStore(const String& objec
 void IDBTransaction::abortDueToFailedRequest(DOMException& error)
 {
     LOG(IndexedDB, "IDBTransaction::abortDueToFailedRequest");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (isFinishedOrFinishing())
         return;
@@ -194,7 +194,7 @@ void IDBTransaction::abortDueToFailedRequest(DOMException& error)
 
 void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT(!isFinishedOrFinishing());
     m_state = state;
@@ -204,7 +204,7 @@ void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
 ExceptionOr<void> IDBTransaction::abort()
 {
     LOG(IndexedDB, "IDBTransaction::abort");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (isFinishedOrFinishing())
         return Exception { InvalidStateError, ASCIILiteral("Failed to execute 'abort' on 'IDBTransaction': The transaction is inactive or finished.") };
@@ -217,7 +217,7 @@ ExceptionOr<void> IDBTransaction::abort()
 void IDBTransaction::internalAbort()
 {
     LOG(IndexedDB, "IDBTransaction::internalAbort");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(!isFinishedOrFinishing());
 
     m_database->willAbortTransaction(*this);
@@ -281,7 +281,7 @@ void IDBTransaction::abortInProgressOperations(const IDBError& error)
 void IDBTransaction::abortOnServerAndCancelRequests(IDBClient::TransactionOperation& operation)
 {
     LOG(IndexedDB, "IDBTransaction::abortOnServerAndCancelRequests");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(m_pendingTransactionOperationQueue.isEmpty());
 
     m_database->connectionProxy().abortTransaction(*this);
@@ -309,26 +309,26 @@ void IDBTransaction::abortOnServerAndCancelRequests(IDBClient::TransactionOperat
 
 const char* IDBTransaction::activeDOMObjectName() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     return "IDBTransaction";
 }
 
 bool IDBTransaction::canSuspendForDocumentSuspension() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     return false;
 }
 
 bool IDBTransaction::hasPendingActivity() const
 {
-    ASSERT(currentThread() == m_database->originThreadID() || mayBeGCThread());
+    ASSERT(&m_database->originThread() == &Thread::current() || mayBeGCThread());
     return !m_contextStopped && m_state != IndexedDB::TransactionState::Finished;
 }
 
 void IDBTransaction::stop()
 {
     LOG(IndexedDB, "IDBTransaction::stop - %s", m_info.loggingString().utf8().data());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     // IDBDatabase::stop() calls IDBTransaction::stop() for each of its active transactions.
     // Since the order of calling ActiveDOMObject::stop() is random, we might already have been stopped.
@@ -347,13 +347,13 @@ void IDBTransaction::stop()
 
 bool IDBTransaction::isActive() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     return m_state == IndexedDB::TransactionState::Active;
 }
 
 bool IDBTransaction::isFinishedOrFinishing() const
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     return m_state == IndexedDB::TransactionState::Committing
         || m_state == IndexedDB::TransactionState::Aborting
@@ -362,13 +362,13 @@ bool IDBTransaction::isFinishedOrFinishing() const
 
 void IDBTransaction::addRequest(IDBRequest& request)
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     m_openRequests.add(&request);
 }
 
 void IDBTransaction::removeRequest(IDBRequest& request)
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(m_openRequests.contains(&request));
     m_openRequests.remove(&request);
 }
@@ -376,7 +376,7 @@ void IDBTransaction::removeRequest(IDBRequest& request)
 void IDBTransaction::scheduleOperation(RefPtr<IDBClient::TransactionOperation>&& operation)
 {
     ASSERT(!m_transactionOperationMap.contains(operation->identifier()));
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_pendingTransactionOperationQueue.append(operation);
     m_transactionOperationMap.set(operation->identifier(), WTFMove(operation));
@@ -386,7 +386,7 @@ void IDBTransaction::scheduleOperation(RefPtr<IDBClient::TransactionOperation>&&
 
 void IDBTransaction::schedulePendingOperationTimer()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!m_pendingOperationTimer.isActive())
         m_pendingOperationTimer.startOneShot(0_s);
@@ -395,7 +395,7 @@ void IDBTransaction::schedulePendingOperationTimer()
 void IDBTransaction::pendingOperationTimerFired()
 {
     LOG(IndexedDB, "IDBTransaction::pendingOperationTimerFired (%p)", this);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!m_startedOnServer)
         return;
@@ -429,8 +429,8 @@ void IDBTransaction::pendingOperationTimerFired()
 
 void IDBTransaction::operationCompletedOnServer(const IDBResultData& data, IDBClient::TransactionOperation& operation)
 {
-    ASSERT(currentThread() == m_database->originThreadID());
-    ASSERT(currentThread() == operation.originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(&operation.originThread() == &Thread::current());
 
     m_completedOnServerQueue.append({ &operation, data });
     scheduleCompletedOperationTimer();
@@ -438,7 +438,7 @@ void IDBTransaction::operationCompletedOnServer(const IDBResultData& data, IDBCl
 
 void IDBTransaction::scheduleCompletedOperationTimer()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!m_completedOperationTimer.isActive())
         m_completedOperationTimer.startOneShot(0_s);
@@ -447,7 +447,7 @@ void IDBTransaction::scheduleCompletedOperationTimer()
 void IDBTransaction::completedOperationTimerFired()
 {
     LOG(IndexedDB, "IDBTransaction::completedOperationTimerFired (%p)", this);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (m_completedOnServerQueue.isEmpty() || m_currentlyCompletingRequest)
         return;
@@ -491,7 +491,7 @@ void IDBTransaction::finishedDispatchEventForRequest(IDBRequest& request)
 void IDBTransaction::commit()
 {
     LOG(IndexedDB, "IDBTransaction::commit");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(!isFinishedOrFinishing());
 
     transitionedToFinishing(IndexedDB::TransactionState::Committing);
@@ -504,7 +504,7 @@ void IDBTransaction::commit()
 void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
 {
     LOG(IndexedDB, "IDBTransaction::commitOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().commitTransaction(*this);
 
@@ -519,7 +519,7 @@ void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
 void IDBTransaction::finishAbortOrCommit()
 {
     ASSERT(m_state != IndexedDB::TransactionState::Finished);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_state = IndexedDB::TransactionState::Finished;
 }
@@ -527,7 +527,7 @@ void IDBTransaction::finishAbortOrCommit()
 void IDBTransaction::didStart(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didStart");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->didStartTransaction(*this);
 
@@ -545,7 +545,7 @@ void IDBTransaction::didStart(const IDBError& error)
 
 void IDBTransaction::notifyDidAbort(const IDBError& error)
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->didAbortTransaction(*this);
     m_idbError = error;
@@ -560,7 +560,7 @@ void IDBTransaction::notifyDidAbort(const IDBError& error)
 void IDBTransaction::didAbort(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didAbort");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (m_state == IndexedDB::TransactionState::Finished)
         return;
@@ -573,7 +573,7 @@ void IDBTransaction::didAbort(const IDBError& error)
 void IDBTransaction::didCommit(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didCommit");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(m_state == IndexedDB::TransactionState::Committing);
 
     if (error.isNull()) {
@@ -590,21 +590,21 @@ void IDBTransaction::didCommit(const IDBError& error)
 void IDBTransaction::fireOnComplete()
 {
     LOG(IndexedDB, "IDBTransaction::fireOnComplete");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     enqueueEvent(Event::create(eventNames().completeEvent, false, false));
 }
 
 void IDBTransaction::fireOnAbort()
 {
     LOG(IndexedDB, "IDBTransaction::fireOnAbort");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     enqueueEvent(Event::create(eventNames().abortEvent, true, false));
 }
 
 void IDBTransaction::enqueueEvent(Ref<Event>&& event)
 {
     ASSERT(m_state != IndexedDB::TransactionState::Finished);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!scriptExecutionContext() || m_contextStopped)
         return;
@@ -617,7 +617,7 @@ void IDBTransaction::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBTransaction::dispatchEvent");
 
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(scriptExecutionContext());
     ASSERT(!m_contextStopped);
     ASSERT(event.target() == this);
@@ -647,7 +647,7 @@ Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo&
     LOG(IndexedDB, "IDBTransaction::createObjectStore");
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     Locker<Lock> locker(m_referencedObjectStoreLock);
 
@@ -664,7 +664,7 @@ Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo&
 void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation& operation, const IDBObjectStoreInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::createObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().createObjectStore(operation, info);
@@ -673,7 +673,7 @@ void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didCreateObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didCreateObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -685,7 +685,7 @@ void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String
 
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT(m_referencedObjectStores.contains(objectStore.info().name()));
     ASSERT(!m_referencedObjectStores.contains(newName));
@@ -702,7 +702,7 @@ void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String
 void IDBTransaction::renameObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const String& newName)
 {
     LOG(IndexedDB, "IDBTransaction::renameObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().renameObjectStore(operation, objectStoreIdentifier, newName);
@@ -711,7 +711,7 @@ void IDBTransaction::renameObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didRenameObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didRenameObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -719,7 +719,7 @@ std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStor
 {
     LOG(IndexedDB, "IDBTransaction::createIndex");
     ASSERT(isVersionChange());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (!scriptExecutionContext())
         return nullptr;
@@ -733,7 +733,7 @@ std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStor
 void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operation, const IDBIndexInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::createIndexOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().createIndex(operation, info);
@@ -742,7 +742,7 @@ void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didCreateIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didCreateIndexOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (resultData.type() == IDBResultType::CreateIndexSuccess)
         return;
@@ -764,7 +764,7 @@ void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
 
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT(m_referencedObjectStores.contains(index.objectStore().info().name()));
     ASSERT(m_referencedObjectStores.get(index.objectStore().info().name()) == &index.objectStore());
@@ -781,7 +781,7 @@ void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
 void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const uint64_t& indexIdentifier, const String& newName)
 {
     LOG(IndexedDB, "IDBTransaction::renameIndexOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().renameIndex(operation, objectStoreIdentifier, indexIdentifier, newName);
@@ -790,14 +790,14 @@ void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didRenameIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didRenameIndexOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameIndexSuccess || resultData.type() == IDBResultType::Error);
 }
 
 Ref<IDBRequest> IDBTransaction::requestOpenCursor(ExecState& state, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
         return doRequestOpenCursor(state, IDBCursor::create(*this, objectStore, info));
@@ -808,7 +808,7 @@ Ref<IDBRequest> IDBTransaction::requestOpenCursor(ExecState& state, IDBObjectSto
 Ref<IDBRequest> IDBTransaction::requestOpenCursor(ExecState& state, IDBIndex& index, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
         return doRequestOpenCursor(state, IDBCursor::create(*this, index, info));
@@ -819,7 +819,7 @@ Ref<IDBRequest> IDBTransaction::requestOpenCursor(ExecState& state, IDBIndex& in
 Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(ExecState& state, Ref<IDBCursor>&& cursor)
 {
     ASSERT(isActive());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -835,7 +835,7 @@ Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(ExecState& state, Ref<IDBCur
 void IDBTransaction::openCursorOnServer(IDBClient::TransactionOperation& operation, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::openCursorOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().openCursor(operation, info);
 }
@@ -843,7 +843,7 @@ void IDBTransaction::openCursorOnServer(IDBClient::TransactionOperation& operati
 void IDBTransaction::didOpenCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didOpenCursorOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     completeCursorRequest(request, resultData);
 }
@@ -853,7 +853,7 @@ void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBIterateCursorData
     LOG(IndexedDB, "IDBTransaction::iterateCursor");
     ASSERT(isActive());
     ASSERT(cursor.request());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     addRequest(*cursor.request());
 
@@ -865,7 +865,7 @@ void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBIterateCursorData
 void IDBTransaction::iterateCursorOnServer(IDBClient::TransactionOperation& operation, const IDBIterateCursorData& data)
 {
     LOG(IndexedDB, "IDBTransaction::iterateCursorOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().iterateCursor(operation, data);
 }
@@ -873,7 +873,7 @@ void IDBTransaction::iterateCursorOnServer(IDBClient::TransactionOperation& oper
 void IDBTransaction::didIterateCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didIterateCursorOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     completeCursorRequest(request, resultData);
 }
@@ -882,7 +882,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllObjectStoreRecords(JSC::ExecState&
 {
     LOG(IndexedDB, "IDBTransaction::requestGetAllObjectStoreRecords");
     ASSERT(isActive());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -901,7 +901,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllIndexRecords(JSC::ExecState& state,
 {
     LOG(IndexedDB, "IDBTransaction::requestGetAllIndexRecords");
     ASSERT(isActive());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -919,7 +919,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllIndexRecords(JSC::ExecState& state,
 void IDBTransaction::getAllRecordsOnServer(IDBClient::TransactionOperation& operation, const IDBGetAllRecordsData& getAllRecordsData)
 {
     LOG(IndexedDB, "IDBTransaction::getAllRecordsOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().getAllRecords(operation, getAllRecordsData);
 }
@@ -927,7 +927,7 @@ void IDBTransaction::getAllRecordsOnServer(IDBClient::TransactionOperation& oper
 void IDBTransaction::didGetAllRecordsOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetAllRecordsOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (resultData.type() == IDBResultType::Error) {
         completeNoncursorRequest(request, resultData);
@@ -954,7 +954,7 @@ Ref<IDBRequest> IDBTransaction::requestGetRecord(ExecState& state, IDBObjectStor
     LOG(IndexedDB, "IDBTransaction::requestGetRecord");
     ASSERT(isActive());
     ASSERT(!getRecordData.keyRangeData.isNull);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -972,7 +972,7 @@ Ref<IDBRequest> IDBTransaction::requestGetRecord(ExecState& state, IDBObjectStor
 Ref<IDBRequest> IDBTransaction::requestGetValue(ExecState& state, IDBIndex& index, const IDBKeyRangeData& range)
 {
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     return requestIndexRecord(state, index, IndexedDB::IndexRecordType::Value, range);
 }
@@ -980,7 +980,7 @@ Ref<IDBRequest> IDBTransaction::requestGetValue(ExecState& state, IDBIndex& inde
 Ref<IDBRequest> IDBTransaction::requestGetKey(ExecState& state, IDBIndex& index, const IDBKeyRangeData& range)
 {
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     return requestIndexRecord(state, index, IndexedDB::IndexRecordType::Key, range);
 }
@@ -990,7 +990,7 @@ Ref<IDBRequest> IDBTransaction::requestIndexRecord(ExecState& state, IDBIndex& i
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1008,7 +1008,7 @@ Ref<IDBRequest> IDBTransaction::requestIndexRecord(ExecState& state, IDBIndex& i
 void IDBTransaction::getRecordOnServer(IDBClient::TransactionOperation& operation, const IDBGetRecordData& getRecordData)
 {
     LOG(IndexedDB, "IDBTransaction::getRecordOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().getRecord(operation, getRecordData);
 }
@@ -1016,7 +1016,7 @@ void IDBTransaction::getRecordOnServer(IDBClient::TransactionOperation& operatio
 void IDBTransaction::didGetRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetRecordOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (resultData.type() == IDBResultType::Error) {
         completeNoncursorRequest(request, resultData);
@@ -1051,7 +1051,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(ExecState& state, IDBObjectStore& o
     LOG(IndexedDB, "IDBTransaction::requestCount (IDBObjectStore)");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1069,7 +1069,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(ExecState& state, IDBIndex& index,
     LOG(IndexedDB, "IDBTransaction::requestCount (IDBIndex)");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1085,7 +1085,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(ExecState& state, IDBIndex& index,
 void IDBTransaction::getCountOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
 {
     LOG(IndexedDB, "IDBTransaction::getCountOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().getCount(operation, keyRange);
 }
@@ -1093,7 +1093,7 @@ void IDBTransaction::getCountOnServer(IDBClient::TransactionOperation& operation
 void IDBTransaction::didGetCountOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetCountOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     request.setResult(resultData.resultInteger());
     completeNoncursorRequest(request, resultData);
@@ -1104,7 +1104,7 @@ Ref<IDBRequest> IDBTransaction::requestDeleteRecord(ExecState& state, IDBObjectS
     LOG(IndexedDB, "IDBTransaction::requestDeleteRecord");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1119,7 +1119,7 @@ Ref<IDBRequest> IDBTransaction::requestDeleteRecord(ExecState& state, IDBObjectS
 void IDBTransaction::deleteRecordOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
 {
     LOG(IndexedDB, "IDBTransaction::deleteRecordOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().deleteRecord(operation, keyRange);
 }
@@ -1127,7 +1127,7 @@ void IDBTransaction::deleteRecordOnServer(IDBClient::TransactionOperation& opera
 void IDBTransaction::didDeleteRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteRecordOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     request.setResultToUndefined();
     completeNoncursorRequest(request, resultData);
@@ -1137,7 +1137,7 @@ Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ExecState& state, IDBObj
 {
     LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");
     ASSERT(isActive());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1155,7 +1155,7 @@ Ref<IDBRequest> IDBTransaction::requestClearObjectStore(ExecState& state, IDBObj
 void IDBTransaction::clearObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier)
 {
     LOG(IndexedDB, "IDBTransaction::clearObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().clearObjectStore(operation, objectStoreIdentifier);
 }
@@ -1163,7 +1163,7 @@ void IDBTransaction::clearObjectStoreOnServer(IDBClient::TransactionOperation& o
 void IDBTransaction::didClearObjectStoreOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didClearObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     request.setResultToUndefined();
     completeNoncursorRequest(request, resultData);
@@ -1175,7 +1175,7 @@ Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore
     ASSERT(isActive());
     ASSERT(!isReadOnly());
     ASSERT(objectStore.info().autoIncrement() || key);
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1191,7 +1191,7 @@ Ref<IDBRequest> IDBTransaction::requestPutOrAdd(ExecState& state, IDBObjectStore
 void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation, RefPtr<IDBKey> key, RefPtr<SerializedScriptValue> value, const IndexedDB::ObjectStoreOverwriteMode& overwriteMode)
 {
     LOG(IndexedDB, "IDBTransaction::putOrAddOnServer");
-    ASSERT(currentThread() == originThreadID());
+    ASSERT(&originThread() == &Thread::current());
     ASSERT(!isReadOnly());
     ASSERT(value);
 
@@ -1224,7 +1224,7 @@ void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation
     operation.setNextRequestCanGoToServer(false);
 
     value->writeBlobsToDiskForIndexedDB([protectedThis = makeRef(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode](const IDBValue& idbValue) mutable {
-        ASSERT(currentThread() == originThreadID());
+        ASSERT(&originThread() == &Thread::current());
         ASSERT(isMainThread());
         if (idbValue.data().data()) {
             m_database->connectionProxy().putOrAdd(protectedOperation.get(), WTFMove(keyData), idbValue, overwriteMode);
@@ -1243,7 +1243,7 @@ void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation
 void IDBTransaction::didPutOrAddOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didPutOrAddOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (auto* result = resultData.resultKey())
         request.setResult(*result);
@@ -1255,7 +1255,7 @@ void IDBTransaction::didPutOrAddOnServer(IDBRequest& request, const IDBResultDat
 void IDBTransaction::deleteObjectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBTransaction::deleteObjectStore");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     Locker<Lock> locker(m_referencedObjectStoreLock);
@@ -1274,7 +1274,7 @@ void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation&
 {
     LOG(IndexedDB, "IDBTransaction::deleteObjectStoreOnServer");
     ASSERT(isVersionChange());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().deleteObjectStore(operation, objectStoreName);
 }
@@ -1282,14 +1282,14 @@ void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didDeleteObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteObjectStoreOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
 void IDBTransaction::deleteIndex(uint64_t objectStoreIdentifier, const String& indexName)
 {
     LOG(IndexedDB, "IDBTransaction::deleteIndex");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT(isVersionChange());
 
     LOG(IndexedDBOperations, "IDB delete index operation: %s (%" PRIu64 ")", indexName.utf8().data(), objectStoreIdentifier);
@@ -1300,7 +1300,7 @@ void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operat
 {
     LOG(IndexedDB, "IDBTransaction::deleteIndexOnServer");
     ASSERT(isVersionChange());
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().deleteIndex(operation, objectStoreIdentifier, indexName);
 }
@@ -1308,7 +1308,7 @@ void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didDeleteIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteIndexOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteIndexSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -1316,8 +1316,8 @@ void IDBTransaction::operationCompletedOnClient(IDBClient::TransactionOperation&
 {
     LOG(IndexedDB, "IDBTransaction::operationCompletedOnClient");
 
-    ASSERT(currentThread() == m_database->originThreadID());
-    ASSERT(currentThread() == operation.originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(&operation.originThread() == &Thread::current());
     ASSERT(m_transactionOperationMap.get(operation.identifier()) == &operation);
     ASSERT(m_transactionOperationsInProgressQueue.first() == &operation);
 
@@ -1330,14 +1330,14 @@ void IDBTransaction::operationCompletedOnClient(IDBClient::TransactionOperation&
 void IDBTransaction::establishOnServer()
 {
     LOG(IndexedDB, "IDBTransaction::establishOnServer");
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     m_database->connectionProxy().establishTransaction(*this);
 }
 
 void IDBTransaction::activate()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (isFinishedOrFinishing())
         return;
@@ -1347,7 +1347,7 @@ void IDBTransaction::activate()
 
 void IDBTransaction::deactivate()
 {
-    ASSERT(currentThread() == m_database->originThreadID());
+    ASSERT(&m_database->originThread() == &Thread::current());
 
     if (m_state == IndexedDB::TransactionState::Active)
         m_state = IndexedDB::TransactionState::Inactive;
index 9eb3f25..742a77a 100644 (file)
@@ -519,12 +519,12 @@ void IDBConnectionProxy::forgetActiveOperations(const Vector<RefPtr<TransactionO
 template<typename KeyType, typename ValueType>
 void removeItemsMatchingCurrentThread(HashMap<KeyType, ValueType>& map)
 {
-    auto currentThreadID = currentThread();
+    auto& currentThread = Thread::current();
 
     Vector<KeyType> keys;
     keys.reserveInitialCapacity(map.size());
     for (auto& iterator : map) {
-        if (iterator.value->originThreadID() == currentThreadID)
+        if (&iterator.value->originThread() == &currentThread)
             keys.uncheckedAppend(iterator.key);
     }
 
index c724531..e855125 100644 (file)
@@ -51,12 +51,12 @@ class TransactionOperation : public ThreadSafeRefCounted<TransactionOperation> {
 public:
     virtual ~TransactionOperation()
     {
-        ASSERT(m_originThreadID == currentThread());
+        ASSERT(m_originThread.ptr() == &Thread::current());
     }
 
     void perform()
     {
-        ASSERT(m_originThreadID == currentThread());
+        ASSERT(m_originThread.ptr() == &Thread::current());
         ASSERT(m_performFunction);
         m_performFunction();
         m_performFunction = { };
@@ -64,7 +64,7 @@ public:
 
     void transitionToCompleteOnThisThread(const IDBResultData& data)
     {
-        ASSERT(m_originThreadID == currentThread());
+        ASSERT(m_originThread.ptr() == &Thread::current());
         m_transaction->operationCompletedOnServer(data, *this);
     }
 
@@ -72,7 +72,7 @@ public:
     {
         ASSERT(isMainThread());
 
-        if (m_originThreadID == currentThread())
+        if (m_originThread.ptr() == &Thread::current())
             transitionToCompleteOnThisThread(data);
         else {
             m_transaction->performCallbackOnOriginThread(*this, &TransactionOperation::transitionToCompleteOnThisThread, data);
@@ -83,7 +83,7 @@ public:
 
     void doComplete(const IDBResultData& data)
     {
-        ASSERT(m_originThreadID == currentThread());
+        ASSERT(m_originThread.ptr() == &Thread::current());
 
         // Due to race conditions between the server sending an "operation complete" message and the client
         // forcefully aborting an operation, it's unavoidable that this method might be called twice.
@@ -102,7 +102,7 @@ public:
 
     const IDBResourceIdentifier& identifier() const { return m_identifier; }
 
-    ThreadIdentifier originThreadID() const { return m_originThreadID; }
+    Thread& originThread() const { return m_originThread.get(); }
 
     IDBRequest* idbRequest() { return m_idbRequest.get(); }
 
@@ -135,7 +135,7 @@ private:
     IDBTransaction& transaction() { return m_transaction.get(); }
     IndexedDB::IndexRecordType indexRecordType() const { return m_indexRecordType; }
 
-    ThreadIdentifier m_originThreadID { currentThread() };
+    Ref<Thread> m_originThread { Thread::current() };
     RefPtr<IDBRequest> m_idbRequest;
     bool m_nextRequestCanGoToServer { true };
 };
index d95047c..a1101ae 100644 (file)
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
 
-// FIXME: check the proper way to reference an undefined thread ID
-const int UndefinedThreadIdentifier = 0xffffffff;
-
 const unsigned MaxPeriodicWaveLength = 4096;
 
 namespace WebCore {
@@ -136,7 +133,6 @@ AudioContext::AudioContext(Document& document)
     : ActiveDOMObject(&document)
     , m_mediaSession(PlatformMediaSession::create(*this))
     , m_eventQueue(std::make_unique<GenericEventQueue>(*this))
-    , m_graphOwnerThread(UndefinedThreadIdentifier)
 {
     constructCommon();
 
@@ -152,7 +148,6 @@ AudioContext::AudioContext(Document& document, unsigned numberOfChannels, size_t
     , m_isOfflineContext(true)
     , m_mediaSession(PlatformMediaSession::create(*this))
     , m_eventQueue(std::make_unique<GenericEventQueue>(*this))
-    , m_graphOwnerThread(UndefinedThreadIdentifier)
 {
     constructCommon();
 
@@ -696,23 +691,23 @@ void AudioContext::lock(bool& mustReleaseLock)
     // Don't allow regular lock in real-time audio thread.
     ASSERT(isMainThread());
 
-    ThreadIdentifier thisThread = currentThread();
+    Thread& thisThread = Thread::current();
 
-    if (thisThread == m_graphOwnerThread) {
+    if (&thisThread == m_graphOwnerThread) {
         // We already have the lock.
         mustReleaseLock = false;
     } else {
         // Acquire the lock.
         m_contextGraphMutex.lock();
-        m_graphOwnerThread = thisThread;
+        m_graphOwnerThread = &thisThread;
         mustReleaseLock = true;
     }
 }
 
 bool AudioContext::tryLock(bool& mustReleaseLock)
 {
-    ThreadIdentifier thisThread = currentThread();
-    bool isAudioThread = thisThread == audioThread();
+    Thread& thisThread = Thread::current();
+    bool isAudioThread = &thisThread == audioThread();
 
     // Try to catch cases of using try lock on main thread - it should use regular lock.
     ASSERT(isAudioThread || isAudioThreadFinished());
@@ -725,7 +720,7 @@ bool AudioContext::tryLock(bool& mustReleaseLock)
     
     bool hasLock;
     
-    if (thisThread == m_graphOwnerThread) {
+    if (&thisThread == m_graphOwnerThread) {
         // Thread already has the lock.
         hasLock = true;
         mustReleaseLock = false;
@@ -734,7 +729,7 @@ bool AudioContext::tryLock(bool& mustReleaseLock)
         hasLock = m_contextGraphMutex.tryLock();
         
         if (hasLock)
-            m_graphOwnerThread = thisThread;
+            m_graphOwnerThread = &thisThread;
 
         mustReleaseLock = hasLock;
     }
@@ -744,20 +739,20 @@ bool AudioContext::tryLock(bool& mustReleaseLock)
 
 void AudioContext::unlock()
 {
-    ASSERT(currentThread() == m_graphOwnerThread);
+    ASSERT(m_graphOwnerThread == &Thread::current());
 
-    m_graphOwnerThread = UndefinedThreadIdentifier;
+    m_graphOwnerThread = nullptr;
     m_contextGraphMutex.unlock();
 }
 
 bool AudioContext::isAudioThread() const
 {
-    return currentThread() == m_audioThread;
+    return m_audioThread == &Thread::current();
 }
 
 bool AudioContext::isGraphOwner() const
 {
-    return currentThread() == m_graphOwnerThread;
+    return m_graphOwnerThread == &Thread::current();
 }
 
 void AudioContext::addDeferredFinishDeref(AudioNode* node)
index 474e687..28edbcb 100644 (file)
@@ -178,8 +178,8 @@ public:
     // Thread Safety and Graph Locking:
     //
     
-    void setAudioThread(ThreadIdentifier thread) { m_audioThread = thread; } // FIXME: check either not initialized or the same
-    ThreadIdentifier audioThread() const { return m_audioThread; }
+    void setAudioThread(Thread& thread) { m_audioThread = &thread; } // FIXME: check either not initialized or the same
+    Thread* audioThread() const { return m_audioThread; }
     bool isAudioThread() const;
 
     // Returns true only after the audio thread has been started and then shutdown.
@@ -381,8 +381,10 @@ private:
 
     // Graph locking.
     Lock m_contextGraphMutex;
-    volatile ThreadIdentifier m_audioThread { 0 };
-    volatile ThreadIdentifier m_graphOwnerThread; // if the lock is held then this is the thread which owns it, otherwise == UndefinedThreadIdentifier
+    // FIXME: Using volatile seems incorrect.
+    // https://bugs.webkit.org/show_bug.cgi?id=180332
+    Thread* volatile m_audioThread { nullptr };
+    Thread* volatile m_graphOwnerThread { nullptr }; // if the lock is held then this is the thread which owns it, otherwise == nullptr.
 
     AsyncAudioDecoder m_audioDecoder;
 
index 5112818..629766c 100644 (file)
@@ -60,7 +60,7 @@ void AudioDestinationNode::render(AudioBus*, AudioBus* destinationBus, size_t nu
     // This will take care of all AudioNodes because they all process within this scope.
     DenormalDisabler denormalDisabler;
     
-    context().setAudioThread(currentThread());
+    context().setAudioThread(Thread::current());
     
     if (!context().isInitialized()) {
         destinationBus->zero();
index 783f921..bdecfa0 100644 (file)
@@ -287,7 +287,7 @@ void Database::close()
 
 void Database::performClose()
 {
-    ASSERT(currentThread() == databaseThread().getThreadID());
+    ASSERT(databaseThread().getThread() == &Thread::current());
 
     {
         LockHolder locker(m_transactionInProgressMutex);
@@ -768,7 +768,7 @@ SecurityOriginData Database::securityOrigin()
 {
     if (m_scriptExecutionContext->isContextThread())
         return SecurityOriginData::fromSecurityOrigin(m_contextThreadSecurityOrigin.get());
-    if (currentThread() == databaseThread().getThreadID())
+    if (databaseThread().getThread() == &Thread::current())
         return SecurityOriginData::fromSecurityOrigin(m_databaseThreadSecurityOrigin.get());
     RELEASE_ASSERT_NOT_REACHED();
 }
index a4e99ad..6a96e23 100644 (file)
@@ -35,17 +35,35 @@ namespace WebCore {
 
 class DatabaseDetails {
 public:
-    DatabaseDetails()
-        : m_expectedUsage(0)
-        , m_currentUsage(0)
-        , m_creationTime(0)
-        , m_modificationTime(0)
+    DatabaseDetails() = default;
+
+    DatabaseDetails(const DatabaseDetails& details)
+        : m_name(details.m_name)
+        , m_displayName(details.m_displayName)
+        , m_expectedUsage(details.m_expectedUsage)
+        , m_currentUsage(details.m_currentUsage)
+        , m_creationTime(details.m_creationTime)
+        , m_modificationTime(details.m_modificationTime)
 #ifndef NDEBUG
-        , m_threadID(Thread::currentID())
+        , m_thread(details.m_thread.copyRef())
 #endif
     {
     }
 
+    DatabaseDetails& operator=(const DatabaseDetails& details)
+    {
+        m_name = details.m_name;
+        m_displayName = details.m_displayName;
+        m_expectedUsage = details.m_expectedUsage;
+        m_currentUsage = details.m_currentUsage;
+        m_creationTime = details.m_creationTime;
+        m_modificationTime = details.m_modificationTime;
+#ifndef NDEBUG
+        m_thread = details.m_thread.copyRef();
+#endif
+        return *this;
+    }
+
     DatabaseDetails(const String& databaseName, const String& displayName, unsigned long long expectedUsage, unsigned long long currentUsage, double creationTime, double modificationTime)
         : m_name(databaseName)
         , m_displayName(displayName)
@@ -53,9 +71,6 @@ public:
         , m_currentUsage(currentUsage)
         , m_creationTime(creationTime)
         , m_modificationTime(modificationTime)
-#ifndef NDEBUG
-        , m_threadID(Thread::currentID())
-#endif
     {
     }
 
@@ -66,18 +81,18 @@ public:
     double creationTime() const { return m_creationTime; }
     double modificationTime() const { return m_modificationTime; }
 #ifndef NDEBUG
-    ThreadIdentifier threadID() const { return m_threadID; }
+    Thread& thread() const { return m_thread.get(); }
 #endif
 
 private:
     String m_name;
     String m_displayName;
-    uint64_t m_expectedUsage;
-    uint64_t m_currentUsage;
-    double m_creationTime;
-    double m_modificationTime;
+    uint64_t m_expectedUsage { 0 };
+    uint64_t m_currentUsage { 0 };
+    double m_creationTime { 0.0 };
+    double m_modificationTime { 0.0 };
 #ifndef NDEBUG
-    ThreadIdentifier m_threadID;
+    Ref<Thread> m_thread { Thread::current() };
 #endif
 };
 
index 48e0c47..b4adc66 100644 (file)
@@ -257,7 +257,7 @@ DatabaseDetails DatabaseManager::detailsForNameAndOrigin(const String& name, Sec
         std::lock_guard<Lock> lock { m_proposedDatabasesMutex };
         for (auto* proposedDatabase : m_proposedDatabases) {
             if (proposedDatabase->details().name() == name && proposedDatabase->origin().equal(&origin)) {
-                ASSERT(proposedDatabase->details().threadID() == Thread::currentID() || isMainThread());
+                ASSERT(&proposedDatabase->details().thread() == &Thread::current() || isMainThread());
                 return proposedDatabase->details();
             }
         }
index 11524cd..007800c 100644 (file)
@@ -106,7 +106,7 @@ void DatabaseThread::databaseThread()
     // Clean up the list of all pending transactions on this database thread
     m_transactionCoordinator->shutdown();
 
-    LOG(StorageAPI, "About to detach thread %i and clear the ref to DatabaseThread %p, which currently has %i ref(s)", m_thread->id(), this, refCount());
+    LOG(StorageAPI, "About to detach thread %p and clear the ref to DatabaseThread %p, which currently has %i ref(s)", m_thread.get(), this, refCount());
 
     // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
     // inconsistent or locked state.
@@ -138,7 +138,7 @@ void DatabaseThread::recordDatabaseOpen(Database& database)
 {
     LockHolder lock(m_openDatabaseSetMutex);
 
-    ASSERT(currentThread() == m_thread->id());
+    ASSERT(m_thread == &Thread::current());
     ASSERT(!m_openDatabaseSet.contains(&database));
     m_openDatabaseSet.add(&database);
 }
@@ -147,7 +147,7 @@ void DatabaseThread::recordDatabaseClosed(Database& database)
 {
     LockHolder lock(m_openDatabaseSetMutex);
 
-    ASSERT(currentThread() == m_thread->id());
+    ASSERT(m_thread == &Thread::current());
     ASSERT(m_queue.killed() || m_openDatabaseSet.contains(&database));
     m_openDatabaseSet.remove(&database);
 }
index 34009d1..a8c570b 100644 (file)
@@ -58,7 +58,7 @@ public:
 
     void recordDatabaseOpen(Database&);
     void recordDatabaseClosed(Database&);
-    ThreadIdentifier getThreadID() { return m_thread ? m_thread->id() : 0; }
+    Thread* getThread() { return m_thread.get(); }
 
     SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCoordinator.get(); }
 
index 171e0db..1877f34 100644 (file)
@@ -184,7 +184,7 @@ void SQLTransaction::checkAndHandleClosedDatabase()
     m_errorCallbackWrapper.clear();
 
     // The next steps should be executed only if we're on the DB thread.
-    if (currentThread() != m_database->databaseThread().getThreadID())
+    if (&Thread::current() != m_database->databaseThread().getThread())
         return;
 
     // The current SQLite transaction should be stopped, as well
index 2ea93dd..d00ec1d 100644 (file)
@@ -353,7 +353,7 @@ SQLTransactionBackend::~SQLTransactionBackend()
 
 void SQLTransactionBackend::doCleanup()
 {
-    ASSERT(currentThread() == m_frontend.database().databaseThread().getThreadID());
+    ASSERT(m_frontend.database().databaseThread().getThread() == &Thread::current());
 
     m_frontend.releaseOriginLockIfNeeded();
 
@@ -465,7 +465,7 @@ void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded()
 
 void SQLTransactionBackend::notifyDatabaseThreadIsShuttingDown()
 {
-    ASSERT(currentThread() == m_frontend.database().databaseThread().getThreadID());
+    ASSERT(m_frontend.database().databaseThread().getThread() == &Thread::current());
 
     // If the transaction is in progress, we should roll it back here, since this
     // is our last opportunity to do something related to this transaction on the
index 49e1535..c6bda55 100644 (file)
@@ -52,7 +52,7 @@ protected:
     explicit JSCallbackData(JSDOMGlobalObject* globalObject)
         : m_globalObject(globalObject)
 #ifndef NDEBUG
-        , m_thread(currentThread())
+        , m_thread(Thread::current())
 #endif
     {
     }
@@ -60,7 +60,7 @@ protected:
     ~JSCallbackData()
     {
 #if !PLATFORM(IOS)
-        ASSERT(m_thread == currentThread());
+        ASSERT(m_thread.ptr() == &Thread::current());
 #endif
     }
     
@@ -69,7 +69,7 @@ protected:
 private:
     JSC::Weak<JSDOMGlobalObject> m_globalObject;
 #ifndef NDEBUG
-    ThreadIdentifier m_thread;
+    Ref<Thread> m_thread;
 #endif
 };
 
index 0f74e6c..6357769 100644 (file)
@@ -146,7 +146,7 @@ void ScheduledAction::execute(Document& document)
 void ScheduledAction::execute(WorkerGlobalScope& workerGlobalScope)
 {
     // In a Worker, the execution should always happen on a worker thread.
-    ASSERT(workerGlobalScope.thread().threadID() == currentThread());
+    ASSERT(workerGlobalScope.thread().thread() == &Thread::current());
 
     WorkerScriptController* scriptController = workerGlobalScope.script();
 
index 2199d4a..b6e85ea 100644 (file)
@@ -164,7 +164,7 @@ void ScriptExecutionContext::dispatchMessagePortEvents()
 void ScriptExecutionContext::createdMessagePort(MessagePort& messagePort)
 {
     ASSERT((is<Document>(*this) && isMainThread())
-        || (is<WorkerGlobalScope>(*this) && currentThread() == downcast<WorkerGlobalScope>(*this).thread().threadID()));
+        || (is<WorkerGlobalScope>(*this) && downcast<WorkerGlobalScope>(*this).thread().thread() == &Thread::current()));
 
     m_messagePorts.add(&messagePort);
 }
@@ -172,7 +172,7 @@ void ScriptExecutionContext::createdMessagePort(MessagePort& messagePort)
 void ScriptExecutionContext::destroyedMessagePort(MessagePort& messagePort)
 {
     ASSERT((is<Document>(*this) && isMainThread())
-        || (is<WorkerGlobalScope>(*this) && currentThread() == downcast<WorkerGlobalScope>(*this).thread().threadID()));
+        || (is<WorkerGlobalScope>(*this) && downcast<WorkerGlobalScope>(*this).thread().thread() == &Thread::current()));
 
     m_messagePorts.remove(&messagePort);
 }
index 646dfef..16aea60 100644 (file)
@@ -78,7 +78,6 @@ private:
     IntPoint m_dragPoint;
 
 #if PLATFORM(COCOA)
-    ThreadIdentifier m_threadID { 0 };
     RetainPtr<CALayer> m_layer;
     RetainPtr<CALayer> m_containerLayer;
 #endif
index d204c76..61fac3a 100644 (file)
@@ -40,8 +40,7 @@ ScrollingThread::ScrollingThread()
 
 bool ScrollingThread::isCurrentThread()
 {
-    RefPtr<Thread> thread = ScrollingThread::singleton().m_thread;
-    return thread && thread->id() == currentThread();
+    return ScrollingThread::singleton().m_thread == &Thread::current();
 }
 
 void ScrollingThread::dispatch(Function<void ()>&& function)
index 33f69a2..6c2619c 100644 (file)
@@ -98,33 +98,33 @@ class Supplementable {
 public:
     void provideSupplement(const char* key, std::unique_ptr<Supplement<T>> supplement)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_threadId));
+        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
         ASSERT(!m_supplements.get(key));
         m_supplements.set(key, WTFMove(supplement));
     }
 
     void removeSupplement(const char* key)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_threadId));
+        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
         m_supplements.remove(key);
     }
 
     Supplement<T>* requireSupplement(const char* key)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_threadId));
+        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
         return m_supplements.get(key);
     }
 
 #if !ASSERT_DISABLED
 protected:
-    Supplementable() : m_threadId(currentThread()) { }
+    Supplementable() = default;
 #endif
 
 private:
     typedef HashMap<const char*, std::unique_ptr<Supplement<T>>, PtrHash<const char*>> SupplementMap;
     SupplementMap m_supplements;
 #if !ASSERT_DISABLED
-    ThreadIdentifier m_threadId;
+    Ref<Thread> m_thread { Thread::current() };
 #endif
 };
 
index 9ccb402..87d4e69 100644 (file)
@@ -186,9 +186,6 @@ inline bool TimerHeapLessThanFunction::operator()(const TimerBase* a, const Time
 // ----------------
 
 TimerBase::TimerBase()
-#ifndef NDEBUG
-    : m_thread(currentThread())
-#endif
 {
 }
 
@@ -203,7 +200,7 @@ TimerBase::~TimerBase()
 
 void TimerBase::start(Seconds nextFireInterval, Seconds repeatInterval)
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread));
+    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
 
     m_repeatInterval = repeatInterval;
     setNextFireTime(MonotonicTime::now() + nextFireInterval);
@@ -211,7 +208,7 @@ void TimerBase::start(Seconds nextFireInterval, Seconds repeatInterval)
 
 void TimerBase::stop()
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread));
+    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
 
     m_repeatInterval = 0_s;
     setNextFireTime(MonotonicTime { });
@@ -362,7 +359,7 @@ void TimerBase::updateHeapIfNeeded(MonotonicTime oldTime)
 
 void TimerBase::setNextFireTime(MonotonicTime newTime)
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread));
+    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
     ASSERT(!m_wasDeleted);
 
     if (m_unalignedNextFireTime != newTime)
index e3fd7b9..52c7398 100644 (file)
@@ -103,7 +103,7 @@ private:
     Vector<TimerBase*>* m_cachedThreadGlobalTimerHeap { nullptr };
 
 #ifndef NDEBUG
-    ThreadIdentifier m_thread;
+    Ref<Thread> m_thread { Thread::current() };
     bool m_wasDeleted { false };
 #endif
 
@@ -140,9 +140,9 @@ inline bool TimerBase::isActive() const
 {
     // FIXME: Write this in terms of USE(WEB_THREAD) instead of PLATFORM(IOS).
 #if !PLATFORM(IOS)
-    ASSERT(m_thread == currentThread());
+    ASSERT(m_thread.ptr() == &Thread::current());
 #else
-    ASSERT(WebThreadIsCurrent() || pthread_main_np() || m_thread == currentThread());
+    ASSERT(WebThreadIsCurrent() || pthread_main_np() || m_thread.ptr() == &Thread::current());
 #endif // PLATFORM(IOS)
     return static_cast<bool>(m_nextFireTime);
 }
index 1f2b5f5..611edfb 100644 (file)
@@ -1224,8 +1224,8 @@ static bool shouldAutoActivateFontIfNeeded(const AtomicString& family)
 #ifndef NDEBUG
     // This cache is not thread safe so the following assertion is there to
     // make sure this function is always called from the same thread.
-    static ThreadIdentifier initThreadId = currentThread();
-    ASSERT(currentThread() == initThreadId);
+    static Thread* initThread = &Thread::current();
+    ASSERT(initThread == &Thread::current());
 #endif
 
     static NeverDestroyed<HashSet<AtomicString>> knownFamilies;
index 1cca0cc..b23dac2 100644 (file)
@@ -58,9 +58,10 @@ TextureMapperPlatformLayerProxy::~TextureMapperPlatformLayerProxy()
 void TextureMapperPlatformLayerProxy::activateOnCompositingThread(Compositor* compositor, TextureMapperLayer* targetLayer)
 {
 #ifndef NDEBUG
-    m_compositorThreadID = m_compositorThreadID ? m_compositorThreadID : WTF::currentThread();
+    if (!m_compositorThread)
+        m_compositorThread = &Thread::current();
 #endif
-    ASSERT(m_compositorThreadID == WTF::currentThread());
+    ASSERT(m_compositorThread == &Thread::current());
     ASSERT(compositor);
     ASSERT(targetLayer);
     LockHolder locker(m_lock);
@@ -80,7 +81,7 @@ void TextureMapperPlatformLayerProxy::activateOnCompositingThread(Compositor* co
 
 void TextureMapperPlatformLayerProxy::invalidate()
 {
-    ASSERT(m_compositorThreadID == WTF::currentThread());
+    ASSERT(m_compositorThread == &Thread::current());
     Function<void()> updateFunction;
     {
         LockHolder locker(m_lock);
@@ -120,7 +121,7 @@ void TextureMapperPlatformLayerProxy::pushNextBuffer(std::unique_ptr<TextureMapp
 std::unique_ptr<TextureMapperPlatformLayerBuffer> TextureMapperPlatformLayerProxy::getAvailableBuffer(const IntSize& size, GLint internalFormat)
 {
     ASSERT(m_lock.isHeld());
-    ASSERT(m_compositorThreadID == WTF::currentThread());
+    ASSERT(m_compositorThread == &Thread::current());
     std::unique_ptr<TextureMapperPlatformLayerBuffer> availableBuffer;
 
     auto buffers = WTFMove(m_usedBuffers);
@@ -144,7 +145,7 @@ std::unique_ptr<TextureMapperPlatformLayerBuffer> TextureMapperPlatformLayerProx
 void TextureMapperPlatformLayerProxy::appendToUnusedBuffers(std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer)
 {
     ASSERT(m_lock.isHeld());
-    ASSERT(m_compositorThreadID == WTF::currentThread());
+    ASSERT(m_compositorThread == &Thread::current());
     m_usedBuffers.append(WTFMove(buffer));
     scheduleReleaseUnusedBuffers();
 }
@@ -172,7 +173,7 @@ void TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired()
 
 void TextureMapperPlatformLayerProxy::swapBuffer()
 {
-    ASSERT(m_compositorThreadID == WTF::currentThread());
+    ASSERT(m_compositorThread == &Thread::current());
     LockHolder locker(m_lock);
     if (!m_targetLayer || !m_pendingBuffer)
         return;
index d004cc8..f3cbdf4 100644 (file)
@@ -91,7 +91,7 @@ private:
     std::unique_ptr<RunLoop::Timer<TextureMapperPlatformLayerProxy>> m_releaseUnusedBuffersTimer;
 
 #ifndef NDEBUG
-    ThreadIdentifier m_compositorThreadID { 0 };
+    RefPtr<Thread> m_compositorThread;
 #endif
 
     void compositorThreadUpdateTimerFired();
index 80e4540..95fcf13 100644 (file)
@@ -656,7 +656,6 @@ void *RunWebThread(void *arg)
     
     // Make sure that the WebThread and the main thread share the same ThreadGlobalData objects.
     WebCore::threadGlobalData().setWebCoreThreadData();
-    initializeWebThreadIdentifier();
 
 #if HAVE(PTHREAD_SETNAME_NP)
     pthread_setname_np("WebThread");
@@ -766,7 +765,7 @@ static void StartWebThread()
         startupCondition.wait(startupLock);
     }
 
-    initializeApplicationUIThreadIdentifier();
+    initializeApplicationUIThread();
 }
 
 static int WebTimedConditionLock (pthread_cond_t *condition, pthread_mutex_t *lock, CFAbsoluteTime interval)
index 987b346..2095ee8 100644 (file)
@@ -105,7 +105,7 @@ bool SQLiteDatabase::open(const String& filename, bool forWebSQLDatabase)
     }
 
     if (isOpen())
-        m_openingThread = currentThread();
+        m_openingThread = &Thread::current();
     else
         m_openErrorMessage = "sqlite_open returned null";
 
@@ -129,7 +129,7 @@ void SQLiteDatabase::close()
 {
     if (m_db) {
         // FIXME: This is being called on the main thread during JS GC. <rdar://problem/5739818>
-        // ASSERT(currentThread() == m_openingThread);
+        // ASSERT(m_openingThread == &Thread::current());
         sqlite3* db = m_db;
         {
             LockHolder locker(m_databaseClosingMutex);
@@ -138,7 +138,7 @@ void SQLiteDatabase::close()
         sqlite3_close(db);
     }
 
-    m_openingThread = 0;
+    m_openingThread = nullptr;
     m_openError = SQLITE_ERROR;
     m_openErrorMessage = CString();
 }
index 7172e4e..debb7c8 100644 (file)
@@ -103,7 +103,7 @@ public:
     sqlite3* sqlite3Handle() const
     {
 #if !PLATFORM(IOS)
-        ASSERT(m_sharable || currentThread() == m_openingThread || !m_db);
+        ASSERT(m_sharable || m_openingThread == &Thread::current() || !m_db);
 #endif
         return m_db;
     }
@@ -157,7 +157,7 @@ private:
     RefPtr<DatabaseAuthorizer> m_authorizer;
 
     Lock m_lockingMutex;
-    ThreadIdentifier m_openingThread { 0 };
+    RefPtr<Thread> m_openingThread { nullptr };
 
     Lock m_databaseClosingMutex;
 
index 8861eb8..bf7452e 100644 (file)
@@ -86,7 +86,7 @@ WorkerGlobalScope::WorkerGlobalScope(const URL& url, const String& identifier, c
 
 WorkerGlobalScope::~WorkerGlobalScope()
 {
-    ASSERT(currentThread() == thread().threadID());
+    ASSERT(thread().thread() == &Thread::current());
 
     m_performance = nullptr;
     m_crypto = nullptr;
@@ -329,7 +329,7 @@ void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, con
 
 bool WorkerGlobalScope::isContextThread() const
 {
-    return currentThread() == thread().threadID();
+    return thread().thread() == &Thread::current();
 }
 
 bool WorkerGlobalScope::isJSExecutionForbidden() const
index b5dd38a..ed024a2 100644 (file)
@@ -59,7 +59,7 @@ WorkerMessagingProxy::WorkerMessagingProxy(Worker& workerObject)
     , m_workerObject(&workerObject)
 {
     ASSERT((is<Document>(*m_scriptExecutionContext) && isMainThread())
-        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && currentThread() == downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().threadID()));
+        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current()));
 
     // Nobody outside this class ref counts this object. The original ref
     // is balanced by the deref in workerGlobalScopeDestroyedInternal.
@@ -69,7 +69,7 @@ WorkerMessagingProxy::~WorkerMessagingProxy()
 {
     ASSERT(!m_workerObject);
     ASSERT((is<Document>(*m_scriptExecutionContext) && isMainThread())
-        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && currentThread() == downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().threadID()));
+        || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current()));
 }
 
 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID)
index 2361bf7..56faf7d 100644 (file)
@@ -151,7 +151,7 @@ MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons
 MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, const ModePredicate& predicate, WaitMode waitMode)
 {
     ASSERT(context);
-    ASSERT(context->thread().threadID() == currentThread());
+    ASSERT(context->thread().thread() == &Thread::current());
 
     JSC::JSRunLoopTimer::TimerNotificationCallback timerAddedTask = WTF::createSharedTask<JSC::JSRunLoopTimer::TimerNotificationType>([this] {
         // We don't actually do anything here, we just want to loop around runInMode
@@ -221,7 +221,7 @@ MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons
 void WorkerRunLoop::runCleanupTasks(WorkerGlobalScope* context)
 {
     ASSERT(context);
-    ASSERT(context->thread().threadID() == currentThread());
+    ASSERT(context->thread().thread() == &Thread::current());
     ASSERT(m_messageQueue.killed());
 
     while (true) {
index 49e5c4b..7c42e29 100644 (file)
@@ -66,7 +66,7 @@ public:
     WEBCORE_EXPORT bool start(WTF::Function<void(const String&)>&& evaluateCallback);
     void stop(WTF::Function<void()>&& terminatedCallback);
 
-    ThreadIdentifier threadID() const { return m_thread ? m_thread->id() : 0; }
+    Thread* thread() const { return m_thread.get(); }
     WorkerRunLoop& runLoop() { return m_runLoop; }
     WorkerLoaderProxy& workerLoaderProxy() const { return m_workerLoaderProxy; }
     WorkerDebuggerProxy& workerDebuggerProxy() const { return m_workerDebuggerProxy; }
index 15d0fec..56ecbc4 100644 (file)
@@ -64,7 +64,7 @@ ServiceWorkerContainer::ServiceWorkerContainer(ScriptExecutionContext& context,
 ServiceWorkerContainer::~ServiceWorkerContainer()
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 }
 
@@ -194,7 +194,7 @@ void ServiceWorkerContainer::updateRegistration(const URL& scopeURL, const URL&
 void ServiceWorkerContainer::scheduleJob(Ref<ServiceWorkerJob>&& job)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     ASSERT(m_swConnection);
@@ -296,7 +296,7 @@ void ServiceWorkerContainer::startMessages()
 void ServiceWorkerContainer::jobFailedWithException(ServiceWorkerJob& job, const Exception& exception)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     if (auto* context = scriptExecutionContext()) {
@@ -310,7 +310,7 @@ void ServiceWorkerContainer::jobFailedWithException(ServiceWorkerJob& job, const
 void ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier identifier)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     if (auto* registration = m_registrations.get(identifier))
@@ -320,7 +320,7 @@ void ServiceWorkerContainer::scheduleTaskToFireUpdateFoundEvent(ServiceWorkerReg
 void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job, ServiceWorkerRegistrationData&& data, ShouldNotifyWhenResolved shouldNotifyWhenResolved)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     auto guard = WTF::makeScopeExit([this, &job] {
@@ -360,7 +360,7 @@ void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job,
 void ServiceWorkerContainer::jobResolvedWithUnregistrationResult(ServiceWorkerJob& job, bool unregistrationResult)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     auto guard = WTF::makeScopeExit([this, &job] {
@@ -381,7 +381,7 @@ void ServiceWorkerContainer::jobResolvedWithUnregistrationResult(ServiceWorkerJo
 void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     LOG(ServiceWorker, "SeviceWorkerContainer %p starting script fetch for job %s", this, job.identifier().loggingString().utf8().data());
@@ -402,7 +402,7 @@ void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
 void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const String& script)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     LOG(ServiceWorker, "SeviceWorkerContainer %p finished fetching script for job %s", this, job.identifier().loggingString().utf8().data());
@@ -415,7 +415,7 @@ void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, con
 void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const ResourceError& error, std::optional<Exception>&& exception)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     LOG(ServiceWorker, "SeviceWorkerContainer %p failed fetching script for job %s", this, job.identifier().loggingString().utf8().data());
@@ -431,7 +431,7 @@ void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const
 void ServiceWorkerContainer::jobDidFinish(ServiceWorkerJob& job)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     auto taken = m_jobMap.take(job.identifier());
@@ -470,7 +470,7 @@ SWClientConnection& ServiceWorkerContainer::ensureSWClientConnection()
 void ServiceWorkerContainer::addRegistration(ServiceWorkerRegistration& registration)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     ensureSWClientConnection().addServiceWorkerRegistrationInServer(registration.identifier());
@@ -480,7 +480,7 @@ void ServiceWorkerContainer::addRegistration(ServiceWorkerRegistration& registra
 void ServiceWorkerContainer::removeRegistration(ServiceWorkerRegistration& registration)
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     m_swConnection->removeServiceWorkerRegistrationInServer(registration.identifier());
@@ -490,7 +490,7 @@ void ServiceWorkerContainer::removeRegistration(ServiceWorkerRegistration& regis
 void ServiceWorkerContainer::scheduleTaskToFireControllerChangeEvent()
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     if (m_isStopped)
@@ -513,7 +513,7 @@ void ServiceWorkerContainer::stop()
 DocumentOrWorkerIdentifier ServiceWorkerContainer::contextIdentifier()
 {
 #ifndef NDEBUG
-    ASSERT(m_creationThread == currentThread());
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 #endif
 
     ASSERT(scriptExecutionContext());
index 2d9a9f0..ea12e8c 100644 (file)
@@ -119,7 +119,7 @@ private:
     HashMap<ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistration*> m_registrations;
 
 #ifndef NDEBUG
-    ThreadIdentifier m_creationThread { currentThread() };
+    Ref<Thread> m_creationThread { Thread::current() };
 #endif
 };
 
index f73f907..4a881d7 100644 (file)
@@ -47,12 +47,12 @@ ServiceWorkerJob::ServiceWorkerJob(ServiceWorkerJobClient& client, Ref<DeferredP
 
 ServiceWorkerJob::~ServiceWorkerJob()
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
 }
 
 void ServiceWorkerJob::failedWithException(const Exception& exception)
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
 
     m_completed = true;
@@ -61,7 +61,7 @@ void ServiceWorkerJob::failedWithException(const Exception& exception)
 
 void ServiceWorkerJob::resolvedWithRegistration(ServiceWorkerRegistrationData&& data, ShouldNotifyWhenResolved shouldNotifyWhenResolved)
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
 
     m_completed = true;
@@ -70,7 +70,7 @@ void ServiceWorkerJob::resolvedWithRegistration(ServiceWorkerRegistrationData&&
 
 void ServiceWorkerJob::resolvedWithUnregistrationResult(bool unregistrationResult)
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
 
     m_completed = true;
@@ -79,7 +79,7 @@ void ServiceWorkerJob::resolvedWithUnregistrationResult(bool unregistrationResul
 
 void ServiceWorkerJob::startScriptFetch()
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
 
     m_client->startScriptFetchForJob(*this);
@@ -87,7 +87,7 @@ void ServiceWorkerJob::startScriptFetch()
 
 void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context)
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
 
     // FIXME: WorkerScriptLoader is the wrong loader class to use here, but there's nothing else better right now.
@@ -97,7 +97,7 @@ void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context)
 
 void ServiceWorkerJob::didReceiveResponse(unsigned long, const ResourceResponse& response)
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(!m_completed);
     ASSERT(m_scriptLoader);
 
@@ -115,7 +115,7 @@ void ServiceWorkerJob::didReceiveResponse(unsigned long, const ResourceResponse&
 
 void ServiceWorkerJob::notifyFinished()
 {
-    ASSERT(currentThread() == m_creationThread);
+    ASSERT(m_creationThread.ptr() == &Thread::current());
     ASSERT(m_scriptLoader);
     
     if (!m_scriptLoader->failed())
index c30a4fb..9c428e7 100644 (file)
@@ -90,7 +90,7 @@ private:
     ResourceResponse m_lastResponse;
 
 #if !ASSERT_DISABLED
-    ThreadIdentifier m_creationThread { currentThread() };
+    Ref<Thread> m_creationThread { Thread::current() };
 #endif
 };
 
index a37d615..4eda32a 100644 (file)
@@ -340,13 +340,13 @@ private:
 // --------------------------------
 
 static int globalDescriptor = 0;
-static ThreadIdentifier libxmlLoaderThread = 0;
+static Thread* libxmlLoaderThread { nullptr };
 
 static int matchFunc(const char*)
 {
     // Only match loads initiated due to uses of libxml2 from within XMLDocumentParser to avoid
     // interfering with client applications that also use libxml2.  http://bugs.webkit.org/show_bug.cgi?id=17353
-    return XMLDocumentParserScope::currentCachedResourceLoader && currentThread() == libxmlLoaderThread;
+    return XMLDocumentParserScope::currentCachedResourceLoader && libxmlLoaderThread == &Thread::current();
 }
 
 class OffsetBuffer {
@@ -432,7 +432,7 @@ static bool shouldAllowExternalLoad(const URL& url)
 static void* openFunc(const char* uri)
 {
     ASSERT(XMLDocumentParserScope::currentCachedResourceLoader);
-    ASSERT(currentThread() == libxmlLoaderThread);
+    ASSERT(&Thread::current() == libxmlLoaderThread);
 
     URL url(URL(), uri);
 
@@ -495,17 +495,20 @@ static void errorFunc(void*, const char*, ...)
 }
 #endif
 
-static bool didInit = false;
-
-Ref<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerPtr handlers, void* userData)
+static void initializeXMLParser()
 {
-    if (!didInit) {
+    static std::once_flag flag;
+    std::call_once(flag, [&] {
         xmlInitParser();
         xmlRegisterInputCallbacks(matchFunc, openFunc, readFunc, closeFunc);
         xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc);
-        libxmlLoaderThread = currentThread();
-        didInit = true;
-    }
+        libxmlLoaderThread = &Thread::current();
+    });
+}
+
+Ref<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerPtr handlers, void* userData)
+{
+    initializeXMLParser();
 
     xmlParserCtxtPtr parser = xmlCreatePushParserCtxt(handlers, 0, 0, 0, 0);
     parser->_private = userData;
@@ -522,13 +525,7 @@ Ref<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerPtr hand
 // Chunk should be encoded in UTF-8
 RefPtr<XMLParserContext> XMLParserContext::createMemoryParser(xmlSAXHandlerPtr handlers, void* userData, const CString& chunk)
 {
-    if (!didInit) {
-        xmlInitParser();
-        xmlRegisterInputCallbacks(matchFunc, openFunc, readFunc, closeFunc);
-        xmlRegisterOutputCallbacks(matchFunc, openFunc, writeFunc, closeFunc);
-        libxmlLoaderThread = currentThread();
-        didInit = true;
-    }
+    initializeXMLParser();
 
     // appendFragmentSource() checks that the length doesn't overflow an int.
     xmlParserCtxtPtr parser = xmlCreateMemoryParserCtxt(chunk.data(), chunk.length());
index faa5825..e5c5101 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        WTF shouldn't have both Thread and ThreadIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=180308
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/glib/IconDatabase.cpp:
+        * UIProcess/GenericCallback.h:
+        (WebKit::GenericCallback::~GenericCallback):
+        (WebKit::GenericCallback::performCallbackWithReturnValue):
+
 2017-12-03  Chris Dumez  <cdumez@apple.com>
 
         Support serviceWorker.postMessage() inside service workers
index c377582..07eedcb 100644 (file)
@@ -43,7 +43,7 @@
 #define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD())
 
 // For methods that are meant to support the sync thread ONLY
-#define IS_ICON_SYNC_THREAD() (m_syncThread->id() == currentThread())
+#define IS_ICON_SYNC_THREAD() (m_syncThread == &Thread::current())
 #define ASSERT_ICON_SYNC_THREAD() ASSERT(IS_ICON_SYNC_THREAD())
 
 using namespace WebCore;
index 2b7b2f5..bac6dca 100644 (file)
@@ -94,13 +94,13 @@ public:
 
     virtual ~GenericCallback()
     {
-        ASSERT(currentThread() == m_originThreadID);
+        ASSERT(m_originThread.ptr() == &Thread::current());
         ASSERT(!m_callback);
     }
 
     void performCallbackWithReturnValue(T... returnValue)
     {
-        ASSERT(currentThread() == m_originThreadID);
+        ASSERT(m_originThread.ptr() == &Thread::current());
 
         if (!m_callback)
             return;
@@ -117,7 +117,7 @@ public:
 
     void invalidate(Error error = Error::Unknown) final
     {
-        ASSERT(currentThread() == m_originThreadID);
+        ASSERT(m_originThread.ptr() == &Thread::current());
 
         if (!m_callback)
             return;
@@ -144,7 +144,7 @@ private:
     std::optional<CallbackFunction> m_callback;
 
 #ifndef NDEBUG
-    ThreadIdentifier m_originThreadID { currentThread() };
+    Ref<Thread> m_originThread { Thread::current() };
 #endif
 };
 
index ef68a95..50a1308 100644 (file)
@@ -1,3 +1,21 @@
+2017-12-03  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        WTF shouldn't have both Thread and ThreadIdentifier
+        https://bugs.webkit.org/show_bug.cgi?id=180308
+
+        Reviewed by Darin Adler.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (dumpRenderTree):
+        (runThread): Deleted.
+        (runPthread): Deleted.
+        (testThreadIdentifierMap): Deleted.
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/ParkingLot.cpp:
+        * TestWebKitAPI/Tests/WTF/Threading.cpp: Added.
+        (TestWebKitAPI::TEST):
+
 2017-12-03  Aakash Jain  <aakash_jain@apple.com>
 
         webkitpy EWS keeps retrying a failing patch
index 327f20b..5452d2d 100644 (file)
@@ -1065,36 +1065,6 @@ static void setDefaultsToConsistentValuesForTesting()
     [[NSUserDefaults standardUserDefaults] setVolatileDomain:processInstanceDefaults forName:NSArgumentDomain];
 }
 
-static void runThread()
-{
-    static ThreadIdentifier previousId = 0;
-    ThreadIdentifier currentId = currentThread();
-    // Verify 2 successive threads do not get the same Id.
-    ASSERT(previousId != currentId);
-    previousId = currentId;
-}
-
-static void* runPthread(void*)
-{
-    runThread();
-    return nullptr;
-}
-
-static void testThreadIdentifierMap()
-{
-    // Imitate 'foreign' threads that are not created by WTF.
-    pthread_t pthread;
-    pthread_create(&pthread, 0, &runPthread, 0);
-    pthread_join(pthread, 0);
-
-    pthread_create(&pthread, 0, &runPthread, 0);
-    pthread_join(pthread, 0);
-
-    // Now create another thread using WTF. On OSX, it will have the same pthread handle
-    // but should get a different RefPtr<Thread>.
-    Thread::create("DumpRenderTree: test", runThread);
-}
-
 static void allocateGlobalControllers()
 {
     // FIXME: We should remove these and move to the ObjC standard [Foo sharedInstance] model
@@ -1283,9 +1253,6 @@ void dumpRenderTree(int argc, const char *argv[])
     [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"localhost"];
     [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:@"127.0.0.1"];
 
-    // http://webkit.org/b/32689
-    testThreadIdentifierMap();
-
     if (threaded)
         startJavaScriptThreads();
 
index 7e31f30..5ac5e61 100644 (file)
@@ -141,6 +141,7 @@ set(TestWTF_SOURCES
     ${TESTWEBKITAPI_DIR}/Tests/WTF/TextBreakIterator.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadGroup.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/ThreadMessages.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WTF/Threading.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Time.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/UniqueRef.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WTF/Variant.cpp
index 8328cea..c52d7e9 100644 (file)
                E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
                E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
                E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; };
+               E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38A0D341FD50CBC00E98C8B /* Threading.cpp */; };
                E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */; };
                ECA680CE1E68CC0900731D20 /* StringUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = ECA680CD1E68CC0900731D20 /* StringUtilities.mm */; };
                F407FE391F1D0DFC0017CF25 /* enormous.svg in Copy Resources */ = {isa = PBXBuildFile; fileRef = F407FE381F1D0DE60017CF25 /* enormous.svg */; };
                E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = "<group>"; };
                E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
                E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NavigatorLanguage.mm; sourceTree = "<group>"; };
+               E38A0D341FD50CBC00E98C8B /* Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Threading.cpp; sourceTree = "<group>"; };
                E3953F951F2CF32100A76A2E /* Signals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Signals.cpp; sourceTree = "<group>"; };
                E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGroup.cpp; sourceTree = "<group>"; };
                E40019301ACE9B5C001B0A2A /* BloomFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BloomFilter.cpp; sourceTree = "<group>"; };
                                5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */,
                                9329AA281DE3F81E003ABD07 /* TextBreakIterator.cpp */,
                                E3DEA8101F0A588000CBC2E8 /* ThreadGroup.cpp */,
+                               E38A0D341FD50CBC00E98C8B /* Threading.cpp */,
                                5311BD5D1EA9490D00525281 /* ThreadMessages.cpp */,
                                0F2C20B71DCD544800542D9E /* Time.cpp */,
                                5C5E633D1D0B67940085A025 /* UniqueRef.cpp */,
                                7C83DF401D0A590C00FEBCF3 /* TestsController.cpp in Sources */,
                                9329AA291DE3F81E003ABD07 /* TextBreakIterator.cpp in Sources */,
                                E3DEA8111F0A589000CBC2E8 /* ThreadGroup.cpp in Sources */,
+                               E38A0D351FD50CC300E98C8B /* Threading.cpp in Sources */,
                                5311BD5E1EA9490E00525281 /* ThreadMessages.cpp in Sources */,
                                0F2C20B81DCD545000542D9E /* Time.cpp in Sources */,
                                7C83E03B1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */,
index ba8dd56..f9440d0 100644 (file)
@@ -51,7 +51,6 @@ struct SingleLatchTest {
                 Thread::create(
                     "Parking Test Thread",
                     [&] () {
-                        EXPECT_NE(0u, currentThread());
                         down();
 
                         std::lock_guard<std::mutex> locker(lock);
diff --git a/Tools/TestWebKitAPI/Tests/WTF/Threading.cpp b/Tools/TestWebKitAPI/Tests/WTF/Threading.cpp
new file mode 100644 (file)
index 0000000..3468d15
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * 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.
+ */
+
+#include "config.h"
+
+#include <wtf/Threading.h>
+#include <wtf/Vector.h>
+
+namespace TestWebKitAPI {
+
+#if USE(PTHREADS)
+TEST(WTF, ThreadingThreadIdentity)
+{
+    // http://webkit.org/b/32689
+    static Thread* thread1;
+    static Thread* thread2;
+
+    // Imitate 'foreign' threads that are not created by WTF.
+    pthread_t pthread;
+    pthread_create(&pthread, nullptr, [] (void*) -> void* {
+        thread1 = &Thread::current();
+        thread1->ref();
+        return nullptr;
+    }, nullptr);
+    pthread_join(pthread, nullptr);
+
+    pthread_create(&pthread, nullptr, [] (void*) -> void* {
+        thread2 = &Thread::current();
+        thread2->ref();
+        return nullptr;
+    }, nullptr);
+    pthread_join(pthread, nullptr);
+
+    // Now create another thread using WTF. On OSX, it may have the same pthread handle
+    // but should get a different RefPtr<Thread> if the previous RefPtr<Thread> is held.
+    Thread::create("DumpRenderTree: test", [] {
+        EXPECT_TRUE(thread1 != &Thread::current());
+        EXPECT_TRUE(thread2 != &Thread::current());
+        EXPECT_TRUE(thread1 != thread2);
+        thread1->deref();
+        thread2->deref();
+    })->waitForCompletion();
+}
+#endif // USE(PTHREADS)
+
+} // namespace TestWebKitAPI