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
parent 3945e1a82a
commit 493a04d5fe
17 changed files with 34 additions and 28 deletions

View File

@@ -137,14 +137,14 @@ ThrowCompletionOr<bool> ModuleNamespaceObject::internal_has_property(PropertyKey
}
// 10.4.6.8 [[Get]] ( P, Receiver ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-get-p-receiver
ThrowCompletionOr<Value> ModuleNamespaceObject::internal_get(PropertyKey const& property_key, Value receiver, CacheablePropertyMetadata* cacheable_metadata) const
ThrowCompletionOr<Value> ModuleNamespaceObject::internal_get(PropertyKey const& property_key, Value receiver, CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase) const
{
auto& vm = this->vm();
// 1. If Type(P) is Symbol, then
if (property_key.is_symbol()) {
// a. Return ! OrdinaryGet(O, P, Receiver).
return MUST(Object::internal_get(property_key, receiver, cacheable_metadata));
return MUST(Object::internal_get(property_key, receiver, cacheable_metadata, phase));
}
// 2. Let exports be O.[[Exports]].