jsval *sp;  if (markp) *markp = JS_ARENA_MARK(&cx->stackPool); JS_ARENA_ALLOCATE_CAST(sp, jsval *, &cx->stackPool, nslots * sizeof(jsval)); if (!sp) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_STACK_OVERFLOW, (cx->fp && cx->fp->fun) ? JS_GetFunctionName(cx->fp->fun) : "script"); } return sp;
JSStackFrame *fp, frame; jsval *sp, *newsp, *limit; jsval *vp, v; JSObject *funobj, *parent, *thisp; JSClass *clasp; JSObjectOps *ops; JSBool ok; JSNative native; JSFunction *fun; JSScript *script; uintN minargs, nvars; void *mark; intN nslots, nalloc, surplus; JSInterpreterHook hook; void *hookData;   fp = cx->fp; sp = fp->sp;   vp = sp - (2 + argc); v = *vp; frame.rval = JSVAL_VOID; #if JSINVOKE_CONSTRUCT != JSFRAME_CONSTRUCTING # error "constructor invoke/frame flag mismatch!" #endif frame.flags = (flags & JSINVOKE_CONSTRUCT);   if (JSVAL_IS_PRIMITIVE(v)) goto bad; funobj = JSVAL_TO_OBJECT(v);   parent = OBJ_GET_PARENT(cx, funobj); thisp = JSVAL_TO_OBJECT(vp[1]);  clasp = OBJ_GET_CLASS(cx, funobj); if (clasp != &js_FunctionClass) {  ops = funobj->map->ops;   if (cx->version == JSVERSION_1_2 || ((ops == &js_ObjectOps) ? clasp->call : ops->call)) { ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v); if (!ok) goto out2;  if (JSVAL_IS_FUNCTION(cx, v)) { funobj = JSVAL_TO_OBJECT(v); parent = OBJ_GET_PARENT(cx, funobj); fun = (JSFunction *) JS_GetPrivate(cx, funobj);   *vp = v; goto have_fun; } } fun = NULL; script = NULL; minargs = nvars = 0;   native = (flags & JSINVOKE_CONSTRUCT) ? ops->construct : ops->call; if (!native) goto bad; } else {  fun = (JSFunction *) JS_GetPrivate(cx, funobj); have_fun: native = fun->native; script = fun->script; minargs = fun->nargs + fun->extra; nvars = fun->nvars;   if (fun->flags & JSFUN_BOUND_METHOD) thisp = parent; }   frame.varobj = NULL; frame.callobj = frame.argsobj = NULL; frame.script = script; frame.fun = fun; frame.argc = argc; frame.argv = sp - argc; frame.nvars = nvars; frame.vars = sp; frame.down = fp; frame.annotation = NULL; frame.scopeChain = NULL;     frame.pc = NULL; frame.spbase = NULL; frame.sharpDepth = 0; frame.sharpArray = NULL; frame.dormantNext = NULL;   ok = ComputeThis(cx, thisp, &frame); if (!ok) goto out2;   cx->fp = &frame; mark = JS_ARENA_MARK(&cx->stackPool);   hook = cx->runtime->callHook; hookData = NULL;   nslots = (intN)((argc < minargs) ? minargs - argc : 0); if (nslots) {  nalloc = nslots; limit = (jsval *) cx->stackPool.current->limit; if (sp + nslots > limit) {  nalloc += 2 + argc; } else {  surplus = (jsval *)mark - sp; JS_ASSERT(surplus >= 0); nalloc -= surplus; }   if (nalloc > 0) {  newsp = js_AllocRawStack(cx, (uintN)nalloc, NULL); if (!newsp) { ok = JS_FALSE; goto out; }   if (newsp != mark) { JS_ASSERT(sp + nslots > limit); JS_ASSERT(2 + argc + nslots == (uintN)nalloc); *newsp++ = vp[0]; *newsp++ = vp[1]; if (argc) memcpy(newsp, frame.argv, argc * sizeof(jsval)); frame.argv = newsp; sp = frame.vars = newsp + argc; } }   frame.vars += nslots;   while (--nslots >= 0) PUSH(JSVAL_VOID); }   nslots = (intN)frame.nvars; if (nslots) { surplus = (intN)((jsval *)cx->stackPool.current->avail - frame.vars); if (surplus < nslots) { newsp = js_AllocRawStack(cx, (uintN)nslots, NULL); if (!newsp) { ok = JS_FALSE; goto out; } if (newsp != sp) {  sp = frame.vars = newsp; } }   while (--nslots >= 0) PUSH(JSVAL_VOID); }   SAVE_SP(&frame);   if (hook && (native || script)) hookData = hook(cx, &frame, JS_TRUE, 0, cx->runtime->callHookData);   if (native) { #if JS_HAS_LVALUE_RETURN  cx->rval2set = JS_FALSE; #endif   frame.varobj = fp->varobj; frame.scopeChain = fp->scopeChain; ok = native(cx, frame.thisp, argc, frame.argv, &frame.rval); JS_RUNTIME_METER(cx->runtime, nativeCalls); } else if (script) {  frame.scopeChain = parent; if (fun->flags & JSFUN_HEAVYWEIGHT) { #if JS_HAS_CALL_OBJECT  if (!js_GetCallObject(cx, &frame, parent)) { ok = JS_FALSE; goto out; } #else  frame.scopeChain = funobj; #endif } ok = js_Interpret(cx, &v); } else {  frame.scopeChain = NULL; ok = JS_TRUE; }  out: if (hookData) { hook = cx->runtime->callHook; if (hook) hook(cx, &frame, JS_FALSE, &ok, hookData); } #if JS_HAS_CALL_OBJECT  if (frame.callobj) ok &= js_PutCallObject(cx, &frame); #endif #if JS_HAS_ARGS_OBJECT  if (frame.argsobj) ok &= js_PutArgsObject(cx, &frame); #endif   JS_ARENA_RELEASE(&cx->stackPool, mark); cx->fp = fp;  out2:  *vp = frame.rval; fp->sp = vp + 1;   if (fp->script && !(flags & JSINVOKE_INTERNAL)) vp[-(intN)fp->script->depth] = (jsval)fp->pc; return ok;  bad: js_ReportIsNotFunction(cx, vp, (flags & JSINVOKE_CONSTRUCT) != 0); ok = JS_FALSE; goto out2;
JS_FRIEND_API(jsval *)js_AllocRawStack(JSContext *cx, uintN nslots, void **markp){    jsval *sp;    if (markp)        *markp = JS_ARENA_MARK(&cx->stackPool);    JS_ARENA_ALLOCATE_CAST(sp, jsval *, &cx->stackPool, nslots * sizeof(jsval));    if (!sp) {        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_STACK_OVERFLOW,                             (cx->fp && cx->fp->fun)                             ? JS_GetFunctionName(cx->fp->fun)                             : "script");    }    return sp;}