Open Bug 1868857 Opened 7 months ago Updated 7 months ago

Suppress deleted properties using low-bit tags instead of removal

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: iain, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

We implement for-in enumeration using NativeIterator, an object with a trailing array of strings that we expect to return as keys. To handle cases where a property is deleted while we are iterating the object, we link NativeIterators into a linked list while active. When a property is deleted, we check to see if it is currently being iterated, and if so, we fix up the NativeIterator.

Currently we do so by mutating the trailing array to remove deleted keys (if we haven't already visited them). This unfortunately means that we can't reuse the iterator again for a subsequent object with the same shape. It also means that we can't simply reuse the cached NativeIterator to do scalar replacement of Object.keys.

Jan suggested that instead of removing keys entirely, we could simply tag them as deleted, and skip deleted keys in MoreIter. This lets us reuse the NativeIterator (by untagging all deleted keys when we're done iterating). It also lets Object.keys use the same NativeIterator, even if there's an active enumeration, by simply ignoring the tag bit. We end up with NativeIterators that are still mutable where necessary for for-in, but immutable from the point of view of Object.keys.

Depends on D195807

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: