Changeset 72050 in webkit for trunk/JavaScriptCore/runtime/JSFunction.cpp
- Timestamp:
- Nov 15, 2010, 5:30:25 PM (15 years ago)
- Author:
- [email protected]
- Message:
-
Bug 49488 - Only add source specific information to exceptions in Interpreter::throwException
Reviewed by Geoff Garen.
Three types of source location information are added to errors.
(1) Divot information.
This was added with the intention of using it to provide better source highlighting in the inspector.
We may still want to do so, but we probably should not be exposing these values in a manner visible to
user scripts – only through an internal C++ interface. The code adding divot properties to objects has
been removed.
(2) Line number information.
Line number information is presently sometimes added at the point the exception is created, and sometimes
added at the point the exception passes through throwException. Change this so that throwException has
the sole responsibility for adding line number and source file information.
(3) Source snippets in the message of certain type errors (e.g. 'doc' in
Result of expression 'doc' [undefined] is not an object.
).
These messages are currently created at the point the exceptions is raised. Instead reformat the message
such that the source snippet is located at the end (Result of expression 'b1' [undefined] is not an object.
becomes'undefined' is not an object (evaluating 'b1.property')
), and append these to the message at
the in throw Exception. This presents a number of advantages:
- we no longer need to have source location information to create these TypeErrors.
- we can chose to append source location information in other error messages, including those where passing source location to the point of construction would be inconvenient.
- we can chose in future to omit to append source location information when running in a non-debug mode.
This also cleans up some error output, e.g. removing double brackets ('[[]]') around objects in output,
removing double periods (..) at end of lines, and adding slightly more context to some errors.
- bytecode/CodeBlock.cpp:
(JSC::CodeBlock::expressionRangeForBytecodeOffset):
- Separated called to access line and range information.
- bytecode/CodeBlock.h:
- Separated called to access line and range information.
- interpreter/Interpreter.cpp:
(JSC::Interpreter::resolve):
(JSC::Interpreter::resolveSkip):
(JSC::Interpreter::resolveGlobal):
(JSC::Interpreter::resolveGlobalDynamic):
(JSC::Interpreter::resolveBaseAndProperty):
(JSC::isInvalidParamForIn):
(JSC::isInvalidParamForInstanceOf):
- Update parameters passed to error constructors.
(JSC::appendSourceToError):
- Update message property to add location information (previously added in createErrorMessage, in ExceptionHelpers)
(JSC::Interpreter::throwException):
- Updated to call appendSourceToError.
(JSC::Interpreter::privateExecute):
- Update parameters passed to error constructors.
- jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
- Update parameters passed to error constructors.
- runtime/Error.cpp:
(JSC::addErrorInfo):
(JSC::hasErrorInfo):
- Removed divot properties.
- runtime/Error.h:
- Removed divot properties.
- runtime/ErrorInstance.cpp:
(JSC::ErrorInstance::ErrorInstance):
- Initialize new property.
- runtime/ErrorInstance.h:
(JSC::ErrorInstance::appendSourceToMessage):
(JSC::ErrorInstance::setAppendSourceToMessage):
(JSC::ErrorInstance::clearAppendSourceToMessage):
- Added flag to check for errors needing location information appending.
(JSC::ErrorInstance::isErrorInstance):
- Added virtual method to check for ErrorInstances.
- runtime/ExceptionHelpers.cpp:
(JSC::createUndefinedVariableError):
(JSC::createInvalidParamError):
(JSC::createNotAConstructorError):
(JSC::createNotAFunctionError):
(JSC::createNotAnObjectError):
- Update parameters passed to error constructors, stopped adding line number information early, changed TypeError messages.
- runtime/ExceptionHelpers.h:
- Updated function signatures.
- runtime/JSFunction.cpp:
(JSC::callHostFunctionAsConstructor):
- Update parameters passed to error constructors.
- runtime/JSObject.h:
(JSC::JSObject::isErrorInstance):
- Added virtual method to check for ErrorInstances.
LayoutTests:
Updated results to account for changes in TypeError messages.
(e.g.Result of expression 'b1' [undefined] is not an object.
->'undefined' is not an object (evaluating 'b1.property')
).
- fast/css/font-face-descriptor-multiple-values-parsing-expected.txt:
- fast/css/resources/font-face-descriptor-multiple-values-parsing.js:
- fast/css/variables/color-hex-test-expected.txt:
- fast/dom/HTMLSelectElement/named-options-expected.txt:
- fast/dom/Range/getClientRects-expected.txt:
- fast/dom/SelectorAPI/dumpNodeList-almost-strict-expected.txt:
- fast/dom/SelectorAPI/dumpNodeList-expected.txt:
- fast/forms/select-namedItem-expected.txt:
- fast/js/basic-strict-mode-expected.txt:
- fast/js/date-toisostring-expected.txt:
- fast/js/delete-getters-setters-expected.txt:
- fast/js/exception-expression-offset-expected.txt:
- fast/js/exception-for-nonobject-expected.txt:
- fast/js/exception-thrown-from-new-expected.txt:
- fast/js/exception-thrown-from-new.html:
- fast/js/instance-of-immediates-expected.txt:
- fast/js/script-tests/exception-expression-offset.js:
(testException):
- fast/js/sputnik/Conformance/08_Types/8.6_The_Object_Type/8.6.2_Internal_Properties_and_Methods/S8.6.2_A7-expected.txt:
- fast/js/sputnik/Conformance/13_Function_Definition/S13_A17_T2-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A1_T1-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A1_T2-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A2_T1-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.2_Object.prototype.toString/S15.2.4.2_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.3_Object.prototype.toLocaleString/S15.2.4.3_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.4_Object.prototype.valueOf/S15.2.4.4_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.5_Object.prototype.hasOwnProperty/S15.2.4.5_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.6_Object.prototype.isPrototypeOf/S15.2.4.6_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/15.2.4.7_Object.prototype.propertyIsEnumerable/S15.2.4.7_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A3-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A4-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.3_Function/15.3.4/15.3.4.2_Function.prototype.toString/S15.3.4.2_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.3_Function/15.3.4/S15.3.4_A5-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T4-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.13_String.prototype.slice/S15.5.4.13_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.15_String.prototype.substring/S15.5.4.15_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.17_String.prototype.toLocaleLowerCase/S15.5.4.17_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A7-expected.txt:
- fast/js/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.8_String.prototype.lastIndexOf/S15.5.4.8_A7-expected.txt:
- fast/xsl/transform-xhr-doc-expected.txt:
- http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write-expected.txt:
- http/tests/security/aboutBlank/xss-DENIED-navigate-opener-javascript-url-expected.txt:
- http/tests/security/aboutBlank/xss-DENIED-set-opener-expected.txt:
- java/lc3/ArrayMethods/byte-001-expected.txt:
- java/lc3/CallStatic/object-001-expected.txt:
- java/lc3/ConvertBoolean/boolean-007-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-008-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-009-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-010-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-011-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-012-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-013-n-expected.txt:
- java/lc3/ConvertBoolean/boolean-014-expected.txt:
- java/lc3/ConvertNull/null-001-expected.txt:
- java/lc3/ConvertNumber/number-011-expected.txt:
- java/lc3/ConvertString/string-006-expected.txt:
- java/lc3/ConvertString/string-007-n-expected.txt:
- java/lc3/ConvertUndefined/undefined-002-expected.txt:
- java/lc3/ConvertUndefined/undefined-003-expected.txt:
- java/lc3/JSBoolean/boolean-005-n-expected.txt:
- java/lc3/JSNumber/ToDouble-002-expected.txt:
- java/lc3/JSObject/ToJSObject-001-expected.txt:
- java/lc3/JSObject/ToObject-001-expected.txt:
- java/lc3/JavaObject/JavaObjectFieldOrMethod-001-expected.txt:
- platform/mac-snowleopard/canvas/philip/tests/2d.imageData.create1.type-expected.txt:
- platform/mac-snowleopard/canvas/philip/tests/2d.imageData.create2.type-expected.txt:
- platform/mac-snowleopard/canvas/philip/tests/2d.imageData.get.type-expected.txt:
- platform/mac/compositing/reflections/reflection-opacity-expected.txt:
- platform/mac/fast/css/variables/remove-variable-test-expected.txt:
- platform/mac/fast/css/variables/set-variable-test-expected.txt:
- platform/mac/fast/css/variables/variable-iteration-test-expected.txt:
- platform/mac/fast/events/updateLayoutForHitTest-expected.txt:
- platform/mac/svg/custom/createelement-expected.txt:
- platform/mac/tables/mozilla/bugs/bug53690-1-expected.txt:
- platform/mac/tables/mozilla_expected_failures/bugs/bug92868_1-expected.txt:
- plugins/npruntime/object-from-destroyed-plugin-expected.txt:
- plugins/npruntime/plugin-scriptable-object-invoke-default-expected.txt:
- svg/custom/use-nested-missing-target-removed-expected.txt:
- svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt:
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSFunction.cpp
r70496 r72050 46 46 EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec) 47 47 { 48 CodeBlock* codeBlock = exec->callerFrame()->codeBlock(); 49 unsigned vPCIndex = codeBlock->bytecodeOffset(exec, exec->returnPC()); 50 return throwVMError(exec, createNotAConstructorError(exec, exec->callee(), vPCIndex, codeBlock)); 48 return throwVMError(exec, createNotAConstructorError(exec, exec->callee())); 51 49 } 52 50 #endif