Commit 5a625a83 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[sparkplug] Use embedded builtins when short builtin calls are disabled

This CL fixes a segfault when Wasm tried to generate a builtin call
from background compilation job when the Isolate was already teared
down by the main thread.

Drive-by: Use CallBuiltin in RegExpMacroAssemblerARM64.

Bug: v8:11527, chromium:1195552
Change-Id: I8048ffcb212bda4d19d07b5ec6b487d6fb16b30d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2811739
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73850}
parent 59e218c8
......@@ -1929,12 +1929,14 @@ void TurboAssembler::CallBuiltin(int builtin_index) {
DCHECK(Builtins::IsBuiltinId(builtin_index));
RecordCommentForOffHeapTrampoline(builtin_index);
CHECK_NE(builtin_index, Builtins::kNoBuiltinId);
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
if (options().short_builtin_calls) {
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
Call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
EmbeddedData d = EmbeddedData::FromBlob();
Address entry = d.InstructionStartOfBuiltin(builtin_index);
UseScratchRegisterScope temps(this);
Register scratch = temps.AcquireX();
Ldr(scratch, Operand(entry, RelocInfo::OFF_HEAP_TARGET));
......@@ -1947,12 +1949,14 @@ void TurboAssembler::TailCallBuiltin(int builtin_index) {
DCHECK(Builtins::IsBuiltinId(builtin_index));
RecordCommentForOffHeapTrampoline(builtin_index);
CHECK_NE(builtin_index, Builtins::kNoBuiltinId);
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
if (options().short_builtin_calls) {
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
Jump(entry, RelocInfo::RUNTIME_ENTRY);
} else {
EmbeddedData d = EmbeddedData::FromBlob();
Address entry = d.InstructionStartOfBuiltin(builtin_index);
// The control flow integrity (CFI) feature allows us to "sign" code entry
// points as a target for calls, jumps or both. Arm64 has special
// instructions for this purpose, so-called "landing pads" (see
......
......@@ -1670,12 +1670,14 @@ void TurboAssembler::CallBuiltin(int builtin_index) {
DCHECK(Builtins::IsBuiltinId(builtin_index));
RecordCommentForOffHeapTrampoline(builtin_index);
CHECK_NE(builtin_index, Builtins::kNoBuiltinId);
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
if (options().short_builtin_calls) {
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
call(entry, RelocInfo::RUNTIME_ENTRY);
} else {
EmbeddedData d = EmbeddedData::FromBlob();
Address entry = d.InstructionStartOfBuiltin(builtin_index);
Move(kScratchRegister, entry, RelocInfo::OFF_HEAP_TARGET);
call(kScratchRegister);
}
......@@ -1686,12 +1688,14 @@ void TurboAssembler::TailCallBuiltin(int builtin_index) {
DCHECK(Builtins::IsBuiltinId(builtin_index));
RecordCommentForOffHeapTrampoline(builtin_index);
CHECK_NE(builtin_index, Builtins::kNoBuiltinId);
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
if (options().short_builtin_calls) {
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(builtin_index);
jmp(entry, RelocInfo::RUNTIME_ENTRY);
} else {
EmbeddedData d = EmbeddedData::FromBlob();
Address entry = d.InstructionStartOfBuiltin(builtin_index);
Jump(entry, RelocInfo::OFF_HEAP_TARGET);
}
if (FLAG_code_comments) RecordComment("]");
......
......@@ -1407,16 +1407,7 @@ void RegExpMacroAssemblerARM64::CallCheckStackGuardState(Register scratch) {
ExternalReference::re_check_stack_guard_state(isolate());
__ Mov(scratch, check_stack_guard_state);
{
UseScratchRegisterScope temps(masm_);
Register scratch = temps.AcquireX();
EmbeddedData d = EmbeddedData::FromBlob(isolate());
Address entry = d.InstructionStartOfBuiltin(Builtins::kDirectCEntry);
__ Ldr(scratch, Operand(entry, RelocInfo::OFF_HEAP_TARGET));
__ Call(scratch);
}
__ CallBuiltin(Builtins::kDirectCEntry);
// The input string may have been moved in memory, we need to reload it.
__ Peek(input_start(), kSystemPointerSize);
......
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