Ignore:
Timestamp:
Aug 28, 2013, 5:28:42 PM (12 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=119548
Refactoring Exception throws.

Patch by Chris Curtis <[email protected]> on 2013-08-28
Reviewed by Geoffrey Garen.

Gardening of exception throws. The act of throwing an exception was being handled in
different ways depending on whether the code was running in the LLint, Baseline JIT,
or the DFG Jit. This made development in the vm exception and error objects difficult.

  • runtime/VM.cpp:

(JSC::appendSourceToError):
This function moved from the interpreter into the VM. It views the developers code
(if there is a codeBlock) to extract what was trying to be evaluated when the error
occurred.

(JSC::VM::throwException):
This function takes in the error object and sets the following:

1: The VM's exception stack
2: The VM's exception
3: Appends extra information on the error message(via appendSourceToError)
4: The error object's line number
5: The error object's column number
6: The error object's sourceURL
7: The error object's stack trace (unless it already exists because the developer

created the error object).

(JSC::VM::getExceptionInfo):
(JSC::VM::setExceptionInfo):
(JSC::VM::clearException):
(JSC::clearExceptionStack):

  • runtime/VM.h:

(JSC::VM::exceptionOffset):
(JSC::VM::exception):
(JSC::VM::addressOfException):
(JSC::VM::exceptionStack):
VM exception and exceptionStack are now private data members.

  • interpreter/Interpreter.h:

(JSC::ClearExceptionScope::ClearExceptionScope):
Created this structure to temporarily clear the exception within the VM. This
needed to see if addition errors occur when setting the debugger as we are
unwinding the stack.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwind):
Removed the code that would try to add error information if it did not exist.
All of this functionality has moved into the VM and all error information is set
at the time the error occurs.

The rest of these functions reference the new calling convention to throw an error.

  • API/APICallbackFunction.h:

(JSC::APICallbackFunction::call):

  • API/JSCallbackConstructor.cpp:

(JSC::constructJSCallback):

  • API/JSCallbackObjectFunctions.h:

(JSC::::getOwnPropertySlot):
(JSC::::defaultValue):
(JSC::::put):
(JSC::::putByIndex):
(JSC::::deleteProperty):
(JSC::::construct):
(JSC::::customHasInstance):
(JSC::::call):
(JSC::::getStaticValue):
(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):

  • debugger/Debugger.cpp:

(JSC::evaluateInGlobalCallFrame):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • dfg/DFGAssemblyHelpers.h:

(JSC::DFG::AssemblyHelpers::emitExceptionCheck):

  • dfg/DFGOperations.cpp:

(JSC::DFG::operationPutByValInternal):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::callCheck):

  • heap/Heap.cpp:

(JSC::Heap::markRoots):

  • interpreter/CallFrame.h:

(JSC::ExecState::clearException):
(JSC::ExecState::exception):
(JSC::ExecState::hadException):

  • interpreter/Interpreter.cpp:

(JSC::eval):
(JSC::loadVarargs):
(JSC::stackTraceAsString):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):

  • interpreter/Interpreter.h:

(JSC::ClearExceptionScope::ClearExceptionScope):

  • jit/JITCode.cpp:

(JSC::JITCode::execute):

  • jit/JITExceptions.cpp:

(JSC::genericThrow):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_catch):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::privateCompileCTINativeCall):
(JSC::JIT::emit_op_catch):

  • jit/JITStubs.cpp:

(JSC::returnToThrowTrampoline):
(JSC::throwExceptionFromOpCall):
(JSC::DEFINE_STUB_FUNCTION):
(JSC::jitCompileFor):
(JSC::lazyLinkFor):
(JSC::putByVal):
(JSC::cti_vm_handle_exception):

  • jit/SlowPathCall.h:

(JSC::JITSlowPathCall::call):

  • jit/ThunkGenerators.cpp:

(JSC::nativeForGenerator):

  • jsc.cpp:

(functionRun):
(functionLoad):
(functionCheckSyntax):

  • llint/LLIntExceptions.cpp:

(JSC::LLInt::doThrow):
(JSC::LLInt::returnToThrow):
(JSC::LLInt::callToThrow):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LowLevelInterpreter.cpp:

(JSC::CLoop::execute):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/ArrayConstructor.cpp:

(JSC::constructArrayWithSizeQuirk):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

(JSC::CommonSlowPaths::opIn):

  • runtime/CommonSlowPathsExceptions.cpp:

(JSC::CommonSlowPaths::interpreterThrowInCaller):

  • runtime/Completion.cpp:

(JSC::evaluate):

  • runtime/Error.cpp:

(JSC::addErrorInfo):
(JSC::throwTypeError):
(JSC::throwSyntaxError):

  • runtime/Error.h:

(JSC::throwVMError):

  • runtime/ExceptionHelpers.cpp:

(JSC::throwOutOfMemoryError):
(JSC::throwStackOverflowError):
(JSC::throwTerminatedExecutionException):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::create):
(JSC::FunctionExecutable::produceCodeBlockFor):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):
(JSC::constructFunctionSkippingEvalEnabledCheck):

  • runtime/JSArray.cpp:

(JSC::JSArray::defineOwnProperty):
(JSC::JSArray::put):
(JSC::JSArray::push):

  • runtime/JSCJSValue.cpp:

(JSC::JSValue::toObjectSlowCase):
(JSC::JSValue::synthesizePrototype):
(JSC::JSValue::putToPrimitive):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::::create):
(JSC::::createUninitialized):
(JSC::::validateRange):
(JSC::::setWithSpecificType):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::encode):
(JSC::decode):
(JSC::globalFuncProtoSetter):

  • runtime/JSNameScope.cpp:

(JSC::JSNameScope::put):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::appendStringifiedValue):
(JSC::Walker::walk):

  • runtime/JSObject.cpp:

(JSC::JSObject::put):
(JSC::JSObject::defaultValue):
(JSC::JSObject::hasInstance):
(JSC::JSObject::defaultHasInstance):
(JSC::JSObject::defineOwnNonIndexProperty):
(JSC::throwTypeError):

  • runtime/ObjectConstructor.cpp:

(JSC::toPropertyDescriptor):

  • runtime/RegExpConstructor.cpp:

(JSC::constructRegExp):

  • runtime/StringObject.cpp:

(JSC::StringObject::defineOwnProperty):

  • runtime/StringRecursionChecker.cpp:

(JSC::StringRecursionChecker::throwStackOverflowError):

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=119548
Refactoring Exception throws.

Patch by Chris Curtis <[email protected]> on 2013-08-28
Reviewed by Geoffrey Garen.

Gets column information from the error object for reporting exceptions.

  • bindings/js/JSDOMBinding.cpp:

(WebCore::reportException):

  • bindings/js/ScriptCallStackFactory.cpp:

(WebCore::createScriptCallStackFromException):

Moved setting an exception into the vm, These functions changed to use the new functionality.

  • bindings/js/JSAudioBufferSourceNodeCustom.cpp:

(WebCore::JSAudioBufferSourceNode::setBuffer):

  • bindings/js/JSBiquadFilterNodeCustom.cpp:

(WebCore::JSBiquadFilterNode::setType):

  • bindings/js/JSCryptoCustom.cpp:

(WebCore::JSCrypto::getRandomValues):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::setDOMException):

  • bindings/js/JSInjectedScriptHostCustom.cpp:

(WebCore::JSInjectedScriptHost::setFunctionVariableValue):

  • bindings/js/JSJavaScriptCallFrameCustom.cpp:

(WebCore::JSJavaScriptCallFrame::evaluate):
(WebCore::JSJavaScriptCallFrame::setVariableValue):

  • bindings/js/JSNodeFilterCondition.cpp:

(WebCore::JSNodeFilterCondition::acceptNode):

  • bindings/js/JSOscillatorNodeCustom.cpp:

(WebCore::JSOscillatorNode::setType):

  • bindings/js/JSPannerNodeCustom.cpp:

(WebCore::JSPannerNode::setPanningModel):
(WebCore::JSPannerNode::setDistanceModel):

  • bindings/js/JSSVGLengthCustom.cpp:

(WebCore::JSSVGLength::convertToSpecifiedUnits):

  • bindings/js/JSWebGLRenderingContextCustom.cpp:

(WebCore::getObjectParameter):
(WebCore::JSWebGLRenderingContext::getAttachedShaders):
(WebCore::JSWebGLRenderingContext::getExtension):
(WebCore::JSWebGLRenderingContext::getFramebufferAttachmentParameter):
(WebCore::JSWebGLRenderingContext::getParameter):
(WebCore::JSWebGLRenderingContext::getProgramParameter):
(WebCore::JSWebGLRenderingContext::getShaderParameter):
(WebCore::JSWebGLRenderingContext::getUniform):
(WebCore::dataFunctionf):
(WebCore::dataFunctioni):
(WebCore::dataFunctionMatrix):

  • bindings/js/JSXMLHttpRequestCustom.cpp:

(WebCore::JSXMLHttpRequest::open):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneBase::throwStackOverflow):
(WebCore::CloneDeserializer::throwValidationError):
(WebCore::SerializedScriptValue::maybeThrowExceptionIfSerializationFailed):

  • bindings/js/WorkerScriptController.cpp:

(WebCore::WorkerScriptController::evaluate):
(WebCore::WorkerScriptController::setException):

  • bridge/c/c_instance.cpp:

(JSC::Bindings::CInstance::moveGlobalExceptionToExecState):
(JSC::Bindings::CInstance::invokeMethod):
(JSC::Bindings::CInstance::invokeDefaultMethod):
(JSC::Bindings::CInstance::invokeConstruct):
(JSC::Bindings::CInstance::toJSPrimitive):

  • bridge/objc/objc_instance.mm:

(ObjcInstance::invokeMethod):

  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::ObjcArray::setValueAt):
(JSC::Bindings::ObjcArray::valueAt):

  • bridge/objc/objc_utility.mm:

