Skip to content

Truly independent web browser

LibJS: Say why each write to a named-property slot needs nothing more

Andreas Kling8069a18eb842
diff --git a/Libraries/LibJS/Rust/src/bytecode/property_access.rs b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
index 92ef1b3e5ed..d36b713dcf3 100644
--- a/Libraries/LibJS/Rust/src/bytecode/property_access.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
@@ -628,7 +628,7 @@ pub fn put_by_property_key(
if !cache.writes_data_property {
continue;
}
- object.put_direct(cache.property_offset, value);
+ object.put_direct_from_cache(cache.property_offset, value);
return Ok(());
}
PropertyLookupCacheEntryType::AddOwnProperty => {
@@ -663,7 +663,7 @@ pub fn put_by_property_key(
continue;
}
object.unsafe_set_shape(cached_shape);
- object.put_direct(cache.property_offset, value);
+ object.initialize_direct(cache.property_offset, value);
return Ok(());
}
PropertyLookupCacheEntryType::GetOwnProperty
@@ -797,7 +797,7 @@ pub fn put_by_property_key(
continue;
}
object.unsafe_set_shape(cached_shape);
- object.put_direct(cache.property_offset, value);
+ object.initialize_direct(cache.property_offset, value);
return Ok(());
}
}
diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
index 6b8fe2083ad..c94ebfcf233 100644
--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
@@ -862,7 +862,7 @@ pub fn set_global(vm: &Vm, pc: u32, instruction: &op::SetGlobal, values: &mut op
return SlowPathControl::continue_at(pc + op::SetGlobal::LENGTH);
}
if entry.writes_data_property {
- binding_object.put_direct(entry.property_offset, src);
+ binding_object.put_direct_from_cache(entry.property_offset, src);
return SlowPathControl::continue_at(pc + op::SetGlobal::LENGTH);
}
}
diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
index 50901fda3d6..227557cb1f5 100644
--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
@@ -564,7 +564,7 @@ fn put_by_value_with_keyed_store_cache(
if (!shape.is_dictionary() || shape.dictionary_generation() == entry.shape_dictionary_generation)
&& !object.get_direct(entry.property_offset).is_accessor()
{
- object.put_direct(entry.property_offset, value);
+ object.put_direct_from_cache(entry.property_offset, value);
return Ok(());
}
}
@@ -580,7 +580,7 @@ fn put_by_value_with_keyed_store_cache(
.is_none_or(|validity| validity.is_valid())
{
object.unsafe_set_shape(new_shape);
- object.put_direct(entry.property_offset, value);
+ object.initialize_direct(entry.property_offset, value);
return Ok(());
}
}
@@ -796,7 +796,7 @@ pub fn init_object_literal_property(
&& object.shape() == cached_shape
&& let Some(property_offset) = cached_property_offset
{
- object.put_direct(property_offset, value);
+ object.initialize_direct(property_offset, value);
return SlowPathControl::continue_at(pc + op::InitObjectLiteralProperty::LENGTH);
}
@@ -1479,7 +1479,7 @@ pub fn try_put_by_id_cache(vm: &Vm, instruction: &op::PutById, values: &op::PutB
if current.is_accessor() || !entry.writes_data_property.get() {
return false;
}
- object.put_direct(entry.property_offset.get(), value);
+ object.put_direct_from_cache(entry.property_offset.get(), value);
return true;
}
PropertyLookupCacheEntryType::AddOwnProperty => {
@@ -1513,7 +1513,7 @@ pub fn try_put_by_id_cache(vm: &Vm, instruction: &op::PutById, values: &op::PutB
continue;
}
object.unsafe_set_shape(cached_shape);
- object.put_direct(entry.property_offset.get(), value);
+ object.initialize_direct(entry.property_offset.get(), value);
return true;
}
_ => continue,
@@ -1609,7 +1609,7 @@ pub fn try_put_by_value_cache(vm: &Vm, instruction: &op::PutByValue, values: &op
if current.is_accessor() || !entry.writes_data_property.get() {
return false;
}
- object.put_direct(entry.property_offset.get(), value);
+ object.put_direct_from_cache(entry.property_offset.get(), value);
return true;
}
PropertyLookupCacheEntryType::AddOwnProperty => {
@@ -1639,7 +1639,7 @@ pub fn try_put_by_value_cache(vm: &Vm, instruction: &op::PutByValue, values: &op
continue;
}
object.unsafe_set_shape(cached_shape);
- object.put_direct(entry.property_offset.get(), value);
+ object.initialize_direct(entry.property_offset.get(), value);
return true;
}
_ => continue,
diff --git a/Libraries/LibJS/Rust/src/jit/dependencies.rs b/Libraries/LibJS/Rust/src/jit/dependencies.rs
index 5bf0d850fee..f127d552f81 100644
--- a/Libraries/LibJS/Rust/src/jit/dependencies.rs
+++ b/Libraries/LibJS/Rust/src/jit/dependencies.rs
@@ -52,9 +52,9 @@ pub struct Dependents {
/// assignment, and neither is storing the value it holds, as CreateGlobalFunctionBinding does after defining the
/// property.
///
- /// Nothing but the runtime (`Object::storage_set()` and `Object::storage_delete()`) writes to the slots of a global
- /// object that are not assigned yet, while its shape is a dictionary: property lookup caches only write to slots
- /// whose writes they cached, and the runtime caches no write to such a slot (see
+ /// Nothing but the runtime (`Object::replace_direct()` and `Object::storage_delete()`) writes to the slots of a
+ /// global object that are not assigned yet, while its shape is a dictionary: property lookup caches only write to
+ /// slots whose writes they cached, and the runtime caches no write to such a slot (see
/// `global_object_slot_may_have_been_assigned()`). And no other object ever gets one of the shapes of a global
/// object once it has a dictionary shape, which belongs to it alone, as do the shapes it gets from that one, so
/// that writes the caches made for other objects never apply to it.
diff --git a/Libraries/LibJS/Rust/src/jit/translate.rs b/Libraries/LibJS/Rust/src/jit/translate.rs
index b7d20db866c..92846812c00 100644
--- a/Libraries/LibJS/Rust/src/jit/translate.rs
+++ b/Libraries/LibJS/Rust/src/jit/translate.rs
@@ -160,7 +160,7 @@ impl<'a> SiteValues<'a> {
Some(location) => self.value(*location),
None => Value::UNDEFINED,
};
- object.put_direct(index, value);
+ object.initialize_direct(index, value);
}
Value::from_object(object)
}
diff --git a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
index ba38beffa5a..7f6b651e5c6 100644
--- a/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
+++ b/Libraries/LibJS/Rust/src/runtime/abstract_operations.rs
@@ -1689,7 +1689,7 @@ pub fn create_unmapped_arguments_object(vm: &Vm, arguments: &[Cell<Value>]) -> G
let object = Object::create_with_premade_shape(vm, realm.unmapped_arguments_object_shape());
// 4. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(len), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- object.put_direct(
+ object.initialize_direct(
realm.unmapped_arguments_object_length_offset(),
Value::from_f64(length as f64),
);
@@ -1703,13 +1703,13 @@ pub fn create_unmapped_arguments_object(vm: &Vm, arguments: &[Cell<Value>]) -> G
// 7. Perform ! DefinePropertyOrThrow(obj, @@iterator, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
let array_prototype_values = realm.array_prototype_values_function();
- object.put_direct(
+ object.initialize_direct(
realm.unmapped_arguments_object_well_known_symbol_iterator_offset(),
Value::from_object(array_prototype_values),
);
// 8. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false }).
- object.put_direct(
+ object.initialize_direct(
realm.unmapped_arguments_object_callee_offset(),
Value::from_accessor(realm.throw_type_error_accessor()),
);
@@ -1769,7 +1769,7 @@ pub fn create_mapped_arguments_object(
set_arguments_as_indexed_elements(&object, arguments);
// 16. Perform ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- object.put_direct(realm.mapped_arguments_object_length_offset(), Value::from_i32(length));
+ object.initialize_direct(realm.mapped_arguments_object_length_offset(), Value::from_i32(length));
// OPTIMIZATION: We take a different route here than what the spec suggests.
// The spec would have us allocate a new object for the parameter map,
@@ -1797,13 +1797,13 @@ pub fn create_mapped_arguments_object(
// 20. Perform ! DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
let array_prototype_values = realm.array_prototype_values_function();
- object.put_direct(
+ object.initialize_direct(
realm.mapped_arguments_object_well_known_symbol_iterator_offset(),
Value::from_object(array_prototype_values),
);
// 21. Perform ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }).
- object.put_direct(
+ object.initialize_direct(
realm.mapped_arguments_object_callee_offset(),
Value::from_object(function),
);
diff --git a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
index 8e208d577af..f4c1ebbc58f 100644
--- a/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/ecmascript_function_object.rs
@@ -238,11 +238,11 @@ impl EcmascriptFunctionObject {
// NOTE: The constructor gave us a premade shape with "length" and "name" (and "prototype" for generator kinds) at
// these offsets, with the attributes the spec requires, so we only have to store the values.
- self.put_direct(
+ self.initialize_direct(
realm.normal_function_length_offset(),
Value::from_i32(self.function_length()),
);
- self.put_direct(realm.normal_function_name_offset(), Value::from_string(name_string));
+ self.initialize_direct(realm.normal_function_name_offset(), Value::from_string(name_string));
match self.kind() {
FunctionKind::Normal => {
@@ -252,7 +252,7 @@ impl EcmascriptFunctionObject {
}
FunctionKind::Generator => {
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
- self.put_direct(
+ self.initialize_direct(
realm.generator_function_prototype_property_offset(),
Value::from_object(Object::create_prototype(
vm,
@@ -266,7 +266,7 @@ impl EcmascriptFunctionObject {
// AsyncFunction instances do not have a prototype property as they are not constructible.
}
FunctionKind::AsyncGenerator => {
- self.put_direct(
+ self.initialize_direct(
realm.generator_function_prototype_property_offset(),
Value::from_object(Object::create_prototype(
vm,
@@ -1076,7 +1076,7 @@ impl EcmascriptFunctionObject {
let metadata = object.shape().lookup(property_key);
if metadata.is_none() {
let prototype = Object::create_with_premade_shape(vm, realm.normal_function_prototype_shape());
- prototype.put_direct(
+ prototype.initialize_direct(
realm.normal_function_prototype_constructor_offset(),
Value::from_object(function.as_function_object_gc()),
);
diff --git a/Libraries/LibJS/Rust/src/runtime/function_prototype.rs b/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
index dfcd9f4a984..0e15023d51b 100644
--- a/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/function_prototype.rs
@@ -295,7 +295,9 @@ impl FunctionPrototype {
// 7. Perform SetFunctionLength(F, L).
match length_and_name_slots {
- LengthAndNameSlots::Premade => function.put_direct(BOUND_FUNCTION_LENGTH_OFFSET, Value::from_f64(length)),
+ LengthAndNameSlots::Premade => {
+ function.initialize_direct(BOUND_FUNCTION_LENGTH_OFFSET, Value::from_f64(length));
+ }
LengthAndNameSlots::Absent => function.set_function_length(vm, length),
}
@@ -318,7 +320,7 @@ impl FunctionPrototype {
if let Some(target_name) = target_name {
builder.append(target_name.utf16_string_view());
}
- function.put_direct(
+ function.initialize_direct(
BOUND_FUNCTION_NAME_OFFSET,
Value::from_string(PrimitiveString::create(vm, builder.to_utf16_string())),
);
diff --git a/Libraries/LibJS/Rust/src/runtime/iterator.rs b/Libraries/LibJS/Rust/src/runtime/iterator.rs
index 176101af54a..2d21cf2269c 100644
--- a/Libraries/LibJS/Rust/src/runtime/iterator.rs
+++ b/Libraries/LibJS/Rust/src/runtime/iterator.rs
@@ -644,10 +644,10 @@ pub fn create_iterator_result_object(vm: &Vm, realm: Gc<Realm>, value: Value, do
let object = Object::create_with_premade_shape(vm, realm.iterator_result_object_shape());
// 2. Perform ! CreateDataPropertyOrThrow(obj, "value", value).
- object.put_direct(realm.iterator_result_object_value_offset(), value);
+ object.initialize_direct(realm.iterator_result_object_value_offset(), value);
// 3. Perform ! CreateDataPropertyOrThrow(obj, "done", done).
- object.put_direct(realm.iterator_result_object_done_offset(), Value::from_bool(done));
+ object.initialize_direct(realm.iterator_result_object_done_offset(), Value::from_bool(done));
// 4. Return obj.
object
diff --git a/Libraries/LibJS/Rust/src/runtime/json_text_parser.rs b/Libraries/LibJS/Rust/src/runtime/json_text_parser.rs
index 0f9bcaec481..f5839507eb9 100644
--- a/Libraries/LibJS/Rust/src/runtime/json_text_parser.rs
+++ b/Libraries/LibJS/Rust/src/runtime/json_text_parser.rs
@@ -459,7 +459,7 @@ impl<'a, 'vm, C: CodeUnit> Parser<'a, 'vm, C> {
if let Some(shape) = tables.shapes.shape_for_keys(self.vm, self.realm, keys) {
let object = Object::create_with_premade_shape(self.vm, shape);
for (offset, value) in self.values.borrow()[first_value..].iter().enumerate() {
- object.put_direct(offset as u32, *value);
+ object.initialize_direct(offset as u32, *value);
}
return object;
}
diff --git a/Libraries/LibJS/Rust/src/runtime/native_function.rs b/Libraries/LibJS/Rust/src/runtime/native_function.rs
index 0fcb1176a71..e24d12e8d77 100644
--- a/Libraries/LibJS/Rust/src/runtime/native_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/native_function.rs
@@ -182,14 +182,14 @@ impl NativeFunction {
function.unsafe_set_shape(realm.native_function_shape());
// 10. Perform SetFunctionLength(func, length).
- function.put_direct(realm.native_function_length_offset(), Value::from_i32(length));
+ function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
// 11. If prefix is not present, then
// a. Perform SetFunctionName(func, name).
// 12. Else,
// a. Perform SetFunctionName(func, name, prefix).
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), prefix);
- function.put_direct(realm.native_function_name_offset(), Value::from_string(function_name));
+ function.initialize_direct(realm.native_function_name_offset(), Value::from_string(function_name));
// 13. Return func.
function
@@ -759,9 +759,9 @@ impl RawNativeFunction {
Self::new_with_realm(vm, Self::CLASS, behaviour, Some(prototype), realm, builtin),
);
function.unsafe_set_shape(realm.native_function_shape());
- function.put_direct(realm.native_function_length_offset(), Value::from_i32(length));
+ function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), prefix);
- function.put_direct(realm.native_function_name_offset(), Value::from_string(function_name));
+ function.initialize_direct(realm.native_function_name_offset(), Value::from_string(function_name));
function
}
@@ -837,9 +837,9 @@ impl DirectGetterFunction {
Self::new(vm, behaviour, realm.function_prototype(), realm, configuration),
);
function.unsafe_set_shape(realm.native_function_shape());
- function.put_direct(realm.native_function_length_offset(), Value::from_i32(length));
+ function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), prefix);
- function.put_direct(realm.native_function_name_offset(), Value::from_string(function_name));
+ function.initialize_direct(realm.native_function_name_offset(), Value::from_string(function_name));
function
}
diff --git a/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs b/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
index dda0cb8f2ee..b316999fa83 100644
--- a/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/native_javascript_backed_function.rs
@@ -109,14 +109,14 @@ impl NativeJavaScriptBackedFunction {
function.unsafe_set_shape(realm.native_function_shape());
// 10. Perform SetFunctionLength(func, length).
- function.put_direct(realm.native_function_length_offset(), Value::from_i32(length));
+ function.initialize_direct(realm.native_function_length_offset(), Value::from_i32(length));
// 11. If prefix is not present, then
// a. Perform SetFunctionName(func, name).
// 12. Else,
// a. Perform SetFunctionName(func, name, prefix).
let function_name = function.make_function_name(vm, &ClassElementName::PropertyKey(name.clone()), None);
- function.put_direct(realm.native_function_name_offset(), Value::from_string(function_name));
+ function.initialize_direct(realm.native_function_name_offset(), Value::from_string(function_name));
// 13. Return func.
function
diff --git a/Libraries/LibJS/Rust/src/runtime/object.rs b/Libraries/LibJS/Rust/src/runtime/object.rs
index 514e8df36bd..c5e11f8296d 100644
--- a/Libraries/LibJS/Rust/src/runtime/object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object.rs
@@ -1462,7 +1462,7 @@ impl Object {
let mut offset = 0;
from_shape.for_each_property_in_insertion_order(|_, metadata| {
if metadata.attributes.is_enumerable() {
- self.put_direct(offset, from.get_direct(metadata.offset));
+ self.initialize_direct(offset, from.get_direct(metadata.offset));
offset += 1;
}
ControlFlow::Continue(())
@@ -1531,7 +1531,7 @@ impl Object {
self.shape().mark_unstable(vm);
self.unsafe_set_shape(from.shape());
from.shape().for_each_property_in_insertion_order(|_, metadata| {
- self.put_direct(metadata.offset, from.get_direct(metadata.offset));
+ self.initialize_direct(metadata.offset, from.get_direct(metadata.offset));
ControlFlow::Continue(())
});
return Ok(());
@@ -2552,7 +2552,7 @@ impl Object {
match phase {
PropertyLookupPhase::OwnProperty => {
// NB: Caches may only write to the slots of a global object that may have been assigned
- // already, since the runtime notes assignments to them (see `storage_set()`).
+ // already, since the runtime notes assignments to them (see `replace_direct()`).
if writes_data_property
&& self.has_global_object_flag()
&& !crate::jit::dependencies::global_object_slot_may_have_been_assigned(
@@ -2783,7 +2783,7 @@ impl Object {
&& let Some(accessor) = find_intrinsic_accessor(vm, self, property_key)
{
let value = accessor.compute_value(vm, self.shape().realm());
- self.put_direct(metadata.offset, value);
+ self.initialize_direct(metadata.offset, value);
}
Some(ValueAndAttributes {
@@ -2844,18 +2844,7 @@ impl Object {
}
}
- // NB: JIT code may take the values of global object properties that were never assigned as constants.
- if self.has_global_object_flag() {
- let previous = self.get_direct(metadata.offset);
- if !previous.is_undefined() && previous != value {
- crate::jit::dependencies::note_global_object_slot_assignments(
- vm,
- self,
- metadata.offset..metadata.offset + 1,
- );
- }
- }
- self.put_direct(metadata.offset, value);
+ self.replace_direct(vm, metadata.offset, value);
Some(metadata.offset)
}
@@ -2890,7 +2879,7 @@ impl Object {
}
let new_offset = self.shape().property_count() - 1;
self.ensure_named_storage_capacity(self.shape().property_count());
- self.put_direct(new_offset, value);
+ self.initialize_direct(new_offset, value);
Some(new_offset)
}
@@ -3603,12 +3592,41 @@ impl Object {
unsafe { self.named_properties.get().add(index as usize).read() }
}
- pub fn put_direct(&self, index: u32, value: Value) {
+ // NB: Every write to a named-property slot goes through one of the three methods below, each of which says why
+ // the write needs no more than it does, so that what depends on a slot keeping its value is told of each write
+ // that changes it.
+ fn write_direct(&self, index: u32, value: Value) {
assert!(index < self.named_storage_capacity());
// SAFETY: The index is within the named storage.
unsafe { self.named_properties.get().add(index as usize).write(value) };
}
+ /// Gives a slot its first value, which nothing can have read yet: a slot of an object that is being created, a
+ /// slot of a property that was just added, or the slot of an intrinsic accessor that computes its value the first
+ /// time it is read.
+ pub fn initialize_direct(&self, index: u32, value: Value) {
+ self.write_direct(index, value);
+ }
+
+ /// Writes a value to the slot of an own writable data property where a property lookup cache recorded a write.
+ /// Caches only record writes that need nothing but the write itself (see `replace_direct()`).
+ pub fn put_direct_from_cache(&self, index: u32, value: Value) {
+ self.write_direct(index, value);
+ }
+
+ /// Changes the value of the own named property in slot `index`, and tells what depends on the slot keeping its
+ /// value.
+ pub fn replace_direct(&self, vm: &Vm, index: u32, value: Value) {
+ // NB: JIT code may take the values of global object properties that were never assigned as constants.
+ if self.has_global_object_flag() {
+ let previous = self.get_direct(index);
+ if !previous.is_undefined() && previous != value {
+ crate::jit::dependencies::note_global_object_slot_assignments(vm, self, index..index + 1);
+ }
+ }
+ self.write_direct(index, value);
+ }
+
fn inline_named_storage_pointer(&self) -> *mut Value {
// Cell<Value> is a transparent UnsafeCell, so the inline storage may be written through this pointer.
core::ptr::from_ref(&self.inline_named_storage)
diff --git a/Libraries/LibJS/Rust/src/runtime/object_constructor.rs b/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
index 424696a3c24..5ccc0abb86e 100644
--- a/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object_constructor.rs
@@ -781,16 +781,14 @@ fn try_assign_from_shape(vm: &Vm, target: &Object, source: &Object) -> ThrowComp
}
// OPTIMIZATION: [[Set]] of an own writable data property of an object with ordinary property lookup and [[Set]]
// changes its value, and nothing else.
- // NB: Assignments to the properties of global objects are noted in `Object::storage_set()`.
if target.has_ordinary_named_property_lookup_and_set()
&& !target.has_intrinsic_accessors()
- && !target.has_global_object_flag()
&& let Some(metadata) = target.shape().lookup(&property_key)
&& metadata.attributes.is_writable()
&& !target.get_direct(metadata.offset).is_accessor()
{
realm_fuses::note_property_change(vm, target, &property_key);
- target.put_direct(metadata.offset, value);
+ target.replace_direct(vm, metadata.offset, value);
continue;
}
target.set(vm, &property_key, value, ShouldThrowExceptions::Yes)?;
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs b/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
index 14809e27af7..5cc2f80e242 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_resolving_element_functions.rs
@@ -179,8 +179,8 @@ impl PromiseResolvingElementFunction {
(NATIVE_FUNCTION_METHODS.initialize)(object, vm, realm);
object.unsafe_set_shape(realm.native_function_shape());
- object.put_direct(realm.native_function_length_offset(), Value::from_i32(1));
- object.put_direct(
+ object.initialize_direct(realm.native_function_length_offset(), Value::from_i32(1));
+ object.initialize_direct(
realm.native_function_name_offset(),
Value::from_string(vm.empty_string()),
);
diff --git a/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs b/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
index 6b591935249..0f3e59a5c36 100644
--- a/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
+++ b/Libraries/LibJS/Rust/src/runtime/promise_resolving_function.rs
@@ -118,8 +118,8 @@ impl PromiseResolvingFunction {
(NATIVE_FUNCTION_METHODS.initialize)(object, vm, realm);
object.unsafe_set_shape(realm.native_function_shape());
- object.put_direct(realm.native_function_length_offset(), Value::from_i32(1));
- object.put_direct(
+ object.initialize_direct(realm.native_function_length_offset(), Value::from_i32(1));
+ object.initialize_direct(
realm.native_function_name_offset(),
Value::from_string(vm.empty_string()),
);
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
index ff0d04498b2..abd0ad40bba 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_object.rs
@@ -207,7 +207,7 @@ impl RegExpObject {
realm: Cell::new(None),
},
);
- regexp_object.put_direct(NEW_REGEXP_OBJECT_LAST_INDEX_OFFSET, Value::from_i32(0));
+ regexp_object.initialize_direct(NEW_REGEXP_OBJECT_LAST_INDEX_OFFSET, Value::from_i32(0));
regexp_object
}
diff --git a/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs b/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
index 498fe979c5a..3155294b874 100644
--- a/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
+++ b/Libraries/LibJS/Rust/src/runtime/regexp_prototype.rs
@@ -533,19 +533,19 @@ fn regexp_builtin_exec(
array.set_indexed_property_elements_to_undefined(n_capture_groups + 1);
// "index" property.
- array.put_direct(
+ array.initialize_direct(
realm.intrinsics().regexp_builtin_exec_array_index_offset(),
index_value(match_index),
);
// "input" property.
- array.put_direct(
+ array.initialize_direct(
realm.intrinsics().regexp_builtin_exec_array_input_offset(),
Value::from_string(string),
);
// NB: The groups slot holds undefined until it is set below, so that the array never exposes an unset slot.
- array.put_direct(
+ array.initialize_direct(
realm.intrinsics().regexp_builtin_exec_array_groups_offset(),
Value::UNDEFINED,
);
@@ -561,7 +561,7 @@ fn regexp_builtin_exec(
};
// "groups" property.
- array.put_direct(realm.intrinsics().regexp_builtin_exec_array_groups_offset(), groups);
+ array.initialize_direct(realm.intrinsics().regexp_builtin_exec_array_groups_offset(), groups);
// Track which group names have been matched (non-undefined) to handle duplicate names.
let mut matched_group_names: HashSet<Utf16FlyString> = HashSet::new();