Source/JavaScriptCore: https://bugs.webkit.org/show_bug.cgi?id=119548
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 00:28:42 +0000 (00:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Aug 2013 00:28:42 +0000 (00:28 +0000)
Refactoring Exception throws.

Patch by Chris Curtis <chris_curtis@apple.com> 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 <chris_curtis@apple.com> 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 <chris_curtis@apple.com> 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 <chris_curtis@apple.com> 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 <chris_curtis@apple.com> 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154797 268f45cc-cd09-0410-ab3c-d52691b4dbfc

90 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/window-onerror4-expected.txt
LayoutTests/fast/js/exception-properties-expected.txt
LayoutTests/fast/js/global-recursion-on-full-stack-expected.txt
LayoutTests/fast/js/mozilla/resources/js-test-pre.js
LayoutTests/fast/js/script-tests/exception-properties.js
LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event-expected.txt
LayoutTests/fast/xmlhttprequest/xmlhttprequest-recursive-sync-event.html
Source/JavaScriptCore/API/APICallbackFunction.h
Source/JavaScriptCore/API/JSCallbackConstructor.cpp
Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
Source/JavaScriptCore/dfg/DFGAssemblyHelpers.h
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/interpreter/CallFrame.h
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/interpreter/Interpreter.h
Source/JavaScriptCore/jit/JITCode.cpp
Source/JavaScriptCore/jit/JITExceptions.cpp
Source/JavaScriptCore/jit/JITOpcodes.cpp
Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/jit/SlowPathCall.h
Source/JavaScriptCore/jit/ThunkGenerators.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/llint/LLIntExceptions.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
Source/JavaScriptCore/runtime/ArrayConstructor.cpp
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
Source/JavaScriptCore/runtime/CommonSlowPaths.h
Source/JavaScriptCore/runtime/CommonSlowPathsExceptions.cpp
Source/JavaScriptCore/runtime/Completion.cpp
Source/JavaScriptCore/runtime/Error.cpp
Source/JavaScriptCore/runtime/Error.h
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
Source/JavaScriptCore/runtime/Executable.cpp
Source/JavaScriptCore/runtime/FunctionConstructor.cpp
Source/JavaScriptCore/runtime/JSArray.cpp
Source/JavaScriptCore/runtime/JSCJSValue.cpp
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Source/JavaScriptCore/runtime/JSNameScope.cpp
Source/JavaScriptCore/runtime/JSONObject.cpp
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/ObjectConstructor.cpp
Source/JavaScriptCore/runtime/RegExpConstructor.cpp
Source/JavaScriptCore/runtime/StringObject.cpp
Source/JavaScriptCore/runtime/StringRecursionChecker.cpp
Source/JavaScriptCore/runtime/VM.cpp
Source/JavaScriptCore/runtime/VM.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp
Source/WebCore/bindings/js/JSBiquadFilterNodeCustom.cpp
Source/WebCore/bindings/js/JSCryptoCustom.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSIDBDatabaseCustom.cpp
Source/WebCore/bindings/js/JSIDBObjectStoreCustom.cpp
Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp
Source/WebCore/bindings/js/JSNodeFilterCondition.cpp
Source/WebCore/bindings/js/JSOscillatorNodeCustom.cpp
Source/WebCore/bindings/js/JSPannerNodeCustom.cpp
Source/WebCore/bindings/js/JSSVGLengthCustom.cpp
Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
Source/WebCore/bindings/js/ScriptCallStackFactory.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bridge/c/c_instance.cpp
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/bridge/objc/objc_utility.mm
Source/WebCore/bridge/qt/qt_class.cpp
Source/WebCore/bridge/qt/qt_instance.cpp
Source/WebCore/bridge/runtime_array.cpp
Source/WebCore/bridge/runtime_object.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

index 0b3d15a..b2c4e9b 100644 (file)
@@ -1,3 +1,33 @@
+2013-08-28  Chris Curtis  <chris_curtis@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=119548
+        Refactoring Exception throws.
+        
+        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:
+
+
 2013-08-28  Dean Jackson  <dino@apple.com>
 
         [WebGL] CoreGraphics can provide greyscale image data
 2013-08-28  Dean Jackson  <dino@apple.com>
 
         [WebGL] CoreGraphics can provide greyscale image data
index adbfa17..b2ebacd 100644 (file)
@@ -1,4 +1,4 @@
 You should see a log record if window.onerror is working properly for this test.Bug 8519.
 
 You should see a log record if window.onerror is working properly for this test.Bug 8519.
 
-Error caught successfully: ReferenceError: Left side of assignment is not a reference. File: undefined Line: 1 Column: 0
+Error caught successfully: ReferenceError: Left side of assignment is not a reference. File: undefined Line: 1 Column: 3
 
 
index 5d9943a..de0530b 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS enumerableProperties(error) is []
 
 
 PASS enumerableProperties(error) is []
-PASS enumerableProperties(nativeError) is ["stack", "line", "sourceURL"]
+PASS enumerableProperties(nativeError).sort() is ["column", "line", "sourceURL"]
 PASS Object.getPrototypeOf(nativeError).name is "RangeError"
 PASS Object.getPrototypeOf(nativeError).message is ""
 PASS successfullyParsed is true
 PASS Object.getPrototypeOf(nativeError).name is "RangeError"
 PASS Object.getPrototypeOf(nativeError).message is ""
 PASS successfullyParsed is true
index b1d972a..1e37f2c 100644 (file)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
+CONSOLE MESSAGE: line 14: RangeError: Maximum call stack size exceeded.
 This tests global code recursion when the JS stack is full.
 PASS: Entering global code with a full JS stack did not crash, and did not allow continued recursion.
 This tests global code recursion when the JS stack is full.
 PASS: Entering global code with a full JS stack did not crash, and did not allow continued recursion.
index c3d6bfc..f6acf6f 100644 (file)
@@ -272,7 +272,7 @@ function shouldThrowType(_a, _e)
     if (exception instanceof _e)
       testPassed(_a + " threw exception of type " + _e.name + ".");
     else
     if (exception instanceof _e)
       testPassed(_a + " threw exception of type " + _e.name + ".");
     else
-      testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + ".");
+      testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _e) + ". Threw exception " + exception + ".");
   } else
     testFailed(_a + " should throw an instance of " + _e.name);
 }
   } else
     testFailed(_a + " should throw an instance of " + _e.name);
 }
index 43e1153..66bbd28 100644 (file)
@@ -16,7 +16,7 @@ try {
     var error = new Error("message");
 
     shouldBe('enumerableProperties(error)', '[]');
     var error = new Error("message");
 
     shouldBe('enumerableProperties(error)', '[]');
-    shouldBe('enumerableProperties(nativeError)', '["stack", "line", "sourceURL"]');
+    shouldBe('enumerableProperties(nativeError).sort()', '["column", "line", "sourceURL"]');
 
     shouldBe('Object.getPrototypeOf(nativeError).name', '"RangeError"');
     shouldBe('Object.getPrototypeOf(nativeError).message', '""');
 
     shouldBe('Object.getPrototypeOf(nativeError).name', '"RangeError"');
     shouldBe('Object.getPrototypeOf(nativeError).message', '""');
index 0ca195a..913df71 100644 (file)
@@ -1,5 +1,5 @@
-CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
-CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
+CONSOLE MESSAGE: line 95: RangeError: Maximum call stack size exceeded.
+CONSOLE MESSAGE: line 95: RangeError: Maximum call stack size exceeded.
 This tests that having infinite recursion in XMLHttpRequest event handler does not crash. 
 PASS
 
 This tests that having infinite recursion in XMLHttpRequest event handler does not crash. 
 PASS
 
index 1d880b2..753a6ad 100644 (file)
@@ -80,7 +80,7 @@ function log(s)
 // onreadystatechange() frame on the return path.
 
 lastReadyStateObserved = 0;
 // onreadystatechange() frame on the return path.
 
 lastReadyStateObserved = 0;
-hasCompensatedAlready = false;
+isCompensating = false;
 
 function test()
 {
 
 function test()
 {
@@ -91,15 +91,13 @@ function test()
     xhr.onreadystatechange = function() {
         lastReadyStateObserved = xhr.readyState;
         if (xhr.readyState == 4) {
     xhr.onreadystatechange = function() {
         lastReadyStateObserved = xhr.readyState;
         if (xhr.readyState == 4) {
-            xhr.open("GET", "recurse.html", false);
-            xhr.send(null);
-
-            // Compensate for test flakiness if needed:
-            if (!hasCompensatedAlready && lastReadyStateObserved == 1) {
-                xhr.open("GET", "recurse.html", false);
-                xhr.send(null);
-                hasCompensatedAlready = true;
-            }
+            do {
+                xhr.open("GET", "recurse.html", false), xhr.send(null);
+                if (isCompensating)
+                    break;
+                if (lastReadyStateObserved == 1)
+                    isCompensating = true;             
+            } while (isCompensating && lastReadyStateObserved == 1);
         }
     };
     xhr.open("GET", "recurse.html", false);
         }
     };
     xhr.open("GET", "recurse.html", false);
index 909193d..683b638 100644 (file)
@@ -59,7 +59,7 @@ EncodedJSValue JSC_HOST_CALL APICallbackFunction::call(ExecState* exec)
         result = jsCast<T*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
     }
     if (exception)
         result = jsCast<T*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
     }
     if (exception)
-        throwError(exec, toJS(exec, exception));
+        exec->vm().throwException(exec, toJS(exec, exception));
 
     // result must be a valid JSValue.
     if (!result)
 
     // result must be a valid JSValue.
     if (!result)
index cc70bfa..371d583 100644 (file)
@@ -86,7 +86,7 @@ static EncodedJSValue JSC_HOST_CALL constructJSCallback(ExecState* exec)
             result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
         }
         if (exception)
             result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
         }
         if (exception)
-            throwError(exec, toJS(exec, exception));
+            exec->vm().throwException(exec, toJS(exec, exception));
         // result must be a valid JSValue.
         if (!result)
             return throwVMTypeError(exec);
         // result must be a valid JSValue.
         if (!result)
             return throwVMTypeError(exec);
index ab3a91f..d1a89fa 100644 (file)
@@ -150,7 +150,7 @@ bool JSCallbackObject<Parent>::getOwnPropertySlot(JSObject* object, ExecState* e
                     value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception) {
                     value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception) {
-                    throwError(exec, toJS(exec, exception));
+                    exec->vm().throwException(exec, toJS(exec, exception));
                     slot.setValue(thisObject, ReadOnly | DontEnum, jsUndefined());
                     return true;
                 }
                     slot.setValue(thisObject, ReadOnly | DontEnum, jsUndefined());
                     return true;
                 }
@@ -201,7 +201,7 @@ JSValue JSCallbackObject<Parent>::defaultValue(const JSObject* object, ExecState
             JSValueRef exception = 0;
             JSValueRef result = convertToType(ctx, thisRef, jsHint, &exception);
             if (exception) {
             JSValueRef exception = 0;
             JSValueRef result = convertToType(ctx, thisRef, jsHint, &exception);
             if (exception) {
-                throwError(exec, toJS(exec, exception));
+                exec->vm().throwException(exec, toJS(exec, exception));
                 return jsUndefined();
             }
             if (result)
                 return jsUndefined();
             }
             if (result)
@@ -233,7 +233,7 @@ void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName p
                     result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
                 }
                 if (exception)
                     result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
                 }
                 if (exception)
-                    throwError(exec, toJS(exec, exception));
+                    exec->vm().throwException(exec, toJS(exec, exception));
                 if (result || exception)
                     return;
             }
                 if (result || exception)
                     return;
             }
@@ -250,7 +250,7 @@ void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName p
                             result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                         }
                         if (exception)
                             result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                         }
                         if (exception)
-                            throwError(exec, toJS(exec, exception));
+                            exec->vm().throwException(exec, toJS(exec, exception));
                         if (result || exception)
                             return;
                     }
                         if (result || exception)
                             return;
                     }
@@ -292,7 +292,7 @@ void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigne
                 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
             }
             if (exception)
                 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
             }
             if (exception)
-                throwError(exec, toJS(exec, exception));
+                exec->vm().throwException(exec, toJS(exec, exception));
             if (result || exception)
                 return;
         }
             if (result || exception)
                 return;
         }
@@ -309,7 +309,7 @@ void JSCallbackObject<Parent>::putByIndex(JSCell* cell, ExecState* exec, unsigne
                         result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                     }
                     if (exception)
                         result = setProperty(ctx, thisRef, entry->propertyNameRef.get(), valueRef, &exception);
                     }
                     if (exception)
-                        throwError(exec, toJS(exec, exception));
+                        exec->vm().throwException(exec, toJS(exec, exception));
                     if (result || exception)
                         return;
                 }
                     if (result || exception)
                         return;
                 }
@@ -348,7 +348,7 @@ bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, Pro
                     result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception)
                     result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception)
-                    throwError(exec, toJS(exec, exception));
+                    exec->vm().throwException(exec, toJS(exec, exception));
                 if (result || exception)
                     return true;
             }
                 if (result || exception)
                     return true;
             }
@@ -415,7 +415,7 @@ EncodedJSValue JSCallbackObject<Parent>::construct(ExecState* exec)
                 result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
             }
             if (exception)
                 result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
             }
             if (exception)
-                throwError(exec, toJS(exec, exception));
+                exec->vm().throwException(exec, toJS(exec, exception));
             return JSValue::encode(result);
         }
     }
             return JSValue::encode(result);
         }
     }
@@ -441,7 +441,7 @@ bool JSCallbackObject<Parent>::customHasInstance(JSObject* object, ExecState* ex
                 result = hasInstance(execRef, thisRef, valueRef, &exception);
             }
             if (exception)
                 result = hasInstance(execRef, thisRef, valueRef, &exception);
             }
             if (exception)
-                throwError(exec, toJS(exec, exception));
+                exec->vm().throwException(exec, toJS(exec, exception));
             return result;
         }
     }
             return result;
         }
     }
@@ -482,7 +482,7 @@ EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec)
                 result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
             }
             if (exception)
                 result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
             }
             if (exception)
-                throwError(exec, toJS(exec, exception));
+                exec->vm().throwException(exec, toJS(exec, exception));
             return JSValue::encode(result);
         }
     }
             return JSValue::encode(result);
         }
     }
@@ -569,7 +569,7 @@ JSValue JSCallbackObject<Parent>::getStaticValue(ExecState* exec, PropertyName p
                             value = getProperty(toRef(exec), thisRef, entry->propertyNameRef.get(), &exception);
                         }
                         if (exception) {
                             value = getProperty(toRef(exec), thisRef, entry->propertyNameRef.get(), &exception);
                         }
                         if (exception) {
-                            throwError(exec, toJS(exec, exception));
+                            exec->vm().throwException(exec, toJS(exec, exception));
                             return jsUndefined();
                         }
                         if (value)
                             return jsUndefined();
                         }
                         if (value)
@@ -608,7 +608,7 @@ JSValue JSCallbackObject<Parent>::staticFunctionGetter(ExecState* exec, JSValue
         }
     }
 
         }
     }
 
-    return throwError(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback.")));
+    return exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("Static function property defined with NULL callAsFunction callback.")));
 }
 
 template <class Parent>
 }
 
 template <class Parent>
@@ -631,7 +631,7 @@ JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotPa
                     value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception) {
                     value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
                 }
                 if (exception) {
-                    throwError(exec, toJS(exec, exception));
+                    exec->vm().throwException(exec, toJS(exec, exception));
                     return jsUndefined();
                 }
                 if (value)
                     return jsUndefined();
                 }
                 if (value)
@@ -640,7 +640,7 @@ JSValue JSCallbackObject<Parent>::callbackGetter(ExecState* exec, JSValue slotPa
         }
     }
 
         }
     }
 
-    return throwError(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist.")));
+    return exec->vm().throwException(exec, createReferenceError(exec, ASCIILiteral("hasProperty callback returned true for a property that doesn't exist.")));
 }
 
 } // namespace JSC
 }
 
 } // namespace JSC
index 5d845f7..cea0ab6 100644 (file)
@@ -1,3 +1,199 @@
+2013-08-28  Chris Curtis  <chris_curtis@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=119548
+        Refactoring Exception throws.
+        
+        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):
+
 2013-08-28  Zan Dobersek  <zdobersek@igalia.com>
 
         [GTK] Add support for building JSC with FTL JIT enabled
 2013-08-28  Zan Dobersek  <zdobersek@igalia.com>
 
         [GTK] Add support for building JSC with FTL JIT enabled
index 5e00a62..30d0cdb 100644 (file)
@@ -132,15 +132,15 @@ JSValue evaluateInGlobalCallFrame(const String& script, JSValue& exception, JSGl
 
     EvalExecutable* eval = EvalExecutable::create(globalCallFrame, makeSource(script), false);
     if (!eval) {
 
     EvalExecutable* eval = EvalExecutable::create(globalCallFrame, makeSource(script), false);
     if (!eval) {
-        exception = vm.exception;
-        vm.exception = JSValue();
+        exception = vm.exception();
+        vm.clearException();
         return exception;
     }
 
     JSValue result = vm.interpreter->execute(eval, globalCallFrame, globalObject, globalCallFrame->scope());
         return exception;
     }
 
     JSValue result = vm.interpreter->execute(eval, globalCallFrame, globalObject, globalCallFrame->scope());
-    if (vm.exception) {
-        exception = vm.exception;
-        vm.exception = JSValue();
+    if (vm.exception()) {
+        exception = vm.exception();
+        vm.clearException();
     }
     ASSERT(result);
     return result;
     }
     ASSERT(result);
     return result;
index 4617e24..9e4e222 100644 (file)
@@ -92,15 +92,15 @@ JSValue DebuggerCallFrame::evaluate(const String& script, JSValue& exception) co
     
     VM& vm = m_callFrame->vm();
     EvalExecutable* eval = EvalExecutable::create(m_callFrame, makeSource(script), m_callFrame->codeBlock()->isStrictMode());
     
     VM& vm = m_callFrame->vm();
     EvalExecutable* eval = EvalExecutable::create(m_callFrame, makeSource(script), m_callFrame->codeBlock()->isStrictMode());
-    if (vm.exception) {
-        exception = vm.exception;
-        vm.exception = JSValue();
+    if (vm.exception()) {
+        exception = vm.exception();
+        vm.clearException();
     }
 
     JSValue result = vm.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scope());
     }
 
     JSValue result = vm.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scope());
-    if (vm.exception) {
-        exception = vm.exception;
-        vm.exception = JSValue();
+    if (vm.exception()) {
+        exception = vm.exception();
+        vm.clearException();
     }
     ASSERT(result);
     return result;
     }
     ASSERT(result);
     return result;
index 40a241c..7b11002 100644 (file)
@@ -310,9 +310,9 @@ public:
     Jump emitExceptionCheck(ExceptionCheckKind kind = NormalExceptionCheck)
     {
 #if USE(JSVALUE64)
     Jump emitExceptionCheck(ExceptionCheckKind kind = NormalExceptionCheck)
     {
 #if USE(JSVALUE64)
-        return branchTest64(kind == NormalExceptionCheck ? NonZero : Zero, AbsoluteAddress(&vm()->exception));
+    return branchTest64(kind == NormalExceptionCheck ? NonZero : Zero, AbsoluteAddress(vm()->addressOfException()));
 #elif USE(JSVALUE32_64)
 #elif USE(JSVALUE32_64)
-        return branch32(kind == NormalExceptionCheck ? NotEqual : Equal, AbsoluteAddress(reinterpret_cast<char*>(&vm()->exception) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), TrustedImm32(JSValue::EmptyValueTag));
+    return branch32(kind == NormalExceptionCheck ? NotEqual : Equal, AbsoluteAddress(reinterpret_cast<char*>(vm()->addressOfException()) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), TrustedImm32(JSValue::EmptyValueTag));
 #endif
     }
 
 #endif
     }
 
index df37f1b..3312ba1 100644 (file)
@@ -382,7 +382,7 @@ ALWAYS_INLINE static void DFG_OPERATION operationPutByValInternal(ExecState* exe
 
     // Don't put to an object if toString throws an exception.
     Identifier ident(exec, property.toString(exec)->value(exec));
 
     // Don't put to an object if toString throws an exception.
     Identifier ident(exec, property.toString(exec)->value(exec));
-    if (!vm->exception) {
+    if (!vm->exception()) {
         PutPropertySlot slot(strict);
         baseValue.put(exec, ident, value, slot);
     }
         PutPropertySlot slot(strict);
         baseValue.put(exec, ident, value, slot);
     }
@@ -394,7 +394,7 @@ char* newTypedArrayWithSize(ExecState* exec, Structure* structure, int32_t size)
     VM& vm = exec->vm();
     NativeCallFrameTracer tracer(&vm, exec);
     if (size < 0) {
     VM& vm = exec->vm();
     NativeCallFrameTracer tracer(&vm, exec);
     if (size < 0) {
-        throwError(exec, createRangeError(exec, "Requested length is negative"));
+        vm.throwException(exec, createRangeError(exec, "Requested length is negative"));
         return 0;
     }
     return bitwise_cast<char*>(ViewClass::create(exec, structure, size));
         return 0;
     }
     return bitwise_cast<char*>(ViewClass::create(exec, structure, size));
@@ -413,7 +413,7 @@ char* newTypedArrayWithOneArgument(
         RefPtr<ArrayBuffer> buffer = jsBuffer->impl();
         
         if (buffer->byteLength() % ViewClass::elementSize) {
         RefPtr<ArrayBuffer> buffer = jsBuffer->impl();
         
         if (buffer->byteLength() % ViewClass::elementSize) {
-            throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size"));
+            vm.throwException(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size"));
             return 0;
         }
         return bitwise_cast<char*>(
             return 0;
         }
         return bitwise_cast<char*>(
@@ -440,18 +440,18 @@ char* newTypedArrayWithOneArgument(
     if (value.isInt32())
         length = value.asInt32();
     else if (!value.isNumber()) {
     if (value.isInt32())
         length = value.asInt32();
     else if (!value.isNumber()) {
-        throwError(exec, createTypeError(exec, "Invalid array length argument"));
+        vm.throwException(exec, createTypeError(exec, "Invalid array length argument"));
         return 0;
     } else {
         length = static_cast<int>(value.asNumber());
         if (length != value.asNumber()) {
         return 0;
     } else {
         length = static_cast<int>(value.asNumber());
         if (length != value.asNumber()) {
-            throwError(exec, createTypeError(exec, "Invalid array length argument (fractional lengths not allowed)"));
+            vm.throwException(exec, createTypeError(exec, "Invalid array length argument (fractional lengths not allowed)"));
             return 0;
         }
     }
     
     if (length < 0) {
             return 0;
         }
     }
     
     if (length < 0) {
-        throwError(exec, createRangeError(exec, "Requested length is negative"));
+        vm.throwException(exec, createRangeError(exec, "Requested length is negative"));
         return 0;
     }
     
         return 0;
     }
     
@@ -676,7 +676,7 @@ EncodedJSValue DFG_OPERATION operationInOptimizeWithReturnAddress(ExecState* exe
     NativeCallFrameTracer tracer(vm, exec);
     
     if (!base->isObject()) {
     NativeCallFrameTracer tracer(vm, exec);
     
     if (!base->isObject()) {
-        vm->exception = createInvalidParameterError(exec, "in", base);
+        vm->throwException(exec, createInvalidParameterError(exec, "in", base));
         return jsUndefined();
     }
     
         return jsUndefined();
     }
     
@@ -703,7 +703,7 @@ EncodedJSValue DFG_OPERATION operationIn(ExecState* exec, JSCell* base, StringIm
     NativeCallFrameTracer tracer(vm, exec);
 
     if (!base->isObject()) {
     NativeCallFrameTracer tracer(vm, exec);
 
     if (!base->isObject()) {
-        vm->exception = createInvalidParameterError(exec, "in", base);
+        vm->throwException(exec, createInvalidParameterError(exec, "in", base));
         return jsUndefined();
     }
 
         return jsUndefined();
     }
 
@@ -1227,14 +1227,14 @@ static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializ
             NativeCallFrameTracer tracer(vm, execCallee);
             execCallee->setCallee(asObject(callee));
             vm->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
             NativeCallFrameTracer tracer(vm, execCallee);
             execCallee->setCallee(asObject(callee));
             vm->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
-            if (vm->exception)
+            if (vm->exception())
                 return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 
             return reinterpret_cast<void*>(getHostCallReturnValue);
         }
     
         ASSERT(callType == CallTypeNone);
                 return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 
             return reinterpret_cast<void*>(getHostCallReturnValue);
         }
     
         ASSERT(callType == CallTypeNone);
-        exec->vm().exception = createNotAFunctionError(exec, callee);
+        exec->vm().throwException(exec, createNotAFunctionError(exec, callee));
         return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
     }
 
         return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
     }
 
@@ -1249,14 +1249,14 @@ static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializ
         NativeCallFrameTracer tracer(vm, execCallee);
         execCallee->setCallee(asObject(callee));
         vm->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
         NativeCallFrameTracer tracer(vm, execCallee);
         execCallee->setCallee(asObject(callee));
         vm->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
-        if (vm->exception)
+        if (vm->exception())
             return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 
         return reinterpret_cast<void*>(getHostCallReturnValue);
     }
     
     ASSERT(constructType == ConstructTypeNone);
             return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 
         return reinterpret_cast<void*>(getHostCallReturnValue);
     }
     
     ASSERT(constructType == ConstructTypeNone);
-    exec->vm().exception = createNotAConstructorError(exec, callee);
+    exec->vm().throwException(exec, createNotAConstructorError(exec, callee));
     return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 }
 
     return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
 }
 
@@ -1283,7 +1283,7 @@ inline char* linkFor(ExecState* execCallee, CodeSpecializationKind kind)
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
         if (error) {
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         JSObject* error = functionExecutable->compileFor(execCallee, callee->scope(), kind);
         if (error) {
-            vm->exception = createStackOverflowError(exec);
+            vm->throwException(exec, createStackOverflowError(exec));
             return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
         }
         codeBlock = &functionExecutable->generatedBytecodeFor(kind);
             return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
         }
         codeBlock = &functionExecutable->generatedBytecodeFor(kind);
@@ -1328,7 +1328,7 @@ inline char* virtualForWithFunction(ExecState* execCallee, CodeSpecializationKin
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         JSObject* error = functionExecutable->compileFor(execCallee, function->scope(), kind);
         if (error) {
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         JSObject* error = functionExecutable->compileFor(execCallee, function->scope(), kind);
         if (error) {
-            exec->vm().exception = error;
+            exec->vm().throwException(execCallee, error);
             return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
         }
     }
             return reinterpret_cast<char*>(vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress());
         }
     }
@@ -1425,7 +1425,7 @@ char* DFG_OPERATION operationNewArrayWithSize(ExecState* exec, Structure* arrayS
     NativeCallFrameTracer tracer(vm, exec);
 
     if (UNLIKELY(size < 0))
     NativeCallFrameTracer tracer(vm, exec);
 
     if (UNLIKELY(size < 0))
-        return bitwise_cast<char*>(throwError(exec, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer."))));
+        return bitwise_cast<char*>(exec->vm().throwException(exec, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer."))));
 
     return bitwise_cast<char*>(JSArray::create(*vm, arrayStructure, size));
 }
 
     return bitwise_cast<char*>(JSArray::create(*vm, arrayStructure, size));
 }
@@ -1551,7 +1551,7 @@ EncodedJSValue DFG_OPERATION operationNewRegexp(ExecState* exec, void* regexpPtr
     NativeCallFrameTracer tracer(&vm, exec);
     RegExp* regexp = static_cast<RegExp*>(regexpPtr);
     if (!regexp->isValid()) {
     NativeCallFrameTracer tracer(&vm, exec);
     RegExp* regexp = static_cast<RegExp*>(regexpPtr);
     if (!regexp->isValid()) {
-        throwError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
+        exec->vm().throwException(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
         return JSValue::encode(jsUndefined());
     }
     
         return JSValue::encode(jsUndefined());
     }
     
@@ -1574,7 +1574,7 @@ JSCell* DFG_OPERATION operationCreateArguments(ExecState* exec)
     // NB: This needs to be exceedingly careful with top call frame tracking, since it
     // may be called from OSR exit, while the state of the call stack is bizarre.
     Arguments* result = Arguments::create(vm, exec);
     // NB: This needs to be exceedingly careful with top call frame tracking, since it
     // may be called from OSR exit, while the state of the call stack is bizarre.
     Arguments* result = Arguments::create(vm, exec);
-    ASSERT(!vm.exception);
+    ASSERT(!vm.exception());
     return result;
 }
 
     return result;
 }
 
@@ -1586,7 +1586,7 @@ JSCell* DFG_OPERATION operationCreateInlinedArguments(
     // NB: This needs to be exceedingly careful with top call frame tracking, since it
     // may be called from OSR exit, while the state of the call stack is bizarre.
     Arguments* result = Arguments::create(vm, exec, inlineCallFrame);
     // NB: This needs to be exceedingly careful with top call frame tracking, since it
     // may be called from OSR exit, while the state of the call stack is bizarre.
     Arguments* result = Arguments::create(vm, exec, inlineCallFrame);
-    ASSERT(!vm.exception);
+    ASSERT(!vm.exception());
     return result;
 }
 
     return result;
 }
 
index 1692c6f..7fa2f6a 100644 (file)
@@ -2386,7 +2386,7 @@ private:
         LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("Exception check continuation"));
         
         m_out.branch(
         LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("Exception check continuation"));
         
         m_out.branch(
-            m_out.notZero64(m_out.load64(m_out.absolute(&vm().exception))),
+            m_out.notZero64(m_out.load64(m_out.absolute(&vm().exception()))),
             didHaveException, continuation);
         
         LBasicBlock lastNext = m_out.appendTo(didHaveException, continuation);
             didHaveException, continuation);
         
         LBasicBlock lastNext = m_out.appendTo(didHaveException, continuation);
index 2ed9517..a40a488 100644 (file)
@@ -534,10 +534,10 @@ void Heap::markRoots()
                 visitor.donateAndDrain();
             }
         }
                 visitor.donateAndDrain();
             }
         }
-        if (m_vm->exception) {
+        if (m_vm->exception()) {
             GCPHASE(MarkingException);
             MARK_LOG_ROOT(visitor, "Exceptions");
             GCPHASE(MarkingException);
             MARK_LOG_ROOT(visitor, "Exceptions");
-            heapRootVisitor.visit(&m_vm->exception);
+            heapRootVisitor.visit(m_vm->addressOfException());
             visitor.donateAndDrain();
         }
     
             visitor.donateAndDrain();
         }
     
index b27bcbe..c11d9d1 100644 (file)
@@ -68,14 +68,14 @@ namespace JSC  {
         // pointer, so these are inefficient, and should be used sparingly in new code.
         // But they're used in many places in legacy code, so they're not going away any time soon.
 
         // pointer, so these are inefficient, and should be used sparingly in new code.
         // But they're used in many places in legacy code, so they're not going away any time soon.
 
-        void clearException() { vm().exception = JSValue(); }
+        void clearException() { vm().clearException(); }
         void clearSupplementaryExceptionInfo()
         {
             vm().clearExceptionStack();
         }
 
         void clearSupplementaryExceptionInfo()
         {
             vm().clearExceptionStack();
         }
 
-        JSValue exception() const { return vm().exception; }
-        bool hadException() const { return vm().exception; }
+        JSValue exception() const { return vm().exception(); }
+        bool hadException() const { return vm().exception(); }
 
         const CommonIdentifiers& propertyNames() const { return *vm().propertyNames; }
         const MarkedArgumentBuffer& emptyList() const { return *vm().emptyList; }
 
         const CommonIdentifiers& propertyNames() const { return *vm().propertyNames; }
         const MarkedArgumentBuffer& emptyList() const { return *vm().emptyList; }
index cc007d3..59f8e50 100644 (file)
@@ -136,7 +136,7 @@ JSValue eval(CallFrame* callFrame)
         }
         
         // If the literal parser bailed, it should not have thrown exceptions.
         }
         
         // If the literal parser bailed, it should not have thrown exceptions.
-        ASSERT(!callFrame->vm().exception);
+        ASSERT(!callFrame->vm().exception());
 
         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock->ownerExecutable(), callerCodeBlock->isStrictMode(), programSource, callerScopeChain);
         if (!eval)
 
         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock->ownerExecutable(), callerCodeBlock->isStrictMode(), programSource, callerScopeChain);
         if (!eval)
@@ -154,7 +154,7 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
         unsigned argumentCountIncludingThis = callFrame->argumentCountIncludingThis();
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argumentCountIncludingThis + JSStack::CallFrameHeaderSize);
         if (argumentCountIncludingThis > Arguments::MaxArguments + 1 || !stack->grow(newCallFrame->registers())) {
         unsigned argumentCountIncludingThis = callFrame->argumentCountIncludingThis();
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + argumentCountIncludingThis + JSStack::CallFrameHeaderSize);
         if (argumentCountIncludingThis > Arguments::MaxArguments + 1 || !stack->grow(newCallFrame->registers())) {
-            callFrame->vm().exception = createStackOverflowError(callFrame);
+            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
             return 0;
         }
 
             return 0;
         }
 
@@ -168,7 +168,7 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
     if (arguments.isUndefinedOrNull()) {
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + 1 + JSStack::CallFrameHeaderSize);
         if (!stack->grow(newCallFrame->registers())) {
     if (arguments.isUndefinedOrNull()) {
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + 1 + JSStack::CallFrameHeaderSize);
         if (!stack->grow(newCallFrame->registers())) {
-            callFrame->vm().exception = createStackOverflowError(callFrame);
+            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(1);
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(1);
@@ -177,7 +177,7 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
     }
 
     if (!arguments.isObject()) {
     }
 
     if (!arguments.isObject()) {
-        callFrame->vm().exception = createInvalidParameterError(callFrame, "Function.prototype.apply", arguments);
+        callFrame->vm().throwException(callFrame, createInvalidParameterError(callFrame, "Function.prototype.apply", arguments));
         return 0;
     }
 
         return 0;
     }
 
@@ -186,7 +186,7 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
         unsigned argCount = argsObject->length(callFrame);
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
         if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
         unsigned argCount = argsObject->length(callFrame);
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
         if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
-            callFrame->vm().exception = createStackOverflowError(callFrame);
+            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
@@ -200,7 +200,7 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
         unsigned argCount = array->length();
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
         if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
         unsigned argCount = array->length();
         CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
         if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
-            callFrame->vm().exception = createStackOverflowError(callFrame);
+            callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
             return 0;
         }
         newCallFrame->setArgumentCountIncludingThis(argCount + 1);
@@ -213,14 +213,14 @@ CallFrame* loadVarargs(CallFrame* callFrame, JSStack* stack, JSValue thisValue,
     unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
     CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
     if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
     unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
     CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister + CallFrame::offsetFor(argCount + 1));
     if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
-        callFrame->vm().exception = createStackOverflowError(callFrame);
+        callFrame->vm().throwException(callFrame,  createStackOverflowError(callFrame));
         return 0;
     }
     newCallFrame->setArgumentCountIncludingThis(argCount + 1);
     newCallFrame->setThisValue(thisValue);
     for (size_t i = 0; i < argCount; ++i) {
         newCallFrame->setArgument(i, asObject(arguments)->get(callFrame, i));
         return 0;
     }
     newCallFrame->setArgumentCountIncludingThis(argCount + 1);
     newCallFrame->setThisValue(thisValue);
     for (size_t i = 0; i < argCount; ++i) {
         newCallFrame->setArgument(i, asObject(arguments)->get(callFrame, i));
-        if (UNLIKELY(callFrame->vm().exception))
+        if (UNLIKELY(callFrame->vm().exception()))
             return 0;
     }
     return newCallFrame;
             return 0;
     }
     return newCallFrame;
@@ -402,60 +402,6 @@ NEVER_INLINE bool Interpreter::unwindCallFrame(StackIterator& iter, JSValue exce
     return !callerFrame->hasHostCallFrameFlag();
 }
 
     return !callerFrame->hasHostCallFrameFlag();
 }
 
-static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception, unsigned bytecodeOffset)
-{
-    exception->clearAppendSourceToMessage();
-
-    if (!callFrame->codeBlock()->hasExpressionInfo())
-        return;
-
-    int startOffset = 0;
-    int endOffset = 0;
-    int divotPoint = 0;
-    unsigned line = 0;
-    unsigned column = 0;
-
-    CodeBlock* codeBlock = callFrame->codeBlock();
-    codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset, line, column);
-
-    int expressionStart = divotPoint - startOffset;
-    int expressionStop = divotPoint + endOffset;
-
-    const String& sourceString = codeBlock->source()->source();
-    if (!expressionStop || expressionStart > static_cast<int>(sourceString.length()))
-        return;
-
-    VM* vm = &callFrame->vm();
-    JSValue jsMessage = exception->getDirect(*vm, vm->propertyNames->message);
-    if (!jsMessage || !jsMessage.isString())
-        return;
-
-    String message = asString(jsMessage)->value(callFrame);
-
-    if (expressionStart < expressionStop)
-        message =  makeString(message, " (evaluating '", codeBlock->source()->getRange(expressionStart, expressionStop), "')");
-    else {
-        // No range information, so give a few characters of context
-        const StringImpl* data = sourceString.impl();
-        int dataLength = sourceString.length();
-        int start = expressionStart;
-        int stop = expressionStart;
-        // Get up to 20 characters of context to the left and right of the divot, clamping to the line.
-        // then strip whitespace.
-        while (start > 0 && (expressionStart - start < 20) && (*data)[start - 1] != '\n')
-            start--;
-        while (start < (expressionStart - 1) && isStrWhiteSpace((*data)[start]))
-            start++;
-        while (stop < dataLength && (stop - expressionStart < 20) && (*data)[stop] != '\n')
-            stop++;
-        while (stop > expressionStart && isStrWhiteSpace((*data)[stop - 1]))
-            stop--;
-        message = makeString(message, " (near '...", codeBlock->source()->getRange(start, stop), "...')");
-    }
-
-    exception->putDirect(*vm, vm->propertyNames->message, jsString(vm, message));
-}
-
 static ALWAYS_INLINE const String getSourceURLFromCallFrame(CallFrame* callFrame)
 {
     ASSERT(!callFrame->hasHostCallFrameFlag());
 static ALWAYS_INLINE const String getSourceURLFromCallFrame(CallFrame* callFrame)
 {
     ASSERT(!callFrame->hasHostCallFrameFlag());
@@ -569,26 +515,8 @@ JSString* Interpreter:: stackTraceAsString(ExecState* exec, Vector<StackFrame> s
     }
     return jsString(&exec->vm(), builder.toString());
 }
     }
     return jsString(&exec->vm(), builder.toString());
 }
-    
-void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSValue error)
-{
-    VM* vm = &callFrame->vm();
-    ASSERT(callFrame == vm->topCallFrame || callFrame == callFrame->lexicalGlobalObject()->globalExec() || callFrame == callFrame->dynamicGlobalObject()->globalExec());
-
-    Vector<StackFrame> stackTrace;
-    vm->interpreter->getStackTrace(stackTrace);
-    vm->exceptionStack() = RefCountedArray<StackFrame>(stackTrace);
-    if (stackTrace.isEmpty() || !error.isObject())
-        return;
-
-    if (asObject(error)->hasProperty(callFrame, vm->propertyNames->stack))
-        return;
-    
-    asObject(error)->putDirect(*vm, vm->propertyNames->stack, vm->interpreter->stackTraceAsString(vm->topCallFrame, stackTrace), None);
-
-}
 
 
-NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset)
+NEVER_INLINE HandlerInfo* Interpreter::unwind(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset)
 {
     CodeBlock* codeBlock = callFrame->codeBlock();
     bool isTermination = false;
 {
     CodeBlock* codeBlock = callFrame->codeBlock();
     bool isTermination = false;
@@ -600,29 +528,18 @@ NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSV
     if (exceptionValue.isEmpty() || (exceptionValue.isCell() && !exceptionValue.asCell()))
         exceptionValue = jsNull();
 
     if (exceptionValue.isEmpty() || (exceptionValue.isCell() && !exceptionValue.asCell()))
         exceptionValue = jsNull();
 
-    // Set up the exception object
     if (exceptionValue.isObject()) {
     if (exceptionValue.isObject()) {
-        JSObject* exception = asObject(exceptionValue);
-
-        if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->appendSourceToMessage())
-            appendSourceToError(callFrame, static_cast<ErrorInstance*>(exception), bytecodeOffset);
-
-        if (!hasErrorInfo(callFrame, exception)) {
-            // FIXME: should only really be adding these properties to VM generated exceptions,
-            // but the inspector currently requires these for all thrown objects.
-            addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source());
-        }
-
-        isTermination = isTerminatedExecutionException(exception);
-    } else {
-        if (!callFrame->vm().exceptionStack().size()) {
-            Vector<StackFrame> stack;
-            callFrame->vm().interpreter->getStackTrace(stack);
-            callFrame->vm().exceptionStack() = RefCountedArray<StackFrame>(stack);
-        }
+        isTermination = isTerminatedExecutionException(asObject(exceptionValue));
     }
 
     }
 
+    ASSERT(callFrame->vm().exceptionStack().size());
+    ASSERT(!exceptionValue.isObject() || asObject(exceptionValue)->hasProperty(callFrame, callFrame->vm().propertyNames->stack));
+
     if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
     if (Debugger* debugger = callFrame->dynamicGlobalObject()->debugger()) {
+        // We need to clear the exception and the exception stack here in order to see if a new exception happens.
+        // Afterwards, the values are put back to continue processing this error.
+        ClearExceptionScope scope(&callFrame->vm());
+        
         DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
         bool hasHandler = codeBlock->handlerForBytecodeOffset(bytecodeOffset);
         debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), 0, hasHandler);
         DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
         bool hasHandler = codeBlock->handlerForBytecodeOffset(bytecodeOffset);
         debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), 0, hasHandler);
@@ -700,7 +617,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, J
     JSScope* scope = callFrame->scope();
     VM& vm = *scope->vm();
 
     JSScope* scope = callFrame->scope();
     VM& vm = *scope->vm();
 
-    ASSERT(!vm.exception);
+    ASSERT(!vm.exception());
     ASSERT(!vm.isCollectorBusy());
     if (vm.isCollectorBusy())
         return jsNull();
     ASSERT(!vm.isCollectorBusy());
     if (vm.isCollectorBusy())
         return jsNull();
@@ -750,7 +667,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, J
                         PropertySlot slot(globalObject);
                         if (!globalObject->getPropertySlot(callFrame, JSONPPath[i].m_pathEntryName, slot)) {
                             if (entry)
                         PropertySlot slot(globalObject);
                         if (!globalObject->getPropertySlot(callFrame, JSONPPath[i].m_pathEntryName, slot)) {
                             if (entry)
-                                return throwError(callFrame, createUndefinedVariableError(globalObject->globalExec(), JSONPPath[i].m_pathEntryName));
+                                return callFrame->vm().throwException(callFrame, createUndefinedVariableError(globalObject->globalExec(), JSONPPath[i].m_pathEntryName));
                             goto failedJSONP;
                         }
                         baseObject = slot.getValue(callFrame, JSONPPath[i].m_pathEntryName);
                             goto failedJSONP;
                         }
                         baseObject = slot.getValue(callFrame, JSONPPath[i].m_pathEntryName);
@@ -780,7 +697,7 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, J
                 CallData callData;
                 CallType callType = getCallData(function, callData);
                 if (callType == CallTypeNone)
                 CallData callData;
                 CallType callType = getCallData(function, callData);
                 if (callType == CallTypeNone)
-                    return throwError(callFrame, createNotAFunctionError(callFrame, function));
+                    return callFrame->vm().throwException(callFrame, createNotAFunctionError(callFrame, function));
                 MarkedArgumentBuffer jsonArg;
                 jsonArg.append(JSONPValue);
                 JSValue thisValue = JSONPPath.size() == 1 ? jsUndefined(): baseObject;
                 MarkedArgumentBuffer jsonArg;
                 jsonArg.append(JSONPValue);
                 JSValue thisValue = JSONPPath.size() == 1 ? jsUndefined(): baseObject;
@@ -815,10 +732,10 @@ failedJSONP:
 
     // Compile source to bytecode if necessary:
     if (JSObject* error = program->initializeGlobalProperties(vm, callFrame, scope))
 
     // Compile source to bytecode if necessary:
     if (JSObject* error = program->initializeGlobalProperties(vm, callFrame, scope))
-        return checkedReturn(throwError(callFrame, error));
+        return checkedReturn(callFrame->vm().throwException(callFrame, error));
 
     if (JSObject* error = program->compile(callFrame, scope))
 
     if (JSObject* error = program->compile(callFrame, scope))
-        return checkedReturn(throwError(callFrame, error));
+        return checkedReturn(callFrame->vm().throwException(callFrame, error));
 
     ProgramCodeBlock* codeBlock = &program->generatedBytecode();
 
 
     ProgramCodeBlock* codeBlock = &program->generatedBytecode();
 
@@ -888,7 +805,7 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT
         // Compile the callee:
         JSObject* compileError = callData.js.functionExecutable->compileForCall(callFrame, scope);
         if (UNLIKELY(!!compileError)) {
         // Compile the callee:
         JSObject* compileError = callData.js.functionExecutable->compileForCall(callFrame, scope);
         if (UNLIKELY(!!compileError)) {
-            return checkedReturn(throwError(callFrame, compileError));
+            return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
         }
         newCodeBlock = &callData.js.functionExecutable->generatedBytecodeForCall();
         ASSERT(!!newCodeBlock);
         }
         newCodeBlock = &callData.js.functionExecutable->generatedBytecodeForCall();
         ASSERT(!!newCodeBlock);
@@ -967,7 +884,7 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
         // Compile the callee:
         JSObject* compileError = constructData.js.functionExecutable->compileForConstruct(callFrame, scope);
         if (UNLIKELY(!!compileError)) {
         // Compile the callee:
         JSObject* compileError = constructData.js.functionExecutable->compileForConstruct(callFrame, scope);
         if (UNLIKELY(!!compileError)) {
-            return checkedReturn(throwError(callFrame, compileError));
+            return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
         }
         newCodeBlock = &constructData.js.functionExecutable->generatedBytecodeForConstruct();
         ASSERT(!!newCodeBlock);
         }
         newCodeBlock = &constructData.js.functionExecutable->generatedBytecodeForConstruct();
         ASSERT(!!newCodeBlock);
@@ -1026,7 +943,7 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc
 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, int argumentCountIncludingThis, JSScope* scope)
 {
     VM& vm = *scope->vm();
 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, JSFunction* function, int argumentCountIncludingThis, JSScope* scope)
 {
     VM& vm = *scope->vm();
-    ASSERT(!vm.exception);
+    ASSERT(!vm.exception());
     
     if (vm.isCollectorBusy())
         return CallFrameClosure();
     
     if (vm.isCollectorBusy())
         return CallFrameClosure();
@@ -1041,7 +958,7 @@ CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionE
     // Compile the callee:
     JSObject* error = functionExecutable->compileForCall(callFrame, scope);
     if (error) {
     // Compile the callee:
     JSObject* error = functionExecutable->compileForCall(callFrame, scope);
     if (error) {
-        throwError(callFrame, error);
+        callFrame->vm().throwException(callFrame, error);
         return CallFrameClosure();
     }
     CodeBlock* newCodeBlock = &functionExecutable->generatedBytecodeForCall();
         return CallFrameClosure();
     }
     CodeBlock* newCodeBlock = &functionExecutable->generatedBytecodeForCall();
@@ -1126,7 +1043,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
     SamplingScope samplingScope(this);
     
     ASSERT(scope->vm() == &callFrame->vm());
     SamplingScope samplingScope(this);
     
     ASSERT(scope->vm() == &callFrame->vm());
-    ASSERT(!vm.exception);
+    ASSERT(!vm.exception());
     ASSERT(!vm.isCollectorBusy());
     if (vm.isCollectorBusy())
         return jsNull();
     ASSERT(!vm.isCollectorBusy());
     if (vm.isCollectorBusy())
         return jsNull();
@@ -1157,7 +1074,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
 
     JSObject* compileError = eval->compile(callFrame, scope);
     if (UNLIKELY(!!compileError))
 
     JSObject* compileError = eval->compile(callFrame, scope);
     if (UNLIKELY(!!compileError))
-        return checkedReturn(throwError(callFrame, compileError));
+        return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
     EvalCodeBlock* codeBlock = &eval->generatedBytecode();
 
     if (numVariables || numFunctions) {
     EvalCodeBlock* codeBlock = &eval->generatedBytecode();
 
     if (numVariables || numFunctions) {
index f8862c5..44ad941 100644 (file)
@@ -38,6 +38,7 @@
 #include "JSStack.h"
 #include "LLIntData.h"
 #include "Opcode.h"
 #include "JSStack.h"
 #include "LLIntData.h"
 #include "Opcode.h"
+#include "SourceProvider.h"
 
 #include <wtf/HashMap.h>
 #include <wtf/text/StringBuilder.h>
 
 #include <wtf/HashMap.h>
 #include <wtf/text/StringBuilder.h>
@@ -133,6 +134,23 @@ namespace JSC {
         void expressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column);
     };
 
         void expressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column);
     };
 
+    class ClearExceptionScope {
+    public:
+        ClearExceptionScope(VM* vm): m_vm(vm)
+        {
+            vm->getExceptionInfo(oldException, oldExceptionStack);
+            vm->clearException();
+        }
+        ~ClearExceptionScope()
+        {
+            m_vm->setExceptionInfo(oldException, oldExceptionStack);
+        }
+    private:
+        JSC::JSValue oldException;
+        RefCountedArray<JSC::StackFrame> oldExceptionStack;
+        VM* m_vm;
+    };
+    
     class TopCallFrameSetter {
     public:
         TopCallFrameSetter(VM& currentVM, CallFrame* callFrame)
     class TopCallFrameSetter {
     public:
         TopCallFrameSetter(VM& currentVM, CallFrame* callFrame)
@@ -169,6 +187,7 @@ namespace JSC {
         friend class CachedCall;
         friend class LLIntOffsetsExtractor;
         friend class JIT;
         friend class CachedCall;
         friend class LLIntOffsetsExtractor;
         friend class JIT;
+        friend class VM;
 
     public:
         class ErrorHandlingMode {
 
     public:
         class ErrorHandlingMode {
@@ -220,9 +239,8 @@ namespace JSC {
 
         bool isInErrorHandlingMode() { return m_errorHandlingModeReentry; }
 
 
         bool isInErrorHandlingMode() { return m_errorHandlingModeReentry; }
 
-        NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset);
+        NEVER_INLINE HandlerInfo* unwind(CallFrame*&, JSValue&, unsigned bytecodeOffset);
         NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column);
         NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column);
-        static void addStackTraceIfNecessary(CallFrame*, JSValue error);
         JSString* stackTraceAsString(ExecState*, Vector<StackFrame>);
 
         static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState*);
         JSString* stackTraceAsString(ExecState*, Vector<StackFrame>);
 
         static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState*);
index 450e2d2..d111110 100644 (file)
@@ -44,7 +44,7 @@ JITCode::~JITCode()
 JSValue JITCode::execute(JSStack* stack, CallFrame* callFrame, VM* vm)
 {
     JSValue result = JSValue::decode(ctiTrampoline(executableAddress(), stack, callFrame, 0, 0, vm));
 JSValue JITCode::execute(JSStack* stack, CallFrame* callFrame, VM* vm)
 {
     JSValue result = JSValue::decode(ctiTrampoline(executableAddress(), stack, callFrame, 0, 0, vm));
-    return vm->exception ? jsNull() : result;
+    return vm->exception() ? jsNull() : result;
 }
 #endif
 
 }
 #endif
 
index 30fbcda..6952f16 100644 (file)
@@ -70,10 +70,7 @@ ExceptionHandler uncaughtExceptionHandler()
 ExceptionHandler genericThrow(VM* vm, ExecState* callFrame, JSValue exceptionValue, unsigned vPCIndex)
 {
     RELEASE_ASSERT(exceptionValue);
 ExceptionHandler genericThrow(VM* vm, ExecState* callFrame, JSValue exceptionValue, unsigned vPCIndex)
 {
     RELEASE_ASSERT(exceptionValue);
-    
-    vm->exception = JSValue();
-    HandlerInfo* handler = vm->interpreter->throwException(callFrame, exceptionValue, vPCIndex); // This may update callFrame & exceptionValue!
-    vm->exception = exceptionValue;
+    HandlerInfo* handler = vm->interpreter->unwind(callFrame, exceptionValue, vPCIndex); // This may update callFrame.
 
     void* catchRoutine;
     Instruction* catchPCForInterpreter = 0;
 
     void* catchRoutine;
     Instruction* catchPCForInterpreter = 0;
index 929b9a7..e2a6119 100644 (file)
@@ -680,8 +680,8 @@ void JIT::emit_op_catch(Instruction* currentInstruction)
     killLastResultRegister(); // FIXME: Implicitly treat op_catch as a labeled statement, and remove this line of code.
     move(regT0, callFrameRegister);
     peek(regT3, OBJECT_OFFSETOF(struct JITStackFrame, vm) / sizeof(void*));
     killLastResultRegister(); // FIXME: Implicitly treat op_catch as a labeled statement, and remove this line of code.
     move(regT0, callFrameRegister);
     peek(regT3, OBJECT_OFFSETOF(struct JITStackFrame, vm) / sizeof(void*));
-    load64(Address(regT3, OBJECT_OFFSETOF(VM, exception)), regT0);
-    store64(TrustedImm64(JSValue::encode(JSValue())), Address(regT3, OBJECT_OFFSETOF(VM, exception)));
+    load64(Address(regT3, VM::exceptionOffset()), regT0);
+    store64(TrustedImm64(JSValue::encode(JSValue())), Address(regT3, VM::exceptionOffset()));
     emitPutVirtualRegister(currentInstruction[1].u.operand);
 }
 
     emitPutVirtualRegister(currentInstruction[1].u.operand);
 }
 
index 051ead9..88e143a 100644 (file)
@@ -155,7 +155,7 @@ JIT::CodeRef JIT::privateCompileCTINativeCall(VM* vm, NativeFunction func)
 #endif // CPU(X86)
 
     // Check for an exception
 #endif // CPU(X86)
 
     // Check for an exception
-    Jump sawException = branch32(NotEqual, AbsoluteAddress(reinterpret_cast<char*>(&vm->exception) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), TrustedImm32(JSValue::EmptyValueTag));
+    Jump sawException = branch32(NotEqual, AbsoluteAddress(reinterpret_cast<char*>(vm->addressOfException()) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), TrustedImm32(JSValue::EmptyValueTag)); 
 
     // Return.
     ret();
 
     // Return.
     ret();
@@ -1002,10 +1002,10 @@ void JIT::emit_op_catch(Instruction* currentInstruction)
 
     // Now store the exception returned by cti_op_throw.
     loadPtr(Address(stackPointerRegister, OBJECT_OFFSETOF(struct JITStackFrame, vm)), regT3);
 
     // Now store the exception returned by cti_op_throw.
     loadPtr(Address(stackPointerRegister, OBJECT_OFFSETOF(struct JITStackFrame, vm)), regT3);
-    load32(Address(regT3, OBJECT_OFFSETOF(VM, exception) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT0);
-    load32(Address(regT3, OBJECT_OFFSETOF(VM, exception) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), regT1);
-    store32(TrustedImm32(JSValue().payload()), Address(regT3, OBJECT_OFFSETOF(VM, exception) + OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
-    store32(TrustedImm32(JSValue().tag()), Address(regT3, OBJECT_OFFSETOF(VM, exception) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
+    load32(Address(regT3, VM::exceptionOffset() + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT0);
+    load32(Address(regT3, VM::exceptionOffset() + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), regT1);
+    store32(TrustedImm32(JSValue().payload()), Address(regT3, VM::exceptionOffset() + OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
+    store32(TrustedImm32(JSValue().tag()), Address(regT3, VM::exceptionOffset() + OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
 
     unsigned exception = currentInstruction[1].u.operand;
     emitStore(exception, regT1, regT0);
 
     unsigned exception = currentInstruction[1].u.operand;
     emitStore(exception, regT1, regT0);
index 9af691b..9f94163 100644 (file)
@@ -44,6 +44,7 @@
 #include "DFGWorklist.h"
 #include "Debugger.h"
 #include "DeferGC.h"
 #include "DFGWorklist.h"
 #include "Debugger.h"
 #include "DeferGC.h"
+#include "ErrorInstance.h"
 #include "ExceptionHelpers.h"
 #include "GetterSetter.h"
 #include "Heap.h"
 #include "ExceptionHelpers.h"
 #include "GetterSetter.h"
 #include "Heap.h"
@@ -324,7 +325,7 @@ struct StackHack {
 // handling code out of line as possible.
 static NEVER_INLINE void returnToThrowTrampoline(VM* vm, ReturnAddressPtr exceptionLocation, ReturnAddressPtr& returnAddressSlot)
 {
 // handling code out of line as possible.
 static NEVER_INLINE void returnToThrowTrampoline(VM* vm, ReturnAddressPtr exceptionLocation, ReturnAddressPtr& returnAddressSlot)
 {
-    RELEASE_ASSERT(vm->exception);
+    RELEASE_ASSERT(vm->exception());
     vm->exceptionLocation = exceptionLocation;
     returnAddressSlot = ReturnAddressPtr(FunctionPtr(ctiVMThrowTrampoline));
 }
     vm->exceptionLocation = exceptionLocation;
     returnAddressSlot = ReturnAddressPtr(FunctionPtr(ctiVMThrowTrampoline));
 }
@@ -341,17 +342,17 @@ static NEVER_INLINE void returnToThrowTrampoline(VM* vm, ReturnAddressPtr except
 
 #define CHECK_FOR_EXCEPTION() \
     do { \
 
 #define CHECK_FOR_EXCEPTION() \
     do { \
-        if (UNLIKELY(stackFrame.vm->exception)) \
+        if (UNLIKELY(stackFrame.vm->exception())) \
             VM_THROW_EXCEPTION(); \
     } while (0)
 #define CHECK_FOR_EXCEPTION_AT_END() \
     do { \
             VM_THROW_EXCEPTION(); \
     } while (0)
 #define CHECK_FOR_EXCEPTION_AT_END() \
     do { \
-        if (UNLIKELY(stackFrame.vm->exception)) \
+        if (UNLIKELY(stackFrame.vm->exception())) \
             VM_THROW_EXCEPTION_AT_END(); \
     } while (0)
 #define CHECK_FOR_EXCEPTION_VOID() \
     do { \
             VM_THROW_EXCEPTION_AT_END(); \
     } while (0)
 #define CHECK_FOR_EXCEPTION_VOID() \
     do { \
-        if (UNLIKELY(stackFrame.vm->exception)) { \
+        if (UNLIKELY(stackFrame.vm->exception())) { \
             VM_THROW_EXCEPTION_AT_END(); \
             return; \
         } \
             VM_THROW_EXCEPTION_AT_END(); \
             return; \
         } \
@@ -397,43 +398,21 @@ private:
     JSValue m_callee;
 };
 
     JSValue m_callee;
 };
 
-class ErrorWithExceptionFunctor : public ErrorFunctor {
-    public:
-    ErrorWithExceptionFunctor(JSValue exception)
-        : m_exception(exception)
-    {
-    }
-    JSValue operator()(ExecState*)
-    {
-    return m_exception;
-    }
-
-private:
-    JSValue m_exception;
-};
-
 // Helper function for JIT stubs that may throw an exception in the middle of
 // processing a function call. This function rolls back the stack to
 // our caller, so exception processing can proceed from a valid state.
 // Helper function for JIT stubs that may throw an exception in the middle of
 // processing a function call. This function rolls back the stack to
 // our caller, so exception processing can proceed from a valid state.
-template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot, ErrorFunctor& createError )
+template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot, ErrorFunctor* createError = 0)
 {
     CallFrame* callFrame = newCallFrame->callerFrame()->removeHostCallFrameFlag();
     jitStackFrame.callFrame = callFrame;
     callFrame->vm().topCallFrame = callFrame;
 {
     CallFrame* callFrame = newCallFrame->callerFrame()->removeHostCallFrameFlag();
     jitStackFrame.callFrame = callFrame;
     callFrame->vm().topCallFrame = callFrame;
-    callFrame->vm().exception = createError(callFrame);
-    ASSERT(callFrame->vm().exception);
+    if (createError)
+        callFrame->vm().throwException(callFrame, (*createError)(callFrame));
+    ASSERT(callFrame->vm().exception());
     returnToThrowTrampoline(&callFrame->vm(), ReturnAddressPtr(newCallFrame->returnPC()), returnAddressSlot);
     return T();
 }
 
     returnToThrowTrampoline(&callFrame->vm(), ReturnAddressPtr(newCallFrame->returnPC()), returnAddressSlot);
     return T();
 }
 
-template<typename T> static T throwExceptionFromOpCall(JITStackFrame& jitStackFrame, CallFrame* newCallFrame, ReturnAddressPtr& returnAddressSlot)
-{
-    CallFrame* callFrame = newCallFrame->callerFrame();
-    ASSERT(callFrame->vm().exception);
-    ErrorWithExceptionFunctor functor = ErrorWithExceptionFunctor(callFrame->vm().exception);
-    return throwExceptionFromOpCall<T>(jitStackFrame, newCallFrame, returnAddressSlot, functor);
-}
-
 // If the CPU specific header does not provide an implementation, use the default one here.
 #ifndef DEFINE_STUB_FUNCTION
 #define DEFINE_STUB_FUNCTION(rtype, op) rtype JIT_STUB cti_##op(STUB_ARGS_DECLARATION)
 // If the CPU specific header does not provide an implementation, use the default one here.
 #ifndef DEFINE_STUB_FUNCTION
 #define DEFINE_STUB_FUNCTION(rtype, op) rtype JIT_STUB cti_##op(STUB_ARGS_DECLARATION)
@@ -445,7 +424,7 @@ DEFINE_STUB_FUNCTION(void, handle_watchdog_timer)
     CallFrame* callFrame = stackFrame.callFrame;
     VM* vm = stackFrame.vm;
     if (UNLIKELY(vm->watchdog.didFire(callFrame))) {
     CallFrame* callFrame = stackFrame.callFrame;
     VM* vm = stackFrame.vm;
     if (UNLIKELY(vm->watchdog.didFire(callFrame))) {
-        vm->exception = createTerminatedExecutionException(vm);
+        vm->throwException(callFrame, createTerminatedExecutionException(vm));
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
@@ -458,7 +437,7 @@ DEFINE_STUB_FUNCTION(void*, stack_check)
 
     if (UNLIKELY(!stackFrame.stack->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
 
     if (UNLIKELY(!stackFrame.stack->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
-        return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);
+        return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     }
 
     return callFrame;
     }
 
     return callFrame;
@@ -894,7 +873,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_check_has_instance)
         }
     }
 
         }
     }
 
-    stackFrame.vm->exception = createInvalidParameterError(callFrame, "instanceof", baseVal);
+    stackFrame.vm->throwException(callFrame, createInvalidParameterError(callFrame, "instanceof", baseVal));
     VM_THROW_EXCEPTION_AT_END();
     return JSValue::encode(JSValue());
 }
     VM_THROW_EXCEPTION_AT_END();
     return JSValue::encode(JSValue());
 }
@@ -1152,7 +1131,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_del_by_id)
     bool couldDelete = baseObj->methodTable()->deleteProperty(baseObj, callFrame, stackFrame.args[1].identifier());
     JSValue result = jsBoolean(couldDelete);
     if (!couldDelete && callFrame->codeBlock()->isStrictMode())
     bool couldDelete = baseObj->methodTable()->deleteProperty(baseObj, callFrame, stackFrame.args[1].identifier());
     JSValue result = jsBoolean(couldDelete);
     if (!couldDelete && callFrame->codeBlock()->isStrictMode())
-        stackFrame.vm->exception = createTypeError(stackFrame.callFrame, "Unable to delete property.");
+        stackFrame.vm->throwException(stackFrame.callFrame, createTypeError(stackFrame.callFrame, "Unable to delete property."));
 
     CHECK_FOR_EXCEPTION_AT_END();
     return JSValue::encode(result);
 
     CHECK_FOR_EXCEPTION_AT_END();
     return JSValue::encode(result);
@@ -1192,7 +1171,7 @@ inline void* jitCompileFor(CallFrame* callFrame, CodeSpecializationKind kind)
     JSObject* error = executable->compileFor(callFrame, callDataScopeChain, kind);
     if (!error)
         return function;
     JSObject* error = executable->compileFor(callFrame, callDataScopeChain, kind);
     if (!error)
         return function;
-    callFrame->vm().exception = error;
+    callFrame->vm().throwException(callFrame, error);
     return 0;
 }
 
     return 0;
 }
 
@@ -1239,7 +1218,7 @@ DEFINE_STUB_FUNCTION(int, op_call_arityCheck)
     int missingArgCount = CommonSlowPaths::arityCheckFor(callFrame, stackFrame.stack, CodeForCall);
     if (missingArgCount < 0) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
     int missingArgCount = CommonSlowPaths::arityCheckFor(callFrame, stackFrame.stack, CodeForCall);
     if (missingArgCount < 0) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
-        return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);
+        return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     }
     return missingArgCount;
 }
     }
     return missingArgCount;
 }
@@ -1253,7 +1232,7 @@ DEFINE_STUB_FUNCTION(int, op_construct_arityCheck)
     int missingArgCount = CommonSlowPaths::arityCheckFor(callFrame, stackFrame.stack, CodeForConstruct);
     if (missingArgCount < 0) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
     int missingArgCount = CommonSlowPaths::arityCheckFor(callFrame, stackFrame.stack, CodeForConstruct);
     if (missingArgCount < 0) {
         ErrorWithExecFunctor functor = ErrorWithExecFunctor(createStackOverflowError);
-        return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);
+        return throwExceptionFromOpCall<int>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     }
     return missingArgCount;
 }
     }
     return missingArgCount;
 }
@@ -1289,7 +1268,7 @@ inline void* lazyLinkFor(CallFrame* callFrame, CodeSpecializationKind kind)
     else {
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         if (JSObject* error = functionExecutable->compileFor(callFrame, callee->scope(), kind)) {
     else {
         FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);
         if (JSObject* error = functionExecutable->compileFor(callFrame, callee->scope(), kind)) {
-            callFrame->vm().exception = error;
+            callFrame->vm().throwException(callFrame, error);
             return 0;
         }
         codeBlock = &functionExecutable->generatedBytecodeFor(kind);
             return 0;
         }
         codeBlock = &functionExecutable->generatedBytecodeFor(kind);
@@ -1367,7 +1346,7 @@ DEFINE_STUB_FUNCTION(void*, vm_lazyLinkClosureCall)
         JSScope* scopeChain = callee->scope();
         JSObject* error = functionExecutable->compileFor(callFrame, scopeChain, CodeForCall);
         if (error) {
         JSScope* scopeChain = callee->scope();
         JSObject* error = functionExecutable->compileFor(callFrame, scopeChain, CodeForCall);
         if (error) {
-            callFrame->vm().exception = error;
+            callFrame->vm().throwException(callFrame, error);
             return 0;
         }
         
             return 0;
         }
         
@@ -1421,7 +1400,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)
     if (callType != CallTypeHost) {
         ASSERT(callType == CallTypeNone);
         ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAFunctionError, callee);
     if (callType != CallTypeHost) {
         ASSERT(callType == CallTypeNone);
         ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAFunctionError, callee);
-        return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);
+        return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     }
 
     EncodedJSValue returnValue;
     }
 
     EncodedJSValue returnValue;
@@ -1430,7 +1409,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)
         returnValue = callData.native.function(callFrame);
     }
 
         returnValue = callData.native.function(callFrame);
     }
 
-    if (stackFrame.vm->exception)
+    if (stackFrame.vm->exception())
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return returnValue;
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return returnValue;
@@ -1517,7 +1496,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct)
     if (constructType != ConstructTypeHost) {
         ASSERT(constructType == ConstructTypeNone);
         ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAConstructorError, callee);
     if (constructType != ConstructTypeHost) {
         ASSERT(constructType == ConstructTypeNone);
         ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAConstructorError, callee);
-        return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, functor);
+        return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);
     }
 
     EncodedJSValue returnValue;
     }
 
     EncodedJSValue returnValue;
@@ -1526,7 +1505,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct)
         returnValue = constructData.native.function(callFrame);
     }
 
         returnValue = constructData.native.function(callFrame);
     }
 
-    if (stackFrame.vm->exception)
+    if (stackFrame.vm->exception())
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return returnValue;
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return returnValue;
@@ -1666,7 +1645,7 @@ static void putByVal(CallFrame* callFrame, JSValue baseValue, JSValue subscript,
         baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
     } else {
         Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
         baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
     } else {
         Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
-        if (!callFrame->vm().exception) { // Don't put to an object if toString threw an exception.
+        if (!callFrame->vm().exception()) { // Don't put to an object if toString threw an exception.
             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
             baseValue.put(callFrame, property, value, slot);
         }
             PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
             baseValue.put(callFrame, property, value, slot);
         }
@@ -1952,7 +1931,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_regexp)
 
     RegExp* regExp = stackFrame.args[0].regExp();
     if (!regExp->isValid()) {
 
     RegExp* regExp = stackFrame.args[0].regExp();
     if (!regExp->isValid()) {
-        stackFrame.vm->exception = createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor.");
+        stackFrame.vm->throwException(callFrame, createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor."));
         VM_THROW_EXCEPTION();
     }
 
         VM_THROW_EXCEPTION();
     }
 
@@ -1977,7 +1956,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)
         return JSValue::encode(JSValue());
 
     JSValue result = eval(callFrame);
         return JSValue::encode(JSValue());
 
     JSValue result = eval(callFrame);
-    if (stackFrame.vm->exception)
+    if (stackFrame.vm->exception())
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return JSValue::encode(result);
         return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);
 
     return JSValue::encode(result);
@@ -1986,6 +1965,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)
 DEFINE_STUB_FUNCTION(void*, op_throw)
 {
     STUB_INIT_STACK_FRAME(stackFrame);
 DEFINE_STUB_FUNCTION(void*, op_throw)
 {
     STUB_INIT_STACK_FRAME(stackFrame);
+    stackFrame.vm->throwException(stackFrame.callFrame, stackFrame.args[0].jsValue()); 
     ExceptionHandler handler = jitThrow(stackFrame.vm, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS);
     STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
     return handler.callFrame;
     ExceptionHandler handler = jitThrow(stackFrame.vm, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS);
     STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
     return handler.callFrame;
@@ -2141,9 +2121,9 @@ DEFINE_STUB_FUNCTION(void, op_throw_static_error)
     CallFrame* callFrame = stackFrame.callFrame;
     String message = errorDescriptionForValue(callFrame, stackFrame.args[0].jsValue())->value(callFrame);
     if (stackFrame.args[1].asInt32)
     CallFrame* callFrame = stackFrame.callFrame;
     String message = errorDescriptionForValue(callFrame, stackFrame.args[0].jsValue())->value(callFrame);
     if (stackFrame.args[1].asInt32)
-        stackFrame.vm->exception = createReferenceError(callFrame, message);
+        stackFrame.vm->throwException(callFrame, createReferenceError(callFrame, message));
     else
     else
-        stackFrame.vm->exception = createTypeError(callFrame, message);
+        stackFrame.vm->throwException(callFrame, createTypeError(callFrame, message));
     VM_THROW_EXCEPTION_AT_END();
 }
 
     VM_THROW_EXCEPTION_AT_END();
 }
 
@@ -2165,7 +2145,7 @@ DEFINE_STUB_FUNCTION(void*, vm_throw)
 {
     STUB_INIT_STACK_FRAME(stackFrame);
     VM* vm = stackFrame.vm;
 {
     STUB_INIT_STACK_FRAME(stackFrame);
     VM* vm = stackFrame.vm;
-    ExceptionHandler handler = jitThrow(vm, stackFrame.callFrame, vm->exception, vm->exceptionLocation);
+    ExceptionHandler handler = jitThrow(vm, stackFrame.callFrame, vm->exception(), vm->exceptionLocation);
     STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
     return handler.callFrame;
 }
     STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
     return handler.callFrame;
 }
@@ -2181,7 +2161,7 @@ EncodedExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
 
     VM* vm = callFrame->codeBlock()->vm();
     vm->topCallFrame = callFrame;
 
     VM* vm = callFrame->codeBlock()->vm();
     vm->topCallFrame = callFrame;
-    return encode(jitThrowNew(vm, callFrame, vm->exception));
+    return encode(jitThrowNew(vm, callFrame, vm->exception()));
 }
 #else
 ExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
 }
 #else
 ExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
@@ -2194,7 +2174,7 @@ ExceptionHandler JIT_STUB cti_vm_handle_exception(CallFrame* callFrame)
 
     VM* vm = callFrame->codeBlock()->vm();
     vm->topCallFrame = callFrame;
 
     VM* vm = callFrame->codeBlock()->vm();
     vm->topCallFrame = callFrame;
-    return jitThrowNew(vm, callFrame, vm->exception);
+    return jitThrowNew(vm, callFrame, vm->exception());
 }
 #endif
 
 }
 #endif
 
@@ -2229,7 +2209,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_from_scope)
     PropertySlot slot(scope);
     if (!scope->getPropertySlot(exec, ident, slot)) {
         if (modeAndType.mode() == ThrowIfNotFound) {
     PropertySlot slot(scope);
     if (!scope->getPropertySlot(exec, ident, slot)) {
         if (modeAndType.mode() == ThrowIfNotFound) {
-            throwError(exec, createUndefinedVariableError(exec, ident));
+            exec->vm().throwException(exec, createUndefinedVariableError(exec, ident));
             VM_THROW_EXCEPTION();
         }
         return JSValue::encode(jsUndefined());
             VM_THROW_EXCEPTION();
         }
         return JSValue::encode(jsUndefined());
@@ -2261,7 +2241,7 @@ DEFINE_STUB_FUNCTION(void, op_put_to_scope)
     ResolveModeAndType modeAndType = ResolveModeAndType(pc[4].u.operand);
 
     if (modeAndType.mode() == ThrowIfNotFound && !scope->hasProperty(exec, ident)) {
     ResolveModeAndType modeAndType = ResolveModeAndType(pc[4].u.operand);
 
     if (modeAndType.mode() == ThrowIfNotFound && !scope->hasProperty(exec, ident)) {
-        throwError(exec, createUndefinedVariableError(exec, ident));
+        exec->vm().throwException(exec, createUndefinedVariableError(exec, ident));
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
@@ -2269,7 +2249,7 @@ DEFINE_STUB_FUNCTION(void, op_put_to_scope)
     PutPropertySlot slot(codeBlock->isStrictMode());
     scope->methodTable()->put(scope, exec, ident, value, slot);
     
     PutPropertySlot slot(codeBlock->isStrictMode());
     scope->methodTable()->put(scope, exec, ident, value, slot);
     
-    if (exec->vm().exception) {
+    if (exec->vm().exception()) {
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
         VM_THROW_EXCEPTION_AT_END();
         return;
     }
index d382e53..93ab094 100644 (file)
@@ -84,9 +84,9 @@ public:
 #endif
         
 #if USE(JSVALUE32_64)
 #endif
         
 #if USE(JSVALUE32_64)
-        JIT::Jump noException = m_jit->branch32(JIT::Equal, JIT::AbsoluteAddress(reinterpret_cast<char*>(&m_jit->m_codeBlock->vm()->exception) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), JIT::TrustedImm32(JSValue::EmptyValueTag));
+        JIT::Jump noException = m_jit->branch32(JIT::Equal, JIT::AbsoluteAddress(reinterpret_cast<char*>(m_jit->m_codeBlock->vm()->addressOfException()) + OBJECT_OFFSETOF(JSValue, u.asBits.tag)), JIT::TrustedImm32(JSValue::EmptyValueTag));
 #else
 #else
-        JIT::Jump noException = m_jit->branchTest64(JIT::Zero, JIT::AbsoluteAddress(&m_jit->m_codeBlock->vm()->exception));
+        JIT::Jump noException = m_jit->branchTest64(JIT::Zero, JIT::AbsoluteAddress(m_jit->m_codeBlock->vm()->addressOfException()));
 #endif
         m_jit->reloadCallFrameFromTopCallFrame();
         m_jit->move(JIT::TrustedImmPtr(FunctionPtr(ctiVMHandleException).value()), JIT::regT1);
 #endif
         m_jit->reloadCallFrameFromTopCallFrame();
         m_jit->move(JIT::TrustedImmPtr(FunctionPtr(ctiVMHandleException).value()), JIT::regT1);
index 58f23b2..615089c 100644 (file)
@@ -379,12 +379,12 @@ static MacroAssemblerCodeRef nativeForGenerator(VM* vm, CodeSpecializationKind k
 
     // Check for an exception
 #if USE(JSVALUE64)
 
     // Check for an exception
 #if USE(JSVALUE64)
-    jit.load64(&(vm->exception), JSInterfaceJIT::regT2);
+    jit.load64(vm->addressOfException(), JSInterfaceJIT::regT2);
     JSInterfaceJIT::Jump exceptionHandler = jit.branchTest64(JSInterfaceJIT::NonZero, JSInterfaceJIT::regT2);
 #else
     JSInterfaceJIT::Jump exceptionHandler = jit.branch32(
         JSInterfaceJIT::NotEqual,
     JSInterfaceJIT::Jump exceptionHandler = jit.branchTest64(JSInterfaceJIT::NonZero, JSInterfaceJIT::regT2);
 #else
     JSInterfaceJIT::Jump exceptionHandler = jit.branch32(
         JSInterfaceJIT::NotEqual,
-        JSInterfaceJIT::AbsoluteAddress(reinterpret_cast<char*>(&vm->exception) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)),
+        JSInterfaceJIT::AbsoluteAddress(reinterpret_cast<char*>(vm->addressOfException()) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag)),
         JSInterfaceJIT::TrustedImm32(JSValue::EmptyValueTag));
 #endif
 
         JSInterfaceJIT::TrustedImm32(JSValue::EmptyValueTag));
 #endif
 
index 403eda7..0653875 100644 (file)
@@ -366,7 +366,7 @@ EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
-        return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
+        return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file.")));
 
     GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>());
 
 
     GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>());
 
@@ -377,7 +377,7 @@ EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec)
     stopWatch.stop();
 
     if (!!exception) {
     stopWatch.stop();
 
     if (!!exception) {
-        throwError(globalObject->globalExec(), exception);
+        exec->vm().throwException(globalObject->globalExec(), exception);
         return JSValue::encode(jsUndefined());
     }
     
         return JSValue::encode(jsUndefined());
     }
     
@@ -389,14 +389,14 @@ EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec)
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
-        return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
+        return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file.")));
 
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     
     JSValue evaluationException;
     JSValue result = evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), &evaluationException);
     if (evaluationException)
 
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     
     JSValue evaluationException;
     JSValue result = evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), &evaluationException);
     if (evaluationException)
-        throwError(exec, evaluationException);
+        exec->vm().throwException(exec, evaluationException);
     return JSValue::encode(result);
 }
 
     return JSValue::encode(result);
 }
 
@@ -405,7 +405,7 @@ EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
     String fileName = exec->argument(0).toString(exec)->value(exec);
     Vector<char> script;
     if (!fillBufferWithContentsOfFile(fileName, script))
-        return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
+        return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file.")));
 
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
 
 
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
 
@@ -417,7 +417,7 @@ EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)
     stopWatch.stop();
 
     if (!validSyntax)
     stopWatch.stop();
 
     if (!validSyntax)
-        throwError(exec, syntaxException);
+        exec->vm().throwException(exec, syntaxException);
     return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
 }
 
     return JSValue::encode(jsNumber(stopWatch.getElapsedMS()));
 }
 
index 66952f6..2273124 100644 (file)
@@ -48,14 +48,14 @@ static void doThrow(ExecState* exec, Instruction* pc)
 {
     VM* vm = &exec->vm();
     NativeCallFrameTracer tracer(vm, exec);
 {
     VM* vm = &exec->vm();
     NativeCallFrameTracer tracer(vm, exec);
-    genericThrow(vm, exec, vm->exception, pc - exec->codeBlock()->instructions().begin());
+    genericThrow(vm, exec, vm->exception(), pc - exec->codeBlock()->instructions().begin());
 }
 
 Instruction* returnToThrow(ExecState* exec, Instruction* pc)
 {
 #if LLINT_SLOW_PATH_TRACING
     VM* vm = &exec->vm();
 }
 
 Instruction* returnToThrow(ExecState* exec, Instruction* pc)
 {
 #if LLINT_SLOW_PATH_TRACING
     VM* vm = &exec->vm();
-    dataLog("Throwing exception ", vm->exception, " (returnToThrow).\n");
+    dataLog("Throwing exception ", vm->exception(), " (returnToThrow).\n");
 #endif
     doThrow(exec, pc);
     return LLInt::exceptionInstructions();
 #endif
     doThrow(exec, pc);
     return LLInt::exceptionInstructions();
@@ -65,7 +65,7 @@ void* callToThrow(ExecState* exec, Instruction* pc)
 {
 #if LLINT_SLOW_PATH_TRACING
     VM* vm = &exec->vm();
 {
 #if LLINT_SLOW_PATH_TRACING
     VM* vm = &exec->vm();
-    dataLog("Throwing exception ", vm->exception, " (callToThrow).\n");
+    dataLog("Throwing exception ", vm->exception(), " (callToThrow).\n");
 #endif
     doThrow(exec, pc);
     return LLInt::getCodePtr(llint_throw_during_call_trampoline);
 #endif
     doThrow(exec, pc);
     return LLInt::getCodePtr(llint_throw_during_call_trampoline);
index d6d0675..0fd3054 100644 (file)
@@ -84,13 +84,13 @@ namespace JSC { namespace LLInt {
 #define LLINT_END_IMPL() LLINT_RETURN_TWO(pc, exec)
 
 #define LLINT_THROW(exceptionToThrow) do {                        \
 #define LLINT_END_IMPL() LLINT_RETURN_TWO(pc, exec)
 
 #define LLINT_THROW(exceptionToThrow) do {                        \
-        vm.exception = (exceptionToThrow);                \
+        vm.throwException(exec, exceptionToThrow);             \
         pc = returnToThrow(exec, pc);                             \
         LLINT_END_IMPL();                                         \
     } while (false)
 
 #define LLINT_CHECK_EXCEPTION() do {                    \
         pc = returnToThrow(exec, pc);                             \
         LLINT_END_IMPL();                                         \
     } while (false)
 
 #define LLINT_CHECK_EXCEPTION() do {                    \
-        if (UNLIKELY(vm.exception)) {           \
+        if (UNLIKELY(vm.exception())) {           \
             pc = returnToThrow(exec, pc);               \
             LLINT_END_IMPL();                           \
         }                                               \
             pc = returnToThrow(exec, pc);               \
             LLINT_END_IMPL();                           \
         }                                               \
@@ -144,14 +144,14 @@ namespace JSC { namespace LLInt {
 #define LLINT_CALL_THROW(exec, pc, exceptionToThrow) do {               \
         ExecState* __ct_exec = (exec);                                  \
         Instruction* __ct_pc = (pc);                                    \
 #define LLINT_CALL_THROW(exec, pc, exceptionToThrow) do {               \
         ExecState* __ct_exec = (exec);                                  \
         Instruction* __ct_pc = (pc);                                    \
-        vm.exception = (exceptionToThrow);                      \
+        vm.throwException(__ct_exec, exceptionToThrow);                     \
         LLINT_CALL_END_IMPL(__ct_exec, callToThrow(__ct_exec, __ct_pc)); \
     } while (false)
 
 #define LLINT_CALL_CHECK_EXCEPTION(exec, pc) do {                       \
         ExecState* __cce_exec = (exec);                                 \
         Instruction* __cce_pc = (pc);                                   \
         LLINT_CALL_END_IMPL(__ct_exec, callToThrow(__ct_exec, __ct_pc)); \
     } while (false)
 
 #define LLINT_CALL_CHECK_EXCEPTION(exec, pc) do {                       \
         ExecState* __cce_exec = (exec);                                 \
         Instruction* __cce_pc = (pc);                                   \
-        if (UNLIKELY(vm.exception))                              \
+        if (UNLIKELY(vm.exception()))                                     \
             LLINT_CALL_END_IMPL(__cce_exec, callToThrow(__cce_exec, __cce_pc)); \
     } while (false)
 
             LLINT_CALL_END_IMPL(__cce_exec, callToThrow(__cce_exec, __cce_pc)); \
     } while (false)
 
@@ -422,7 +422,7 @@ LLINT_SLOW_PATH_DECL(stack_check)
     if (UNLIKELY(!vm.interpreter->stack().grow(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters]))) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
     if (UNLIKELY(!vm.interpreter->stack().grow(&exec->registers()[exec->codeBlock()->m_numCalleeRegisters]))) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
-        vm.exception = createStackOverflowError(exec);
+        vm.throwException(exec, createStackOverflowError(exec));
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         pc = returnToThrowForThrownException(exec);
     }
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         pc = returnToThrowForThrownException(exec);
     }
@@ -1261,7 +1261,7 @@ LLINT_SLOW_PATH_DECL(slow_path_profile_did_call)
 LLINT_SLOW_PATH_DECL(throw_from_native_call)
 {
     LLINT_BEGIN();
 LLINT_SLOW_PATH_DECL(throw_from_native_call)
 {
     LLINT_BEGIN();
-    ASSERT(vm.exception);
+    ASSERT(vm.exception());
     LLINT_END();
 }
 
     LLINT_END();
 }
 
@@ -1282,7 +1282,7 @@ LLINT_SLOW_PATH_DECL(slow_path_get_from_scope)
     PropertySlot slot(scope);
     if (!scope->getPropertySlot(exec, ident, slot)) {
         if (modeAndType.mode() == ThrowIfNotFound)
     PropertySlot slot(scope);
     if (!scope->getPropertySlot(exec, ident, slot)) {
         if (modeAndType.mode() == ThrowIfNotFound)
-            LLINT_RETURN(throwError(exec, createUndefinedVariableError(exec, ident)));
+            LLINT_RETURN(exec->vm().throwException(exec, createUndefinedVariableError(exec, ident)));
         LLINT_RETURN(jsUndefined());
     }
 
         LLINT_RETURN(jsUndefined());
     }
 
index ac150ec..f60b059 100644 (file)
@@ -436,7 +436,7 @@ JSValue CLoop::execute(CallFrame* callFrame, OpcodeID bootstrapOpcodeId,
 
         OFFLINE_ASM_GLUE_LABEL(ctiOpThrowNotCaught)
         {
 
         OFFLINE_ASM_GLUE_LABEL(ctiOpThrowNotCaught)
         {
-            return vm->exception;
+            return vm->exception();
         }
 
 #if !ENABLE(COMPUTED_GOTO_OPCODES)
         }
 
 #if !ENABLE(COMPUTED_GOTO_OPCODES)
index 75cbcd6..d14ad47 100644 (file)
@@ -1720,10 +1720,10 @@ _llint_op_catch:
     move t0, cfr
     loadp JITStackFrame::vm[sp], t3
     loadi VM::targetInterpreterPCForThrow[t3], PC
     move t0, cfr
     loadp JITStackFrame::vm[sp], t3
     loadi VM::targetInterpreterPCForThrow[t3], PC
-    loadi VM::exception + PayloadOffset[t3], t0
-    loadi VM::exception + TagOffset[t3], t1
-    storei 0, VM::exception + PayloadOffset[t3]
-    storei EmptyValueTag, VM::exception + TagOffset[t3]       
+    loadi VM::m_exception + PayloadOffset[t3], t0
+    loadi VM::m_exception + TagOffset[t3], t1
+    storei 0, VM::m_exception + PayloadOffset[t3]
+    storei EmptyValueTag, VM::m_exception + TagOffset[t3]
     loadi 4[PC], t2
     storei t0, PayloadOffset[cfr, t2, 8]
     storei t1, TagOffset[cfr, t2, 8]
     loadi 4[PC], t2
     storei t0, PayloadOffset[cfr, t2, 8]
     storei t1, TagOffset[cfr, t2, 8]
@@ -1855,7 +1855,7 @@ macro nativeCallTrampoline(executableOffsetToFunction)
     else  
         error
     end
     else  
         error
     end
-    bineq VM::exception + TagOffset[t3], EmptyValueTag, .exception
+    bineq VM::m_exception + TagOffset[t3], EmptyValueTag, .exception
     ret
 .exception:
     preserveReturnAddressAfterCall(t1) # This is really only needed on X86
     ret
 .exception:
     preserveReturnAddressAfterCall(t1) # This is really only needed on X86
index f322170..72b936c 100644 (file)
@@ -1572,8 +1572,8 @@ _llint_op_catch:
     loadp VM::targetInterpreterPCForThrow[t3], PC
     subp PB, PC
     rshiftp 3, PC
     loadp VM::targetInterpreterPCForThrow[t3], PC
     subp PB, PC
     rshiftp 3, PC
-    loadq VM::exception[t3], t0
-    storeq 0, VM::exception[t3]
+    loadq VM::m_exception[t3], t0
+    storeq 0, VM::m_exception[t3]
     loadisFromInstruction(1, t2)
     storeq t0, [cfr, t2, 8]
     traceExecution()
     loadisFromInstruction(1, t2)
     storeq t0, [cfr, t2, 8]
     traceExecution()
@@ -1649,7 +1649,7 @@ macro nativeCallTrampoline(executableOffsetToFunction)
         error
     end
 
         error
     end
 
-    btqnz VM::exception[t3], .exception
+    btqnz VM::m_exception[t3], .exception
     ret
 .exception:
     preserveReturnAddressAfterCall(t1)
     ret
 .exception:
     preserveReturnAddressAfterCall(t1)
index 7b6864d..87a8f0e 100644 (file)
@@ -80,7 +80,7 @@ JSObject* constructArrayWithSizeQuirk(ExecState* exec, ArrayAllocationProfile* p
     
     uint32_t n = length.toUInt32(exec);
     if (n != length.toNumber(exec))
     
     uint32_t n = length.toUInt32(exec);
     if (n != length.toNumber(exec))
-        return throwError(exec, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
+        return exec->vm().throwException(exec, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer.")));
     return constructEmptyArray(exec, profile, globalObject, n);
 }
 
     return constructEmptyArray(exec, profile, globalObject, n);
 }
 
index 201d4de..90e7619 100644 (file)
@@ -91,13 +91,13 @@ namespace JSC {
 #define END_IMPL() RETURN_TWO(pc, exec)
 
 #define THROW(exceptionToThrow) do {                        \
 #define END_IMPL() RETURN_TWO(pc, exec)
 
 #define THROW(exceptionToThrow) do {                        \
-        vm.exception = (exceptionToThrow);                \
-        RETURN_TO_THROW(exec, pc);                             \
+        vm.throwException(exec, exceptionToThrow);          \
+        RETURN_TO_THROW(exec, pc);                          \
         END_IMPL();                                         \
     } while (false)
 
 #define CHECK_EXCEPTION() do {                    \
         END_IMPL();                                         \
     } while (false)
 
 #define CHECK_EXCEPTION() do {                    \
-        if (UNLIKELY(vm.exception)) {           \
+        if (UNLIKELY(vm.exception())) {           \
             RETURN_TO_THROW(exec, pc);               \
             END_IMPL();                           \
         }                                               \
             RETURN_TO_THROW(exec, pc);               \
             END_IMPL();                           \
         }                                               \
@@ -151,14 +151,14 @@ namespace JSC {
 #define CALL_THROW(exec, pc, exceptionToThrow) do {               \
         ExecState* ctExec = (exec);                                  \
         Instruction* ctPC = (pc);                                    \
 #define CALL_THROW(exec, pc, exceptionToThrow) do {               \
         ExecState* ctExec = (exec);                                  \
         Instruction* ctPC = (pc);                                    \
-        vm.exception = (exceptionToThrow);                      \
+        vm.throwException(exec, exceptionToThrow);                      \
         CALL_END_IMPL(ctExec, LLInt::callToThrow(ctExec, ctPC)); \
     } while (false)
 
 #define CALL_CHECK_EXCEPTION(exec, pc) do {                       \
         ExecState* cceExec = (exec);                                 \
         Instruction* ccePC = (pc);                                   \
         CALL_END_IMPL(ctExec, LLInt::callToThrow(ctExec, ctPC)); \
     } while (false)
 
 #define CALL_CHECK_EXCEPTION(exec, pc) do {                       \
         ExecState* cceExec = (exec);                                 \
         Instruction* ccePC = (pc);                                   \
-        if (UNLIKELY(vm.exception))                              \
+        if (UNLIKELY(vm.exception()))                              \
             CALL_END_IMPL(cceExec, LLInt::callToThrow(cceExec, ccePC)); \
     } while (false)
 
             CALL_END_IMPL(cceExec, LLInt::callToThrow(cceExec, ccePC)); \
     } while (false)
 
@@ -177,7 +177,7 @@ SLOW_PATH_DECL(slow_path_call_arityCheck)
     if (SlotsToAdd < 0) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
     if (SlotsToAdd < 0) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
-        vm.exception = createStackOverflowError(exec);
+        vm.throwException(exec, createStackOverflowError(exec));
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
     }
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
     }
@@ -191,7 +191,7 @@ SLOW_PATH_DECL(slow_path_construct_arityCheck)
     if (SlotsToAdd < 0) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
     if (SlotsToAdd < 0) {
         ReturnAddressPtr returnPC = exec->returnPC();
         exec = exec->callerFrame();
-        vm.exception = createStackOverflowError(exec);
+        vm.throwException(exec, createStackOverflowError(exec));
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
     }
         CommonSlowPaths::interpreterThrowInCaller(exec, returnPC);
         RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
     }
index 4a4452c..2665aa3 100644 (file)
@@ -66,7 +66,7 @@ ALWAYS_INLINE int arityCheckFor(ExecState* exec, JSStack* stack, CodeSpecializat
 inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal)
 {
     if (!baseVal.isObject()) {
 inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal)
 {
     if (!baseVal.isObject()) {
-        exec->vm().exception = createInvalidParameterError(exec, "in", baseVal);
+        exec->vm().throwException(exec, createInvalidParameterError(exec, "in", baseVal));
         return false;
     }
 
         return false;
     }
 
@@ -80,7 +80,7 @@ inline bool opIn(ExecState* exec, JSValue propName, JSValue baseVal)
         return baseObj->hasProperty(exec, jsCast<NameInstance*>(propName.asCell())->privateName());
 
     Identifier property(exec, propName.toString(exec)->value(exec));
         return baseObj->hasProperty(exec, jsCast<NameInstance*>(propName.asCell())->privateName());
 
     Identifier property(exec, propName.toString(exec)->value(exec));
-    if (exec->vm().exception)
+    if (exec->vm().exception())
         return false;
     return baseObj->hasProperty(exec, property);
 }
         return false;
     return baseObj->hasProperty(exec, property);
 }
index 8eadecd..c4cbc66 100644 (file)
@@ -38,10 +38,10 @@ void interpreterThrowInCaller(ExecState* exec, ReturnAddressPtr pc)
     VM* vm = &exec->vm();
     NativeCallFrameTracer tracer(vm, exec);
 #if LLINT_SLOW_PATH_TRACING
     VM* vm = &exec->vm();
     NativeCallFrameTracer tracer(vm, exec);
 #if LLINT_SLOW_PATH_TRACING
-    dataLog("Throwing exception ", vm->exception, ".\n");
+    dataLog("Throwing exception ", vm->exception(), ".\n");
 #endif
     genericThrow(
 #endif
     genericThrow(
-        vm, exec, vm->exception,
+        vm, exec, vm->exception(),
         exec->codeBlock()->bytecodeOffset(exec, pc));
 }
 
         exec->codeBlock()->bytecodeOffset(exec, pc));
 }
 
index 45cdd42..eec95e1 100644 (file)
@@ -71,9 +71,9 @@ JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, J
     ProgramExecutable* program = ProgramExecutable::create(exec, source);
     if (!program) {
         if (returnedException)
     ProgramExecutable* program = ProgramExecutable::create(exec, source);
     if (!program) {
         if (returnedException)
-            *returnedException = exec->vm().exception;
+            *returnedException = exec->vm().exception();
 
 
-        exec->vm().exception = JSValue();
+        exec->vm().clearException();
         return jsUndefined();
     }
 
         return jsUndefined();
     }
 
index 9cbe20b..a87be18 100644 (file)
@@ -140,9 +140,6 @@ JSObject* addErrorInfo(CallFrame* callFrame, JSObject* error, int line, const So
         error->putDirect(*vm, Identifier(vm, linePropertyName), jsNumber(line), ReadOnly | DontDelete);
     if (!sourceURL.isNull())
         error->putDirect(*vm, Identifier(vm, sourceURLPropertyName), jsString(vm, sourceURL), ReadOnly | DontDelete);
         error->putDirect(*vm, Identifier(vm, linePropertyName), jsNumber(line), ReadOnly | DontDelete);
     if (!sourceURL.isNull())
         error->putDirect(*vm, Identifier(vm, sourceURLPropertyName), jsString(vm, sourceURL), ReadOnly | DontDelete);
-
-    vm->interpreter->addStackTraceIfNecessary(callFrame, error);
-
     return error;
 }
 
     return error;
 }
 
@@ -153,28 +150,14 @@ bool hasErrorInfo(ExecState* exec, JSObject* error)
         || error->hasProperty(exec, Identifier(exec, sourceURLPropertyName));
 }
 
         || error->hasProperty(exec, Identifier(exec, sourceURLPropertyName));
 }
 
-JSValue throwError(ExecState* exec, JSValue error)
-{
-    Interpreter::addStackTraceIfNecessary(exec, error);
-    exec->vm().exception = error;
-    return error;
-}
-
-JSObject* throwError(ExecState* exec, JSObject* error)
-{
-    Interpreter::addStackTraceIfNecessary(exec, error);
-    exec->vm().exception = error;
-    return error;
-}
-
 JSObject* throwTypeError(ExecState* exec)
 {
 JSObject* throwTypeError(ExecState* exec)
 {
-    return throwError(exec, createTypeError(exec, ASCIILiteral("Type error")));
+    return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Type error")));
 }
 
 JSObject* throwSyntaxError(ExecState* exec)
 {
 }
 
 JSObject* throwSyntaxError(ExecState* exec)
 {
-    return throwError(exec, createSyntaxError(exec, ASCIILiteral("Syntax error")));
+    return exec->vm().throwException(exec, createSyntaxError(exec, ASCIILiteral("Syntax error")));
 }
 
 const ClassInfo StrictModeTypeErrorFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictModeTypeErrorFunction) };
 }
 
 const ClassInfo StrictModeTypeErrorFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictModeTypeErrorFunction) };
index 126dff8..2b3b4b3 100644 (file)
@@ -62,15 +62,13 @@ namespace JSC {
     JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&);
 
     // Methods to throw Errors.
     JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&);
 
     // Methods to throw Errors.
-    JS_EXPORT_PRIVATE JSValue throwError(ExecState*, JSValue);
-    JS_EXPORT_PRIVATE JSObject* throwError(ExecState*, JSObject*);
 
     // Convenience wrappers, create an throw an exception with a default message.
     JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*);
     JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*);
 
     // Convenience wrappers, wrap result as an EncodedJSValue.
 
     // Convenience wrappers, create an throw an exception with a default message.
     JS_EXPORT_PRIVATE JSObject* throwTypeError(ExecState*);
     JS_EXPORT_PRIVATE JSObject* throwSyntaxError(ExecState*);
 
     // Convenience wrappers, wrap result as an EncodedJSValue.
-    inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(throwError(exec, error)); }
+    inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(exec->vm().throwException(exec, error)); }
     inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); }
 
     class StrictModeTypeErrorFunction : public InternalFunction {
     inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); }
 
     class StrictModeTypeErrorFunction : public InternalFunction {
index 60268ac..d5c390b 100644 (file)
@@ -155,19 +155,19 @@ JSObject* createOutOfMemoryError(JSGlobalObject* globalObject)
 
 JSObject* throwOutOfMemoryError(ExecState* exec)
 {
 
 JSObject* throwOutOfMemoryError(ExecState* exec)
 {
-    return throwError(exec, createOutOfMemoryError(exec->lexicalGlobalObject()));
+    return exec->vm().throwException(exec, createOutOfMemoryError(exec->lexicalGlobalObject()));
 }
 
 JSObject* throwStackOverflowError(ExecState* exec)
 {
     Interpreter::ErrorHandlingMode mode(exec);
 }
 
 JSObject* throwStackOverflowError(ExecState* exec)
 {
     Interpreter::ErrorHandlingMode mode(exec);
-    return throwError(exec, createStackOverflowError(exec));
+    return exec->vm().throwException(exec, createStackOverflowError(exec));
 }
 
 JSObject* throwTerminatedExecutionException(ExecState* exec)
 {
     Interpreter::ErrorHandlingMode mode(exec);
 }
 
 JSObject* throwTerminatedExecutionException(ExecState* exec)
 {
     Interpreter::ErrorHandlingMode mode(exec);
-    return throwError(exec, createTerminatedExecutionException(&exec->vm()));
+    return exec->vm().throwException(exec, createTerminatedExecutionException(&exec->vm()));
 }
 
 } // namespace JSC
 }
 
 } // namespace JSC
index 0b36935..46e48e6 100644 (file)
@@ -120,7 +120,7 @@ EvalExecutable* EvalExecutable::create(ExecState* exec, const SourceCode& source
 {
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     if (!globalObject->evalEnabled()) {
 {
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     if (!globalObject->evalEnabled()) {
-        throwError(exec, createEvalError(exec, globalObject->evalDisabledErrorMessage()));
+        exec->vm().throwException(exec, createEvalError(exec, globalObject->evalDisabledErrorMessage()));
         return 0;
     }
 
         return 0;
     }
 
@@ -503,7 +503,7 @@ PassRefPtr<FunctionCodeBlock> FunctionExecutable::produceCodeBlockFor(JSScope* s
     recordParse(m_unlinkedExecutable->features(), m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn());
 
     if (!unlinkedCodeBlock) {
     recordParse(m_unlinkedExecutable->features(), m_unlinkedExecutable->hasCapturedVariables(), lineNo(), lastLine(), startColumn());
 
     if (!unlinkedCodeBlock) {
-        exception = error.toErrorObject(globalObject, m_source);
+        exception = vm->throwException(globalObject->globalExec(), error.toErrorObject(globalObject, m_source));
         return 0;
     }
 
         return 0;
     }
 
index 3c4379b..cb91c26 100644 (file)
@@ -82,7 +82,7 @@ CallType FunctionConstructor::getCallData(JSCell*, CallData& callData)
 JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const String& sourceURL, const TextPosition& position)
 {
     if (!globalObject->evalEnabled())
 JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const String& sourceURL, const TextPosition& position)
 {
     if (!globalObject->evalEnabled())
-        return throwError(exec, createEvalError(exec, globalObject->evalDisabledErrorMessage()));
+        return exec->vm().throwException(exec, createEvalError(exec, globalObject->evalDisabledErrorMessage()));
     return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position);
 }
 
     return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position);
 }
 
@@ -115,7 +115,7 @@ JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObj
     FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->dynamicGlobalObject()->debugger(), source, &exception);
     if (!function) {
         ASSERT(exception);
     FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, exec, exec->dynamicGlobalObject()->debugger(), source, &exception);
     if (!function) {
         ASSERT(exception);
-        return throwError(exec, exception);
+        return exec->vm().throwException(exec, exception);
     }
 
     return JSFunction::create(exec, function, globalObject);
     }
 
     return JSFunction::create(exec, function, globalObject);
index 20921c7..3719ca7 100644 (file)
@@ -109,7 +109,7 @@ bool JSArray::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName
         unsigned newLen = descriptor.value().toUInt32(exec);
         // d. If newLen is not equal to ToNumber( Desc.[[Value]]), throw a RangeError exception.
         if (newLen != descriptor.value().toNumber(exec)) {
         unsigned newLen = descriptor.value().toUInt32(exec);
         // d. If newLen is not equal to ToNumber( Desc.[[Value]]), throw a RangeError exception.
         if (newLen != descriptor.value().toNumber(exec)) {
-            throwError(exec, createRangeError(exec, "Invalid array length"));
+            exec->vm().throwException(exec, createRangeError(exec, "Invalid array length"));
             return false;
         }
 
             return false;
         }
 
@@ -197,7 +197,7 @@ void JSArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSVa
     if (propertyName == exec->propertyNames().length) {
         unsigned newLength = value.toUInt32(exec);
         if (value.toNumber(exec) != static_cast<double>(newLength)) {
     if (propertyName == exec->propertyNames().length) {
         unsigned newLength = value.toUInt32(exec);
         if (value.toNumber(exec) != static_cast<double>(newLength)) {
-            throwError(exec, createRangeError(exec, ASCIILiteral("Invalid array length")));
+            exec->vm().throwException(exec, createRangeError(exec, ASCIILiteral("Invalid array length")));
             return;
         }
         thisObject->setLength(exec, newLength, slot.isStrictMode());
             return;
         }
         thisObject->setLength(exec, newLength, slot.isStrictMode());
@@ -569,7 +569,7 @@ void JSArray::push(ExecState* exec, JSValue value)
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
-                throwError(exec, createRangeError(exec, "Invalid array length"));
+                exec->vm().throwException(exec, createRangeError(exec, "Invalid array length"));
             return;
         }
         
             return;
         }
         
@@ -589,7 +589,7 @@ void JSArray::push(ExecState* exec, JSValue value)
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
-                throwError(exec, createRangeError(exec, "Invalid array length"));
+                exec->vm().throwException(exec, createRangeError(exec, "Invalid array length"));
             return;
         }
         
             return;
         }
         
@@ -621,7 +621,7 @@ void JSArray::push(ExecState* exec, JSValue value)
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
         if (length > MAX_ARRAY_INDEX) {
             methodTable()->putByIndex(this, exec, length, value, true);
             if (!exec->hadException())
-                throwError(exec, createRangeError(exec, "Invalid array length"));
+                exec->vm().throwException(exec, createRangeError(exec, "Invalid array length"));
             return;
         }
         
             return;
         }
         
@@ -656,7 +656,7 @@ void JSArray::push(ExecState* exec, JSValue value)
             methodTable()->putByIndex(this, exec, storage->length(), value, true);
             // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
             if (!exec->hadException())
             methodTable()->putByIndex(this, exec, storage->length(), value, true);
             // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
             if (!exec->hadException())
-                throwError(exec, createRangeError(exec, "Invalid array length"));
+                exec->vm().throwException(exec, createRangeError(exec, "Invalid array length"));
             return;
         }
 
             return;
         }
 
index 1006b62..8a5c24b 100644 (file)
@@ -76,7 +76,7 @@ JSObject* JSValue::toObjectSlowCase(ExecState* exec, JSGlobalObject* globalObjec
         return constructBooleanFromImmediateBoolean(exec, globalObject, asValue());
 
     ASSERT(isUndefinedOrNull());
         return constructBooleanFromImmediateBoolean(exec, globalObject, asValue());
 
     ASSERT(isUndefinedOrNull());
-    throwError(exec, createNotAnObjectError(exec, *this));
+    exec->vm().throwException(exec, createNotAnObjectError(exec, *this));
     return JSNotAnObject::create(exec);
 }
 
     return JSNotAnObject::create(exec);
 }
 
@@ -108,7 +108,7 @@ JSObject* JSValue::synthesizePrototype(ExecState* exec) const
         return exec->lexicalGlobalObject()->booleanPrototype();
 
     ASSERT(isUndefinedOrNull());
         return exec->lexicalGlobalObject()->booleanPrototype();
 
     ASSERT(isUndefinedOrNull());
-    throwError(exec, createNotAnObjectError(exec, *this));
+    exec->vm().throwException(exec, createNotAnObjectError(exec, *this));
     return JSNotAnObject::create(exec);
 }
 
     return JSNotAnObject::create(exec);
 }
 
@@ -144,7 +144,7 @@ void JSValue::putToPrimitive(ExecState* exec, PropertyName propertyName, JSValue
         if (offset != invalidOffset) {
             if (attributes & ReadOnly) {
                 if (slot.isStrictMode())
         if (offset != invalidOffset) {
             if (attributes & ReadOnly) {
                 if (slot.isStrictMode())
-                    throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
+                    exec->vm().throwException(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
                 return;
             }
 
                 return;
             }
 
index 3686ba6..7fa4ca0 100644 (file)
@@ -408,27 +408,27 @@ bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, PropertyNa
      
     if (descriptor.configurablePresent() && descriptor.configurable()) {
         if (throwException)
      
     if (descriptor.configurablePresent() && descriptor.configurable()) {
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
         return false;
     }
     if (descriptor.enumerablePresent() && descriptor.enumerable()) {
         if (throwException)
         return false;
     }
     if (descriptor.enumerablePresent() && descriptor.enumerable()) {
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
         return false;
     }
     if (descriptor.isAccessorDescriptor()) {
         if (throwException)
         return false;
     }
     if (descriptor.isAccessorDescriptor()) {
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
         return false;
     }
     if (descriptor.writablePresent() && descriptor.writable()) {
         if (throwException)
         return false;
     }
     if (descriptor.writablePresent() && descriptor.writable()) {
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
         return false;
     }
     if (!valueCheck) {
         if (throwException)
         return false;
     }
     if (!valueCheck) {
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
         return false;
     }
     return true;
         return false;
     }
     return true;
index 0a1edf2..be25ba6 100644 (file)
@@ -49,7 +49,7 @@ JSGenericTypedArrayView<Adaptor>* JSGenericTypedArrayView<Adaptor>::create(
 {
     ConstructionContext context(exec->vm(), structure, length, sizeof(typename Adaptor::Type));
     if (!context) {
 {
     ConstructionContext context(exec->vm(), structure, length, sizeof(typename Adaptor::Type));
     if (!context) {
-        throwError(exec, createOutOfMemoryError(structure->globalObject()));
+        exec->vm().throwException(exec, createOutOfMemoryError(structure->globalObject()));
         return 0;
     }
     JSGenericTypedArrayView* result =
         return 0;
     }
     JSGenericTypedArrayView* result =
@@ -67,7 +67,7 @@ JSGenericTypedArrayView<Adaptor>* JSGenericTypedArrayView<Adaptor>::createUninit
         exec->vm(), structure, length, sizeof(typename Adaptor::Type),
         ConstructionContext::DontInitialize);
     if (!context) {
         exec->vm(), structure, length, sizeof(typename Adaptor::Type),
         ConstructionContext::DontInitialize);
     if (!context) {
-        throwError(exec, createOutOfMemoryError(structure->globalObject()));
+        exec->vm().throwException(exec, createOutOfMemoryError(structure->globalObject()));
         return 0;
     }
     JSGenericTypedArrayView* result =
         return 0;
     }
     JSGenericTypedArrayView* result =
@@ -84,7 +84,7 @@ JSGenericTypedArrayView<Adaptor>* JSGenericTypedArrayView<Adaptor>::create(
 {
     RefPtr<ArrayBuffer> buffer = passedBuffer;
     if (!ArrayBufferView::verifySubRange<typename Adaptor::Type>(buffer, byteOffset, length)) {
 {
     RefPtr<ArrayBuffer> buffer = passedBuffer;
     if (!ArrayBufferView::verifySubRange<typename Adaptor::Type>(buffer, byteOffset, length)) {
-        throwError(
+        exec->vm().throwException(
             exec, createRangeError(exec, "Byte offset and length out of range of buffer"));
         return 0;
     }
             exec, createRangeError(exec, "Byte offset and length out of range of buffer"));
         return 0;
     }
@@ -126,7 +126,7 @@ bool JSGenericTypedArrayView<Adaptor>::validateRange(
     if (canAccessRangeQuickly(offset, length))
         return true;
     
     if (canAccessRangeQuickly(offset, length))
         return true;
     
-    throwError(exec, createRangeError(exec, "Range consisting of offset and length are out of bounds"));
+    exec->vm().throwException(exec, createRangeError(exec, "Range consisting of offset and length are out of bounds"));
     return false;
 }
 
     return false;
 }
 
@@ -148,7 +148,7 @@ bool JSGenericTypedArrayView<Adaptor>::setWithSpecificType(
         return false;
     
     if (other->length() != length) {
         return false;
     
     if (other->length() != length) {
-        throwError(exec, createRangeError(exec, "Length of incoming array changed unexpectedly."));
+        exec->vm().throwException(exec, createRangeError(exec, "Length of incoming array changed unexpectedly."));
         return false;
     }
     
         return false;
     }
     
index 4e954ba..8874394 100644 (file)
@@ -57,7 +57,7 @@ static JSValue encode(ExecState* exec, const char* doNotEscape)
 {
     CString cstr = exec->argument(0).toString(exec)->value(exec).utf8(StrictConversion);
     if (!cstr.data())
 {
     CString cstr = exec->argument(0).toString(exec)->value(exec).utf8(StrictConversion);
     if (!cstr.data())
-        return throwError(exec, createURIError(exec, ASCIILiteral("String contained an illegal UTF-16 sequence.")));
+        return exec->vm().throwException(exec, createURIError(exec, ASCIILiteral("String contained an illegal UTF-16 sequence.")));
 
     JSStringBuilder builder;
     const char* p = cstr.data();
 
     JSStringBuilder builder;
     const char* p = cstr.data();
@@ -118,7 +118,7 @@ static JSValue decode(ExecState* exec, const CharType* characters, int length, c
             }
             if (charLen == 0) {
                 if (strict)
             }
             if (charLen == 0) {
                 if (strict)
-                    return throwError(exec, createURIError(exec, ASCIILiteral("URI error")));
+                    return exec->vm().throwException(exec, createURIError(exec, ASCIILiteral("URI error")));
                 // The only case where we don't use "strict" mode is the "unescape" function.
                 // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
                 if (k <= length - 6 && p[1] == 'u'
                 // The only case where we don't use "strict" mode is the "unescape" function.
                 // For that, it's good to support the wonky "%u" syntax for compatibility with WinIE.
                 if (k <= length - 6 && p[1] == 'u'
@@ -744,7 +744,7 @@ EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState* exec)
         return throwVMError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
 
     if (!thisObject->setPrototypeWithCycleCheck(exec, value))
         return throwVMError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
 
     if (!thisObject->setPrototypeWithCycleCheck(exec, value))
-        throwError(exec, createError(exec, "cyclic __proto__ value"));
+        exec->vm().throwException(exec, createError(exec, "cyclic __proto__ value"));
     return JSValue::encode(jsUndefined());
 }
 
     return JSValue::encode(jsUndefined());
 }
 
index 7bccabe..76542f6 100644 (file)
@@ -65,7 +65,7 @@ void JSNameScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
         bool isWritable = true;
         symbolTableGet(thisObject, propertyName, slot, isWritable);
         if (!isWritable) {
         bool isWritable = true;
         symbolTableGet(thisObject, propertyName, slot, isWritable);
         if (!isWritable) {
-            throwError(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
+            exec->vm().throwException(exec, createTypeError(exec, StrictModeReadonlyPropertyWriteError));
             return;
         }
     }
             return;
         }
     }
index 3fff0cd..2c2ccd8 100644 (file)
@@ -411,7 +411,7 @@ Stringifier::StringifyResult Stringifier::appendStringifiedValue(StringBuilder&
     // Handle cycle detection, and put the holder on the stack.
     for (unsigned i = 0; i < m_holderStack.size(); i++) {
         if (m_holderStack[i].object() == object) {
     // Handle cycle detection, and put the holder on the stack.
     for (unsigned i = 0; i < m_holderStack.size(); i++) {
         if (m_holderStack[i].object() == object) {
-            throwError(m_exec, createTypeError(m_exec, ASCIILiteral("JSON.stringify cannot serialize cyclic structures.")));
+            m_exec->vm().throwException(m_exec, createTypeError(m_exec, ASCIILiteral("JSON.stringify cannot serialize cyclic structures.")));
             return StringifyFailed;
         }
     }
             return StringifyFailed;
         }
     }
@@ -646,7 +646,7 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered)
                 ASSERT(inValue.isObject());
                 ASSERT(isJSArray(asObject(inValue)) || asObject(inValue)->inherits(JSArray::info()));
                 if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
                 ASSERT(inValue.isObject());
                 ASSERT(isJSArray(asObject(inValue)) || asObject(inValue)->inherits(JSArray::info()));
                 if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
-                    return throwError(m_exec, createStackOverflowError(m_exec));
+                    return m_exec->vm().throwException(m_exec, createStackOverflowError(m_exec));
 
                 JSArray* array = asArray(inValue);
                 arrayStack.push(array);
 
                 JSArray* array = asArray(inValue);
                 arrayStack.push(array);
@@ -697,7 +697,7 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered)
                 ASSERT(inValue.isObject());
                 ASSERT(!isJSArray(asObject(inValue)) && !asObject(inValue)->inherits(JSArray::info()));
                 if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
                 ASSERT(inValue.isObject());
                 ASSERT(!isJSArray(asObject(inValue)) && !asObject(inValue)->inherits(JSArray::info()));
                 if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
-                    return throwError(m_exec, createStackOverflowError(m_exec));
+                    return m_exec->vm().throwException(m_exec, createStackOverflowError(m_exec));
 
                 JSObject* object = asObject(inValue);
                 objectStack.push(object);
 
                 JSObject* object = asObject(inValue);
                 objectStack.push(object);
index 259e879..d8f99f9 100644 (file)
@@ -379,7 +379,7 @@ void JSObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSV
             if (attributes & ReadOnly) {
                 ASSERT(thisObject->structure()->prototypeChainMayInterceptStoreTo(exec->vm(), propertyName) || obj == thisObject);
                 if (slot.isStrictMode())
             if (attributes & ReadOnly) {
                 ASSERT(thisObject->structure()->prototypeChainMayInterceptStoreTo(exec->vm(), propertyName) || obj == thisObject);
                 if (slot.isStrictMode())
-                    throwError(exec, createTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError)));
+                    exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral(StrictModeReadonlyPropertyWriteError)));
                 return;
             }
 
                 return;
             }
 
@@ -1367,7 +1367,7 @@ JSValue JSObject::defaultValue(const JSObject* object, ExecState* exec, Preferre
 
     ASSERT(!exec->hadException());
 
 
     ASSERT(!exec->hadException());
 
-    return throwError(exec, createTypeError(exec, ASCIILiteral("No default value")));
+    return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("No default value")));
 }
 
 const HashEntry* JSObject::findPropertyHashEntry(ExecState* exec, PropertyName propertyName) const
 }
 
 const HashEntry* JSObject::findPropertyHashEntry(ExecState* exec, PropertyName propertyName) const
@@ -1388,7 +1388,7 @@ bool JSObject::hasInstance(ExecState* exec, JSValue value)
         return defaultHasInstance(exec, value, get(exec, exec->propertyNames().prototype));
     if (info.implementsHasInstance())
         return methodTable()->customHasInstance(this, exec, value);
         return defaultHasInstance(exec, value, get(exec, exec->propertyNames().prototype));
     if (info.implementsHasInstance())
         return methodTable()->customHasInstance(this, exec, value);
-    throwError(exec, createInvalidParameterError(exec, "instanceof" , this));
+    exec->vm().throwException(exec, createInvalidParameterError(exec, "instanceof" , this));
     return false;
 }
 
     return false;
 }
 
@@ -1398,7 +1398,7 @@ bool JSObject::defaultHasInstance(ExecState* exec, JSValue value, JSValue proto)
         return false;
 
     if (!proto.isObject()) {
         return false;
 
     if (!proto.isObject()) {
-        throwError(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
+        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("instanceof called on an object with an invalid prototype property.")));
         return false;
     }
 
         return false;
     }
 
@@ -2472,7 +2472,7 @@ bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyN
         // unless extensions are prevented!
         if (!isExtensible()) {
             if (throwException)
         // unless extensions are prevented!
         if (!isExtensible()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
             return false;
         }
         PropertyDescriptor oldDescriptor;
             return false;
         }
         PropertyDescriptor oldDescriptor;
@@ -2490,12 +2490,12 @@ bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyN
     if (!current.configurable()) {
         if (descriptor.configurable()) {
             if (throwException)
     if (!current.configurable()) {
         if (descriptor.configurable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
             return false;
         }
         if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
             if (throwException)
             return false;
         }
         if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
             return false;
         }
     }
             return false;
         }
     }
@@ -2513,7 +2513,7 @@ bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyN
     if (descriptor.isDataDescriptor() != current.isDataDescriptor()) {
         if (!current.configurable()) {
             if (throwException)
     if (descriptor.isDataDescriptor() != current.isDataDescriptor()) {
         if (!current.configurable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
             return false;
         }
         methodTable()->deleteProperty(this, exec, propertyName);
             return false;
         }
         methodTable()->deleteProperty(this, exec, propertyName);
@@ -2525,13 +2525,13 @@ bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyN
         if (!current.configurable()) {
             if (!current.writable() && descriptor.writable()) {
                 if (throwException)
         if (!current.configurable()) {
             if (!current.writable() && descriptor.writable()) {
                 if (throwException)
-                    throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
+                    exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
                 return false;
             }
             if (!current.writable()) {
                 if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) {
                     if (throwException)
                 return false;
             }
             if (!current.writable()) {
                 if (descriptor.value() && !sameValue(exec, current.value(), descriptor.value())) {
                     if (throwException)
-                        throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
+                        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
                     return false;
                 }
             }
                     return false;
                 }
             }
@@ -2547,12 +2547,12 @@ bool JSObject::defineOwnNonIndexProperty(ExecState* exec, PropertyName propertyN
     if (!current.configurable()) {
         if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) {
             if (throwException)
     if (!current.configurable()) {
         if (descriptor.setterPresent() && !(current.setterPresent() && JSValue::strictEqual(exec, current.setter(), descriptor.setter()))) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the setter of an unconfigurable property.")));
             return false;
         }
         if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) {
             if (throwException)
             return false;
         }
         if (descriptor.getterPresent() && !(current.getterPresent() && JSValue::strictEqual(exec, current.getter(), descriptor.getter()))) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change the getter of an unconfigurable property.")));
             return false;
         }
     }
             return false;
         }
     }
@@ -2599,7 +2599,7 @@ bool JSObject::getOwnPropertySlotSlow(ExecState* exec, PropertyName propertyName
 
 JSObject* throwTypeError(ExecState* exec, const String& message)
 {
 
 JSObject* throwTypeError(ExecState* exec, const String& message)
 {
-    return throwError(exec, createTypeError(exec, message));
+    return exec->vm().throwException(exec, createTypeError(exec, message));
 }
 
 } // namespace JSC
 }
 
 } // namespace JSC
