Bug 1651645 part 2 - Simplify DeleteArrayElement, make some methods private. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 09 Jul 2020 20:55:29 +0000
changeset 540333 4a7666aa3cc64b5f63cc6ef1e816359cac07a0da
parent 540332 1b1c0c802a6b47c8d7c52725212ad23cdc636a10
child 540334 d34278f7a4a713aada6fe56289a344395f194415
push id37599
push userapavel@mozilla.com
push dateTue, 14 Jul 2020 15:35:20 +0000
treeherdermozilla-central@bca48c382991 [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 2 - Simplify DeleteArrayElement, make some methods private. r=evilpie Depends on D82958 Differential Revision: https://phabricator.services.mozilla.com/D82959
js/src/builtin/Array.cpp
js/src/vm/NativeObject.h
--- a/js/src/builtin/Array.cpp
+++ b/js/src/builtin/Array.cpp
@@ -542,18 +542,17 @@ static bool DeleteArrayElement(JSContext
       uint32_t idx = uint32_t(index);
       if (idx < aobj->getDenseInitializedLength()) {
         if (!aobj->maybeCopyElementsForWrite(cx)) {
           return false;
         }
         if (idx + 1 == aobj->getDenseInitializedLength()) {
           aobj->setDenseInitializedLengthMaybeNonExtensible(cx, idx);
         } else {
-          aobj->markDenseElementsNotPacked(cx);
-          aobj->setDenseElement(idx, MagicValue(JS_ELEMENTS_HOLE));
+          aobj->setDenseElementHole(cx, idx);
         }
         if (!SuppressDeletedElement(cx, obj, idx)) {
           return false;
         }
       }
     }
 
     return result.succeed();
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -1260,16 +1260,20 @@ class NativeObject : public JSObject {
     checkStoredValue(val);
     elements_[index].init(this, HeapSlot::Element, unshiftedIndex(index), val);
   }
 
  private:
   inline void addDenseElementType(JSContext* cx, uint32_t index,
                                   const Value& val);
 
+  // Packed information for this object's elements.
+  inline bool writeToIndexWouldMarkNotPacked(uint32_t index);
+  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);
   inline void removeDenseElementForSparseIndex(JSContext* cx, uint32_t index);
 
@@ -1306,20 +1310,16 @@ class NativeObject : public JSObject {
 
   bool denseElementsAreSealed() const {
     return getElementsHeader()->isSealed();
   }
   bool denseElementsAreFrozen() const {
     return hasAllFlags(js::BaseShape::FROZEN_ELEMENTS);
   }
 
-  /* Packed information for this object's elements. */
-  inline bool writeToIndexWouldMarkNotPacked(uint32_t index);
-  inline void markDenseElementsNotPacked(JSContext* cx);
-
   // Ensures that the object can hold at least index + extra elements. This
   // returns DenseElement_Success on success, DenseElement_Failed on failure
   // to grow the array, or DenseElement_Incomplete when the object is too
   // sparse to grow (this includes the case of index + extra overflow). In
   // the last two cases the object is kept intact.
   inline DenseElementResult ensureDenseElements(JSContext* cx, uint32_t index,
                                                 uint32_t extra);