Bug 1505574 - Remove Unboxed Objects from Builtins Directory r=iain
authorMatthew Gaudet <mgaudet@mozilla.com>
Fri, 22 Mar 2019 15:31:35 +0000
changeset 465710 7e790d902c60ca290cde9e30c04d4d10fa3cf25b
parent 465709 ef947b198f2c861b13b13b66f5b4095c43b4acb8
child 465711 3abc5dfef71f8ae282215ef226cc8043f6821c20
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 from Builtins Directory r=iain Differential Revision: https://phabricator.services.mozilla.com/D24039
js/src/builtin/Array-inl.h
js/src/builtin/Array.cpp
js/src/builtin/Object.cpp
js/src/builtin/RegExp.cpp
--- a/js/src/builtin/Array-inl.h
+++ b/js/src/builtin/Array-inl.h
@@ -8,17 +8,16 @@
 #define builtin_Array_inl_h
 
 #include "builtin/Array.h"
 
 #include "vm/ArgumentsObject.h"
 #include "vm/JSObject.h"
 
 #include "vm/ArgumentsObject-inl.h"
-#include "vm/UnboxedObject-inl.h"
 
 namespace js {
 
 inline bool GetElement(JSContext* cx, HandleObject obj, uint32_t index,
                        MutableHandleValue vp) {
   if (obj->isNative() &&
       index < obj->as<NativeObject>().getDenseInitializedLength()) {
     vp.set(obj->as<NativeObject>().getDenseElement(index));
--- a/js/src/builtin/Array.cpp
+++ b/js/src/builtin/Array.cpp
@@ -43,17 +43,16 @@
 
 #include "vm/ArgumentsObject-inl.h"
 #include "vm/ArrayObject-inl.h"
 #include "vm/Caches-inl.h"
 #include "vm/GeckoProfiler-inl.h"
 #include "vm/Interpreter-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/NativeObject-inl.h"
-#include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 
 using mozilla::Abs;
 using mozilla::ArrayLength;
 using mozilla::CeilingLog2;
 using mozilla::CheckedInt;
 using mozilla::DebugOnly;
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -20,17 +20,16 @@
 #include "vm/AsyncFunction.h"
 #include "vm/EqualityOperations.h"  // js::SameValue
 #include "vm/JSContext.h"
 #include "vm/RegExpObject.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/Shape-inl.h"
-#include "vm/UnboxedObject-inl.h"
 
 #ifdef FUZZING
 #  include "builtin/TestingFunctions.h"
 #endif
 
 using namespace js;
 
 using js::frontend::IsIdentifier;
@@ -521,17 +520,17 @@ static bool GetBuiltinTagSlow(JSContext*
 
 static MOZ_ALWAYS_INLINE JSString* GetBuiltinTagFast(JSObject* obj,
                                                      const Class* clasp,
                                                      JSContext* cx) {
   MOZ_ASSERT(clasp == obj->getClass());
   MOZ_ASSERT(!clasp->isProxy());
 
   // Optimize the non-proxy case to bypass GetBuiltinClass.
-  if (clasp == &PlainObject::class_ || clasp == &UnboxedPlainObject::class_) {
+  if (clasp == &PlainObject::class_) {
     // This is not handled by GetBuiltinTagSlow, but this case is by far
     // the most common so we optimize it here.
     return cx->names().objectObject;
   }
 
   if (clasp == &ArrayObject::class_) {
     return cx->names().objectArray;
   }
@@ -609,17 +608,17 @@ bool js::obj_toString(JSContext* cx, uns
 #ifdef DEBUG
     // Assert this fast path is correct and matches BuiltinTagSlow. The
     // only exception is the PlainObject case: we special-case it here
     // because it's so common, but BuiltinTagSlow doesn't handle this.
     RootedString builtinTagSlow(cx);
     if (!GetBuiltinTagSlow(cx, obj, &builtinTagSlow)) {
       return false;
     }
-    if (clasp == &PlainObject::class_ || clasp == &UnboxedPlainObject::class_) {
+    if (clasp == &PlainObject::class_) {
       MOZ_ASSERT(!builtinTagSlow);
     } else {
       MOZ_ASSERT(builtinTagSlow == builtinTag);
     }
 #endif
   }
 
   // Step 14.
@@ -831,76 +830,16 @@ static bool TryAssignNative(JSContext* c
     if (MOZ_UNLIKELY(!result.checkStrict(cx, to, nextKey))) {
       return false;
     }
   }
 
   return true;
 }
 
-static bool TryAssignFromUnboxed(JSContext* cx, HandleObject to,
-                                 HandleObject from, bool* optimized) {
-  *optimized = false;
-
-  if (!from->is<UnboxedPlainObject>() || !to->isNative()) {
-    return true;
-  }
-
-  // Don't use the fast path for unboxed objects with expandos.
-  UnboxedPlainObject* fromUnboxed = &from->as<UnboxedPlainObject>();
-  if (fromUnboxed->maybeExpando()) {
-    return true;
-  }
-
-  *optimized = true;
-
-  RootedObjectGroup fromGroup(cx, from->group());
-
-  RootedValue propValue(cx);
-  RootedId nextKey(cx);
-  RootedValue toReceiver(cx, ObjectValue(*to));
-
-  const UnboxedLayout& layout = fromUnboxed->layout();
-  for (size_t i = 0; i < layout.properties().length(); i++) {
-    const UnboxedLayout::Property& property = layout.properties()[i];
-    nextKey = NameToId(property.name);
-
-    // All unboxed properties are enumerable.
-    // Guard on the group to ensure that the object stays unboxed.
-    // We can ignore expando properties added after the loop starts.
-    if (MOZ_LIKELY(from->group() == fromGroup)) {
-      propValue = from->as<UnboxedPlainObject>().getValue(property);
-    } else {
-      // |from| changed so we have to do the slower enumerability check
-      // and GetProp.
-      bool enumerable;
-      if (!PropertyIsEnumerable(cx, from, nextKey, &enumerable)) {
-        return false;
-      }
-      if (!enumerable) {
-        continue;
-      }
-      if (!GetProperty(cx, from, from, nextKey, &propValue)) {
-        return false;
-      }
-    }
-
-    ObjectOpResult result;
-    if (MOZ_UNLIKELY(
-            !SetProperty(cx, to, nextKey, propValue, toReceiver, result))) {
-      return false;
-    }
-    if (MOZ_UNLIKELY(!result.checkStrict(cx, to, nextKey))) {
-      return false;
-    }
-  }
-
-  return true;
-}
-
 static bool AssignSlow(JSContext* cx, HandleObject to, HandleObject from) {
   // Step 4.b.ii.
   AutoIdVector keys(cx);
   if (!GetPropertyKeys(
           cx, from, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &keys)) {
     return false;
   }
 
@@ -938,23 +877,16 @@ JS_PUBLIC_API bool JS_AssignObject(JSCon
   bool optimized;
   if (!TryAssignNative(cx, target, src, &optimized)) {
     return false;
   }
   if (optimized) {
     return true;
   }
 
-  if (!TryAssignFromUnboxed(cx, target, src, &optimized)) {
-    return false;
-  }
-  if (optimized) {
-    return true;
-  }
-
   return AssignSlow(cx, target, src);
 }
 
 // ES2018 draft rev 48ad2688d8f964da3ea8c11163ef20eb126fb8a4
 // 19.1.2.1 Object.assign(target, ...sources)
 static bool obj_assign(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
 
@@ -1544,72 +1476,16 @@ static bool TryEnumerableOwnPropertiesNa
   if (!array) {
     return false;
   }
 
   rval.setObject(*array);
   return true;
 }
 
-template <EnumerableOwnPropertiesKind kind>
-static bool TryEnumerableOwnPropertiesUnboxed(JSContext* cx, HandleObject obj,
-                                              MutableHandleValue rval,
-                                              bool* optimized) {
-  *optimized = false;
-
-  if (!obj->is<UnboxedPlainObject>()) {
-    return true;
-  }
-
-  Handle<UnboxedPlainObject*> uobj = obj.as<UnboxedPlainObject>();
-  if (uobj->maybeExpando()) {
-    return true;
-  }
-
-  *optimized = true;
-
-  AutoValueVector properties(cx);
-  RootedValue key(cx);
-  RootedValue value(cx);
-
-  const UnboxedLayout& layout = uobj->layout();
-
-  for (size_t i = 0, len = layout.properties().length(); i < len; i++) {
-    MOZ_ASSERT(obj->is<UnboxedPlainObject>(), "Object should still be unboxed");
-
-    const UnboxedLayout::Property& property = layout.properties()[i];
-
-    if (kind == EnumerableOwnPropertiesKind::Keys ||
-        kind == EnumerableOwnPropertiesKind::Names) {
-      value.setString(property.name);
-    } else if (kind == EnumerableOwnPropertiesKind::Values) {
-      value.set(uobj->getValue(property));
-    } else {
-      key.setString(property.name);
-      value.set(uobj->getValue(property));
-      if (!NewValuePair(cx, key, value, &value)) {
-        return false;
-      }
-    }
-
-    if (!properties.append(value)) {
-      return false;
-    }
-  }
-
-  JSObject* array =
-      NewDenseCopiedArray(cx, properties.length(), properties.begin());
-  if (!array) {
-    return false;
-  }
-
-  rval.setObject(*array);
-  return true;
-}
-
 // ES2018 draft rev c164be80f7ea91de5526b33d54e5c9321ed03d3f
 // 7.3.21 EnumerableOwnProperties ( O, kind )
 template <EnumerableOwnPropertiesKind kind>
 static bool EnumerableOwnProperties(JSContext* cx, const JS::CallArgs& args) {
   static_assert(kind == EnumerableOwnPropertiesKind::Values ||
                     kind == EnumerableOwnPropertiesKind::KeysAndValues,
                 "Only implemented for Object.keys and Object.entries");
 
@@ -1623,24 +1499,16 @@ static bool EnumerableOwnProperties(JSCo
   if (!TryEnumerableOwnPropertiesNative<kind>(cx, obj, args.rval(),
                                               &optimized)) {
     return false;
   }
   if (optimized) {
     return true;
   }
 
-  if (!TryEnumerableOwnPropertiesUnboxed<kind>(cx, obj, args.rval(),
-                                               &optimized)) {
-    return false;
-  }
-  if (optimized) {
-    return true;
-  }
-
   // Typed arrays are always handled in the fast path.
   MOZ_ASSERT(!obj->is<TypedArrayObject>());
 
   // Step 2.
   AutoIdVector ids(cx);
   if (!GetPropertyKeys(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, &ids)) {
     return false;
   }
@@ -1746,24 +1614,16 @@ static bool obj_keys(JSContext* cx, unsi
   if (!TryEnumerableOwnPropertiesNative<kind>(cx, obj, args.rval(),
                                               &optimized)) {
     return false;
   }
   if (optimized) {
     return true;
   }
 
-  if (!TryEnumerableOwnPropertiesUnboxed<kind>(cx, obj, args.rval(),
-                                               &optimized)) {
-    return false;
-  }
-  if (optimized) {
-    return true;
-  }
-
   // Steps 2-3.
   return GetOwnPropertyKeys(cx, obj, JSITER_OWNONLY, args.rval());
 }
 
 // ES2018 draft rev c164be80f7ea91de5526b33d54e5c9321ed03d3f
 // 19.1.2.21 Object.values ( O )
 static bool obj_values(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
@@ -1861,24 +1721,16 @@ bool js::obj_getOwnPropertyNames(JSConte
   if (!TryEnumerableOwnPropertiesNative<kind>(cx, obj, args.rval(),
                                               &optimized)) {
     return false;
   }
   if (optimized) {
     return true;
   }
 
-  if (!TryEnumerableOwnPropertiesUnboxed<kind>(cx, obj, args.rval(),
-                                               &optimized)) {
-    return false;
-  }
-  if (optimized) {
-    return true;
-  }
-
   return GetOwnPropertyKeys(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN,
                             args.rval());
 }
 
 // ES2018 draft rev c164be80f7ea91de5526b33d54e5c9321ed03d3f
 // 19.1.2.10 Object.getOwnPropertySymbols ( O )
 static bool obj_getOwnPropertySymbols(JSContext* cx, unsigned argc, Value* vp) {
   CallArgs args = CallArgsFromVp(argc, vp);
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -18,17 +18,16 @@
 #include "vm/JSContext.h"
 #include "vm/RegExpStatics.h"
 #include "vm/SelfHosting.h"
 
 #include "vm/EnvironmentObject-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 #include "vm/ObjectOperations-inl.h"
-#include "vm/UnboxedObject-inl.h"
 
 using namespace js;
 
 using mozilla::CheckedInt;
 using mozilla::IsAsciiDigit;
 
 using JS::CompileOptions;