-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=223302 Reviewed by Yusuke Suzuki. JSTests: Add tests. test262 doesn't currently have any, but the spec is exceedingly simple anyway. * stress/error-cause.js: Added. Source/JavaScriptCore: This patch implements the Error.prototype.cause proposal, which reached Stage 3 at last week's TC39 meeting: https://github.com/tc39/proposal-error-cause This very simple proposal allows to one reference the "error that caused this one" in a cascading scenario. It does so by adding an options bag parameter to the Error, _NativeError_, and AggregateError constructors. If it is an object with a `cause` property, the property will be used; if not, nothing happens at all. * API/JSObjectRef.cpp: (JSObjectMakeError): * runtime/AggregateError.cpp: (JSC::AggregateError::finishCreation): (JSC::AggregateError::create): * runtime/AggregateError.h: * runtime/AggregateErrorConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/CommonIdentifiers.h: * runtime/Error.cpp: (JSC::createError): (JSC::createEvalError): (JSC::createRangeError): (JSC::createReferenceError): (JSC::createSyntaxError): (JSC::createTypeError): (JSC::createURIError): (JSC::createGetterTypeError): * runtime/ErrorConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/ErrorInstance.cpp: (JSC::ErrorInstance::create): (JSC::ErrorInstance::finishCreation): * runtime/ErrorInstance.h: (JSC::ErrorInstance::create): * runtime/JSGlobalObjectFunctions.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor<errorType>::constructImpl): (JSC::NativeErrorConstructor<errorType>::callImpl): * runtime/NullSetterFunction.cpp: (JSC::NullSetterFunctionInternal::JSC_DEFINE_HOST_FUNCTION): * wasm/js/JSWebAssemblyCompileError.cpp: (JSC::JSWebAssemblyCompileError::create): * wasm/js/JSWebAssemblyLinkError.cpp: (JSC::JSWebAssemblyLinkError::create): * wasm/js/JSWebAssemblyRuntimeError.cpp: (JSC::JSWebAssemblyRuntimeError::create): * wasm/js/WebAssemblyCompileErrorConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * wasm/js/WebAssemblyLinkErrorConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/235397@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
21 changed files
with
155 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
2021-03-16 Ross Kirsling <[email protected]> | ||
|
||
[JSC] Implement Error#cause | ||
https://bugs.webkit.org/show_bug.cgi?id=223302 | ||
|
||
Reviewed by Yusuke Suzuki. | ||
|
||
Add tests. test262 doesn't currently have any, but the spec is exceedingly simple anyway. | ||
|
||
* stress/error-cause.js: Added. | ||
|
||
2021-03-16 Saam Barati <[email protected]> | ||
|
||
Object allocation sinking phase should prioritize materializations with no dependencies before materializations with no reverse dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error(`expected ${expected} but got ${actual}`); | ||
} | ||
|
||
const errorConstructors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError, AggregateError]; | ||
const constructError = (E, ...args) => E === AggregateError ? new E([], '', ...args) : new E('', ...args); | ||
|
||
for (const E of errorConstructors) { | ||
shouldBe(constructError(E).cause, undefined); | ||
shouldBe(constructError(E, undefined).cause, undefined); | ||
shouldBe(constructError(E, null).cause, undefined); | ||
shouldBe(constructError(E, true).cause, undefined); | ||
shouldBe(constructError(E, 3).cause, undefined); | ||
shouldBe(constructError(E, 'hi').cause, undefined); | ||
shouldBe(constructError(E, {}).cause, undefined); | ||
|
||
shouldBe(constructError(E, { cause: undefined }).cause, undefined); | ||
shouldBe(constructError(E, { cause: null }).cause, null); | ||
shouldBe(constructError(E, { cause: true }).cause, true); | ||
shouldBe(constructError(E, { cause: 3 }).cause, 3); | ||
shouldBe(constructError(E, { cause: 'hi' }).cause, 'hi'); | ||
|
||
const cause = new Error(); | ||
shouldBe(constructError(E, { cause }).cause, cause); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,62 @@ | ||
2021-03-16 Ross Kirsling <[email protected]> | ||
|
||
[JSC] Implement Error#cause | ||
https://bugs.webkit.org/show_bug.cgi?id=223302 | ||
|
||
Reviewed by Yusuke Suzuki. | ||
|
||
This patch implements the Error.prototype.cause proposal, which reached Stage 3 at last week's TC39 meeting: | ||
https://github.com/tc39/proposal-error-cause | ||
|
||
This very simple proposal allows to one reference the "error that caused this one" in a cascading scenario. | ||
It does so by adding an options bag parameter to the Error, _NativeError_, and AggregateError constructors. | ||
If it is an object with a `cause` property, the property will be used; if not, nothing happens at all. | ||
|
||
* API/JSObjectRef.cpp: | ||
(JSObjectMakeError): | ||
* runtime/AggregateError.cpp: | ||
(JSC::AggregateError::finishCreation): | ||
(JSC::AggregateError::create): | ||
* runtime/AggregateError.h: | ||
* runtime/AggregateErrorConstructor.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
* runtime/CommonIdentifiers.h: | ||
* runtime/Error.cpp: | ||
(JSC::createError): | ||
(JSC::createEvalError): | ||
(JSC::createRangeError): | ||
(JSC::createReferenceError): | ||
(JSC::createSyntaxError): | ||
(JSC::createTypeError): | ||
(JSC::createURIError): | ||
(JSC::createGetterTypeError): | ||
* runtime/ErrorConstructor.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
* runtime/ErrorInstance.cpp: | ||
(JSC::ErrorInstance::create): | ||
(JSC::ErrorInstance::finishCreation): | ||
* runtime/ErrorInstance.h: | ||
(JSC::ErrorInstance::create): | ||
* runtime/JSGlobalObjectFunctions.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
* runtime/NativeErrorConstructor.cpp: | ||
(JSC::NativeErrorConstructor<errorType>::constructImpl): | ||
(JSC::NativeErrorConstructor<errorType>::callImpl): | ||
* runtime/NullSetterFunction.cpp: | ||
(JSC::NullSetterFunctionInternal::JSC_DEFINE_HOST_FUNCTION): | ||
* wasm/js/JSWebAssemblyCompileError.cpp: | ||
(JSC::JSWebAssemblyCompileError::create): | ||
* wasm/js/JSWebAssemblyLinkError.cpp: | ||
(JSC::JSWebAssemblyLinkError::create): | ||
* wasm/js/JSWebAssemblyRuntimeError.cpp: | ||
(JSC::JSWebAssemblyRuntimeError::create): | ||
* wasm/js/WebAssemblyCompileErrorConstructor.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
* wasm/js/WebAssemblyLinkErrorConstructor.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
* wasm/js/WebAssemblyRuntimeErrorConstructor.cpp: | ||
(JSC::JSC_DEFINE_HOST_FUNCTION): | ||
|
||
2021-03-16 Saam Barati <[email protected]> | ||
|
||
Object allocation sinking phase should prioritize materializations with no dependencies before materializations with no reverse dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.