index 21d6e59..2c98651 100644 (file)
@@ -206,7 +206,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)
 static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor& desc)
 {
     if (!in.isObject()) {
 static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor& desc)
 {
     if (!in.isObject()) {
-        throwError(exec, createTypeError(exec, ASCIILiteral("Property description must be an object.")));
+        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Property description must be an object.")));
         return false;
     }
     JSObject* description = asObject(in);
         return false;
     }
     JSObject* description = asObject(in);
@@ -248,7 +248,7 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor
         if (!get.isUndefined()) {
             CallData callData;
             if (getCallData(get, callData) == CallTypeNone) {
         if (!get.isUndefined()) {
             CallData callData;
             if (getCallData(get, callData) == CallTypeNone) {
-                throwError(exec, createTypeError(exec, ASCIILiteral("Getter must be a function.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Getter must be a function.")));
                 return false;
             }
         }
                 return false;
             }
         }
@@ -263,7 +263,7 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor
         if (!set.isUndefined()) {
             CallData callData;
             if (getCallData(set, callData) == CallTypeNone) {
         if (!set.isUndefined()) {
             CallData callData;
             if (getCallData(set, callData) == CallTypeNone) {
-                throwError(exec, createTypeError(exec, ASCIILiteral("Setter must be a function.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Setter must be a function.")));
                 return false;
             }
         }
                 return false;
             }
         }
@@ -274,12 +274,12 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor
         return true;
 
     if (desc.value()) {
         return true;
 
     if (desc.value()) {
-        throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'value' present on property with getter or setter.")));
+        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'value' present on property with getter or setter.")));
         return false;
     }
 
     if (desc.writablePresent()) {
         return false;
     }
 
     if (desc.writablePresent()) {
-        throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'writable' present on property with getter or setter.")));
+        exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Invalid property.  'writable' present on property with getter or setter.")));
         return false;
     }
     return true;
         return false;
     }
     return true;
index 1e2ec34..6e9bd40 100644 (file)
@@ -256,7 +256,7 @@ JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const A
 
     if (arg0.inherits(RegExpObject::info())) {
         if (!arg1.isUndefined())
 
     if (arg0.inherits(RegExpObject::info())) {
         if (!arg1.isUndefined())
-            return throwError(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
+            return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Cannot supply flags when constructing one RegExp from another.")));
         // If called as a function, this just returns the first argument (see 15.10.3.1).
         if (callAsConstructor) {
             RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp();
         // If called as a function, this just returns the first argument (see 15.10.3.1).
         if (callAsConstructor) {
             RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp();
@@ -275,12 +275,12 @@ JSObject* constructRegExp(ExecState* exec, JSGlobalObject* globalObject, const A
         if (exec->hadException())
             return 0;
         if (flags == InvalidFlags)
         if (exec->hadException())
             return 0;
         if (flags == InvalidFlags)
-            return throwError(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
+            return exec->vm().throwException(exec, createSyntaxError(exec, ASCIILiteral("Invalid flags supplied to RegExp constructor.")));
     }
 
     RegExp* regExp = RegExp::create(exec->vm(), pattern, flags);
     if (!regExp->isValid())
     }
 
     RegExp* regExp = RegExp::create(exec->vm(), pattern, flags);
     if (!regExp->isValid())
-        return throwError(exec, createSyntaxError(exec, regExp->errorMessage()));
+        return exec->vm().throwException(exec, createSyntaxError(exec, regExp->errorMessage()));
     return RegExpObject::create(exec, exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp);
 }
 
     return RegExpObject::create(exec, exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp);
 }
 
index 4162323..2536c9e 100644 (file)
@@ -88,27 +88,27 @@ bool StringObject::defineOwnProperty(JSObject* object, ExecState* exec, Property
     if (propertyName == exec->propertyNames().length) {
         if (!object->isExtensible()) {
             if (throwException)
     if (propertyName == exec->propertyNames().length) {
         if (!object->isExtensible()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to define property on object that is not extensible.")));
             return false;
         }
         if (descriptor.configurablePresent() && descriptor.configurable()) {
             if (throwException)
             return false;
         }
         if (descriptor.configurablePresent() && descriptor.configurable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to configurable attribute of unconfigurable property.")));
             return false;
         }
         if (descriptor.enumerablePresent() && descriptor.enumerable()) {
             if (throwException)
             return false;
         }
         if (descriptor.enumerablePresent() && descriptor.enumerable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change enumerable attribute of unconfigurable property.")));
             return false;
         }
         if (descriptor.isAccessorDescriptor()) {
             if (throwException)
             return false;
         }
         if (descriptor.isAccessorDescriptor()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change access mechanism for an unconfigurable property.")));
             return false;
         }
         if (descriptor.writablePresent() && descriptor.writable()) {
             if (throwException)
             return false;
         }
         if (descriptor.writablePresent() && descriptor.writable()) {
             if (throwException)
-                throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
+                exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change writable attribute of unconfigurable property.")));
             return false;
         }
         if (!descriptor.value())
             return false;
         }
         if (!descriptor.value())
@@ -116,7 +116,7 @@ bool StringObject::defineOwnProperty(JSObject* object, ExecState* exec, Property
         if (propertyName == exec->propertyNames().length && sameValue(exec, descriptor.value(), jsNumber(thisObject->internalValue()->length())))
             return true;
         if (throwException)
         if (propertyName == exec->propertyNames().length && sameValue(exec, descriptor.value(), jsNumber(thisObject->internalValue()->length())))
             return true;
         if (throwException)
-            throwError(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
+            exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("Attempting to change value of a readonly property.")));
         return false;
     }
 
         return false;
     }
 
index 8835a5c..1f20423 100644 (file)
@@ -28,7 +28,7 @@ namespace JSC {
 
 JSValue StringRecursionChecker::throwStackOverflowError()
 {
 
 JSValue StringRecursionChecker::throwStackOverflowError()
 {
-    return throwError(m_exec, createStackOverflowError(m_exec));
+    return m_exec->vm().throwException(m_exec, createStackOverflowError(m_exec));
 }
 
 JSValue StringRecursionChecker::emptyString()
 }
 
 JSValue StringRecursionChecker::emptyString()
index 9bb0d4c..7302258 100644 (file)
 #include "VM.h"
 
 #include "ArgList.h"
 #include "VM.h"
 
 #include "ArgList.h"
+#include "CallFrameInlines.h"
+#include "CodeBlock.h"
 #include "CodeCache.h"
 #include "CommonIdentifiers.h"
 #include "DFGLongLivedState.h"
 #include "DFGWorklist.h"
 #include "DebuggerActivation.h"
 #include "CodeCache.h"
 #include "CommonIdentifiers.h"
 #include "DFGLongLivedState.h"
 #include "DFGWorklist.h"
 #include "DebuggerActivation.h"
+#include "ErrorInstance.h"
 #include "FunctionConstructor.h"
 #include "GCActivityCallback.h"
 #include "GetterSetter.h"
 #include "Heap.h"
 #include "HostCallReturnValue.h"
 #include "FunctionConstructor.h"
 #include "GCActivityCallback.h"
 #include "GetterSetter.h"
 #include "Heap.h"
 #include "HostCallReturnValue.h"
+#include "Identifier.h"
 #include "IncrementalSweeper.h"
 #include "Interpreter.h"
 #include "JSActivation.h"
 #include "JSAPIValueWrapper.h"
 #include "JSArray.h"
 #include "JSFunction.h"
 #include "IncrementalSweeper.h"
 #include "Interpreter.h"
 #include "JSActivation.h"
 #include "JSAPIValueWrapper.h"
 #include "JSArray.h"
 #include "JSFunction.h"
+#include "JSGlobalObjectFunctions.h"
 #include "JSLock.h"
 #include "JSNameScope.h"
 #include "JSNotAnObject.h"
 #include "JSLock.h"
 #include "JSNameScope.h"
 #include "JSNotAnObject.h"
@@ -554,11 +559,132 @@ void VM::releaseExecutableMemory()
     heap.collectAllGarbage();
 }
 
     heap.collectAllGarbage();
 }
 
-void VM::clearExceptionStack()
+static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception, unsigned bytecodeOffset)
 {
 {
-    m_exceptionStack = RefCountedArray<StackFrame>();
+    exception->clearAppendSourceToMessage();
+    
+    if (!callFrame->codeBlock()->hasExpressionInfo())
+        return;
+    
+    int startOffset = 0;
+    int endOffset = 0;
+    int divotPoint = 0;
+    unsigned line = 0;
+    unsigned column = 0;
+    
+    CodeBlock* codeBlock = callFrame->codeBlock();
+    codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset, line, column);
+    
+    int expressionStart = divotPoint - startOffset;
+    int expressionStop = divotPoint + endOffset;
+    
+    const String& sourceString = codeBlock->source()->source();
+    if (!expressionStop || expressionStart > static_cast<int>(sourceString.length()))
+        return;
+    
+    VM* vm = &callFrame->vm();
+    JSValue jsMessage = exception->getDirect(*vm, vm->propertyNames->message);
+    if (!jsMessage || !jsMessage.isString())
+        return;
+    
+    String message = asString(jsMessage)->value(callFrame);
+    
+    if (expressionStart < expressionStop)
+        message =  makeString(message, " (evaluating '", codeBlock->source()->getRange(expressionStart, expressionStop), "')");
+    else {
+        // No range information, so give a few characters of context.
+        const StringImpl* data = sourceString.impl();
+        int dataLength = sourceString.length();
+        int start = expressionStart;
+        int stop = expressionStart;
+        // Get up to 20 characters of context to the left and right of the divot, clamping to the line.
+        // Then strip whitespace.
+        while (start > 0 && (expressionStart - start < 20) && (*data)[start - 1] != '\n')
+            start--;
+        while (start < (expressionStart - 1) && isStrWhiteSpace((*data)[start]))
+            start++;
+        while (stop < dataLength && (stop - expressionStart < 20) && (*data)[stop] != '\n')
+            stop++;
+        while (stop > expressionStart && isStrWhiteSpace((*data)[stop - 1]))
+            stop--;
+        message = makeString(message, " (near '...", codeBlock->source()->getRange(start, stop), "...')");
+    }
+    
+    exception->putDirect(*vm, vm->propertyNames->message, jsString(vm, message));
+}
+    
+JSValue VM::throwException(ExecState* exec, JSValue error)
+{
+    ASSERT(exec == topCallFrame || exec == exec->lexicalGlobalObject()->globalExec() || exec == exec->dynamicGlobalObject()->globalExec());
+    
+    Vector<StackFrame> stackTrace;
+    interpreter->getStackTrace(stackTrace);
+    m_exceptionStack = RefCountedArray<StackFrame>(stackTrace);
+    m_exception = error;
+    
+    if (stackTrace.isEmpty() || !error.isObject())
+        return error;
+    JSObject* exception = asObject(error);
+    
+    StackFrame stackFrame;
+    for (unsigned i = 0 ; i < stackTrace.size(); ++i) {
+        stackFrame = stackTrace.at(i);
+        if (stackFrame.bytecodeOffset)
+            break;
+    }
+    unsigned bytecodeOffset = stackFrame.bytecodeOffset;
+    if (!hasErrorInfo(exec, exception)) {
+        // FIXME: We should only really be adding these properties to VM generated exceptions,
+        // but the inspector currently requires these for all thrown objects.
+        unsigned line;
+        unsigned column;
+        stackFrame.computeLineAndColumn(line, column);
+        exception->putDirect(*this, Identifier(this, "line"), jsNumber(line), ReadOnly | DontDelete);
+        exception->putDirect(*this, Identifier(this, "column"), jsNumber(column), ReadOnly | DontDelete);
+        if (!stackFrame.sourceURL.isEmpty())
+            exception->putDirect(*this, Identifier(this, "sourceURL"), jsString(this, stackFrame.sourceURL), ReadOnly | DontDelete);
+    }
+    if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->appendSourceToMessage()) {
+        unsigned stackIndex = 0;
+        CallFrame* callFrame;
+        for (callFrame = exec; callFrame && !callFrame->codeBlock(); callFrame = callFrame->callerFrame()->removeHostCallFrameFlag())
+            stackIndex++;
+        stackFrame = stackTrace.at(stackIndex);
+        bytecodeOffset = stackFrame.bytecodeOffset;
+        appendSourceToError(callFrame, static_cast<ErrorInstance*>(exception), bytecodeOffset);
+    }
+
+    if (exception->hasProperty(exec, this->propertyNames->stack))
+        return error;
+    
+    exception->putDirect(*this, propertyNames->stack, interpreter->stackTraceAsString(topCallFrame, stackTrace), DontEnum);
+    return error;
 }
     
 }
     
+JSObject* VM::throwException(ExecState* exec, JSObject* error)
+{
+    return asObject(throwException(exec, JSValue(error)));
+}
+void VM::getExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack)
+{
+    exception = m_exception;
+    exceptionStack = m_exceptionStack;
+}
+void VM::setExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack)
+{
+    m_exception = exception;
+    m_exceptionStack = exceptionStack;
+}
+
+void VM::clearException()
+{
+    m_exception = JSValue();
+}
+void VM:: clearExceptionStack()
+{
+    m_exceptionStack = RefCountedArray<StackFrame>();
+}
+
 void releaseExecutableMemory(VM& vm)
 {
     vm.releaseExecutableMemory();
 void releaseExecutableMemory(VM& vm)
 {
     vm.releaseExecutableMemory();
index 843db3a..c514d2a 100644 (file)
@@ -333,10 +333,22 @@ namespace JSC {
 #endif
         NativeExecutable* getHostFunction(NativeFunction, NativeFunction constructor);
 
 #endif
         NativeExecutable* getHostFunction(NativeFunction, NativeFunction constructor);
 
-        JSValue exception;
+        static ptrdiff_t exceptionOffset()
+        {
+            return OBJECT_OFFSETOF(VM, m_exception);
+        }
+        
+        JS_EXPORT_PRIVATE void clearException();
         JS_EXPORT_PRIVATE void clearExceptionStack();
         JS_EXPORT_PRIVATE void clearExceptionStack();
-        RefCountedArray<StackFrame>& exceptionStack() { return m_exceptionStack; }
-
+        void getExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack);
+        void setExceptionInfo(JSValue& exception, RefCountedArray<StackFrame>& exceptionStack);
+        JSValue exception() const { return m_exception; }
+        JSValue* addressOfException() { return &m_exception; }
+        const RefCountedArray<StackFrame>& exceptionStack() const { return m_exceptionStack; }
+
+        JS_EXPORT_PRIVATE JSValue throwException(ExecState*, JSValue);
+        JS_EXPORT_PRIVATE JSObject* throwException(ExecState*, JSObject*);
+        
         const ClassInfo* const jsArrayClassInfo;
         const ClassInfo* const jsFinalObjectClassInfo;
 
         const ClassInfo* const jsArrayClassInfo;
         const ClassInfo* const jsFinalObjectClassInfo;
 
@@ -438,6 +450,7 @@ namespace JSC {
 
     private:
         friend class LLIntOffsetsExtractor;
 
     private:
         friend class LLIntOffsetsExtractor;
+        friend class ClearExceptionScope;
         
         VM(VMType, HeapType);
         static VM*& sharedInstanceInternal();
         
         VM(VMType, HeapType);
         static VM*& sharedInstanceInternal();
@@ -454,6 +467,7 @@ namespace JSC {
 #if ENABLE(GC_VALIDATION)
         const ClassInfo* m_initializingObjectClass;
 #endif
 #if ENABLE(GC_VALIDATION)
         const ClassInfo* m_initializingObjectClass;
 #endif
+        JSValue m_exception;
         bool m_inDefineOwnProperty;
         OwnPtr<CodeCache> m_codeCache;
         RefCountedArray<StackFrame> m_exceptionStack;
         bool m_inDefineOwnProperty;
         OwnPtr<CodeCache> m_codeCache;
         RefCountedArray<StackFrame> m_exceptionStack;
index 386eb1b..baebb00 100644 (file)
@@ -1,3 +1,83 @@
+2013-08-28  Chris Curtis  <chris_curtis@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=119548
+        Refactoring Exception throws.
+        
+        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):
+
 2013-08-28  Alexey Proskuryakov  <ap@apple.com>
 
         Remove an unused data member from Page.
 2013-08-28  Alexey Proskuryakov  <ap@apple.com>
 
         Remove an unused data member from Page.
index d7441df..f648bd7 100644 (file)
@@ -43,12 +43,12 @@ void JSAudioBufferSourceNode::setBuffer(ExecState* exec, JSValue value)
     AudioBufferSourceNode* imp = static_cast<AudioBufferSourceNode*>(impl());
     AudioBuffer* buffer = toAudioBuffer(value);
     if (!buffer) {
     AudioBufferSourceNode* imp = static_cast<AudioBufferSourceNode*>(impl());
     AudioBuffer* buffer = toAudioBuffer(value);
     if (!buffer) {
-        throwError(exec, createTypeError(exec, "Value is not of type AudioBuffer"));
+        exec->vm().throwException(exec, createTypeError(exec, "Value is not of type AudioBuffer"));
         return;
     }
     
     if (!imp->setBuffer(buffer))
         return;
     }
     
     if (!imp->setBuffer(buffer))
-        throwError(exec, createTypeError(exec, "AudioBuffer unsupported number of channels"));
+        exec->vm().throwException(exec, createTypeError(exec, "AudioBuffer unsupported number of channels"));
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 8ad9c9c..64008e9 100644 (file)
@@ -44,7 +44,7 @@ void JSBiquadFilterNode::setType(ExecState* exec, JSValue value)
     if (value.isNumber()) {
         uint32_t type = value.toUInt32(exec);
         if (!imp->setType(type))
     if (value.isNumber()) {
         uint32_t type = value.toUInt32(exec);
         if (!imp->setType(type))
-            throwError(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
+            exec->vm().throwException(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
         return;
     }
 #endif
         return;
     }
 #endif
@@ -57,7 +57,7 @@ void JSBiquadFilterNode::setType(ExecState* exec, JSValue value)
         }
     }
     
         }
     }
     
-    throwError(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
+    exec->vm().throwException(exec, createTypeError(exec, "Illegal BiquadFilterNode type"));
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 4cb22e0..2208971 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 JSValue JSCrypto::getRandomValues(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
 JSValue JSCrypto::getRandomValues(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     JSValue buffer = exec->argument(0);
     RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer);
 
     JSValue buffer = exec->argument(0);
     RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer);
index 0210a29..3dae124 100644 (file)
@@ -172,6 +172,8 @@ void reportException(ExecState* exec, JSValue exception, CachedScript* cachedScr
         JSObject* exceptionObject = exception.toObject(exec);
         JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line"));
         lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0;
         JSObject* exceptionObject = exception.toObject(exec);
         JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line"));
         lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0;
+        JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column"));
+        columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0;
         JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL"));
         exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
     }
         JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL"));
         exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
     }
@@ -227,7 +229,7 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     }
 
     ASSERT(errorObject);
     }
 
     ASSERT(errorObject);
-    throwError(exec, errorObject);
+    exec->vm().throwException(exec, errorObject);
 }
 
 #undef TRY_TO_CREATE_EXCEPTION
 }
 
 #undef TRY_TO_CREATE_EXCEPTION
index 64dc34f..9f803a9 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 JSValue JSIDBDatabase::createObjectStore(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
 JSValue JSIDBDatabase::createObjectStore(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     String name = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
 
     String name = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
index 54c9d60..fc8d3eb 100644 (file)
@@ -46,10 +46,10 @@ JSValue JSIDBObjectStore::createIndex(ExecState* exec)
 {
     ScriptExecutionContext* context = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
 {
     ScriptExecutionContext* context = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
     if (!context)
-        return throwError(exec, createReferenceError(exec, "IDBObjectStore script execution context is unavailable"));
+        return exec->vm().throwException(exec, createReferenceError(exec, "IDBObjectStore script execution context is unavailable"));
 
     if (exec->argumentCount() < 2)
 
     if (exec->argumentCount() < 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     String name = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
 
     String name = exec->argument(0).toString(exec)->value(exec);
     if (exec->hadException())
index 8b3d561..4ac90bb 100644 (file)
@@ -289,7 +289,7 @@ JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const
 JSValue JSInjectedScriptHost::setFunctionVariableValue(JSC::ExecState* exec)
 {
     // FIXME: implement this. https://bugs.webkit.org/show_bug.cgi?id=107830
 JSValue JSInjectedScriptHost::setFunctionVariableValue(JSC::ExecState* exec)
 {
     // FIXME: implement this. https://bugs.webkit.org/show_bug.cgi?id=107830
-    throwError(exec, createTypeError(exec, "Variable value mutation is not supported"));
+    exec->vm().throwException(exec, createTypeError(exec, "Variable value mutation is not supported"));
     return jsUndefined();
 }
 
     return jsUndefined();
 }
 
index e1dd7c7..f72f5ab 100644 (file)
@@ -43,7 +43,7 @@ JSValue JSJavaScriptCallFrame::evaluate(ExecState* exec)
     JSValue result = impl()->evaluate(exec->argument(0).toString(exec)->value(exec), exception);
 
     if (exception)
     JSValue result = impl()->evaluate(exec->argument(0).toString(exec)->value(exec), exception);
 
     if (exception)
-        throwError(exec, exception);
+        exec->vm().throwException(exec, exception);
 
     return result;
 }
 
     return result;
 }
@@ -133,7 +133,7 @@ JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec)
 JSValue JSJavaScriptCallFrame::setVariableValue(JSC::ExecState* exec)
 {
     // FIXME: implement this. https://bugs.webkit.org/show_bug.cgi?id=107830
 JSValue JSJavaScriptCallFrame::setVariableValue(JSC::ExecState* exec)
 {
     // FIXME: implement this. https://bugs.webkit.org/show_bug.cgi?id=107830
-    throwError(exec, createTypeError(exec, "Variable value mutation is not supported"));
+    exec->vm().throwException(exec, createTypeError(exec, "Variable value mutation is not supported"));
     return jsUndefined();
 }
 
     return jsUndefined();
 }
 
index 9a0a6ed..756e0c6 100644 (file)
@@ -55,7 +55,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode)
         filter = filter.get(exec, Identifier(exec, "acceptNode"));
         callType = getCallData(filter, callData);
         if (callType == CallTypeNone) {
         filter = filter.get(exec, Identifier(exec, "acceptNode"));
         callType = getCallData(filter, callData);
         if (callType == CallTypeNone) {
-            throwError(exec, createTypeError(exec, "NodeFilter object does not have an acceptNode function"));
+            exec->vm().throwException(exec, createTypeError(exec, "NodeFilter object does not have an acceptNode function"));
             return NodeFilter::FILTER_REJECT;
         }
     }
             return NodeFilter::FILTER_REJECT;
         }
     }
index 04bbcc4..716ff5d 100644 (file)
@@ -44,7 +44,7 @@ void JSOscillatorNode::setType(ExecState* exec, JSValue value)
     if (value.isNumber()) {
         uint32_t type = value.toUInt32(exec);
         if (!imp->setType(type))
     if (value.isNumber()) {
         uint32_t type = value.toUInt32(exec);
         if (!imp->setType(type))
-            throwError(exec, createTypeError(exec, "Illegal OscillatorNode type"));
+            exec->vm().throwException(exec, createTypeError(exec, "Illegal OscillatorNode type"));
         return;
     }
 #endif
         return;
     }
 #endif
@@ -57,7 +57,7 @@ void JSOscillatorNode::setType(ExecState* exec, JSValue value)
         }
     }
     
         }
     }
     
-    throwError(exec, createTypeError(exec, "Illegal OscillatorNode type"));
+    exec->vm().throwException(exec, createTypeError(exec, "Illegal OscillatorNode type"));
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 6913de4..a3e5ad0 100644 (file)
@@ -44,7 +44,7 @@ void JSPannerNode::setPanningModel(ExecState* exec, JSValue value)
     if (value.isNumber()) {
         uint32_t model = value.toUInt32(exec);
         if (!imp->setPanningModel(model))
     if (value.isNumber()) {
         uint32_t model = value.toUInt32(exec);
         if (!imp->setPanningModel(model))
-            throwError(exec, createTypeError(exec, "Illegal panningModel"));
+            exec->vm().throwException(exec, createTypeError(exec, "Illegal panningModel"));
         return;
     }
 #endif
         return;
     }
 #endif
@@ -57,7 +57,7 @@ void JSPannerNode::setPanningModel(ExecState* exec, JSValue value)
         }
     }
     
         }
     }
     
-    throwError(exec, createTypeError(exec, "Illegal panningModel"));
+    exec->vm().throwException(exec, createTypeError(exec, "Illegal panningModel"));
 }
 
 void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
 }
 
 void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
@@ -68,7 +68,7 @@ void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
     if (value.isNumber()) {
         uint32_t model = value.toUInt32(exec);
         if (!imp->setDistanceModel(model))
     if (value.isNumber()) {
         uint32_t model = value.toUInt32(exec);
         if (!imp->setDistanceModel(model))
-            throwError(exec, createTypeError(exec, "Illegal distanceModel"));
+            exec->vm().throwException(exec, createTypeError(exec, "Illegal distanceModel"));
         return;
     }
 #endif
         return;
     }
 #endif
@@ -81,7 +81,7 @@ void JSPannerNode::setDistanceModel(ExecState* exec, JSValue value)
         }
     }
     
         }
     }
     
-    throwError(exec, createTypeError(exec, "Illegal distanceModel"));
+    exec->vm().throwException(exec, createTypeError(exec, "Illegal distanceModel"));
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index dca4983..5b92c35 100644 (file)
@@ -81,7 +81,7 @@ JSValue JSSVGLength::convertToSpecifiedUnits(ExecState* exec)
     SVGLength& podImp = impl()->propertyReference();
 
     if (exec->argumentCount() < 1)
     SVGLength& podImp = impl()->propertyReference();
 
     if (exec->argumentCount() < 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     unsigned short unitType = exec->argument(0).toUInt32(exec);
     if (exec->hadException())
 
     unsigned short unitType = exec->argument(0).toUInt32(exec);
     if (exec->hadException())
index d48ac39..4426037 100644 (file)
@@ -152,7 +152,7 @@ enum ObjectType {
 static JSValue getObjectParameter(JSWebGLRenderingContext* obj, ExecState* exec, ObjectType objectType)
 {
     if (exec->argumentCount() != 2)
 static JSValue getObjectParameter(JSWebGLRenderingContext* obj, ExecState* exec, ObjectType objectType)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(obj->impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(obj->impl());
@@ -243,7 +243,7 @@ void JSWebGLRenderingContext::visitChildren(JSCell* cell, SlotVisitor& visitor)
 JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
 JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLProgram::info()))
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLProgram::info()))
@@ -268,7 +268,7 @@ JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec)
 JSValue JSWebGLRenderingContext::getExtension(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
 JSValue JSWebGLRenderingContext::getExtension(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     const String name = exec->argument(0).toString(exec)->value(exec);
 
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
     const String name = exec->argument(0).toString(exec)->value(exec);
@@ -286,7 +286,7 @@ JSValue JSWebGLRenderingContext::getBufferParameter(ExecState* exec)
 JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 3)
 JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 3)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
