static inline bool UncachedInlineCall(VMFrame &f, uint32 flags, void **pret, bool *unjittable, uint32 argc) { JSContext *cx = f.cx; Value *vp = f.regs.sp - (argc + 2); JSObject &callee = vp->toObject(); JSFunction *newfun = callee.getFunctionPrivate(); JSScript *newscript = newfun->script(); /* Get pointer to new frame/slots, prepare arguments. */ StackSpace &stack = cx->stack(); JSStackFrame *newfp = stack.getInlineFrameWithinLimit(cx, f.regs.sp, argc, newfun, newscript, &flags, f.entryfp, &f.stackLimit); if (JS_UNLIKELY(!newfp)) return false; /* Initialize frame, locals. */ newfp->initCallFrame(cx, callee, newfun, argc, flags); SetValueRangeToUndefined(newfp->slots(), newscript->nfixed); /* Officially push the frame. */ stack.pushInlineFrame(cx, newscript, newfp, &f.regs); JS_ASSERT(newfp == f.regs.fp); /* Scope with a call object parented by callee's parent. */ if (newfun->isHeavyweight() && !js::CreateFunCallObject(cx, newfp)) return false; /* Try to compile if not already compiled. */ if (newscript->getJITStatus(newfp->isConstructing()) == JITScript_None) { CompileStatus status = CanMethodJIT(cx, newscript, newfp, CompileRequest_Interpreter); if (status == Compile_Error) { /* A runtime exception was thrown, get out. */ InlineReturn(f); return false; } if (status == Compile_Abort) *unjittable = true; } /* If newscript was successfully compiled, run it. */ if (JITScript *jit = newscript->getJIT(newfp->isConstructing())) { *pret = jit->invokeEntry; return true; } /* Otherwise, run newscript in the interpreter. */ bool ok = !!Interpret(cx, cx->fp()); InlineReturn(f); *pret = NULL; return ok; }
static inline bool UncachedInlineCall(VMFrame &f, MaybeConstruct construct, void **pret, bool *unjittable, uint32 argc) { JSContext *cx = f.cx; CallArgs args = CallArgsFromSp(argc, f.regs.sp); JSObject &callee = args.callee(); JSFunction *newfun = callee.getFunctionPrivate(); JSScript *newscript = newfun->script(); /* Get pointer to new frame/slots, prepare arguments. */ if (!cx->stack.pushInlineFrame(cx, f.regs, args, callee, newfun, newscript, construct, &f.stackLimit)) return false; /* Scope with a call object parented by callee's parent. */ if (newfun->isHeavyweight() && !js::CreateFunCallObject(cx, f.fp())) return false; /* Try to compile if not already compiled. */ if (newscript->getJITStatus(f.fp()->isConstructing()) == JITScript_None) { CompileStatus status = CanMethodJIT(cx, newscript, f.fp(), CompileRequest_Interpreter); if (status == Compile_Error) { /* A runtime exception was thrown, get out. */ InlineReturn(f); return false; } if (status == Compile_Abort) *unjittable = true; } /* If newscript was successfully compiled, run it. */ if (JITScript *jit = newscript->getJIT(f.fp()->isConstructing())) { *pret = jit->invokeEntry; return true; } /* Otherwise, run newscript in the interpreter. */ bool ok = !!Interpret(cx, cx->fp()); InlineReturn(f); *pret = NULL; return ok; }
static inline bool UncachedInlineCall(VMFrame &f, InitialFrameFlags initial, void **pret, bool *unjittable, uint32_t argc) { JSContext *cx = f.cx; CallArgs args = CallArgsFromSp(argc, f.regs.sp); JSFunction *newfun = args.callee().toFunction(); JSScript *newscript = newfun->script(); bool construct = InitialFrameFlagsAreConstructing(initial); bool newType = construct && cx->typeInferenceEnabled() && types::UseNewType(cx, f.script(), f.pc()); types::TypeMonitorCall(cx, args, construct); /* Try to compile if not already compiled. */ if (newscript->getJITStatus(construct) == JITScript_None) { CompileStatus status = CanMethodJIT(cx, newscript, construct, CompileRequest_Interpreter); if (status == Compile_Error) { /* A runtime exception was thrown, get out. */ return false; } if (status == Compile_Abort) *unjittable = true; } /* * Make sure we are not calling from an inline frame if we need to make a * call object for the callee, as doing so could trigger GC and cause * jitcode discarding / frame expansion. */ if (f.regs.inlined() && newfun->isHeavyweight()) { ExpandInlineFrames(cx->compartment); JS_ASSERT(!f.regs.inlined()); } /* * Preserve f.regs.fp while pushing the new frame, for the invariant that * f.regs reflects the state when we entered the stub call. This handoff is * tricky: we need to make sure that f.regs is not updated to the new * frame, and we also need to ensure that cx->regs still points to f.regs * when space is reserved, in case doing so throws an exception. */ FrameRegs regs = f.regs; /* Get pointer to new frame/slots, prepare arguments. */ if (!cx->stack.pushInlineFrame(cx, regs, args, *newfun, newscript, initial, &f.stackLimit)) return false; /* Finish the handoff to the new frame regs. */ PreserveRegsGuard regsGuard(cx, regs); /* Scope with a call object parented by callee's parent. */ if (!regs.fp()->functionPrologue(cx)) return false; /* * If newscript was successfully compiled, run it. Skip for calls which * will be constructing a new type object for 'this'. */ if (!newType) { if (JITScript *jit = newscript->getJIT(regs.fp()->isConstructing())) { *pret = jit->invokeEntry; /* Restore the old fp around and let the JIT code repush the new fp. */ regs.popFrame((Value *) regs.fp()); return true; } } /* * Otherwise, run newscript in the interpreter. Expand any inlined frame we * are calling from, as the new frame is not associated with the VMFrame * and will not have its prevpc info updated if frame expansion is * triggered while interpreting. */ if (f.regs.inlined()) { ExpandInlineFrames(cx->compartment); JS_ASSERT(!f.regs.inlined()); regs.fp()->resetInlinePrev(f.fp(), f.regs.pc); } bool ok = !!Interpret(cx, cx->fp()); f.cx->stack.popInlineFrame(regs); if (ok) types::TypeScript::Monitor(f.cx, f.script(), f.pc(), args.rval()); *pret = NULL; return ok; }