From 1ac89d1c096ede21339cf2f626a009513b974846 Mon Sep 17 00:00:00 2001 From: Robert Sayre Date: Thu, 6 Jan 2011 21:41:25 -0500 Subject: [PATCH] Backed out changeset 2e94f0b8d03c --- js/src/jsfun.cpp | 93 +++++++++++-------------- js/src/jsinterp.cpp | 3 +- js/src/jsinterpinlines.h | 29 ++------ js/src/methodjit/InvokeHelpers.cpp | 7 ++ js/src/methodjit/StubCalls.h | 1 + js/src/tests/ecma_5/eval/jstests.list | 32 ++++----- js/src/tests/ecma_5/strict/jstests.list | 2 +- 7 files changed, 75 insertions(+), 92 deletions(-) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 81c9ff82cd57..dff2a0571636 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -1079,70 +1079,58 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp) /* Get the arguments object to snapshot fp's actual argument values. */ if (fp->hasArgsObj()) { - JS_ASSERT(!fp->isEvalFrame()); if (!fp->hasOverriddenArgs()) callobj.setCallObjArguments(ObjectValue(fp->argsObj())); js_PutArgsObject(cx, fp); } - JSScript *script = fp->script(); - Bindings &bindings = script->bindings; + JSFunction *fun = fp->fun(); + JS_ASSERT(fun == callobj.getCallObjCalleeFunction()); - JSObject *callee = callobj.getCallObjCallee(); - if (callee) { - JSFunction *fun = fp->fun(); - JS_ASSERT(fun == callee->getFunctionPrivate()); - JS_ASSERT(script == fun->script()); + Bindings &bindings = fun->script()->bindings; + uintN n = bindings.countArgsAndVars(); - if (uintN n = bindings.countArgsAndVars()) { - JS_ASSERT(JSObject::CALL_RESERVED_SLOTS + n <= callobj.numSlots()); + if (n != 0) { + JS_ASSERT(JSFunction::CLASS_RESERVED_SLOTS + n <= callobj.numSlots()); - uint32 nvars = bindings.countVars(); - uint32 nargs = bindings.countArgs(); - JS_ASSERT(fun->nargs == nargs); - JS_ASSERT(nvars + nargs == n); + uint32 nvars = bindings.countVars(); + uint32 nargs = bindings.countArgs(); + JS_ASSERT(fun->nargs == nargs); + JS_ASSERT(nvars + nargs == n); - JSScript *script = fun->script(); - if (script->usesEval - #ifdef JS_METHODJIT - || script->debugMode - #endif - ) { - CopyValuesToCallObject(callobj, nargs, fp->formalArgs(), nvars, fp->slots()); - } else { - /* - * For each arg & var that is closed over, copy it from the stack - * into the call object. - */ - uint32 nclosed = script->nClosedArgs; - for (uint32 i = 0; i < nclosed; i++) { - uint32 e = script->getClosedArg(i); - callobj.setSlot(JSObject::CALL_RESERVED_SLOTS + e, fp->formalArg(e)); - } + JSScript *script = fun->script(); + if (script->usesEval +#ifdef JS_METHODJIT + || script->debugMode +#endif + ) { + CopyValuesToCallObject(callobj, nargs, fp->formalArgs(), nvars, fp->slots()); + } else { + /* + * For each arg & var that is closed over, copy it from the stack + * into the call object. + */ + uint32 nclosed = script->nClosedArgs; + for (uint32 i = 0; i < nclosed; i++) { + uint32 e = script->getClosedArg(i); + callobj.setSlot(JSObject::CALL_RESERVED_SLOTS + e, fp->formalArg(e)); + } - nclosed = script->nClosedVars; - for (uint32 i = 0; i < nclosed; i++) { - uint32 e = script->getClosedVar(i); - callobj.setSlot(JSObject::CALL_RESERVED_SLOTS + nargs + e, fp->slots()[e]); - } + nclosed = script->nClosedVars; + for (uint32 i = 0; i < nclosed; i++) { + uint32 e = script->getClosedVar(i); + callobj.setSlot(JSObject::CALL_RESERVED_SLOTS + nargs + e, fp->slots()[e]); } } + } - /* Clear private pointers to fp, which is about to go away (js_Invoke). */ - if (js_IsNamedLambda(fun)) { - JSObject *env = callobj.getParent(); + /* Clear private pointers to fp, which is about to go away (js_Invoke). */ + if (js_IsNamedLambda(fun)) { + JSObject *env = callobj.getParent(); - JS_ASSERT(env->getClass() == &js_DeclEnvClass); - JS_ASSERT(env->getPrivate() == fp); - env->setPrivate(NULL); - } - } else { - JS_ASSERT(fp->isEvalFrame()); - JS_ASSERT(script->strictModeCode); - JS_ASSERT(bindings.countArgs() == 0); - - /* This could be optimized as above. But for now, keep it simple. */ - CopyValuesToCallObject(callobj, 0, NULL, bindings.countVars(), fp->slots()); + JS_ASSERT(env->getClass() == &js_DeclEnvClass); + JS_ASSERT(env->getPrivate() == fp); + env->setPrivate(NULL); } callobj.setPrivate(NULL); @@ -1372,7 +1360,8 @@ static void call_trace(JSTracer *trc, JSObject *obj) { JS_ASSERT(obj->isCall()); - if (JSStackFrame *fp = obj->maybeCallObjStackFrame()) { + JSStackFrame *fp = (JSStackFrame *) obj->getPrivate(); + if (fp) { /* * FIXME: Hide copies of stack values rooted by fp from the Cycle * Collector, which currently lacks a non-stub Unlink implementation @@ -1381,7 +1370,7 @@ call_trace(JSTracer *trc, JSObject *obj) * hiding hack. */ uintN first = JSObject::CALL_RESERVED_SLOTS; - uintN count = fp->script()->bindings.countArgsAndVars(); + uintN count = fp->fun()->script()->bindings.countArgsAndVars(); JS_ASSERT(obj->numSlots() >= first + count); SetValueRangeToUndefined(obj->getSlots() + first, count); diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 2b45b37cd6a9..967a3427fe4d 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -966,12 +966,12 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, initialVarObj = (cx->options & JSOPTION_VAROBJFIX) ? chain->getGlobal() : chain; } +#if 0 /* to be reenabled shortly when this works */ /* * Strict mode eval code receives its own, fresh lexical environment; thus * strict mode eval can't mutate its calling frame's binding set. */ if (script->strictModeCode) { - AutoScriptRooter root(cx, script); initialVarObj = NewCallObject(cx, &script->bindings, *initialVarObj, NULL); if (!initialVarObj) return false; @@ -982,6 +982,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script, frame.fp()->clearCallObj(); frame.fp()->setScopeChainAndCallObj(*initialVarObj); } +#endif JS_ASSERT(!initialVarObj->getOps()->defineProperty); #if JS_HAS_SHARP_VARS diff --git a/js/src/jsinterpinlines.h b/js/src/jsinterpinlines.h index f449f92f620a..451e723bbe3a 100644 --- a/js/src/jsinterpinlines.h +++ b/js/src/jsinterpinlines.h @@ -722,28 +722,13 @@ ScriptEpilogue(JSContext *cx, JSStackFrame *fp, JSBool ok) if (JS_UNLIKELY(hook != NULL) && (hookData = fp->maybeHookData())) hook(cx, fp, JS_FALSE, &ok, hookData); - if (fp->isEvalFrame()) { - /* - * The parent (ancestor for nested eval) of a non-strict eval frame - * owns its activation objects. Strict mode eval frames own their own - * Call objects but never have an arguments object (the first non-eval - * parent frame has it). - */ - if (fp->script()->strictModeCode) { - JS_ASSERT(!fp->isYielding()); - JS_ASSERT(fp->hasCallObj()); - JS_ASSERT(!fp->hasArgsObj()); - js_PutCallObject(cx, fp); - } - } else { - /* - * Otherwise only function frames have activation objects. A yielding - * frame's activation objects are transferred to the floating frame, - * stored in the generator, and thus need not be synced. - */ - if (fp->isFunctionFrame() && !fp->isYielding()) - PutActivationObjects(cx, fp); - } + /* + * An eval frame's parent owns its activation objects. A yielding frame's + * activation objects are transferred to the floating frame, stored in the + * generator. + */ + if (fp->isFunctionFrame() && !fp->isEvalFrame() && !fp->isYielding()) + PutActivationObjects(cx, fp); /* * If inline-constructing, replace primitive rval with the new object diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp index 8e70f2bbf499..23070ce6b512 100644 --- a/js/src/methodjit/InvokeHelpers.cpp +++ b/js/src/methodjit/InvokeHelpers.cpp @@ -480,6 +480,13 @@ stubs::UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr) return; } +void JS_FASTCALL +stubs::PutCallObject(VMFrame &f) +{ + JS_ASSERT(f.fp()->hasCallObj()); + js_PutCallObject(f.cx, f.fp()); +} + void JS_FASTCALL stubs::PutActivationObjects(VMFrame &f) { diff --git a/js/src/methodjit/StubCalls.h b/js/src/methodjit/StubCalls.h index f3e106949bb6..9625906c6652 100644 --- a/js/src/methodjit/StubCalls.h +++ b/js/src/methodjit/StubCalls.h @@ -107,6 +107,7 @@ void UncachedNewHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr); void JS_FASTCALL CreateThis(VMFrame &f, JSObject *proto); void JS_FASTCALL Throw(VMFrame &f); +void JS_FASTCALL PutCallObject(VMFrame &f); void JS_FASTCALL PutActivationObjects(VMFrame &f); void JS_FASTCALL GetCallObject(VMFrame &f); #if JS_MONOIC diff --git a/js/src/tests/ecma_5/eval/jstests.list b/js/src/tests/ecma_5/eval/jstests.list index 8e7d1372e935..fed5de9a1aee 100644 --- a/js/src/tests/ecma_5/eval/jstests.list +++ b/js/src/tests/ecma_5/eval/jstests.list @@ -16,22 +16,22 @@ url-prefix ../../jsreftest.html?test=ecma_5/eval/ # optimizations we might perform -- add new tests for such changes as needed. # -script exhaustive-fun-normalcaller-direct-normalcode.js -script exhaustive-fun-normalcaller-direct-strictcode.js -script exhaustive-fun-normalcaller-indirect-normalcode.js -script exhaustive-fun-normalcaller-indirect-strictcode.js -script exhaustive-fun-strictcaller-direct-normalcode.js -script exhaustive-fun-strictcaller-direct-strictcode.js -script exhaustive-fun-strictcaller-indirect-normalcode.js -script exhaustive-fun-strictcaller-indirect-strictcode.js -script exhaustive-global-normalcaller-direct-normalcode.js -script exhaustive-global-normalcaller-direct-strictcode.js -script exhaustive-global-normalcaller-indirect-normalcode.js -script exhaustive-global-normalcaller-indirect-strictcode.js -script exhaustive-global-strictcaller-direct-normalcode.js -script exhaustive-global-strictcaller-direct-strictcode.js -script exhaustive-global-strictcaller-indirect-normalcode.js -script exhaustive-global-strictcaller-indirect-strictcode.js +# script exhaustive-fun-normalcaller-direct-normalcode.js +# script exhaustive-fun-normalcaller-direct-strictcode.js +# script exhaustive-fun-normalcaller-indirect-normalcode.js +# script exhaustive-fun-normalcaller-indirect-strictcode.js +# script exhaustive-fun-strictcaller-direct-normalcode.js +# script exhaustive-fun-strictcaller-direct-strictcode.js +# script exhaustive-fun-strictcaller-indirect-normalcode.js +# script exhaustive-fun-strictcaller-indirect-strictcode.js +# script exhaustive-global-normalcaller-direct-normalcode.js +# script exhaustive-global-normalcaller-direct-strictcode.js +# script exhaustive-global-normalcaller-indirect-normalcode.js +# script exhaustive-global-normalcaller-indirect-strictcode.js +# script exhaustive-global-strictcaller-direct-normalcode.js +# script exhaustive-global-strictcaller-direct-strictcode.js +# script exhaustive-global-strictcaller-indirect-normalcode.js +# script exhaustive-global-strictcaller-indirect-strictcode.js # Not written yet! These require a new shell primitive to work there, though # browser could probably use setTimeout for this. Moreover, we haven't diff --git a/js/src/tests/ecma_5/strict/jstests.list b/js/src/tests/ecma_5/strict/jstests.list index a5b58c2cbf63..87225af9b5bb 100644 --- a/js/src/tests/ecma_5/strict/jstests.list +++ b/js/src/tests/ecma_5/strict/jstests.list @@ -39,4 +39,4 @@ script unbrand-this.js script this-for-function-expression-recursion.js script assign-to-callee-name.js script directive-prologue-01.js -script eval-variable-environment.js +# script eval-variable-environment.js