tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 37689855e101170fedf1c99f590b89750a01e9d8
parent 9f088561c1523d1bd46e310cc738ebd6b7eadd0c
Author: Atila Butkovits <abutkovits@mozilla.com>
Date:   Thu, 20 Nov 2025 18:12:03 +0200

Revert "Bug 1989115 - Avoid OOM stack trace at certain times r=jandem" for causing various performance regressions.

This reverts commit 2e87317ac55e46b74e2ec7095c655fa09dc3cae2.

Revert "Bug 1989115 - Remove UnsafeABIStrictness::AllowThrownExceptions r=mgaudet"

This reverts commit 5a1f649191a902e103679b4edec73a7d7f5d4999.

Revert "Bug 1989115 - Implement OOM stack trace capture r=jandem"

This reverts commit 4f122ff84138a07a04e912280e0dda1b3f4b4b1c.

Revert "Bug 1989115 - Add FixedBufferPrinter r=mgaudet"

This reverts commit f7ba505d3dbc5a4f91240c1fedbf6b245f18d20b.

Revert "Bug 1989115 - Track unsafe call with ABI state in release r=mgaudet,rhunt"

This reverts commit b46ba4b78eb9ff83adf03bbf09e8c45f058d55ba.

Diffstat:
Mjs/public/Printer.h | 22----------------------
Mjs/src/builtin/TestingFunctions.cpp | 32--------------------------------
Djs/src/jit-test/tests/test_oom_comprehensive.js | 33---------------------------------
Mjs/src/jit/BaselineBailouts.cpp | 2--
Mjs/src/jit/BaselineDebugModeOSR.cpp | 3---
Mjs/src/jit/MacroAssembler.cpp | 12+++++++++++-
Mjs/src/jit/MacroAssembler.h | 2+-
Mjs/src/jsapi-tests/moz.build | 1-
Djs/src/jsapi-tests/testPrinter.cpp | 111-------------------------------------------------------------------------------
Mjs/src/vm/JSContext.cpp | 82++++++++++---------------------------------------------------------------------
Mjs/src/vm/JSContext.h | 43++++++++++++++-----------------------------
Mjs/src/vm/Printer.cpp | 8--------
Mjs/src/wasm/WasmBuiltins.cpp | 3---
Mmodules/libpref/init/StaticPrefList.yaml | 11++---------
14 files changed, 38 insertions(+), 327 deletions(-)

diff --git a/js/public/Printer.h b/js/public/Printer.h @@ -323,28 +323,6 @@ class JS_PUBLIC_API JSSprinter : public StringPrinter { JSString* release(JSContext* cx) { return releaseJS(cx); } }; -// FixedBufferPrinter, print to a fixed-size buffer. The string in the buffer -// will always be null-terminated after being passed to the constructor. -class FixedBufferPrinter final : public GenericPrinter { - private: - // The first char in the buffer where put will append the next string - char* buffer_; - // The remaining size available in the buffer - size_t size_; - - public: - constexpr FixedBufferPrinter(char* buf, size_t size) - : buffer_(buf), size_(size) { - MOZ_ASSERT(buffer_); - memset(buffer_, 0, size_); - } - - // Puts |len| characters from |s| at the current position. - // If the buffer fills up, this won't do anything. - void put(const char* s, size_t len) override; - using GenericPrinter::put; // pick up |put(const char* s);| -}; - // Fprinter, print a string directly into a file. class JS_PUBLIC_API Fprinter final : public GenericPrinter { private: diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp @@ -10035,32 +10035,6 @@ static bool TestingFunc_SupportDifferentialTesting(JSContext* cx, unsigned argc, return true; } -static bool GetLastOOMStackTrace(JSContext* cx, unsigned argc, Value* vp) { - CallArgs args = CallArgsFromVp(argc, vp); - - if (!cx->hasOOMStackTrace()) { - args.rval().setNull(); - return true; - } - - const char* stackTrace = cx->getOOMStackTrace(); - if (!stackTrace) { - args.rval().setNull(); - return true; - } - - JSString* str = JS_NewStringCopyZ(cx, stackTrace); - if (!str) { - return false; - } - - // Clear the stored OOM stack trace after retrieving it once. - cx->unsetOOMStackTrace(); - - args.rval().setString(str); - return true; -} - // clang-format off static const JSFunctionSpecWithHelp TestingFunctions[] = { JS_FN_HELP("gc", ::GC, 0, 0, @@ -11179,12 +11153,6 @@ JS_FN_HELP("isSmallFunction", IsSmallFunction, 1, 0, "popAllFusesInRealm()", " Pops all the fuses in the current realm"), - JS_FN_HELP("getLastOOMStackTrace", GetLastOOMStackTrace, 0, 0, -"getLastOOMStackTrace()", -" Returns the stack trace captured from the most recent out-of-memory exception,\n" -" or null if no OOM stack trace is available. The stack trace shows the JavaScript\n" -" call stack at the time the out-of-memory condition occurred."), - JS_FN_HELP("popAllFusesInRuntime", PopAllFusesInRuntime, 0, 0, "popAllFusesInRuntime()", " Pops all the fuses in the runtime"), diff --git a/js/src/jit-test/tests/test_oom_comprehensive.js b/js/src/jit-test/tests/test_oom_comprehensive.js @@ -1,32 +0,0 @@ -// |jit-test| --setpref=experimental.capture_oom_stack_trace=true; skip-if: !this.hasOwnProperty("getLastOOMStackTrace") - -function testStack() { - function deepFunction() { - function evenDeeper() { - throwOutOfMemory(); - } - return evenDeeper(); - } - return deepFunction(); -} - -// Clear any existing trace -var initialTrace = getLastOOMStackTrace(); -assertEq(initialTrace, null); - -try { - testStack(); - assertEq(true, false, "Expected an OOM exception"); -} catch (e) { - print("✓ Exception caught: " + e); - - // Check for captured stack trace - var finalTrace = getLastOOMStackTrace(); - assertEq(finalTrace !== null, true, "Expected a stack trace after OOM"); - - print(finalTrace); - - // Detailed analysis - var lines = finalTrace.split('\n').filter(line => line.trim()); - assertEq(finalTrace.includes("#"), true); -} -\ No newline at end of file diff --git a/js/src/jit/BaselineBailouts.cpp b/js/src/jit/BaselineBailouts.cpp @@ -1564,8 +1564,6 @@ bool jit::BailoutIonToBaseline(JSContext* cx, JitActivation* activation, MaybeReadFallback recoverBailout(cx, activation, &iter, MaybeReadFallback::Fallback_DoNothing); - // FrameIter can't walk the stack trace while we are bailing out - AutoUnsafeStackTrace aust(cx); // Ensure that all value locations are readable from the SnapshotIterator. // Get the RInstructionResults from the JitActivation if the frame got // recovered ahead of the bailout. diff --git a/js/src/jit/BaselineDebugModeOSR.cpp b/js/src/jit/BaselineDebugModeOSR.cpp @@ -416,9 +416,6 @@ bool js::jit::RecompileBaselineScriptForDebugMode( observing ? "DEBUGGING" : "NORMAL EXECUTION"); AutoKeepJitScripts keepJitScripts(cx); - // FrameIter can't walk the stack if OOM happens because script doesn't have a - // BaselineScript while we recompile it. - AutoUnsafeStackTrace aust(cx); BaselineScript* oldBaselineScript = script->jitScript()->clearBaselineScript(cx->gcContext(), script); diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp @@ -4934,6 +4934,7 @@ void MacroAssembler::setupAlignedABICall() { dynamicAlignment_ = false; } +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI void MacroAssembler::wasmCheckUnsafeCallWithABIPre() { // Set the JSContext::inUnsafeCallWithABI flag. loadPtr(Address(InstanceReg, wasm::Instance::offsetOfCx()), @@ -4943,7 +4944,6 @@ void MacroAssembler::wasmCheckUnsafeCallWithABIPre() { store32(Imm32(1), flagAddr); } -#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI void MacroAssembler::wasmCheckUnsafeCallWithABIPost() { // Check JSContext::inUnsafeCallWithABI was cleared as expected. Label ok; @@ -5035,6 +5035,7 @@ void MacroAssembler::callWithABINoProfiler(void* fun, ABIType result, uint32_t stackAdjust; callWithABIPre(&stackAdjust); +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI if (check == CheckUnsafeCallWithABI::Check) { // Set the JSContext::inUnsafeCallWithABI flag. push(ReturnReg); @@ -5045,6 +5046,7 @@ void MacroAssembler::callWithABINoProfiler(void* fun, ABIType result, // On arm64, SP may be < PSP now (that's OK). // eg testcase: tests/bug1375074.js } +#endif call(ImmPtr(fun)); @@ -5076,9 +5078,13 @@ CodeOffset MacroAssembler::callWithABI(wasm::BytecodeOffset bytecode, // The instance register is used in builtin thunks and must be set. bool needsBuiltinThunk = wasm::NeedsBuiltinThunk(imm); +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI // The builtin thunk exits the JIT activation, if we don't have one we must // use AutoUnsafeCallWithABI inside the builtin and check that here. bool checkUnsafeCallWithABI = !needsBuiltinThunk; +#else + bool checkUnsafeCallWithABI = false; +#endif if (needsBuiltinThunk || checkUnsafeCallWithABI) { if (instanceOffset) { loadPtr(Address(getStackPointer(), *instanceOffset + stackAdjust), @@ -5088,9 +5094,11 @@ CodeOffset MacroAssembler::callWithABI(wasm::BytecodeOffset bytecode, } } +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI if (checkUnsafeCallWithABI) { wasmCheckUnsafeCallWithABIPre(); } +#endif CodeOffset raOffset = call( wasm::CallSiteDesc(bytecode.offset(), wasm::CallSiteKind::Symbolic), imm); @@ -6432,12 +6440,14 @@ CodeOffset MacroAssembler::wasmCallBuiltinInstanceMethod( MOZ_CRASH("Unknown abi passing style for pointer"); } +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI // The builtin thunk exits the JIT activation, if we don't have one we must // use AutoUnsafeCallWithABI inside the builtin and check that here. bool checkUnsafeCallWithABI = !wasm::NeedsBuiltinThunk(builtin); if (checkUnsafeCallWithABI) { wasmCheckUnsafeCallWithABIPre(); } +#endif CodeOffset ret = call(desc, builtin); diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h @@ -836,9 +836,9 @@ class MacroAssembler : public MacroAssemblerSpecific { void callWithABIPost(uint32_t stackAdjust, ABIType result, bool callFromWasm = false) PER_ARCH; +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI // Set the JSContext::inUnsafeCallWithABI flag using InstanceReg. void wasmCheckUnsafeCallWithABIPre(); -#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI // Check JSContext::inUnsafeCallWithABI was cleared as expected. void wasmCheckUnsafeCallWithABIPost(); #endif diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build @@ -108,7 +108,6 @@ UNIFIED_SOURCES += [ "testParserAtom.cpp", "testPersistentRooted.cpp", "testPreserveJitCode.cpp", - "testPrinter.cpp", "testPrintf.cpp", "testPrivateGCThingValue.cpp", "testProfileStrings.cpp", diff --git a/js/src/jsapi-tests/testPrinter.cpp b/js/src/jsapi-tests/testPrinter.cpp @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: set ts=8 sts=2 et sw=2 tw=80: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "js/Printer.h" // FixedBufferPrinter - -#include "jsapi-tests/tests.h" - -using namespace js; - -struct TestBuffer { - const char ASCII_ACK = (char)6; - - char* buffer; - size_t size; - - // len is the buffer size, including terminating null - explicit TestBuffer(const size_t len) : buffer(new char[len + 3]), size(len) { - buffer[size] = ASCII_ACK; // to detect overflow - buffer[size + 1] = ASCII_ACK; - buffer[size + 2] = ASCII_ACK; - } - - ~TestBuffer() { delete[] buffer; } - - // test has written past the end of the buffer - bool hasOverflowed() { - return buffer[size] != ASCII_ACK || buffer[size + 1] != ASCII_ACK || - buffer[size + 2] != ASCII_ACK; - } - - bool matches(const char* expected) { return strcmp(buffer, expected) == 0; } -}; - -BEGIN_TEST(testFixedBufferPrinter) { - // empty buffer - { - TestBuffer actual(0); - FixedBufferPrinter fbp(actual.buffer, 0); - fbp.put("will not fit"); - CHECK(!actual.hasOverflowed()); - } - // buffer is initially null-terminated - { - TestBuffer actual(10); - // make sure the buffer is not null-terminated - memset(actual.buffer, '!', actual.size); - FixedBufferPrinter fbp(actual.buffer, 10); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches("")); - } - // one put that fits - { - TestBuffer actual(50); - FixedBufferPrinter fbp(actual.buffer, actual.size); - const char* expected = "expected string fits"; - fbp.put(expected); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches(expected)); - } - // unterminated string in put - { - TestBuffer actual(50); - FixedBufferPrinter fbp(actual.buffer, actual.size); - const char* expected = "okBAD"; - fbp.put(expected, 2); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches("ok")); - } - // one put that more than fills the buffer - { - TestBuffer actual(16); - FixedBufferPrinter fbp(actual.buffer, actual.size); - const char* expected = "expected string overflow"; - fbp.put(expected); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches("expected string")); - } - // maintains position over multiple puts that fit - { - TestBuffer actual(16); - FixedBufferPrinter fbp(actual.buffer, actual.size); - fbp.put("expected "); - fbp.put("string"); - CHECK(actual.matches("expected string")); - } - // multiple puts, last one more than fills the buffer - { - TestBuffer actual(9); - FixedBufferPrinter fbp(actual.buffer, actual.size); - fbp.put("expected"); - fbp.put("overflow"); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches("expected")); - } - // put after buffer is full doesn't overflow - { - TestBuffer actual(2); - FixedBufferPrinter fbp(actual.buffer, actual.size); - fbp.put("exp"); - fbp.put("overflow"); - CHECK(!actual.hasOverflowed()); - CHECK(actual.matches("e")); - } - - return true; -} -END_TEST(testFixedBufferPrinter) diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp @@ -56,9 +56,7 @@ #include "util/NativeStack.h" #include "util/Text.h" #include "util/WindowsWrapper.h" -#include "js/friend/DumpFunctions.h" // for stack trace utilities -#include "js/Printer.h" // for FixedBufferPrinter -#include "vm/BytecodeUtil.h" // JSDVG_IGNORE_STACK +#include "vm/BytecodeUtil.h" // JSDVG_IGNORE_STACK #include "vm/ErrorObject.h" #include "vm/ErrorReporting.h" #include "vm/FrameIter.h" @@ -268,12 +266,6 @@ static void MaybeReportOutOfMemoryForDifferentialTesting() { } } -bool JSContext::safeToCaptureStackTrace() const { - // If we're in an unsafe ABI context, we don't need to capture a stack trace - // because the function will explicitly recover from OOM. - return !inUnsafeCallWithABI && !unsafeToCaptureStackTrace; -} - /* * Since memory has been exhausted, avoid the normal error-handling path which * allocates an error object, report and callstack. Instead simply throw the @@ -286,9 +278,6 @@ void JSContext::onOutOfMemory() { runtime()->hadOutOfMemory = true; gc::AutoSuppressGC suppressGC(this); - // Capture stack trace before doing anything else that might use memory. - maybeCaptureOOMStackTrace(); - /* Report the oom. */ if (JS::OutOfMemoryCallback oomCallback = runtime()->oomCallback) { oomCallback(this, runtime()->oomCallbackData); @@ -1238,9 +1227,10 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options) activation_(this, nullptr), profilingActivation_(nullptr), noExecuteDebuggerTop(this, nullptr), - unsafeToCaptureStackTrace(this, false), +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI inUnsafeCallWithABI(this, false), hasAutoUnsafeCallWithABI(this, false), +#endif #ifdef DEBUG liveArraySortDataInstances(this, 0), #endif @@ -1302,17 +1292,9 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options) canSkipEnqueuingJobs(this, false), promiseRejectionTrackerCallback(this, nullptr), promiseRejectionTrackerCallbackData(this, nullptr), - oomStackTraceBuffer_(this, nullptr), - oomStackTraceBufferValid_(this, false), insideExclusiveDebuggerOnEval(this, nullptr) { MOZ_ASSERT(static_cast<JS::RootingContext*>(this) == JS::RootingContext::get(this)); - - if (JS::Prefs::experimental_capture_oom_stack_trace()) { - // Allocate pre-allocated buffer for OOM stack traces - oomStackTraceBuffer_ = - static_cast<char*>(js_calloc(OOMStackTraceBufferSize)); - } } JSContext::~JSContext() { @@ -1342,45 +1324,9 @@ JSContext::~JSContext() { irregexp::DestroyIsolate(isolate.ref()); } - // Free the pre-allocated OOM stack trace buffer - if (oomStackTraceBuffer_) { - js_free(oomStackTraceBuffer_); - } - TlsContext.set(nullptr); } -void JSContext::unsetOOMStackTrace() { oomStackTraceBufferValid_ = false; } - -const char* JSContext::getOOMStackTrace() const { - if (!oomStackTraceBufferValid_ || !oomStackTraceBuffer_) { - return nullptr; - } - return oomStackTraceBuffer_; -} - -bool JSContext::hasOOMStackTrace() const { return oomStackTraceBufferValid_; } - -void JSContext::maybeCaptureOOMStackTrace() { - // Clear any existing stack trace - oomStackTraceBufferValid_ = false; - - if (!oomStackTraceBuffer_) { - return; // Buffer not available - } - - // Write directly to pre-allocated buffer to avoid any memory allocation - FixedBufferPrinter fbp(oomStackTraceBuffer_, OOMStackTraceBufferSize); - if (safeToCaptureStackTrace()) { - js::DumpBacktrace(this, fbp); - } else { - fbp.put("Unsafe to capture stack trace"); - } - - MOZ_ASSERT(strlen(oomStackTraceBuffer_) < OOMStackTraceBufferSize); - oomStackTraceBufferValid_ = true; -} - void JSContext::setRuntime(JSRuntime* rt) { MOZ_ASSERT(!resolvingList); MOZ_ASSERT(!compartment()); @@ -1759,16 +1705,7 @@ void JSContext::suspendExecutionTracing() { #endif -AutoUnsafeStackTrace::AutoUnsafeStackTrace(JSContext* cx) - : cx_(cx), nested_(cx_->unsafeToCaptureStackTrace) { - cx_->unsafeToCaptureStackTrace = true; -} - -AutoUnsafeStackTrace::~AutoUnsafeStackTrace() { - if (!nested_) { - cx_->unsafeToCaptureStackTrace = false; - } -} +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI AutoUnsafeCallWithABI::AutoUnsafeCallWithABI(UnsafeABIStrictness strictness) : cx_(TlsContext.get()), @@ -1778,7 +1715,6 @@ AutoUnsafeCallWithABI::AutoUnsafeCallWithABI(UnsafeABIStrictness strictness) // This is a helper thread doing Ion or Wasm compilation - nothing to do. return; } -#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI switch (strictness) { case UnsafeABIStrictness::NoExceptions: MOZ_ASSERT(!JS_IsExceptionPending(cx_)); @@ -1787,8 +1723,10 @@ AutoUnsafeCallWithABI::AutoUnsafeCallWithABI(UnsafeABIStrictness strictness) case UnsafeABIStrictness::AllowPendingExceptions: checkForPendingException_ = !JS_IsExceptionPending(cx_); break; + case UnsafeABIStrictness::AllowThrownExceptions: + checkForPendingException_ = false; + break; } -#endif cx_->hasAutoUnsafeCallWithABI = true; } @@ -1797,16 +1735,16 @@ AutoUnsafeCallWithABI::~AutoUnsafeCallWithABI() { if (!cx_) { return; } -#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI MOZ_ASSERT(cx_->hasAutoUnsafeCallWithABI); - MOZ_ASSERT_IF(checkForPendingException_, !JS_IsExceptionPending(cx_)); -#endif if (!nested_) { cx_->hasAutoUnsafeCallWithABI = false; cx_->inUnsafeCallWithABI = false; } + MOZ_ASSERT_IF(checkForPendingException_, !JS_IsExceptionPending(cx_)); } +#endif // JS_CHECK_UNSAFE_CALL_WITH_ABI + #ifdef __wasi__ JS_PUBLIC_API void js::IncWasiRecursionDepth(JSContext* cx) { ++JS::RootingContext::get(cx)->wasiRecursionDepth; diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h @@ -280,8 +280,6 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, return thing->compartment() == compartment(); } - bool safeToCaptureStackTrace() const; - void onOutOfMemory(); void* onOutOfMemory(js::AllocFunction allocFunc, arena_id_t arena, size_t nbytes, void* reallocPtr = nullptr) { @@ -460,9 +458,11 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, return offsetof(JSContext, jitActivation); } +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI static size_t offsetOfInUnsafeCallWithABI() { return offsetof(JSContext, inUnsafeCallWithABI); } +#endif public: js::InterpreterStack& interpreterStack() { @@ -501,9 +501,10 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, */ js::ContextData<js::EnterDebuggeeNoExecute*> noExecuteDebuggerTop; - js::ContextData<bool> unsafeToCaptureStackTrace; +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI js::ContextData<uint32_t> inUnsafeCallWithABI; js::ContextData<bool> hasAutoUnsafeCallWithABI; +#endif #ifdef DEBUG js::ContextData<uint32_t> liveArraySortDataInstances; @@ -704,12 +705,6 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, #endif } - // OOM stack trace buffer management - void unsetOOMStackTrace(); - const char* getOOMStackTrace() const; - bool hasOOMStackTrace() const; - void maybeCaptureOOMStackTrace(); - js::ContextData<int32_t> reportGranularity; /* see vm/Probes.h */ js::ContextData<js::AutoResolving*> resolvingList; @@ -982,14 +977,6 @@ struct JS_PUBLIC_API JSContext : public JS::RootingContext, promiseRejectionTrackerCallback; js::ContextData<void*> promiseRejectionTrackerCallbackData; - // Pre-allocated buffer for storing out-of-memory stack traces. - // This buffer is allocated during context initialization to avoid - // allocation during OOM conditions. The buffer stores a formatted - // stack trace string that can be retrieved by privileged JavaScript. - static constexpr size_t OOMStackTraceBufferSize = 4096; - js::ContextData<char*> oomStackTraceBuffer_; - js::ContextData<bool> oomStackTraceBufferValid_; - JSObject* getIncumbentGlobal(JSContext* cx); bool enqueuePromiseJob(JSContext* cx, js::HandleFunction job, js::HandleObject promise, @@ -1214,19 +1201,12 @@ class MOZ_RAII AutoNoteExclusiveDebuggerOnEval { } }; -// Should be used in functions that manipulate the stack so FrameIter is unable -// to iterate over it. -class MOZ_RAII AutoUnsafeStackTrace { - JSContext* cx_; - bool nested_; - - public: - explicit AutoUnsafeStackTrace(JSContext* cx); - ~AutoUnsafeStackTrace(); +enum UnsafeABIStrictness { + NoExceptions, + AllowPendingExceptions, + AllowThrownExceptions }; -enum UnsafeABIStrictness { NoExceptions, AllowPendingExceptions }; - // Should be used in functions called directly from JIT code (with // masm.callWithABI). This assert invariants in debug builds. Resets // JSContext::inUnsafeCallWithABI on destruction. @@ -1243,17 +1223,22 @@ enum UnsafeABIStrictness { NoExceptions, AllowPendingExceptions }; // the function is not called with a pending exception, and that it does not // throw an exception itself. class MOZ_RAII AutoUnsafeCallWithABI { +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI JSContext* cx_; bool nested_; -#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI bool checkForPendingException_; #endif JS::AutoCheckCannotGC nogc; public: +#ifdef JS_CHECK_UNSAFE_CALL_WITH_ABI explicit AutoUnsafeCallWithABI( UnsafeABIStrictness strictness = UnsafeABIStrictness::NoExceptions); ~AutoUnsafeCallWithABI(); +#else + explicit AutoUnsafeCallWithABI( + UnsafeABIStrictness unused_ = UnsafeABIStrictness::NoExceptions) {} +#endif }; template <typename T> diff --git a/js/src/vm/Printer.cpp b/js/src/vm/Printer.cpp @@ -497,14 +497,6 @@ void LSprinter::clear() { hadOOM_ = false; } -void FixedBufferPrinter::put(const char* s, size_t len) { - snprintf(buffer_, size_, "%.*s", int(len), s); - size_t written = std::min(len, size_); - MOZ_ASSERT(size_ >= written); - size_ -= written; - buffer_ += written; -} - void LSprinter::put(const char* s, size_t len) { if (hadOutOfMemory()) { return; diff --git a/js/src/wasm/WasmBuiltins.cpp b/js/src/wasm/WasmBuiltins.cpp @@ -1138,9 +1138,6 @@ static int32_t CoerceInPlace_JitEntry(int funcIndex, Instance* instance, // Allocate a BigInt without GC, corresponds to the similar VMFunction. static BigInt* AllocateBigIntTenuredNoGC() { JSContext* cx = TlsContext.get(); // Cold code (the caller is elaborate) - // WasmFrameIter doesn't know how to walk the stack from here (see bug - // 1999042), so we can't capture a stack trace if we OOM - AutoUnsafeStackTrace aust(cx); BigInt* bi = cx->newCell<BigInt, NoGC>(gc::Heap::Tenured); if (!bi) { diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -9024,21 +9024,14 @@ mirror: always set_spidermonkey_pref: startup - # Experimental support for Iterator Chunking in JavaScript. + # Experimental support for Iterator Chunking in JavaScript. - name: javascript.options.experimental.iterator_chunking type: bool value: false mirror: always set_spidermonkey_pref: startup - #endif // NIGHTLY_BUILD - - # Capture stack traces for OOM -- name: javascript.options.experimental.capture_oom_stack_trace - type: bool - value: @IS_NIGHTLY_BUILD@ - mirror: always - set_spidermonkey_pref: startup +#endif // NIGHTLY_BUILD # Whether to Baseline-compile self-hosted functions the first time they are # used and cache the result.