Skip to content

Commit

Permalink
deps: V8: cherry-pick d2283ba066ba
Browse files Browse the repository at this point in the history
Original commit message:

    [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=​[email protected]

    (cherry picked from commit 6b3994e8507b32dfb956329395dbe33a2a8fee14)

    No-Try: true
    No-Presubmit: true
    No-Tree-Checks: true
    Bug: chromium:1146813
    Change-Id: I4ee59084e4184f2e9039208e4e6db43482cefde6
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2593333
    Reviewed-by: Clemens Backes <[email protected]>
    Commit-Queue: Thibaud Michaud <[email protected]>
    Cr-Original-Commit-Position: refs/heads/master@{#71785}
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2731535
    Commit-Queue: Victor-Gabriel Savu <[email protected]>
    Reviewed-by: Jana Grill <[email protected]>
    Cr-Commit-Position: refs/branch-heads/8.6@{#66}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@d2283ba

PR-URL: #38275
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
  • Loading branch information
targos committed Apr 30, 2021
1 parent 26cc160 commit d221cdc
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.45',
'v8_embedder_string': '-node.46',

##### V8 defaults for Node.js #####

Expand Down
19 changes: 11 additions & 8 deletions deps/v8/src/codegen/arm/macro-assembler-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -722,23 +722,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
Expand All @@ -762,9 +761,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);
}

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/arm/macro-assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,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);
};

Expand Down
19 changes: 11 additions & 8 deletions deps/v8/src/codegen/arm64/macro-assembler-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2738,23 +2738,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
Expand All @@ -2778,9 +2777,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);
}

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/arm64/macro-assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,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);
};

Expand Down
19 changes: 11 additions & 8 deletions deps/v8/src/codegen/ia32/macro-assembler-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,25 +415,24 @@ 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(
Register object, Register address,
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
Expand Down Expand Up @@ -461,10 +460,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);
}

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/ia32/macro-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,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);
};

Expand Down
19 changes: 11 additions & 8 deletions deps/v8/src/codegen/x64/macro-assembler-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,25 +385,24 @@ 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(
Register object, Register address,
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();
Expand Down Expand Up @@ -432,10 +431,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);
}

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/x64/macro-assembler-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,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);
};

Expand Down

0 comments on commit d221cdc

Please sign in to comment.