Commit 877e7352 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [heap] Remove write barrier builtin for incremental marking

Port e50d19cb

Original Commit Message:

    https://crrev.com/c/3471854 already disabled the RecordWrite builtin
    specifically for incremental marking. Since this didn't regress performance as expected, we can now remove those versions of the
    builtin.

    This will simplify the barrier implementation a bit, but is also
    required for the shared heap write barrier. Unlike the generational barrier, the shared heap barrier can't be elided for map values.

R=dinfuehr@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: Ic1a31fad3faaafeab077590d71d6d998eaddcc6a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3691128Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/main@{#80979}
parent 7fd79963
......@@ -1121,7 +1121,7 @@ static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm,
__ RecordWriteField(closure, JSFunction::kCodeOffset, value, slot_address,
kLRHasNotBeenSaved, SaveFPRegsMode::kIgnore,
RememberedSetAction::kOmit, SmiCheck::kOmit);
SmiCheck::kOmit);
}
static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1,
......
......@@ -1160,7 +1160,7 @@ static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm,
__ RecordWriteField(closure, JSFunction::kCodeOffset, value, slot_address,
kLRHasNotBeenSaved, SaveFPRegsMode::kIgnore,
RememberedSetAction::kOmit, SmiCheck::kOmit);
SmiCheck::kOmit);
}
static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1,
......
......@@ -667,7 +667,6 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
Register value, Register slot_address,
LinkRegisterStatus lr_status,
SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action,
SmiCheck smi_check) {
// First, check if a write barrier is even needed. The tests below
// catch stores of Smis.
......@@ -691,8 +690,7 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
bind(&ok);
}
RecordWrite(object, slot_address, value, lr_status, save_fp,
remembered_set_action, SmiCheck::kOmit);
RecordWrite(object, slot_address, value, lr_status, save_fp, SmiCheck::kOmit);
bind(&done);
......@@ -737,10 +735,10 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object,
MaybeRestoreRegisters(registers);
}
void TurboAssembler::CallRecordWriteStubSaveRegisters(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
StubCallMode mode) {
void TurboAssembler::CallRecordWriteStubSaveRegisters(Register object,
Register slot_address,
SaveFPRegsMode fp_mode,
StubCallMode mode) {
DCHECK(!AreAliased(object, slot_address));
RegList registers =
WriteBarrierDescriptor::ComputeSavedRegisters(object, slot_address);
......@@ -755,16 +753,14 @@ void TurboAssembler::CallRecordWriteStubSaveRegisters(
pop(slot_address_parameter);
pop(object_parameter);
CallRecordWriteStub(object_parameter, slot_address_parameter,
remembered_set_action, fp_mode, mode);
CallRecordWriteStub(object_parameter, slot_address_parameter, fp_mode, mode);
MaybeRestoreRegisters(registers);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
StubCallMode mode) {
void TurboAssembler::CallRecordWriteStub(Register object, Register slot_address,
SaveFPRegsMode fp_mode,
StubCallMode mode) {
// Use CallRecordWriteStubSaveRegisters if the object and slot registers
// need to be caller saved.
DCHECK_EQ(WriteBarrierDescriptor::ObjectRegister(), object);
......@@ -772,15 +768,13 @@ void TurboAssembler::CallRecordWriteStub(
#if V8_ENABLE_WEBASSEMBLY
if (mode == StubCallMode::kCallWasmRuntimeStub) {
// Use {near_call} for direct Wasm call within a module.
auto wasm_target =
wasm::WasmCode::GetRecordWriteStub(remembered_set_action, fp_mode);
auto wasm_target = wasm::WasmCode::GetRecordWriteStub(fp_mode);
Call(wasm_target, RelocInfo::WASM_STUB_CALL);
#else
if (false) {
#endif
} else {
auto builtin_index =
Builtins::GetRecordWriteStub(remembered_set_action, fp_mode);
auto builtin_index = Builtins::GetRecordWriteStub(fp_mode);
if (options().inline_offheap_trampolines) {
RecordCommentForOffHeapTrampoline(builtin_index);
// Use ip directly instead of using UseScratchRegisterScope, as we do
......@@ -800,9 +794,7 @@ void TurboAssembler::CallRecordWriteStub(
// tag is shifted away.
void MacroAssembler::RecordWrite(Register object, Register slot_address,
Register value, LinkRegisterStatus lr_status,
SaveFPRegsMode fp_mode,
RememberedSetAction remembered_set_action,
SmiCheck smi_check) {
SaveFPRegsMode fp_mode, SmiCheck smi_check) {
DCHECK(!AreAliased(object, value, slot_address));
if (FLAG_debug_code) {
LoadTaggedPointerField(r0, MemOperand(slot_address));
......@@ -810,9 +802,7 @@ void MacroAssembler::RecordWrite(Register object, Register slot_address,
Check(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite);
}
if ((remembered_set_action == RememberedSetAction::kOmit &&
!FLAG_incremental_marking) ||
FLAG_disable_write_barriers) {
if (FLAG_disable_write_barriers) {
return;
}
......@@ -836,8 +826,7 @@ void MacroAssembler::RecordWrite(Register object, Register slot_address,
mflr(r0);
push(r0);
}
CallRecordWriteStubSaveRegisters(object, slot_address, remembered_set_action,
fp_mode);
CallRecordWriteStubSaveRegisters(object, slot_address, fp_mode);
if (lr_status == kLRHasNotBeenSaved) {
pop(r0);
mtlr(r0);
......
......@@ -547,12 +547,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
SaveFPRegsMode fp_mode);
void CallRecordWriteStubSaveRegisters(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Register object, Register slot_address, SaveFPRegsMode fp_mode,
StubCallMode mode = StubCallMode::kCallBuiltinPointer);
void CallRecordWriteStub(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Register object, Register slot_address, SaveFPRegsMode fp_mode,
StubCallMode mode = StubCallMode::kCallBuiltinPointer);
void MultiPush(RegList regs, Register location = sp);
......@@ -1097,20 +1095,17 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// stored. value and scratch registers are clobbered by the operation.
// The offset is the offset from the start of the object, not the offset from
// the tagged HeapObject pointer. For use with FieldMemOperand(reg, off).
void RecordWriteField(
Register object, int offset, Register value, Register slot_address,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action = RememberedSetAction::kEmit,
SmiCheck smi_check = SmiCheck::kInline);
void RecordWriteField(Register object, int offset, Register value,
Register slot_address, LinkRegisterStatus lr_status,
SaveFPRegsMode save_fp,
SmiCheck smi_check = SmiCheck::kInline);
// For a given |object| notify the garbage collector that the slot |address|
// has been written. |value| is the object being stored. The value and
// address registers are clobbered by the operation.
void RecordWrite(
Register object, Register slot_address, Register value,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action = RememberedSetAction::kEmit,
SmiCheck smi_check = SmiCheck::kInline);
void RecordWrite(Register object, Register slot_address, Register value,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
SmiCheck smi_check = SmiCheck::kInline);
// Enter exit frame.
// stack_space - extra stack space, used for parameters before call to C.
......
......@@ -901,7 +901,6 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
Register value, Register slot_address,
LinkRegisterStatus lr_status,
SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action,
SmiCheck smi_check) {
// First, check if a write barrier is even needed. The tests below
// catch stores of Smis.
......@@ -925,8 +924,7 @@ void MacroAssembler::RecordWriteField(Register object, int offset,
bind(&ok);
}
RecordWrite(object, slot_address, value, lr_status, save_fp,
remembered_set_action, SmiCheck::kOmit);
RecordWrite(object, slot_address, value, lr_status, save_fp, SmiCheck::kOmit);
bind(&done);
......@@ -971,10 +969,10 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object,
MaybeRestoreRegisters(registers);
}
void TurboAssembler::CallRecordWriteStubSaveRegisters(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
StubCallMode mode) {
void TurboAssembler::CallRecordWriteStubSaveRegisters(Register object,
Register slot_address,
SaveFPRegsMode fp_mode,
StubCallMode mode) {
DCHECK(!AreAliased(object, slot_address));
RegList registers =
WriteBarrierDescriptor::ComputeSavedRegisters(object, slot_address);
......@@ -989,31 +987,27 @@ void TurboAssembler::CallRecordWriteStubSaveRegisters(
Pop(slot_address_parameter);
Pop(object_parameter);
CallRecordWriteStub(object_parameter, slot_address_parameter,
remembered_set_action, fp_mode, mode);
CallRecordWriteStub(object_parameter, slot_address_parameter, fp_mode, mode);
MaybeRestoreRegisters(registers);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
StubCallMode mode) {
void TurboAssembler::CallRecordWriteStub(Register object, Register slot_address,
SaveFPRegsMode fp_mode,
StubCallMode mode) {
// Use CallRecordWriteStubSaveRegisters if the object and slot registers
// need to be caller saved.
DCHECK_EQ(WriteBarrierDescriptor::ObjectRegister(), object);
DCHECK_EQ(WriteBarrierDescriptor::SlotAddressRegister(), slot_address);
#if V8_ENABLE_WEBASSEMBLY
if (mode == StubCallMode::kCallWasmRuntimeStub) {
auto wasm_target =
wasm::WasmCode::GetRecordWriteStub(remembered_set_action, fp_mode);
auto wasm_target = wasm::WasmCode::GetRecordWriteStub(fp_mode);
Call(wasm_target, RelocInfo::WASM_STUB_CALL);
#else
if (false) {
#endif
} else {
auto builtin_index =
Builtins::GetRecordWriteStub(remembered_set_action, fp_mode);
auto builtin_index = Builtins::GetRecordWriteStub(fp_mode);
if (options().inline_offheap_trampolines) {
RecordCommentForOffHeapTrampoline(builtin_index);
mov(ip, Operand(BuiltinEntry(builtin_index), RelocInfo::OFF_HEAP_TARGET));
......@@ -1031,9 +1025,7 @@ void TurboAssembler::CallRecordWriteStub(
// tag is shifted away.
void MacroAssembler::RecordWrite(Register object, Register slot_address,
Register value, LinkRegisterStatus lr_status,
SaveFPRegsMode fp_mode,
RememberedSetAction remembered_set_action,
SmiCheck smi_check) {
SaveFPRegsMode fp_mode, SmiCheck smi_check) {
DCHECK(!AreAliased(object, slot_address, value));
if (FLAG_debug_code) {
LoadTaggedPointerField(r0, MemOperand(slot_address));
......@@ -1041,9 +1033,7 @@ void MacroAssembler::RecordWrite(Register object, Register slot_address,
Check(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite);
}
if ((remembered_set_action == RememberedSetAction::kOmit &&
!FLAG_incremental_marking) ||
FLAG_disable_write_barriers) {
if (FLAG_disable_write_barriers) {
return;
}
// First, check if a write barrier is even needed. The tests below
......@@ -1065,8 +1055,7 @@ void MacroAssembler::RecordWrite(Register object, Register slot_address,
if (lr_status == kLRHasNotBeenSaved) {
push(r14);
}
CallRecordWriteStubSaveRegisters(object, slot_address, remembered_set_action,
fp_mode);
CallRecordWriteStubSaveRegisters(object, slot_address, fp_mode);
if (lr_status == kLRHasNotBeenSaved) {
pop(r14);
}
......
......@@ -164,12 +164,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
SaveFPRegsMode fp_mode);
void CallRecordWriteStubSaveRegisters(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Register object, Register slot_address, SaveFPRegsMode fp_mode,
StubCallMode mode = StubCallMode::kCallBuiltinPointer);
void CallRecordWriteStub(
Register object, Register slot_address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Register object, Register slot_address, SaveFPRegsMode fp_mode,
StubCallMode mode = StubCallMode::kCallBuiltinPointer);
void MultiPush(RegList regs, Register location = sp);
......@@ -1758,20 +1756,17 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// stored. value and scratch registers are clobbered by the operation.
// The offset is the offset from the start of the object, not the offset from
// the tagged HeapObject pointer. For use with FieldMemOperand(reg, off).
void RecordWriteField(
Register object, int offset, Register value, Register slot_address,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action = RememberedSetAction::kEmit,
SmiCheck smi_check = SmiCheck::kInline);
void RecordWriteField(Register object, int offset, Register value,
Register slot_address, LinkRegisterStatus lr_status,
SaveFPRegsMode save_fp,
SmiCheck smi_check = SmiCheck::kInline);
// For a given |object| notify the garbage collector that the slot |address|
// has been written. |value| is the object being stored. The value and
// address registers are clobbered by the operation.
void RecordWrite(
Register object, Register slot_address, Register value,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
RememberedSetAction remembered_set_action = RememberedSetAction::kEmit,
SmiCheck smi_check = SmiCheck::kInline);
void RecordWrite(Register object, Register slot_address, Register value,
LinkRegisterStatus lr_status, SaveFPRegsMode save_fp,
SmiCheck smi_check = SmiCheck::kInline);
void TestCodeTIsMarkedForDeoptimization(Register codet, Register scratch);
Operand ClearedValue() const;
......
......@@ -186,11 +186,6 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
DCHECK_EQ(0, offset_immediate_);
__ add(scratch1_, object_, offset_);
}
RememberedSetAction const remembered_set_action =
mode_ > RecordWriteMode::kValueIsMap ||
FLAG_use_full_record_write_builtin
? RememberedSetAction::kEmit
: RememberedSetAction::kOmit;
SaveFPRegsMode const save_fp_mode = frame()->DidAllocateDoubleRegisters()
? SaveFPRegsMode::kSave
: SaveFPRegsMode::kIgnore;
......@@ -204,13 +199,11 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
__ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode);
#if V8_ENABLE_WEBASSEMBLY
} else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) {
__ CallRecordWriteStubSaveRegisters(object_, scratch1_,
remembered_set_action, save_fp_mode,
__ CallRecordWriteStubSaveRegisters(object_, scratch1_, save_fp_mode,
StubCallMode::kCallWasmRuntimeStub);
#endif // V8_ENABLE_WEBASSEMBLY
} else {
__ CallRecordWriteStubSaveRegisters(object_, scratch1_,
remembered_set_action, save_fp_mode);
__ CallRecordWriteStubSaveRegisters(object_, scratch1_, save_fp_mode);
}
if (must_save_lr_) {
// We need to save and restore lr if the frame was elided.
......
......@@ -223,11 +223,6 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
DCHECK_EQ(0, offset_immediate_);
__ AddS64(scratch1_, object_, offset_);
}
RememberedSetAction const remembered_set_action =
mode_ > RecordWriteMode::kValueIsMap ||
FLAG_use_full_record_write_builtin
? RememberedSetAction::kEmit
: RememberedSetAction::kOmit;
SaveFPRegsMode const save_fp_mode = frame()->DidAllocateDoubleRegisters()
? SaveFPRegsMode::kSave
: SaveFPRegsMode::kIgnore;
......@@ -240,13 +235,11 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
__ CallEphemeronKeyBarrier(object_, scratch1_, save_fp_mode);
#if V8_ENABLE_WEBASSEMBLY
} else if (stub_mode_ == StubCallMode::kCallWasmRuntimeStub) {
__ CallRecordWriteStubSaveRegisters(object_, scratch1_,
remembered_set_action, save_fp_mode,
__ CallRecordWriteStubSaveRegisters(object_, scratch1_, save_fp_mode,
StubCallMode::kCallWasmRuntimeStub);
#endif // V8_ENABLE_WEBASSEMBLY
} else {
__ CallRecordWriteStubSaveRegisters(object_, scratch1_,
remembered_set_action, save_fp_mode);
__ CallRecordWriteStubSaveRegisters(object_, scratch1_, save_fp_mode);
}
if (must_save_lr_) {
// We need to save and restore r14 if the frame was elided.
......
......@@ -340,8 +340,7 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
if (offset_reg != no_reg) {
add(ip, ip, offset_reg);
}
CallRecordWriteStubSaveRegisters(dst_addr, ip, RememberedSetAction::kEmit,
SaveFPRegsMode::kSave,
CallRecordWriteStubSaveRegisters(dst_addr, ip, SaveFPRegsMode::kSave,
StubCallMode::kCallWasmRuntimeStub);
bind(&exit);
}
......
......@@ -318,8 +318,7 @@ void LiftoffAssembler::StoreTaggedPointer(Register dst_addr,
CheckPageFlag(src.gp(), r1, MemoryChunk::kPointersToHereAreInterestingMask,
eq, &exit);
lay(r1, dst_op);
CallRecordWriteStubSaveRegisters(dst_addr, r1, RememberedSetAction::kEmit,
SaveFPRegsMode::kSave,
CallRecordWriteStubSaveRegisters(dst_addr, r1, SaveFPRegsMode::kSave,
StubCallMode::kCallWasmRuntimeStub);
bind(&exit);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment