Remove unused parameters from WTF threading API
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 21:54:55 +0000 (21:54 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2012 21:54:55 +0000 (21:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78389

Patch by Kalev Lember <kalevlember@gmail.com> 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:

* JavaScriptCore.order:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* bytecode/SamplingTool.cpp:
(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:

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

49 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.order
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/bytecode/SamplingTool.cpp
Source/JavaScriptCore/bytecode/SamplingTool.h
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/MarkStack.cpp
Source/JavaScriptCore/heap/MarkStack.h
Source/JavaScriptCore/wtf/ParallelJobsGeneric.cpp
Source/JavaScriptCore/wtf/ParallelJobsGeneric.h
Source/JavaScriptCore/wtf/ThreadFunctionInvocation.h
Source/JavaScriptCore/wtf/Threading.cpp
Source/JavaScriptCore/wtf/Threading.h
Source/JavaScriptCore/wtf/ThreadingPthreads.cpp
Source/JavaScriptCore/wtf/ThreadingWin.cpp
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/GCController.cpp
Source/WebCore/fileapi/FileThread.cpp
Source/WebCore/fileapi/FileThread.h
Source/WebCore/loader/icon/IconDatabase.cpp
Source/WebCore/loader/icon/IconDatabase.h
Source/WebCore/page/scrolling/ScrollingThread.cpp
Source/WebCore/page/scrolling/ScrollingThread.h
Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp
Source/WebCore/platform/audio/ReverbConvolver.cpp
Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp
Source/WebCore/storage/DatabaseThread.cpp
Source/WebCore/storage/DatabaseThread.h
Source/WebCore/storage/LocalStorageThread.cpp
Source/WebCore/storage/LocalStorageThread.h
Source/WebCore/webaudio/AsyncAudioDecoder.cpp
Source/WebCore/webaudio/AsyncAudioDecoder.h
Source/WebCore/webaudio/OfflineAudioDestinationNode.cpp
Source/WebCore/webaudio/OfflineAudioDestinationNode.h
Source/WebCore/workers/WorkerThread.cpp
Source/WebCore/workers/WorkerThread.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebKit.vcproj/WebKit_Cairo.def
Source/WebKit/win/WebKit.vcproj/WebKit_Cairo_debug.def
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/WorkQueue.h
Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp
Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/win/WebKit2.def
Source/WebKit2/win/WebKit2CFLite.def

index 27caf1e..6f6a212 100644 (file)
@@ -1,3 +1,71 @@
+2012-02-17  Kalev Lember  <kalevlember@gmail.com>
+
+        Remove unused parameters from WTF threading API
+        https://bugs.webkit.org/show_bug.cgi?id=78389
+
+        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.
+
+        * JavaScriptCore.order:
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+        * bytecode/SamplingTool.cpp:
+        (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):
+
 2012-02-16  Oliver Hunt  <oliver@apple.com>
 
         Implement Error.stack
index 6fbca7f..e1e1f23 100644 (file)
@@ -58,6 +58,7 @@ __ZN3WTF5Mutex6unlockEv
 __ZN3WTF10StringImpl12sharedBufferEv
 __ZN3WTF10StringImpl8endsWithEPS0_b
 __ZN3WTF12createThreadEPFPvS0_ES0_PKc
+__ZN3WTF12createThreadEPFvPvES0_PKc
 __ZN3WTF20createThreadInternalEPFPvS0_ES0_PKc
 __ZN3WTFL35establishIdentifierForPthreadHandleERKP17_opaque_pthread_t
 __ZN3WTF9HashTableIjSt4pairIjP17_opaque_pthread_tENS_18PairFirstExtractorIS4_EENS_7IntHashIjEENS_14PairHashTraitsINS_10HashTraitsIjEENSA_IS3_EEEESB_E6rehashEi
@@ -1153,6 +1154,7 @@ __ZN3WTF10fastStrDupEPKc
 __ZN3JSC10Identifier11addSlowCaseEPNS_12JSGlobalDataEPN3WTF10StringImplE
 _JSStringRetain
 ___initializeScavenger_block_invoke_1
+__ZN3WTF23waitForThreadCompletionEj
 __ZN3WTF23waitForThreadCompletionEjPPv
 _JSObjectCopyPropertyNames
 __ZN3JSC8JSObject16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
index 2b5dda2..d5fc16a 100644 (file)
@@ -124,6 +124,7 @@ EXPORTS
     ?createTable@HashTable@JSC@@ABEXPAVJSGlobalData@2@@Z
     ?createThread@WTF@@YAIP6APAXPAX@Z0@Z
     ?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
+    ?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z
     ?createTypeError@JSC@@YAPAVJSObject@1@PAVExecState@1@ABVUString@1@@Z
     ?cryptographicallyRandomNumber@WTF@@YAIXZ
     ?cryptographicallyRandomValues@WTF@@YAXPAXI@Z
@@ -364,6 +365,7 @@ EXPORTS
     ?visitChildren@JSGlobalThis@JSC@@KAXPAVJSCell@2@AAVSlotVisitor@2@@Z
     ?visitChildren@JSObject@JSC@@SAXPAVJSCell@2@AAVSlotVisitor@2@@Z
     ?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
+    ?waitForThreadCompletion@WTF@@YAHI@Z
     ?waitForThreadCompletion@WTF@@YAHIPAPAX@Z
     ?writable@PropertyDescriptor@JSC@@QBE_NXZ
     ?writeBarrier@HandleHeap@JSC@@QAEXPAVJSValue@2@ABV32@@Z
index 6431319..077f041 100644 (file)
@@ -210,7 +210,7 @@ bool SamplingThread::s_running = false;
 unsigned SamplingThread::s_hertz = 10000;
 ThreadIdentifier SamplingThread::s_samplingThread;
 
-void* SamplingThread::threadStartFunc(void*)
+void SamplingThread::threadStartFunc(void*)
 {
     while (s_running) {
         sleepForMicroseconds(hertz2us(s_hertz));
@@ -225,8 +225,6 @@ void* SamplingThread::threadStartFunc(void*)
         SamplingTool::sample();
 #endif
     }
-
-    return 0;
 }
 
 
@@ -243,7 +241,7 @@ void SamplingThread::stop()
 {
     ASSERT(s_running);
     s_running = false;
-    waitForThreadCompletion(s_samplingThread, 0);
+    waitForThreadCompletion(s_samplingThread);
 }
 
 
index 32a44ad..28fd528 100644 (file)
@@ -223,7 +223,7 @@ namespace JSC {
         JS_EXPORT_PRIVATE static void start(unsigned hertz=10000);
         JS_EXPORT_PRIVATE static void stop();
 
-        static void* threadStartFunc(void*);
+        static void threadStartFunc(void*);
     };
 
     class SamplingTool {
index a064eb5..1333c7b 100644 (file)
@@ -345,7 +345,7 @@ Heap::~Heap()
         m_blockFreeingThreadShouldQuit = true;
         m_freeBlockCondition.broadcast();
     }
-    waitForThreadCompletion(m_blockFreeingThread, 0);
+    waitForThreadCompletion(m_blockFreeingThread);
 
     // The destroy function must already have been called, so assert this.
     ASSERT(!m_globalData);
@@ -407,10 +407,9 @@ void Heap::waitForRelativeTime(double relative)
     waitForRelativeTimeWhileHoldingLock(relative);
 }
 
-void* Heap::blockFreeingThreadStartFunc(void* heap)
+void Heap::blockFreeingThreadStartFunc(void* heap)
 {
     static_cast<Heap*>(heap)->blockFreeingThreadMain();
-    return 0;
 }
 
 void Heap::blockFreeingThreadMain()
index 3092407..250f3ef 100644 (file)
@@ -187,7 +187,7 @@ namespace JSC {
         void waitForRelativeTimeWhileHoldingLock(double relative);
         void waitForRelativeTime(double relative);
         void blockFreeingThreadMain();
-        static void* blockFreeingThreadStartFunc(void* heap);
+        static void blockFreeingThreadStartFunc(void* heap);
         
         const HeapSize m_heapSize;
         const size_t m_minBytesPerCycle;
index 9e0dc5e..eab2482 100644 (file)
@@ -226,10 +226,9 @@ void MarkStackThreadSharedData::markingThreadMain()
     slotVisitor.drainFromShared(SlotVisitor::SlaveDrain);
 }
 
-void* MarkStackThreadSharedData::markingThreadStartFunc(void* shared)
+void MarkStackThreadSharedData::markingThreadStartFunc(void* shared)
 {
     static_cast<MarkStackThreadSharedData*>(shared)->markingThreadMain();
-    return 0;
 }
 #endif
 
@@ -258,7 +257,7 @@ MarkStackThreadSharedData::~MarkStackThreadSharedData()
         m_markingCondition.broadcast();
     }
     for (unsigned i = 0; i < m_markingThreads.size(); ++i)
-        waitForThreadCompletion(m_markingThreads[i], 0);
+        waitForThreadCompletion(m_markingThreads[i]);
 #endif
 }
     
index a441cde..0695b1b 100644 (file)
@@ -178,7 +178,7 @@ namespace JSC {
 
 #if ENABLE(PARALLEL_GC)
         void markingThreadMain();
-        static void* markingThreadStartFunc(void* heap);
+        static void markingThreadStartFunc(void* heap);
 #endif
 
         JSGlobalData* m_globalData;
index fd5b1f8..2cc0bc6 100644 (file)
@@ -121,7 +121,7 @@ void ParallelEnvironment::ThreadPrivate::waitForFinish()
         m_threadCondition.wait(m_mutex);
 }
 
-void* ParallelEnvironment::ThreadPrivate::workerThread(void* threadData)
+void ParallelEnvironment::ThreadPrivate::workerThread(void* threadData)
 {
     ThreadPrivate* sharedThread = reinterpret_cast<ThreadPrivate*>(threadData);
     MutexLocker lock(sharedThread->m_mutex);
@@ -136,7 +136,6 @@ void* ParallelEnvironment::ThreadPrivate::workerThread(void* threadData)
 
         sharedThread->m_threadCondition.wait(sharedThread->m_mutex);
     }
-    return 0;
 }
 
 } // namespace WTF
index 1c7d63c..6de7106 100644 (file)
@@ -69,7 +69,7 @@ public:
             return adoptRef(new ThreadPrivate());
         }
 
-        static void* workerThread(void*);
+        static void workerThread(void*);
 
     private:
         ThreadIdentifier m_threadID;
index f1e1472..2d8599e 100644 (file)
@@ -31,7 +31,7 @@
 
 namespace WTF {
 
-typedef void* (*ThreadFunction)(void* argument);
+typedef void (*ThreadFunction)(void* argument);
 
 struct ThreadFunctionInvocation {
     ThreadFunctionInvocation(ThreadFunction function, void* data)
index d8dbbae..8d658e9 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "config.h"
 #include "Threading.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 
 #include <string.h>
 
@@ -47,7 +49,7 @@ public:
     Mutex creationMutex;
 };
 
-static void* threadEntryPoint(void* contextData)
+static void threadEntryPoint(void* contextData)
 {
     NewThreadContext* context = reinterpret_cast<NewThreadContext*>(contextData);
 
@@ -64,7 +66,7 @@ static void* threadEntryPoint(void* contextData)
     void* data = context->data;
     delete context;
 
-    return entryPoint(data);
+    entryPoint(data);
 }
 
 ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* name)
@@ -86,14 +88,58 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char*
 
 #if PLATFORM(MAC) || PLATFORM(WIN)
 
+// For ABI compatibility with Safari on Mac / Windows: Safari uses the private
+// createThread() and waitForThreadCompletion() functions directly and we need
+// to keep the old ABI compatibility until it's been rebuilt.
+
+typedef void* (*ThreadFunctionWithReturnValue)(void* argument);
+
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data, const char* name);
+
+struct ThreadFunctionWithReturnValueInvocation {
+    ThreadFunctionWithReturnValueInvocation(ThreadFunctionWithReturnValue function, void* data)
+        : function(function)
+        , data(data)
+    {
+    }
+
+    ThreadFunctionWithReturnValue function;
+    void* data;
+};
+
+static void compatEntryPoint(void* param)
+{
+    // Balanced by .leakPtr() in createThread.
+    OwnPtr<ThreadFunctionWithReturnValueInvocation> invocation = adoptPtr(static_cast<ThreadFunctionWithReturnValueInvocation*>(param));
+    invocation->function(invocation->data);
+}
+
+ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data, const char* name)
+{
+    OwnPtr<ThreadFunctionWithReturnValueInvocation> invocation = adoptPtr(new ThreadFunctionWithReturnValueInvocation(entryPoint, data));
+
+    // Balanced by adoptPtr() in compatEntryPoint.
+    return createThread(compatEntryPoint, invocation.leakPtr(), name);
+}
+
+WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier, void**);
+
+int waitForThreadCompletion(ThreadIdentifier threadID, void**)
+{
+    return waitForThreadCompletion(threadID);
+}
+
 // This function is deprecated but needs to be kept around for backward
 // compatibility. Use the 3-argument version of createThread above.
 
-WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction entryPoint, void* data);
+WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data);
 
-ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
+ThreadIdentifier createThread(ThreadFunctionWithReturnValue entryPoint, void* data)
 {
-    return createThread(entryPoint, data, 0);
+    OwnPtr<ThreadFunctionWithReturnValueInvocation> invocation = adoptPtr(new ThreadFunctionWithReturnValueInvocation(entryPoint, data));
+
+    // Balanced by adoptPtr() in compatEntryPoint.
+    return createThread(compatEntryPoint, invocation.leakPtr(), 0);
 }
 #endif
 
index 1dee5da..b5d4326 100644 (file)
@@ -78,7 +78,7 @@
 namespace WTF {
 
 typedef uint32_t ThreadIdentifier;
-typedef void* (*ThreadFunction)(void* argument);
+typedef void (*ThreadFunction)(void* argument);
 
 // This function must be called from the main thread. It is safe to call it repeatedly.
 // Darwin is an exception to this rule: it is OK to call it from any thread, the only 
@@ -97,7 +97,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadN
 void initializeCurrentThreadInternal(const char* threadName);
 
 WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
-WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier, void**);
+WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
 WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
 
 WTF_EXPORT_PRIVATE void yield();
index 763ec2b..abd350d 100644 (file)
 #include "HashMap.h"
 #include "RandomNumberSeed.h"
 #include "StdLibExtras.h"
+#include "ThreadFunctionInvocation.h"
 #include "ThreadIdentifierDataPthreads.h"
 #include "ThreadSpecific.h"
 #include "UnusedParam.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/WTFThreadData.h>
 #include <errno.h>
 
@@ -152,6 +155,15 @@ void clearPthreadHandleForIdentifier(ThreadIdentifier id)
     threadMap().remove(id);
 }
 
+static void* wtfThreadEntryPoint(void* param)
+{
+    // Balanced by .leakPtr() in createThreadInternal.
+    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFunctionInvocation*>(param));
+    invocation->function(invocation->data);
+
+    return 0;
+}
+
 #if PLATFORM(BLACKBERRY)
 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char* threadName)
 {
@@ -171,8 +183,9 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
             LOG_ERROR("pthread_attr_getstack() failed: %d", errno);
     }
 
+    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));
     pthread_t threadHandle;
-    if (pthread_create(&threadHandle, &attr, entryPoint, data)) {
+    if (pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get())) {
         LOG_ERROR("pthread_create() failed: %d", errno);
         threadHandle = 0;
     }
@@ -183,17 +196,26 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
     if (!threadHandle)
         return 0;
 
+    // Balanced by adoptPtr() in wtfThreadEntryPoint.
+    ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr();
+    UNUSED_PARAM(leakedInvocation);
+
     return establishIdentifierForPthreadHandle(threadHandle);
 }
 #else
 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)
 {
+    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));
     pthread_t threadHandle;
