Ignore:
Timestamp:
Feb 17, 2012, 1:54:55 PM (13 years ago)
Author:
[email protected]
Message:

Remove unused parameters from WTF threading API
https://bugs.webkit.org/show_bug.cgi?id=78389

Patch by Kalev Lember <[email protected]> on 2012-02-17
Reviewed by Adam Roben.

waitForThreadCompletion() had an out param 'void result' to get the
'void *' returned by ThreadFunction. However, the implementation in
ThreadingWin.cpp ignored the out param, not filling it in. This had
led to a situation where none of the client code made use of the param
and just ignored it.

To clean this up, the patch changes the signature of ThreadFunction to
return void instead of void* and drops the the unused 'void result'
parameter from waitForThreadCompletion. Also, all client code is
updated for the API change.

As mentioned in https://bugs.webkit.org/show_bug.cgi?id=78389 , even
though the change only affects internal API, Safari is using it
directly and we'll need to keep the old versions around for ABI
compatibility. For this, the patch adds compatibility wrappers with
the old ABI.

Source/JavaScriptCore:

(JSC::SamplingThread::threadStartFunc):
(JSC::SamplingThread::stop):

  • bytecode/SamplingTool.h:

(SamplingThread):

  • heap/Heap.cpp:

(JSC::Heap::~Heap):
(JSC::Heap::blockFreeingThreadStartFunc):

  • heap/Heap.h:
  • heap/MarkStack.cpp:

(JSC::MarkStackThreadSharedData::markingThreadStartFunc):
(JSC::MarkStackThreadSharedData::~MarkStackThreadSharedData):

  • heap/MarkStack.h:

(MarkStackThreadSharedData):

  • wtf/ParallelJobsGeneric.cpp:

(WTF::ParallelEnvironment::ThreadPrivate::workerThread):

  • wtf/ParallelJobsGeneric.h:

(ThreadPrivate):

  • wtf/ThreadFunctionInvocation.h: Update the signature of

ThreadFunction.
(WTF):

  • wtf/Threading.cpp:

(WTF::threadEntryPoint): Update for ThreadFunction signature change.
(WTF):
(WTF::ThreadFunctionWithReturnValueInvocation::ThreadFunctionWithReturnValueInvocation):
ABI compatibility function for Safari.
(ThreadFunctionWithReturnValueInvocation): Ditto.
(WTF::compatEntryPoint): Ditto.
(WTF::createThread): Ditto.
(WTF::waitForThreadCompletion): Ditto.

  • wtf/Threading.h: Update the signature of ThreadFunction and

waitForThreadCompletion.
(WTF):

  • wtf/ThreadingPthreads.cpp: Implement the new API.

(WTF::wtfThreadEntryPoint):
(WTF):
(WTF::createThreadInternal):
(WTF::waitForThreadCompletion):

  • wtf/ThreadingWin.cpp: Implement the new API.

(WTF::wtfThreadEntryPoint):
(WTF::waitForThreadCompletion):

Source/WebCore:

  • bindings/js/GCController.cpp:

(WebCore::collect):
(WebCore::GCController::garbageCollectOnAlternateThreadForDebugging):

  • fileapi/FileThread.cpp:

(WebCore::FileThread::fileThreadStart):
(WebCore::FileThread::runLoop):

  • fileapi/FileThread.h:

(FileThread):

  • loader/icon/IconDatabase.cpp:

(WebCore::IconDatabase::close):
(WebCore::IconDatabase::iconDatabaseSyncThreadStart):
(WebCore::IconDatabase::iconDatabaseSyncThread):
(WebCore::IconDatabase::syncThreadMainLoop):

  • loader/icon/IconDatabase.h:

(IconDatabase):

  • page/scrolling/ScrollingThread.cpp:

(WebCore::ScrollingThread::threadCallback):

  • page/scrolling/ScrollingThread.h:

(ScrollingThread):

  • platform/audio/HRTFDatabaseLoader.cpp:

(WebCore::databaseLoaderEntry):
(WebCore::HRTFDatabaseLoader::waitForLoaderThreadCompletion):

  • platform/audio/ReverbConvolver.cpp:

(WebCore::backgroundThreadEntry):
(WebCore::ReverbConvolver::~ReverbConvolver):

  • platform/network/cf/LoaderRunLoopCF.cpp:

(WebCore::runLoaderThread):

  • storage/DatabaseThread.cpp:

(WebCore::DatabaseThread::databaseThreadStart):
(WebCore::DatabaseThread::databaseThread):

  • storage/DatabaseThread.h:

