Changeset 107390 in webkit


Ignore:
Timestamp:
Feb 10, 2012 2:48:50 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] GC should be parallel on Qt platform
https://bugs.webkit.org/show_bug.cgi?id=73309

Patch by Roland Takacs <takacs.roland@stud.u-szeged.hu> on 2012-02-10
Reviewed by Zoltan Herczeg.

These changes made the parallel gc feature available for Qt port.
The implementation of "registerGCThread" and "isMainThreadOrGCThread",
and a local static function [initializeGCThreads] is moved from
MainThreadMac.mm to the common MainThread.cpp to make them available
for other platforms.

Measurement results:
V8 speed-up: 1.025x as fast [From: 663.4ms To: 647.0ms ]
V8 Splay speed-up: 1.185x as fast [From: 138.4ms To: 116.8ms ]

Tested on Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz with 4-core.

(WTF::initializeMainThread):
(WTF):
(WTF::initializeGCThreads):
(WTF::registerGCThread):
(WTF::isMainThreadOrGCThread):

  • wtf/MainThread.h:

(WTF):

  • wtf/Platform.h:
  • wtf/mac/MainThreadMac.mm:

(WTF):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r107348 r107390  
     12012-02-10  Roland Takacs  <takacs.roland@stud.u-szeged.hu>
     2
     3        [Qt] GC should be parallel on Qt platform
     4        https://bugs.webkit.org/show_bug.cgi?id=73309
     5
     6        Reviewed by Zoltan Herczeg.
     7
     8        These changes made the parallel gc feature available for Qt port.
     9        The implementation of "registerGCThread" and "isMainThreadOrGCThread",
     10        and a local static function [initializeGCThreads] is moved from
     11        MainThreadMac.mm to the common MainThread.cpp to make them available
     12        for other platforms.
     13
     14        Measurement results:
     15        V8           speed-up:  1.025x as fast  [From: 663.4ms  To: 647.0ms ]
     16        V8 Splay     speed-up:  1.185x as fast  [From: 138.4ms  To: 116.8ms ]
     17
     18        Tested on Intel(R) Core(TM) i5-2320 CPU @ 3.00GHz with 4-core.
     19
     20        * JavaScriptCore.order:
     21        * wtf/MainThread.cpp:
     22        (WTF::initializeMainThread):
     23        (WTF):
     24        (WTF::initializeGCThreads):
     25        (WTF::registerGCThread):
     26        (WTF::isMainThreadOrGCThread):
     27        * wtf/MainThread.h:
     28        (WTF):
     29        * wtf/Platform.h:
     30        * wtf/mac/MainThreadMac.mm:
     31        (WTF):
     32
    1332012-02-09  Andy Wingo  <wingo@igalia.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.order

    r105635 r107390  
    11451145__ZN3JSCL19jsStrDecimalLiteralERPKtS1_
    11461146__ZN3WTF22cancelCallOnMainThreadEPFvPvES0_
     1147__ZN3WTF22isMainThreadOrGCThreadEv
    11471148__ZNK3JSC8JSString9toBooleanEPNS_9ExecStateE
    11481149__ZN3WTF10StringImpl4findEPFbtEj
  • trunk/Source/JavaScriptCore/wtf/MainThread.cpp

    r105987 r107390  
    3535#include "StdLibExtras.h"
    3636#include "Threading.h"
     37#include <wtf/ThreadSpecific.h>
    3738
    3839#if PLATFORM(CHROMIUM)
     
    102103    mainThreadFunctionQueueMutex();
    103104    initializeMainThreadPlatform();
     105    initializeGCThreads();
    104106}
    105107
     
    250252#endif
    251253
     254#if ENABLE(PARALLEL_GC)
     255static ThreadSpecific<bool>* isGCThread;
     256#endif
     257
     258void initializeGCThreads()
     259{
     260#if ENABLE(PARALLEL_GC)
     261    isGCThread = new ThreadSpecific<bool>();
     262#endif
     263}
     264
     265#if ENABLE(PARALLEL_GC)
     266void registerGCThread()
     267{
     268    if (!isGCThread) {
     269        // This happens if we're running in a process that doesn't care about
     270        // MainThread.
     271        return;
     272    }
     273
     274    **isGCThread = true;
     275}
     276
     277bool isMainThreadOrGCThread()
     278{
     279    if (isGCThread->isSet() && **isGCThread)
     280        return true;
     281
     282    return isMainThread();
     283}
     284#elif PLATFORM(MAC) || PLATFORM(WINDOWS)
     285// This is necessary because JavaScriptCore.exp doesn't support preprocessor macros.
     286bool isMainThreadOrGCThread()
     287{
     288    return isMainThread();
     289}
     290#endif
     291
    252292} // namespace WTF
  • trunk/Source/JavaScriptCore/wtf/MainThread.h

    r104900 r107390  
    5353
    5454WTF_EXPORT_PRIVATE bool isMainThread();
     55
     56void initializeGCThreads();
     57
    5558#if ENABLE(PARALLEL_GC)
    5659void registerGCThread();
    5760WTF_EXPORT_PRIVATE bool isMainThreadOrGCThread();
    58 #elif PLATFORM(MAC)
    59 bool isMainThreadOrGCThread();
     61#elif PLATFORM(MAC) || PLATFORM(WINDOWS)
     62WTF_EXPORT_PRIVATE bool isMainThreadOrGCThread();
    6063#else
    6164inline bool isMainThreadOrGCThread() { return isMainThread(); }
  • trunk/Source/JavaScriptCore/wtf/Platform.h

    r107036 r107390  
    11241124#endif
    11251125
    1126 #if !defined(ENABLE_PARALLEL_GC) && (PLATFORM(MAC) || PLATFORM(IOS)) && ENABLE(COMPARE_AND_SWAP)
     1126#if !defined(ENABLE_PARALLEL_GC) && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(QT)) && ENABLE(COMPARE_AND_SWAP)
    11271127#define ENABLE_PARALLEL_GC 1
    11281128#endif
  • trunk/Source/JavaScriptCore/wtf/mac/MainThreadMac.mm

    r105987 r107390  
    3636#import <wtf/HashSet.h>
    3737#import <wtf/Threading.h>
    38 #import <wtf/ThreadSpecific.h>
    3938
    4039@interface JSWTFMainThreadCaller : NSObject {
     
    5958static pthread_t mainThreadPthread;
    6059static NSThread* mainThreadNSThread;
    61 
    62 #if ENABLE(PARALLEL_GC)
    63 static ThreadSpecific<bool>* isGCThread;
    64 
    65 static void initializeGCThreads()
    66 {
    67     isGCThread = new ThreadSpecific<bool>();
    68 }
    69 #else
    70 static void initializeGCThreads() { }
    71 #endif
    7260
    7361void initializeMainThreadPlatform()
     
    146134}
    147135
    148 #if ENABLE(PARALLEL_GC)
    149 void registerGCThread()
    150 {
    151     if (!isGCThread) {
    152         // This happens if we're running in a process that doesn't care about
    153         // MainThread.
    154         return;
    155     }
    156 
    157     **isGCThread = true;
    158 }
    159 
    160 bool isMainThreadOrGCThread()
    161 {
    162     if (isGCThread->isSet() && **isGCThread)
    163         return true;
    164    
    165     return isMainThread();
    166 }
    167 #else
    168 // This is necessary because JavaScriptCore.exp doesn't support preprocessor macros.
    169 bool isMainThreadOrGCThread()
    170 {
    171     return isMainThread();
    172 }
    173 #endif
    174 
    175136} // namespace WTF
Note: See TracChangeset for help on using the changeset viewer.