Ignore:
Timestamp:
Mar 24, 2015, 12:30:05 AM (10 years ago)
Author:
[email protected]
Message:

Improve error messages in JSC
https://bugs.webkit.org/show_bug.cgi?id=141869

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

JavaScriptCore has some unintuitive error messages associated
with certain common errors. This patch changes some specific
error messages to be more understandable and also creates a
mechanism that will allow for easy modification of error messages
in the future. The specific errors we change are not a function
errors and invalid parameter errors.

(JSC::sizeOfVarargs):

  • jit/JITOperations.cpp:

op_throw_static_error always has a JSString as its argument.
There is no need to dance around this, and we should assert
that this always holds. This JSString represents the error
message we want to display to the user, so there is no need
to pass it into errorDescriptionForValue which will now place
quotes around the string.

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

(JSC::CommonSlowPaths::opIn):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::ErrorInstance):

  • runtime/ErrorInstance.h:

(JSC::ErrorInstance::hasSourceAppender):
(JSC::ErrorInstance::sourceAppender):
(JSC::ErrorInstance::setSourceAppender):
(JSC::ErrorInstance::clearSourceAppender):
(JSC::ErrorInstance::setRuntimeTypeForCause):
(JSC::ErrorInstance::runtimeTypeForCause):
(JSC::ErrorInstance::clearRuntimeTypeForCause):
(JSC::ErrorInstance::appendSourceToMessage): Deleted.
(JSC::ErrorInstance::setAppendSourceToMessage): Deleted.
(JSC::ErrorInstance::clearAppendSourceToMessage): Deleted.

  • runtime/ExceptionHelpers.cpp:

(JSC::errorDescriptionForValue):
(JSC::defaultApproximateSourceError):
(JSC::defaultSourceAppender):
(JSC::functionCallBase):
(JSC::notAFunctionSourceAppender):
(JSC::invalidParameterInSourceAppender):
(JSC::invalidParameterInstanceofSourceAppender):
(JSC::createError):
(JSC::createInvalidFunctionApplyParameterError):
(JSC::createInvalidInParameterError):
(JSC::createInvalidInstanceofParameterError):
(JSC::createNotAConstructorError):
(JSC::createNotAFunctionError):
(JSC::createNotAnObjectError):
(JSC::createInvalidParameterError): Deleted.

  • runtime/ExceptionHelpers.h:
  • runtime/JSObject.cpp:

(JSC::JSObject::hasInstance):

  • runtime/RuntimeType.cpp: Added.

(JSC::runtimeTypeForValue):
(JSC::runtimeTypeAsString):

  • runtime/RuntimeType.h: Added.
  • runtime/TypeProfilerLog.cpp:

(JSC::TypeProfilerLog::processLogEntries):

  • runtime/TypeSet.cpp:

(JSC::TypeSet::getRuntimeTypeForValue): Deleted.

  • runtime/TypeSet.h:
  • runtime/VM.cpp:

(JSC::appendSourceToError):
(JSC::VM::throwException):

LayoutTests:

  • fast/dom/NodeList/nodelist-item-call-as-function-expected.txt:
  • fast/dom/call-a-constructor-as-a-function-expected.txt:
  • fast/regex/dom/cross-frame-callable-expected.txt:
  • fast/selectors/closest-general-expected.txt:
  • http/tests/security/xss-DENIED-window-index-assign-expected.txt:
  • js/dom/exception-thrown-from-new-expected.txt:
  • js/exception-for-nonobject-expected.txt:
  • js/exception-function-apply-expected.txt: Added.
  • js/exception-function-apply.html: Added.
  • js/exception-in-expected.txt: Added.
  • js/exception-in.html: Added.
  • js/exception-instanceof-expected.txt: Added.
  • js/exception-instanceof.html: Added.
  • js/instance-of-immediates-expected.txt:
  • js/script-tests/exception-function-apply.js: Added.
  • js/script-tests/exception-in.js: Added.
  • js/script-tests/exception-instanceof.js: Added.
  • js/typedarray-constructors-expected.txt:
  • platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-expected.txt:
  • platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt:
  • platform/mac/css3/selectors3/xhtml/css3-modsel-15c-expected.txt:
  • platform/mac/css3/selectors3/xml/css3-modsel-15c-expected.txt:
  • plugins/npruntime/object-from-destroyed-plugin-expected.txt:
  • plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt:
  • plugins/npruntime/plugin-scriptable-object-invoke-default-expected.txt:
  • sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt:
  • sputnik/Conformance/13_Function_Definition/S13_A17_T2-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A2_T1-expected.txt:
  • sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A3-expected.txt:
  • svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt:
File:
1 edited

Legend:

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

    r180460 r181889  
    14721472    if (info.implementsHasInstance())
    14731473        return methodTable(vm)->customHasInstance(this, exec, value);
    1474     vm.throwException(exec, createInvalidParameterError(exec, "instanceof" , this));
     1474    vm.throwException(exec, createInvalidInstanceofParameterError(exec, this));
    14751475    return false;
    14761476}
Note: See TracChangeset for help on using the changeset viewer.