(DatabaseThread):

  • storage/LocalStorageThread.cpp:

(WebCore::LocalStorageThread::threadEntryPointCallback):
(WebCore::LocalStorageThread::threadEntryPoint):
(WebCore::LocalStorageThread::terminate):

  • storage/LocalStorageThread.h:

(LocalStorageThread):

  • webaudio/AsyncAudioDecoder.cpp:

(WebCore::AsyncAudioDecoder::~AsyncAudioDecoder):
(WebCore::AsyncAudioDecoder::threadEntry):

  • webaudio/AsyncAudioDecoder.h:

(AsyncAudioDecoder):

  • webaudio/OfflineAudioDestinationNode.cpp:

(WebCore::OfflineAudioDestinationNode::uninitialize):
(WebCore::OfflineAudioDestinationNode::renderEntry):

  • webaudio/OfflineAudioDestinationNode.h:

(OfflineAudioDestinationNode):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThread::workerThreadStart):
(WebCore::WorkerThread::workerThread):

  • workers/WorkerThread.h:

(WorkerThread):

Source/WebKit/win:

  • WebKit.vcproj/WebKit_Cairo.def: Add the new functions.
  • WebKit.vcproj/WebKit_Cairo_debug.def: Ditto.

Source/WebKit2:

  • Platform/WorkQueue.h:

(WorkQueue):

  • Platform/gtk/WorkQueueGtk.cpp:

(WorkQueue::startWorkQueueThread):

  • UIProcess/Launcher/mac/ThreadLauncherMac.mm:

(WebKit::webThreadBody):

  • UIProcess/Launcher/qt/ThreadLauncherQt.cpp:

(WebKit::webThreadBody):

  • UIProcess/Launcher/win/ThreadLauncherWin.cpp:

(WebKit::webThreadBody):

  • WebProcess/WebProcess.cpp:

(WebKit::randomCrashThread):

  • win/WebKit2.def:
  • win/WebKit2CFLite.def:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/wtf/ThreadingPthreads.cpp

    r101041 r108119  
    4141#include "RandomNumberSeed.h"
    4242#include "StdLibExtras.h"
     43#include "ThreadFunctionInvocation.h"
    4344#include "ThreadIdentifierDataPthreads.h"
    4445#include "ThreadSpecific.h"
    4546#include "UnusedParam.h"
     47#include <wtf/OwnPtr.h>
     48#include <wtf/PassOwnPtr.h>
    4649#include <wtf/WTFThreadData.h>
    4750#include <errno.h>
     
    153156}
    154157
     158static void* wtfThreadEntryPoint(void* param)
     159{
     160    // Balanced by .leakPtr() in createThreadInternal.
     161    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFunctionInvocation*>(param));
     162    invocation->function(invocation->data);
     163
     164    return 0;
     165}
     166
    155167#if PLATFORM(BLACKBERRY)
    156168ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char* threadName)
     
    172184    }
    173185
     186    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));
    174187    pthread_t threadHandle;
    175     if (pthread_create(&threadHandle, &attr, entryPoint, data)) {
     188    if (pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get())) {
    176189        LOG_ERROR("pthread_create() failed: %d", errno);
    177190        threadHandle = 0;
     
    184197        return 0;
    185198
     199    // Balanced by adoptPtr() in wtfThreadEntryPoint.
     200    ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr();
     201    UNUSED_PARAM(leakedInvocation);
     202
    186203    return establishIdentifierForPthreadHandle(threadHandle);
    187204}
     
    189206ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)
    190207{
     208    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));
    191209    pthread_t threadHandle;
    192     if (pthread_create(&threadHandle, 0, entryPoint, data)) {
    193         LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data);
     210    if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) {
     211        LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, invocation.get());
    194212        return 0;
    195213    }
     214
     215    // Balanced by adoptPtr() in wtfThreadEntryPoint.
     216    ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr();
     217    UNUSED_PARAM(leakedInvocation);
    196218
    197219    return establishIdentifierForPthreadHandle(threadHandle);
     
    218240}
    219241
    220 int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
     242int waitForThreadCompletion(ThreadIdentifier threadID)
    221243{
    222244    ASSERT(threadID);
     
    226248        return 0;
    227249
    228     int joinResult = pthread_join(pthreadHandle, result);
     250    int joinResult = pthread_join(pthreadHandle, 0);
    229251    if (joinResult == EDEADLK)
    230252        LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", threadID);
Note: See TracChangeset for help on using the changeset viewer.