Ignore:
Timestamp:
Dec 16, 2019, 2:34:50 PM (5 years ago)
Author:
[email protected]
Message:

Changed jsc shell timeout mechanism to leverage the VMTraps and use CPUTime.
https://bugs.webkit.org/show_bug.cgi?id=205279
<rdar://problem/57971874>

Reviewed by Saam Barati.

This fixes all the timeouts that occur due to CPU time starvation when
running JSC tests on a debug build.

What this means is that the timeout mechanism may trigger asynchronous
OSR exits. If a test requires no OSR exits, that test should
requireOption("--usePollingTraps=true") so that the VMTraps will use its
polling implementation instead.

I've tested this with a full run of the JSC stress tests with a debug
build and saw 0 timeouts. I've also tested it with a contrived tests that
loops forever, and saw the expected timeout crash.

Will look into re-tuning needed timeout value (and other JSC tests timeout
cleanup) in https://bugs.webkit.org/show_bug.cgi?id=205298.

  • interpreter/Interpreter.cpp:

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

  • interpreter/InterpreterInlines.h:

(JSC::Interpreter::execute):

  • jsc.cpp:

(timeoutCheckCallback):
(initializeTimeoutIfNeeded):
(startTimeoutThreadIfNeeded):
(runJSC):
(jscmain):

  • runtime/JSCConfig.h:
  • runtime/VM.h:

(JSC::VM::notifyNeedShellTimeoutCheck):

  • runtime/VMTraps.cpp:

(JSC::VMTraps::handleTraps):

  • runtime/VMTraps.h:

(JSC::VMTraps::Mask::Mask):
(JSC::VMTraps::Mask::allEventTypes):
(JSC::VMTraps::Mask::init):
(JSC::VMTraps::interruptingTraps):

  • tools/VMInspector.cpp:

(JSC::VMInspector::forEachVM):

  • tools/VMInspector.h:
File:
1 edited

Legend:

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

    r253520 r253581  
    821821    }
    822822
    823     VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
    824     if (UNLIKELY(vm.needTrapHandling(mask))) {
    825         vm.handleTraps(globalObject, vm.topCallFrame, mask);
     823    constexpr auto trapsMask = VMTraps::interruptingTraps();
     824    if (UNLIKELY(vm.needTrapHandling(trapsMask))) {
     825        vm.handleTraps(globalObject, vm.topCallFrame, trapsMask);
    826826        RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
    827827    }
     
    882882        newCodeBlock = 0;
    883883
    884     VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
    885     if (UNLIKELY(vm.needTrapHandling(mask))) {
    886         vm.handleTraps(globalObject, vm.topCallFrame, mask);
     884    constexpr auto trapsMask = VMTraps::interruptingTraps();
     885    if (UNLIKELY(vm.needTrapHandling(trapsMask))) {
     886        vm.handleTraps(globalObject, vm.topCallFrame, trapsMask);
    887887        RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
    888888    }
     
    953953        newCodeBlock = 0;
    954954
    955     VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
    956     if (UNLIKELY(vm.needTrapHandling(mask))) {
    957         vm.handleTraps(globalObject, vm.topCallFrame, mask);
     955    constexpr auto trapsMask = VMTraps::interruptingTraps();
     956    if (UNLIKELY(vm.needTrapHandling(trapsMask))) {
     957        vm.handleTraps(globalObject, vm.topCallFrame, trapsMask);
    958958        RETURN_IF_EXCEPTION(throwScope, nullptr);
    959959    }
     
    11371137    }
    11381138
    1139     VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
    1140     if (UNLIKELY(vm.needTrapHandling(mask))) {
    1141         vm.handleTraps(globalObject, vm.topCallFrame, mask);
     1139    constexpr auto trapsMask = VMTraps::interruptingTraps();
     1140    if (UNLIKELY(vm.needTrapHandling(trapsMask))) {
     1141        vm.handleTraps(globalObject, vm.topCallFrame, trapsMask);
    11421142        RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
    11431143    }
     
    11871187    }
    11881188
    1189     VMTraps::Mask mask(VMTraps::NeedTermination, VMTraps::NeedWatchdogCheck);
    1190     if (UNLIKELY(vm.needTrapHandling(mask))) {
    1191         vm.handleTraps(globalObject, vm.topCallFrame, mask);
     1189    constexpr auto trapsMask = VMTraps::interruptingTraps();
     1190    if (UNLIKELY(vm.needTrapHandling(trapsMask))) {
     1191        vm.handleTraps(globalObject, vm.topCallFrame, trapsMask);
    11921192        RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
    11931193    }
Note: See TracChangeset for help on using the changeset viewer.