(JSC::Bindings::throwError):

  • bridge/qt/qt_instance.cpp:

(JSC::Bindings::QtField::valueFromInstance):
(JSC::Bindings::QtField::setValueToInstance):

  • bridge/runtime_array.cpp:

(JSC::RuntimeArray::put):
(JSC::RuntimeArray::putByIndex):

  • bridge/runtime_object.cpp:

(JSC::Bindings::RuntimeObject::throwInvalidAccessError):

Source/WebKit/mac: https://bugs.webkit.org/show_bug.cgi?id=119548
Refactoring Exception throws.

Patch by Chris Curtis <[email protected]> on 2013-08-28
Reviewed by Geoffrey Garen.

Moved setting an exception into the vm, These functions changed to use the new functionality.

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::moveGlobalExceptionToExecState):

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyInstance::invokeMethod):

Source/WebKit2: https://bugs.webkit.org/show_bug.cgi?id=119548
Refactoring Exception throws.

Patch by Chris Curtis <[email protected]> on 2013-08-28
Reviewed by Geoffrey Garen.

Moved setting an exception into the vm, These functions changed to use the new functionality.

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::JSNPObject::callMethod):
(WebKit::JSNPObject::callObject):
(WebKit::JSNPObject::callConstructor):
(WebKit::JSNPObject::throwInvalidAccessError):

  • WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:

(WebKit::NPRuntimeObjectMap::moveGlobalExceptionToExecState):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=119548
Refactoring Exception throws.

Patch by Chris Curtis <[email protected]> on 2013-08-28
Reviewed by Geoffrey Garen.

Column/line information was added into these results.

  • fast/events/window-onerror4-expected.txt:
  • fast/js/global-recursion-on-full-stack-expected.txt:

fixed a variable name in a case when shouldThrowType failed.

  • fast/js/mozilla/resources/js-test-pre.js:

(shouldThrowType):

Sorted the properties to allow the results always show in the same order.

  • fast/js/script-tests/exception-properties.js:
  • fast/js/exception-properties-expected.txt:

This test needed to be modified to have the line numbers match on the output across
wk and wk2. This test is inherently flaky because is relies on size of the available
native stack. To account for the flakiness an additional call was made to force the
results to match.
This patch now records and outputs the line number where the errors were occurring.
This was causing the test results to no longer match because of the line numbers.
By changing how to account for the flakiness, the results match again.

  • fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt:
  • fast/xmlhttprequest/xmlhttprequest-recursive-sync-event.html:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r154633 r154797  
    380380                ASSERT(thisObject->structure()->prototypeChainMayInterceptStoreTo(exec->vm(), propertyName) || obj == thisObject);
    381381                if (slot.isStrictMode())
    382                     throwError(exec, createTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError)));
     382                    exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError)));
    383383                return;
    384384            }
     
    13681368    ASSERT(!exec->hadException());
    13691369
    1370     return throwError(exec, createTypeError(exec, ASCIILiteral("No default value")));
     1370    return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("No default value")));
    13711371}
    13721372
     
    13891389    if (info.implementsHasInstance())
    13901390        return methodTable()->customHasInstance(this, exec, value);
    1391     throwError(exec, createInvalidParameterError(exec, "instanceof" , this));
     1391    exec->vm().throwException(exec, createInvalidParameterError(exec, "instanceof" , this));
    13921392    return false;
    13931393}
     
    13991399
    14001400    if (!proto.isObject()) {
    1401         throwError(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
     1401        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
    14021402        return false;
    14031403    }
     
    24732473        if (!isExtensible()) {
    24742474            if (throwException)
    2475                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
     2475                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
    24762476            return false;
    24772477        }
     
    24912491        if (descriptor.configurable()) {
    24922492            if (throwException)
    2493                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
     2493                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
    24942494            return false;
    24952495        }
    24962496        if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
    24972497            if (throwException)
    2498                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
     2498                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
    24992499            return false;
    25002500        }
     
    25142514        if (!current.configurable()) {
    25152515            if (throwException)
    2516                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
     2516                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
    25172517            return false;
    25182518        }
     
    25262526            if (!current.writable() && descriptor.writable()) {
    25272527                if (throwException)
    2528                     throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
     2528                    exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
    25292529                return false;
    25302530            }
     
    25322532                if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) {
    25332533                    if (throwException)
    2534                         throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
     2534                        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
    25352535                    return false;
    25362536                }
     
    25482548        if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) {
    25492549            if (throwException)
    2550                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
     2550                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
    25512551            return false;
    25522552        }
    25532553        if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) {
    25542554            if (throwException)
    2555                 throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
     2555                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
    25562556            return false;
    25572557        }
     
    26002600JSObject* throwTypeError(ExecState* exec, const String& message)
    26012601{
    2602     return throwError(exec, createTypeError(exec, message));
     2602    return exec->vm().throwException(exec, createTypeError(exec, message));
    26032603}
    26042604
Note: See TracChangeset for help on using the changeset viewer.