Bug 1951338: Add fast path for packed elements in willBeSparseElements r=jandem
I originally intended to reset the NON_PACKED flag in this code if there were no holes, but after a closer look, I realized that we exit early from the loop once we've seen enough non-holes, but resetting the flag would require us to examine every element. Differential Revision: https://phabricator.services.mozilla.com/D241534
This commit is contained in:
@@ -545,9 +545,13 @@ bool NativeObject::willBeSparseElements(uint32_t requiredCapacity,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t len = getDenseInitializedLength();
|
uint32_t initLen = getDenseInitializedLength();
|
||||||
|
if (denseElementsArePacked()) {
|
||||||
|
return minimalDenseCount > initLen;
|
||||||
|
}
|
||||||
|
|
||||||
const Value* elems = getDenseElements();
|
const Value* elems = getDenseElements();
|
||||||
for (uint32_t i = 0; i < len; i++) {
|
for (uint32_t i = 0; i < initLen; i++) {
|
||||||
if (!elems[i].isMagic(JS_ELEMENTS_HOLE) && !--minimalDenseCount) {
|
if (!elems[i].isMagic(JS_ELEMENTS_HOLE) && !--minimalDenseCount) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user