Closed Bug 1234947 Opened 9 years ago Closed 4 months ago

Array element access is too slow when the Array length does not fit into int32_t.

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox46 --- affected

People

(Reporter: arai, Unassigned)

References

Details

derived from bug 1233642. [[Has]] (and also [[Get]]) operation for Array element takes 50x longer time when the Array length does not fit into int32_t. function test(E) { var i = 0, k = 0, len = E.length; while (k < len) { if (k in E) i++; k++; } return i; } var t = elapsed(); test(new Array(2**31 - 1)); print(elapsed() - t); t = elapsed(); test(new Array(2**31)); // this takes so long time print(elapsed() - t);
looks like it's because IonMonkey is optimized for an Array with length <= INT32_MAX. https://dxr.mozilla.org/mozilla-central/rev/388bdc46ba51ee31da8b8abe977e0ca38d117434/js/src/vm/ArrayObject-inl.h#29 > inline void > ArrayObject::setLength(ExclusiveContext* cx, uint32_t length) > { > MOZ_ASSERT(lengthIsWritable()); > > if (length > INT32_MAX) { > /* Track objects with overflowing lengths in type information. */ > MarkObjectGroupFlags(cx, this, OBJECT_FLAG_LENGTH_OVERFLOW); > } > > getElementsHeader()->length = length; > } https://dxr.mozilla.org/mozilla-central/rev/388bdc46ba51ee31da8b8abe977e0ca38d117434/js/src/vm/UnboxedObject-inl.h#189 > inline void > UnboxedArrayObject::setLength(ExclusiveContext* cx, uint32_t length) > { > if (length > INT32_MAX) { > // Track objects with overflowing lengths in type information. > MarkObjectGroupFlags(cx, this, OBJECT_FLAG_LENGTH_OVERFLOW); > } > > length_ = length; > }
Severity: normal → S3

Times are similar enough for me that I'll call this fixed.

Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.