Skip to content

Truly independent web browser

LibJS: Stop checking extensibility where the shape tells it

Shannon Boothee747a9faa16
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs b/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
index c4c500df900..2c55b668c8a 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
@@ -520,21 +520,15 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
layout.property_lookup_cache_entry_type_add_own_property as i32,
miss,
);
- // Extensible objects that may cache property additions, without a
- // magical length (whose additions depend on the key).
- let flags = layout.object_flag_is_extensible
- | layout.object_flag_may_interfere
+ // Objects that may cache property additions, without a magical length
+ // (whose additions depend on the key).
+ let flags = layout.object_flag_may_interfere
| layout.object_flag_requires_slow_add_own_property
| layout.object_flag_has_magical_length;
self.masm
.load16(scratch, &Address::new(object, offsets.object_flags as i32));
- self.masm.and32_imm(scratch, scratch, u32::from(flags));
- self.masm.branch32_imm(
- Condition::NotEqual,
- scratch,
- i32::from(layout.object_flag_is_extensible),
- miss,
- );
+ self.masm
+ .branch_test32(Condition::NonZero, scratch, u32::from(flags), miss);
let valid_chain = self.masm.new_label();
self.masm
.load64(shape, &Address::new(entry, fields.prototype_chain_validity));
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
index a6b5bdb2f13..5d2e59e8bf7 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
@@ -3262,10 +3262,9 @@ fn put_by_id_adds_properties_through_property_caches() {
};
assert_eq!(add(&mut fake, FLAG_IS_EXTENSIBLE), 0);
assert_eq!(fake.properties[3], value::TRUE);
- // Objects that are not extensible, may interfere with indexed accesses,
- // require slow additions or have a magical length are left to the probe.
+ // Objects that may interfere with indexed accesses, require slow
+ // additions or have a magical length are left to the probe.
for flags in [
- 0,
FLAG_IS_EXTENSIBLE | FLAG_MAY_INTERFERE,
FLAG_IS_EXTENSIBLE | FLAG_REQUIRES_SLOW_ADD_OWN_PROPERTY,
FLAG_IS_EXTENSIBLE | FLAG_HAS_MAGICAL_LENGTH,
diff --git a/Libraries/LibJS/Rust/src/bytecode/property_access.rs b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
index 60ebba3d6a8..ee4b73d5e5a 100644
--- a/Libraries/LibJS/Rust/src/bytecode/property_access.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
@@ -601,11 +601,6 @@ pub fn put_by_property_key(
continue;
};
- // Cannot add properties to non-extensible objects (frozen, sealed, or preventExtensions).
- if !object.internal_is_extensible(vm)? {
- continue;
- }
-
// The cache is invalid if the prototype chain has been mutated, since such a mutation could have added a setter for the property.
if cache
.prototype_chain_validity
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 ffce9dfbcd0..ddd629ea95c 100644
--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
@@ -581,7 +581,6 @@ fn put_by_value_with_keyed_store_cache(
// NB: These are the checks of an addition through the cache of a put (see put_by_property_key()).
let new_shape = entry.new_shape.expect("additions have a new shape");
if property_addition_is_cacheable(vm, &object, property_key)
- && object.internal_is_extensible(vm)?
&& entry
.prototype_chain_validity
.is_none_or(|validity| validity.is_valid())
@@ -1587,9 +1586,6 @@ fn try_put_by_property_lookup_cache(
let Some(new_shape) = entry.new_shape.get() else {
continue;
};
- if !object.extensible() {
- continue;
- }
if entry
.prototype_chain_validity
.get()
diff --git a/Libraries/LibJS/Rust/src/runtime/object.rs b/Libraries/LibJS/Rust/src/runtime/object.rs
index bcebd650a8d..7916141c0ba 100644
--- a/Libraries/LibJS/Rust/src/runtime/object.rs
+++ b/Libraries/LibJS/Rust/src/runtime/object.rs
@@ -1423,7 +1423,6 @@ impl Object {
let from_shape = from.shape();
if !(self.shape() == new_object_shape
&& self.indexed_storage_kind() == IndexedStorageKind::None
- && self.extensible()
&& self.eligible_for_own_property_enumeration_fast_path()
&& !self.has_intrinsic_accessors()
&& !self.may_interfere_with_indexed_property_access()
@@ -1542,7 +1541,6 @@ impl Object {
&& excluded_values.is_empty()
&& self.shape() == current_realm().new_object_shape()
&& self.indexed_storage_kind() == IndexedStorageKind::None
- && self.extensible()
&& self.eligible_for_own_property_enumeration_fast_path()
&& !self.has_intrinsic_accessors()
&& !self.may_interfere_with_indexed_property_access()