From 2aeb294c197777fa5ea745a77025262b59bdb288 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Thu, 19 Aug 2010 16:44:12 -0700 Subject: [PATCH] Interface for JSStackFrame.argc, bug 586533. r=lw --- js/src/jscntxtinlines.h | 4 +- js/src/jsexn.cpp | 8 ++-- js/src/jsfun.cpp | 11 +++--- js/src/jsinterp.cpp | 28 +++++++------- js/src/jsinterp.h | 18 ++++++++- js/src/jsiter.cpp | 6 +-- js/src/jsobj.cpp | 3 +- js/src/jsrecursion.cpp | 19 +++++----- js/src/jstracer.cpp | 84 +++++++++++++++++++++-------------------- 9 files changed, 101 insertions(+), 80 deletions(-) diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index 3c8adf5088d..e360468e03e 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -340,13 +340,13 @@ inline Value * FrameRegsIter::contiguousDownFrameSP(JSStackFrame *up) { JS_ASSERT(up->argv); - Value *sp = up->argv + up->argc; + Value *sp = up->argv + up->numActualArgs(); #ifdef DEBUG JS_ASSERT(sp <= up->argEnd()); JS_ASSERT(sp >= (up->down->hasScript() ? up->down->base() : up->down->slots())); if (up->hasFunction()) { uint16 nargs = up->getFunction()->nargs; - uintN argc = up->argc; + uintN argc = up->numActualArgs(); uintN missing = argc < nargs ? nargs - argc : 0; JS_ASSERT(sp == up->argEnd() - missing); } else { diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 1b9c9d26252..09a3dffd74e 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -299,7 +299,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message, !checkAccess(cx, fp->callee(), callerid, JSACC_READ, &v)) { break; } - valueCount += fp->argc; + valueCount += fp->numActualArgs(); } ++stackDepth; } @@ -341,9 +341,9 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message, elem->funName = fp->getFunction()->atom ? ATOM_TO_STRING(fp->getFunction()->atom) : cx->runtime->emptyString; - elem->argc = fp->argc; - memcpy(values, fp->argv, fp->argc * sizeof(jsval)); - values += fp->argc; + elem->argc = fp->numActualArgs(); + memcpy(values, fp->argv, elem->argc * sizeof(jsval)); + values += elem->argc; } elem->ulineno = 0; elem->filename = NULL; diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index f250f2fe793..b3c54eecd37 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -137,7 +137,7 @@ js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, Value *vp) if (JSID_IS_INT(id)) { uint32 arg = uint32(JSID_TO_INT(id)); JSObject *argsobj = fp->maybeArgsObj(); - if (arg < fp->argc) { + if (arg < fp->numActualArgs()) { if (argsobj) { if (argsobj->getArgsElement(arg).isMagic(JS_ARGS_HOLE)) return argsobj->getProperty(cx, id, vp); @@ -163,7 +163,7 @@ js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, Value *vp) JSObject *argsobj = fp->maybeArgsObj(); if (argsobj && argsobj->isArgsLengthOverridden()) return argsobj->getProperty(cx, id, vp); - vp->setInt32(fp->argc); + vp->setInt32(fp->numActualArgs()); } return true; } @@ -226,7 +226,7 @@ js_GetArgsObject(JSContext *cx, JSStackFrame *fp) /* Compute the arguments object's parent slot from fp's scope chain. */ JSObject *global = fp->getScopeChain()->getGlobal(); - JSObject *argsobj = NewArguments(cx, global, fp->argc, &fp->argv[-2].toObject()); + JSObject *argsobj = NewArguments(cx, global, fp->numActualArgs(), &fp->argv[-2].toObject()); if (!argsobj) return argsobj; @@ -240,8 +240,9 @@ js_GetArgsObject(JSContext *cx, JSStackFrame *fp) * up-to-date parameter values. */ if (argsobj->isStrictArguments()) { - JS_ASSERT_IF(fp->argc > 0, argsobj->dslots[-1].toPrivateUint32() >= fp->argc); - memcpy(argsobj->dslots, fp->argv, fp->argc * sizeof(Value)); + JS_ASSERT_IF(fp->numActualArgs() > 0, + argsobj->dslots[-1].toPrivateUint32() >= fp->numActualArgs()); + memcpy(argsobj->dslots, fp->argv, fp->numActualArgs() * sizeof(Value)); } else { argsobj->setPrivate(fp); } diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 278cc3732b0..71e3b6e6ad9 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -503,7 +503,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native, fp->setArgsObj(NULL); fp->setScript(script); fp->setFunction(fun); - fp->argc = args.argc(); + fp->setNumActualArgs(args.argc()); fp->argv = args.argv(); fp->setAnnotation(NULL); fp->setScopeChain(NULL); @@ -552,7 +552,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native, if (hook) hookData = hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData); - DTrace::enterJSFun(cx, fp, fun, fp->down, fp->argc, fp->argv); + DTrace::enterJSFun(cx, fp, fun, fp->down, fp->numActualArgs(), fp->argv); /* Call the function, either a native method or an interpreted script. */ JSBool ok; @@ -562,7 +562,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native, #endif JSObject *thisp = fp->getThisValue().toObjectOrNull(); - ok = callJSNative(cx, native, thisp, fp->argc, fp->argv, + ok = callJSNative(cx, native, thisp, fp->numActualArgs(), fp->argv, fp->addressReturnValue()); JS_ASSERT(cx->fp == fp); @@ -818,7 +818,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, fp->setFunction((script->staticLevel > 0) ? down->maybeFunction() : NULL); fp->setThisValue(down->getThisValue()); fp->flags = flags | (down->flags & JSFRAME_COMPUTED_THIS); - fp->argc = down->argc; + fp->setNumActualArgs(down->numActualArgs()); fp->argv = down->argv; fp->setAnnotation(down->maybeAnnotation()); fp->setScopeChain(chain); @@ -839,7 +839,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, fp->setFunction(NULL); fp->setThisValue(UndefinedValue()); /* Make GC-safe until initialized below. */ fp->flags = flags | JSFRAME_COMPUTED_THIS; - fp->argc = 0; + fp->setNumActualArgs(0); fp->argv = NULL; fp->setAnnotation(NULL); @@ -1346,13 +1346,13 @@ js::GetUpvar(JSContext *cx, uintN closureLevel, UpvarCookie cookie) if (!fp->hasFunction() || (fp->flags & JSFRAME_EVAL)) { vp = fp->slots() + fp->getFixedCount(); - } else if (slot < fp->getArgumentCount()) { + } else if (slot < fp->numFormalArgs()) { vp = fp->argv; } else if (slot == UpvarCookie::CALLEE_SLOT) { vp = &fp->argv[-2]; slot = 0; } else { - slot -= fp->getArgumentCount(); + slot -= fp->numFormalArgs(); JS_ASSERT(slot < fp->getSlotCount()); vp = fp->slots(); } @@ -2909,7 +2909,7 @@ BEGIN_CASE(JSOP_FORARG) { JS_ASSERT(regs.sp - 1 >= fp->base()); uintN slot = GET_ARGNO(regs.pc); - JS_ASSERT(slot < fp->getArgumentCount()); + JS_ASSERT(slot < fp->numFormalArgs()); JS_ASSERT(regs.sp[-1].isObject()); if (!IteratorNext(cx, ®s.sp[-1].toObject(), &fp->argv[slot])) goto error; @@ -3814,7 +3814,7 @@ BEGIN_CASE(JSOP_ARGINC) // If we initialize in the declaration, MSVC complains that the labels skip init. uint32 slot; slot = GET_ARGNO(regs.pc); - JS_ASSERT(slot < fp->getArgumentCount()); + JS_ASSERT(slot < fp->numFormalArgs()); METER_SLOT_OP(op, slot); vp = fp->argv + slot; goto do_int_fast_incop; @@ -3946,7 +3946,7 @@ BEGIN_CASE(JSOP_GETARGPROP) { i = ARGNO_LEN; uint32 slot = GET_ARGNO(regs.pc); - JS_ASSERT(slot < fp->getArgumentCount()); + JS_ASSERT(slot < fp->numFormalArgs()); PUSH_COPY(fp->argv[slot]); goto do_getprop_body; } @@ -4612,7 +4612,7 @@ BEGIN_CASE(JSOP_APPLY) newfp->setArgsObj(NULL); newfp->setScript(newscript); newfp->setFunction(fun); - newfp->argc = argc; + newfp->setNumActualArgs(argc); newfp->argv = vp + 2; newfp->clearReturnValue(); newfp->setAnnotation(NULL); @@ -4664,7 +4664,7 @@ BEGIN_CASE(JSOP_APPLY) inlineCallCount++; JS_RUNTIME_METER(rt, inlineCalls); - DTrace::enterJSFun(cx, fp, fun, fp->down, fp->argc, fp->argv); + DTrace::enterJSFun(cx, fp, fun, fp->down, fp->numActualArgs(), fp->argv); #ifdef JS_TRACER if (TraceRecorder *tr = TRACE_RECORDER(cx)) { @@ -5112,7 +5112,7 @@ BEGIN_CASE(JSOP_GETARG) BEGIN_CASE(JSOP_CALLARG) { uint32 slot = GET_ARGNO(regs.pc); - JS_ASSERT(slot < fp->getArgumentCount()); + JS_ASSERT(slot < fp->numFormalArgs()); METER_SLOT_OP(op, slot); PUSH_COPY(fp->argv[slot]); if (op == JSOP_CALLARG) @@ -5123,7 +5123,7 @@ END_CASE(JSOP_GETARG) BEGIN_CASE(JSOP_SETARG) { uint32 slot = GET_ARGNO(regs.pc); - JS_ASSERT(slot < fp->getArgumentCount()); + JS_ASSERT(slot < fp->numFormalArgs()); METER_SLOT_OP(op, slot); fp->argv[slot] = regs.sp[-1]; } diff --git a/js/src/jsinterp.h b/js/src/jsinterp.h index 54d790f03e2..c8b948aa2f9 100644 --- a/js/src/jsinterp.h +++ b/js/src/jsinterp.h @@ -97,9 +97,9 @@ struct JSStackFrame JSFunction *fun; /* function being called or null */ js::Value thisv; /* "this" pointer if in method */ js::Value rval; /* function return value */ + uintN argc; /* actual argument count */ public: - uintN argc; /* actual argument count */ js::Value *argv; /* base of argument stack slots */ /* Maintained by StackSpace operations */ @@ -383,7 +383,7 @@ struct JSStackFrame return fun; } - size_t getArgumentCount() const { + size_t numFormalArgs() const { return getFunction()->nargs; } @@ -423,6 +423,20 @@ struct JSStackFrame return offsetof(JSStackFrame, rval); } + /* Argument count accessors */ + + size_t numActualArgs() const { + return argc; + } + + void setNumActualArgs(size_t n) { + argc = n; + } + + static size_t offsetNumActualArgs() { + return offsetof(JSStackFrame, argc); + } + /* Other accessors */ void putActivationObjects(JSContext *cx) { diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 892923bc3e7..c3c338e1b90 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -1095,8 +1095,8 @@ js_NewGenerator(JSContext *cx) /* Load and compute stack slot counts. */ JSStackFrame *fp = cx->fp; - uintN argc = fp->argc; - uintN nargs = JS_MAX(argc, fp->getArgumentCount()); + uintN argc = fp->numActualArgs(); + uintN nargs = JS_MAX(argc, fp->numFormalArgs()); uintN vplen = 2 + nargs; /* Compute JSGenerator size. */ @@ -1139,7 +1139,7 @@ js_NewGenerator(JSContext *cx) newfp->setScript(fp->getScript()); newfp->setFunction(fp->getFunction()); newfp->setThisValue(fp->getThisValue()); - newfp->argc = fp->argc; + newfp->setNumActualArgs(fp->numActualArgs()); newfp->argv = vp + 2; newfp->setReturnValue(fp->getReturnValue()); newfp->setAnnotation(NULL); diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index d7264f070d0..04af3156427 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -6398,7 +6398,8 @@ js_DumpStackFrame(JSContext *cx, JSStackFrame *start) fputc('\n', stderr); } } - fprintf(stderr, " argv: %p (argc: %u)\n", (void *) fp->argv, (unsigned) fp->argc); + fprintf(stderr, " argv: %p (argc: %u)\n", + (void *) fp->argv, (unsigned) fp->numActualArgs()); MaybeDumpObject("callobj", fp->maybeCallObj()); MaybeDumpObject("argsobj", fp->maybeArgsObj()); MaybeDumpValue("this", fp->getThisValue()); diff --git a/js/src/jsrecursion.cpp b/js/src/jsrecursion.cpp index 18ccba269ab..d2b1bc6c78a 100644 --- a/js/src/jsrecursion.cpp +++ b/js/src/jsrecursion.cpp @@ -257,10 +257,10 @@ TraceRecorder::upRecursion() * moved on this one. */ fi->spdist = DownFrameSP(cx) - cx->fp->down->slots(); - JS_ASSERT(cx->fp->argc == cx->fp->down->argc); - fi->set_argc(uint16(cx->fp->argc), false); + JS_ASSERT(cx->fp->numActualArgs() == cx->fp->down->numActualArgs()); + fi->set_argc(uint16(cx->fp->numActualArgs()), false); fi->callerHeight = downPostSlots; - fi->callerArgc = cx->fp->down->argc; + fi->callerArgc = cx->fp->down->numActualArgs(); if (anchor && anchor->exitType == RECURSIVE_MISMATCH_EXIT) { /* @@ -390,7 +390,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus TraceRecorder::slurpDownFrames(jsbytecode* return_pc) { /* Missing - no go */ - if (cx->fp->argc != cx->fp->getArgumentCount()) + if (cx->fp->numActualArgs() != cx->fp->numFormalArgs()) RETURN_STOP_A("argc != nargs"); LIns* argv_ins; @@ -450,10 +450,10 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc) /* fp->down->argc should be == argc. */ guard(true, lir->ins2(LIR_eqi, - addName(lir->insLoad(LIR_ldi, fp_ins, offsetof(JSStackFrame, argc), + addName(lir->insLoad(LIR_ldi, fp_ins, JSStackFrame::offsetNumActualArgs(), ACCSET_OTHER), "argc"), - INS_CONST(cx->fp->argc)), + INS_CONST(cx->fp->numActualArgs())), MISMATCH_EXIT); /* Pop the interpreter frame. */ @@ -591,7 +591,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc) /* this */ slurpSlot(argv_ins, -1 * ptrdiff_t(sizeof(Value)), &fp->argv[-1], &info); /* args[0..n] */ - for (unsigned i = 0; i < JS_MAX(fp->argc, fp->getArgumentCount()); i++) + for (unsigned i = 0; i < JS_MAX(fp->numActualArgs(), fp->numFormalArgs()); i++) slurpSlot(argv_ins, i * sizeof(Value), &fp->argv[i], &info); /* argsobj */ slurpFrameObjPtrSlot(fp_ins, JSStackFrame::offsetArgsObj(), fp->addressArgsObj(), &info); @@ -614,7 +614,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc) if (anchor && anchor->exitType == RECURSIVE_SLURP_FAIL_EXIT) limit--; else - limit -= fp->getArgumentCount() + 2; + limit -= fp->numFormalArgs() + 2; for (size_t i = 0; i < limit; i++) slurpSlot(stack_ins, i * sizeof(Value), &stack[i], &info); @@ -681,7 +681,8 @@ TraceRecorder::downRecursion() /* Adjust the stack by the budget the down-frame needs. */ int slots = NativeStackSlots(cx, 1) - NativeStackSlots(cx, 0); - JS_ASSERT(unsigned(slots) == NativeStackSlots(cx, 1) - fp->argc - 2 - fp->getFixedCount() - 2); + JS_ASSERT(unsigned(slots) == + NativeStackSlots(cx, 1) - fp->numActualArgs() - 2 - fp->getFixedCount() - 2); /* Guard that there is enough stack space. */ JS_ASSERT(tree->maxNativeStackSlots >= tree->nativeStackBase / sizeof(double)); diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 9857026d1a3..25c76b69ee2 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -1092,7 +1092,7 @@ Tracker::set(const void* v, LIns* i) static inline jsuint argSlots(JSStackFrame* fp) { - return JS_MAX(fp->argc, fp->getArgumentCount()); + return JS_MAX(fp->numActualArgs(), fp->numFormalArgs()); } static inline bool @@ -1835,7 +1835,7 @@ VisitFrameSlots(Visitor &visitor, JSContext *cx, unsigned depth, if (!visitor.visitStackSlots(base, size_t(sp - base), fp)) return false; if (up) { - int missing = up->getArgumentCount() - up->argc; + int missing = up->numFormalArgs() - up->numActualArgs(); if (missing > 0) { visitor.setStackSlotKind("missing"); if (!visitor.visitStackSlots(sp, size_t(missing), fp)) @@ -2008,7 +2008,7 @@ NativeStackSlots(JSContext *cx, unsigned callDepth) #endif return slots; } - int missing = fp->getArgumentCount() - fp->argc; + int missing = fp->numFormalArgs() - fp->numActualArgs(); if (missing > 0) slots += missing; } @@ -3374,10 +3374,12 @@ struct VarClosureTraits // See documentation on ArgClosureTraits for what these functions // should be doing. // See also UpvarVarTraits. - static inline uint32 adj_slot(JSStackFrame* fp, uint32 slot) { return 4 + fp->argc + slot; } + static inline uint32 adj_slot(JSStackFrame* fp, uint32 slot) { + return 4 + fp->numActualArgs() + slot; + } static inline LIns* adj_slot_lir(LirWriter* lir, LIns* fp_ins, unsigned slot) { - LIns *argc_ins = lir->insLoad(LIR_ldi, fp_ins, offsetof(JSStackFrame, argc), ACCSET_OTHER); + LIns *argc_ins = lir->insLoad(LIR_ldi, fp_ins, JSStackFrame::offsetNumActualArgs(), ACCSET_OTHER); return lir->ins2(LIR_addi, lir->insImmI(4 + slot), argc_ins); } @@ -3535,14 +3537,14 @@ TraceRecorder::importImpl(LIns* base, ptrdiff_t offset, const void* p, JSValueTy : ""; } if (!strcmp(prefix, "argv")) { - if (index < fp->getArgumentCount()) { + if (index < fp->numFormalArgs()) { JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[index]); JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom)); } else { JS_snprintf(name, sizeof name, "$%s.", funName, index); } } else if (!strcmp(prefix, "vars")) { - JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[fp->getArgumentCount() + index]); + JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[fp->numFormalArgs() + index]); JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom)); } else { JS_snprintf(name, sizeof name, "$%s%d", prefix, index); @@ -5706,7 +5708,7 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee) newfp->setArgsObj(NULL); newfp->setScript(newscript); newfp->setFunction(fun); - newfp->argc = argc; + newfp->setNumActualArgs(argc); newfp->argv = argv; #ifdef DEBUG // Initialize argv[-1] to a known-bogus value so we'll catch it if @@ -5754,7 +5756,7 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee) * some of the complexity? */ return (fi.spdist - newfp->down->getFixedCount()) + - ((fun->nargs > newfp->argc) ? fun->nargs - newfp->argc : 0) + + ((fun->nargs > newfp->numActualArgs()) ? fun->nargs - newfp->numActualArgs() : 0) + newscript->nfixed + SPECIAL_FRAME_SLOTS; } @@ -5781,7 +5783,7 @@ SynthesizeSlowNativeFrame(TracerState& state, JSContext *cx, VMSideExit *exit) fp->setArgsObj(NULL); fp->setScript(NULL); fp->setThisValue(state.nativeVp[1]); - fp->argc = state.nativeVpLen - 2; + fp->setNumActualArgs(state.nativeVpLen - 2); fp->argv = state.nativeVp + 2; fp->setFunction(GET_FUNCTION_PRIVATE(cx, fp->callee())); fp->clearReturnValue(); @@ -5973,7 +5975,7 @@ AttemptToStabilizeTree(JSContext* cx, JSObject* globalObj, VMSideExit* exit, jsb } if (exit->recursive_pc != cx->regs->pc) return false; - from = LookupLoop(tm, exit->recursive_pc, globalObj, globalShape, cx->fp->argc); + from = LookupLoop(tm, exit->recursive_pc, globalObj, globalShape, cx->fp->numActualArgs()); if (!from) return false; /* use stale TI for RecordTree - since from might not have one anymore. */ @@ -6100,8 +6102,8 @@ AttemptToExtendTree(JSContext* cx, VMSideExit* anchor, VMSideExit* exitedFrom, j } JS_ASSERT(ngslots >= anchor->numGlobalSlots); bool rv = TraceRecorder::startRecorder(cx, anchor, c, stackSlots, ngslots, typeMap, - exitedFrom, outer, cx->fp->argc, Record_Branch, - hits < maxHits); + exitedFrom, outer, cx->fp->numActualArgs(), + Record_Branch, hits < maxHits); #ifdef MOZ_TRACEVIS if (!rv && tvso) tvso->r = R_FAIL_EXTEND_START; @@ -6149,7 +6151,7 @@ TraceRecorder::recordLoopEdge(JSContext* cx, TraceRecorder* r, uintN& inlineCall JS_ASSERT(r->fragment && !r->fragment->lastIns); TreeFragment* root = r->fragment->root; TreeFragment* first = LookupOrAddLoop(tm, cx->regs->pc, root->globalObj, - root->globalShape, cx->fp->argc); + root->globalShape, cx->fp->numActualArgs()); /* * Make sure the shape of the global object still matches (this might flush @@ -6177,7 +6179,7 @@ TraceRecorder::recordLoopEdge(JSContext* cx, TraceRecorder* r, uintN& inlineCall TreeFragment* outerFragment = root; jsbytecode* outer = (jsbytecode*) outerFragment->ip; uint32 outerArgc = outerFragment->argc; - JS_ASSERT(cx->fp->argc == first->argc); + JS_ASSERT(cx->fp->numActualArgs() == first->argc); AbortRecording(cx, "No compatible inner tree"); return RecordingIfTrue(RecordTree(cx, first, outer, outerArgc, globalSlots, Record_Branch)); @@ -7189,7 +7191,7 @@ MonitorLoopEdge(JSContext* cx, uintN& inlineCallCount, RecordReason reason) } jsbytecode* pc = cx->regs->pc; - uint32 argc = cx->fp->argc; + uint32 argc = cx->fp->numActualArgs(); TreeFragment* f = LookupOrAddLoop(tm, pc, globalObj, globalShape, argc); @@ -8047,7 +8049,7 @@ DeepBail(JSContext *cx) JS_REQUIRES_STACK Value& TraceRecorder::argval(unsigned n) const { - JS_ASSERT(n < cx->fp->getArgumentCount()); + JS_ASSERT(n < cx->fp->numFormalArgs()); return cx->fp->argv[n]; } @@ -8232,7 +8234,7 @@ TraceRecorder::callProp(JSObject* obj, JSProperty* prop, jsid id, Value*& vp, JSStackFrame* cfp = (JSStackFrame*) obj->getPrivate(); if (cfp) { if (sprop->getterOp() == js_GetCallArg) { - JS_ASSERT(slot < cfp->getArgumentCount()); + JS_ASSERT(slot < cfp->numFormalArgs()); vp = &cfp->argv[slot]; upvar_slot = slot; nr.v = *vp; @@ -8240,7 +8242,7 @@ TraceRecorder::callProp(JSObject* obj, JSProperty* prop, jsid id, Value*& vp, sprop->getterOp() == js_GetCallVarChecked) { JS_ASSERT(slot < cfp->getSlotCount()); vp = &cfp->slots()[slot]; - upvar_slot = cx->fp->getArgumentCount() + slot; + upvar_slot = cx->fp->numFormalArgs() + slot; nr.v = *vp; } else { RETURN_STOP("dynamic property of Call object"); @@ -10292,7 +10294,9 @@ TraceRecorder::clearCurrentFrameSlotsFromTracker(Tracker& which) JS_REQUIRES_STACK void TraceRecorder::putActivationObjects() { - bool have_args = cx->fp->hasArgsObj() && !cx->fp->getArgsObj()->isStrictArguments() && cx->fp->argc > 0; + bool have_args = cx->fp->hasArgsObj() && + !cx->fp->getArgsObj()->isStrictArguments() && + cx->fp->numActualArgs() > 0; bool have_call = cx->fp->hasFunction() && JSFUN_HEAVYWEIGHT_TEST(cx->fp->getFunction()->flags) && cx->fp->getFunction()->countArgsAndVars(); @@ -10300,7 +10304,7 @@ TraceRecorder::putActivationObjects() if (!have_args && !have_call) return; - int nargs = have_args ? argSlots(cx->fp) : cx->fp->getArgumentCount(); + int nargs = have_args ? argSlots(cx->fp) : cx->fp->numFormalArgs(); LIns* args_ins; if (nargs) { @@ -10334,7 +10338,7 @@ TraceRecorder::putActivationObjects() LIns* scopeChain_ins = getFrameObjPtr(cx->fp->addressScopeChain()); LIns* args[] = { slots_ins, INS_CONST(nslots), args_ins, - INS_CONST(cx->fp->getArgumentCount()), scopeChain_ins, cx_ins }; + INS_CONST(cx->fp->numFormalArgs()), scopeChain_ins, cx_ins }; lir->insCall(&js_PutCallObjectOnTrace_ci, args); } } @@ -10348,9 +10352,9 @@ IsTraceableRecursion(JSContext *cx) return false; if (down->maybeScript() != fp->maybeScript()) return false; - if (down->argc != fp->argc) + if (down->numActualArgs() != fp->numActualArgs()) return false; - if (fp->argc != fp->getArgumentCount()) + if (fp->numActualArgs() != fp->numFormalArgs()) return false; if (fp->hasIMacroPC() || down->hasIMacroPC()) return false; @@ -10395,8 +10399,8 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount) // This doesn't do layout arithmetic, but it must initialize in the tracker all the // slots defined as imported by VisitFrameSlots. - Value* vp = &fp->argv[fp->argc]; - Value* vpstop = vp + ptrdiff_t(fp->getArgumentCount()) - ptrdiff_t(fp->argc); + Value* vp = &fp->argv[fp->numActualArgs()]; + Value* vpstop = vp + ptrdiff_t(fp->numFormalArgs()) - ptrdiff_t(fp->numActualArgs()); for (; vp < vpstop; ++vp) { nativeFrameTracker.set(vp, NULL); set(vp, void_ins); @@ -10462,7 +10466,7 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount) } TreeFragment* first = LookupLoop(&JS_TRACE_MONITOR(cx), cx->regs->pc, tree->globalObj, - tree->globalShape, fp->argc); + tree->globalShape, fp->numActualArgs()); if (!first) return ARECORD_CONTINUE; TreeFragment* f = findNestedCompatiblePeer(first); @@ -10482,7 +10486,7 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount) JSContext* _cx = cx; SlotList* globalSlots = tree->globalSlots; AbortRecording(cx, "trying to compile inner recursive tree"); - JS_ASSERT(_cx->fp->argc == first->argc); + JS_ASSERT(_cx->fp->numActualArgs() == first->argc); RecordTree(_cx, first, NULL, 0, globalSlots, Record_EnterFrame); break; } @@ -10651,7 +10655,7 @@ LIns* TraceRecorder::newArguments(LIns* callee_ins, bool strict) { LIns* global_ins = INS_CONSTOBJ(globalObj); - LIns* argc_ins = INS_CONST(cx->fp->argc); + LIns* argc_ins = INS_CONST(cx->fp->numActualArgs()); LIns* args[] = { callee_ins, argc_ins, global_ins, cx_ins }; LIns* call_ins = lir->insCall(&js_Arguments_ci, args); @@ -10659,7 +10663,7 @@ TraceRecorder::newArguments(LIns* callee_ins, bool strict) if (strict) { JSStackFrame* fp = cx->fp; - uintN argc = fp->argc; + uintN argc = fp->numActualArgs(); LIns* argsSlots_ins = NULL; for (uintN i = 0; i < argc; i++) stobj_set_dslot(call_ins, i, argsSlots_ins, fp->argv[i], get(&fp->argv[i])); @@ -12683,7 +12687,7 @@ TraceRecorder::record_JSOP_GETELEM() uintN int_idx = idx.toInt32(); Value* vp = &afp->argv[int_idx]; if (idx_ins->isImmD()) { - if (int_idx < 0 || int_idx >= afp->argc) + if (int_idx < 0 || int_idx >= afp->numActualArgs()) RETURN_STOP_A("cannot trace arguments with out of range index"); v_ins = get(vp); } else { @@ -12691,7 +12695,7 @@ TraceRecorder::record_JSOP_GETELEM() // the native stack area. The guard on js_ArgumentClass above ensures the up-to-date // value has been written back to the native stack area. idx_ins = makeNumberInt32(idx_ins); - if (int_idx < 0 || int_idx >= afp->argc) + if (int_idx < 0 || int_idx >= afp->numActualArgs()) RETURN_STOP_A("cannot trace arguments with out of range index"); VMSideExit *exit = snapshot(MISMATCH_EXIT); @@ -12700,7 +12704,7 @@ TraceRecorder::record_JSOP_GETELEM() "guard(upvar index >= 0)"), exit); guard(true, - addName(lir->ins2(LIR_lti, idx_ins, INS_CONST(afp->argc)), + addName(lir->ins2(LIR_lti, idx_ins, INS_CONST(afp->numActualArgs())), "guard(upvar index in range)"), exit); @@ -12740,7 +12744,7 @@ TraceRecorder::record_JSOP_GETELEM() BRANCH_EXIT); // Read the value out of the native stack area. - guard(true, lir->ins2(LIR_ltui, idx_ins, INS_CONST(afp->argc)), + guard(true, lir->ins2(LIR_ltui, idx_ins, INS_CONST(afp->numActualArgs())), snapshot(BRANCH_EXIT)); size_t stackOffset = nativespOffset(&afp->argv[0]); LIns* args_addr_ins = lir->ins2(LIR_addp, lirbuf->sp, INS_CONSTWORD(stackOffset)); @@ -13172,7 +13176,7 @@ TraceRecorder::upvar(JSScript* script, JSUpvarArray* uva, uintN index, Value& v) if (!fp->hasFunction() || (fp->flags & JSFRAME_EVAL)) { ci = &GetUpvarStackOnTrace_ci; slot = cookieSlot; - } else if (cookieSlot < fp->getArgumentCount()) { + } else if (cookieSlot < fp->numFormalArgs()) { ci = &GetUpvarArgOnTrace_ci; slot = cookieSlot; } else if (cookieSlot == UpvarCookie::CALLEE_SLOT) { @@ -13180,7 +13184,7 @@ TraceRecorder::upvar(JSScript* script, JSUpvarArray* uva, uintN index, Value& v) slot = -2; } else { ci = &GetUpvarVarOnTrace_ci; - slot = cookieSlot - fp->getArgumentCount(); + slot = cookieSlot - fp->numFormalArgs(); } LIns* outp = lir->insAlloc(sizeof(double)); @@ -13410,7 +13414,7 @@ TraceRecorder::interpretedFunctionCall(Value& fval, JSFunction* fun, uintN argc, fi->spdist = cx->regs->sp - fp->slots(); fi->set_argc(uint16(argc), constructing); fi->callerHeight = stackSlots - (2 + argc); - fi->callerArgc = fp->argc; + fi->callerArgc = fp->numActualArgs(); if (callDepth >= tree->maxCallDepth) tree->maxCallDepth = callDepth + 1; @@ -13533,7 +13537,7 @@ TraceRecorder::record_JSOP_APPLY() JSStackFrame *afp = guardArguments(aobj, aobj_ins, &depth); if (!afp) RETURN_STOP_A("can't reach arguments object's frame"); - length = afp->argc; + length = afp->numActualArgs(); } else { RETURN_STOP_A("arguments parameter of apply is not a dense array or argments object"); } @@ -15242,7 +15246,7 @@ TraceRecorder::record_JSOP_ARGSUB() JSStackFrame* const fp = cx->fp; if (!(fp->getFunction()->flags & JSFUN_HEAVYWEIGHT)) { uintN slot = GET_ARGNO(cx->regs->pc); - if (slot >= fp->argc) + if (slot >= fp->numActualArgs()) RETURN_STOP_A("can't trace out-of-range arguments"); stack(0, get(&cx->fp->argv[slot])); return ARECORD_CONTINUE; @@ -15282,7 +15286,7 @@ TraceRecorder::record_JSOP_ARGCNT() LIns *label = lir->ins0(LIR_label); br->setTarget(label); } - stack(0, lir->insImmD(cx->fp->argc)); + stack(0, lir->insImmD(cx->fp->numActualArgs())); return ARECORD_CONTINUE; }