Diff
Modified: trunk/Tools/ChangeLog (149842 => 149843)
--- trunk/Tools/ChangeLog 2013-05-09 21:34:45 UTC (rev 149842)
+++ trunk/Tools/ChangeLog 2013-05-09 21:35:01 UTC (rev 149843)
@@ -1,3 +1,20 @@
+2013-05-09 Patrick Gansterer <[email protected]>
+
+ [DRT] Replace _javascript_ThreadingPthreads.cpp with _javascript_Threading.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=92505
+
+ Reviewed by Brent Fulgham.
+
+ * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+ * DumpRenderTree/_javascript_Threading.cpp: Copied from DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp.
+ (_javascript_ThreadsMutex):
+ (_javascript_Threads):
+ (runJavaScriptThread):
+ (startJavaScriptThreads):
+ (stopJavaScriptThreads):
+ * DumpRenderTree/pthreads: Removed.
+ * DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp: Removed.
+
2013-05-09 Mario Sanchez Prada <[email protected]>
Unreviewed. Update Simon Pena email on his behalf.
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (149842 => 149843)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-05-09 21:34:45 UTC (rev 149842)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2013-05-09 21:35:01 UTC (rev 149843)
@@ -58,6 +58,7 @@
29CFBA10122736E600BC30C0 /* AccessibilityTextMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */; };
29CFBA11122736E600BC30C0 /* AccessibilityTextMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */; };
29CFBA2E12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */; };
+ 2CE88FA217124D8C00734FC0 /* _javascript_Threading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CE88FA117124CEE00734FC0 /* _javascript_Threading.cpp */; };
2D403F05150871F9005358D2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE8257EF08D22389000507AB /* Carbon.framework */; };
2D403F06150871F9005358D2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A84F608908B136DA00E9745F /* Cocoa.framework */; };
2D403F08150871F9005358D2 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23BCB88F0EA57623003C6289 /* OpenGL.framework */; };
@@ -122,7 +123,6 @@
BC0E26150E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */; };
BC0E26150E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */; };
BC47412A0D038A4C0072B006 /* _javascript_Threading.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4741290D038A4C0072B006 /* _javascript_Threading.h */; };
- BC4741410D038A570072B006 /* _javascript_ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4741400D038A570072B006 /* _javascript_ThreadingPthreads.cpp */; };
BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */; };
BC9D90250C97472E0099A4A3 /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9D90220C97472E0099A4A3 /* WorkQueue.h */; };
BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */; };
@@ -273,6 +273,7 @@
29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityTextMarker.h; sourceTree = "<group>"; };
29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityTextMarker.cpp; sourceTree = "<group>"; };
29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityTextMarkerMac.mm; path = mac/AccessibilityTextMarkerMac.mm; sourceTree = "<group>"; };
+ 2CE88FA117124CEE00734FC0 /* _javascript_Threading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = _javascript_Threading.cpp; sourceTree = "<group>"; };
2D403EA215087142005358D2 /* LayoutTestHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LayoutTestHelper.m; path = mac/LayoutTestHelper.m; sourceTree = "<group>"; };
2D403F19150871F9005358D2 /* LayoutTestHelper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = LayoutTestHelper; sourceTree = BUILT_PRODUCTS_DIR; };
31117B3A15D9A56A00163BC8 /* MockWebNotificationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockWebNotificationProvider.h; path = mac/MockWebNotificationProvider.h; sourceTree = "<group>"; };
@@ -336,7 +337,6 @@
BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityUIElementMac.mm; path = mac/AccessibilityUIElementMac.mm; sourceTree = "<group>"; };
BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityCommonMac.mm; path = mac/AccessibilityCommonMac.mm; sourceTree = "<group>"; };
BC4741290D038A4C0072B006 /* _javascript_Threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _javascript_Threading.h; sourceTree = "<group>"; };
- BC4741400D038A570072B006 /* _javascript_ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = _javascript_ThreadingPthreads.cpp; path = pthreads/_javascript_ThreadingPthreads.cpp; sourceTree = "<group>"; };
BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
BC9D90220C97472E0099A4A3 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueueItem.h; sourceTree = "<group>"; };
@@ -456,12 +456,12 @@
A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */,
A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */,
BC4741290D038A4C0072B006 /* _javascript_Threading.h */,
- BC4741400D038A570072B006 /* _javascript_ThreadingPthreads.cpp */,
BCA18C0A0C9B59EF00114369 /* DumpRenderTreeMac.h */,
BCA18B730C9B08F100114369 /* DumpRenderTreeDraggingInfo.h */,
BCA18B740C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm */,
A8D79CE80FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.h */,
A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */,
+ 2CE88FA117124CEE00734FC0 /* _javascript_Threading.cpp */,
44A997820FCDE86400580F10 /* WebArchiveDumpSupport.h */,
44A997830FCDE86400580F10 /* WebArchiveDumpSupport.cpp */,
440590701268453800CFD48D /* WebArchiveDumpSupportMac.mm */,
@@ -985,7 +985,7 @@
BCA18B230C9B014B00114369 /* GCControllerMac.mm in Sources */,
AA5A15EF16E15CD000F7C561 /* AccessibilityControllerIOS.mm in Sources */,
5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */,
- BC4741410D038A570072B006 /* _javascript_ThreadingPthreads.cpp in Sources */,
+ 2CE88FA217124D8C00734FC0 /* _javascript_Threading.cpp in Sources */,
E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */,
31117B3D15D9A56A00163BC8 /* MockWebNotificationProvider.mm in Sources */,
BCA18B720C9B08DB00114369 /* NavigationController.m in Sources */,
Copied: trunk/Tools/DumpRenderTree/_javascript_Threading.cpp (from rev 149820, trunk/Tools/DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp) (0 => 149843)
--- trunk/Tools/DumpRenderTree/_javascript_Threading.cpp (rev 0)
+++ trunk/Tools/DumpRenderTree/_javascript_Threading.cpp 2013-05-09 21:35:01 UTC (rev 149843)
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ * (C) 2007 Graham Dennis ([email protected])
+ * (C) 2007 Eric Seidel <[email protected]>
+ * (C) 2012 Patrick Ganstere <[email protected]>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "_javascript_Threading.h"
+
+#include <_javascript_Core/_javascript_Core.h>
+#include <stdlib.h>
+#include <wtf/Assertions.h>
+#include <wtf/HashSet.h>
+#include <wtf/Vector.h>
+
+static const size_t _javascript_ThreadsCount = 4;
+static bool _javascript_ThreadsShouldTerminate;
+static JSContextGroupRef _javascript_ThreadsGroup;
+
+static Mutex& _javascript_ThreadsMutex()
+{
+ DEFINE_STATIC_LOCAL(Mutex, staticMutex, ());
+ return staticMutex;
+}
+
+typedef HashSet<ThreadIdentifier> ThreadSet;
+static ThreadSet& _javascript_Threads()
+{
+ DEFINE_STATIC_LOCAL(ThreadSet, staticJavaScriptThreads, ());
+ ASSERT(!_javascript_ThreadsMutex().tryLock());
+ return staticJavaScriptThreads;
+}
+
+// This function exercises JSC in a loop until _javascript_ThreadsShouldTerminate
+// becomes true or it probabilistically decides to spawn a replacement thread and exit.
+void runJavaScriptThread(void*)
+{
+ static const char* const script =
+ "var array = [];"
+ "for (var i = 0; i < 1024; i++) {"
+ " array.push(String(i));"
+ "}";
+
+ JSGlobalContextRef ctx;
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ ctx = JSGlobalContextCreateInGroup(_javascript_ThreadsGroup, 0);
+ }
+
+ JSStringRef scriptRef;
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ scriptRef = JSStringCreateWithUTF8CString(script);
+ }
+
+ while (true) {
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ JSValueRef exception = 0;
+ JSEvaluateScript(ctx, scriptRef, 0, 0, 1, &exception);
+ ASSERT(!exception);
+ }
+
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ const size_t valuesCount = 1024;
+ JSValueRef values[valuesCount];
+ for (size_t i = 0; i < valuesCount; ++i)
+ values[i] = JSObjectMake(ctx, 0, 0);
+ }
+
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ if (_javascript_ThreadsShouldTerminate)
+ break;
+ }
+
+ // Respawn probabilistically.
+ if (rand() % 5)
+ continue;
+
+ MutexLocker locker(_javascript_ThreadsMutex());
+ ThreadIdentifier thread = currentThread();
+ detachThread(thread);
+ _javascript_Threads().remove(thread);
+ _javascript_Threads().add(createThread(&runJavaScriptThread, 0, 0));
+ break;
+ }
+
+ MutexLocker locker(_javascript_ThreadsMutex());
+ JSStringRelease(scriptRef);
+ JSGarbageCollect(ctx);
+ JSGlobalContextRelease(ctx);
+}
+
+void startJavaScriptThreads()
+{
+ _javascript_ThreadsGroup = JSContextGroupCreate();
+
+ MutexLocker locker(_javascript_ThreadsMutex());
+
+ for (size_t i = 0; i < _javascript_ThreadsCount; ++i)
+ _javascript_Threads().add(createThread(&runJavaScriptThread, 0, 0));
+}
+
+void stopJavaScriptThreads()
+{
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ _javascript_ThreadsShouldTerminate = true;
+ }
+
+ Vector<ThreadIdentifier, _javascript_ThreadsCount> threads;
+ {
+ MutexLocker locker(_javascript_ThreadsMutex());
+ copyToVector(_javascript_Threads(), threads);
+ ASSERT(threads.size() == _javascript_ThreadsCount);
+ }
+
+ for (size_t i = 0; i < _javascript_ThreadsCount; ++i)
+ waitForThreadCompletion(threads[i]);
+
+ _javascript_Threads().clear();
+
+ JSContextGroupRelease(_javascript_ThreadsGroup);
+}
Deleted: trunk/Tools/DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp (149842 => 149843)
--- trunk/Tools/DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp 2013-05-09 21:34:45 UTC (rev 149842)
+++ trunk/Tools/DumpRenderTree/pthreads/_javascript_ThreadingPthreads.cpp 2013-05-09 21:35:01 UTC (rev 149843)
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- * (C) 2007 Graham Dennis ([email protected])
- * (C) 2007 Eric Seidel <[email protected]>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "_javascript_Threading.h"
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <_javascript_Core/_javascript_Core.h>
-#include <pthread.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashSet.h>
-
-static JSContextGroupRef _javascript_ThreadsGroup;
-
-static pthread_mutex_t _javascript_ThreadsMutex = PTHREAD_MUTEX_INITIALIZER;
-static bool _javascript_ThreadsShouldTerminate;
-
-static const int _javascript_ThreadsCount = 4;
-
-typedef HashSet<pthread_t> ThreadSet;
-
-static ThreadSet* _javascript_Threads()
-{
- ASSERT(pthread_mutex_trylock(&_javascript_ThreadsMutex) == EBUSY);
- static ThreadSet staticJavaScriptThreads;
- return &staticJavaScriptThreads;
-}
-
-// This function exercises JSC in a loop until _javascript_ThreadsShouldTerminate
-// becomes true or it probabilistically decides to spawn a replacement thread and exit.
-void* runJavaScriptThread(void* arg)
-{
- static const char* const script =
- "var array = [];"
- "for (var i = 0; i < 1024; i++) {"
- " array.push(String(i));"
- "}";
-
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- JSGlobalContextRef ctx = JSGlobalContextCreateInGroup(_javascript_ThreadsGroup, 0);
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- JSStringRef scriptRef = JSStringCreateWithUTF8CString(script);
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- while (1) {
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- JSValueRef exception = 0;
- JSEvaluateScript(ctx, scriptRef, 0, 0, 1, &exception);
- ASSERT(!exception);
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- size_t valuesCount = 1024;
- JSValueRef values[valuesCount];
- for (size_t i = 0; i < valuesCount; ++i)
- values[i] = JSObjectMake(ctx, 0, 0);
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- // Check for cancellation.
- if (_javascript_ThreadsShouldTerminate)
- goto done;
-
- // Respawn probabilistically.
- if (random() % 5 == 0) {
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- pthread_t pthread;
- pthread_create(&pthread, 0, &runJavaScriptThread, 0);
- pthread_detach(pthread);
- _javascript_Threads()->add(pthread);
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
- goto done;
- }
- }
-
-done:
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- JSStringRelease(scriptRef);
- JSGarbageCollect(ctx);
- JSGlobalContextRelease(ctx);
- _javascript_Threads()->remove(pthread_self());
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
- return 0;
-}
-
-void startJavaScriptThreads()
-{
- _javascript_ThreadsGroup = JSContextGroupCreate();
-
- 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);
- _javascript_Threads()->add(pthread);
- }
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-}
-
-void stopJavaScriptThreads()
-{
- pthread_mutex_lock(&_javascript_ThreadsMutex);
-
- _javascript_ThreadsShouldTerminate = true;
-
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- while (true) {
- pthread_mutex_lock(&_javascript_ThreadsMutex);
- int threadCount = _javascript_Threads()->size();
- pthread_mutex_unlock(&_javascript_ThreadsMutex);
-
- if (!threadCount)
- break;
-
- usleep(1000);
- }
-}