Bug 1505574 - Remove Unboxed Objects support from Iteration.cpp r=iain
authorMatthew Gaudet <mgaudet@mozilla.com>
Fri, 22 Mar 2019 15:31:47 +0000
changeset 465712 551ced45a264cc9fb585676ab9d8f6c345c6a666
parent 465711 3abc5dfef71f8ae282215ef226cc8043f6821c20
child 465713 35a9aa1ae7b9551b732f7d3b75ba1a1f8c716e08
push id35746
push usershindli@mozilla.com
push dateSat, 23 Mar 2019 09:46:24 +0000
treeherdermozilla-central@02b7484f316b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1505574
milestone68.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 1505574 - Remove Unboxed Objects support from Iteration.cpp r=iain Differential Revision: https://phabricator.services.mozilla.com/D24041
js/src/vm/Iteration.cpp
--- a/js/src/vm/Iteration.cpp
+++ b/js/src/vm/Iteration.cpp
@@ -173,20 +173,20 @@ static bool SortComparatorIntegerIds(jsi
   uint32_t indexA, indexB;
   MOZ_ALWAYS_TRUE(IdIsIndex(a, &indexA));
   MOZ_ALWAYS_TRUE(IdIsIndex(b, &indexB));
   *lessOrEqualp = (indexA <= indexB);
   return true;
 }
 
 template <bool CheckForDuplicates>
-static bool EnumerateNativeProperties(
-    JSContext* cx, HandleNativeObject pobj, unsigned flags,
-    MutableHandle<IdSet> visited, AutoIdVector* props,
-    Handle<UnboxedPlainObject*> unboxed = nullptr) {
+static bool EnumerateNativeProperties(JSContext* cx, HandleNativeObject pobj,
+                                      unsigned flags,
+                                      MutableHandle<IdSet> visited,
+                                      AutoIdVector* props) {
   bool enumerateSymbols;
   if (flags & JSITER_SYMBOLSONLY) {
     enumerateSymbols = true;
   } else {
     // Collect any dense elements from this object.
     size_t firstElemIndex = props->length();
     size_t initlen = pobj->getDenseInitializedLength();
     const Value* vp = pobj->getDenseElements();
@@ -251,28 +251,16 @@ static bool EnumerateNativeProperties(
       }
       PodCopy(tmp.begin(), ids, n);
 
       if (!MergeSort(ids, n, tmp.begin(), SortComparatorIntegerIds)) {
         return false;
       }
     }
 
-    if (unboxed) {
-      // If |unboxed| is set then |pobj| is the expando for an unboxed
-      // plain object we are enumerating. Add the unboxed properties
-      // themselves here since they are all property names that were
-      // given to the object before any of the expando's properties.
-      MOZ_ASSERT(pobj->is<UnboxedExpandoObject>());
-      if (!EnumerateExtraProperties<CheckForDuplicates>(cx, unboxed, flags,
-                                                        visited, props)) {
-        return false;
-      }
-    }
-
     size_t initialLength = props->length();
 
     /* Collect all unique property names from this object's shape. */
     bool symbolsFound = false;
     Shape::Range<NoGC> r(pobj->lastProperty());
     for (; !r.empty(); r.popFront()) {
       Shape& shape = r.front();
       jsid id = shape.propid();
@@ -313,26 +301,25 @@ static bool EnumerateNativeProperties(
       }
     }
     ::Reverse(props->begin() + initialLength, props->end());
   }
 
   return true;
 }
 
