LibJS: Add fast path internal_has_property() for Array

If array has packed index property storage without holes, we could check
if indexed property is present simple by checking if it's less than
array's length.

Makes the following program go 1.1x faster:
```js
function f() {
    let array = [];
    for (let i = 0; i < 3_000; i++) {
        array.push(i);
    }

    for (let i = 0; i < 10_000; i++) {
        array.map(x => x * 2);
    }
}

f();
```
This commit is contained in:
Aliaksandr Kalenik 2025-06-03 19:09:33 +02:00 committed by Alexander Kalenik
commit 93cd17db74
Notes: github-actions[bot] 2025-06-03 21:19:39 +00:00
2 changed files with 14 additions and 0 deletions

View file

@ -50,6 +50,7 @@ public:
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override final;
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) override;
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override final;
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override final;
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const override final;