[webkit-changes] [WebKit/WebKit] 997e07: Add support for Error.captureStackTrace

Keith Miller noreply at github.com
Thu Aug 17 13:06:02 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 997e074bb35ed07b69c9b821141c91dd548e0d02
      https://github.com/WebKit/WebKit/commit/997e074bb35ed07b69c9b821141c91dd548e0d02
  Author: Keith Miller <keith_miller at apple.com>
  Date:   2023-08-17 (Thu, 17 Aug 2023)

  Changed paths:
    A JSTests/stress/captureStackTrace-on-error-object.js
    A JSTests/stress/captureStackTrace.js
    M LayoutTests/js/Object-getOwnPropertyNames-expected.txt
    M LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
    M Source/JavaScriptCore/interpreter/Interpreter.cpp
    M Source/JavaScriptCore/interpreter/Interpreter.h
    M Source/JavaScriptCore/runtime/CommonIdentifiers.h
    M Source/JavaScriptCore/runtime/Error.cpp
    M Source/JavaScriptCore/runtime/ErrorConstructor.cpp

  Log Message:
  -----------
  Add support for Error.captureStackTrace
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




More information about the webkit-changes mailing list