bool GeneratorObject::suspend(JSContext *cx, HandleObject obj, AbstractFramePtr frame, jsbytecode *pc, Value *vp, unsigned nvalues) { MOZ_ASSERT(*pc == JSOP_INITIALYIELD || *pc == JSOP_YIELD); Rooted<GeneratorObject*> genObj(cx, &obj->as<GeneratorObject>()); MOZ_ASSERT(!genObj->hasExpressionStack()); if (*pc == JSOP_YIELD && genObj->isClosing() && genObj->is<LegacyGeneratorObject>()) { RootedValue val(cx, ObjectValue(*frame.callee())); js_ReportValueError(cx, JSMSG_BAD_GENERATOR_YIELD, JSDVG_IGNORE_STACK, val, NullPtr()); return false; } uint32_t yieldIndex = GET_UINT24(pc); genObj->setYieldIndex(yieldIndex); genObj->setScopeChain(*frame.scopeChain()); if (nvalues) { ArrayObject *stack = NewDenseCopiedArray(cx, nvalues, vp); if (!stack) return false; genObj->setExpressionStack(*stack); } return true; }
bool js::DirectEval(JSContext *cx, const CallArgs &args) { // Direct eval can assume it was called from an interpreted or baseline frame. ScriptFrameIter iter(cx); AbstractFramePtr caller = iter.abstractFramePtr(); JS_ASSERT(caller.scopeChain()->global().valueIsEval(args.calleev())); JS_ASSERT(JSOp(*iter.pc()) == JSOP_EVAL || JSOp(*iter.pc()) == JSOP_SPREADEVAL); JS_ASSERT_IF(caller.isFunctionFrame(), caller.compartment() == caller.callee()->compartment()); RootedObject scopeChain(cx, caller.scopeChain()); return EvalKernel(cx, args, DIRECT_EVAL, caller, scopeChain, iter.pc()); }
JSObject * JSAbstractFramePtr::scopeChain(JSContext *cx) { AbstractFramePtr frame = Valueify(*this); RootedObject scopeChain(cx, frame.scopeChain()); AutoCompartment ac(cx, scopeChain); return GetDebugScopeForFrame(cx, frame); }
bool js::DirectEval(JSContext *cx, const CallArgs &args) { // Direct eval can assume it was called from an interpreted or baseline frame. ScriptFrameIter iter(cx); AbstractFramePtr caller = iter.abstractFramePtr(); JS_ASSERT(IsBuiltinEvalForScope(caller.scopeChain(), args.calleev())); JS_ASSERT(JSOp(*iter.pc()) == JSOP_EVAL); JS_ASSERT_IF(caller.isFunctionFrame(), caller.compartment() == caller.callee()->compartment()); if (!WarnOnTooManyArgs(cx, args)) return false; RootedObject scopeChain(cx, caller.scopeChain()); return EvalKernel(cx, args, DIRECT_EVAL, caller, scopeChain, iter.pc()); }
JSObject * JSAbstractFramePtr::scopeChain(JSContext *cx) { AbstractFramePtr frame = Valueify(*this); JS_ASSERT_IF(frame.isStackFrame(), cx->stack.space().containsSlow(frame.asStackFrame())); RootedObject scopeChain(cx, frame.scopeChain()); AutoCompartment ac(cx, scopeChain); return GetDebugScopeForFrame(cx, frame); }
bool JSAbstractFramePtr::getThisValue(JSContext *cx, MutableHandleValue thisv) { AbstractFramePtr frame = Valueify(*this); RootedObject scopeChain(cx, frame.scopeChain()); js::AutoCompartment ac(cx, scopeChain); if (!ComputeThis(cx, frame)) return false; thisv.set(frame.thisValue()); return true; }
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, FrameIter::GO_THROUGH_SAVED); AbstractFramePtr caller = iter.abstractFramePtr(); MOZ_ASSERT(JSOp(*iter.pc()) == JSOP_EVAL || JSOp(*iter.pc()) == JSOP_STRICTEVAL || JSOp(*iter.pc()) == JSOP_SPREADEVAL || JSOp(*iter.pc()) == JSOP_STRICTSPREADEVAL); MOZ_ASSERT(caller.compartment() == caller.script()->compartment()); RootedObject scopeChain(cx, caller.scopeChain()); return EvalKernel(cx, v, DIRECT_EVAL, caller, scopeChain, iter.pc(), vp); }