Bug 1154296 - Small GetOwnPropertyDescriptor cleanup. r=jorendorff
authorTom Schuster <evilpies@gmail.com>
Fri, 24 Apr 2015 22:06:16 +0200
changeset 241019 1f443ee3a7e9ff61f21222756ac32c55701525db
parent 241018 8e7257aeee45ba712a491d43d0073469c04d9cce
child 241020 3e548b8fed23a6eb759f41a1abe7e36979dd800a
push id58991
push userevilpies@gmail.com
push dateFri, 24 Apr 2015 21:23:19 +0000
treeherdermozilla-inbound@1f443ee3a7e9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1154296
milestone40.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 1154296 - Small GetOwnPropertyDescriptor cleanup. r=jorendorff
js/src/jsobj.cpp
js/src/vm/NativeObject.h
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3001,29 +3001,28 @@ js::GetOwnPropertyDescriptor(JSContext* 
     if (obj->is<RegExpObject>() && id == NameToId(cx->names().source)) {
         if (JSScript* script = cx->currentScript()) {
             const char* filename = script->filename();
             cx->compartment()->addTelemetry(filename, JSCompartment::RegExpSourceProperty);
         }
     }
 #endif
 
+    RootedNativeObject nobj(cx, obj.as<NativeObject>());
     RootedShape shape(cx);
-    if (!NativeLookupOwnProperty<CanGC>(cx, obj.as<NativeObject>(), id, &shape))
+    if (!NativeLookupOwnProperty<CanGC>(cx, nobj, id, &shape))
         return false;
     if (!shape) {
         desc.object().set(nullptr);
         return true;
     }
 
-    bool doGet = true;
     desc.setAttributes(GetShapeAttributes(obj, shape));
     if (desc.isAccessorDescriptor()) {
         MOZ_ASSERT(desc.isShared());
-        doGet = false;
 
         // The result of GetOwnPropertyDescriptor() must be either undefined or
         // a complete property descriptor (per ES6 draft rev 32 (2015 Feb 2)
         // 6.1.7.3, Invariants of the Essential Internal Methods).
         //
         // It is an unfortunate fact that in SM, properties can exist that have
         // JSPROP_GETTER or JSPROP_SETTER but not both. In these cases, rather
         // than return true with desc incomplete, we fill out the missing
@@ -3035,30 +3034,34 @@ js::GetOwnPropertyDescriptor(JSContext* 
             desc.attributesRef() |= JSPROP_GETTER;
         }
         if (desc.hasSetterObject()) {
             desc.setSetterObject(shape->setterObject());
         } else {
             desc.setSetterObject(nullptr);
             desc.attributesRef() |= JSPROP_SETTER;
         }
+
+        desc.value().setUndefined();
     } else {
         // This is either a straight-up data property or (rarely) a
         // property with a JSGetterOp/JSSetterOp. The latter must be
         // reported to the caller as a plain data property, so don't
         // populate desc.getter/setter, and mask away the SHARED bit.
         desc.attributesRef() &= ~JSPROP_SHARED;
+
+        if (IsImplicitDenseOrTypedArrayElement(shape)) {
+            desc.value().set(nobj->getDenseOrTypedArrayElement(JSID_TO_INT(id)));
+        } else {
+            if (!NativeGetExistingProperty(cx, nobj, nobj, shape, desc.value()))
+                return false;
+        }
     }
 
-    RootedValue value(cx);
-    if (doGet && !GetProperty(cx, obj, obj, id, &value))
-        return false;
-
-    desc.value().set(value);
-    desc.object().set(obj);
+    desc.object().set(nobj);
     desc.assertComplete();
     return true;
 }
 
 bool
 js::DefineProperty(JSContext* cx, HandleObject obj, HandleId id, Handle<PropertyDescriptor> desc,
                    ObjectOpResult& result)
 {
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -1353,17 +1353,17 @@ NativeLookupOwnProperty(ExclusiveContext
  * Get a property from `receiver`, after having already done a lookup and found
  * the property on a native object `obj`.
  *
  * `shape` must not be null and must not be an implicit dense property. It must
  * be present in obj's shape chain.
  */
 extern bool
 NativeGetExistingProperty(JSContext* cx, HandleObject receiver, HandleNativeObject obj,
-                          HandleShape shape, MutableHandle<Value> vp);
+                          HandleShape shape, MutableHandleValue vp);
 
 /* * */
 
 /*
  * If obj has an already-resolved data property for id, return true and
  * store the property value in *vp.
  */
 extern bool