From 99af827f25bc051061a07b162b812884d6106a9a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 10 Aug 2023 19:55:14 -0700 Subject: More lazily initialize these static strings --- src/bun.js/bindings/ErrorStackTrace.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/bun.js/bindings/ErrorStackTrace.cpp') diff --git a/src/bun.js/bindings/ErrorStackTrace.cpp b/src/bun.js/bindings/ErrorStackTrace.cpp index 59e0e765b..a8c5b65d8 100644 --- a/src/bun.js/bindings/ErrorStackTrace.cpp +++ b/src/bun.js/bindings/ErrorStackTrace.cpp @@ -213,10 +213,11 @@ JSCStackFrame::SourcePositions* JSCStackFrame::getSourcePositions() return (SourcePositionsState::Calculated == m_sourcePositionsState) ? &m_sourcePositions : nullptr; } -static auto sourceURLWasmString = MAKE_STATIC_STRING_IMPL("[wasm code]"); -static auto sourceURLNativeString = MAKE_STATIC_STRING_IMPL("[native code]"); ALWAYS_INLINE JSC::JSString* JSCStackFrame::retrieveSourceURL() { + static auto sourceURLWasmString = MAKE_STATIC_STRING_IMPL("[wasm code]"); + static auto sourceURLNativeString = MAKE_STATIC_STRING_IMPL("[native code]"); + if (m_isWasmFrame) { return jsOwnedString(m_vm, sourceURLWasmString); } @@ -229,11 +230,12 @@ ALWAYS_INLINE JSC::JSString* JSCStackFrame::retrieveSourceURL() return sourceURL.isNull() ? m_vm.smallStrings.emptyString() : JSC::jsString(m_vm, sourceURL); } -static auto functionNameEvalCodeString = MAKE_STATIC_STRING_IMPL("eval code"); -static auto functionNameModuleCodeString = MAKE_STATIC_STRING_IMPL("module code"); -static auto functionNameGlobalCodeString = MAKE_STATIC_STRING_IMPL("global code"); ALWAYS_INLINE JSC::JSString* JSCStackFrame::retrieveFunctionName() { + static auto functionNameEvalCodeString = MAKE_STATIC_STRING_IMPL("eval code"); + static auto functionNameModuleCodeString = MAKE_STATIC_STRING_IMPL("module code"); + static auto functionNameGlobalCodeString = MAKE_STATIC_STRING_IMPL("global code"); + if (m_isWasmFrame) { return jsString(m_vm, JSC::Wasm::makeString(m_wasmFunctionIndexOrName)); } -- cgit v1.2.3