Bug 1274193 part 1 - Pass SavedOption explicitly to frame iterators. r=luke

This commit is contained in:
Jan de Mooij 2016-05-24 07:50:13 +02:00
Родитель 7e12058989
Коммит 031c858a7a
16 изменённых файлов: 34 добавлений и 36 удалений

Просмотреть файл

@ -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 ||

Просмотреть файл

@ -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);

Просмотреть файл

@ -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())

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -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())

Просмотреть файл

@ -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;

Просмотреть файл

@ -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());
/*

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -1481,7 +1481,7 @@ Debugger::fireDebuggerStatement(JSContext* cx, MutableHandleValue vp)
Maybe<AutoCompartment> 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<WasmModuleObject*> 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<GlobalObject*> 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);

Просмотреть файл

@ -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)) {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -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();

Просмотреть файл

@ -3888,7 +3888,7 @@ TypeNewScript::rollbackPartiallyInitializedObjects(JSContext* cx, ObjectGroup* g
RootedFunction function(cx, this->function());
Vector<uint32_t, 32> 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())))