void InterpreterFrame::initExecuteFrame(JSContext *cx, HandleScript script, AbstractFramePtr evalInFramePrev, const Value &thisv, HandleObject scopeChain, ExecuteType type) { /* * See encoding of ExecuteType. When GLOBAL isn't set, we are executing a * script in the context of another frame and the frame type is determined * by the context. */ flags_ = type | HAS_SCOPECHAIN; JSObject *callee = nullptr; if (!(flags_ & (GLOBAL))) { if (evalInFramePrev) { MOZ_ASSERT(evalInFramePrev.isFunctionFrame() || evalInFramePrev.isGlobalFrame()); if (evalInFramePrev.isFunctionFrame()) { callee = evalInFramePrev.callee(); flags_ |= FUNCTION; } else { flags_ |= GLOBAL; } } else { FrameIter iter(cx); MOZ_ASSERT(iter.isFunctionFrame() || iter.isGlobalFrame()); MOZ_ASSERT(!iter.isAsmJS()); if (iter.isFunctionFrame()) { callee = iter.callee(cx); flags_ |= FUNCTION; } else { flags_ |= GLOBAL; } } } Value *dstvp = (Value *)this - 2; dstvp[1] = thisv; if (isFunctionFrame()) { dstvp[0] = ObjectValue(*callee); exec.fun = &callee->as<JSFunction>(); u.evalScript = script; } else { MOZ_ASSERT(isGlobalFrame()); dstvp[0] = NullValue(); exec.script = script; #ifdef DEBUG u.evalScript = (JSScript *)0xbad; #endif } scopeChain_ = scopeChain.get(); prev_ = nullptr; prevpc_ = nullptr; prevsp_ = nullptr; MOZ_ASSERT_IF(evalInFramePrev, isDebuggerEvalFrame()); evalInFramePrev_ = evalInFramePrev; if (script->isDebuggee()) setIsDebuggee(); #ifdef DEBUG Debug_SetValueRangeToCrashOnTouch(&rval_, 1); #endif }