mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibJS: Cache PutById to setters in the prototype chain
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This is *extremely* common on the web, but barely shows up at all in JavaScript benchmarks. A typical example is setting Element.innerHTML on a HTMLDivElement. HTMLDivElement doesn't have innerHTML, so it has to travel up the prototype chain until it finds it. Before this change, we didn't cache this at all, so we had to travel the prototype chain every time a setter like this was used. We now use the same mechanism we already had for GetBydId and cache PutById setter accesses in the prototype chain as well. 1.74x speedup on MicroBench/setter-in-prototype-chain.js
This commit is contained in:
parent
71665fa504
commit
183c847c80
Notes:
github-actions[bot]
2025-05-05 13:22:41 +00:00
Author: https://github.com/awesomekling
Commit: 183c847c80
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4597
18 changed files with 93 additions and 39 deletions
|
@ -1224,20 +1224,54 @@ inline ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value thi
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Op::PropertyKind::KeyValue: {
|
case Op::PropertyKind::KeyValue: {
|
||||||
if (cache && cache->shape == &object->shape()) {
|
if (cache) {
|
||||||
object->put_direct(*cache->property_offset, value);
|
if (cache->prototype) {
|
||||||
return {};
|
// OPTIMIZATION: If the prototype chain hasn't been mutated in a way that would invalidate the cache, we can use it.
|
||||||
|
bool can_use_cache = [&]() -> bool {
|
||||||
|
if (&object->shape() != cache->shape)
|
||||||
|
return false;
|
||||||
|
if (!cache->prototype_chain_validity)
|
||||||
|
return false;
|
||||||
|
if (!cache->prototype_chain_validity->is_valid())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}();
|
||||||
|
if (can_use_cache) {
|
||||||
|
auto value_in_prototype = cache->prototype->get_direct(cache->property_offset.value());
|
||||||
|
if (value_in_prototype.is_accessor()) {
|
||||||
|
TRY(call(vm, value_in_prototype.as_accessor().setter(), this_value, value));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (cache->shape == &object->shape()) {
|
||||||
|
auto value_in_object = object->get_direct(cache->property_offset.value());
|
||||||
|
if (value_in_object.is_accessor()) {
|
||||||
|
TRY(call(vm, value_in_object.as_accessor().setter(), this_value, value));
|
||||||
|
} else {
|
||||||
|
object->put_direct(*cache->property_offset, value);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheablePropertyMetadata cacheable_metadata;
|
CacheablePropertyMetadata cacheable_metadata;
|
||||||
bool succeeded = TRY(object->internal_set(name, value, this_value, &cacheable_metadata));
|
bool succeeded = TRY(object->internal_set(name, value, this_value, &cacheable_metadata));
|
||||||
|
|
||||||
if (succeeded && cache && cacheable_metadata.type == CacheablePropertyMetadata::Type::OwnProperty) {
|
if (succeeded && cache) {
|
||||||
cache->shape = object->shape();
|
if (cacheable_metadata.type == CacheablePropertyMetadata::Type::OwnProperty) {
|
||||||
cache->property_offset = cacheable_metadata.property_offset.value();
|
*cache = {};
|
||||||
|
cache->shape = object->shape();
|
||||||
|
cache->property_offset = cacheable_metadata.property_offset.value();
|
||||||
|
} else if (cacheable_metadata.type == CacheablePropertyMetadata::Type::InPrototypeChain) {
|
||||||
|
*cache = {};
|
||||||
|
cache->shape = object->shape();
|
||||||
|
cache->property_offset = cacheable_metadata.property_offset.value();
|
||||||
|
cache->prototype = *cacheable_metadata.prototype;
|
||||||
|
cache->prototype_chain_validity = *cacheable_metadata.prototype->shape().prototype_chain_validity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!succeeded && vm.in_strict_mode()) {
|
if (!succeeded && vm.in_strict_mode()) [[unlikely]] {
|
||||||
if (base.is_object())
|
if (base.is_object())
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, base.to_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, base.to_string_without_side_effects());
|
||||||
return vm.throw_completion<TypeError>(ErrorType::ReferencePrimitiveSetProperty, name, base.typeof_(vm)->utf8_string(), base.to_string_without_side_effects());
|
return vm.throw_completion<TypeError>(ErrorType::ReferencePrimitiveSetProperty, name, base.typeof_(vm)->utf8_string(), base.to_string_without_side_effects());
|
||||||
|
@ -2318,7 +2352,7 @@ ThrowCompletionOr<void> SetGlobal::execute_impl(Bytecode::Interpreter& interpret
|
||||||
if (&shape == cache.shape) {
|
if (&shape == cache.shape) {
|
||||||
auto value = binding_object.get_direct(cache.property_offset.value());
|
auto value = binding_object.get_direct(cache.property_offset.value());
|
||||||
if (value.is_accessor())
|
if (value.is_accessor())
|
||||||
TRY(call(vm, value.as_accessor().setter(), js_undefined(), value));
|
TRY(call(vm, value.as_accessor().setter(), &binding_object, src));
|
||||||
else
|
else
|
||||||
binding_object.put_direct(cache.property_offset.value(), src);
|
binding_object.put_direct(cache.property_offset.value(), src);
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -54,7 +54,7 @@ ThrowCompletionOr<Value> ArgumentsObject::internal_get(PropertyKey const& proper
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.4.4.4 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-set-p-v-receiver
|
// 10.4.4.4 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-arguments-exotic-objects-set-p-v-receiver
|
||||||
ThrowCompletionOr<bool> ArgumentsObject::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*)
|
ThrowCompletionOr<bool> ArgumentsObject::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase)
|
||||||
{
|
{
|
||||||
bool is_mapped = false;
|
bool is_mapped = false;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override;
|
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override;
|
||||||
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
||||||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*) override;
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
||||||
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
||||||
|
|
||||||
// [[ParameterMap]]
|
// [[ParameterMap]]
|
||||||
|
|
|
@ -185,7 +185,7 @@ ThrowCompletionOr<Value> ModuleNamespaceObject::internal_get(PropertyKey const&
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.4.6.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-set-p-v-receiver
|
// 10.4.6.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-module-namespace-exotic-objects-set-p-v-receiver
|
||||||
ThrowCompletionOr<bool> ModuleNamespaceObject::internal_set(PropertyKey const&, Value, Value, CacheablePropertyMetadata*)
|
ThrowCompletionOr<bool> ModuleNamespaceObject::internal_set(PropertyKey const&, Value, Value, CacheablePropertyMetadata*, PropertyLookupPhase)
|
||||||
{
|
{
|
||||||
// 1. Return false.
|
// 1. Return false.
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
|
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
|
||||||
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) const override;
|
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) const override;
|
||||||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*) override;
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
||||||
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
||||||
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const override;
|
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const override;
|
||||||
virtual void initialize(Realm&) override;
|
virtual void initialize(Realm&) override;
|
||||||
|
|
|
@ -952,7 +952,7 @@ ThrowCompletionOr<Value> Object::internal_get(PropertyKey const& property_key, V
|
||||||
|
|
||||||
// 10.1.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver
|
// 10.1.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver
|
||||||
// 10.1.9.1 OrdinarySet ( O, P, V, Receiver ), https://tc39.es/ecma262/#sec-ordinaryset
|
// 10.1.9.1 OrdinarySet ( O, P, V, Receiver ), https://tc39.es/ecma262/#sec-ordinaryset
|
||||||
ThrowCompletionOr<bool> Object::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata* cacheable_metadata)
|
ThrowCompletionOr<bool> Object::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase)
|
||||||
{
|
{
|
||||||
VERIFY(!value.is_special_empty_value());
|
VERIFY(!value.is_special_empty_value());
|
||||||
VERIFY(!receiver.is_special_empty_value());
|
VERIFY(!receiver.is_special_empty_value());
|
||||||
|
@ -961,11 +961,11 @@ ThrowCompletionOr<bool> Object::internal_set(PropertyKey const& property_key, Va
|
||||||
auto own_descriptor = TRY(internal_get_own_property(property_key));
|
auto own_descriptor = TRY(internal_get_own_property(property_key));
|
||||||
|
|
||||||
// 3. Return ? OrdinarySetWithOwnDescriptor(O, P, V, Receiver, ownDesc).
|
// 3. Return ? OrdinarySetWithOwnDescriptor(O, P, V, Receiver, ownDesc).
|
||||||
return ordinary_set_with_own_descriptor(property_key, value, receiver, own_descriptor, cacheable_metadata);
|
return ordinary_set_with_own_descriptor(property_key, value, receiver, own_descriptor, cacheable_metadata, phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.1.9.2 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ), https://tc39.es/ecma262/#sec-ordinarysetwithowndescriptor
|
// 10.1.9.2 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ), https://tc39.es/ecma262/#sec-ordinarysetwithowndescriptor
|
||||||
ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey const& property_key, Value value, Value receiver, Optional<PropertyDescriptor> own_descriptor, CacheablePropertyMetadata* cacheable_metadata)
|
ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey const& property_key, Value value, Value receiver, Optional<PropertyDescriptor> own_descriptor, CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase)
|
||||||
{
|
{
|
||||||
VERIFY(!value.is_special_empty_value());
|
VERIFY(!value.is_special_empty_value());
|
||||||
VERIFY(!receiver.is_special_empty_value());
|
VERIFY(!receiver.is_special_empty_value());
|
||||||
|
@ -980,7 +980,7 @@ ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey con
|
||||||
// b. If parent is not null, then
|
// b. If parent is not null, then
|
||||||
if (parent) {
|
if (parent) {
|
||||||
// i. Return ? parent.[[Set]](P, V, Receiver).
|
// i. Return ? parent.[[Set]](P, V, Receiver).
|
||||||
return TRY(parent->internal_set(property_key, value, receiver));
|
return TRY(parent->internal_set(property_key, value, receiver, cacheable_metadata, PropertyLookupPhase::PrototypeChain));
|
||||||
}
|
}
|
||||||
// c. Else,
|
// c. Else,
|
||||||
else {
|
else {
|
||||||
|
@ -994,6 +994,27 @@ ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto update_inline_cache = [&] {
|
||||||
|
// Non-standard: If the caller has requested cacheable metadata and the property is an own property, fill it in.
|
||||||
|
if (!cacheable_metadata || !own_descriptor->property_offset.has_value() || !shape().is_cacheable())
|
||||||
|
return;
|
||||||
|
if (phase == PropertyLookupPhase::OwnProperty) {
|
||||||
|
*cacheable_metadata = CacheablePropertyMetadata {
|
||||||
|
.type = CacheablePropertyMetadata::Type::OwnProperty,
|
||||||
|
.property_offset = own_descriptor->property_offset.value(),
|
||||||
|
.prototype = nullptr,
|
||||||
|
};
|
||||||
|
} else if (phase == PropertyLookupPhase::PrototypeChain) {
|
||||||
|
VERIFY(shape().is_prototype_shape());
|
||||||
|
VERIFY(shape().prototype_chain_validity()->is_valid());
|
||||||
|
*cacheable_metadata = CacheablePropertyMetadata {
|
||||||
|
.type = CacheablePropertyMetadata::Type::InPrototypeChain,
|
||||||
|
.property_offset = own_descriptor->property_offset.value(),
|
||||||
|
.prototype = this,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 2. If IsDataDescriptor(ownDesc) is true, then
|
// 2. If IsDataDescriptor(ownDesc) is true, then
|
||||||
if (own_descriptor->is_data_descriptor()) {
|
if (own_descriptor->is_data_descriptor()) {
|
||||||
// a. If ownDesc.[[Writable]] is false, return false.
|
// a. If ownDesc.[[Writable]] is false, return false.
|
||||||
|
@ -1022,13 +1043,10 @@ ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey con
|
||||||
// iii. Let valueDesc be the PropertyDescriptor { [[Value]]: V }.
|
// iii. Let valueDesc be the PropertyDescriptor { [[Value]]: V }.
|
||||||
auto value_descriptor = PropertyDescriptor { .value = value };
|
auto value_descriptor = PropertyDescriptor { .value = value };
|
||||||
|
|
||||||
if (cacheable_metadata && own_descriptor.has_value() && own_descriptor->property_offset.has_value() && shape().is_cacheable()) {
|
// NOTE: We don't cache non-setter properties in the prototype chain, as that's a weird
|
||||||
*cacheable_metadata = CacheablePropertyMetadata {
|
// use-case, and doesn't seem like something in need of optimization.
|
||||||
.type = CacheablePropertyMetadata::Type::OwnProperty,
|
if (phase == PropertyLookupPhase::OwnProperty)
|
||||||
.property_offset = own_descriptor->property_offset.value(),
|
update_inline_cache();
|
||||||
.prototype = nullptr,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// iv. Return ? Receiver.[[DefineOwnProperty]](P, valueDesc).
|
// iv. Return ? Receiver.[[DefineOwnProperty]](P, valueDesc).
|
||||||
return TRY(receiver_object.internal_define_own_property(property_key, value_descriptor, &existing_descriptor));
|
return TRY(receiver_object.internal_define_own_property(property_key, value_descriptor, &existing_descriptor));
|
||||||
|
@ -1053,6 +1071,8 @@ ThrowCompletionOr<bool> Object::ordinary_set_with_own_descriptor(PropertyKey con
|
||||||
if (!setter)
|
if (!setter)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
update_inline_cache();
|
||||||
|
|
||||||
// 6. Perform ? Call(setter, Receiver, « V »).
|
// 6. Perform ? Call(setter, Receiver, « V »).
|
||||||
(void)TRY(call(vm, *setter, receiver, value));
|
(void)TRY(call(vm, *setter, receiver, value));
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ public:
|
||||||
PrototypeChain,
|
PrototypeChain,
|
||||||
};
|
};
|
||||||
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) const;
|
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) const;
|
||||||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata* = nullptr);
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty);
|
||||||
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&);
|
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&);
|
||||||
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const;
|
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const;
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public:
|
||||||
// might not hold when property access behaves differently.
|
// might not hold when property access behaves differently.
|
||||||
bool may_interfere_with_indexed_property_access() const { return m_may_interfere_with_indexed_property_access; }
|
bool may_interfere_with_indexed_property_access() const { return m_may_interfere_with_indexed_property_access; }
|
||||||
|
|
||||||
ThrowCompletionOr<bool> ordinary_set_with_own_descriptor(PropertyKey const&, Value, Value, Optional<PropertyDescriptor>, CacheablePropertyMetadata* = nullptr);
|
ThrowCompletionOr<bool> ordinary_set_with_own_descriptor(PropertyKey const&, Value, Value, Optional<PropertyDescriptor>, CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty);
|
||||||
|
|
||||||
// 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects
|
// 10.4.7 Immutable Prototype Exotic Objects, https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_get(PropertyKey const& property_k
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.5.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
|
// 10.5.9 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
|
||||||
ThrowCompletionOr<bool> ProxyObject::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*)
|
ThrowCompletionOr<bool> ProxyObject::internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase)
|
||||||
{
|
{
|
||||||
LIMIT_PROXY_RECURSION_DEPTH();
|
LIMIT_PROXY_RECURSION_DEPTH();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
|
virtual ThrowCompletionOr<bool> internal_has_property(PropertyKey const&) const override;
|
||||||
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
virtual ThrowCompletionOr<Value> internal_get(PropertyKey const&, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
||||||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*) override;
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const&, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
||||||
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
virtual ThrowCompletionOr<bool> internal_delete(PropertyKey const&) override;
|
||||||
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const override;
|
virtual ThrowCompletionOr<GC::RootVector<Value>> internal_own_property_keys() const override;
|
||||||
virtual ThrowCompletionOr<Value> internal_call(ExecutionContext&, Value this_argument) override;
|
virtual ThrowCompletionOr<Value> internal_call(ExecutionContext&, Value this_argument) override;
|
||||||
|
|
|
@ -352,7 +352,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.4.5.6 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-set-p-v-receiver
|
// 10.4.5.6 [[Set]] ( P, V, Receiver ), https://tc39.es/ecma262/#sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||||
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*) override
|
virtual ThrowCompletionOr<bool> internal_set(PropertyKey const& property_key, Value value, Value receiver, CacheablePropertyMetadata*, PropertyLookupPhase) override
|
||||||
{
|
{
|
||||||
VERIFY(!value.is_special_empty_value());
|
VERIFY(!value.is_special_empty_value());
|
||||||
VERIFY(!receiver.is_special_empty_value());
|
VERIFY(!receiver.is_special_empty_value());
|
||||||
|
|
|
@ -215,10 +215,10 @@ JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> PlatformObject::internal
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://webidl.spec.whatwg.org/#legacy-platform-object-set
|
// https://webidl.spec.whatwg.org/#legacy-platform-object-set
|
||||||
JS::ThrowCompletionOr<bool> PlatformObject::internal_set(JS::PropertyKey const& property_name, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata)
|
JS::ThrowCompletionOr<bool> PlatformObject::internal_set(JS::PropertyKey const& property_name, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata, PropertyLookupPhase phase)
|
||||||
{
|
{
|
||||||
if (!m_legacy_platform_object_flags.has_value() || m_legacy_platform_object_flags->has_global_interface_extended_attribute)
|
if (!m_legacy_platform_object_flags.has_value() || m_legacy_platform_object_flags->has_global_interface_extended_attribute)
|
||||||
return Base::internal_set(property_name, value, receiver, metadata);
|
return Base::internal_set(property_name, value, receiver, metadata, phase);
|
||||||
|
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
// ^JS::Object
|
// ^JS::Object
|
||||||
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value, JS::Value, JS::CacheablePropertyMetadata* = nullptr) override;
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value, JS::Value, JS::CacheablePropertyMetadata* = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
|
virtual JS::ThrowCompletionOr<bool> internal_prevent_extensions() override;
|
||||||
|
|
|
@ -672,13 +672,13 @@ JS::ThrowCompletionOr<JS::Value> Location::internal_get(JS::PropertyKey const& p
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.10.5.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-set
|
// 7.10.5.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/history.html#location-set
|
||||||
JS::ThrowCompletionOr<bool> Location::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata)
|
JS::ThrowCompletionOr<bool> Location::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* cacheable_metadata, PropertyLookupPhase phase)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
|
|
||||||
// 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinarySet(this, P, V, Receiver).
|
// 1. If IsPlatformObjectSameOrigin(this) is true, then return ? OrdinarySet(this, P, V, Receiver).
|
||||||
if (HTML::is_platform_object_same_origin(*this))
|
if (HTML::is_platform_object_same_origin(*this))
|
||||||
return JS::Object::internal_set(property_key, value, receiver, cacheable_metadata);
|
return JS::Object::internal_set(property_key, value, receiver, cacheable_metadata, phase);
|
||||||
|
|
||||||
// 2. Return ? CrossOriginSet(this, P, V, Receiver).
|
// 2. Return ? CrossOriginSet(this, P, V, Receiver).
|
||||||
return HTML::cross_origin_set(vm, static_cast<JS::Object&>(*this), property_key, value, receiver);
|
return HTML::cross_origin_set(vm, static_cast<JS::Object&>(*this), property_key, value, receiver);
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*) override;
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
||||||
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
|
||||||
|
|
||||||
// 7.4.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy-set
|
// 7.4.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy-set
|
||||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy-set
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#windowproxy-set
|
||||||
JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*)
|
JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase)
|
||||||
{
|
{
|
||||||
auto& vm = this->vm();
|
auto& vm = this->vm();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
virtual JS::ThrowCompletionOr<Optional<JS::PropertyDescriptor>> internal_get_own_property(JS::PropertyKey const&) const override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
virtual JS::ThrowCompletionOr<bool> internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&, Optional<JS::PropertyDescriptor>* precomputed_get_own_property = nullptr) override;
|
||||||
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) const override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*) override;
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata*, PropertyLookupPhase) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const&) override;
|
||||||
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
virtual JS::ThrowCompletionOr<GC::RootVector<JS::Value>> internal_own_property_keys() const override;
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@ void ObservableArray::set_on_delete_an_indexed_value_callback(DeleteAnIndexedVal
|
||||||
m_on_delete_an_indexed_value = GC::create_function(heap(), move(callback));
|
m_on_delete_an_indexed_value = GC::create_function(heap(), move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::ThrowCompletionOr<bool> ObservableArray::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata)
|
JS::ThrowCompletionOr<bool> ObservableArray::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata, PropertyLookupPhase phase)
|
||||||
{
|
{
|
||||||
if (property_key.is_number() && m_on_set_an_indexed_value)
|
if (property_key.is_number() && m_on_set_an_indexed_value)
|
||||||
TRY(Bindings::throw_dom_exception_if_needed(vm(), [&] { return m_on_set_an_indexed_value->function()(value); }));
|
TRY(Bindings::throw_dom_exception_if_needed(vm(), [&] { return m_on_set_an_indexed_value->function()(value); }));
|
||||||
return TRY(Base::internal_set(property_key, value, receiver, metadata));
|
return TRY(Base::internal_set(property_key, value, receiver, metadata, phase));
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::ThrowCompletionOr<bool> ObservableArray::internal_delete(JS::PropertyKey const& property_key)
|
JS::ThrowCompletionOr<bool> ObservableArray::internal_delete(JS::PropertyKey const& property_key)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ObservableArray final : public JS::Array {
|
||||||
public:
|
public:
|
||||||
static GC::Ref<ObservableArray> create(JS::Realm& realm);
|
static GC::Ref<ObservableArray> create(JS::Realm& realm);
|
||||||
|
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata = nullptr) override;
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata = nullptr, PropertyLookupPhase = PropertyLookupPhase::OwnProperty) override;
|
||||||
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const& property_key) override;
|
virtual JS::ThrowCompletionOr<bool> internal_delete(JS::PropertyKey const& property_key) override;
|
||||||
|
|
||||||
using SetAnIndexedValueCallbackFunction = Function<ExceptionOr<void>(JS::Value&)>;
|
using SetAnIndexedValueCallbackFunction = Function<ExceptionOr<void>(JS::Value&)>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue