LibJS: Add PropertyLookupPhase enum to distinguish Object [[Get]] calls

We can now tell the difference between an own property access and a
subsequent (automatic) prototype chain access.

This will be used to implement caching of prototype chain accesses.
This commit is contained in:
Andreas Kling 2024-05-02 11:13:08 +02:00
commit 493a04d5fe
Notes: sideshowbarker 2024-07-17 23:07:41 +09:00
17 changed files with 34 additions and 28 deletions

View file

@ -483,13 +483,13 @@ JS::ThrowCompletionOr<bool> Location::internal_define_own_property(JS::PropertyK
}
// 7.10.5.7 [[Get]] ( P, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-get
JS::ThrowCompletionOr<JS::Value> Location::internal_get(JS::PropertyKey const& property_key, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata) const
JS::ThrowCompletionOr<JS::Value> Location::internal_get(JS::PropertyKey const& property_key, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase) const
{
auto& vm = this->vm();
// 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinaryGet(this, P, Receiver).
if (HTML::is_platform_object_same_origin(*this))
return JS::Object::internal_get(property_key, receiver, cacheable_metadata);
return JS::Object::internal_get(property_key, receiver, cacheable_metadata, phase);
// 2. Return ? CrossOriginGet(this, P, Receiver).
return HTML::cross_origin_get(vm, static_cast<JS::Object const&>(*this), property_key, receiver);