Skip to content

Truly independent web browser

LibJS: Key every property lookup cache entry by one shape

Shannon Booth0120aeb47b8c
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
index 437f0fe44f9..8ba2117fd7c 100644
--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
@@ -5109,38 +5109,38 @@ asm_handler_PutByValue:
b.eq .Lasm_PutByValue.ssa_block_2
and x0, x0, #0xfffffffffffffffc
ldr w2, [x21, #4]
- ldr x3, [x27, x2, lsl #3]
- lsr x9, x3, #48
+ ldr x2, [x27, x2, lsl #3]
+ lsr x9, x2, #48
mov w10, #65529
cmp x9, x10
b.ne .Lasm_PutByValue.ssa_block_1
ldr x9, [x0, #48]
cmp x9, x1
b.ne .Lasm_PutByValue.ssa_block_3
- and x3, x3, #0x3ffffffffff
- add x3, x3, x24
- ldr x1, [x3, #24]
+ and x2, x2, #0x3ffffffffff
+ add x2, x2, x24
+ ldr x1, [x2, #24]
cbz x1, .Lasm_PutByValue.assert_failure_2
- ldp x4, x2, [x0, #24]
+ ldp x4, x3, [x0, #24]
cmp x4, x1
b.ne .Lasm_PutByValue.ssa_block_3
- cbnz x2, .Lasm_PutByValue.ssa_block_3
- ldp w2, w4, [x0, #4]
+ cbnz x3, .Lasm_PutByValue.ssa_block_3
+ ldp w3, w4, [x0, #4]
ldr w9, [x1, #52]
cmp w9, w4
b.ne .Lasm_PutByValue.ssa_block_3
- ldr x1, [x3, #32]
- cbz x1, .Lasm_PutByValue.assert_failure_3
- ldr x3, [x1, x2, lsl #3]
- lsr x9, x3, #48
+ ldrb w9, [x0, #12]
+ cbz w9, .Lasm_PutByValue.ssa_block_3
+ ldr x0, [x2, #32]
+ cbz x0, .Lasm_PutByValue.assert_failure_3
+ ldr x1, [x0, x3, lsl #3]
+ lsr x9, x1, #48
mov w10, #65532
cmp x9, x10
b.eq .Lasm_PutByValue.ssa_block_3
- ldrb w9, [x0, #12]
- cbz w9, .Lasm_PutByValue.ssa_block_3
- ldr w0, [x21, #12]
- ldr x0, [x27, x0, lsl #3]
- str x0, [x1, x2, lsl #3]
+ ldr w1, [x21, #12]
+ ldr x1, [x27, x1, lsl #3]
+ str x1, [x0, x3, lsl #3]
ldrb w9, [x21, #32]
add x21, x21, #32
ldr x10, [x19, x9, lsl #3]
@@ -5273,18 +5273,18 @@ asm_handler_PutById:
ldr w9, [x1, #52]
cmp w9, w4
b.ne .Lasm_PutById.ssa_block_2
- ldr x1, [x2, #32]
- cbz x1, .Lasm_PutById.assert_failure_2
- ldr x2, [x1, x3, lsl #3]
- lsr x9, x2, #48
+ ldrb w9, [x0, #12]
+ cbz w9, .Lasm_PutById.ssa_block_2
+ ldr x0, [x2, #32]
+ cbz x0, .Lasm_PutById.assert_failure_2
+ ldr x1, [x0, x3, lsl #3]
+ lsr x9, x1, #48
mov w10, #65532
cmp x9, x10
b.eq .Lasm_PutById.ssa_block_2
- ldrb w9, [x0, #12]
- cbz w9, .Lasm_PutById.ssa_block_2
- ldr w0, [x21, #12]
- ldr x0, [x27, x0, lsl #3]
- str x0, [x1, x3, lsl #3]
+ ldr w1, [x21, #12]
+ ldr x1, [x27, x1, lsl #3]
+ str x1, [x0, x3, lsl #3]
ldrb w9, [x21, #32]
add x21, x21, #32
ldr x10, [x19, x9, lsl #3]
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
index 893bdf72e4c..dcd9a43ce2b 100644
--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
@@ -5168,19 +5168,19 @@ asm_handler_PutByValue:
mov edi, DWORD PTR [rax + 8]
cmp DWORD PTR [rcx + 52], edi
jne .Lasm_PutByValue.ssa_block_3
- mov rcx, QWORD PTR [rsi + 32]
- test rcx, rcx
+ cmp BYTE PTR [rax + 12], 0
+ jz .Lasm_PutByValue.ssa_block_3
+ mov rax, QWORD PTR [rsi + 32]
+ test rax, rax
jz .Lasm_PutByValue.assert_failure_3
- mov rsi, QWORD PTR [rcx + rdx * 8]
- mov r11, rsi
+ mov rcx, QWORD PTR [rax + rdx * 8]
+ mov r11, rcx
shr r11, 48
cmp r11w, 65532
je .Lasm_PutByValue.ssa_block_3
- cmp BYTE PTR [rax + 12], 0
- jz .Lasm_PutByValue.ssa_block_3
- mov eax, DWORD PTR [r14 + r13 + 12]
- mov rax, QWORD PTR [rbx + rax * 8]
- mov QWORD PTR [rcx + rdx * 8], rax
+ mov ecx, DWORD PTR [r14 + r13 + 12]
+ mov rcx, QWORD PTR [rbx + rcx * 8]
+ mov QWORD PTR [rax + rdx * 8], rcx
add r13d, 32
movzx eax, BYTE PTR [r14 + r13]
jmp [r12 + rax * 8]
@@ -5324,19 +5324,19 @@ asm_handler_PutById:
mov edi, DWORD PTR [rax + 8]
cmp DWORD PTR [rcx + 52], edi
jne .Lasm_PutById.ssa_block_2
- mov rcx, QWORD PTR [rdx + 32]
- test rcx, rcx
+ cmp BYTE PTR [rax + 12], 0
+ jz .Lasm_PutById.ssa_block_2
+ mov rax, QWORD PTR [rdx + 32]
+ test rax, rax
jz .Lasm_PutById.assert_failure_2
- mov rdx, QWORD PTR [rcx + rsi * 8]
- mov r11, rdx
+ mov rcx, QWORD PTR [rax + rsi * 8]
+ mov r11, rcx
shr r11, 48
cmp r11w, 65532
je .Lasm_PutById.ssa_block_2
- cmp BYTE PTR [rax + 12], 0
- jz .Lasm_PutById.ssa_block_2
- mov eax, DWORD PTR [r14 + r13 + 12]
- mov rax, QWORD PTR [rbx + rax * 8]
- mov QWORD PTR [rcx + rsi * 8], rax
+ mov ecx, DWORD PTR [r14 + r13 + 12]
+ mov rcx, QWORD PTR [rbx + rcx * 8]
+ mov QWORD PTR [rax + rsi * 8], rcx
add r13d, 32
movzx eax, BYTE PTR [r14 + r13]
jmp [r12 + rax * 8]
diff --git a/Libraries/LibJS/Flap/tests/interpreter-layout.conf b/Libraries/LibJS/Flap/tests/interpreter-layout.conf
index b9a5bc245f6..e1701c1b195 100644
--- a/Libraries/LibJS/Flap/tests/interpreter-layout.conf
+++ b/Libraries/LibJS/Flap/tests/interpreter-layout.conf
@@ -57,7 +57,7 @@ const PROPERTY_LOOKUP_CACHE_ENTRY_DICTIONARY_GENERATION = 8
field PropertyLookupCache.shape_dictionary_generation u32 PROPERTY_LOOKUP_CACHE_ENTRY_DICTIONARY_GENERATION nullable scalar cache_details
const PROPERTY_LOOKUP_CACHE_ENTRY_WRITES_DATA_PROPERTY = 12
field PropertyLookupCache.writes_data_property bool PROPERTY_LOOKUP_CACHE_ENTRY_WRITES_DATA_PROPERTY nullable scalar
-const PROPERTY_LOOKUP_CACHE_ENTRY_FROM_SHAPE = 16
+const PROPERTY_LOOKUP_CACHE_ENTRY_NEW_SHAPE = 16
const PROPERTY_LOOKUP_CACHE_ENTRY_SHAPE = 24
field PropertyLookupCache.shape Shape PROPERTY_LOOKUP_CACHE_ENTRY_SHAPE nullable cell cache_target
const PROPERTY_LOOKUP_CACHE_ENTRY_PROTOTYPE = 32
diff --git a/Libraries/LibJS/Interpreter/interpreter.flap b/Libraries/LibJS/Interpreter/interpreter.flap
index 9e00aa31cab..16e5b4509ce 100644
--- a/Libraries/LibJS/Interpreter/interpreter.flap
+++ b/Libraries/LibJS/Interpreter/interpreter.flap
@@ -2916,8 +2916,9 @@ handler PutByValue(
guard property_cache.shape == shape else try_cache;
guard property_cache.prototype == 0 else try_cache;
guard property_cache.shape_dictionary_generation == shape.dictionary_generation else try_cache;
- guard object.named_properties[property_cache.property_offset] is not Value<Accessor> else try_cache;
+ # NB: Addition entries have no slot at their offset.
guard property_cache.writes_data_property != 0 else try_cache;
+ guard object.named_properties[property_cache.property_offset] is not Value<Accessor> else try_cache;
object.named_properties[property_cache.property_offset] = load(src);
dispatch_next;
};
@@ -3358,8 +3359,9 @@ handler PutById(
guard property_cache.shape == shape else try_cache;
guard property_cache.prototype == 0 else try_cache;
guard property_cache.shape_dictionary_generation == shape.dictionary_generation else try_cache;
- guard object.named_properties[property_cache.property_offset] is not Value<Accessor> else try_cache;
+ # NB: Addition entries have no slot at their offset.
guard property_cache.writes_data_property != 0 else try_cache;
+ guard object.named_properties[property_cache.property_offset] is not Value<Accessor> else try_cache;
object.named_properties[property_cache.property_offset] = load(src);
dispatch_next;
}
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/caches.rs b/Libraries/LibJS/JIT/Rust/src/builder/caches.rs
index cdc0bdfa707..379d8ec3bf1 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/caches.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/caches.rs
@@ -144,13 +144,11 @@ impl CacheEntry {
offset: entry.property_offset,
},
),
- // NB: Additions are only speculated for shapes that are no
- // dictionaries.
- PropertyCacheEntryType::AddOwnProperty if !entry.shape_is_dictionary => (
- entry.from_shape?,
+ PropertyCacheEntryType::AddOwnProperty => (
+ entry.shape?,
Action::Add {
offset: entry.property_offset,
- shape: entry.shape?,
+ shape: entry.new_shape?,
prototype_chain: entry
.prototype_chain_validity
.map(|validity| (validity, entry.prototype_chain_valid)),
@@ -163,7 +161,7 @@ impl CacheEntry {
shape,
dictionary_generation: entry.shape_is_dictionary.then_some(entry.shape_dictionary_generation),
},
- // NB: For additions, the stable shape would be the new one.
+ // NB: Additions take objects off the shape.
stable: entry.shape_is_stable && !matches!(action, Action::Add { .. }),
key: entry.key.map(|cell| (entry.key_value, cell)),
action,
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
index 32e21d55cb7..f8fdd8ca846 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
@@ -829,7 +829,7 @@ pub(crate) mod property_access {
shape_is_dictionary: false,
shape_is_stable: false,
writes_data_property: entry_type == PropertyCacheEntryType::ChangeOwnProperty,
- from_shape: None,
+ new_shape: None,
shape: Some(CellId(shape)),
prototype: None,
prototype_chain_validity: None,
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/probes/keyed.rs b/Libraries/LibJS/JIT/Rust/src/codegen/probes/keyed.rs
index 16a38441b23..9be4a5f8de6 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/probes/keyed.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/probes/keyed.rs
@@ -10,7 +10,6 @@
//! `hasOwnProperty` and `in` (`ProbeHasProperty`).
use super::super::Codegen;
-use super::megamorphic::EntryShape;
use super::megamorphic::MegamorphicKey;
use super::property::AdditionEntryFields;
use super::property::CacheProbe;
@@ -131,11 +130,8 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
self.masm.bind(addition);
self.masm.move64(entry, object);
self.emit_unbox_cell(object, base);
- // NB: Finding the entry matched the shape and its dictionary generation.
let fields = AdditionEntryFields {
entry_type: layout.keyed_lookup_cache_entry_type as i32,
- from_shape: None,
- dictionary_generation: None,
prototype_chain_validity: layout.keyed_lookup_cache_prototype_chain_validity as i32,
new_shape: layout.keyed_lookup_cache_new_shape as i32,
property_offset: layout.keyed_lookup_cache_property_offset as i32,
@@ -257,9 +253,9 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
}
/// Loads the entry of property lookup cache `cache_index` of a keyed
- /// access for `key` and the shape of `object` (matching `entry_shape`
- /// of the entries) into `entry`: the most recently used entry, or
- /// another entry of a polymorphic or megamorphic cache. Branches to
+ /// access for `key` and the shape of `object` into `entry`: the most
+ /// recently used entry, or another entry of a polymorphic or megamorphic
+ /// cache. Branches to
/// `miss` unless there is one, for an own property. Uses `shape` and the
/// scratch register.
#[allow(clippy::too_many_arguments)]
@@ -271,7 +267,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
entry: Gpr,
executable: u32,
cache_index: u32,
- entry_shape: EntryShape,
miss: Label,
) -> Result<(), CompileFailure> {
let scratch = self.pinned.scratch;
@@ -301,7 +296,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
.and64_imm(entry, entry, layout.property_lookup_cache_data_pointer_mask);
self.masm
.load64(shape, &Address::new(object, self.runtime.offsets.object_shape as i32));
- self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Keyed { key }, entry_shape, found, miss);
+ self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Keyed { key }, found, miss);
self.masm.bind(not_megamorphic);
}
self.masm.branch_test64(Condition::Zero, entry, u64::MAX, miss);
@@ -321,7 +316,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
.add64_imm(entry, entry, i64::from(layout.property_lookup_cache_entry_size));
}
self.masm.branch64_memory(Condition::NotEqual, &entry_key, key, next);
- self.branch_if_entry_shape(entry, shape, entry_shape, found);
+ self.branch_if_entry_shape(entry, shape, found);
self.masm.bind(next);
// The other entries of a polymorphic cache follow the most
// recently used one.
@@ -345,7 +340,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
layout.property_lookup_cache_megamorphic_tag as i64,
miss,
);
- self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Keyed { key }, entry_shape, found, miss);
+ self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Keyed { key }, found, miss);
self.masm.bind(found);
let expected = Address::new(entry, layout.property_lookup_cache_entry_dictionary_generation as i32);
self.branch_unless_dictionary_generation_is(shape, expected, [shape, scratch], miss);
@@ -422,16 +417,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
let fail = failure.0;
self.unbox_object_or_branch(object, base, fail);
let lookup_cache = self.masm.new_label();
- self.probe_keyed_cache_entry(
- object,
- key,
- shape,
- entry,
- executable,
- cache,
- EntryShape::Shape,
- lookup_cache,
- )?;
+ self.probe_keyed_cache_entry(object, key, shape, entry, executable, cache, lookup_cache)?;
let missing = self.masm.new_label();
self.masm.branch32_memory_imm(
Condition::Equal,
@@ -484,16 +470,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
let fail = failure.0;
self.unbox_object_or_branch(object, base, fail);
let store_cache = self.masm.new_label();
- self.probe_keyed_cache_entry(
- object,
- key,
- shape,
- entry,
- executable,
- cache,
- EntryShape::ShapeOrFromShape,
- store_cache,
- )?;
+ self.probe_keyed_cache_entry(object, key, shape, entry, executable, cache, store_cache)?;
let add = self.masm.new_label();
self.masm.branch32_memory_imm(
Condition::Equal,
@@ -514,8 +491,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
self.masm.jump(stored);
self.masm.bind(add);
- self.masm
- .load64(shape, &Address::new(object, self.runtime.offsets.object_shape as i32));
let registers = CacheRegisters { object, shape, entry };
let fields = self.site_addition_entry_fields();
self.emit_add_own_property(node, &registers, fields, source, storage, fail);
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/probes/megamorphic.rs b/Libraries/LibJS/JIT/Rust/src/codegen/probes/megamorphic.rs
index 4714a136c2e..aa9660d92cf 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/probes/megamorphic.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/probes/megamorphic.rs
@@ -28,65 +28,24 @@ pub(super) enum MegamorphicKey {
Keyed { key: Gpr },
}
-/// Which shape of a cache entry an object's shape must be for the entry to
-/// apply to it.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub(super) enum EntryShape {
- /// The entry's shape, for reads and changes of properties.
- Shape,
- /// The entry's shape or the shape it adds a property to (the
- /// `from_shape` of `AddOwnProperty` entries, which other entries do not
- /// have), for stores, like `PropertyLookupCache::entry_lookup_shape()`.
- ShapeOrFromShape,
-}
-
impl<M: PortableMacroAssembler> Codegen<'_, M> {
/// Branches to `found` if cache entry `candidate` applies to objects of
/// the shape in `shape`.
- pub(super) fn branch_if_entry_shape(&mut self, candidate: Gpr, shape: Gpr, entry_shape: EntryShape, found: Label) {
- let layout = self.runtime.layout;
- let candidate_shape = Address::new(candidate, layout.property_lookup_cache_entry_shape as i32);
+ pub(super) fn branch_if_entry_shape(&mut self, candidate: Gpr, shape: Gpr, found: Label) {
+ let candidate_shape = Address::new(candidate, self.runtime.layout.property_lookup_cache_entry_shape as i32);
self.masm
.branch64_memory(Condition::Equal, &candidate_shape, shape, found);
- if entry_shape == EntryShape::ShapeOrFromShape {
- let from_shape = Address::new(candidate, layout.property_lookup_cache_entry_from_shape as i32);
- self.masm.branch64_memory(Condition::Equal, &from_shape, shape, found);
- }
- }
-
- /// Branches to `miss` unless the cache entry at `candidate` applies to
- /// objects of the shape in `shape`.
- fn branch_unless_entry_shape(&mut self, candidate: Address, shape: Gpr, entry_shape: EntryShape, miss: Label) {
- let layout = self.runtime.layout;
- let field = |offset: u32| Address {
- displacement: candidate.displacement + offset as i32,
- ..candidate
- };
- let candidate_shape = field(layout.property_lookup_cache_entry_shape);
- if entry_shape == EntryShape::Shape {
- self.masm
- .branch64_memory(Condition::NotEqual, &candidate_shape, shape, miss);
- return;
- }
- let matched = self.masm.new_label();
- self.masm
- .branch64_memory(Condition::Equal, &candidate_shape, shape, matched);
- let from_shape = field(layout.property_lookup_cache_entry_from_shape);
- self.masm.branch64_memory(Condition::NotEqual, &from_shape, shape, miss);
- self.masm.bind(matched);
}
/// Looks up the entry for the shape in `shape` (and the key, if keyed)
- /// in the megamorphic cache data that `entry` points to, matching
- /// `entry_shape` of its entries, and branches to `found` with the entry
- /// in `entry`, or to `miss`. Clobbers the scratch register.
- #[allow(clippy::too_many_arguments)]
+ /// in the megamorphic cache data that `entry` points to, and branches to
+ /// `found` with the entry in `entry`, or to `miss`. Clobbers the scratch
+ /// register.
pub(super) fn emit_megamorphic_cache_lookup(
&mut self,
shape: Gpr,
entry: Gpr,
key: MegamorphicKey,
- entry_shape: EntryShape,
found: Label,
miss: Label,
) {
@@ -126,7 +85,12 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
self.masm
.branch64_memory(Condition::NotEqual, &candidate_key, key, next);
}
- self.branch_unless_entry_shape(candidate, shape, entry_shape, next);
+ let candidate_shape = Address {
+ displacement: candidate.displacement + layout.property_lookup_cache_entry_shape as i32,
+ ..candidate
+ };
+ self.masm
+ .branch64_memory(Condition::NotEqual, &candidate_shape, shape, next);
self.masm.load_effective_address(entry, &candidate);
self.masm.jump(found);
self.masm.bind(next);
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs b/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
index 8016f8fd6b4..422eecc30a7 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/probes/property.rs
@@ -12,7 +12,6 @@
use super::super::Codegen;
use super::super::checked_i32;
use super::super::slow_path_calls::slow_path_saved_registers;
-use super::megamorphic::EntryShape;
use super::megamorphic::MegamorphicKey;
use crate::CompileFailure;
use crate::asm::Address;
@@ -64,14 +63,10 @@ pub(in crate::codegen) struct CacheRegisters {
}
/// The offsets in a cache entry of the parts of an addition (see
-/// `Codegen::emit_add_own_property()`). Entries that the shape they add to
-/// and its dictionary generation were already matched for have no
-/// `from_shape` or `dictionary_generation` to check.
+/// `Codegen::emit_add_own_property()`).
#[derive(Clone, Copy)]
pub(super) struct AdditionEntryFields {
pub entry_type: i32,
- pub from_shape: Option<i32>,
- pub dictionary_generation: Option<i32>,
pub prototype_chain_validity: i32,
pub new_shape: i32,
pub property_offset: i32,
@@ -116,9 +111,9 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
/// Loads the shape of the object in `registers.object` and the entry of
/// property lookup cache `cache_index` for that shape into the entry
/// register: the most recently used entry, or another entry of a
- /// polymorphic or megamorphic cache, matching `entry_shape` of the
- /// entries. Branches to `miss` unless there is one for the shape and its
- /// dictionary generation. Leaves the shape register free. Caches that
+ /// polymorphic or megamorphic cache. Branches to `miss` unless there is
+ /// one for the shape and its dictionary generation. Leaves the shape
+ /// register free. Caches that
/// were megamorphic when the snapshot was taken look in their hash
/// tables first.
fn probe_cache_entry(
@@ -126,7 +121,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
registers: &CacheRegisters,
executable: u32,
cache_index: u32,
- entry_shape: EntryShape,
miss: Label,
) -> Result<(), CompileFailure> {
let layout = self.runtime.layout;
@@ -155,14 +149,14 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
);
self.masm
.and64_imm(entry, entry, layout.property_lookup_cache_data_pointer_mask);
- self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Named, entry_shape, found, miss);
+ self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Named, found, miss);
self.masm.bind(not_megamorphic);
}
self.masm.branch_test64(Condition::Zero, entry, u64::MAX, miss);
self.masm.move64(scratch, entry);
self.masm
.and64_imm(entry, entry, layout.property_lookup_cache_data_pointer_mask);
- self.branch_if_entry_shape(entry, shape, entry_shape, found);
+ self.branch_if_entry_shape(entry, shape, found);
// The other entries of a polymorphic cache follow the most recently used one.
self.masm
.and64_imm(scratch, scratch, !layout.property_lookup_cache_data_pointer_mask);
@@ -176,7 +170,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
for _ in 1..layout.property_lookup_cache_polymorphic_entry_count {
self.masm
.add64_imm(entry, entry, i64::from(layout.property_lookup_cache_entry_size));
- self.branch_if_entry_shape(entry, shape, entry_shape, found);
+ self.branch_if_entry_shape(entry, shape, found);
}
self.masm.jump(miss);
// Megamorphic caches keep the other shapes' entries in hash tables.
@@ -187,7 +181,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
layout.property_lookup_cache_megamorphic_tag as i64,
miss,
);
- self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Named, entry_shape, found, miss);
+ self.emit_megamorphic_cache_lookup(shape, entry, MegamorphicKey::Named, found, miss);
self.masm.bind(found);
self.branch_unless_dictionary_generation_matches(shape, entry, miss);
Ok(())
@@ -362,7 +356,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
self.masm.bind(is_object);
self.emit_unbox_cell(object, base);
self.masm.bind(have_object);
- self.probe_cache_entry(&registers, executable, cache_index, EntryShape::Shape, probe)?;
+ self.probe_cache_entry(&registers, executable, cache_index, probe)?;
let present = self.masm.new_label();
self.masm.branch32_memory_imm(
Condition::NotEqual,
@@ -427,6 +421,7 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
let CacheRegisters { object, shape, entry } = registers;
let (failure, stored, done) = (self.probe_failure_label(), self.masm.new_label(), self.masm.new_label());
let (others, change, transition) = (self.masm.new_label(), self.masm.new_label(), self.masm.new_label());
+ let no_data_write = self.masm.new_label();
let probe = if executable == 0 {
let probe = self.masm.new_label();
self.deferred_cache_probes.push(DeferredCacheProbe {
@@ -450,21 +445,12 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
self.masm.branch_test64(Condition::Zero, entry, u64::MAX, probe);
self.masm
.and64_imm(entry, entry, layout.property_lookup_cache_data_pointer_mask);
- let most_recent_matches = self.masm.new_label();
self.masm.branch64_memory(
- Condition::Equal,
+ Condition::NotEqual,
&Address::new(entry, layout.property_lookup_cache_entry_shape as i32),
shape,
- most_recent_matches,
+ others,
);
- self.masm.branch64_memory(
- Condition::Equal,
- &Address::new(entry, layout.property_lookup_cache_entry_from_shape as i32),
- shape,
- transition,
- );
- self.masm.jump(others);
- self.masm.bind(most_recent_matches);
self.branch_unless_dictionary_generation_matches(shape, entry, probe);
// Own data properties.
self.masm.bind(change);
@@ -478,19 +464,25 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
scratch,
&Address::new(entry, layout.property_lookup_cache_entry_writes_data_property as i32),
);
- self.masm.branch_test32(Condition::Zero, scratch, 0xFF, probe);
+ self.masm.branch_test32(Condition::Zero, scratch, 0xFF, no_data_write);
// NB: The address uses the scratch register, so the tag check must not.
let property = self.cached_property_address(&registers, object);
self.masm.load64(entry, &property);
self.branch_on_tag(Condition::Equal, entry, value::ACCESSOR_TAG, entry, probe);
self.masm.store64(&property, source);
self.masm.jump(stored);
+ self.masm.bind(no_data_write);
+ self.masm.branch32_memory_imm(
+ Condition::Equal,
+ &Address::new(entry, layout.property_lookup_cache_entry_type as i32),
+ layout.property_lookup_cache_entry_type_add_own_property as i32,
+ transition,
+ );
+ self.masm.jump(probe);
- // The entry for the object's shape, or the addition to it.
+ // The entry for the object's shape among the others.
self.masm.bind(others);
- self.probe_cache_entry(&registers, executable, cache_index, EntryShape::ShapeOrFromShape, probe)?;
- self.masm
- .load64(shape, &Address::new(object, self.runtime.offsets.object_shape as i32));
+ self.probe_cache_entry(&registers, executable, cache_index, probe)?;
self.masm.branch32_memory_imm(
Condition::NotEqual,
&Address::new(entry, layout.property_lookup_cache_entry_type as i32),
@@ -508,10 +500,10 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
}
/// Adds the property of the `AddOwnProperty` entry in `registers.entry`,
- /// laid out like `fields` says, to the object in `registers.object`,
- /// whose shape is in `registers.shape`, like `asm_try_put_by_id_cache()`
- /// does: the object takes the entry's new shape, and `source` goes in the
- /// new property's slot. Storage that must grow grows out of line (see
+ /// laid out like `fields` says and found for the shape of the object in
+ /// `registers.object`, like `asm_try_put_by_id_cache()` does: the object
+ /// takes the entry's new shape, and `source` goes in the new property's
+ /// slot. Storage that must grow grows out of line (see
/// `named_storage`), or the addition is left to `miss`. Uses `storage`
/// and clobbers the shape register.
pub(super) fn emit_add_own_property(
@@ -534,10 +526,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
layout.property_lookup_cache_entry_type_add_own_property as i32,
miss,
);
- if let Some(from_shape) = fields.from_shape {
- self.masm
- .branch64_memory(Condition::NotEqual, &Address::new(entry, from_shape), shape, 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
@@ -553,12 +541,6 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
i32::from(layout.object_flag_is_extensible),
miss,
);
- // NB: Only additions that make dictionary shapes need the dictionary
- // generations to match, but requiring it of all of them is safe.
- if let Some(dictionary_generation) = fields.dictionary_generation {
- let expected = Address::new(entry, dictionary_generation);
- self.branch_unless_dictionary_generation_is(shape, expected, [shape, scratch], miss);
- }
let valid_chain = self.masm.new_label();
self.masm
.load64(shape, &Address::new(entry, fields.prototype_chain_validity));
@@ -610,10 +592,8 @@ impl<M: PortableMacroAssembler> Codegen<'_, M> {
let layout = self.runtime.layout;
AdditionEntryFields {
entry_type: layout.property_lookup_cache_entry_type as i32,
- from_shape: Some(layout.property_lookup_cache_entry_from_shape as i32),
- dictionary_generation: Some(layout.property_lookup_cache_entry_dictionary_generation as i32),
prototype_chain_validity: layout.property_lookup_cache_entry_prototype_chain_validity as i32,
- new_shape: layout.property_lookup_cache_entry_shape as i32,
+ new_shape: layout.property_lookup_cache_entry_new_shape as i32,
property_offset: layout.property_lookup_cache_entry_property_offset as i32,
}
}
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
index fc8d5219841..97333f75936 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests/lowerings.rs
@@ -1326,7 +1326,7 @@ fn fake_object_layout() -> RuntimeLayout {
property_lookup_cache_entry_size: 64,
property_lookup_cache_entry_key: 48,
property_lookup_cache_keyed_generic: 3,
- property_lookup_cache_entry_from_shape: 16,
+ property_lookup_cache_entry_new_shape: 16,
property_lookup_cache_megamorphic_tag: 2,
property_lookup_cache_megamorphic_primary_entries: 64,
property_lookup_cache_megamorphic_secondary_entries: 64 + 64 * 64,
@@ -2868,8 +2868,7 @@ impl FakeCachedObject {
/// `new_shape`, for property `offset`.
fn set_add_entry(&mut self, new_shape: &[u64], offset: u32) {
self.set_entry(1, offset, false);
- self.entry[2] = self.shape.as_ptr() as u64;
- self.entry[3] = new_shape.as_ptr() as u64;
+ self.entry[2] = new_shape.as_ptr() as u64;
}
fn run(&self, instruction: Instruction, arguments: &[u64]) -> (JitResult, u64) {
@@ -3217,7 +3216,7 @@ fn put_by_id_adds_properties_through_property_caches() {
}
// So are other shapes, generations, invalid prototype chains, missing
// new shapes, and objects whose storage would have to grow.
- fake.entry[2] = 8;
+ fake.entry[3] = 8;
assert_eq!(add(&mut fake, FLAG_IS_EXTENSIBLE), 1);
fake.set_add_entry(&new_shape, 2);
fake.entry[1] = 6;
@@ -3230,7 +3229,7 @@ fn put_by_id_adds_properties_through_property_caches() {
std::hint::black_box(&validity);
assert_eq!(add(&mut fake, FLAG_IS_EXTENSIBLE), 0);
fake.entry[5] = 0;
- fake.entry[3] = 0;
+ fake.entry[2] = 0;
assert_eq!(add(&mut fake, FLAG_IS_EXTENSIBLE), 1);
fake.set_add_entry(&new_shape, 2);
fake.properties[0] = 2;
@@ -4264,11 +4263,11 @@ fn keyed_accesses_of_missing_and_added_properties_through_property_caches() {
// A megamorphic cache whose most recently used entry is the one tested.
let mut data = vec![0u64; ENTRY_WORDS * (1 + 2 * 64)];
fake.caches[1] = data.as_ptr() as u64 | 2;
- let set_entry = |data: &mut Vec<u64>, entry_type: u64, offset: u64, from_shape: u64, shape: u64| {
+ let set_entry = |data: &mut Vec<u64>, entry_type: u64, offset: u64, new_shape: u64, shape: u64| {
data[..ENTRY_WORDS].fill(0);
data[0] = entry_type | offset << 32;
data[1] = 5 | 1 << 40;
- data[2] = from_shape;
+ data[2] = new_shape;
data[3] = shape;
data[6] = key;
};
@@ -4322,7 +4321,7 @@ fn keyed_accesses_of_missing_and_added_properties_through_property_caches() {
let mut new_shape = vec![0u64; 12];
new_shape[10] = 3 | 5 << 32;
let new_shape_address = new_shape.as_ptr() as u64;
- set_entry(&mut data, 1, 2, shape, new_shape_address);
+ set_entry(&mut data, 1, 2, new_shape_address, shape);
assert_eq!(put(&fake, other_key, value::TRUE), 1);
assert_eq!(put(&fake, key, value::TRUE), 0);
assert_eq!(fake.object[6], new_shape_address);
diff --git a/Libraries/LibJS/JIT/Rust/src/snapshot.rs b/Libraries/LibJS/JIT/Rust/src/snapshot.rs
index aacd539e226..87f419f64c6 100644
--- a/Libraries/LibJS/JIT/Rust/src/snapshot.rs
+++ b/Libraries/LibJS/JIT/Rust/src/snapshot.rs
@@ -660,7 +660,7 @@ pub struct PropertyCacheEntrySnapshot {
/// Whether `shape` was stable (see `Dependency::StableShape`).
pub shape_is_stable: bool,
pub writes_data_property: bool,
- pub from_shape: Option<CellId>,
+ pub new_shape: Option<CellId>,
pub shape: Option<CellId>,
pub prototype: Option<CellId>,
pub prototype_chain_validity: Option<CellId>,
@@ -1951,9 +1951,9 @@ pub struct RuntimeLayout {
pub property_lookup_cache_entry_key: u32,
/// `PropertyLookupCache::data` of a keyed access that saw too many keys to cache.
pub property_lookup_cache_keyed_generic: u64,
- /// `PropertyLookupCache::Entry::from_shape` (cell pointer): the shape an
- /// `AddOwnProperty` entry transitions from.
- pub property_lookup_cache_entry_from_shape: u32,
+ /// `PropertyLookupCache::Entry::new_shape` (cell pointer): the shape an
+ /// `AddOwnProperty` entry transitions to.
+ pub property_lookup_cache_entry_new_shape: u32,
/// The tag of `PropertyLookupCache::data` for `MegamorphicData`.
pub property_lookup_cache_megamorphic_tag: u64,
/// `PropertyLookupCache::MegamorphicData::primary_entries` (entries).
diff --git a/Libraries/LibJS/Rust/generate/layout_table.rs b/Libraries/LibJS/Rust/generate/layout_table.rs
index f7682c4ed75..038a6237016 100644
--- a/Libraries/LibJS/Rust/generate/layout_table.rs
+++ b/Libraries/LibJS/Rust/generate/layout_table.rs
@@ -217,7 +217,7 @@ pub fn generate(configuration: &LayoutConfiguration) -> LayoutWriter {
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_PROPERTY_OFFSET", "PropertyLookupCache.property_offset", "u32", PropertyLookupCacheEntry, property_offset, 4, "nullable", "scalar", "cache_details");
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_DICTIONARY_GENERATION", "PropertyLookupCache.shape_dictionary_generation", "u32", PropertyLookupCacheEntry, shape_dictionary_generation, 4, "nullable", "scalar", "cache_details");
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_WRITES_DATA_PROPERTY", "PropertyLookupCache.writes_data_property", "bool", PropertyLookupCacheEntry, writes_data_property, 1, "nullable", "scalar");
- offset!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_FROM_SHAPE", PropertyLookupCacheEntry, from_shape);
+ offset!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_NEW_SHAPE", PropertyLookupCacheEntry, new_shape);
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_SHAPE", "PropertyLookupCache.shape", "Shape", PropertyLookupCacheEntry, shape, 8, "nullable", "cell", "cache_target");
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_PROTOTYPE", "PropertyLookupCache.prototype", "Object", PropertyLookupCacheEntry, prototype, 8, "nullable", "cell", "cache_target");
field!(w, "PROPERTY_LOOKUP_CACHE_ENTRY_PROTOTYPE_CHAIN_VALIDITY", "PropertyLookupCache.prototype_chain_validity", "WatchpointSet", PropertyLookupCacheEntry, prototype_chain_validity, 8, "nullable", "cell");
diff --git a/Libraries/LibJS/Rust/src/bytecode/executable.rs b/Libraries/LibJS/Rust/src/bytecode/executable.rs
index 9b93fc6f7e0..6ec7a917372 100644
--- a/Libraries/LibJS/Rust/src/bytecode/executable.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/executable.rs
@@ -68,7 +68,7 @@ pub struct PropertyLookupCacheEntryData {
pub property_offset: u32,
pub shape_dictionary_generation: u32,
pub writes_data_property: bool,
- pub from_shape: Option<Gc<Shape>>,
+ pub new_shape: Option<Gc<Shape>>,
pub shape: Option<Gc<Shape>>,
pub prototype: Option<Gc<Object>>,
pub prototype_chain_validity: Option<Gc<WatchpointSet>>,
@@ -84,7 +84,7 @@ impl Default for PropertyLookupCacheEntryData {
property_offset: 0,
shape_dictionary_generation: 0,
writes_data_property: false,
- from_shape: None,
+ new_shape: None,
shape: None,
prototype: None,
prototype_chain_validity: None,
@@ -95,15 +95,6 @@ impl Default for PropertyLookupCacheEntryData {
}
impl PropertyLookupCacheEntryData {
- /// The shape an entry is looked up by: the shape before the addition for AddOwnProperty, the receiver's shape
- /// otherwise.
- pub fn lookup_shape(&self) -> Option<Gc<Shape>> {
- if self.entry_type == PropertyLookupCacheEntryType::AddOwnProperty {
- return self.from_shape;
- }
- self.shape
- }
-
fn has_same_cache_key_as(&self, other: &Self) -> bool {
if self.entry_type == PropertyLookupCacheEntryType::Empty
|| other.entry_type == PropertyLookupCacheEntryType::Empty
@@ -116,7 +107,7 @@ impl PropertyLookupCacheEntryData {
match self.entry_type {
PropertyLookupCacheEntryType::AddOwnProperty => {
- self.from_shape == other.from_shape && self.shape == other.shape
+ self.shape == other.shape && self.new_shape == other.new_shape
}
PropertyLookupCacheEntryType::ChangeOwnProperty
| PropertyLookupCacheEntryType::GetOwnProperty
@@ -132,7 +123,7 @@ impl PropertyLookupCacheEntryData {
fn has_dead_cell(&self, sweep: &Sweep<'_>) -> bool {
(self.key != 0 && sweep.is_dead(Value::from_bits(self.key).as_cell()))
- || self.from_shape.is_some_and(|shape| sweep.is_dead(shape))
+ || self.new_shape.is_some_and(|shape| sweep.is_dead(shape))
|| self.shape.is_some_and(|shape| sweep.is_dead(shape))
|| self.prototype.is_some_and(|prototype| sweep.is_dead(prototype))
|| self
@@ -156,7 +147,7 @@ impl PropertyLookupCacheEntry {
property_offset: Cell::new(data.property_offset),
shape_dictionary_generation: Cell::new(data.shape_dictionary_generation),
writes_data_property: Cell::new(data.writes_data_property),
- from_shape: Cell::new(data.from_shape),
+ new_shape: Cell::new(data.new_shape),
shape: Cell::new(data.shape),
prototype: Cell::new(data.prototype),
prototype_chain_validity: Cell::new(data.prototype_chain_validity),
@@ -171,7 +162,7 @@ impl PropertyLookupCacheEntry {
property_offset: self.property_offset.get(),
shape_dictionary_generation: self.shape_dictionary_generation.get(),
writes_data_property: self.writes_data_property.get(),
- from_shape: self.from_shape.get(),
+ new_shape: self.new_shape.get(),
shape: self.shape.get(),
prototype: self.prototype.get(),
prototype_chain_validity: self.prototype_chain_validity.get(),
@@ -185,7 +176,7 @@ impl PropertyLookupCacheEntry {
self.property_offset.set(data.property_offset);
self.shape_dictionary_generation.set(data.shape_dictionary_generation);
self.writes_data_property.set(data.writes_data_property);
- self.from_shape.set(data.from_shape);
+ self.new_shape.set(data.new_shape);
self.shape.set(data.shape);
self.prototype.set(data.prototype);
self.prototype_chain_validity.set(data.prototype_chain_validity);
@@ -288,7 +279,7 @@ fn megamorphic_secondary_index(shape: Gc<Shape>, key: u64) -> usize {
fn megamorphic_slot_for_shape(data: &MegamorphicData, shape: Gc<Shape>, key: u64) -> Option<&PropertyLookupCacheEntry> {
let is_for_shape = |slot: &&PropertyLookupCacheEntry| {
let entry = slot.get();
- entry.lookup_shape() == Some(shape) && entry.key == key
+ entry.shape == Some(shape) && entry.key == key
};
Some(&data.primary_entries[megamorphic_primary_index(shape, key)])
.filter(is_for_shape)
@@ -296,11 +287,11 @@ fn megamorphic_slot_for_shape(data: &MegamorphicData, shape: Gc<Shape>, key: u64
}
fn insert_megamorphic_entry(data: &MegamorphicData, entry: &PropertyLookupCacheEntryData) {
- let lookup_shape = entry.lookup_shape().expect("a megamorphic entry has a lookup shape");
+ let lookup_shape = entry.shape.expect("a megamorphic entry has a shape");
let primary_entry = &data.primary_entries[megamorphic_primary_index(lookup_shape, entry.key)];
let primary = primary_entry.get();
- if let Some(displaced_shape) = primary.lookup_shape()
+ if let Some(displaced_shape) = primary.shape
&& (displaced_shape != lookup_shape || primary.key != entry.key)
{
data.secondary_entries[megamorphic_secondary_index(displaced_shape, primary.key)].set(primary);
@@ -471,12 +462,10 @@ impl PropertyLookupCache {
// NB: A keyed access that keeps missing cycles through more keys than the cache can hold, and filling it
// would cost more than it saves.
if new_entry.key != 0 {
- let lookup_shape = new_entry
- .lookup_shape()
- .expect("a megamorphic entry has a lookup shape");
+ let lookup_shape = new_entry.shape.expect("a megamorphic entry has a shape");
let is_known = |entry: &PropertyLookupCacheEntry| {
let entry = entry.get();
- entry.lookup_shape() == Some(lookup_shape) && entry.key == new_entry.key
+ entry.shape == Some(lookup_shape) && entry.key == new_entry.key
};
let known = is_known(&data.primary_entries[megamorphic_primary_index(lookup_shape, new_entry.key)])
|| is_known(&data.secondary_entries[megamorphic_secondary_index(lookup_shape, new_entry.key)]);
@@ -566,7 +555,7 @@ impl PropertyLookupCache {
});
for entry in entries.iter().rev() {
let entry = entry.get();
- if entry.lookup_shape().is_some() {
+ if entry.shape.is_some() {
insert_megamorphic_entry(&new_data, &entry);
}
}
diff --git a/Libraries/LibJS/Rust/src/bytecode/property_access.rs b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
index 74b43cd77fc..05c8c303e61 100644
--- a/Libraries/LibJS/Rust/src/bytecode/property_access.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/property_access.rs
@@ -604,13 +604,13 @@ pub fn put_by_property_key(
PropertyLookupCacheEntryType::AddOwnProperty => {
// OPTIMIZATION: If the object's shape is the same as the one cached before adding the new property, we can
// reuse the resulting shape from the cache.
- if cache.from_shape != Some(object.shape()) {
+ if cache.shape != Some(object.shape()) {
continue;
}
if !property_addition_is_cacheable(vm, &object, name) {
continue;
}
- let Some(cached_shape) = cache.shape else {
+ let Some(new_shape) = cache.new_shape else {
continue;
};
@@ -626,7 +626,7 @@ pub fn put_by_property_key(
{
continue;
}
- object.unsafe_set_shape(cached_shape);
+ object.unsafe_set_shape(new_shape);
object.initialize_direct(cache.property_offset, value);
return Ok(());
}
@@ -659,11 +659,11 @@ pub fn put_by_property_key(
{
caches.update(PropertyLookupCacheEntryType::AddOwnProperty, |cache| {
cache.key = cache_key;
- cache.from_shape = Some(from_shape);
+ cache.shape = Some(from_shape);
cache.property_offset = cacheable_metadata
.property_offset
.expect("cacheable metadata has an offset");
- cache.shape = Some(object.shape());
+ cache.new_shape = Some(object.shape());
if let Some(prototype) = cacheable_metadata.prototype {
cache.prototype_chain_validity = prototype.shape().prototype_chain_validity();
}
@@ -743,16 +743,16 @@ pub fn put_by_property_key(
// objects, but keep this aligned with the normal PutById
// AddOwnProperty cache hit so a future bytecode path cannot
// bypass subclass hooks for objects that require them.
- if cache.from_shape != Some(object.shape()) {
+ if cache.shape != Some(object.shape()) {
continue;
}
if !property_addition_is_cacheable(vm, &object, name) {
continue;
}
- let Some(cached_shape) = cache.shape else {
+ let Some(new_shape) = cache.new_shape else {
continue;
};
- object.unsafe_set_shape(cached_shape);
+ object.unsafe_set_shape(new_shape);
object.initialize_direct(cache.property_offset, value);
return Ok(());
}
@@ -773,8 +773,8 @@ pub fn put_by_property_key(
{
caches.update(PropertyLookupCacheEntryType::AddOwnProperty, |cache| {
cache.key = cache_key;
- cache.from_shape = Some(from_shape);
- cache.shape = Some(object.shape());
+ cache.shape = Some(from_shape);
+ cache.new_shape = Some(object.shape());
cache.property_offset = object.shape().lookup(name).expect("the property was just added").offset;
});
}
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 1dac21a4260..4aff9ade62b 100644
--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/property_access.rs
@@ -595,11 +595,11 @@ fn put_by_value_with_keyed_store_cache(
lookup.entry_type = PropertyLookupCacheEntryType::ChangeOwnProperty;
lookup.property_offset = entry.property_offset;
}
- PropertyLookupCacheEntryType::AddOwnProperty if entry.from_shape == Some(shape) && entry.shape.is_some() => {
+ PropertyLookupCacheEntryType::AddOwnProperty if entry.shape == Some(shape) && entry.new_shape.is_some() => {
lookup.entry_type = PropertyLookupCacheEntryType::AddOwnProperty;
lookup.property_offset = entry.property_offset;
lookup.prototype_chain_validity = entry.prototype_chain_validity;
- lookup.new_shape = entry.shape;
+ lookup.new_shape = entry.new_shape;
}
_ => {}
}
@@ -1554,7 +1554,7 @@ fn try_put_by_property_lookup_cache(
return true;
}
PropertyLookupCacheEntryType::AddOwnProperty => {
- if entry.from_shape.get() != Some(object.shape()) {
+ if entry.shape.get() != Some(object.shape()) {
continue;
}
if !object_can_cache_property_additions(&object) {
@@ -1566,7 +1566,7 @@ fn try_put_by_property_lookup_cache(
{
continue;
}
- let Some(cached_shape) = entry.shape.get() else {
+ let Some(new_shape) = entry.new_shape.get() else {
continue;
};
if !object.extensible() {
@@ -1579,7 +1579,7 @@ fn try_put_by_property_lookup_cache(
{
continue;
}
- object.unsafe_set_shape(cached_shape);
+ object.unsafe_set_shape(new_shape);
object.initialize_direct(entry.property_offset.get(), value);
return true;
}
diff --git a/Libraries/LibJS/Rust/src/jit/runtime_info.rs b/Libraries/LibJS/Rust/src/jit/runtime_info.rs
index c2bb42d2b0b..c6174bd1905 100644
--- a/Libraries/LibJS/Rust/src/jit/runtime_info.rs
+++ b/Libraries/LibJS/Rust/src/jit/runtime_info.rs
@@ -353,7 +353,7 @@ fn runtime_layout() -> RuntimeLayout {
property_lookup_cache_entry_size: offset(size_of::<PropertyLookupCacheEntry>()),
property_lookup_cache_entry_key: offset(offset_of!(PropertyLookupCacheEntry, key)),
property_lookup_cache_keyed_generic: PROPERTY_LOOKUP_CACHE_KEYED_GENERIC_DATA as u64,
- property_lookup_cache_entry_from_shape: offset(offset_of!(PropertyLookupCacheEntry, from_shape)),
+ property_lookup_cache_entry_new_shape: offset(offset_of!(PropertyLookupCacheEntry, new_shape)),
property_lookup_cache_megamorphic_tag: MEGAMORPHIC_DATA_TAG as u64,
property_lookup_cache_megamorphic_primary_entries: offset(MEGAMORPHIC_PRIMARY_ENTRIES_OFFSET),
property_lookup_cache_megamorphic_secondary_entries: offset(MEGAMORPHIC_SECONDARY_ENTRIES_OFFSET),
diff --git a/Libraries/LibJS/Rust/src/jit/snapshot.rs b/Libraries/LibJS/Rust/src/jit/snapshot.rs
index 3b245ae2ae4..d3f607a35d9 100644
--- a/Libraries/LibJS/Rust/src/jit/snapshot.rs
+++ b/Libraries/LibJS/Rust/src/jit/snapshot.rs
@@ -477,7 +477,7 @@ impl SnapshotBuilder<'_> {
shape_is_dictionary: entry.shape.is_some_and(|shape| shape.is_dictionary()),
shape_is_stable: entry.shape.is_some_and(|shape| shape.is_stable()),
writes_data_property: entry.writes_data_property,
- from_shape: self.optional_cell(entry.from_shape),
+ new_shape: self.optional_cell(entry.new_shape),
shape: self.optional_cell(entry.shape),
prototype: self.optional_cell(entry.prototype),
prototype_chain_validity: self.optional_cell(entry.prototype_chain_validity),
diff --git a/Libraries/LibJS/Rust/src/layout/property_lookup_cache.rs b/Libraries/LibJS/Rust/src/layout/property_lookup_cache.rs
index 31965a14c9c..523bcf8689b 100644
--- a/Libraries/LibJS/Rust/src/layout/property_lookup_cache.rs
+++ b/Libraries/LibJS/Rust/src/layout/property_lookup_cache.rs
@@ -38,7 +38,7 @@ pub struct PropertyLookupCacheEntry {
pub property_offset: Cell<u32>,
pub shape_dictionary_generation: Cell<u32>,
pub writes_data_property: Cell<bool>,
- pub from_shape: Cell<Option<Gc<Shape>>>,
+ pub new_shape: Cell<Option<Gc<Shape>>>,
pub shape: Cell<Option<Gc<Shape>>>,
pub prototype: Cell<Option<Gc<Object>>>,
pub prototype_chain_validity: Cell<Option<Gc<WatchpointSet>>>,