Skip to content

Commit 7b241ad

Browse files
WTF shouldn't have both Thread and ThreadIdentifier
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: http://svn.webkit.org/repository/webkit/trunk@225470 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 633a2a6 commit 7b241ad

File tree

72 files changed

+997
-518
lines changed

Some content is hidden

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

72 files changed

+997
-518
lines changed

Source/JavaScriptCore/ChangeLog

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2017-12-03 Yusuke Suzuki <[email protected]>
2+
3+
WTF shouldn't have both Thread and ThreadIdentifier
4+
https://bugs.webkit.org/show_bug.cgi?id=180308
5+
6+
Reviewed by Darin Adler.
7+
8+
* heap/MachineStackMarker.cpp:
9+
(JSC::MachineThreads::tryCopyOtherThreadStacks):
10+
* llint/LLIntSlowPaths.cpp:
11+
(JSC::LLInt::llint_trace_operand):
12+
(JSC::LLInt::llint_trace_value):
13+
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
14+
(JSC::LLInt::traceFunctionPrologue):
15+
* runtime/ExceptionScope.cpp:
16+
(JSC::ExceptionScope::unexpectedExceptionMessage):
17+
* runtime/JSLock.h:
18+
(JSC::JSLock::currentThreadIsHoldingLock):
19+
* runtime/VM.cpp:
20+
(JSC::VM::throwException):
21+
* runtime/VM.h:
22+
(JSC::VM::throwingThread const):
23+
(JSC::VM::clearException):
24+
* tools/HeapVerifier.cpp:
25+
(JSC::HeapVerifier::printVerificationHeader):
26+
127
2017-12-03 Caio Lima <[email protected]>
228

329
Rename DestroyFunc to avoid redefinition on unified build

Source/JavaScriptCore/heap/MachineStackMarker.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void
151151
{
152152
unsigned index = 0;
153153
for (auto& thread : threads) {
154-
if (thread.get() != currentThread) {
154+
if (thread.ptr() != &currentThread) {
155155
auto result = thread->suspend();
156156
if (result)
157157
isSuspended.set(index);
@@ -160,8 +160,8 @@ bool MachineThreads::tryCopyOtherThreadStacks(const AbstractLocker& locker, void
160160
// These threads will be removed from the ThreadGroup. Thus, we do not do anything here except for reporting.
161161
ASSERT(result.error() != KERN_SUCCESS);
162162
WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION,
163-
"JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p] id %u.",
164-
result.error(), index, threads.size(), thread.ptr(), thread->id());
163+
"JavaScript garbage collection encountered an invalid thread (err 0x%x): Thread [%d/%d: %p].",
164+
result.error(), index, threads.size(), thread.ptr());
165165
#endif
166166
}
167167
}

Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ namespace JSC { namespace LLInt {
191191
extern "C" SlowPathReturnType llint_trace_operand(ExecState* exec, Instruction* pc, int fromWhere, int operand)
192192
{
193193
LLINT_BEGIN();
194-
dataLogF("<%d> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
195-
currentThread(),
194+
dataLogF("<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d\n",
195+
&Thread::current(),
196196
exec->codeBlock(),
197197
exec,
198198
static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -215,8 +215,8 @@ extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc
215215
} u;
216216
u.asValue = JSValue::encode(value);
217217
dataLogF(
218-
"<%d> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
219-
currentThread(),
218+
"<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %d: %08x:%08x: %s\n",
219+
&Thread::current(),
220220
exec->codeBlock(),
221221
exec,
222222
static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -232,7 +232,7 @@ extern "C" SlowPathReturnType llint_trace_value(ExecState* exec, Instruction* pc
232232

233233
LLINT_SLOW_PATH_DECL(trace_prologue)
234234
{
235-
dataLogF("<%d> %p / %p: in prologue of ", currentThread(), exec->codeBlock(), exec);
235+
dataLogF("<%p> %p / %p: in prologue of ", &Thread::current(), exec->codeBlock(), exec);
236236
dataLog(*exec->codeBlock(), "\n");
237237
LLINT_END_IMPL();
238238
}
@@ -242,7 +242,7 @@ static void traceFunctionPrologue(ExecState* exec, const char* comment, CodeSpec
242242
JSFunction* callee = jsCast<JSFunction*>(exec->jsCallee());
243243
FunctionExecutable* executable = callee->jsExecutable();
244244
CodeBlock* codeBlock = executable->codeBlockFor(kind);
245-
dataLogF("<%d> %p / %p: in %s of ", currentThread(), codeBlock, exec, comment);
245+
dataLogF("<%p> %p / %p: in %s of ", &Thread::current(), codeBlock, exec, comment);
246246
dataLog(*codeBlock);
247247
dataLogF(" function %p, executable %p; numVars = %u, numParameters = %u, numCalleeLocals = %u, caller = %p.\n",
248248
callee, executable, codeBlock->m_numVars, codeBlock->numParameters(), codeBlock->m_numCalleeLocals, exec->callerFrame());
@@ -275,8 +275,8 @@ LLINT_SLOW_PATH_DECL(trace_arityCheck_for_construct)
275275
LLINT_SLOW_PATH_DECL(trace)
276276
{
277277
OpcodeID opcodeID = Interpreter::getOpcodeID(pc[0].u.opcode);
278-
dataLogF("<%d> %p / %p: executing bc#%zu, %s, pc = %p\n",
279-
currentThread(),
278+
dataLogF("<%p> %p / %p: executing bc#%zu, %s, pc = %p\n",
279+
&Thread::current(),
280280
exec->codeBlock(),
281281
exec,
282282
static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),
@@ -294,8 +294,8 @@ LLINT_SLOW_PATH_DECL(trace)
294294

295295
LLINT_SLOW_PATH_DECL(special_trace)
296296
{
297-
dataLogF("<%d> %p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
298-
currentThread(),
297+
dataLogF("<%p> %p / %p: executing special case bc#%zu, op#%u, return PC is %p\n",
298+
&Thread::current(),
299299
exec->codeBlock(),
300300
exec,
301301
static_cast<intptr_t>(pc - exec->codeBlock()->instructions().begin()),

Source/JavaScriptCore/runtime/ExceptionScope.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ CString ExceptionScope::unexpectedExceptionMessage()
5555
{
5656
StringPrintStream out;
5757

58-
out.println("Unexpected exception observed on thread ", currentThread(), " at:");
58+
out.println("Unexpected exception observed on thread ", Thread::current(), " at:");
5959
auto currentStack = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit(), 1);
6060
currentStack->dump(out, " ");
6161

6262
if (!m_vm.nativeStackTraceOfLastThrow())
6363
return CString();
6464

65-
out.println("The exception was thrown from thread ", m_vm.throwingThread(), " at:");
65+
out.println("The exception was thrown from thread ", *m_vm.throwingThread(), " at:");
6666
m_vm.nativeStackTraceOfLastThrow()->dump(out, " ");
6767

6868
return out.toCString();

Source/JavaScriptCore/runtime/JSLock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class JSLock : public ThreadSafeRefCounted<JSLock> {
9898
return m_ownerThread;
9999
return std::nullopt;
100100
}
101-
bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread->id() == currentThread(); }
101+
bool currentThreadIsHoldingLock() { return m_hasOwnerThread && m_ownerThread.get() == &Thread::current(); }
102102

103103
void willDestroyVM(VM*);
104104

Source/JavaScriptCore/runtime/VM.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ void VM::throwException(ExecState* exec, Exception* exception)
689689

690690
#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
691691
m_nativeStackTraceOfLastThrow = StackTrace::captureStackTrace(Options::unexpectedExceptionStackTraceLimit());
692-
m_throwingThread = currentThread();
692+
m_throwingThread = &Thread::current();
693693
#endif
694694
}
695695

Source/JavaScriptCore/runtime/VM.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
711711

712712
#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
713713
StackTrace* nativeStackTraceOfLastThrow() const { return m_nativeStackTraceOfLastThrow.get(); }
714-
ThreadIdentifier throwingThread() const { return m_throwingThread; }
714+
Thread* throwingThread() const { return m_throwingThread.get(); }
715715
#endif
716716

717717
#if USE(CF)
@@ -754,7 +754,7 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
754754
#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
755755
m_needExceptionCheck = false;
756756
m_nativeStackTraceOfLastThrow = nullptr;
757-
m_throwingThread = 0;
757+
m_throwingThread = nullptr;
758758
#endif
759759
m_exception = nullptr;
760760
}
@@ -806,7 +806,7 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
806806
mutable bool m_needExceptionCheck { false };
807807
std::unique_ptr<StackTrace> m_nativeStackTraceOfLastThrow;
808808
std::unique_ptr<StackTrace> m_nativeStackTraceOfLastSimulatedThrow;
809-
ThreadIdentifier m_throwingThread;
809+
RefPtr<Thread> m_throwingThread;
810810
#endif
811811

812812
bool m_failNextNewCodeBlock { false };

Source/JavaScriptCore/tools/HeapVerifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void HeapVerifier::printVerificationHeader()
143143
RELEASE_ASSERT(m_heap->collectionScope());
144144
CollectionScope scope = currentCycle().scope;
145145
MonotonicTime gcCycleTimestamp = currentCycle().timestamp;
146-
dataLog("Verifying heap in [p", getCurrentProcessID(), ", t", currentThread(), "] vm ",
146+
dataLog("Verifying heap in [p", getCurrentProcessID(), ", ", Thread::current(), "] vm ",
147147
RawPointer(m_heap->vm()), " on ", scope, " GC @ ", gcCycleTimestamp, "\n");
148148
}
149149

Source/WTF/ChangeLog

+53
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,56 @@
1+
2017-12-03 Yusuke Suzuki <[email protected]>
2+
3+
WTF shouldn't have both Thread and ThreadIdentifier
4+
https://bugs.webkit.org/show_bug.cgi?id=180308
5+
6+
Reviewed by Darin Adler.
7+
8+
We should use a pointer of WTF::Thread instead of ThreadIdentifier.
9+
10+
One problem is that Windows support library uses WTF::createThread,
11+
which returns ThreadIdentifier. So we cannot drop ThreadIdentifier
12+
in Windows environment. This patch keeps ThreadIdentifier in Windows.
13+
14+
* wtf/MainThread.cpp:
15+
(WTF::initializeMainThread):
16+
(WTF::isMainThread):
17+
(WTF::canAccessThreadLocalDataForThread):
18+
* wtf/MainThread.h:
19+
* wtf/ParkingLot.cpp:
20+
(WTF::ParkingLot::parkConditionallyImpl):
21+
(WTF::ParkingLot::unparkOne):
22+
(WTF::ParkingLot::unparkOneImpl):
23+
(WTF::ParkingLot::unparkCount):
24+
* wtf/RecursiveLockAdapter.h:
25+
(WTF::RecursiveLockAdapter::lock):
26+
(WTF::RecursiveLockAdapter::unlock):
27+
(WTF::RecursiveLockAdapter::tryLock):
28+
* wtf/Threading.cpp:
29+
(WTF::Thread::dump const):
30+
* wtf/Threading.h:
31+
(WTF::Thread::id const):
32+
(WTF::Thread::operator==): Deleted.
33+
(WTF::Thread::operator!=): Deleted.
34+
(WTF::currentThread): Deleted.
35+
* wtf/ThreadingPrimitives.h:
36+
* wtf/ThreadingPthreads.cpp:
37+
(WTF::Thread::waitForCompletion):
38+
(WTF::Thread::detach):
39+
(WTF::Thread::initializeCurrentTLS):
40+
(WTF::Thread::suspend):
41+
(WTF::Thread::establishPlatformSpecificHandle):
42+
(WTF::Thread::currentID): Deleted.
43+
* wtf/ThreadingWin.cpp:
44+
(WTF::Thread::waitForCompletion):
45+
(WTF::Thread::suspend):
46+
(WTF::Thread::currentDying):
47+
* wtf/mac/MainThreadMac.mm:
48+
(WTF::initializeApplicationUIThread):
49+
(WTF::initializeWebThreadPlatform):
50+
(WTF::canAccessThreadLocalDataForThread):
51+
(WTF::initializeApplicationUIThreadIdentifier): Deleted.
52+
(WTF::initializeWebThreadIdentifier): Deleted.
53+
154
2017-12-03 Darin Adler <[email protected]>
255

356
Add WTF::Hasher, an easier to use replacement for WTF::IntegerHasher

Source/WTF/wtf/MainThread.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace WTF {
4444

4545
static bool callbacksPaused; // This global variable is only accessed from main thread.
4646
#if !PLATFORM(COCOA)
47-
static ThreadIdentifier mainThreadIdentifier;
47+
static Thread* mainThread { nullptr };
4848
#endif
4949

5050
static StaticLock mainThreadFunctionQueueMutex;
@@ -62,7 +62,7 @@ void initializeMainThread()
6262
std::call_once(initializeKey, [] {
6363
initializeThreading();
6464
#if !PLATFORM(COCOA)
65-
mainThreadIdentifier = currentThread();
65+
mainThread = &Thread::current();
6666
#endif
6767
initializeMainThreadPlatform();
6868
initializeGCThreads();
@@ -72,7 +72,7 @@ void initializeMainThread()
7272
#if !PLATFORM(COCOA)
7373
bool isMainThread()
7474
{
75-
return currentThread() == mainThreadIdentifier;
75+
return mainThread == &Thread::current();
7676
}
7777
#endif
7878

@@ -98,9 +98,9 @@ void initializeWebThread()
9898
#endif // PLATFORM(COCOA)
9999

100100
#if !USE(WEB_THREAD)
101-
bool canAccessThreadLocalDataForThread(ThreadIdentifier threadId)
101+
bool canAccessThreadLocalDataForThread(Thread& thread)
102102
{
103-
return threadId == currentThread();
103+
return &thread == &Thread::current();
104104
}
105105
#endif
106106

Source/WTF/wtf/MainThread.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
namespace WTF {
4040

4141
class PrintStream;
42+
class Thread;
4243

4344
// Must be called from the main thread.
4445
WTF_EXPORT_PRIVATE void initializeMainThread();
@@ -54,14 +55,13 @@ WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
5455

5556
WTF_EXPORT_PRIVATE bool isMainThread();
5657

57-
WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(ThreadIdentifier);
58+
WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(Thread&);
5859

5960
#if USE(WEB_THREAD)
6061
WTF_EXPORT_PRIVATE bool isWebThread();
6162
WTF_EXPORT_PRIVATE bool isUIThread();
6263
WTF_EXPORT_PRIVATE void initializeWebThread();
63-
WTF_EXPORT_PRIVATE void initializeApplicationUIThreadIdentifier();
64-
WTF_EXPORT_PRIVATE void initializeWebThreadIdentifier();
64+
WTF_EXPORT_PRIVATE void initializeApplicationUIThread();
6565
void initializeWebThreadPlatform();
6666
#else
6767
inline bool isWebThread() { return isMainThread(); }
@@ -113,8 +113,7 @@ using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
113113
#endif
114114
#if USE(WEB_THREAD)
115115
using WTF::initializeWebThread;
116-
using WTF::initializeApplicationUIThreadIdentifier;
117-
using WTF::initializeWebThreadIdentifier;
116+
using WTF::initializeApplicationUIThread;
118117
#endif
119118

120119
#endif // MainThread_h

0 commit comments

Comments
 (0)