This commit is contained in:
Blake Kaplan 2008-08-15 09:35:16 -07:00
commit a6f7e7c0f7
2 changed files with 30 additions and 30 deletions

View File

@ -1321,12 +1321,6 @@ have_fun:
} }
frame.slots = sp - fun->u.i.nvars; frame.slots = sp - fun->u.i.nvars;
ok = js_Interpret(cx); ok = js_Interpret(cx);
#ifdef JS_TRACER
if (JS_TRACE_MONITOR(cx).recorder) {
js_AbortRecording(cx, frame.down->regs->pc,
"recording out of js_Invoke interpreter activation");
}
#endif
} else { } else {
/* fun might be onerror trying to report a syntax error in itself. */ /* fun might be onerror trying to report a syntax error in itself. */
frame.scopeChain = NULL; frame.scopeChain = NULL;
@ -1570,14 +1564,6 @@ out2:
} }
out: out:
#ifdef JS_TRACER
if (JS_TRACE_MONITOR(cx).recorder) {
js_AbortRecording(cx, NULL,
"recording out of js_Execute interpreter activation");
}
#endif
#ifdef INCLUDE_MOZILLA_DTRACE #ifdef INCLUDE_MOZILLA_DTRACE
if (JAVASCRIPT_EXECUTE_DONE_ENABLED()) if (JAVASCRIPT_EXECUTE_DONE_ENABLED())
jsdtrace_execute_done(script); jsdtrace_execute_done(script);
@ -6978,6 +6964,10 @@ js_Interpret(JSContext *cx)
*/ */
JS_ASSERT(inlineCallCount == 0); JS_ASSERT(inlineCallCount == 0);
JS_ASSERT(fp->regs == &regs); JS_ASSERT(fp->regs == &regs);
#ifdef JS_TRACER
if (JS_TRACE_MONITOR(cx).recorder)
js_AbortRecording(cx, regs.pc, "recording out of js_Interpret");
#endif
if (JS_UNLIKELY(fp->flags & JSFRAME_YIELDING)) { if (JS_UNLIKELY(fp->flags & JSFRAME_YIELDING)) {
JSGenerator *gen; JSGenerator *gen;

View File

@ -482,9 +482,12 @@ public:
jsval* vpstop; \ jsval* vpstop; \
if (fp->callee) { \ if (fp->callee) { \
if (depth == 0) { \ if (depth == 0) { \
SET_VPNAME("callee"); \
vp = &fp->argv[-2]; \
{ code; } \
SET_VPNAME("this"); \ SET_VPNAME("this"); \
vp = &fp->argv[-1]; \ vp = &fp->argv[-1]; \
code; \ { code; } \
SET_VPNAME("argv"); \ SET_VPNAME("argv"); \
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc); \ unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc); \
vp = &fp->argv[0]; vpstop = &fp->argv[nargs]; \ vp = &fp->argv[0]; vpstop = &fp->argv[nargs]; \
@ -557,7 +560,7 @@ nativeStackSlots(JSContext *cx, unsigned callDepth, JSStackFrame* fp)
if (callDepth-- == 0) { if (callDepth-- == 0) {
if (fp->callee) { if (fp->callee) {
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc); unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc);
slots += 1/*this*/ + nargs; slots += 2/*callee,this*/ + nargs;
} }
#if defined _DEBUG #if defined _DEBUG
unsigned int m = 0; unsigned int m = 0;
@ -746,9 +749,9 @@ done:
if (fp->callee) { if (fp->callee) {
if (fsp == fstack) { if (fsp == fstack) {
unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc); unsigned nargs = JS_MAX(fp->fun->nargs, fp->argc);
if (size_t(p - &fp->argv[-1]) < nargs + 1) if (size_t(p - &fp->argv[-2]) < 2/*callee,this*/ + nargs)
RETURN(offset + size_t(p - &fp->argv[-1]) * sizeof(double)); RETURN(offset + size_t(p - &fp->argv[-2]) * sizeof(double));
offset += (nargs + 1) * sizeof(double); offset += (2/*callee,this*/ + nargs) * sizeof(double);
} }
if (size_t(p - &fp->slots[0]) < fp->script->nfixed) if (size_t(p - &fp->slots[0]) < fp->script->nfixed)
RETURN(offset + size_t(p - &fp->slots[0]) * sizeof(double)); RETURN(offset + size_t(p - &fp->slots[0]) * sizeof(double));
@ -1353,23 +1356,26 @@ TraceRecorder::emitTreeCall(Fragment* inner, GuardRecord* lr)
/* Calculate the amount we have to lift the native stack pointer by to compensate for /* Calculate the amount we have to lift the native stack pointer by to compensate for
any outer frames that the inner tree doesn't expect but the outer tree has. */ any outer frames that the inner tree doesn't expect but the outer tree has. */
ptrdiff_t sp_adj = nativeStackOffset(&cx->fp->argv[-2]); ptrdiff_t sp_adj = nativeStackOffset(&cx->fp->argv[-2]);
/* sp points to the native stack base of the outer tree and the inner tree might
need a different native stack base, so compensate for that. */
sp_adj -= treeInfo->nativeStackBase;
sp_adj += ti->nativeStackBase;
/* Calculate the amount we have to lift the call stack by */ /* Calculate the amount we have to lift the call stack by */
ptrdiff_t rp_adj = callDepth * sizeof(FrameInfo); ptrdiff_t rp_adj = callDepth * sizeof(FrameInfo);
/* Guard that we have enough stack space for the tree we are trying to call on top /* Guard that we have enough stack space for the tree we are trying to call on top
of the new value for sp. */ of the new value for sp. */
LIns* sp_top = lir->ins2i(LIR_add, lirbuf->sp, sp_adj + debug_only(printf("sp_adj=%d outer=%d inner=%d\n",
ti->maxNativeStackSlots * sizeof(double)); sp_adj, treeInfo->nativeStackBase, ti->nativeStackBase));
LIns* sp_top = lir->ins2i(LIR_add, lirbuf->sp,
- treeInfo->nativeStackBase /* rebase sp to beginning of outer tree's stack */
+ sp_adj /* adjust for stack in outer frame inner tree can't see */
+ ti->maxNativeStackSlots * sizeof(double)); /* plus the inner tree's stack */
guard(true, lir->ins2(LIR_lt, sp_top, eos_ins), OOM_EXIT); guard(true, lir->ins2(LIR_lt, sp_top, eos_ins), OOM_EXIT);
/* Guard that we have enough call stack space. */ /* Guard that we have enough call stack space. */
LIns* rp_top = lir->ins2i(LIR_add, lirbuf->rp, rp_adj + LIns* rp_top = lir->ins2i(LIR_add, lirbuf->rp, rp_adj +
ti->maxCallDepth * sizeof(FrameInfo)); ti->maxCallDepth * sizeof(FrameInfo));
guard(true, lir->ins2(LIR_lt, rp_top, eor_ins), OOM_EXIT); guard(true, lir->ins2(LIR_lt, rp_top, eor_ins), OOM_EXIT);
/* We have enough space, so adjust sp and rp to their new level. */ /* We have enough space, so adjust sp and rp to their new level. */
lir->insStorei(inner_sp = lir->ins2i(LIR_add, lirbuf->sp, sp_adj), lir->insStorei(inner_sp = lir->ins2i(LIR_add, lirbuf->sp,
- treeInfo->nativeStackBase /* rebase sp to beginning of outer tree's stack */
+ sp_adj /* adjust for stack in outer frame inner tree can't see */
+ ti->nativeStackBase), /* plus the inner tree's stack base */
lirbuf->state, offsetof(InterpState, sp)); lirbuf->state, offsetof(InterpState, sp));
lir->insStorei(lir->ins2i(LIR_add, lirbuf->rp, rp_adj), lir->insStorei(lir->ins2i(LIR_add, lirbuf->rp, rp_adj),
lirbuf->state, offsetof(InterpState, rp)); lirbuf->state, offsetof(InterpState, rp));
@ -1794,7 +1800,7 @@ js_ExecuteTree(JSContext* cx, Fragment* f, uintN& inlineCallCount)
call guard or the innermost tree exit guard will restore. */ call guard or the innermost tree exit guard will restore. */
unsigned slots = FlushNativeStackFrame(cx, calldepth, unsigned slots = FlushNativeStackFrame(cx, calldepth,
lr->exit->typeMap + lr->exit->numGlobalSlots, lr->exit->typeMap + lr->exit->numGlobalSlots,
stack, &cx->fp->argv[-1]); stack, &cx->fp->argv[-2]);
callstack += calldepth; callstack += calldepth;
inlineCallCount += calldepth; inlineCallCount += calldepth;
stack += slots; stack += slots;
@ -2171,6 +2177,9 @@ TraceRecorder::cmp(LOpcode op, bool negate)
return false; return false;
} }
} else if (isNumber(l) || isNumber(r)) { } else if (isNumber(l) || isNumber(r)) {
jsval tmp[2] = {l, r};
JSAutoTempValueRooter tvr(cx, 2, tmp);
// TODO: coerce non-numbers to numbers if it's not string-on-string above // TODO: coerce non-numbers to numbers if it's not string-on-string above
LIns* l_ins = get(&l); LIns* l_ins = get(&l);
LIns* r_ins = get(&r); LIns* r_ins = get(&r);
@ -2191,7 +2200,7 @@ TraceRecorder::cmp(LOpcode op, bool negate)
} else if (!isNumber(l)) { } else if (!isNumber(l)) {
ABORT_TRACE("unsupported LHS type for cmp vs number"); ABORT_TRACE("unsupported LHS type for cmp vs number");
} }
lnum = js_ValueToNumber(cx, &l); lnum = js_ValueToNumber(cx, &tmp[0]);
args[0] = get(&r); args[0] = get(&r);
if (JSVAL_IS_STRING(r)) { if (JSVAL_IS_STRING(r)) {
@ -2202,9 +2211,10 @@ TraceRecorder::cmp(LOpcode op, bool negate)
} else if (!isNumber(r)) { } else if (!isNumber(r)) {
ABORT_TRACE("unsupported RHS type for cmp vs number"); ABORT_TRACE("unsupported RHS type for cmp vs number");
} }
rnum = js_ValueToNumber(cx, &r); rnum = js_ValueToNumber(cx, &tmp[1]);
x = lir->ins2(op, l_ins, r_ins); x = lir->ins2(op, l_ins, r_ins);
if (negate) if (negate)
x = lir->ins_eq0(x); x = lir->ins_eq0(x);
switch (op) { switch (op) {
@ -2701,7 +2711,7 @@ TraceRecorder::clearFrameSlotsFromCache()
jsval* vp; jsval* vp;
jsval* vpstop; jsval* vpstop;
if (fp->callee) { if (fp->callee) {
vp = &fp->argv[-1]; vp = &fp->argv[-2];
vpstop = &fp->argv[JS_MAX(fp->fun->nargs,fp->argc)]; vpstop = &fp->argv[JS_MAX(fp->fun->nargs,fp->argc)];
while (vp < vpstop) while (vp < vpstop)
nativeFrameTracker.set(vp++, (LIns*)0); nativeFrameTracker.set(vp++, (LIns*)0);