Add support for Error.captureStackTrace#16790
Merged
webkit-commit-queue merged 1 commit intoAug 17, 2023
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 448a461) Details |
448a461 to
e125c84
Compare
Collaborator
|
EWS run on previous version of this PR (hash e125c84) Details |
e125c84 to
a23a602
Compare
Collaborator
|
EWS run on current version of this PR (hash a23a602) Details |
https://bugs.webkit.org/show_bug.cgi?id=260326 rdar://113767788 Reviewed by Yusuke Suzuki. This change adds support for the Error.captureStackTrace extension. We mostly want it because web tooling benchamrk uses it in the hot path of the chai-wtb test, where having native Error.captureStackTrace is a 5% progression over the polyfill. Error.captureStackTrace(obj[, caller]) sets the "stack" property on obj with a string of the current callstack. If caller is provided then any frames above (textually, below in the machine stack) or at the first reference to caller are omitted from the trace. Our implementation should behave the same as v8's with two exceptions: 1) The stack trace is formatted the same as our Error.stack, not v8's. 2) v8 makes the stack property a getter/setter whereas we make it a data property, like our Error object. * Source/JavaScriptCore/interpreter/Interpreter.cpp: (JSC::Interpreter::getStackTrace): * Source/JavaScriptCore/interpreter/Interpreter.h: * Source/JavaScriptCore/runtime/CommonIdentifiers.h: * Source/JavaScriptCore/runtime/Error.cpp: (JSC::getStackTrace): * Source/JavaScriptCore/runtime/ErrorConstructor.cpp: (JSC::ErrorConstructor::finishCreation): (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/267010@main
a23a602 to
997e074
Compare
Collaborator
|
Committed 267010@main (997e074): https://commits.webkit.org/267010@main Reviewed commits have been landed. Closing PR #16790 and removing active labels. |
|
There's a second argument along with Error.prepareStackTrace which allows custom formatting. More complicated though |
Contributor
Author
|
Interesting! I missed Error.prepareStackTrace when I was reading about v8 errors. Do you think Error.prepareStackTrace is important for compatibility? |
|
It’s important because code which checks for the existence of
Error.captureStackTrace assumes Error.prepareStackTrace is also implemented.
It’s mostly used to get the source origin without constructing the entire
stack trace string, afaik
…On Thu, Aug 17, 2023 at 1:40 PM Keith Miller ***@***.***> wrote:
Interesting! I missed Error.prepareStackTrace when I was reading about v8
errors. Do you think Error.prepareStackTrace is important for compatibility?
—
Reply to this email directly, view it on GitHub
<#16790 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFNGS4AQIX767W2OYE55HLXVZ6ULANCNFSM6AAAAAA3UGYYTU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
997e074
a23a602
🧪 wpe-wk2