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/API/JSContextRef.cpp

    r166756 r169139  
    9090    VM& vm = *toJS(group);
    9191    JSLockHolder locker(&vm);
    92     Watchdog& watchdog = vm.watchdog;
     92    if (!vm.watchdog)
     93        vm.watchdog = std::make_unique<Watchdog>();
     94    Watchdog& watchdog = *vm.watchdog;
    9395    if (callback) {
    9496        void* callbackPtr = reinterpret_cast<void*>(callback);
     
    102104    VM& vm = *toJS(group);
    103105    JSLockHolder locker(&vm);
    104     Watchdog& watchdog = vm.watchdog;
     106    if (!vm.watchdog)
     107        vm.watchdog = std::make_unique<Watchdog>();
     108    Watchdog& watchdog = *vm.watchdog;
    105109    watchdog.setTimeLimit(vm, std::numeric_limits<double>::infinity());
    106110}
Note: See TracChangeset for help on using the changeset viewer.