-    if (pthread_create(&threadHandle, 0, entryPoint, data)) {
-        LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data);
+    if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) {
+        LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, invocation.get());
         return 0;
     }
 
+    // Balanced by adoptPtr() in wtfThreadEntryPoint.
+    ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr();
+    UNUSED_PARAM(leakedInvocation);
+
     return establishIdentifierForPthreadHandle(threadHandle);
 }
 #endif
@@ -217,7 +239,7 @@ void initializeCurrentThreadInternal(const char* threadName)
     ThreadIdentifierData::initialize(id);
 }
 
-int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
+int waitForThreadCompletion(ThreadIdentifier threadID)
 {
     ASSERT(threadID);
 
@@ -225,7 +247,7 @@ int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
     if (!pthreadHandle)
         return 0;
 
-    int joinResult = pthread_join(pthreadHandle, result);
+    int joinResult = pthread_join(pthreadHandle, 0);
     if (joinResult == EDEADLK)
         LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", threadID);
 
index ac0f73f..bc32262 100644 (file)
@@ -210,14 +210,14 @@ static void clearThreadHandleForIdentifier(ThreadIdentifier id)
 static unsigned __stdcall wtfThreadEntryPoint(void* param)
 {
     OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFunctionInvocation*>(param));
-    void* result = invocation->function(invocation->data);
+    invocation->function(invocation->data);
 
 #if !USE(PTHREADS) && OS(WINDOWS)
     // Do the TLS cleanup.
     ThreadSpecificThreadExit();
 #endif
 
-    return reinterpret_cast<unsigned>(result);
+    return 0;
 }
 
 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char* threadName)
@@ -252,7 +252,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
     return threadID;
 }
 
-int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
+int waitForThreadCompletion(ThreadIdentifier threadID)
 {
     ASSERT(threadID);
     
index bd3fba3..0bde95e 100644 (file)
@@ -1,3 +1,81 @@
+2012-02-17  Kalev Lember  <kalevlember@gmail.com>
+
+        Remove unused parameters from WTF threading API
+        https://bugs.webkit.org/show_bug.cgi?id=78389
+
+        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.
+
+        * 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):
+
 2012-02-17  Robert Hogan  <robert@webkit.org>
 
         AppleMac Build fix for r108111
index 765e363..cf70f18 100644 (file)
@@ -36,11 +36,10 @@ using namespace JSC;
 
 namespace WebCore {
 
-static void* collect(void*)
+static void collect(void*)
 {
     JSLock lock(SilenceAssertionsOnly);
     JSDOMWindow::commonJSGlobalData()->heap.collectAllGarbage();
-    return 0;
 }
 
 GCController& gcController()
@@ -77,7 +76,7 @@ void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDon
     ThreadIdentifier threadID = createThread(collect, 0, "WebCore: GCController");
 
     if (waitUntilDone) {
-        waitForThreadCompletion(threadID, 0);
+        waitForThreadCompletion(threadID);
         return;
     }
 
index 4d55630..82bc686 100644 (file)
@@ -83,13 +83,13 @@ void FileThread::unscheduleTasks(const void* instance)
     m_queue.removeIf(predicate);
 }
 
-void* FileThread::fileThreadStart(void* arg)
+void FileThread::fileThreadStart(void* arg)
 {
     FileThread* fileThread = static_cast<FileThread*>(arg);
-    return fileThread->runLoop();
+    fileThread->runLoop();
 }
 
-void* FileThread::runLoop()
+void FileThread::runLoop()
 {
     {
         // Wait for FileThread::start() to complete to have m_threadID
@@ -110,8 +110,6 @@ void* FileThread::runLoop()
 
     // Clear the self refptr, possibly resulting in deletion
     m_selfRef = 0;
-
-    return 0;
 }
 
 } // namespace WebCore
index 9c1d267..6c3255b 100644 (file)
@@ -72,8 +72,8 @@ public:
 private:
     FileThread();
 
-    static void* fileThreadStart(void*);
-    void* runLoop();
+    static void fileThreadStart(void*);
+    void runLoop();
 
     ThreadIdentifier m_threadID;
     RefPtr<FileThread> m_selfRef;
index a8507a9..5ae8005 100644 (file)
@@ -156,7 +156,7 @@ void IconDatabase::close()
         wakeSyncThread();
         
         // Wait for the sync thread to terminate
-        waitForThreadCompletion(m_syncThread, 0);
+        waitForThreadCompletion(m_syncThread);
     }
 
     m_syncThreadRunning = false;    
@@ -949,14 +949,14 @@ bool IconDatabase::shouldStopThreadActivity() const
     return m_threadTerminationRequested || m_removeIconsRequested;
 }
 
-void* IconDatabase::iconDatabaseSyncThreadStart(void* vIconDatabase)
+void IconDatabase::iconDatabaseSyncThreadStart(void* vIconDatabase)
 {    
     IconDatabase* iconDB = static_cast<IconDatabase*>(vIconDatabase);
     
-    return iconDB->iconDatabaseSyncThread();
+    iconDB->iconDatabaseSyncThread();
 }
 
