summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-02-03 04:52:44 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-02-03 04:52:44 +0100
commit9c6a8450b3e96442035b84025b0dd13be3a9e5f8 (patch)
tree7ac81b5bf434c27dc4952364016536bbf19cc3b8
parentbbbfd00f95d2d689aabe0087e597efab48442a18 (diff)
downloadUXP-9c6a8450b3e96442035b84025b0dd13be3a9e5f8.tar
UXP-9c6a8450b3e96442035b84025b0dd13be3a9e5f8.tar.gz
UXP-9c6a8450b3e96442035b84025b0dd13be3a9e5f8.tar.lz
UXP-9c6a8450b3e96442035b84025b0dd13be3a9e5f8.tar.xz
UXP-9c6a8450b3e96442035b84025b0dd13be3a9e5f8.zip
Issue #1382 - Remove invalid assertion.
There is flexibility in exactly the value the initialized length must hold, i.e. if an array is completely empty, it is valid for the initialized length to be any value between zero and the length of the array, as long as the in-memory values below the initialized length have been initialized with a hole value. In the case of 0, the array is packed and the move operation would be a nop, so simply convert the assert to a condition to save some cycles.
-rw-r--r--js/src/jsarray.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp
index e618c319f..73243d918 100644
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -2105,14 +2105,15 @@ js::ArrayShiftMoveElements(NativeObject* obj)
MOZ_ASSERT_IF(obj->is<ArrayObject>(), obj->as<ArrayObject>().lengthIsWritable());
size_t initlen = obj->getDenseInitializedLength();
- MOZ_ASSERT(initlen > 0);
-
- /*
- * At this point the length and initialized length have already been
- * decremented and the result fetched, so just shift the array elements
- * themselves.
- */
- obj->moveDenseElementsNoPreBarrier(0, 1, initlen);
+
+ if (initlen > 0) {
+ /*
+ * At this point the length and initialized length have already been
+ * decremented and the result fetched, so just shift the array elements
+ * themselves.
+ */
+ obj->moveDenseElementsNoPreBarrier(0, 1, initlen);
+ }
}
static inline void