Reland of [builtins] Introduce a builtin for Abort().

Original message:

Calling Runtime::kAbort through a builtin instead of the c-entry stub
will allow to generate the call in a background thread, because a
builtin provides its own handle, whereas a code stub does not.

@v8-mips-ports: Could you take a special look at the padding that is
done in MacroAssembler::Abort()?

Reason for revert:
The reason for reverting is: Blocks roll:
https://build.chromium.org/p/client.v8.ports/builders/V8%20Linux%20-%20arm64%20-%20sim%20-%20debug/builds/1622

The problem was that on arm64 the builtin for Abort() contained a call to
Abort(). The problem is fixed by using a NoUseRealAbortsScope in the
code generation of Abort().

R=titzer@chromium.org, rmcilroy@chromium.org, rodolph.perfetta@arm.com

Review-Url: https://codereview.chromium.org/2163263002
Cr-Commit-Position: refs/heads/master@{#37929}
This commit is contained in:
ahaas 2016-07-21 02:10:42 -07:00 committed by Commit bot
parent 2744fcbb6c
commit 66cb026f4a
15 changed files with 115 additions and 26 deletions

View File

@ -2965,17 +2965,19 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
mov(r0, Operand(Smi::FromInt(reason)));
push(r0);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(r1, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
// will not return here
if (is_const_pool_blocked()) {

View File

@ -4653,16 +4653,18 @@ void MacroAssembler::Abort(BailoutReason reason) {
// Avoid infinite recursion; Push contains some assertions that use Abort.
NoUseRealAbortsScope no_real_aborts(this);
Mov(x0, Smi::FromInt(reason));
Push(x0);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(x1, Smi::FromInt(static_cast<int>(reason)));
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
} else {
// Load the string to pass to Printf.

View File

@ -2725,6 +2725,17 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r1 : message_id as Smi
// -- lr : return address
// -----------------------------------
__ Push(r1);
__ Move(cp, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
// static
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes one argument in r0.

View File

@ -2810,6 +2810,19 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
ASM_LOCATION("Builtins::Generate_Abort");
// ----------- S t a t e -------------
// -- x1 : message_id as Smi
// -- lr : return address
// -----------------------------------
MacroAssembler::NoUseRealAbortsScope no_use_real_aborts(masm);
__ Push(x1);
__ Move(cp, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
// static
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes one argument in x0.

View File

@ -48,6 +48,7 @@ namespace internal {
// DBG: Builtin in platform-dependent assembly, used by the debugger.
// Args: name
#define BUILTIN_LIST(CPP, API, TFJ, TFS, ASM, ASH, DBG) \
ASM(Abort) \
/* Handlers */ \
ASM(KeyedLoadIC_Miss) \
ASM(KeyedStoreIC_Miss) \

View File

@ -2698,6 +2698,19 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- edx : message_id as Smi
// -- esp[0] : return address
// -----------------------------------
__ PopReturnAddressTo(ecx);
__ Push(edx);
__ PushReturnAddressFrom(ecx);
__ Move(esi, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
// static
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes one argument in eax.

View File

@ -2793,6 +2793,17 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : message_id as Smi
// -- ra : return address
// -----------------------------------
__ Push(a0);
__ Move(cp, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
// static
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes on argument in a0.

View File

@ -2787,6 +2787,17 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- a0 : message_id as Smi
// -- ra : return address
// -----------------------------------
__ Push(a0);
__ Move(cp, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
// static
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes on argument in a0.

View File

@ -2115,6 +2115,19 @@ void Builtins::Generate_AllocateInOldSpace(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kAllocateInTargetSpace);
}
// static
void Builtins::Generate_Abort(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- rdx : message_id as Smi
// -- rsp[0] : return address
// -----------------------------------
__ PopReturnAddressTo(rcx);
__ Push(rdx);
__ PushReturnAddressFrom(rcx);
__ Move(rsi, Smi::FromInt(0));
__ TailCallRuntime(Runtime::kAbort);
}
void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
// The StringToNumber stub takes one argument in rax.
__ AssertString(rax);

View File

@ -2876,8 +2876,6 @@ void Heap::CreateInitialObjects() {
// Initialize compilation cache.
isolate_->compilation_cache()->Clear();
CreateFixedStubs();
}
bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {

View File

@ -2952,15 +2952,19 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(reason))));
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(edx, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
// will not return here
int3();

View File

@ -2331,6 +2331,9 @@ bool Isolate::Init(Deserializer* des) {
bootstrapper_->Initialize(create_heap_objects);
builtins_.SetUp(this, create_heap_objects);
if (create_heap_objects) {
heap_.CreateFixedStubs();
}
if (FLAG_log_internal_timer_events) {
set_event_logger(Logger::DefaultEventLoggerSentinel);

View File

@ -5806,16 +5806,19 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
li(a0, Operand(Smi::FromInt(reason)));
push(a0);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(a0, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
// Will not return here.
if (is_trampoline_pool_blocked()) {

View File

@ -6088,16 +6088,19 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
li(a0, Operand(Smi::FromInt(reason)));
push(a0);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(a0, Smi::FromInt(static_cast<int>(reason)));
// Disable stub call restrictions to always allow calls to abort.
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
// Will not return here.
if (is_trampoline_pool_blocked()) {

View File

@ -638,17 +638,18 @@ void MacroAssembler::Abort(BailoutReason reason) {
}
#endif
Move(kScratchRegister, Smi::FromInt(static_cast<int>(reason)),
Assembler::RelocInfoNone());
Push(kScratchRegister);
// Check if Abort() has already been initialized.
DCHECK(isolate()->builtins()->Abort()->IsHeapObject());
Move(rdx, Smi::FromInt(static_cast<int>(reason)));
if (!has_frame_) {
// We don't actually want to generate a pile of code for this, so just
// claim there is a stack frame, without generating one.
FrameScope scope(this, StackFrame::NONE);
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
} else {
CallRuntime(Runtime::kAbort);
Call(isolate()->builtins()->Abort(), RelocInfo::CODE_TARGET);
}
// Control will not return here.
int3();