ok = native(cx, thisp, argc, frame.argv, &frame.rval);
ok = native(cx, frame.thisp, argc, frame.argv, &frame.rval);
JS_FRIEND_API(JSBool)js_Invoke(JSContext *cx, uintN argc, uintN flags){    JSStackFrame *fp, frame;    jsval *sp, *newsp;    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;    /* Reach under args and this to find the callee on the stack. */    fp = cx->fp;    sp = fp->sp;    /*     * Set vp to the callee value's stack slot (it's where rval goes).     * Once vp is set, control must flow through label out2: to return.     * Set frame.rval early so native class and object ops can throw and     * return false, causing a goto out2 with ok set to false.  Also set     * frame.constructing so we may test it anywhere below.     */    vp = sp - (2 + argc);    v = *vp;    frame.rval = JSVAL_VOID;    frame.constructing = (JSPackedBool)(flags & JSINVOKE_CONSTRUCT);    /* A callee must be an object reference. */    if (JSVAL_IS_PRIMITIVE(v))        goto bad;    funobj = JSVAL_TO_OBJECT(v);    /* Load callee parent and this parameter for later. */    parent = OBJ_GET_PARENT(cx, funobj);    thisp = JSVAL_TO_OBJECT(vp[1]);    clasp = OBJ_GET_CLASS(cx, funobj);    if (clasp != &js_FunctionClass) {        /* Function is inlined, all other classes use object ops. */        ops = funobj->map->ops;        /*         * XXX         * Try converting to function, for closure and API compatibility.         * We attempt the conversion under all circumstances for 1.2, but         * only if there is a call op defined otherwise.         */        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);                /* Make vp refer to funobj to keep it available as argv[-2]. */                *vp = v;                goto have_fun;            }        }        fun = NULL;        script = NULL;        minargs = nvars = 0;        /* Try a call or construct native object op, using fun as fallback. */        native = frame.constructing ? ops->construct : ops->call;        if (!native)            goto bad;    } else {        /* Get private data and set derived locals from it. */        fun = (JSFunction *) JS_GetPrivate(cx, funobj);have_fun:        native = fun->call;        script = fun->script;        minargs = fun->nargs + fun->extra;        nvars = fun->nvars;        /* Handle bound method special case. */        if (fun->flags & JSFUN_BOUND_METHOD)            thisp = parent;    }    /* Initialize most of frame, except for varobj, thisp, and scopeChain. */    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;    /* set below for real, after cx->fp is set */    frame.pc = NULL;    frame.sp = sp;    frame.sharpDepth = 0;    frame.sharpArray = NULL;    frame.overrides = 0;    frame.special = 0;    frame.dormantNext = NULL;    /* Compute the 'this' parameter and store it in frame as frame.thisp. */    ok = ComputeThis(cx, thisp, &frame);    if (!ok)        goto out2;    /* From here on, control must flow through label out: to return. */    cx->fp = &frame;    mark = JS_ARENA_MARK(&cx->stackPool);    /* Init these now in case we goto out before first hook call. */    hook = cx->runtime->callHook;    hookData = NULL;    /* Check for missing arguments expected by the function. */    nslots = (intN)((argc < minargs) ? minargs - argc : 0);    if (nslots) {        /* All arguments must be contiguous, so we may have to copy actuals. */        nalloc = nslots;        if ((jsuword)(sp + nslots) > cx->stackPool.current->limit)            nalloc += argc;        /* Take advantage of the surplus slots in the caller's frame depth. */        surplus = (jsval *)mark - sp;        JS_ASSERT(surplus >= 0);        nalloc -= surplus;        /* Check whether we have enough space in the caller's frame. */        if (nalloc > 0) {            /* Need space for actuals plus missing formals minus surplus. */            newsp = js_AllocStack(cx, (uintN)nalloc, NULL);            if (!newsp) {                ok = JS_FALSE;                goto out;            }            /* If we couldn't allocate contiguous args, copy actuals now. */            if (newsp != mark) {                if (argc)                    memcpy(newsp, frame.argv, argc * sizeof(jsval));                frame.argv = newsp;                frame.vars = frame.sp = newsp + argc;                RESTORE_SP(&frame);            }        }        /* Advance frame.vars to make room for the missing args. */        frame.vars += nslots;        /* Push void to initialize missing args. */        while (--nslots >= 0)            PUSH(JSVAL_VOID);    }    /* Now allocate stack space for local variables. */    nslots = (intN)frame.nvars;    if (nslots) {        surplus = (intN)((jsval *)cx->stackPool.current->avail - frame.vars);        if (surplus < nslots) {            newsp = js_AllocStack(cx, (uintN)nslots, NULL);            if (!newsp) {                ok = JS_FALSE;                goto out;            }            if (newsp != sp) {                /* NB: Discontinuity between argv and vars. */                frame.vars = frame.sp = newsp;                RESTORE_SP(&frame);            }        }        /* Push void to initialize local variables. */        while (--nslots >= 0)            PUSH(JSVAL_VOID);    }    /* Store the current sp in frame before calling fun. */    SAVE_SP(&frame);    /* call the hook if present */    if (hook && (native || script))        hookData = hook(cx, &frame, JS_TRUE, 0, cx->runtime->callHookData);    /* Call the function, either a native method or an interpreted script. */    if (native) {        /* If native, use caller varobj and scopeChain for eval. */        frame.varobj = fp->varobj;        frame.scopeChain = fp->scopeChain;        ok = native(cx, thisp, argc, frame.argv, &frame.rval);    } else if (script) {        if (fun->flags & JSFUN_HEAVYWEIGHT) {#if JS_HAS_CALL_OBJECT            /* Scope with a call object parented by the callee's parent. */            if (!js_GetCallObject(cx, &frame, parent)) {                ok = JS_FALSE;                goto out;            }#else            /* Bad old code used the function as a proxy for all calls to it. */            frame.scopeChain = funobj;#endif        } else {            frame.scopeChain = parent;        }        ok = js_Interpret(cx, &v);    } else {        /* fun might be onerror trying to report a syntax error in itself. */        frame.scopeChain = NULL;        ok = JS_TRUE;    }out:    if (hook && hookData)        hook(cx, &frame, JS_FALSE, &ok, hookData);#if JS_HAS_CALL_OBJECT    /* If frame has a call object, sync values and clear back-pointer. */    if (frame.callobj)        ok &= js_PutCallObject(cx, &frame);#endif#if JS_HAS_ARGS_OBJECT    /* If frame has an arguments object, sync values and clear back-pointer. */    if (frame.argsobj)        ok &= js_PutArgsObject(cx, &frame);#endif    /* Pop everything off the stack and restore cx->fp. */    JS_ARENA_RELEASE(&cx->stackPool, mark);    cx->fp = fp;out2:    /* Store the return value and restore sp just above it. */    *vp = frame.rval;    fp->sp = vp + 1;    /*     * Store the location of the JSOP_CALL or JSOP_EVAL that generated the     * return value, but only if this is an external (compiled from script     * source) call that has stack budget for the generating pc.     */    if (fp->script && !(flags & JSINVOKE_INTERNAL))        vp[-(intN)fp->script->depth] = (jsval)fp->pc;    return ok;bad:    js_ReportIsNotFunction(cx, vp, frame.constructing);    ok = JS_FALSE;    goto out2;}