-void* IconDatabase::iconDatabaseSyncThread()
+void IconDatabase::iconDatabaseSyncThread()
 {
     // The call to create this thread might not complete before the thread actually starts, so we might fail this ASSERT_ICON_SYNC_THREAD() because the pointer 
     // to our thread structure hasn't been filled in yet.
@@ -988,12 +988,14 @@ void* IconDatabase::iconDatabaseSyncThread()
         MutexLocker locker(m_syncLock);
         if (!m_syncDB.open(m_completeDatabasePath)) {
             LOG_ERROR("Unable to open icon database at path %s - %s", m_completeDatabasePath.ascii().data(), m_syncDB.lastErrorMsg());
-            return 0;
+            return;
         }
     }
     
-    if (shouldStopThreadActivity())
-        return syncThreadMainLoop();
+    if (shouldStopThreadActivity()) {
+        syncThreadMainLoop();
+        return;
+    }
         
 #if !LOG_DISABLED
     double timeStamp = currentTime();
@@ -1001,8 +1003,10 @@ void* IconDatabase::iconDatabaseSyncThread()
 #endif    
 
     performOpenInitialization();
-    if (shouldStopThreadActivity())
-        return syncThreadMainLoop();
+    if (shouldStopThreadActivity()) {
+        syncThreadMainLoop();
+        return;
+    }
         
 #if !LOG_DISABLED
     double newStamp = currentTime();
@@ -1024,8 +1028,10 @@ void* IconDatabase::iconDatabaseSyncThread()
             importTransaction.rollback();
         }
         
-        if (shouldStopThreadActivity())
-            return syncThreadMainLoop();
+        if (shouldStopThreadActivity()) {
+            syncThreadMainLoop();
+            return;
+        }
             
 #if !LOG_DISABLED
         newStamp = currentTime();
@@ -1041,8 +1047,10 @@ void* IconDatabase::iconDatabaseSyncThread()
     LOG(IconDatabase, "(THREAD) Starting iconURL import");
     performURLImport();
     
-    if (shouldStopThreadActivity())
-        return syncThreadMainLoop();
+    if (shouldStopThreadActivity()) {
+        syncThreadMainLoop();
+        return;
+    }
 
 #if !LOG_DISABLED
     newStamp = currentTime();
@@ -1050,7 +1058,7 @@ void* IconDatabase::iconDatabaseSyncThread()
 #endif 
 
     LOG(IconDatabase, "(THREAD) Beginning sync");
-    return syncThreadMainLoop();
+    syncThreadMainLoop();
 }
 
 static int databaseVersionNumber(SQLiteDatabase& db)
@@ -1348,7 +1356,7 @@ void IconDatabase::performURLImport()
     callOnMainThread(notifyPendingLoadDecisionsOnMainThread, this);
 }
 
-void* IconDatabase::syncThreadMainLoop()
+void IconDatabase::syncThreadMainLoop()
 {
     ASSERT_ICON_SYNC_THREAD();
 
@@ -1461,8 +1469,6 @@ void* IconDatabase::syncThreadMainLoop()
         MutexLocker locker(m_syncLock);
         m_disabledSuddenTerminationForSyncThread = false;
     }
-
-    return 0;
 }
 
 bool IconDatabase::readFromDatabase()
index 7ab0841..f4abb8b 100644 (file)
@@ -183,15 +183,15 @@ public:
     virtual bool shouldStopThreadActivity() const;
 
 private:    
-    static void* iconDatabaseSyncThreadStart(void *);
-    void* iconDatabaseSyncThread();
+    static void iconDatabaseSyncThreadStart(void *);
+    void iconDatabaseSyncThread();
     
     // The following block of methods are called exclusively by the sync thread to manage i/o to and from the database
     // Each method should periodically monitor m_threadTerminationRequested when it makes sense to return early on shutdown
     void performOpenInitialization();
     bool checkIntegrity();
     void performURLImport();
-    void* syncThreadMainLoop();
+    void syncThreadMainLoop();
     bool readFromDatabase();
     bool writeToDatabase();
     void pruneUnretainedIcons();
index fc5a405..a95cfb4 100644 (file)
@@ -77,11 +77,9 @@ void ScrollingThread::createThreadIfNeeded()
     }
 }
 
-void* ScrollingThread::threadCallback(void* scrollingThread)
+void ScrollingThread::threadCallback(void* scrollingThread)
 {
     static_cast<ScrollingThread*>(scrollingThread)->threadBody();
-
-    return 0;
 }
 
 void ScrollingThread::threadBody()
index 22671e4..d8dfa2d 100644 (file)
@@ -52,7 +52,7 @@ private:
     static ScrollingThread& shared();
 
     void createThreadIfNeeded();
-    static void* threadCallback(void* scrollingThread);
+    static void threadCallback(void* scrollingThread);
     void threadBody();
     void dispatchFunctionsFromScrollingThread();
 
index cb7355a..8f96c96 100644 (file)
@@ -80,13 +80,11 @@ HRTFDatabaseLoader::~HRTFDatabaseLoader()
 
 
 // Asynchronously load the database in this thread.
-static void* databaseLoaderEntry(void* threadData)
+static void databaseLoaderEntry(void* threadData)
 {
     HRTFDatabaseLoader* loader = reinterpret_cast<HRTFDatabaseLoader*>(threadData);
     ASSERT(loader);
     loader->load();
-    
-    return 0;
 }
 
 void HRTFDatabaseLoader::load()
@@ -121,7 +119,7 @@ void HRTFDatabaseLoader::waitForLoaderThreadCompletion()
     
     // waitForThreadCompletion() should not be called twice for the same thread.
     if (m_databaseLoaderThread)
-        waitForThreadCompletion(m_databaseLoaderThread, 0);
+        waitForThreadCompletion(m_databaseLoaderThread);
     m_databaseLoaderThread = 0;
 }
 
index c611414..c6ab54e 100644 (file)
@@ -53,11 +53,10 @@ const size_t RealtimeFrameLimit = 8192  + 4096; // ~278msec @ 44.1KHz
 const size_t MinFFTSize = 256;
 const size_t MaxRealtimeFFTSize = 2048;
 
-static void* backgroundThreadEntry(void* threadData)
+static void backgroundThreadEntry(void* threadData)
 {
     ReverbConvolver* reverbConvolver = static_cast<ReverbConvolver*>(threadData);
     reverbConvolver->backgroundThreadEntry();
-    return 0;
 }
 
 ReverbConvolver::ReverbConvolver(AudioChannel* impulseResponse, size_t renderSliceSize, size_t maxFFTSize, size_t convolverRenderPhase, bool useBackgroundThreads)
@@ -142,7 +141,7 @@ ReverbConvolver::~ReverbConvolver()
             m_backgroundThreadCondition.signal();
         }
 
-        waitForThreadCompletion(m_backgroundThread, 0);
+        waitForThreadCompletion(m_backgroundThread);
     }
 }
 
index aa99df3..3088eb4 100644 (file)
@@ -42,7 +42,7 @@ static void emptyPerform(void*)
 {
 }
 
-static void* runLoaderThread(void*)
+static void runLoaderThread(void*)
 {
     loaderRunLoopObject = CFRunLoopGetCurrent();
 
@@ -56,8 +56,6 @@ static void* runLoaderThread(void*)
         AutodrainedPool pool;
         result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, std::numeric_limits<double>::max(), true);
     } while (result != kCFRunLoopRunStopped && result != kCFRunLoopRunFinished);
-
-    return 0;
 }
 
 CFRunLoopRef loaderRunLoop()
index cbde324..d771b1c 100644 (file)
@@ -88,13 +88,13 @@ bool DatabaseThread::terminationRequested(DatabaseTaskSynchronizer* taskSynchron
     return m_queue.killed();
 }
 
-void* DatabaseThread::databaseThreadStart(void* vDatabaseThread)
+void DatabaseThread::databaseThreadStart(void* vDatabaseThread)
 {
     DatabaseThread* dbThread = static_cast<DatabaseThread*>(vDatabaseThread);
-    return dbThread->databaseThread();
+    dbThread->databaseThread();
 }
 
-void* DatabaseThread::databaseThread()
+void DatabaseThread::databaseThread()
 {
     {
         // Wait for DatabaseThread::start() to complete.
@@ -134,8 +134,6 @@ void* DatabaseThread::databaseThread()
 
     if (cleanupSync) // Someone wanted to know when we were done cleaning up.
         cleanupSync->taskCompleted();
-
-    return 0;
 }
 
 void DatabaseThread::recordDatabaseOpen(Database* database)
index d410edb..fa4fd08 100644 (file)
@@ -72,8 +72,8 @@ public:
 private:
     DatabaseThread();
 
-    static void* databaseThreadStart(void*);
-    void* databaseThread();
+    static void databaseThreadStart(void*);
+    void databaseThread();
 
     Mutex m_threadCreationMutex;
     ThreadIdentifier m_threadID;
index ba1b0fa..a8e44b6 100644 (file)
@@ -56,18 +56,16 @@ bool LocalStorageThread::start()
     return m_threadID;
 }
 
-void* LocalStorageThread::threadEntryPointCallback(void* thread)
+void LocalStorageThread::threadEntryPointCallback(void* thread)
 {
-    return static_cast<LocalStorageThread*>(thread)->threadEntryPoint();
+    static_cast<LocalStorageThread*>(thread)->threadEntryPoint();
 }
 
-void* LocalStorageThread::threadEntryPoint()
+void LocalStorageThread::threadEntryPoint()
 {
     ASSERT(!isMainThread());
     while (OwnPtr<LocalStorageTask> task = m_queue.waitForMessage())
         task->performTask();
-
-    return 0;
 }
 
 void LocalStorageThread::scheduleTask(PassOwnPtr<LocalStorageTask> task)
@@ -85,9 +83,8 @@ void LocalStorageThread::terminate()
     if (!m_threadID)
         return;
 
-    void* returnValue;
     m_queue.append(LocalStorageTask::createTerminate(this));
-    waitForThreadCompletion(m_threadID, &returnValue);
+    waitForThreadCompletion(m_threadID);
     ASSERT(m_queue.killed());
     m_threadID = 0;
 }
index 46467af..434f31d 100644 (file)
@@ -55,8 +55,8 @@ namespace WebCore {
         LocalStorageThread();
 
         // Called on background thread.
-        static void* threadEntryPointCallback(void*);
-        void* threadEntryPoint();
+        static void threadEntryPointCallback(void*);
+        void threadEntryPoint();
 
         ThreadIdentifier m_threadID;
         MessageQueue<LocalStorageTask> m_queue;
index c268243..f00bd1a 100644 (file)
@@ -49,8 +49,7 @@ AsyncAudioDecoder::~AsyncAudioDecoder()
     m_queue.kill();
     
     // Stop thread.
-    void* exitCode;
-    waitForThreadCompletion(m_threadID, &exitCode);
+    waitForThreadCompletion(m_threadID);
     m_threadID = 0;
 }
 
@@ -66,12 +65,11 @@ void AsyncAudioDecoder::decodeAsync(ArrayBuffer* audioData, float sampleRate, Pa
 }
 
 // Asynchronously decode in this thread.
-void* AsyncAudioDecoder::threadEntry(void* threadData)
+void AsyncAudioDecoder::threadEntry(void* threadData)
 {
     ASSERT(threadData);
     AsyncAudioDecoder* decoder = reinterpret_cast<AsyncAudioDecoder*>(threadData);
     decoder->runLoop();
-    return 0;
 }
 
 void AsyncAudioDecoder::runLoop()
index e2fc4dc..ced8058 100644 (file)
@@ -76,7 +76,7 @@ private:
         RefPtr<AudioBuffer> m_audioBuffer;
     };
     
-    static void* threadEntry(void* threadData);
+    static void threadEntry(void* threadData);
     void runLoop();
 
     WTF::ThreadIdentifier m_threadID;
index 7ea22dc..a40e605 100644 (file)
@@ -68,7 +68,7 @@ void OfflineAudioDestinationNode::uninitialize()
         return;
 
     if (m_renderThread) {
-        waitForThreadCompletion(m_renderThread, 0);
+        waitForThreadCompletion(m_renderThread);
         m_renderThread = 0;
     }
 
@@ -90,13 +90,11 @@ void OfflineAudioDestinationNode::startRendering()
 }
 
 // Do offline rendering in this thread.
-void* OfflineAudioDestinationNode::renderEntry(void* threadData)
+void OfflineAudioDestinationNode::renderEntry(void* threadData)
 {
     OfflineAudioDestinationNode* destinationNode = reinterpret_cast<OfflineAudioDestinationNode*>(threadData);
     ASSERT(destinationNode);
     destinationNode->render();
-    
-    return 0;
 }
 
 void OfflineAudioDestinationNode::render()
index 1fb7300..c2da6ff 100644 (file)
@@ -64,7 +64,7 @@ private:
     // Rendering thread.
     volatile ThreadIdentifier m_renderThread;
     bool m_startedRendering;
-    static void* renderEntry(void* threadData);
+    static void renderEntry(void* threadData);
     void render();
     
     // For completion callback on main thread.
index 93ba0bf..34cf909 100644 (file)
@@ -123,12 +123,12 @@ bool WorkerThread::start()
     return m_threadID;
 }
 
-void* WorkerThread::workerThreadStart(void* thread)
+void WorkerThread::workerThreadStart(void* thread)
 {
-    return static_cast<WorkerThread*>(thread)->workerThread();
+    static_cast<WorkerThread*>(thread)->workerThread();
 }
 
-void* WorkerThread::workerThread()
+void WorkerThread::workerThread()
 {
     {
         MutexLocker lock(m_threadCreationMutex);
@@ -173,8 +173,6 @@ void* WorkerThread::workerThread()
 
     // The thread object may be already destroyed from notification now, don't try to access "this".
     detachThread(threadID);
-
-    return 0;
 }
 
 void WorkerThread::runEventLoop()
index 6646b11..e3a11df 100644 (file)
@@ -80,8 +80,8 @@ namespace WebCore {
 
     private:
         // Static function executed as the core routine on the new thread. Passed a pointer to a WorkerThread object.
-        static void* workerThreadStart(void*);
-        void* workerThread();
+        static void workerThreadStart(void*);
+        void workerThread();
 
         ThreadIdentifier m_threadID;
         WorkerRunLoop m_runLoop;
index 169e98b..04194ff 100644 (file)
@@ -1,3 +1,30 @@
+2012-02-17  Kalev Lember  <kalevlember@gmail.com>
+
+        Remove unused parameters from WTF threading API
+        https://bugs.webkit.org/show_bug.cgi?id=78389
+
+        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.
+
+        * WebKit.vcproj/WebKit_Cairo.def: Add the new functions.
+        * WebKit.vcproj/WebKit_Cairo_debug.def: Ditto.
+
 2012-02-15  Sadrul Habib Chowdhury  <sadrul@chromium.org>
 
         Notify ChromeClient when touch-event handlers are installed/removed.
index 89b0a2a..e4cd266 100644 (file)
@@ -122,6 +122,7 @@ EXPORTS
         ?broadcast@ThreadCondition@WTF@@QAEXXZ
         ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
+        ?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z
         ?currentThread@WTF@@YAIXZ
         ?detachThread@WTF@@YAXI@Z
         ?initializeMainThread@WTF@@YAXXZ
@@ -139,5 +140,6 @@ EXPORTS
         ?unlockAtomicallyInitializedStaticMutex@WTF@@YAXXZ
         ?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
         ?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
+        ?waitForThreadCompletion@WTF@@YAHI@Z
         ?waitForThreadCompletion@WTF@@YAHIPAPAX@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0@Z
index 1b1b72d..e4ac119 100644 (file)
@@ -122,6 +122,7 @@ EXPORTS
         ?broadcast@ThreadCondition@WTF@@QAEXXZ
         ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
+        ?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z
         ?currentThread@WTF@@YAIXZ
         ?detachThread@WTF@@YAXI@Z
         ?initializeMainThread@WTF@@YAXXZ
@@ -139,5 +140,6 @@ EXPORTS
         ?unlockAtomicallyInitializedStaticMutex@WTF@@YAXXZ
         ?updateLayoutIgnorePendingStylesheets@Document@WebCore@@QAEXXZ
         ?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
+        ?waitForThreadCompletion@WTF@@YAHI@Z
         ?waitForThreadCompletion@WTF@@YAHIPAPAX@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0@Z
index a69dcfe..cc2d7ab 100644 (file)
@@ -1,3 +1,42 @@
+2012-02-17  Kalev Lember  <kalevlember@gmail.com>
+
+        Remove unused parameters from WTF threading API
+        https://bugs.webkit.org/show_bug.cgi?id=78389
+
+        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.
+
+        * 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:
+
 2012-02-17  Mihnea Ovidenie  <mihnea@adobe.com>
 
         CSS regions enabled by default
index 587ef89..7b4aff7 100644 (file)
@@ -166,7 +166,7 @@ private:
     QThread* m_workThread;
     friend class WorkItemQt;
 #elif PLATFORM(GTK)
-    static void* startWorkQueueThread(WorkQueue*);
+    static void startWorkQueueThread(WorkQueue*);
     void workQueueThreadBody();
     void dispatchOnSource(GSource*, const Function<void()>&, GSourceFunc);
 
index 112ba28..f0c11f9 100644 (file)
@@ -142,10 +142,9 @@ void WorkQueue::platformInvalidate()
     }
 }
 
-void* WorkQueue::startWorkQueueThread(WorkQueue* workQueue)
+void WorkQueue::startWorkQueueThread(WorkQueue* workQueue)
 {
     workQueue->workQueueThreadBody();
-    return 0;
 }
 
 void WorkQueue::workQueueThreadBody()
index dd53b3e..7c01153 100644 (file)
@@ -37,7 +37,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static void* webThreadBody(void* context)
+static void webThreadBody(void* context)
 {
     mach_port_t serverPort = static_cast<mach_port_t>(reinterpret_cast<uintptr_t>(context));
 
@@ -52,8 +52,6 @@ static void* webThreadBody(void* context)
     [pool drain];
 
     RunLoop::current()->run();
-
-    return 0;
 }
 
 CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
index 1d0caf3..37d045f 100644 (file)
@@ -47,7 +47,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static void* webThreadBody(void* /* context */)
+static void webThreadBody(void* /* context */)
 {
     // Initialization
     JSC::initializeThreading();
@@ -57,8 +57,6 @@ static void* webThreadBody(void* /* context */)
 
     WebProcess::shared().initialize(-1, RunLoop::current());
     RunLoop::run();
-
-    return 0;
 }
 
 CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
index f9d1c04..5abec7a 100644 (file)
@@ -36,7 +36,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static void* webThreadBody(void* context)
+static void webThreadBody(void* context)
 {
     HANDLE clientIdentifier = reinterpret_cast<HANDLE>(context);
 
@@ -46,8 +46,6 @@ static void* webThreadBody(void* context)
 
     WebProcess::shared().initialize(clientIdentifier, RunLoop::current());
     RunLoop::run();
-
-    return 0;
 }
 
 CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
index d098107..2cf2af2 100644 (file)
@@ -100,7 +100,7 @@ static void sleep(unsigned seconds)
 }
 #endif
 
-static void* randomCrashThread(void*)
+static void randomCrashThread(void*)
 {
     // This delay was chosen semi-arbitrarily. We want the crash to happen somewhat quickly to
     // enable useful stress testing, but not so quickly that the web process will always crash soon
@@ -109,7 +109,6 @@ static void* randomCrashThread(void*)
 
     sleep(randomNumber() * maximumRandomCrashDelay);
     CRASH();
-    return 0;
 }
 
 static void startRandomCrashThreadIfRequested()
index 8a6023a..2aa70df 100644 (file)
@@ -116,6 +116,7 @@ EXPORTS
         ?broadcast@ThreadCondition@WTF@@QAEXXZ
         ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
+        ?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z
         ?currentThread@WTF@@YAIXZ
         ?detachThread@WTF@@YAXI@Z
         ?initializeMainThread@WTF@@YAXXZ
@@ -131,6 +132,7 @@ EXPORTS
         ?unlock@Mutex@WTF@@QAEXXZ
         ?unlockAtomicallyInitializedStaticMutex@WTF@@YAXXZ
         ?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
+        ?waitForThreadCompletion@WTF@@YAHI@Z
         ?waitForThreadCompletion@WTF@@YAHIPAPAX@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0@Z
         ; Re-exports from WebCore for test harnesses
index 149b3af..cb7b7ce 100644 (file)
@@ -110,6 +110,7 @@ EXPORTS
         ?broadcast@ThreadCondition@WTF@@QAEXXZ
         ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0PBD@Z
+        ?createThread@WTF@@YAIP6AXPAX@Z0PBD@Z
         ?currentThread@WTF@@YAIXZ
         ?detachThread@WTF@@YAXI@Z
         ?initializeMainThread@WTF@@YAXXZ
@@ -125,6 +126,7 @@ EXPORTS
         ?unlock@Mutex@WTF@@QAEXXZ
         ?unlockAtomicallyInitializedStaticMutex@WTF@@YAXXZ
         ?wait@ThreadCondition@WTF@@QAEXAAVMutex@2@@Z
+        ?waitForThreadCompletion@WTF@@YAHI@Z
         ?waitForThreadCompletion@WTF@@YAHIPAPAX@Z
         ?createThread@WTF@@YAIP6APAXPAX@Z0@Z