diff --git a/js/src/builtin/Eval.cpp b/js/src/builtin/Eval.cpp index 46e983e77416..0de005ec08d4 100644 --- a/js/src/builtin/Eval.cpp +++ b/js/src/builtin/Eval.cpp @@ -426,7 +426,7 @@ bool js::DirectEval(JSContext* cx, HandleValue v, MutableHandleValue vp) { // Direct eval can assume it was called from an interpreted or baseline frame. - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); AbstractFramePtr caller = iter.abstractFramePtr(); MOZ_ASSERT(JSOp(*iter.pc()) == JSOP_EVAL || diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 721e97b5c9c7..c4853839699d 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -1730,7 +1730,7 @@ ShellAllocationMetadataBuilder::build(JSContext* cx, HandleObject, int stackIndex = 0; RootedId id(cx); RootedValue callee(cx); - for (NonBuiltinScriptFrameIter iter(cx); !iter.done(); ++iter) { + for (NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); !iter.done(); ++iter) { if (iter.isFunctionFrame() && iter.compartment() == cx->compartment()) { id = INT_TO_JSID(stackIndex); RootedObject callee(cx, iter.callee(cx)); @@ -1841,7 +1841,7 @@ testingFunc_inIon(JSContext* cx, unsigned argc, Value* vp) return true; } - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (iter.isIon()) { // Reset the counter of the IonScript's script. jit::JitFrameIterator jitIter(cx); diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp index 67622f8c306b..e45f5a3913ec 100644 --- a/js/src/jit/Ion.cpp +++ b/js/src/jit/Ion.cpp @@ -2842,7 +2842,7 @@ jit::SetEnterJitData(JSContext* cx, EnterJitData& data, RunState& state, if (!vals.reserve(1)) return false; - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); data.maxArgc = 1; data.maxArgv = vals.begin(); if (state.asExecute()->newTarget().isNull()) diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 790c748335ee..3c49f6378e0f 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -1270,7 +1270,7 @@ MarkObjectGroupFromIon(JSRuntime* rt, ObjectGroup** groupp) bool ThrowRuntimeLexicalError(JSContext* cx, unsigned errorNumber) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); RootedScript script(cx, iter.script()); ReportRuntimeLexicalError(cx, errorNumber, script, iter.pc()); return false; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 8d49930d09d4..0b19cd40f142 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -6416,7 +6416,7 @@ DescribeScriptedCaller(JSContext* cx, AutoFilename* filename, unsigned* lineno, if (column) *column = 0; - NonBuiltinFrameIter i(cx); + NonBuiltinFrameIter i(cx, FrameIter::STOP_AT_SAVED); if (i.done()) return false; @@ -6496,7 +6496,7 @@ GetScriptedCallerGlobal(JSContext* cx) if (!activation) return nullptr; } else { - NonBuiltinFrameIter i(cx); + NonBuiltinFrameIter i(cx, FrameIter::STOP_AT_SAVED); if (i.done()) return nullptr; activation = i.activation(); diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 9da93384c5ae..c3c0956cd086 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -403,7 +403,7 @@ js::RunningWithTrustedPrincipals(JSContext* cx) JS_FRIEND_API(JSFunction*) js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext* cx) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); // Skip eval frames. while (!iter.done() && iter.isEvalFrame()) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 873eb4f6ab2d..56d07e6f4daf 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -164,7 +164,7 @@ ArgumentsGetterImpl(JSContext* cx, const CallArgs& args) return false; // Return null if this function wasn't found on the stack. - NonBuiltinScriptFrameIter iter(cx); + NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (!AdvanceToActiveCallLinear(cx, iter, fun)) { args.rval().setNull(); return true; @@ -255,7 +255,7 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args) return false; // Also return null if this function wasn't found on the stack. - NonBuiltinScriptFrameIter iter(cx); + NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (!AdvanceToActiveCallLinear(cx, iter, fun)) { args.rval().setNull(); return true; @@ -326,7 +326,7 @@ CallerSetterImpl(JSContext* cx, const CallArgs& args) // computing the caller, checking that no security boundaries are crossed, // and throwing a TypeError if the resulting caller is strict. - NonBuiltinScriptFrameIter iter(cx); + NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (!AdvanceToActiveCallLinear(cx, iter, fun)) return true; @@ -1221,7 +1221,7 @@ js::fun_apply(JSContext* cx, unsigned argc, Value* vp) // the calling frame (which we must do now). if (args[1].isMagic(JS_OPTIMIZED_ARGUMENTS)) { // Step 3-6. - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(iter.numActualArgs() <= ARGS_LENGTH_MAX); if (!args2.init(iter.numActualArgs())) return false; diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 3709fec18e21..4b5ca5e293d1 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -719,7 +719,7 @@ js::DumpPC(JSContext* cx) Sprinter sprinter(cx); if (!sprinter.init()) return false; - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (iter.done()) { fprintf(stdout, "Empty stack.\n"); return true; @@ -1415,7 +1415,7 @@ DecompileExpressionFromStack(JSContext* cx, int spindex, int skipStackHits, Hand return true; #endif - FrameIter frameIter(cx); + FrameIter frameIter(cx, FrameIter::STOP_AT_SAVED); if (frameIter.done() || !frameIter.hasScript()) return true; @@ -1486,7 +1486,7 @@ DecompileArgumentFromStack(JSContext* cx, int formalIndex, char** res) * Settle on the nearest script frame, which should be the builtin that * called the intrinsic. */ - FrameIter frameIter(cx); + FrameIter frameIter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(!frameIter.done()); /* diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index df2f69214970..49ad1db89be2 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -3370,7 +3370,7 @@ js::DescribeScriptedCallerForCompilation(JSContext* cx, MutableHandleScript mayb return; } - NonBuiltinFrameIter iter(cx); + NonBuiltinFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (iter.done()) { maybeScript.set(nullptr); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 20839f548ec9..cb08e05af147 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -2003,7 +2003,7 @@ ValueToScript(JSContext* cx, Value vArg, JSFunction** funp = nullptr) static JSScript* GetTopScript(JSContext* cx) { - NonBuiltinScriptFrameIter iter(cx); + NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); return iter.done() ? nullptr : iter.script(); } @@ -4250,7 +4250,7 @@ DecompileThisScript(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); - NonBuiltinScriptFrameIter iter(cx); + NonBuiltinScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (iter.done()) { args.rval().setString(cx->runtime()->emptyString); return true; diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index c7ccef727de9..53dd8fa595ef 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -1481,7 +1481,7 @@ Debugger::fireDebuggerStatement(JSContext* cx, MutableHandleValue vp) Maybe ac; ac.emplace(cx, object); - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); RootedValue scriptFrame(cx); if (!getScriptFrame(cx, iter, &scriptFrame)) return handleUncaughtException(ac, false); @@ -1510,7 +1510,7 @@ Debugger::fireExceptionUnwind(JSContext* cx, MutableHandleValue vp) RootedValue scriptFrame(cx); RootedValue wrappedExc(cx, exc); - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (!getScriptFrame(cx, iter, &scriptFrame) || !wrapDebuggeeValue(cx, &wrappedExc)) return handleUncaughtException(ac, false); @@ -1682,7 +1682,7 @@ Debugger::slowPathOnNewWasmModule(JSContext* cx, Handle wasmM /* static */ JSTrapStatus Debugger::onTrap(JSContext* cx, MutableHandleValue vp) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); RootedScript script(cx, iter.script()); MOZ_ASSERT(script->isDebuggee()); Rooted scriptGlobal(cx, &script->global()); @@ -1746,7 +1746,7 @@ Debugger::onTrap(JSContext* cx, MutableHandleValue vp) /* static */ JSTrapStatus Debugger::onSingleStep(JSContext* cx, MutableHandleValue vp) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); /* * We may be stepping over a JSOP_EXCEPTION, that pushes the context's @@ -6040,7 +6040,7 @@ Debugger::removeFromFrameMapsAndClearBreakpointsIn(JSContext* cx, AbstractFrameP /* static */ bool Debugger::handleBaselineOsr(JSContext* cx, InterpreterFrame* from, jit::BaselineFrame* to) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(iter.abstractFramePtr() == to); return replaceFrameGuts(cx, from, to, iter); } @@ -6056,7 +6056,7 @@ Debugger::handleIonBailout(JSContext* cx, jit::RematerializedFrame* from, jit::B // across any inlined frames younger than |to|, the baseline frame // reconstructed during bailout from the Ion frame corresponding to // |from|. - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); while (iter.abstractFramePtr() != to) ++iter; return replaceFrameGuts(cx, from, to, iter); diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index f82a69082782..1d04af7a43d7 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -591,7 +591,7 @@ InvokeInterruptCallback(JSContext* cx) // Debugger treats invoking the interrupt callback as a "step", so // invoke the onStep handler. if (cx->compartment()->isDebuggee()) { - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); if (!iter.done() && iter.script()->stepModeEnabled()) { RootedValue rval(cx); switch (Debugger::onSingleStep(cx, &rval)) { diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index fc49d846318a..4ea5b88433db 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -806,7 +806,7 @@ intrinsic_ActiveFunction(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 0); - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(iter.isFunctionFrame()); args.rval().setObject(*iter.callee(cx)); return true; @@ -1761,7 +1761,7 @@ js::ReportIncompatibleSelfHostedMethod(JSContext* cx, const CallArgs& args) // self-hosted things until we find a non-self-hosted one because of cases // like array.sort(somethingSelfHosted), where we want to report the error // in the somethingSelfHosted, not in the sort() call. - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(iter.isFunctionFrame()); while (!iter.done()) { @@ -1880,7 +1880,7 @@ intrinsic_IsConstructing(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); MOZ_ASSERT(args.length() == 0); - ScriptFrameIter iter(cx); + ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); bool isConstructing = iter.isConstructing(); args.rval().setBoolean(isConstructing); return true; diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index d5d3523d522a..25fb94a8a922 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -47,7 +47,7 @@ InterpreterFrame::initExecuteFrame(JSContext* cx, HandleScript script, AbstractF if (newTarget.isNull() && evalInFramePrev.script()->functionOrCallerFunction()) newTarget = evalInFramePrev.newTarget(); } else { - FrameIter iter(cx); + FrameIter iter(cx, FrameIter::STOP_AT_SAVED); MOZ_ASSERT(!iter.isWasm()); if (newTarget.isNull() && iter.script()->functionOrCallerFunction()) newTarget = iter.newTarget(); diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index b9d357939f5d..be5b53c6a727 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -1774,7 +1774,7 @@ class FrameIter Data(const Data& other); }; - MOZ_IMPLICIT FrameIter(JSContext* cx, SavedOption = STOP_AT_SAVED); + FrameIter(JSContext* cx, SavedOption); FrameIter(JSContext* cx, ContextOption, SavedOption, DebuggerEvalOption = FOLLOW_DEBUGGER_EVAL_PREV_LINK); FrameIter(JSContext* cx, ContextOption, SavedOption, DebuggerEvalOption, JSPrincipals*); @@ -1915,7 +1915,7 @@ class ScriptFrameIter : public FrameIter } public: - explicit ScriptFrameIter(JSContext* cx, SavedOption savedOption = STOP_AT_SAVED) + ScriptFrameIter(JSContext* cx, SavedOption savedOption) : FrameIter(cx, savedOption) { settle(); @@ -1967,8 +1967,7 @@ class NonBuiltinFrameIter : public FrameIter void settle(); public: - explicit NonBuiltinFrameIter(JSContext* cx, - FrameIter::SavedOption opt = FrameIter::STOP_AT_SAVED) + NonBuiltinFrameIter(JSContext* cx, FrameIter::SavedOption opt) : FrameIter(cx, opt) { settle(); @@ -2019,8 +2018,7 @@ class NonBuiltinScriptFrameIter : public ScriptFrameIter public: explicit NonBuiltinScriptFrameIter(JSContext* cx, - ScriptFrameIter::SavedOption opt = - ScriptFrameIter::STOP_AT_SAVED) + ScriptFrameIter::SavedOption opt) : ScriptFrameIter(cx, opt) { settle(); diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index fe6780b03f9f..6c70264f1b02 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -3888,7 +3888,7 @@ TypeNewScript::rollbackPartiallyInitializedObjects(JSContext* cx, ObjectGroup* g RootedFunction function(cx, this->function()); Vector pcOffsets(cx); - for (ScriptFrameIter iter(cx); !iter.done(); ++iter) { + for (ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED); !iter.done(); ++iter) { { AutoEnterOOMUnsafeRegion oomUnsafe; if (!pcOffsets.append(iter.script()->pcToOffset(iter.pc())))