Changeset 153331 in webkit


Ignore:
Timestamp:
Jul 25, 2013 10:01:56 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Optimize the thread locks for API Shims
https://bugs.webkit.org/show_bug.cgi?id=118573

Patch by Yi Shen <max.hong.shen@gmail.com> on 2013-07-25
Reviewed by Geoffrey Garen.

Remove the thread lock from API Shims if the VM has an exclusive thread (e.g. the VM
only used by WebCore's main thread).

Source/JavaScriptCore:

  • API/APIShims.h:

(JSC::APIEntryShim::APIEntryShim):
(JSC::APICallbackShim::APICallbackShim):

  • runtime/JSLock.cpp:

(JSC::JSLockHolder::JSLockHolder):
(JSC::JSLockHolder::init):
(JSC::JSLockHolder::~JSLockHolder):
(JSC::JSLock::DropAllLocks::DropAllLocks):
(JSC::JSLock::DropAllLocks::~DropAllLocks):

  • runtime/VM.cpp:

(JSC::VM::VM):

  • runtime/VM.h:

Source/WebCore:

No new tests required since no functionality changed.

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::commonVM):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/APIShims.h

    r148704 r153331  
    6060    APIEntryShim(ExecState* exec, bool registerThread = true)
    6161        : APIEntryShimWithoutLock(&exec->vm(), registerThread)
    62         , m_lockHolder(exec)
     62        , m_lockHolder(exec->vm().exclusiveThread ? 0 : exec)
    6363    {
    6464    }
     
    6767    APIEntryShim(VM* vm, bool registerThread = true)
    6868        : APIEntryShimWithoutLock(vm, registerThread)
    69         , m_lockHolder(vm)
     69        , m_lockHolder(vm->exclusiveThread ? 0 : vm)
    7070    {
    7171    }
     
    8484public:
    8585    APICallbackShim(ExecState* exec)
    86         : m_dropAllLocks(exec)
     86        : m_dropAllLocks(exec->vm().exclusiveThread ? 0 : exec)
    8787        , m_vm(&exec->vm())
    8888    {
  • trunk/Source/JavaScriptCore/ChangeLog

    r153329 r153331  
     12013-07-25  Yi Shen  <max.hong.shen@gmail.com>
     2
     3        Optimize the thread locks for API Shims
     4        https://bugs.webkit.org/show_bug.cgi?id=118573
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Remove the thread lock from API Shims if the VM has an exclusive thread (e.g. the VM
     9        only used by WebCore's main thread).
     10
     11        * API/APIShims.h:
     12        (JSC::APIEntryShim::APIEntryShim):
     13        (JSC::APICallbackShim::APICallbackShim):
     14        * runtime/JSLock.cpp:
     15        (JSC::JSLockHolder::JSLockHolder):
     16        (JSC::JSLockHolder::init):
     17        (JSC::JSLockHolder::~JSLockHolder):
     18        (JSC::JSLock::DropAllLocks::DropAllLocks):
     19        (JSC::JSLock::DropAllLocks::~DropAllLocks):
     20        * runtime/VM.cpp:
     21        (JSC::VM::VM):
     22        * runtime/VM.h:
     23
    1242013-07-25  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    225
  • trunk/Source/JavaScriptCore/runtime/JSLock.cpp

    r148696 r153331  
    5252
    5353JSLockHolder::JSLockHolder(ExecState* exec)
    54     : m_vm(&exec->vm())
     54    : m_vm(exec ? &exec->vm() : 0)
    5555{
    5656    init();
     
    7171void JSLockHolder::init()
    7272{
    73     m_vm->apiLock().lock();
     73    if (m_vm)
     74        m_vm->apiLock().lock();
    7475}
    7576
    7677JSLockHolder::~JSLockHolder()
    7778{
     79    if (!m_vm)
     80        return;
     81
    7882    RefPtr<JSLock> apiLock(&m_vm->apiLock());
    7983    m_vm.clear();
     
    216220JSLock::DropAllLocks::DropAllLocks(ExecState* exec)
    217221    : m_lockCount(0)
    218     , m_vm(&exec->vm())
    219 {
    220     m_lockCount = m_vm->apiLock().dropAllLocks();
     222    , m_vm(exec ? &exec->vm() : 0)
     223{
     224    if (m_vm)
     225        m_lockCount = m_vm->apiLock().dropAllLocks();
    221226}
    222227
     
    225230    , m_vm(vm)
    226231{
    227     m_lockCount = m_vm->apiLock().dropAllLocks();
     232    if (m_vm)
     233        m_lockCount = m_vm->apiLock().dropAllLocks();
    228234}
    229235
    230236JSLock::DropAllLocks::~DropAllLocks()
    231237{
    232     m_vm->apiLock().grabAllLocks(m_lockCount);
     238    if (m_vm)
     239        m_vm->apiLock().grabAllLocks(m_lockCount);
    233240}
    234241
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r153276 r153331  
    176176    , m_rtTraceList(new RTTraceList())
    177177#endif
    178 #ifndef NDEBUG
    179178    , exclusiveThread(0)
    180 #endif
    181179    , m_newStringsSinceLastHashCons(0)
    182180#if ENABLE(ASSEMBLER)
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r153223 r153331  
    390390#endif
    391391
    392 #ifndef NDEBUG
    393392        ThreadIdentifier exclusiveThread;
    394 #endif
    395393
    396394        CachedTranscendentalFunction<std::sin> cachedSin;
  • trunk/Source/WebCore/ChangeLog

    r153330 r153331  
     12013-07-25  Yi Shen  <max.hong.shen@gmail.com>
     2
     3        Optimize the thread locks for API Shims
     4        https://bugs.webkit.org/show_bug.cgi?id=118573
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Remove the thread lock from API Shims if the VM has an exclusive thread (e.g. the VM
     9        only used by WebCore's main thread).
     10
     11        No new tests required since no functionality changed.
     12
     13        * bindings/js/JSDOMWindowBase.cpp:
     14        (WebCore::JSDOMWindowBase::commonVM):
     15
    1162013-07-25  Bear Travis  <betravis@adobe.com>
    217
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp

    r151605 r153331  
    185185        ScriptController::initializeThreading();
    186186        vm = VM::createLeaked(LargeHeap).leakRef();
    187 #ifndef NDEBUG
    188187        vm->exclusiveThread = currentThread();
    189 #endif
    190188        initNormalWorldClientData(vm);
    191189    }
Note: See TracChangeset for help on using the changeset viewer.