Changeset 188338 in webkit


Ignore:
Timestamp:
Aug 12, 2015 11:14:02 AM (9 years ago)
Author:
mark.lam@apple.com
Message:

Add a JSC option to enable the watchdog for testing.
https://bugs.webkit.org/show_bug.cgi?id=147939

Reviewed by Michael Saboff.

  • API/JSContextRef.cpp:

(JSContextGroupSetExecutionTimeLimit):
(createWatchdogIfNeeded): Deleted.

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

(JSC::VM::VM):
(JSC::VM::~VM):
(JSC::VM::sharedInstanceInternal):
(JSC::VM::ensureWatchdog):
(JSC::thunkGeneratorForIntrinsic):

  • runtime/VM.h:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSContextRef.cpp

    r188329 r188338  
    9393}
    9494
    95 static void createWatchdogIfNeeded(VM& vm)
    96 {
    97     if (!vm.watchdog) {
    98         vm.watchdog = adoptRef(new Watchdog());
    99 
    100         // The LLINT peeks into the Watchdog object directly. In order to do that,
    101         // the LLINT assumes that the internal shape of a std::unique_ptr is the
    102         // same as a plain C++ pointer, and loads the address of Watchdog from it.
    103         RELEASE_ASSERT(*reinterpret_cast<Watchdog**>(&vm.watchdog) == vm.watchdog.get());
    104     }
    105 }
    106 
    10795void JSContextGroupSetExecutionTimeLimit(JSContextGroupRef group, double limit, JSShouldTerminateCallback callback, void* callbackData)
    10896{
    10997    VM& vm = *toJS(group);
    11098    JSLockHolder locker(&vm);
    111     createWatchdogIfNeeded(vm);
    112     Watchdog& watchdog = *vm.watchdog;
     99    Watchdog& watchdog = vm.ensureWatchdog();
    113100    if (callback) {
    114101        void* callbackPtr = reinterpret_cast<void*>(callback);
  • trunk/Source/JavaScriptCore/ChangeLog

    r188329 r188338  
     12015-08-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Add a JSC option to enable the watchdog for testing.
     4        https://bugs.webkit.org/show_bug.cgi?id=147939
     5
     6        Reviewed by Michael Saboff.
     7
     8        * API/JSContextRef.cpp:
     9        (JSContextGroupSetExecutionTimeLimit):
     10        (createWatchdogIfNeeded): Deleted.
     11        * runtime/Options.h:
     12        * runtime/VM.cpp:
     13        (JSC::VM::VM):
     14        (JSC::VM::~VM):
     15        (JSC::VM::sharedInstanceInternal):
     16        (JSC::VM::ensureWatchdog):
     17        (JSC::thunkGeneratorForIntrinsic):
     18        * runtime/VM.h:
     19
    1202015-08-11  Mark Lam  <mark.lam@apple.com>
    221
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r187555 r188338  
    321321    v(bool, enableDollarVM, false, "installs the $vm debugging tool in global objects") \
    322322    v(optionString, functionOverrides, nullptr, "file with debugging overrides for function bodies") \
     323    \
     324    v(unsigned, watchdog, 0, "watchdog timeout (0 = Disabled, N = a timeout period of N milliseconds)") \
    323325
    324326class Options {
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r188329 r188338  
    287287    if (Options::enableControlFlowProfiler())
    288288        enableControlFlowProfiler();
     289
     290    if (Options::watchdog()) {
     291        std::chrono::milliseconds timeoutMillis(Options::watchdog());
     292        Watchdog& watchdog = ensureWatchdog();
     293        watchdog.setTimeLimit(*this, timeoutMillis);
     294    }
    289295}
    290296
     
    370376    static VM* sharedInstance;
    371377    return sharedInstance;
     378}
     379
     380Watchdog& VM::ensureWatchdog()
     381{
     382    if (!watchdog) {
     383        watchdog = adoptRef(new Watchdog());
     384       
     385        // The LLINT peeks into the Watchdog object directly. In order to do that,
     386        // the LLINT assumes that the internal shape of a std::unique_ptr is the
     387        // same as a plain C++ pointer, and loads the address of Watchdog from it.
     388        RELEASE_ASSERT(*reinterpret_cast<Watchdog**>(&watchdog) == watchdog.get());
     389    }
     390    return *watchdog;
    372391}
    373392
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r188329 r188338  
    238238    JS_EXPORT_PRIVATE ~VM();
    239239
     240    Watchdog& ensureWatchdog();
     241
    240242private:
    241243    RefPtr<JSLock> m_apiLock;
Note: See TracChangeset for help on using the changeset viewer.