Bug 1484349 - Add unboxed object support GetProperyPure. r=jandem
authorTom Schuster <evilpies@gmail.com>
Fri, 17 Aug 2018 23:11:56 +0200
changeset 432435 8047901cef0e5c166c1ba26c327f5f5581851f20
parent 432434 d2195ec4e254ab9c1f3bfaedfcd93dddf3197a19
child 432436 075bfbeee249a7c7dd733f1c5ed815d8e622845c
push id106736
push userevilpies@gmail.com
push dateMon, 20 Aug 2018 18:27:56 +0000
treeherdermozilla-inbound@075bfbeee249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1484349
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1484349 - Add unboxed object support GetProperyPure. r=jandem
js/src/vm/JSObject.cpp
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -2501,47 +2501,70 @@ NativeGetPureInline(NativeObject* pobj, 
     if (!shape->isDataProperty())
         return false;
 
     *vp = pobj->getSlot(shape->slot());
     MOZ_ASSERT(!vp->isMagic());
     return true;
 }
 
+static inline bool
+UnboxedGetPureInline(JSObject* pobj, jsid id, PropertyResult prop, Value* vp)
+{
+    MOZ_ASSERT(prop.isNonNativeProperty());
+
+    // This might be a TypedObject.
+    if (!pobj->is<UnboxedPlainObject>())
+        return false;
+
+    const UnboxedLayout& layout = pobj->as<UnboxedPlainObject>().layout();
+    if (const UnboxedLayout::Property* property = layout.lookup(id)) {
+        *vp = pobj->as<UnboxedPlainObject>().getValue(*property);
+        return true;
+    }
+
+    // Don't bother supporting expandos for now.
+    return false;
+}
+
 bool
 js::GetPropertyPure(JSContext* cx, JSObject* obj, jsid id, Value* vp)
 {
     JSObject* pobj;
     PropertyResult prop;
     if (!LookupPropertyPure(cx, obj, id, &pobj, &prop))
         return false;
 
     if (!prop) {
         vp->setUndefined();
         return true;
     }
 
-    return pobj->isNative() && NativeGetPureInline(&pobj->as<NativeObject>(), id, prop, vp);
+    if (MOZ_LIKELY(pobj->isNative()))
+        return NativeGetPureInline(&pobj->as<NativeObject>(), id, prop, vp);
+    return UnboxedGetPureInline(pobj, id, prop, vp);
 }
 
 bool
 js::GetOwnPropertyPure(JSContext* cx, JSObject* obj, jsid id, Value* vp, bool* found)
 {
     PropertyResult prop;
     if (!LookupOwnPropertyPure(cx, obj, id, &prop))
         return false;
 
     if (!prop) {
         *found = false;
         vp->setUndefined();
         return true;
     }
 
     *found = true;
-    return obj->isNative() && NativeGetPureInline(&obj->as<NativeObject>(), id, prop, vp);
+    if (MOZ_LIKELY(obj->isNative()))
+        return NativeGetPureInline(&obj->as<NativeObject>(), id, prop, vp);
+    return UnboxedGetPureInline(obj, id, prop, vp);
 }
 
 static inline bool
 NativeGetGetterPureInline(PropertyResult prop, JSFunction** fp)
 {
     if (!prop.isDenseOrTypedArrayElement() && prop.shape()->hasGetterObject()) {
         Shape* shape = prop.shape();
         if (shape->getterObject()->is<JSFunction>()) {