X87: [builtins] New frame type for exits to C++ builtins.
port 5febc27b5d
(r37416)
original commit message:
Prior to this commit, calls to C++ builtins created standard exit
frames, which are skipped when constructing JS stack traces. In order to
show these calls on traces, we introduce a new builtin exit frame type.
Builtin exit frames contain target and new.target on the stack and are
not skipped during stack trace construction.
BUG=
Review-Url: https://codereview.chromium.org/2120873002
Cr-Commit-Position: refs/heads/master@{#37490}
This commit is contained in:
parent
a21bc23d53
commit
f50725d3ba
@ -16,7 +16,8 @@ namespace internal {
|
||||
|
||||
#define __ ACCESS_MASM(masm)
|
||||
|
||||
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
|
||||
void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id,
|
||||
ExitFrameType exit_frame_type) {
|
||||
// ----------- S t a t e -------------
|
||||
// -- eax : number of arguments excluding receiver
|
||||
// -- edi : target
|
||||
@ -46,7 +47,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) {
|
||||
// including the receiver and the extra arguments.
|
||||
__ add(eax, Immediate(num_extra_args + 1));
|
||||
|
||||
__ JumpToExternalReference(ExternalReference(id, masm->isolate()));
|
||||
__ JumpToExternalReference(ExternalReference(id, masm->isolate()),
|
||||
exit_frame_type == BUILTIN_EXIT);
|
||||
}
|
||||
|
||||
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
|
||||
|
@ -1498,13 +1498,16 @@ void CEntryStub::Generate(MacroAssembler* masm) {
|
||||
// Enter the exit frame that transitions from JavaScript to C++.
|
||||
if (argv_in_register()) {
|
||||
DCHECK(!save_doubles());
|
||||
DCHECK(!is_builtin_exit());
|
||||
__ EnterApiExitFrame(arg_stack_space);
|
||||
|
||||
// Move argc and argv into the correct registers.
|
||||
__ mov(esi, ecx);
|
||||
__ mov(edi, eax);
|
||||
} else {
|
||||
__ EnterExitFrame(arg_stack_space, save_doubles());
|
||||
__ EnterExitFrame(
|
||||
arg_stack_space, save_doubles(),
|
||||
is_builtin_exit() ? StackFrame::BUILTIN_EXIT : StackFrame::EXIT);
|
||||
}
|
||||
|
||||
// ebx: pointer to C function (C callee-saved)
|
||||
|
@ -1078,8 +1078,10 @@ void MacroAssembler::LeaveFrame(StackFrame::Type type) {
|
||||
leave();
|
||||
}
|
||||
|
||||
void MacroAssembler::EnterExitFramePrologue(StackFrame::Type frame_type) {
|
||||
DCHECK(frame_type == StackFrame::EXIT ||
|
||||
frame_type == StackFrame::BUILTIN_EXIT);
|
||||
|
||||
void MacroAssembler::EnterExitFramePrologue() {
|
||||
// Set up the frame structure on the stack.
|
||||
DCHECK_EQ(+2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement);
|
||||
DCHECK_EQ(+1 * kPointerSize, ExitFrameConstants::kCallerPCOffset);
|
||||
@ -1088,7 +1090,7 @@ void MacroAssembler::EnterExitFramePrologue() {
|
||||
mov(ebp, esp);
|
||||
|
||||
// Reserve room for entry stack pointer and push the code object.
|
||||
push(Immediate(Smi::FromInt(StackFrame::EXIT)));
|
||||
push(Immediate(Smi::FromInt(frame_type)));
|
||||
DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
|
||||
push(Immediate(0)); // Saved entry sp, patched before call.
|
||||
DCHECK_EQ(-3 * kPointerSize, ExitFrameConstants::kCodeOffset);
|
||||
@ -1127,9 +1129,9 @@ void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) {
|
||||
mov(Operand(ebp, ExitFrameConstants::kSPOffset), esp);
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::EnterExitFrame(int argc, bool save_doubles) {
|
||||
EnterExitFramePrologue();
|
||||
void MacroAssembler::EnterExitFrame(int argc, bool save_doubles,
|
||||
StackFrame::Type frame_type) {
|
||||
EnterExitFramePrologue(frame_type);
|
||||
|
||||
// Set up argc and argv in callee-saved registers.
|
||||
int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
|
||||
@ -1142,7 +1144,7 @@ void MacroAssembler::EnterExitFrame(int argc, bool save_doubles) {
|
||||
|
||||
|
||||
void MacroAssembler::EnterApiExitFrame(int argc) {
|
||||
EnterExitFramePrologue();
|
||||
EnterExitFramePrologue(StackFrame::EXIT);
|
||||
EnterExitFrameEpilogue(argc, false);
|
||||
}
|
||||
|
||||
@ -2141,11 +2143,12 @@ void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) {
|
||||
JumpToExternalReference(ExternalReference(fid, isolate()));
|
||||
}
|
||||
|
||||
|
||||
void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) {
|
||||
void MacroAssembler::JumpToExternalReference(const ExternalReference& ext,
|
||||
bool builtin_exit_frame) {
|
||||
// Set the entry point and jump to the C entry runtime stub.
|
||||
mov(ebx, Immediate(ext));
|
||||
CEntryStub ces(isolate(), 1);
|
||||
CEntryStub ces(isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
|
||||
builtin_exit_frame);
|
||||
jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ class MacroAssembler: public Assembler {
|
||||
// arguments in register eax and sets up the number of arguments in
|
||||
// register edi and the pointer to the first argument in register
|
||||
// esi.
|
||||
void EnterExitFrame(int argc, bool save_doubles);
|
||||
void EnterExitFrame(int argc, bool save_doubles, StackFrame::Type frame_type);
|
||||
|
||||
void EnterApiExitFrame(int argc);
|
||||
|
||||
@ -775,7 +775,8 @@ class MacroAssembler: public Assembler {
|
||||
void CallCFunction(Register function, int num_arguments);
|
||||
|
||||
// Jump to a runtime routine.
|
||||
void JumpToExternalReference(const ExternalReference& ext);
|
||||
void JumpToExternalReference(const ExternalReference& ext,
|
||||
bool builtin_exit_frame = false);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Utilities
|
||||
@ -951,7 +952,7 @@ class MacroAssembler: public Assembler {
|
||||
Label::Distance done_distance,
|
||||
const CallWrapper& call_wrapper);
|
||||
|
||||
void EnterExitFramePrologue();
|
||||
void EnterExitFramePrologue(StackFrame::Type frame_type);
|
||||
void EnterExitFrameEpilogue(int argc, bool save_doubles);
|
||||
|
||||
void LeaveExitFrameEpilogue(bool restore_context);
|
||||
|
Loading…
Reference in New Issue
Block a user