From 3ee6b808a4326f2cd0140876cbd9c1e3c429761b Mon Sep 17 00:00:00 2001 From: bjaideep Date: Thu, 30 Jun 2016 15:30:38 -0700 Subject: [PATCH] PPC/s390: [builtins] New frame type for exits to C++ builtins Port 5febc27b5d17f14908d5e3c225bdb9b8a6b2df9a 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. R=jgruber@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com BUG=v8:4815 LOG=N Review-Url: https://codereview.chromium.org/2105023008 Cr-Commit-Position: refs/heads/master@{#37461} --- src/ppc/builtins-ppc.cc | 6 ++++-- src/ppc/code-stubs-ppc.cc | 4 +++- src/ppc/macro-assembler-ppc.cc | 13 +++++++++---- src/ppc/macro-assembler-ppc.h | 6 ++++-- src/s390/builtins-s390.cc | 6 ++++-- src/s390/code-stubs-s390.cc | 4 +++- src/s390/macro-assembler-s390.cc | 13 +++++++++---- src/s390/macro-assembler-s390.h | 6 ++++-- 8 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc index c3c2b84be8..90ef0a40ca 100644 --- a/src/ppc/builtins-ppc.cc +++ b/src/ppc/builtins-ppc.cc @@ -17,7 +17,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 ------------- // -- r3 : number of arguments excluding receiver // -- r4 : target @@ -43,7 +44,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { // including the receiver and the extra arguments. __ addi(r3, r3, Operand(num_extra_args + 1)); - __ JumpToExternalReference(ExternalReference(id, masm->isolate())); + __ JumpToExternalReference(ExternalReference(id, masm->isolate()), + exit_frame_type == BUILTIN_EXIT); } diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc index 401aa4187e..b6cfec77b8 100644 --- a/src/ppc/code-stubs-ppc.cc +++ b/src/ppc/code-stubs-ppc.cc @@ -928,7 +928,9 @@ void CEntryStub::Generate(MacroAssembler* masm) { arg_stack_space += result_size(); } - __ EnterExitFrame(save_doubles(), arg_stack_space); + __ EnterExitFrame(save_doubles(), arg_stack_space, is_builtin_exit() + ? StackFrame::BUILTIN_EXIT + : StackFrame::EXIT); // Store a copy of argc in callee-saved registers for later. __ mr(r14, r3); diff --git a/src/ppc/macro-assembler-ppc.cc b/src/ppc/macro-assembler-ppc.cc index 8e55bc6702..45c35961fd 100644 --- a/src/ppc/macro-assembler-ppc.cc +++ b/src/ppc/macro-assembler-ppc.cc @@ -1089,7 +1089,10 @@ int MacroAssembler::LeaveFrame(StackFrame::Type type, int stack_adjustment) { // in the fp register (r31) // Then - we buy a new frame -void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { +void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, + StackFrame::Type frame_type) { + DCHECK(frame_type == StackFrame::EXIT || + frame_type == StackFrame::BUILTIN_EXIT); // Set up the frame structure on the stack. DCHECK_EQ(2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement); DCHECK_EQ(1 * kPointerSize, ExitFrameConstants::kCallerPCOffset); @@ -1100,7 +1103,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { // all of the pushes that have happened inside of V8 // since we were called from C code - LoadSmiLiteral(ip, Smi::FromInt(StackFrame::EXIT)); + LoadSmiLiteral(ip, Smi::FromInt(frame_type)); PushCommonFrame(ip); // Reserve room for saved entry sp and code object. subi(sp, fp, Operand(ExitFrameConstants::kFixedFrameSizeFromFp)); @@ -2754,9 +2757,11 @@ void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { } -void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { +void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, + bool builtin_exit_frame) { mov(r4, Operand(builtin)); - CEntryStub stub(isolate(), 1); + CEntryStub stub(isolate(), 1, kDontSaveFPRegs, kArgvOnStack, + builtin_exit_frame); Jump(stub.GetCode(), RelocInfo::CODE_TARGET); } diff --git a/src/ppc/macro-assembler-ppc.h b/src/ppc/macro-assembler-ppc.h index 0d5df2fa44..56db98a09b 100644 --- a/src/ppc/macro-assembler-ppc.h +++ b/src/ppc/macro-assembler-ppc.h @@ -433,7 +433,8 @@ class MacroAssembler : public Assembler { // Enter exit frame. // stack_space - extra stack space, used for parameters before call to C. // At least one slot (for the return address) should be provided. - void EnterExitFrame(bool save_doubles, int stack_space = 1); + void EnterExitFrame(bool save_doubles, int stack_space = 1, + StackFrame::Type frame_type = StackFrame::EXIT); // Leave the current exit frame. Expects the return value in r0. // Expect the number of values, pushed prior to the exit frame, to @@ -1072,7 +1073,8 @@ class MacroAssembler : public Assembler { void MovFromFloatResult(DoubleRegister dst); // Jump to a runtime routine. - void JumpToExternalReference(const ExternalReference& builtin); + void JumpToExternalReference(const ExternalReference& builtin, + bool builtin_exit_frame = false); Handle CodeObject() { DCHECK(!code_object_.is_null()); diff --git a/src/s390/builtins-s390.cc b/src/s390/builtins-s390.cc index f0059bc37d..4ffd1528c4 100644 --- a/src/s390/builtins-s390.cc +++ b/src/s390/builtins-s390.cc @@ -15,7 +15,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 ------------- // -- r2 : number of arguments excluding receiver // -- r3 : target @@ -40,7 +41,8 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { // including the receiver and the extra arguments. __ AddP(r2, r2, Operand(num_extra_args + 1)); - __ JumpToExternalReference(ExternalReference(id, masm->isolate())); + __ JumpToExternalReference(ExternalReference(id, masm->isolate()), + exit_frame_type == BUILTIN_EXIT); } // Load the built-in InternalArray function from the current context. diff --git a/src/s390/code-stubs-s390.cc b/src/s390/code-stubs-s390.cc index ab85852a49..dc3fc7897e 100644 --- a/src/s390/code-stubs-s390.cc +++ b/src/s390/code-stubs-s390.cc @@ -897,7 +897,9 @@ void CEntryStub::Generate(MacroAssembler* masm) { arg_stack_space += 2; #endif - __ EnterExitFrame(save_doubles(), arg_stack_space); + __ EnterExitFrame(save_doubles(), arg_stack_space, is_builtin_exit() + ? StackFrame::BUILTIN_EXIT + : StackFrame::EXIT); // Store a copy of argc, argv in callee-saved registers for later. __ LoadRR(r6, r2); diff --git a/src/s390/macro-assembler-s390.cc b/src/s390/macro-assembler-s390.cc index 0b5bbb4d1a..746265235a 100644 --- a/src/s390/macro-assembler-s390.cc +++ b/src/s390/macro-assembler-s390.cc @@ -1024,7 +1024,10 @@ int MacroAssembler::LeaveFrame(StackFrame::Type type, int stack_adjustment) { // gaps // Args // ABIRes <- newSP -void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { +void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, + StackFrame::Type frame_type) { + DCHECK(frame_type == StackFrame::EXIT || + frame_type == StackFrame::BUILTIN_EXIT); // Set up the frame structure on the stack. DCHECK_EQ(2 * kPointerSize, ExitFrameConstants::kCallerSPDisplacement); DCHECK_EQ(1 * kPointerSize, ExitFrameConstants::kCallerPCOffset); @@ -1035,7 +1038,7 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { // all of the pushes that have happened inside of V8 // since we were called from C code CleanseP(r14); - LoadSmiLiteral(r1, Smi::FromInt(StackFrame::EXIT)); + LoadSmiLiteral(r1, Smi::FromInt(frame_type)); PushCommonFrame(r1); // Reserve room for saved entry sp and code object. lay(sp, MemOperand(fp, -ExitFrameConstants::kFixedFrameSizeFromFp)); @@ -2614,9 +2617,11 @@ void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { JumpToExternalReference(ExternalReference(fid, isolate())); } -void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin) { +void MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, + bool builtin_exit_frame) { mov(r3, Operand(builtin)); - CEntryStub stub(isolate(), 1); + CEntryStub stub(isolate(), 1, kDontSaveFPRegs, kArgvOnStack, + builtin_exit_frame); Jump(stub.GetCode(), RelocInfo::CODE_TARGET); } diff --git a/src/s390/macro-assembler-s390.h b/src/s390/macro-assembler-s390.h index 23b353ed01..3a038fdcda 100644 --- a/src/s390/macro-assembler-s390.h +++ b/src/s390/macro-assembler-s390.h @@ -734,7 +734,8 @@ class MacroAssembler : public Assembler { // Enter exit frame. // stack_space - extra stack space, used for parameters before call to C. // At least one slot (for the return address) should be provided. - void EnterExitFrame(bool save_doubles, int stack_space = 1); + void EnterExitFrame(bool save_doubles, int stack_space = 1, + StackFrame::Type frame_type = StackFrame::EXIT); // Leave the current exit frame. Expects the return value in r0. // Expect the number of values, pushed prior to the exit frame, to @@ -1337,7 +1338,8 @@ class MacroAssembler : public Assembler { void MovFromFloatResult(DoubleRegister dst); // Jump to a runtime routine. - void JumpToExternalReference(const ExternalReference& builtin); + void JumpToExternalReference(const ExternalReference& builtin, + bool builtin_exit_frame = false); Handle CodeObject() { DCHECK(!code_object_.is_null());