ladybird/Libraries/LibJS/Tests/builtins/Object
Aliaksandr Kalenik 451c947c3f LibJS: Fast-path own-property enumeration and reduce descriptor lookups
Before this change, PropertyNameIterator (used by for..in) and
`Object::enumerable_own_property_names()` (used by `Object.keys()`,
`Object.values()`, and `Object.entries()`) enumerated an object's own
enumerable properties exactly as the spec prescribes:
- Call `internal_own_property_keys()`, allocating a list of JS::Value
  keys.
- For each key, call internal_get_own_property() to obtain a
  descriptor and check `[[Enumerable]]`.

While that is required in the general case (e.g. for Proxy objects or
platform/exotic objects that override `[[OwnPropertyKeys]]`), it's
overkill for ordinary JS objects that store their own properties in the
shape table and indexed-properties storage.

This change introduces `for_each_own_property_with_enumerability()`,
which, for objects where
`eligible_for_own_property_enumeration_fast_path()` is `true`, lets us
read the enumerability directly from shape metadata (and from
indexed-properties storage) without a per-property descriptor lookup.
When we cannot avoid `internal_get_own_property()`, we still
benefit by skipping the temporary `Vector<Value>` of keys and avoiding
the unnecessary round-trip between PropertyKey and Value.
2025-09-21 15:06:32 +02:00
..
Object.assign.js
Object.create.js
Object.defineProperties.js
Object.defineProperty.js
Object.entries.js
Object.freeze.js
Object.getOwnPropertyDescriptor.js
Object.getOwnPropertyNames.js
Object.getOwnPropertySymbols.js
Object.getPrototypeOf.js
Object.groupBy.js
Object.hasOwn.js
Object.is.js
Object.isExtensible.js
Object.isFrozen.js
Object.isSealed.js
Object.js
Object.keys.js
Object.preventExtensions.js
Object.prototype.constructor.js
Object.prototype.hasOwnProperty.js
Object.prototype.isPrototypeOf.js
Object.prototype.js
Object.prototype.propertyIsEnumerable.js
Object.prototype.toLocaleString.js
Object.prototype.toString.js
Object.prototype.valueOf.js
Object.seal.js
Object.setPrototypeOf.js
Object.values.js