mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibJS: Support instrinsic Object properties with deferred evaluation
For performance, it is desirable to defer evaluation of intrinsics that are stored on the GlobalObject for every created Realm. To support this, Object now maintains a global storage map to store lambdas that will return the associated intrinsic when evaluated. Once accessed, the instrinsic is moved from this global map to normal Object storage. To prevent this flow from becoming observable, when a deferred intrinsic is stored, we still place an empty object in the normal Object storage. This is so we still create the metadata for the object, and in doing so, can preserve insertion order of the Object storage. Otherwise, this will be observable by way of Object.getOwnPropertyDescriptors.
This commit is contained in:
parent
4f08f2f581
commit
12f9f3d9ef
2 changed files with 53 additions and 1 deletions
|
@ -47,7 +47,7 @@ public:
|
|||
static Object* create(Realm&, Object* prototype);
|
||||
|
||||
virtual void initialize(Realm&) override;
|
||||
virtual ~Object() = default;
|
||||
virtual ~Object();
|
||||
|
||||
enum class PropertyKind {
|
||||
Key,
|
||||
|
@ -151,6 +151,9 @@ public:
|
|||
void define_direct_property(PropertyKey const& property_key, Value value, PropertyAttributes attributes) { storage_set(property_key, { value, attributes }); };
|
||||
void define_direct_accessor(PropertyKey const&, FunctionObject* getter, FunctionObject* setter, PropertyAttributes attributes);
|
||||
|
||||
using IntrinsicAccessor = Value (*)(Realm&);
|
||||
virtual void define_intrinsic_accessor(PropertyKey const&, PropertyAttributes attributes, IntrinsicAccessor accessor);
|
||||
|
||||
void define_native_function(Realm&, PropertyKey const&, SafeFunction<ThrowCompletionOr<Value>(VM&)>, i32 length, PropertyAttributes attributes);
|
||||
void define_native_accessor(Realm&, PropertyKey const&, SafeFunction<ThrowCompletionOr<Value>(VM&)> getter, SafeFunction<ThrowCompletionOr<Value>(VM&)> setter, PropertyAttributes attributes);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue