From 4b9d50f0ba9bbe39109c3d2f6d330237080d0156 Mon Sep 17 00:00:00 2001 From: "shaver%mozilla.org" Date: Thu, 27 Sep 2001 14:52:14 +0000 Subject: [PATCH] Bug 94506: parameter named "arguments" is not accessible in JavaScript method. Now we check for the magic "arguments" name after var-and-arg slot optimizations. r=rogerl, sr=brendan git-svn-id: svn://10.0.0.236/trunk@103943 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsemit.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/mozilla/js/src/jsemit.c b/mozilla/js/src/jsemit.c index e19fd34202c..8b261111bd6 100644 --- a/mozilla/js/src/jsemit.c +++ b/mozilla/js/src/jsemit.c @@ -537,22 +537,11 @@ LookupArgOrVar(JSContext *cx, JSTreeContext *tc, JSParseNode *pn) } /* - * Ok, we may be able to optimize name to stack slot. We must check for - * the predefined arguments variable. It may be overridden by assignment, - * in which case the function is heavyweight and the interpreter will look - * up 'arguments' in the function's call object. - */ - if (pn->pn_op == JSOP_NAME && - atom == cx->runtime->atomState.argumentsAtom) { - pn->pn_op = JSOP_ARGUMENTS; - return JS_TRUE; - } - - /* - * Look for an argument or variable property in the function, or its call - * object, not found in any prototype object. Rewrite pn_op and update pn - * accordingly. NB: We know that JSOP_DELNAME on an argument or variable - * must evaluate to false, due to JSPROP_PERMANENT. + * Ok, we may be able to optimize name to stack slot. Look for an argument + * or variable property in the function, or its call object, not found in + * any prototype object. Rewrite pn_op and update pn accordingly. NB: We + * know that JSOP_DELNAME on an argument or variable must evaluate to + * false, due to JSPROP_PERMANENT. */ if (!js_LookupProperty(cx, obj, (jsid)atom, &pobj, (JSProperty **)&sprop)) return JS_FALSE; @@ -599,7 +588,19 @@ LookupArgOrVar(JSContext *cx, JSTreeContext *tc, JSParseNode *pn) } if (pn->pn_slot < 0) { - /* We couldn't optimize it, so it's not an arg or local var name. */ + /* + * We couldn't optimize it, so it's not an arg or local var name. Now + * we must check for the predefined arguments variable. It may be + * overridden by assignment, in which case the function is heavyweight + * and the interpreter will look up 'arguments' in the function's call + * object. + */ + if (pn->pn_op == JSOP_NAME && + atom == cx->runtime->atomState.argumentsAtom) { + pn->pn_op = JSOP_ARGUMENTS; + return JS_TRUE; + } + tc->flags |= TCF_FUN_USES_NONLOCALS; } return JS_TRUE;