Fixed cases where argc varied between recording time and execution time (bug 451727).

This commit is contained in:
Brendan Eich 2008-08-25 16:04:10 -07:00
parent eb8bbd11d2
commit b385e456d9

View File

@ -517,8 +517,7 @@ public:
vp = &fp->argv[-1]; \
{ code; } \
SET_VPNAME("argv"); \
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc); \
vp = &fp->argv[0]; vpstop = &fp->argv[nargs]; \
vp = &fp->argv[0]; vpstop = &fp->argv[fp->fun->nargs]; \
while (vp < vpstop) { code; ++vp; INC_VPNUM(); } \
} \
SET_VPNAME("vars"); \
@ -572,8 +571,8 @@ public:
/* Calculate the total number of native frame slots we need from this frame
all the way back to the entry frame, including the current stack usage. */
static unsigned
nativeStackSlots(JSContext *cx, unsigned callDepth)
unsigned
js_NativeStackSlots(JSContext *cx, unsigned callDepth)
{
JSStackFrame* fp = cx->fp;
unsigned slots = 0;
@ -588,8 +587,7 @@ nativeStackSlots(JSContext *cx, unsigned callDepth)
slots += fp->script->nfixed;
if (callDepth-- == 0) {
if (fp->callee) {
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc);
slots += 2/*callee,this*/ + nargs;
slots += 2/*callee,this*/ + fp->fun->nargs;
}
#if defined _DEBUG
unsigned int m = 0;
@ -604,7 +602,7 @@ nativeStackSlots(JSContext *cx, unsigned callDepth)
if (missing > 0)
slots += missing;
}
JS_NOT_REACHED("nativeStackSlots");
JS_NOT_REACHED("js_NativeStackSlots");
}
/* Capture the type map for the selected slots of the global object. */
@ -628,7 +626,7 @@ TypeMap::captureGlobalTypes(JSContext* cx, SlotList& slots)
void
TypeMap::captureStackTypes(JSContext* cx, unsigned callDepth)
{
setLength(nativeStackSlots(cx, callDepth));
setLength(js_NativeStackSlots(cx, callDepth));
uint8* map = data();
uint8* m = map;
FORALL_SLOTS_IN_PENDING_FRAMES(cx, callDepth,
@ -817,10 +815,9 @@ done:
fp = *fsp;
if (fp->callee) {
if (fsp == fstack) {
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc);
if (size_t(p - &fp->argv[-2]) < 2/*callee,this*/ + nargs)
if (size_t(p - &fp->argv[-2]) < 2/*callee,this*/ + fp->fun->nargs)
RETURN(offset + size_t(p - &fp->argv[-2]) * sizeof(double));
offset += (2/*callee,this*/ + nargs) * sizeof(double);
offset += (2/*callee,this*/ + fp->fun->nargs) * sizeof(double);
}
if (size_t(p - &fp->slots[0]) < fp->script->nfixed)
RETURN(offset + size_t(p - &fp->slots[0]) * sizeof(double));
@ -1352,7 +1349,7 @@ TraceRecorder::snapshot(ExitType exitType)
if (exitType == BRANCH_EXIT && js_IsLoopExit(cx, fp->script, fp->regs->pc))
exitType = LOOP_EXIT;
/* Generate the entry map and stash it in the trace. */
unsigned stackSlots = nativeStackSlots(cx, callDepth);
unsigned stackSlots = js_NativeStackSlots(cx, callDepth);
/* It's sufficient to track the native stack use here since all stores above the
stack watermark defined by guards are killed. */
trackNativeStackUse(stackSlots + 1);
@ -1820,7 +1817,7 @@ js_RecordTree(JSContext* cx, JSTraceMonitor* tm, Fragment* f)
/* determine the native frame layout at the entry point */
unsigned entryNativeStackSlots = ti->stackTypeMap.length();
JS_ASSERT(entryNativeStackSlots == nativeStackSlots(cx, 0/*callDepth*/));
JS_ASSERT(entryNativeStackSlots == js_NativeStackSlots(cx, 0/*callDepth*/));
ti->nativeStackBase = (entryNativeStackSlots -
(cx->fp->regs->sp - StackBase(cx->fp))) * sizeof(double);
ti->maxNativeStackSlots = entryNativeStackSlots;
@ -3109,7 +3106,7 @@ TraceRecorder::clearFrameSlotsFromCache()
jsval* vpstop;
if (fp->callee) {
vp = &fp->argv[-2];
vpstop = &fp->argv[JS_MAX(fp->fun->nargs,fp->argc)];
vpstop = &fp->argv[fp->fun->nargs];
while (vp < vpstop)
nativeFrameTracker.set(vp++, (LIns*)0);
}