Check for doubles that fit in ints in JSOP_GETELEM slow paths (bug 604905, r=luke).
authorDavid Anderson <danderson@mozilla.com>
Fri, 19 Nov 2010 17:24:47 -0800
changeset 58066 9bff531727b2e8faa93a34c0698f7830d70fb232
parent 58065 6f7f0da1569382067e13026c691be579bba72b6d
child 58067 b7ffbcf89604c59c8526c3dbe05f0d9980f80d66
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersluke
bugs604905
milestone2.0b8pre
Check for doubles that fit in ints in JSOP_GETELEM slow paths (bug 604905, r=luke).
js/src/jsinterp.cpp
js/src/methodjit/StubCalls.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -4499,19 +4499,24 @@ BEGIN_CASE(JSOP_GETELEM)
                 }
             }
         }
         if (JS_LIKELY(INT_FITS_IN_JSID(i)))
             id = INT_TO_JSID(i);
         else
             goto intern_big_int;
     } else {
-      intern_big_int:
-        if (!js_InternNonIntElementId(cx, obj, rref, &id))
-            goto error;
+        int32_t i;
+        if (ValueFitsInInt32(rref, &i) && INT_FITS_IN_JSID(i)) {
+            id = INT_TO_JSID(i);
+        } else {
+          intern_big_int:
+            if (!js_InternNonIntElementId(cx, obj, rref, &id))
+                goto error;
+        }
     }
 
     if (!obj->getProperty(cx, id, &rval))
         goto error;
     copyFrom = &rval;
 
   end_getelem:
     regs.sp--;
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -482,19 +482,24 @@ stubs::GetElem(VMFrame &f)
             }
         }
         if (JS_LIKELY(INT_FITS_IN_JSID(i)))
             id = INT_TO_JSID(i);
         else
             goto intern_big_int;
 
     } else {
-      intern_big_int:
-        if (!js_InternNonIntElementId(cx, obj, rref, &id))
-            THROW();
+        int32_t i;
+        if (ValueFitsInInt32(rref, &i) && INT_FITS_IN_JSID(i)) {
+            id = INT_TO_JSID(i);
+        } else {
+          intern_big_int:
+            if (!js_InternNonIntElementId(cx, obj, rref, &id))
+                THROW();
+        }
     }
 
     if (!obj->getProperty(cx, id, &rval))
         THROW();
     copyFrom = &rval;
 
   end_getelem:
     f.regs.sp[-2] = *copyFrom;