-static bool EnumerateNativeProperties(
-    JSContext* cx, HandleNativeObject pobj, unsigned flags,
-    MutableHandle<IdSet> visited, AutoIdVector* props, bool checkForDuplicates,
-    Handle<UnboxedPlainObject*> unboxed = nullptr) {
+static bool EnumerateNativeProperties(JSContext* cx, HandleNativeObject pobj,
+                                      unsigned flags,
+                                      MutableHandle<IdSet> visited,
+                                      AutoIdVector* props,
+                                      bool checkForDuplicates) {
   if (checkForDuplicates) {
-    return EnumerateNativeProperties<true>(cx, pobj, flags, visited, props,
-                                           unboxed);
+    return EnumerateNativeProperties<true>(cx, pobj, flags, visited, props);
   }
-  return EnumerateNativeProperties<false>(cx, pobj, flags, visited, props,
-                                          unboxed);
+  return EnumerateNativeProperties<false>(cx, pobj, flags, visited, props);
 }
 
 template <bool CheckForDuplicates>
 static bool EnumerateProxyProperties(JSContext* cx, HandleObject pobj,
                                      unsigned flags,
                                      MutableHandle<IdSet> visited,
                                      AutoIdVector* props) {
   MOZ_ASSERT(pobj->is<ProxyObject>());
@@ -466,52 +453,27 @@ static bool Snapshot(JSContext* cx, Hand
   //
   // The only special case is when the object has a newEnumerate hook: it
   // can return duplicate properties and we have to filter them. This is
   // handled below.
   bool checkForDuplicates = !(flags & JSITER_OWNONLY);
 
   do {
     if (pobj->getClass()->getNewEnumerate()) {
-      if (pobj->is<UnboxedPlainObject>() &&
-          pobj->as<UnboxedPlainObject>().maybeExpando()) {
-        // Special case unboxed objects with an expando object.
-        RootedNativeObject expando(
-            cx, pobj->as<UnboxedPlainObject>().maybeExpando());
-        if (!EnumerateNativeProperties(cx, expando, flags, &visited, props,
-                                       checkForDuplicates,
-                                       pobj.as<UnboxedPlainObject>())) {
+      if (!EnumerateExtraProperties<true>(cx, pobj, flags, &visited, props)) {
+        return false;
+      }
+
+      if (pobj->isNative()) {
+        if (!EnumerateNativeProperties(cx, pobj.as<NativeObject>(), flags,
+                                       &visited, props, true)) {
           return false;
         }
-      } else {
-        // The newEnumerate hook may return duplicates. Whitelist the
-        // unboxed object hooks because we know they are well-behaved.
-        if (!pobj->is<UnboxedPlainObject>()) {
-          checkForDuplicates = true;
-        }
+      }
 
-        if (checkForDuplicates) {
-          if (!EnumerateExtraProperties<true>(cx, pobj, flags, &visited,
-                                              props)) {
-            return false;
-          }
-        } else {
-          if (!EnumerateExtraProperties<false>(cx, pobj, flags, &visited,
-                                               props)) {
-            return false;
-          }
-        }
-
-        if (pobj->isNative()) {
-          if (!EnumerateNativeProperties(cx, pobj.as<NativeObject>(), flags,
-                                         &visited, props, checkForDuplicates)) {
-            return false;
-          }
-        }
-      }
     } else if (pobj->isNative()) {
       // Give the object a chance to resolve all lazy properties
       if (JSEnumerateOp enumerate = pobj->getClass()->getEnumerate()) {
         if (!enumerate(cx, pobj.as<NativeObject>())) {
           return false;
         }
       }
       if (!EnumerateNativeProperties(cx, pobj.as<NativeObject>(), flags,
@@ -804,23 +766,16 @@ bool IteratorHashPolicy::match(PropertyI
   return ArrayEqual(reinterpret_cast<ReceiverGuard*>(ni->guardsBegin()),
                     lookup.guards, ni->guardCount());
 }
 
 static inline bool CanCompareIterableObjectToCache(JSObject* obj) {
   if (obj->isNative()) {
     return obj->as<NativeObject>().getDenseInitializedLength() == 0;
   }
-  if (obj->is<UnboxedPlainObject>()) {
-    if (UnboxedExpandoObject* expando =
-            obj->as<UnboxedPlainObject>().maybeExpando()) {
-      return expando->getDenseInitializedLength() == 0;
-    }
-    return true;
-  }
   return false;
 }
 
 using ReceiverGuardVector = Vector<ReceiverGuard, 8>;
 
 static MOZ_ALWAYS_INLINE PropertyIteratorObject* LookupInIteratorCache(
     JSContext* cx, JSObject* obj, uint32_t* numGuards) {
   MOZ_ASSERT(*numGuards == 0);
@@ -861,30 +816,28 @@ static MOZ_ALWAYS_INLINE PropertyIterato
     return nullptr;
   }
 
   return iterobj;
 }
 
 static bool CanStoreInIteratorCache(JSObject* obj) {
   do {
-    if (obj->isNative()) {
-      MOZ_ASSERT(obj->as<NativeObject>().getDenseInitializedLength() == 0);
+    MOZ_ASSERT(obj->isNative());
+
+    MOZ_ASSERT(obj->as<NativeObject>().getDenseInitializedLength() == 0);
 
-      // Typed arrays have indexed properties not captured by the Shape guard.
-      // Enumerate hooks may add extra properties.
-      const Class* clasp = obj->getClass();
-      if (MOZ_UNLIKELY(IsTypedArrayClass(clasp))) {
-        return false;
-      }
-      if (MOZ_UNLIKELY(clasp->getNewEnumerate() || clasp->getEnumerate())) {
-        return false;
-      }
-    } else {
-      MOZ_ASSERT(obj->is<UnboxedPlainObject>());
+    // Typed arrays have indexed properties not captured by the Shape guard.
+    // Enumerate hooks may add extra properties.
+    const Class* clasp = obj->getClass();
+    if (MOZ_UNLIKELY(IsTypedArrayClass(clasp))) {
+      return false;
+    }
+    if (MOZ_UNLIKELY(clasp->getNewEnumerate() || clasp->getEnumerate())) {
+      return false;
     }
 
     obj = obj->staticPrototype();
   } while (obj);
 
   return true;
 }