From 11ad4b2679cb7b9281e51d5d94f4f938699ca89a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 22 Sep 2010 14:29:48 -0700 Subject: [PATCH] Fix method-JIT debug mode bugs and add more testing capability (bug 598444, r=sstangl). --- js/src/jsfun.cpp | 2 +- js/src/methodjit/Compiler.cpp | 2 +- js/src/methodjit/InvokeHelpers.cpp | 14 ++++++++------ js/src/shell/js.cpp | 6 +++++- js/src/trace-test/trace-test.py | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 99e1669690fe..b04d197ffec2 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -1133,7 +1133,7 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp) JS_STATIC_ASSERT(JS_INITIAL_NSLOTS == JSSLOT_PRIVATE + JSObject::CALL_RESERVED_SLOTS + 1); JSScript *script = fun->u.i.script; memcpy(callobj.dslots, fp->formalArgs(), nargs * sizeof(Value)); - if (!script->jit || script->usesEval) { + if (!script->jit || script->usesEval || script->debugMode) { memcpy(callobj.dslots + nargs, fp->slots(), nvars * sizeof(Value)); } else if (script->jit) { for (uint32 i = 0; i < script->jit->nescaping; i++) { diff --git a/js/src/methodjit/Compiler.cpp b/js/src/methodjit/Compiler.cpp index 19b60fe6b69b..ae1b0b32c750 100644 --- a/js/src/methodjit/Compiler.cpp +++ b/js/src/methodjit/Compiler.cpp @@ -1964,7 +1964,6 @@ mjit::Compiler::emitUncachedCall(uint32 argc, bool callingNew) ADD_CALLSITE(false); Jump notCompiled = masm.branchTestPtr(Assembler::Zero, r0, r0); - stubcc.linkExitDirect(notCompiled, stubcc.masm.label()); masm.call(r0); #if (defined(JS_NO_FASTCALL) && defined(JS_CPU_X86)) || defined(_WIN64) @@ -1980,6 +1979,7 @@ mjit::Compiler::emitUncachedCall(uint32 argc, bool callingNew) frame.takeReg(JSReturnReg_Data); frame.pushRegs(JSReturnReg_Type, JSReturnReg_Data); + stubcc.linkExitDirect(notCompiled, stubcc.masm.label()); stubcc.rejoin(Changes(0)); } diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp index 12cf05c4006a..864b1af53d64 100644 --- a/js/src/methodjit/InvokeHelpers.cpp +++ b/js/src/methodjit/InvokeHelpers.cpp @@ -487,16 +487,18 @@ stubs::UncachedNewHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr) /* Try to do a fast inline call before the general Invoke path. */ if (IsFunctionObject(*vp, &ucr->fun) && ucr->fun->isInterpreted() && - !ucr->fun->script()->isEmpty()) { + !ucr->fun->script()->isEmpty()) + { + if (!stubs::NewObject(f, argc)) + return; + ucr->callee = &vp->toObject(); if (!UncachedInlineCall(f, JSFRAME_CONSTRUCTING, &ucr->codeAddr, argc)) THROW(); - return; + } else { + if (!InvokeConstructor(cx, InvokeArgsAlreadyOnTheStack(vp, argc))) + THROW(); } - - if (!InvokeConstructor(cx, InvokeArgsAlreadyOnTheStack(vp, argc))) - THROW(); - return; } void * JS_FASTCALL diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 16f2a5ea5715..409e8c8af4ea 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -558,7 +558,7 @@ static int usage(void) { fprintf(gErrFile, "%s\n", JS_GetImplementationVersion()); - fprintf(gErrFile, "usage: js [-zKPswWxCij] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] " + fprintf(gErrFile, "usage: js [-zKPswWxCijmd] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] " #ifdef JS_GC_ZEAL "[-Z gczeal] " #endif @@ -836,6 +836,10 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc) gMaxStackSize = atoi(argv[i]); break; + case 'd': + js_SetDebugMode(cx, JS_TRUE); + break; + case 'z': obj = split_setup(cx, JS_FALSE); if (!obj) diff --git a/js/src/trace-test/trace-test.py b/js/src/trace-test/trace-test.py index 72fb85ffe2ce..23968f605c7a 100644 --- a/js/src/trace-test/trace-test.py +++ b/js/src/trace-test/trace-test.py @@ -257,7 +257,7 @@ def parse_jitflags(): for flags in OPTIONS.jitflags.split(',') ] for flags in jitflags: for flag in flags: - if flag not in ('-j', '-m'): + if flag not in ('-j', '-m', '-d'): print('Invalid jit flag: "%s"'%flag) sys.exit(1) return jitflags