From c4ead6da5c20b18a2137e29fa705290f170d98f6 Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Thu, 7 Oct 2010 11:33:23 -0700 Subject: [PATCH] Nit-picks, mainly localizing and initializing the oldAttrs var, on patchwork for bug 599009 (r=bz). --- js/src/jsinterp.cpp | 29 +++++++++++++++-------------- js/src/methodjit/StubCalls.cpp | 33 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index c38d0a3f958..1edf625ad46 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -5379,23 +5379,24 @@ BEGIN_CASE(JSOP_DEFFUN) bool doSet = false; if (prop) { JS_ASSERT((attrs == JSPROP_ENUMERATE) == regs.fp->isEvalFrame()); - uint32 old; - if (attrs == JSPROP_ENUMERATE || - (parent == pobj && - parent->isCall() && - (old = ((Shape *) prop)->attributes(), - !(old & (JSPROP_GETTER|JSPROP_SETTER)) && - (old & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs))) { - /* - * js_CheckRedeclaration must reject attempts to add a getter or - * setter to an existing property without a getter or setter. - */ - JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); - JS_ASSERT_IF(attrs != JSPROP_ENUMERATE, !(old & JSPROP_READONLY)); - doSet = true; + if (attrs == JSPROP_ENUMERATE || (parent == pobj && parent->isCall())) { + JS_ASSERT(pobj->isNative()); + uintN oldAttrs = ((Shape *) prop)->attributes(); + + if (!(oldAttrs & (JSPROP_GETTER|JSPROP_SETTER)) && + (oldAttrs & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs) { + /* + * js_CheckRedeclaration must reject attempts to add a getter or + * setter to an existing property without a getter or setter. + */ + JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); + JS_ASSERT(!(oldAttrs & JSPROP_READONLY)); + doSet = true; + } } pobj->dropProperty(cx, prop); } + Value rval = ObjectValue(*obj); ok = doSet ? parent->setProperty(cx, id, &rval, script->strictModeCode) diff --git a/js/src/methodjit/StubCalls.cpp b/js/src/methodjit/StubCalls.cpp index 508c2f35dc5..87c60d8e5df 100644 --- a/js/src/methodjit/StubCalls.cpp +++ b/js/src/methodjit/StubCalls.cpp @@ -914,9 +914,6 @@ stubs::DefFun(VMFrame &f, JSFunction *fun) */ JSObject *parent = &fp->varobj(cx); - uint32 old; - bool doSet; - /* * Check for a const property of the same name -- or any kind of property * if executing with the strict option. We check here at runtime as well @@ -940,25 +937,27 @@ stubs::DefFun(VMFrame &f, JSFunction *fun) * setters that store the value of the property in the interpreter frame, * see bug 467495. */ - doSet = false; + bool doSet = false; if (prop) { JS_ASSERT((attrs == JSPROP_ENUMERATE) == fp->isEvalFrame()); - if (attrs == JSPROP_ENUMERATE || - (parent == pobj && - parent->isCall() && - (old = ((Shape *) prop)->attributes(), - !(old & (JSPROP_GETTER|JSPROP_SETTER)) && - (old & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs))) { - /* - * js_CheckRedeclaration must reject attempts to add a getter or - * setter to an existing property without a getter or setter. - */ - JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); - JS_ASSERT_IF(attrs != JSPROP_ENUMERATE, !(old & JSPROP_READONLY)); - doSet = true; + if (attrs == JSPROP_ENUMERATE || (parent == pobj && parent->isCall())) { + JS_ASSERT(pobj->isNative()); + uintN oldAttrs = ((Shape *) prop)->attributes(); + + if (!(oldAttrs & (JSPROP_GETTER|JSPROP_SETTER)) && + (oldAttrs & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs) { + /* + * js_CheckRedeclaration must reject attempts to add a getter or + * setter to an existing property without a getter or setter. + */ + JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); + JS_ASSERT(!(oldAttrs & JSPROP_READONLY)); + doSet = true; + } } pobj->dropProperty(cx, prop); } + Value rval = ObjectValue(*obj); ok = doSet ? parent->setProperty(cx, id, &rval, strict)