diff options
author | 2022-11-09 00:37:57 -0800 | |
---|---|---|
committer | 2022-11-09 00:37:57 -0800 | |
commit | 047a8d3f0d39118ded97f693d4e4a7cb23e8c6a4 (patch) | |
tree | 47ed7e03743f2ca060c9c99b64d8ebb91b8118f2 /src/bun.js/bindings/ZigGlobalObject.h | |
parent | 2c4777f579041d86b20e78ba6f519863ad3a6a13 (diff) | |
download | bun-047a8d3f0d39118ded97f693d4e4a7cb23e8c6a4.tar.gz bun-047a8d3f0d39118ded97f693d4e4a7cb23e8c6a4.tar.zst bun-047a8d3f0d39118ded97f693d4e4a7cb23e8c6a4.zip |
Error.captureStackTrace implementation (#1476)
* capture stack trace formatting, tests
* fix callsite methods, stack formatting or undefined
* isNative, tests for callsite methods
* Update src/bun.js/bindings/ZigGlobalObject.cpp
* Update src/bun.js/bindings/ZigGlobalObject.cpp
* template and macros for visitchildren
* static strings, handle infinity and clamp stacktracelimit
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.h')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index 8613bc912..68fa452b2 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -34,6 +34,10 @@ class EventLoopTask; #include "DOMIsoSubspaces.h" #include "BunPlugin.h" +#include "ErrorStackTrace.h" +#include "CallSite.h" +#include "CallSitePrototype.h" + extern "C" void Bun__reportError(JSC__JSGlobalObject*, JSC__JSValue); // defined in ModuleLoader.cpp extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultResolve(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame); @@ -58,6 +62,8 @@ extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultReject(JSC::JSGlobalO namespace Zig { +class JSCStackTrace; + using JSDOMStructureMap = HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::Structure>>; using DOMGuardedObjectSet = HashSet<WebCore::DOMGuardedObject*>; @@ -153,6 +159,9 @@ public: void clearDOMGuardedObjects(); + static void createCallSitesFromFrames(JSC::JSGlobalObject* lexicalGlobalObject, JSC::ObjectInitializationScope& objectScope, JSCStackTrace& stackTrace, JSC::JSArray* callSites); + JSC::JSValue formatStackTrace(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* errorObject, JSC::JSArray* callSites, ZigStackFrame remappedStackFrames[]); + static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, JSC::Exception*); static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObject); static void queueMicrotaskToEventLoop(JSC::JSGlobalObject& global, Ref<JSC::Microtask>&& task); @@ -218,6 +227,8 @@ public: JSC::JSMap* requireMap() { return m_requireMap.getInitializedOnMainThread(this); } JSC::JSObject* encodeIntoObjectPrototype() { return m_encodeIntoObjectPrototype.getInitializedOnMainThread(this); } + JSC::Structure* callSiteStructure() const { return m_callSiteStructure.getInitializedOnMainThread(this); } + JSC::JSObject* performanceObject() { return m_performanceObject.getInitializedOnMainThread(this); } JSC::JSObject* primordialsObject() { return m_primordialsObject.getInitializedOnMainThread(this); } @@ -441,6 +452,7 @@ private: LazyClassStructure m_JSStringDecoderClassStructure; LazyClassStructure m_NapiClassStructure; LazyClassStructure m_OnigurumaRegExpClassStructure; + LazyClassStructure m_callSiteStructure; /** * WARNING: You must update visitChildrenImpl() if you add a new field. |