Changeset 277094 in webkit


Ignore:
Timestamp:
May 6, 2021 9:22:45 AM (3 years ago)
Author:
mark.lam@apple.com
Message:

Forbid further execution in jsc shell if execution is terminated.
https://bugs.webkit.org/show_bug.cgi?id=225410
rdar://77548608

Reviewed by Michael Saboff.

JSTests:

  • stress/jsc-shell-forbid-execution-after-termination.js: Added.

Source/JavaScriptCore:

  1. Introduce a VM::m_executionForbidden flag.
  2. In the jsc shell, forbid further execution if termination was encountered.
  • jsc.cpp:

(runWithOptions):

  • runtime/VM.cpp:

(JSC::VM::drainMicrotasks):

  • runtime/VM.h:

(JSC::VM::executionForbidden const):
(JSC::VM::setExecutionForbidden):

Source/WebCore:

Re-implement WorkerOrWorkletScriptController::forbidExecution() and
isExecutionForbidden() using the VM's notion of the flag

  • workers/WorkerOrWorkletScriptController.cpp:

(WebCore::WorkerOrWorkletScriptController::forbidExecution):
(WebCore::WorkerOrWorkletScriptController::isExecutionForbidden const):

  • workers/WorkerOrWorkletScriptController.h:
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r277035 r277094  
     12021-05-06  Mark Lam  <mark.lam@apple.com>
     2
     3        Forbid further execution in jsc shell if execution is terminated.
     4        https://bugs.webkit.org/show_bug.cgi?id=225410
     5        rdar://77548608
     6
     7        Reviewed by Michael Saboff.
     8
     9        * stress/jsc-shell-forbid-execution-after-termination.js: Added.
     10
    1112021-05-05  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r277092 r277094  
     12021-05-06  Mark Lam  <mark.lam@apple.com>
     2
     3        Forbid further execution in jsc shell if execution is terminated.
     4        https://bugs.webkit.org/show_bug.cgi?id=225410
     5        rdar://77548608
     6
     7        Reviewed by Michael Saboff.
     8
     9        1. Introduce a VM::m_executionForbidden flag.
     10        2. In the jsc shell, forbid further execution if termination was encountered.
     11
     12        * jsc.cpp:
     13        (runWithOptions):
     14        * runtime/VM.cpp:
     15        (JSC::VM::drainMicrotasks):
     16        * runtime/VM.h:
     17        (JSC::VM::executionForbidden const):
     18        (JSC::VM::setExecutionForbidden):
     19
    1202021-05-06  Mark Lam  <mark.lam@apple.com>
    221
  • trunk/Source/JavaScriptCore/jsc.cpp

    r276786 r277094  
    30493049            JSValue returnValue = evaluate(globalObject, jscSource(scriptBuffer, sourceOrigin , fileName), JSValue(), evaluationException);
    30503050            scope.assertNoException();
    3051             if (evaluationException)
     3051            if (evaluationException) {
     3052                if (vm.isTerminationException(evaluationException.get()))
     3053                    vm.setExecutionForbidden();
    30523054                returnValue = evaluationException->value();
     3055            }
    30533056            checkException(globalObject, isLastFile, evaluationException, returnValue, options, success);
    30543057        }
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r277068 r277094  
    13861386void VM::drainMicrotasks()
    13871387{
    1388     do {
    1389         while (!m_microtaskQueue.isEmpty()) {
    1390             m_microtaskQueue.takeFirst()->run();
    1391             if (m_onEachMicrotaskTick)
    1392                 m_onEachMicrotaskTick(*this);
    1393         }
    1394         didExhaustMicrotaskQueue();
    1395     } while (!m_microtaskQueue.isEmpty());
     1388    if (UNLIKELY(executionForbidden()))
     1389        m_microtaskQueue.clear();
     1390    else {
     1391        do {
     1392            while (!m_microtaskQueue.isEmpty()) {
     1393                m_microtaskQueue.takeFirst()->run();
     1394                if (m_onEachMicrotaskTick)
     1395                    m_onEachMicrotaskTick(*this);
     1396            }
     1397            didExhaustMicrotaskQueue();
     1398        } while (!m_microtaskQueue.isEmpty());
     1399    }
    13961400    finalizeSynchronousJSExecution();
    13971401}
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r277068 r277094  
    341341    bool terminationInProgress() const { return m_terminationInProgress; }
    342342    void setTerminationInProgress(bool value) { m_terminationInProgress = value; }
     343
     344    bool executionForbidden() const { return m_executionForbidden; }
     345    void setExecutionForbidden() { m_executionForbidden = true; }
    343346
    344347    JS_EXPORT_PRIVATE Exception* ensureTerminationException();
     
    12641267
    12651268    bool m_terminationInProgress { false };
     1269    bool m_executionForbidden { false };
    12661270
    12671271    Lock m_loopHintExecutionCountLock;
  • trunk/Source/WebCore/ChangeLog

    r277093 r277094  
     12021-05-06  Mark Lam  <mark.lam@apple.com>
     2
     3        Forbid further execution in jsc shell if execution is terminated.
     4        https://bugs.webkit.org/show_bug.cgi?id=225410
     5        rdar://77548608
     6
     7        Reviewed by Michael Saboff.
     8
     9        Re-implement WorkerOrWorkletScriptController::forbidExecution() and
     10        isExecutionForbidden() using the VM's notion of the flag
     11
     12        * workers/WorkerOrWorkletScriptController.cpp:
     13        (WebCore::WorkerOrWorkletScriptController::forbidExecution):
     14        (WebCore::WorkerOrWorkletScriptController::isExecutionForbidden const):
     15        * workers/WorkerOrWorkletScriptController.h:
     16
    1172021-05-06  Darin Adler  <darin@apple.com>
    218
  • trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp

    r276069 r277094  
    109109{
    110110    ASSERT(m_globalScope->isContextThread());
    111     m_executionForbidden = true;
     111    m_vm->setExecutionForbidden();
    112112}
    113113
     
    115115{
    116116    ASSERT(m_globalScope->isContextThread());
    117     return m_executionForbidden;
     117    return m_vm->executionForbidden();
    118118}
    119119
  • trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.h

    r273299 r277094  
    11/*
    2  * Copyright (C) 2008-2020 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008-2021 Apple Inc. All Rights Reserved.
    33 * Copyright (C) 2012 Google Inc. All Rights Reserved.
    44 *
     
    123123    std::unique_ptr<WorkerConsoleClient> m_consoleClient;
    124124    mutable Lock m_scheduledTerminationMutex;
    125     bool m_executionForbidden { false };
    126125    bool m_isTerminatingExecution { false };
    127126};
Note: See TracChangeset for help on using the changeset viewer.