mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
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.
This commit is contained in:
parent
66601f7d59
commit
451c947c3f
Notes:
github-actions[bot]
2025-09-21 13:07:39 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 451c947c3f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6244
Reviewed-by: https://github.com/awesomekling
13 changed files with 148 additions and 61 deletions
|
|
@ -33,6 +33,8 @@ public:
|
|||
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
||||
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
||||
|
||||
virtual bool eligible_for_own_property_enumeration_fast_path() const override final { return false; }
|
||||
|
||||
GC::Ptr<Window> window() const { return m_window; }
|
||||
void set_window(GC::Ref<Window>);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue