Ignore:
Timestamp:
Apr 6, 2010, 9:38:23 PM (15 years ago)
Author:
[email protected]
Message:

2010-04-06 Adam Barth <[email protected]>

Reviewed by Eric Seidel.

REGRESSION: Worker termination via JS timeout may cause worker tests like fast/workers/worker-terminate.html fail.
https://bugs.webkit.org/show_bug.cgi?id=36646

Add a new exception type for forcibly terminating a JavaScript stack.
The new exception functions similarly to the
InterruptedExecutionException but is conceptually different because
execution is terminated instead of just interrupted.

  • GNUmakefile.am:
    • Added new Terminator.h file.
  • JavaScriptCore.gypi:
    • Added new Terminator.h file.
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
    • Added new Terminator.h file.
  • JavaScriptCore.xcodeproj/project.pbxproj:
    • Added new Terminator.h file.
  • interpreter/Interpreter.cpp: (JSC::Interpreter::throwException):
    • Fully unwind the stack for TerminatedExecutionException.

(JSC::Interpreter::privateExecute):

  • Check if we've been terminated at the same time we check if we've timed out.
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
    • Check if we've been terminated at the same time we check if we've timed out.
  • runtime/Completion.cpp:
    • Some exceptions define special completion types so that calls can see why we terminated evaluation.

(JSC::evaluate):

  • runtime/Completion.h:
    • Define a new completion type for termination.

(JSC::):

  • runtime/ExceptionHelpers.cpp:
    • Define TerminatedExecutionException and refactor pseudo-RTTI virtual function to be more semantic.

(JSC::InterruptedExecutionError::exceptionType):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
(JSC::TerminatedExecutionError::exceptionType):
(JSC::TerminatedExecutionError::toString):
(JSC::createTerminatedExecutionException):

  • runtime/ExceptionHelpers.h:
    • Entry point for generating a TerminatedExecutionException.
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
    • Add a Terminator object that can be used to asynchronously terminate a JavaScript execution stack.
  • runtime/JSGlobalData.h:
  • runtime/JSObject.h: (JSC::JSObject::exceptionType):
    • Define that, by default, thrown objects have a normal exception type.
  • runtime/Terminator.h: Added.
    • Added a new controller object that can be used to terminate execution asynchronously. This object is more or less a glorified bool.

(JSC::Terminator::Terminator):
(JSC::Terminator::termianteSoon):
(JSC::Terminator::shouldTerminate):

2010-04-06 Adam Barth <[email protected]>

Reviewed by Eric Seidel.

REGRESSION: Worker termination via JS timeout may cause worker tests like fast/workers/worker-terminate.html fail.
https://bugs.webkit.org/show_bug.cgi?id=36646

  • fast/workers/resources/worker-run-forever.js: Added.
  • fast/workers/worker-terminate-forever-expected.txt: Added.
  • fast/workers/worker-terminate-forever.html: Added.
    • Test what happens when we terminate an infinitely running worker. The essential point is that we don't spam the console with nonsense about a timeout.
  • platform/mac/Skipped:
    • Rescue worker-terminate.html from the Skipped list now that we've fixed the underlying bug that was causing the flakiness.

2010-04-06 Adam Barth <[email protected]>

Reviewed by Eric Seidel.

REGRESSION: Worker termination via JS timeout may cause worker tests like fast/workers/worker-terminate.html fail.
https://bugs.webkit.org/show_bug.cgi?id=36646

Cause the worker code to swallow termination exceptions because these
need not be reported to the user because they are an implementation
detail of how we terminate worker execution.

Test: fast/workers/worker-terminate-forever.html

  • bindings/js/JSDOMBinding.cpp: (WebCore::reportException):
    • Refuse to report termination exceptions to the user because they are an implementation detail.
  • bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::forbidExecution):
    • Instead of using timeouts to stop run away workers, use our fancy new Terminator object.
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Terminator.h

    r57191 r57192  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1111 *     notice, this list of conditions and the following disclaimer in the
    1212 *     documentation and/or other materials provided with the distribution.
    13  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     13 * 3.  Neither the name of Google Inc. ("Google") nor the names of
    1414 *     its contributors may be used to endorse or promote products derived
    1515 *     from this software without specific prior written permission.
     
    2727 */
    2828
    29 #ifndef ExceptionHelpers_h
    30 #define ExceptionHelpers_h
    31 
     29#ifndef Terminator_h
     30#define Terminator_h
    3231
    3332namespace JSC {
    3433
    35     class CodeBlock;
    36     class ExecState;
    37     class Identifier;
    38     class JSGlobalData;
    39     class JSNotAnObjectErrorStub;
    40     class JSObject;
    41     class JSValue;
    42     class Node;
    43     struct Instruction;
    44    
    45     JSValue createInterruptedExecutionException(JSGlobalData*);
    46     JSValue createStackOverflowError(ExecState*);
    47     JSValue createTypeError(ExecState*, const char* message);
    48     JSValue createUndefinedVariableError(ExecState*, const Identifier&, unsigned bytecodeOffset, CodeBlock*);
    49     JSNotAnObjectErrorStub* createNotAnObjectErrorStub(ExecState*, bool isNull);
    50     JSObject* createInvalidParamError(ExecState*, const char* op, JSValue, unsigned bytecodeOffset, CodeBlock*);
    51     JSObject* createNotAConstructorError(ExecState*, JSValue, unsigned bytecodeOffset, CodeBlock*);
    52     JSValue createNotAFunctionError(ExecState*, JSValue, unsigned bytecodeOffset, CodeBlock*);
    53     JSObject* createNotAnObjectError(ExecState*, JSNotAnObjectErrorStub*, unsigned bytecodeOffset, CodeBlock*);
    54     JSValue throwOutOfMemoryError(ExecState*);
     34class Terminator {
     35public:
     36    Terminator() : m_shouldTerminate(false) { }
     37
     38    void terminateSoon() { m_shouldTerminate = true; }
     39    bool shouldTerminate() const { return m_shouldTerminate; }
     40
     41private:
     42    bool m_shouldTerminate;
     43};
    5544
    5645} // namespace JSC
    5746
    58 #endif // ExceptionHelpers_h
     47#endif // Terminator_h
Note: See TracChangeset for help on using the changeset viewer.