Bug 836949 - Remove obj parameter from ValueToId. r=njn
authorTom Schuster <evilpies@gmail.com>
Tue, 09 Apr 2013 13:33:32 +0200
changeset 134920 471f0b0a58e11e7628f8b3c6cd3f9fe5644f30c4
parent 134919 53273047c43e9ac0a3d3fd00ab98b966754b1501
child 134921 8ca4c43e5f64ace928e34ce57af67deb4a2c3cd3
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs836949
milestone23.0a1
Bug 836949 - Remove obj parameter from ValueToId. r=njn
js/src/jsatominlines.h
js/src/jsinterp.cpp
--- a/js/src/jsatominlines.h
+++ b/js/src/jsatominlines.h
@@ -58,41 +58,32 @@ ToAtom(JSContext *cx, const js::Value &v
         return &str->asAtom();
 
     JS::Anchor<JSString *> anchor(str);
     return AtomizeString<allowGC>(cx, str);
 }
 
 template <AllowGC allowGC>
 inline bool
-ValueToId(JSContext* cx, JSObject *obj, const Value &v,
-          typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
+ValueToId(JSContext* cx, const Value &v, typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
 {
     int32_t i;
     if (ValueFitsInInt32(v, &i) && INT_FITS_IN_JSID(i)) {
         idp.set(INT_TO_JSID(i));
         return true;
     }
 
     JSAtom *atom = ToAtom<allowGC>(cx, v);
     if (!atom)
         return false;
 
     idp.set(AtomToId(atom));
     return true;
 }
 
-template <AllowGC allowGC>
-inline bool
-ValueToId(JSContext* cx, const Value &v,
-          typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
-{
-    return ValueToId<allowGC>(cx, NULL, v, idp);
-}
-
 /*
  * Write out character representing |index| to the memory just before |end|.
  * Thus |*end| is not touched, but |end[-1]| and earlier are modified as
  * appropriate.  There must be at least js::UINT32_CHAR_BUFFER_LENGTH elements
  * before |end| to avoid buffer underflow.  The start of the characters written
  * is returned and is necessarily before |end|.
  */
 template <typename T>
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -1643,20 +1643,20 @@ BEGIN_CASE(JSOP_AND)
     bool cond = ToBoolean(regs.sp[-1]);
     if (cond == false) {
         len = GET_JUMP_OFFSET(regs.pc);
         DO_NEXT_OP(len);
     }
 }
 END_CASE(JSOP_AND)
 
-#define FETCH_ELEMENT_ID(obj, n, id)                                          \
+#define FETCH_ELEMENT_ID(n, id)                                               \
     JS_BEGIN_MACRO                                                            \
         const Value &idval_ = regs.sp[n];                                     \
-        if (!ValueToId<CanGC>(cx, obj, idval_, &id))                          \
+        if (!ValueToId<CanGC>(cx, idval_, &id))                               \
             goto error;                                                       \
     JS_END_MACRO
 
 #define TRY_BRANCH_AFTER_COND(cond,spdec)                                     \
     JS_BEGIN_MACRO                                                            \
         JS_ASSERT(js_CodeSpec[op].length == 1);                               \
         unsigned diff_ = (unsigned) GET_UINT8(regs.pc) - (unsigned) JSOP_IFEQ;         \
         if (diff_ <= 1) {                                                     \
@@ -1676,17 +1676,17 @@ BEGIN_CASE(JSOP_IN)
     HandleValue rref = HandleValue::fromMarkedLocation(&regs.sp[-1]);
     if (!rref.isObject()) {
         js_ReportValueError(cx, JSMSG_IN_NOT_OBJECT, -1, rref, NullPtr());
         goto error;
     }
     RootedObject &obj = rootObject0;
     obj = &rref.toObject();
     RootedId &id = rootId0;
-    FETCH_ELEMENT_ID(obj, -2, id);
+    FETCH_ELEMENT_ID(-2, id);
     RootedObject &obj2 = rootObject1;
     RootedShape &prop = rootShape0;
     if (!JSObject::lookupGeneric(cx, obj, id, &obj2, &prop))
         goto error;
     bool cond = prop != NULL;
     prop = NULL;
     TRY_BRANCH_AFTER_COND(cond, 2);
     regs.sp--;
@@ -1799,17 +1799,17 @@ END_CASE(JSOP_SETCONST);
 BEGIN_CASE(JSOP_ENUMCONSTELEM)
 {
     RootedValue &rval = rootValue0;
     rval = regs.sp[-3];
 
     RootedObject &obj = rootObject0;
     FETCH_OBJECT(cx, -2, obj);
     RootedId &id = rootId0;
-    FETCH_ELEMENT_ID(obj, -1, id);
+    FETCH_ELEMENT_ID(-1, id);
     if (!JSObject::defineGeneric(cx, obj, id, rval,
                                  JS_PropertyStub, JS_StrictPropertyStub,
                                  JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY)) {
         goto error;
     }
     regs.sp -= 3;
 }
 END_CASE(JSOP_ENUMCONSTELEM)
@@ -2303,34 +2303,34 @@ BEGIN_CASE(JSOP_CALLELEM)
 }
 END_CASE(JSOP_GETELEM)
 
 BEGIN_CASE(JSOP_SETELEM)
 {
     RootedObject &obj = rootObject0;
     FETCH_OBJECT(cx, -3, obj);
     RootedId &id = rootId0;
-    FETCH_ELEMENT_ID(obj, -2, id);
+    FETCH_ELEMENT_ID(-2, id);
     Value &value = regs.sp[-1];
     if (!SetObjectElementOperation(cx, obj, id, value, script->strict))
         goto error;
     regs.sp[-3] = value;
     regs.sp -= 2;
 }
 END_CASE(JSOP_SETELEM)
 
 BEGIN_CASE(JSOP_ENUMELEM)
 {
     RootedObject &obj = rootObject0;
     RootedValue &rval = rootValue0;
 
     /* Funky: the value to set is under the [obj, id] pair. */
     FETCH_OBJECT(cx, -2, obj);
     RootedId &id = rootId0;
-    FETCH_ELEMENT_ID(obj, -1, id);
+    FETCH_ELEMENT_ID(-1, id);
     rval = regs.sp[-3];
     if (!JSObject::setGeneric(cx, obj, obj, id, &rval, script->strict))
         goto error;
     regs.sp -= 3;
 }
 END_CASE(JSOP_ENUMELEM)
 
 BEGIN_CASE(JSOP_EVAL)
@@ -2846,17 +2846,17 @@ BEGIN_CASE(JSOP_SETTER)
         JS_ASSERT(lref.isObject());
         obj = &lref.toObject();
         break;
       }
     }
 
     /* Ensure that id has a type suitable for use with obj. */
     if (JSID_IS_VOID(id))
-        FETCH_ELEMENT_ID(obj, i, id);
+        FETCH_ELEMENT_ID(i, id);
 
     if (!js_IsCallable(rval)) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_GETTER_OR_SETTER,
                              (op == JSOP_GETTER) ? js_getter_str : js_setter_str);
         goto error;
     }
 
     /*