@@ -1501,7 +1501,7 @@ void MacroAssembler::ReplaceClosureCodeWithOptimizedCode(
15011501 FieldMemOperand (closure, JSFunction::kCodeOffset ));
15021502 RecordWriteField (closure, JSFunction::kCodeOffset , optimized_code,
15031503 kLRHasNotBeenSaved , SaveFPRegsMode::kIgnore , SmiCheck::kOmit ,
1504- SlotDescriptor::ForCodePointerSlot ());
1504+ ReadOnlyCheck:: kOmit , SlotDescriptor::ForCodePointerSlot ());
15051505#endif // V8_ENABLE_LEAPTIERING
15061506}
15071507
@@ -3614,17 +3614,24 @@ void MacroAssembler::JumpIfNotMarking(Label* not_marking,
36143614 Cbz (scratch, not_marking);
36153615}
36163616
3617- void MacroAssembler::RecordWriteField (Register object, int offset,
3618- Register value,
3619- LinkRegisterStatus lr_status,
3620- SaveFPRegsMode save_fp,
3621- SmiCheck smi_check, SlotDescriptor slot) {
3617+ void MacroAssembler::RecordWriteField (
3618+ Register object, int offset, Register value, LinkRegisterStatus lr_status,
3619+ SaveFPRegsMode save_fp, SmiCheck smi_check, ReadOnlyCheck ro_check,
3620+ SlotDescriptor slot) {
36223621 ASM_CODE_COMMENT (this );
36233622 DCHECK (!AreAliased (object, value));
36243623 // First, check if a write barrier is even needed. The tests below
3625- // catch stores of Smis.
3624+ // catch stores of Smis and read-only objects .
36263625 Label done;
36273626
3627+ #if V8_STATIC_ROOTS_BOOL
3628+ if (ro_check == ReadOnlyCheck::kInline ) {
3629+ // Quick check for Read-only and small Smi values.
3630+ static_assert (StaticReadOnlyRoot::kLastAllocatedRoot < kRegularPageSize );
3631+ JumpIfUnsignedLessThan (value, kRegularPageSize , &done);
3632+ }
3633+ #endif // V8_STATIC_ROOTS_BOOL
3634+
36283635 // Skip the barrier if writing a smi.
36293636 if (smi_check == SmiCheck::kInline ) {
36303637 JumpIfSmi (value, &done);
@@ -3648,7 +3655,7 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
36483655 }
36493656
36503657 RecordWrite (object, Operand (offset - kHeapObjectTag ), value, lr_status,
3651- save_fp, SmiCheck::kOmit , slot);
3658+ save_fp, SmiCheck::kOmit , ReadOnlyCheck:: kOmit , slot);
36523659
36533660 Bind (&done);
36543661}
@@ -4008,7 +4015,7 @@ void MacroAssembler::MoveObjectAndSlot(Register dst_object, Register dst_slot,
40084015void MacroAssembler::RecordWrite (Register object, Operand offset,
40094016 Register value, LinkRegisterStatus lr_status,
40104017 SaveFPRegsMode fp_mode, SmiCheck smi_check,
4011- SlotDescriptor slot) {
4018+ ReadOnlyCheck ro_check, SlotDescriptor slot) {
40124019 ASM_CODE_COMMENT (this );
40134020 ASM_LOCATION_IN_ASSEMBLER (" MacroAssembler::RecordWrite" );
40144021 DCHECK (!AreAliased (object, value));
@@ -4035,9 +4042,18 @@ void MacroAssembler::RecordWrite(Register object, Operand offset,
40354042 }
40364043
40374044 // First, check if a write barrier is even needed. The tests below
4038- // catch stores of smis and stores into the young generation.
4045+ // catch stores of smisand read-only objects, as well as stores into the
4046+ // young generation.
40394047 Label done;
40404048
4049+ #if V8_STATIC_ROOTS_BOOL
4050+ if (ro_check == ReadOnlyCheck::kInline ) {
4051+ // Quick check for Read-only and small Smi values.
4052+ static_assert (StaticReadOnlyRoot::kLastAllocatedRoot < kRegularPageSize );
4053+ JumpIfUnsignedLessThan (value, kRegularPageSize , &done);
4054+ }
4055+ #endif // V8_STATIC_ROOTS_BOOL
4056+
40414057 if (smi_check == SmiCheck::kInline ) {
40424058 DCHECK_EQ (0 , kSmiTag );
40434059 JumpIfSmi (value, &done);
0 commit comments