Closed Bug 1500052 Opened 7 years ago Closed 7 years ago

Iterator cache should check initialized length instead of empty elements singleton

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

Attachments

(1 file)

Instead of checking hasEmptyElements() we should check getDenseInitializedLength() == 0. This eliminates thousands of iterator objects on Google Docs (I noticed this while looking into bug 505818 comment 18). The patch improves the micro-benchmark below a lot: before: 13575 ms after: 170 ms function f() { var a = new Array(10); var t = new Date; for (var i = 0; i < 10000000; i++) { for (var x in a) {} } print(new Date - t); } f();
hasEmptyElements() is too pessimistic: arrays often have no elements but aren't using the empty elements singleton.
Pushed by jandemooij@gmail.com: https://hg.mozilla.org/integration/autoland/rev/609976e5c798 Fix iterator cache to check getDenseInitializedLength() == 0 instead of hasEmptyElements(). r=evilpie
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: