Ignore:
Timestamp:
May 20, 2014, 3:55:49 PM (11 years ago)
Author:
[email protected]
Message:

Watchdog timer should be lazily allocated
https://bugs.webkit.org/show_bug.cgi?id=133135

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:
We incur a noticeable amount of overhead on some benchmarks due to checking if the Watchdog ever fired.
There is no reason to do this checking if we never activated the Watchdog, which can only be done through
JSContextGroupSetExecutionTimeLimit or JSContextGroupClearExecutionTimeLimit.

By allocating the Watchdog lazily on the VM we can avoid all of the associated overhead when we don't use
these two API functions (which is true of most clients).

  • API/JSContextRef.cpp:

(JSContextGroupSetExecutionTimeLimit):
(JSContextGroupClearExecutionTimeLimit):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_loop_hint):
(JSC::JIT::emitSlow_op_loop_hint):

  • jit/JITOperations.cpp:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/VM.h:
  • runtime/Watchdog.cpp:

(JSC::Watchdog::Scope::Scope): Deleted.
(JSC::Watchdog::Scope::~Scope): Deleted.

  • runtime/Watchdog.h:

(JSC::Watchdog::Scope::Scope):
(JSC::Watchdog::Scope::~Scope):

Source/WebCore:
No new tests.

We incur a noticeable amount of overhead on some benchmarks due to checking if the Watchdog ever fired.
There is no reason to do this checking if we never activated the Watchdog, which can only be done through
JSContextGroupSetExecutionTimeLimit or JSContextGroupClearExecutionTimeLimit.

By allocating the Watchdog lazily on the VM we can avoid all of the associated overhead when we don't use
these two API functions (which is true of most clients).

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::evaluate):
(WebCore::WorkerScriptController::scheduleExecutionTermination):
(WebCore::WorkerScriptController::isExecutionTerminating):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r167313 r169139  
    914914    ProgramCodeBlock* codeBlock = program->codeBlock();
    915915
    916     if (UNLIKELY(vm.watchdog.didFire(callFrame)))
     916    if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
    917917        return throwTerminatedExecutionException(callFrame);
    918918
     
    929929    {
    930930        SamplingTool::CallRecord callRecord(m_sampler.get());
    931         Watchdog::Scope watchdogScope(vm.watchdog);
     931        Watchdog::Scope watchdogScope(vm.watchdog.get());
    932932
    933933        result = program->generatedJITCode()->execute(&vm, &protoCallFrame);
     
    976976        newCodeBlock = 0;
    977977
    978     if (UNLIKELY(vm.watchdog.didFire(callFrame)))
     978    if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
    979979        return throwTerminatedExecutionException(callFrame);
    980980
     
    988988    {
    989989        SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSCall);
    990         Watchdog::Scope watchdogScope(vm.watchdog);
     990        Watchdog::Scope watchdogScope(vm.watchdog.get());
    991991
    992992        // Execute the code:
     
    10441044        newCodeBlock = 0;
    10451045
    1046     if (UNLIKELY(vm.watchdog.didFire(callFrame)))
     1046    if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
    10471047        return throwTerminatedExecutionException(callFrame);
    10481048
     
    10561056    {
    10571057        SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSConstruct);
    1058         Watchdog::Scope watchdogScope(vm.watchdog);
     1058        Watchdog::Scope watchdogScope(vm.watchdog.get());
    10591059
    10601060        // Execute the code.
     
    11191119        profiler->willExecute(closure.oldCallFrame, closure.function);
    11201120
    1121     if (UNLIKELY(vm.watchdog.didFire(closure.oldCallFrame)))
     1121    if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(closure.oldCallFrame)))
    11221122        return throwTerminatedExecutionException(closure.oldCallFrame);
    11231123
     
    11261126    {
    11271127        SamplingTool::CallRecord callRecord(m_sampler.get());
    1128         Watchdog::Scope watchdogScope(vm.watchdog);
     1128        Watchdog::Scope watchdogScope(vm.watchdog.get());
    11291129
    11301130        result = closure.functionExecutable->generatedJITCodeForCall()->execute(&vm, closure.protoCallFrame);
     
    11951195    }
    11961196
    1197     if (UNLIKELY(vm.watchdog.didFire(callFrame)))
     1197    if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
    11981198        return throwTerminatedExecutionException(callFrame);
    11991199
     
    12101210    {
    12111211        SamplingTool::CallRecord callRecord(m_sampler.get());
    1212         Watchdog::Scope watchdogScope(vm.watchdog);
     1212        Watchdog::Scope watchdogScope(vm.watchdog.get());
    12131213
    12141214        result = eval->generatedJITCode()->execute(&vm, &protoCallFrame);
Note: See TracChangeset for help on using the changeset viewer.