Bug 1651645 part 8 - Fold writeToIndexWouldMarkNotPacked into its sole caller. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 09 Jul 2020 21:31:04 +0000
changeset 540356 783890691a76b39c4eb26f482ad815889643f881
parent 540355 5c435dbe3a720460af6daa0e993f9aa603e9379b
child 540357 f112125cab4db8b9665ae3072df166b0e9ccfdbe
push id121651
push userjdemooij@mozilla.com
push dateTue, 14 Jul 2020 08:39:33 +0000
treeherderautoland@f112125cab4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs1651645
milestone80.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 1651645 part 8 - Fold writeToIndexWouldMarkNotPacked into its sole caller. r=evilpie Also move it down a bit because we only need to do this when writing to an index > initlength. Depends on D82964 Differential Revision: https://phabricator.services.mozilla.com/D82965
js/src/vm/NativeObject-inl.h
js/src/vm/NativeObject.h
--- a/js/src/vm/NativeObject-inl.h
+++ b/js/src/vm/NativeObject-inl.h
@@ -116,20 +116,16 @@ inline void NativeObject::removeDenseEle
   if (IsTypeInferenceEnabled()) {
     MarkObjectGroupFlags(cx, this, OBJECT_FLAG_SPARSE_INDEXES);
   }
   if (containsDenseElement(index)) {
     setDenseElementHole(cx, index);
   }
 }
 
-inline bool NativeObject::writeToIndexWouldMarkNotPacked(uint32_t index) {
-  return getElementsHeader()->initializedLength < index;
-}
-
 inline void NativeObject::markDenseElementsNotPacked(JSContext* cx) {
   MOZ_ASSERT(isNative());
   if (IsTypeInferenceEnabled()) {
     MarkObjectGroupFlags(cx, this, OBJECT_FLAG_NON_PACKED);
   }
 }
 
 inline void NativeObject::elementsRangeWriteBarrierPost(uint32_t start,
@@ -323,27 +319,27 @@ inline void NativeObject::ensureDenseIni
   // mark the elements through 'index + extra' as initialized in preparation
   // for a write.
 
   MOZ_ASSERT(!denseElementsAreCopyOnWrite());
   MOZ_ASSERT(!denseElementsAreFrozen());
   MOZ_ASSERT(isExtensible() || (containsDenseElement(index) && extra == 1));
   MOZ_ASSERT(index + extra <= getDenseCapacity());
 
-  if (writeToIndexWouldMarkNotPacked(index)) {
-    markDenseElementsNotPacked(cx);
-  }
-
   uint32_t initlen = getDenseInitializedLength();
   if (index + extra <= initlen) {
     return;
   }
 
   MOZ_ASSERT(isExtensible());
 
+  if (index > initlen) {
+    markDenseElementsNotPacked(cx);
+  }
+
   uint32_t numShifted = getElementsHeader()->numShiftedElements();
   size_t offset = initlen;
   for (HeapSlot* sp = elements_ + initlen; sp != elements_ + (index + extra);
        sp++, offset++) {
     sp->init(this, HeapSlot::Element, offset + numShifted,
              MagicValue(JS_ELEMENTS_HOLE));
   }
 
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -1267,18 +1267,17 @@ class NativeObject : public JSObject {
     MOZ_ASSERT(!denseElementsAreFrozen());
     checkStoredValue(val);
     elements_[index].set(this, HeapSlot::Element, unshiftedIndex(index), val);
   }
 
   inline void addDenseElementType(JSContext* cx, uint32_t index,
                                   const Value& val);
 
-  // Packed information for this object's elements.
-  inline bool writeToIndexWouldMarkNotPacked(uint32_t index);
+  // Mark the dense elements as possibly containing holes.
   inline void markDenseElementsNotPacked(JSContext* cx);
 
  public:
   inline void setDenseElementWithType(JSContext* cx, uint32_t index,
                                       const Value& val);
   inline void initDenseElementWithType(JSContext* cx, uint32_t index,
                                        const Value& val);
   inline void setDenseElementHole(JSContext* cx, uint32_t index);