Commit 6b3994e8 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[macro-assembler] Avoid using the isolate in CallRecordWriteStub

CallRecordWriteStub is used in a background compile thread for
JS-to-Wasm wrapper compilation, so it should avoid accessing the
isolate.
Call the builtin using CallBuiltin which does not require a Handle<Code>
object and instead gets the call target directly from the embedded data.

R=clemensb@chromium.org

Bug: chromium:1146813
Change-Id: I4ee59084e4184f2e9039208e4e6db43482cefde6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2593333Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71785}
parent 43d61196
......@@ -716,23 +716,22 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object, Operand offset,
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode) {
CallRecordWriteStub(
object, offset, remembered_set_action, fp_mode,
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite),
kNullAddress);
CallRecordWriteStub(object, offset, remembered_set_action, fp_mode,
Builtins::kRecordWrite, kNullAddress);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Address wasm_target) {
CallRecordWriteStub(object, offset, remembered_set_action, fp_mode,
Handle<Code>::null(), wasm_target);
Builtins::kNoBuiltinId, wasm_target);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target, Address wasm_target) {
DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress);
SaveFPRegsMode fp_mode, int builtin_index, Address wasm_target) {
DCHECK_NE(builtin_index == Builtins::kNoBuiltinId,
wasm_target == kNullAddress);
// TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode,
// i.e. always emit remember set and save FP registers in RecordWriteStub. If
// large performance regression is observed, we should use these values to
......@@ -756,9 +755,13 @@ void TurboAssembler::CallRecordWriteStub(
Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action));
Move(fp_mode_parameter, Smi::FromEnum(fp_mode));
if (code_target.is_null()) {
if (builtin_index == Builtins::kNoBuiltinId) {
Call(wasm_target, RelocInfo::WASM_STUB_CALL);
} else if (options().inline_offheap_trampolines) {
CallBuiltin(builtin_index);
} else {
Handle<Code> code_target =
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite);
Call(code_target, RelocInfo::CODE_TARGET);
}
......
......@@ -604,7 +604,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CallRecordWriteStub(Register object, Operand offset,
RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target,
SaveFPRegsMode fp_mode, int builtin_index,
Address wasm_target);
};
......
......@@ -2882,23 +2882,22 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object, Operand offset,
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode) {
CallRecordWriteStub(
object, offset, remembered_set_action, fp_mode,
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite),
kNullAddress);
CallRecordWriteStub(object, offset, remembered_set_action, fp_mode,
Builtins::kRecordWrite, kNullAddress);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Address wasm_target) {
CallRecordWriteStub(object, offset, remembered_set_action, fp_mode,
Handle<Code>::null(), wasm_target);
Builtins::kNoBuiltinId, wasm_target);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Operand offset, RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target, Address wasm_target) {
DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress);
SaveFPRegsMode fp_mode, int builtin_index, Address wasm_target) {
DCHECK_NE(builtin_index == Builtins::kNoBuiltinId,
wasm_target == kNullAddress);
// TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode,
// i.e. always emit remember set and save FP registers in RecordWriteStub. If
// large performance regression is observed, we should use these values to
......@@ -2922,9 +2921,13 @@ void TurboAssembler::CallRecordWriteStub(
Mov(remembered_set_parameter, Smi::FromEnum(remembered_set_action));
Mov(fp_mode_parameter, Smi::FromEnum(fp_mode));
if (code_target.is_null()) {
if (builtin_index == Builtins::kNoBuiltinId) {
Call(wasm_target, RelocInfo::WASM_STUB_CALL);
} else if (options().inline_offheap_trampolines) {
CallBuiltin(builtin_index);
} else {
Handle<Code> code_target =
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite);
Call(code_target, RelocInfo::CODE_TARGET);
}
......
......@@ -1440,7 +1440,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CallRecordWriteStub(Register object, Operand offset,
RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target,
SaveFPRegsMode fp_mode, int builtin_index,
Address wasm_target);
};
......
......@@ -443,10 +443,8 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address,
void TurboAssembler::CallRecordWriteStub(
Register object, Register address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) {
CallRecordWriteStub(
object, address, remembered_set_action, fp_mode,
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite),
kNullAddress);
CallRecordWriteStub(object, address, remembered_set_action, fp_mode,
Builtins::kRecordWrite, kNullAddress);
}
void TurboAssembler::CallRecordWriteStub(
......@@ -454,14 +452,15 @@ void TurboAssembler::CallRecordWriteStub(
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Address wasm_target) {
CallRecordWriteStub(object, address, remembered_set_action, fp_mode,
Handle<Code>::null(), wasm_target);
Builtins::kNoBuiltinId, wasm_target);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Register address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Handle<Code> code_target, Address wasm_target) {
DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress);
int builtin_index, Address wasm_target) {
DCHECK_NE(builtin_index == Builtins::kNoBuiltinId,
wasm_target == kNullAddress);
// TODO(albertnetymk): For now we ignore remembered_set_action and fp_mode,
// i.e. always emit remember set and save FP registers in RecordWriteStub. If
// large performance regression is observed, we should use these values to
......@@ -489,10 +488,14 @@ void TurboAssembler::CallRecordWriteStub(
Move(remembered_set_parameter, Smi::FromEnum(remembered_set_action));
Move(fp_mode_parameter, Smi::FromEnum(fp_mode));
if (code_target.is_null()) {
if (builtin_index == Builtins::kNoBuiltinId) {
// Use {wasm_call} for direct Wasm call within a module.
wasm_call(wasm_target, RelocInfo::WASM_STUB_CALL);
} else if (options().inline_offheap_trampolines) {
CallBuiltin(builtin_index);
} else {
Handle<Code> code_target =
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite);
Call(code_target, RelocInfo::CODE_TARGET);
}
......
......@@ -665,7 +665,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CallRecordWriteStub(Register object, Register address,
RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target,
SaveFPRegsMode fp_mode, int builtin_index,
Address wasm_target);
};
......
......@@ -389,10 +389,8 @@ void TurboAssembler::CallEphemeronKeyBarrier(Register object, Register address,
void TurboAssembler::CallRecordWriteStub(
Register object, Register address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode) {
CallRecordWriteStub(
object, address, remembered_set_action, fp_mode,
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite),
kNullAddress);
CallRecordWriteStub(object, address, remembered_set_action, fp_mode,
Builtins::kRecordWrite, kNullAddress);
}
void TurboAssembler::CallRecordWriteStub(
......@@ -400,14 +398,15 @@ void TurboAssembler::CallRecordWriteStub(
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Address wasm_target) {
CallRecordWriteStub(object, address, remembered_set_action, fp_mode,
Handle<Code>::null(), wasm_target);
Builtins::kNoBuiltinId, wasm_target);
}
void TurboAssembler::CallRecordWriteStub(
Register object, Register address,
RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode,
Handle<Code> code_target, Address wasm_target) {
DCHECK_NE(code_target.is_null(), wasm_target == kNullAddress);
int builtin_index, Address wasm_target) {
DCHECK_NE(builtin_index == Builtins::kNoBuiltinId,
wasm_target == kNullAddress);
RecordWriteDescriptor descriptor;
RegList registers = descriptor.allocatable_registers();
......@@ -436,10 +435,14 @@ void TurboAssembler::CallRecordWriteStub(
} else {
movq(fp_mode_parameter, remembered_set_parameter);
}
if (code_target.is_null()) {
if (builtin_index == Builtins::kNoBuiltinId) {
// Use {near_call} for direct Wasm call within a module.
near_call(wasm_target, RelocInfo::WASM_STUB_CALL);
} else if (options().inline_offheap_trampolines) {
CallBuiltin(builtin_index);
} else {
Handle<Code> code_target =
isolate()->builtins()->builtin_handle(Builtins::kRecordWrite);
Call(code_target, RelocInfo::CODE_TARGET);
}
......
......@@ -730,7 +730,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void CallRecordWriteStub(Register object, Register address,
RememberedSetAction remembered_set_action,
SaveFPRegsMode fp_mode, Handle<Code> code_target,
SaveFPRegsMode fp_mode, int builtin_index,
Address wasm_target);
};
......
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