Modified: trunk/Tools/ChangeLog (149854 => 149855)
--- trunk/Tools/ChangeLog 2013-05-09 23:41:26 UTC (rev 149854)
+++ trunk/Tools/ChangeLog 2013-05-09 23:47:54 UTC (rev 149855)
@@ -1,5 +1,22 @@
2013-05-09 Patrick Gansterer <par...@webkit.org>
+ [WIN][DRT] Remove duplicated (start|stop)_javascript_Threads()
+ https://bugs.webkit.org/show_bug.cgi?id=92371
+
+ Reviewed by Brent Fulgham.
+
+ Use _javascript_Threading.cpp where the same functionality is
+ implemented too. This reduces the dependency on the pthread
+ library. Also replace assert() with WebKit ASSERT().
+
+ * DumpRenderTree/DumpRenderTree.vcxproj/DumpRenderTree/DumpRenderTree.vcxproj:
+ * DumpRenderTree/win/DumpRenderTree.cpp:
+ (dumpHistoryItem):
+ (dumpBackForwardList):
+ * DumpRenderTree/win/DumpRenderTree.vcproj:
+
+2013-05-09 Patrick Gansterer <par...@webkit.org>
+
[DRT] Replace _javascript_ThreadingPthreads.cpp with _javascript_Threading.cpp
https://bugs.webkit.org/show_bug.cgi?id=92505
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/DumpRenderTree/DumpRenderTree.vcxproj (149854 => 149855)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/DumpRenderTree/DumpRenderTree.vcxproj 2013-05-09 23:41:26 UTC (rev 149854)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.vcxproj/DumpRenderTree/DumpRenderTree.vcxproj 2013-05-09 23:47:54 UTC (rev 149855)
@@ -107,6 +107,7 @@
<ClCompile Include="..\..\CyclicRedundancyCheck.cpp" />
<ClCompile Include="..\..\DumpRenderTreeCommon.cpp" />
<ClCompile Include="..\..\GCController.cpp" />
+ <ClCompile Include="..\..\_javascript_Threading.cpp" />
<ClCompile Include="..\..\PixelDumpSupport.cpp" />
<ClCompile Include="..\..\TestRunner.cpp" />
<ClCompile Include="..\..\win\AccessibilityControllerWin.cpp" />
@@ -150,6 +151,7 @@
<ClInclude Include="..\..\DumpRenderTree.h" />
<ClInclude Include="..\..\DumpRenderTreePrefix.h" />
<ClInclude Include="..\..\GCController.h" />
+ <ClInclude Include="..\..\_javascript_Threading.h" />
<ClInclude Include="..\..\PixelDumpSupport.h" />
<ClInclude Include="..\..\TestRunner.h" />
<ClInclude Include="..\..\win\DraggingInfo.h" />
Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (149854 => 149855)
--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2013-05-09 23:41:26 UTC (rev 149854)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp 2013-05-09 23:47:54 UTC (rev 149855)
@@ -32,6 +32,7 @@
#include "EditingDelegate.h"
#include "FrameLoadDelegate.h"
#include "HistoryDelegate.h"
+#include "_javascript_Threading.h"
#include "PixelDumpSupport.h"
#include "PolicyDelegate.h"
#include "ResourceLoadDelegate.h"
@@ -45,7 +46,6 @@
#include <fcntl.h>
#include <io.h>
#include <math.h>
-#include <pthread.h>
#include <shlwapi.h>
#include <stdio.h>
#include <string.h>
@@ -54,7 +54,6 @@
#include <wtf/Vector.h>
#include <windows.h>
#include <CoreFoundation/CoreFoundation.h>
-#include <_javascript_Core/_javascript_Core.h>
#include <WebKit/WebKit.h>
#include <WebKit/WebKitCOMAPI.h>
@@ -528,7 +527,7 @@
static void dumpHistoryItem(IWebHistoryItem* item, int indent, bool current)
{
- assert(item);
+ ASSERT(item);
int start = 0;
if (current) {
@@ -645,17 +644,17 @@
if (FAILED(bfList->itemAtIndex(i, &item)))
return;
// something is wrong if the item from the last test is in the forward part of the b/f list
- assert(item != prevTestBFItem);
+ ASSERT(item != prevTestBFItem);
COMPtr<IUnknown> itemUnknown;
item->QueryInterface(&itemUnknown);
itemsToPrint.append(itemUnknown);
}
-
+
COMPtr<IWebHistoryItem> currentItem;
if (FAILED(bfList->currentItem(¤tItem)))
return;
- assert(currentItem != prevTestBFItem);
+ ASSERT(currentItem != prevTestBFItem);
COMPtr<IUnknown> currentItemUnknown;
currentItem->QueryInterface(¤tItemUnknown);
itemsToPrint.append(currentItemUnknown);
@@ -1071,111 +1070,6 @@
return;
}
-static Boolean pthreadEqualCallback(const void* value1, const void* value2)
-{
- return (Boolean)pthread_equal(*(pthread_t*)value1, *(pthread_t*)value2);
-}
-
-static CFDictionaryKeyCallBacks pthreadKeyCallbacks = { 0, 0, 0, 0, pthreadEqualCallback, 0 };
-
-static pthread_mutex_t _javascript_ThreadsMutex = PTHREAD_MUTEX_INITIALIZER;
-static bool _javascript_ThreadsShouldTerminate;
-
-static const int _javascript_ThreadsCount = 4;
-static CFMutableDictionaryRef _javascript_Threads()
-{
- assert(pthread_mutex_trylock(&_javascript_ThreadsMutex) == EBUSY);
- static CFMutableDictionaryRef staticJavaScriptThreads;
- if (!staticJavaScriptThreads)
- staticJavaScriptThreads = CFDictionaryCreateMutable(0, 0, &pthreadKeyCallbacks, 0);
- return staticJavaScriptThreads;
-}
-
-// Loops forever, running a script and randomly respawning, until
-// _javascript_ThreadsShouldTerminate becomes true.
-void* runJavaScriptThread(void* arg)
-{
- const char* const script =
- " \
- var array = []; \
- for (var i = 0; i < 10; i++) { \
- array.push(String(i)); \
- } \
- ";
-
- while (true) {
- JSGlobalContextRef ctx = JSGlobalContextCreate(0);
- JSStringRef scriptRef = JSStringCreateWithUTF8CString(script);
-
- JSValueRef exception = 0;
- JSEvaluateScript(ctx, scriptRef, 0, 0, 1, &exception);
- assert(!exception);
-
- JSGlobalContextRelease(ctx);
- JSStringRelease(scriptRef);
-
- JSGarbageCollect(ctx);
-
- pthread_mutex_lock(&_javascript_ThreadsMutex);
-
- // Check for cancellation.
- if (_javascript_ThreadsShouldTerminate) {
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
- return 0;
- }
-
- // Respawn probabilistically.
- if (rand() % 5 == 0) {
- pthread_t pthread;
- pthread_create(&pthread, 0, &runJavaScriptThread, 0);
- pthread_detach(pthread);
-
- pthread_t self = pthread_self();
- CFDictionaryRemoveValue(_javascript_Threads(), self.p);
- CFDictionaryAddValue(_javascript_Threads(), pthread.p, 0);
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
- return 0;
- }
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
- }
-}
-
-static void startJavaScriptThreads(void)
-{
- pthread_mutex_lock(&_javascript_ThreadsMutex);
-
- for (int i = 0; i < _javascript_ThreadsCount; i++) {
- pthread_t pthread;
- pthread_create(&pthread, 0, &runJavaScriptThread, 0);
- pthread_detach(pthread);
- CFDictionaryAddValue(_javascript_Threads(), pthread.p, 0);
- }
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-}
-
-static void stopJavaScriptThreads(void)
-{
- pthread_mutex_lock(&_javascript_ThreadsMutex);
-
- _javascript_ThreadsShouldTerminate = true;
-
- pthread_t* pthreads[_javascript_ThreadsCount] = {0};
- int threadDictCount = CFDictionaryGetCount(_javascript_Threads());
- assert(threadDictCount == _javascript_ThreadsCount);
- CFDictionaryGetKeysAndValues(_javascript_Threads(), (const void**)pthreads, 0);
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- for (int i = 0; i < _javascript_ThreadsCount; i++) {
- pthread_t* pthread = pthreads[i];
- pthread_join(*pthread, 0);
- free(pthread);
- }
-}
-
Vector<HWND>& openWindows()
{
static Vector<HWND> vector;
Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.vcproj (149854 => 149855)
--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.vcproj 2013-05-09 23:41:26 UTC (rev 149854)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.vcproj 2013-05-09 23:47:54 UTC (rev 149855)
@@ -615,6 +615,14 @@
</FileConfiguration>
</File>
<File
+ RelativePath="..\_javascript_Threading.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\_javascript_Threading.h"
+ >
+ </File>
+ <File
RelativePath="..\PixelDumpSupport.cpp"
>
</File>