Bug 903389 - Make Make NativeGet[Getter]PureInline handle dense/typed array shapes. r=arai
authorTom Schuster <evilpies@gmail.com>
Wed, 21 Dec 2016 16:17:26 +0100
changeset 452475 4e9e1f7ef5a8a6a8e88ef36e8aeb997136eb0d75
parent 452474 78fdff5726df7f30f0780587e4eed68095ae4a22
child 452476 da479aa758a8e5eee2583da370bfdac2ca819999
push id39415
push usermozilla@noorenberghe.ca
push dateWed, 21 Dec 2016 20:49:14 +0000
reviewersarai
bugs903389
milestone53.0a1
Bug 903389 - Make Make NativeGet[Getter]PureInline handle dense/typed array shapes. r=arai
js/src/jsobj.cpp
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -2349,19 +2349,28 @@ js::LookupOwnPropertyPure(ExclusiveConte
         return false;
     }
 
     *propp = nullptr;
     return true;
 }
 
 static inline bool
-NativeGetPureInline(NativeObject* pobj, Shape* shape, Value* vp)
+NativeGetPureInline(NativeObject* pobj, jsid id, Shape* shape, Value* vp)
 {
-    /* Fail if we have a custom getter. */
+    if (IsImplicitDenseOrTypedArrayElement(shape)) {
+        // For simplicity we ignore the TypedArray with string index case.
+        if (!JSID_IS_INT(id))
+            return false;
+
+        *vp = pobj->getDenseOrTypedArrayElement(JSID_TO_INT(id));
+        return true;
+    }
+
+    // Fail if we have a custom getter.
     if (!shape->hasDefaultGetter())
         return false;
 
     if (shape->hasSlot()) {
         *vp = pobj->getSlot(shape->slot());
         MOZ_ASSERT(!vp->isMagic());
     } else {
         vp->setUndefined();
@@ -2378,23 +2387,23 @@ js::GetPropertyPure(ExclusiveContext* cx
     if (!LookupPropertyPure(cx, obj, id, &pobj, &shape))
         return false;
 
     if (!shape) {
         vp->setUndefined();
         return true;
     }
 
-    return pobj->isNative() && NativeGetPureInline(&pobj->as<NativeObject>(), shape, vp);
+    return pobj->isNative() && NativeGetPureInline(&pobj->as<NativeObject>(), id, shape, vp);
 }
 
 static inline bool
 NativeGetGetterPureInline(Shape* shape, JSFunction** fp)
 {
-    if (shape->hasGetterObject()) {
+    if (!IsImplicitDenseOrTypedArrayElement(shape) && shape->hasGetterObject()) {
         if (shape->getterObject()->is<JSFunction>()) {
             *fp = &shape->getterObject()->as<JSFunction>();
             return true;
         }
     }
 
     *fp = nullptr;
     return true;