1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibJS: Make Object::internal_get() reveal the used property offset

This function now takes an optional out parameter for callers who would
like to what kind of property we ended up getting.

This will be used to implement inline caching for property lookups.

Also, to prepare for adding more forms of caching, the out parameter
is a struct CacheablePropertyMetadata rather than just an offset. :^)
This commit is contained in:
Andreas Kling 2023-07-08 17:39:18 +02:00
parent babe924da1
commit 52cd671163
19 changed files with 58 additions and 28 deletions

View file

@ -39,6 +39,17 @@ struct PrivateElement {
Handle<Value> value;
};
// Non-standard: This is information optionally returned by object property access functions.
// It can be used to implement inline caches for property lookup.
struct CacheablePropertyMetadata {
enum class Type {
NotCacheable,
OwnProperty,
};
Type type { Type::NotCacheable };
Optional<u32> property_offset;
};
class Object : public Cell {
JS_CELL(Object, Cell);
@ -118,7 +129,7 @@ public:
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const;
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&);
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const;
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver) const;
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr) const;
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver);
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&);
virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const;