@@ -310,7 +310,7 @@ JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* ex
 JSValue JSWebGLRenderingContext::getParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 1)
 JSValue JSWebGLRenderingContext::getParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 1)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
@@ -328,7 +328,7 @@ JSValue JSWebGLRenderingContext::getParameter(ExecState* exec)
 JSValue JSWebGLRenderingContext::getProgramParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
 JSValue JSWebGLRenderingContext::getProgramParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
@@ -354,7 +354,7 @@ JSValue JSWebGLRenderingContext::getRenderbufferParameter(ExecState* exec)
 JSValue JSWebGLRenderingContext::getShaderParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
 JSValue JSWebGLRenderingContext::getShaderParameter(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
@@ -392,7 +392,7 @@ JSValue JSWebGLRenderingContext::getTexParameter(ExecState* exec)
 JSValue JSWebGLRenderingContext::getUniform(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
 JSValue JSWebGLRenderingContext::getUniform(ExecState* exec)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
 
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
@@ -466,7 +466,7 @@ static bool functionForUniform(DataFunctionToCall f)
 static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 2)
 static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
     
     WebGLUniformLocation* location = 0;
     long index = -1;
     
     WebGLUniformLocation* location = 0;
     long index = -1;
@@ -556,7 +556,7 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, We
 static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 2)
 static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLUniformLocation::info()))
         return throwTypeError(exec);
 
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLUniformLocation::info()))
         return throwTypeError(exec);
@@ -621,7 +621,7 @@ static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, We
 static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 3)
 static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, WebGLRenderingContext* context)
 {
     if (exec->argumentCount() != 3)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLUniformLocation::info()))
         return throwTypeError(exec);
 
     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(JSWebGLUniformLocation::info()))
         return throwTypeError(exec);
index 814ddbe..66ae3dc 100644 (file)
@@ -82,7 +82,7 @@ void JSXMLHttpRequest::visitChildren(JSCell* cell, SlotVisitor& visitor)
 JSValue JSXMLHttpRequest::open(ExecState* exec)
 {
     if (exec->argumentCount() < 2)
 JSValue JSXMLHttpRequest::open(ExecState* exec)
 {
     if (exec->argumentCount() < 2)
-        return throwError(exec, createNotEnoughArgumentsError(exec));
+        return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
 
     const KURL& url = impl()->scriptExecutionContext()->completeURL(exec->argument(1).toString(exec)->value(exec));
     String method = exec->argument(0).toString(exec)->value(exec);
 
     const KURL& url = impl()->scriptExecutionContext()->completeURL(exec->argument(1).toString(exec)->value(exec));
     String method = exec->argument(0).toString(exec)->value(exec);
index ae4741d..59514db 100644 (file)
@@ -120,9 +120,11 @@ PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState* e
         if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) {
             JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line"));
             int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0;
         if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) {
             JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line"));
             int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0;
+            JSValue columnValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "column"));
+            int columnNumber = columnValue && columnValue.isNumber() ? int(columnValue.toNumber(exec)) : 0;
             JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL"));
             String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
             JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL"));
             String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
-            frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, 0);
+            frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, columnNumber);
         }
     }
 
         }
     }
 
index fb4457d..c22f493 100644 (file)
@@ -261,7 +261,7 @@ protected:
 
     void throwStackOverflow()
     {
 
     void throwStackOverflow()
     {
-        throwError(m_exec, createStackOverflowError(m_exec));
+        m_exec->vm().throwException(m_exec, createStackOverflowError(m_exec));
     }
 
     NO_RETURN_DUE_TO_ASSERT
     }
 
     NO_RETURN_DUE_TO_ASSERT
@@ -1066,7 +1066,7 @@ private:
 
     void throwValidationError()
     {
 
     void throwValidationError()
     {
-        throwError(m_exec, createTypeError(m_exec, "Unable to deserialize data."));
+        m_exec->vm().throwException(m_exec, createTypeError(m_exec, "Unable to deserialize data."));
     }
 
     bool isValid() const { return m_version <= CurrentVersion; }
     }
 
     bool isValid() const { return m_version <= CurrentVersion; }
@@ -1894,10 +1894,10 @@ void SerializedScriptValue::maybeThrowExceptionIfSerializationFailed(ExecState*
     
     switch (code) {
     case StackOverflowError:
     
     switch (code) {
     case StackOverflowError:
-        throwError(exec, createStackOverflowError(exec));
+        exec->vm().throwException(exec, createStackOverflowError(exec));
         break;
     case ValidationError:
         break;
     case ValidationError:
-        throwError(exec, createTypeError(exec, "Unable to deserialize data."));
+        exec->vm().throwException(exec, createTypeError(exec, "Unable to deserialize data."));
         break;
     case DataCloneError:
         setDOMException(exec, DATA_CLONE_ERR);
         break;
     case DataCloneError:
         setDOMException(exec, DATA_CLONE_ERR);
index 8da06ee..200912a 100644 (file)
@@ -148,7 +148,7 @@ void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
         int columnNumber = 0;
         String sourceURL = sourceCode.url().string();
         if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, sourceCode.cachedScript()))
         int columnNumber = 0;
         String sourceURL = sourceCode.url().string();
         if (m_workerGlobalScope->sanitizeScriptError(errorMessage, lineNumber, columnNumber, sourceURL, sourceCode.cachedScript()))
-            *exception = ScriptValue(*m_vm, throwError(exec, createError(exec, errorMessage.impl())));
+            *exception = ScriptValue(*m_vm, exec->vm().throwException(exec, createError(exec, errorMessage.impl())));
         else
             *exception = ScriptValue(*m_vm, evaluationException);
     }
         else
             *exception = ScriptValue(*m_vm, evaluationException);
     }
@@ -156,7 +156,7 @@ void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, Script
 
 void WorkerScriptController::setException(const ScriptValue& exception)
 {
 
 void WorkerScriptController::setException(const ScriptValue& exception)
 {
-    throwError(m_workerGlobalScopeWrapper->globalExec(), exception.jsValue());
+    m_workerGlobalScopeWrapper->globalExec()->vm().throwException(m_workerGlobalScopeWrapper->globalExec(), exception.jsValue());
 }
 
 void WorkerScriptController::scheduleExecutionTermination()
 }
 
 void WorkerScriptController::scheduleExecutionTermination()
index d6bcc62..985dd98 100644 (file)
@@ -72,7 +72,7 @@ void CInstance::moveGlobalExceptionToExecState(ExecState* exec)
 
     {
         JSLockHolder lock(exec);
 
     {
         JSLockHolder lock(exec);
-        throwError(exec, createError(exec, globalExceptionString()));
+        exec->vm().throwException(exec, createError(exec, globalExceptionString()));
     }
 
     globalExceptionString() = String();
     }
 
     globalExceptionString() = String();
@@ -153,7 +153,7 @@ JSValue CInstance::getMethod(ExecState* exec, PropertyName propertyName)
 JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(CRuntimeMethod::info()))
 JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(CRuntimeMethod::info()))
-        return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
+        return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
     CMethod* method = static_cast<CMethod*>(runtimeMethod->method());
     ASSERT(method);
 
     CMethod* method = static_cast<CMethod*>(runtimeMethod->method());
     ASSERT(method);
@@ -182,7 +182,7 @@ JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
     }
 
     if (!retval)
     }
 
     if (!retval)
-        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
+        exec->vm().throwException(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
@@ -217,7 +217,7 @@ JSValue CInstance::invokeDefaultMethod(ExecState* exec)
     }
 
     if (!retval)
     }
 
     if (!retval)
-        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
+        exec->vm().throwException(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
@@ -256,7 +256,7 @@ JSValue CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
     }
 
     if (!retval)
     }
 
     if (!retval)
-        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
+        exec->vm().throwException(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
 
     for (i = 0; i < count; i++)
         _NPN_ReleaseVariantValue(&cArgs[i]);
@@ -326,7 +326,7 @@ bool CInstance::toJSPrimitive(ExecState* exec, const char* name, JSValue& result
     }
 
     if (!retval)
     }
 
     if (!retval)
-        throwError(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
+        exec->vm().throwException(exec, createError(exec, ASCIILiteral("Error calling method on NPObject.")));
 
     resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
     _NPN_ReleaseVariantValue(&resultVariant);
 
     resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
     _NPN_ReleaseVariantValue(&resultVariant);
index af37022..cbafc2d 100644 (file)
@@ -224,7 +224,7 @@ JSValue ObjcInstance::getMethod(ExecState* exec, PropertyName propertyName)
 JSValue ObjcInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(ObjCRuntimeMethod::info()))
 JSValue ObjcInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(ObjCRuntimeMethod::info()))
-        return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
+        return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
     ObjcMethod *method = static_cast<ObjcMethod*>(runtimeMethod->method());
     ASSERT(method);
 
     ObjcMethod *method = static_cast<ObjcMethod*>(runtimeMethod->method());
     ASSERT(method);
index fa355a5..7dd12c2 100644 (file)
@@ -149,12 +149,12 @@ ObjcArray::ObjcArray(ObjectStructPtr a, PassRefPtr<RootObject> rootObject)
 void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue aValue) const
 {
     if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) {
 void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue aValue) const
 {
     if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) {
-        throwError(exec, createTypeError(exec, "Array is not mutable."));
+        exec->vm().throwException(exec, createTypeError(exec, "Array is not mutable."));
         return;
     }
 
     if (index > [_array.get() count]) {
         return;
     }
 
     if (index > [_array.get() count]) {
-        throwError(exec, createRangeError(exec, "Index exceeds array size."));
+        exec->vm().throwException(exec, createRangeError(exec, "Index exceeds array size."));
         return;
     }
     
         return;
     }
     
@@ -165,20 +165,20 @@ void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue aValue)
     @try {
         [_array.get() insertObject:oValue.objectValue atIndex:index];
     } @catch(NSException* localException) {
     @try {
         [_array.get() insertObject:oValue.objectValue atIndex:index];
     } @catch(NSException* localException) {
-        throwError(exec, createError(exec, "Objective-C exception."));
+        exec->vm().throwException(exec, createError(exec, "Objective-C exception."));
     }
 }
 
 JSValue ObjcArray::valueAt(ExecState* exec, unsigned int index) const
 {
     if (index > [_array.get() count])
     }
 }
 
 JSValue ObjcArray::valueAt(ExecState* exec, unsigned int index) const
 {
     if (index > [_array.get() count])
-        return throwError(exec, createRangeError(exec, "Index exceeds array size."));
+        return exec->vm().throwException(exec, createRangeError(exec, "Index exceeds array size."));
     @try {
         id obj = [_array.get() objectAtIndex:index];
         if (obj)
             return convertObjcValueToValue (exec, &obj, ObjcObjectType, m_rootObject.get());
     } @catch(NSException* localException) {
     @try {
         id obj = [_array.get() objectAtIndex:index];
         if (obj)
             return convertObjcValueToValue (exec, &obj, ObjcObjectType, m_rootObject.get());
     } @catch(NSException* localException) {
-        return throwError(exec, createError(exec, "Objective-C exception."));
+        return exec->vm().throwException(exec, createError(exec, "Objective-C exception."));
     }
     return jsUndefined();
 }
     }
     return jsUndefined();
 }
index e1695c8..2c4fb1e 100644 (file)
@@ -313,7 +313,7 @@ ObjcValueType objcValueTypeForType(const char *type)
 JSObject *throwError(ExecState *exec, NSString *message)
 {
     ASSERT(message);
 JSObject *throwError(ExecState *exec, NSString *message)
 {
     ASSERT(message);
-    JSObject *error = JSC::throwError(exec, JSC::createError(exec, String(message)));
+    JSObject *error = exec->vm().throwException(exec, JSC::createError(exec, String(message)));
     return error;
 }
 
     return error;
 }
 
index da25d95..e99d2d7 100644 (file)
@@ -80,7 +80,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, PropertyName id
     if (QtRuntimeMethod* method = qtinst->m_methods.value(name)) {
         JSValue obj = toJS(method->jsObjectRef(context, &exception));
         if (exception)
     if (QtRuntimeMethod* method = qtinst->m_methods.value(name)) {
         JSValue obj = toJS(method->jsObjectRef(context, &exception));
         if (exception)
-            return throwError(exec, toJS(exec, exception));
+            return exec->vm().throwException(exec, toJS(exec, exception));
         return obj;
     }
 
         return obj;
     }
 
@@ -117,7 +117,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, PropertyName id
     qtinst->m_methods.insert(name, method);
     JSValue obj = toJS(method->jsObjectRef(context, &exception));
     if (exception)
     qtinst->m_methods.insert(name, method);
     JSValue obj = toJS(method->jsObjectRef(context, &exception));
     if (exception)
-        return throwError(exec, toJS(exec, exception));
+        return exec->vm().throwException(exec, toJS(exec, exception));
     return obj;
 }
 
     return obj;
 }
 
index 7e046ff..0efe2b1 100644 (file)
@@ -337,11 +337,11 @@ JSValue QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
         JSValueRef exception = 0;
         JSValueRef jsValue = convertQVariantToValue(toRef(exec), inst->rootObject(), val, &exception);
         if (exception)
         JSValueRef exception = 0;
         JSValueRef jsValue = convertQVariantToValue(toRef(exec), inst->rootObject(), val, &exception);
         if (exception)
-            return throwError(exec, toJS(exec, exception));
+            return exec->vm().throwException(exec, toJS(exec, exception));
         return toJS(exec, jsValue);
     }
     QString msg = QString(QLatin1String("cannot access member `%1' of deleted QObject")).arg(QLatin1String(name()));
         return toJS(exec, jsValue);
     }
     QString msg = QString(QLatin1String("cannot access member `%1' of deleted QObject")).arg(QLatin1String(name()));
-    return throwError(exec, createError(exec, msg.toLatin1().constData()));
+    return exec->vm().throwException(exec, createError(exec, msg.toLatin1().constData()));
 }
 
 void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue aValue) const
 }
 
 void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue aValue) const
@@ -360,7 +360,7 @@ void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue
         JSValueRef exception = 0;
         QVariant val = convertValueToQVariant(toRef(exec), toRef(exec, aValue), argtype, 0, &exception);
         if (exception) {
         JSValueRef exception = 0;
         QVariant val = convertValueToQVariant(toRef(exec), toRef(exec, aValue), argtype, 0, &exception);
         if (exception) {
-            throwError(exec, toJS(exec, exception));
+            exec->vm().throwException(exec, toJS(exec, exception));
             return;
         }
         if (m_type == MetaProperty) {
             return;
         }
         if (m_type == MetaProperty) {
@@ -373,7 +373,7 @@ void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue
 #endif
     } else {
         QString msg = QString(QLatin1String("cannot access member `%1' of deleted QObject")).arg(QLatin1String(name()));
 #endif
     } else {
         QString msg = QString(QLatin1String("cannot access member `%1' of deleted QObject")).arg(QLatin1String(name()));
-        throwError(exec, createError(exec, msg.toLatin1().constData()));
+        exec->vm().throwException(exec, createError(exec, msg.toLatin1().constData()));
     }
 }
 
     }
 }
 
index f00f011..fd0dbb8 100644 (file)
@@ -118,7 +118,7 @@ void RuntimeArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName,
 {
     RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
     if (propertyName == exec->propertyNames().length) {
 {
     RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
     if (propertyName == exec->propertyNames().length) {
-        throwError(exec, createRangeError(exec, "Range error"));
+        exec->vm().throwException(exec, createRangeError(exec, "Range error"));
         return;
     }
     
         return;
     }
     
@@ -135,7 +135,7 @@ void RuntimeArray::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSV
 {
     RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
     if (index >= thisObject->getLength()) {
 {
     RuntimeArray* thisObject = jsCast<RuntimeArray*>(cell);
     if (index >= thisObject->getLength()) {
-        throwError(exec, createRangeError(exec, "Range error"));
+        exec->vm().throwException(exec, createRangeError(exec, "Range error"));
         return;
     }
     
         return;
     }
     
index af1db3a..94e832a 100644 (file)
@@ -271,7 +271,7 @@ void RuntimeObject::getOwnPropertyNames(JSObject* object, ExecState* exec, Prope
 
 JSObject* RuntimeObject::throwInvalidAccessError(ExecState* exec)
 {
 
 JSObject* RuntimeObject::throwInvalidAccessError(ExecState* exec)
 {
-    return throwError(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
+    return exec->vm().throwException(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
 }
 
 }
 }
 
 }
index 0ce8cbf..b3093d6 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-28  Chris Curtis  <chris_curtis@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=119548
+        Refactoring Exception throws.
+
+        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):
+
 2013-08-27  Anders Carlsson  <andersca@apple.com>
 
         Fix build.
 2013-08-27  Anders Carlsson  <andersca@apple.com>
 
         Fix build.
index 8c19524..fda910a 100644 (file)
@@ -1683,7 +1683,7 @@ void NetscapePluginInstanceProxy::moveGlobalExceptionToExecState(ExecState* exec
 
     {
         JSLockHolder lock(exec);
 
     {
         JSLockHolder lock(exec);
-        throwError(exec, createError(exec, globalExceptionString()));
+        exec->vm().throwException(exec, createError(exec, globalExceptionString()));
     }
 
     globalExceptionString() = String();
     }
 
     globalExceptionString() = String();
index d7a81fb..c3c5f53 100644 (file)
@@ -221,7 +221,7 @@ JSValue ProxyInstance::getMethod(JSC::ExecState* exec, PropertyName propertyName
 JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(ProxyRuntimeMethod::info()))
 JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtimeMethod)
 {
     if (!asObject(runtimeMethod)->inherits(ProxyRuntimeMethod::info()))
-        return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
+        return exec->vm().throwException(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
 
     ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
     ASSERT(method);
 
     ProxyMethod* method = static_cast<ProxyMethod*>(runtimeMethod->method());
     ASSERT(method);
index f81614d..c636c11 100644 (file)
@@ -1,3 +1,20 @@
+2013-08-28  Chris Curtis  <chris_curtis@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=119548
+        Refactoring Exception throws.
+
+        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):
+
 2013-08-28  Anders Carlsson  <andersca@apple.com>
 
         Allow the Flash plug-in to open its preference pane
 2013-08-28  Anders Carlsson  <andersca@apple.com>
 
         Allow the Flash plug-in to open its preference pane
index 5b78a9a..c19e00c 100644 (file)
@@ -137,7 +137,7 @@ JSValue JSNPObject::callMethod(ExecState* exec, NPIdentifier methodName)
         releaseNPVariantValue(&arguments[i]);
 
     if (!returnValue)
         releaseNPVariantValue(&arguments[i]);
 
     if (!returnValue)
-        throwError(exec, createError(exec, "Error calling method on NPObject."));
+        exec->vm().throwException(exec, createError(exec, "Error calling method on NPObject."));
 
     JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
 
     JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
@@ -177,7 +177,7 @@ JSC::JSValue JSNPObject::callObject(JSC::ExecState* exec)
         releaseNPVariantValue(&arguments[i]);
 
     if (!returnValue)
         releaseNPVariantValue(&arguments[i]);
 
     if (!returnValue)
-        throwError(exec, createError(exec, "Error calling method on NPObject."));
+        exec->vm().throwException(exec, createError(exec, "Error calling method on NPObject."));
 
     JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
 
     JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
@@ -213,7 +213,7 @@ JSValue JSNPObject::callConstructor(ExecState* exec)
     }
 
     if (!returnValue)
     }
 
     if (!returnValue)
-        throwError(exec, createError(exec, "Error calling method on NPObject."));
+        exec->vm().throwException(exec, createError(exec, "Error calling method on NPObject."));
     
     JSValue value = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
     
     JSValue value = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
     releaseNPVariantValue(&result);
@@ -467,7 +467,7 @@ JSValue JSNPObject::methodGetter(ExecState* exec, JSValue slotBase, PropertyName
 
 JSObject* JSNPObject::throwInvalidAccessError(ExecState* exec)
 {
 
 JSObject* JSNPObject::throwInvalidAccessError(ExecState* exec)
 {
-    return throwError(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
+    return exec->vm().throwException(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
 }
 
 } // namespace WebKit
 }
 
 } // namespace WebKit
index 0461d27..33adc46 100644 (file)
@@ -274,7 +274,7 @@ void NPRuntimeObjectMap::moveGlobalExceptionToExecState(ExecState* exec)
 
     {
         JSLockHolder lock(exec);
 
     {
         JSLockHolder lock(exec);
-        throwError(exec, createError(exec, globalExceptionString()));
+        exec->vm().throwException(exec, createError(exec, globalExceptionString()));
     }
     
     globalExceptionString() = String();
     }
     
     globalExceptionString() = String();