Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 2090723005: [builtins] New frame type for exits to C++ builtins (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing condition in SafeStackFrameIter::frame() Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/cctest/compiler/test-run-inlining.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // ----------------------------------- 731 // -----------------------------------
732 732
733 const Runtime::Function* function = Runtime::FunctionForId(fid); 733 const Runtime::Function* function = Runtime::FunctionForId(fid);
734 DCHECK_EQ(1, function->result_size); 734 DCHECK_EQ(1, function->result_size);
735 if (function->nargs >= 0) { 735 if (function->nargs >= 0) {
736 Set(rax, function->nargs); 736 Set(rax, function->nargs);
737 } 737 }
738 JumpToExternalReference(ExternalReference(fid, isolate())); 738 JumpToExternalReference(ExternalReference(fid, isolate()));
739 } 739 }
740 740
741 741 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext,
742 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 742 bool builtin_exit_frame) {
743 // Set the entry point and jump to the C entry runtime stub. 743 // Set the entry point and jump to the C entry runtime stub.
744 LoadAddress(rbx, ext); 744 LoadAddress(rbx, ext);
745 CEntryStub ces(isolate(), 1); 745 CEntryStub ces(isolate(), 1, kDontSaveFPRegs, kArgvOnStack,
746 builtin_exit_frame);
746 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); 747 jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
747 } 748 }
748 749
749
750 #define REG(Name) \ 750 #define REG(Name) \
751 { Register::kCode_##Name } 751 { Register::kCode_##Name }
752 752
753 static const Register saved_regs[] = { 753 static const Register saved_regs[] = {
754 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), 754 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8),
755 REG(r9), REG(r10), REG(r11) 755 REG(r9), REG(r10), REG(r11)
756 }; 756 };
757 757
758 #undef REG 758 #undef REG
759 759
(...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 if (emit_debug_code()) { 4429 if (emit_debug_code()) {
4430 Move(kScratchRegister, Smi::FromInt(type)); 4430 Move(kScratchRegister, Smi::FromInt(type));
4431 cmpp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset), 4431 cmpp(Operand(rbp, CommonFrameConstants::kContextOrFrameTypeOffset),
4432 kScratchRegister); 4432 kScratchRegister);
4433 Check(equal, kStackFrameTypesMustMatch); 4433 Check(equal, kStackFrameTypesMustMatch);
4434 } 4434 }
4435 movp(rsp, rbp); 4435 movp(rsp, rbp);
4436 popq(rbp); 4436 popq(rbp);
4437 } 4437 }
4438 4438
4439 void MacroAssembler::EnterExitFramePrologue(bool save_rax,
4440 StackFrame::Type frame_type) {
4441 DCHECK(frame_type == StackFrame::EXIT ||
4442 frame_type == StackFrame::BUILTIN_EXIT);
4439 4443
4440 void MacroAssembler::EnterExitFramePrologue(bool save_rax) {
4441 // Set up the frame structure on the stack. 4444 // Set up the frame structure on the stack.
4442 // All constants are relative to the frame pointer of the exit frame. 4445 // All constants are relative to the frame pointer of the exit frame.
4443 DCHECK_EQ(kFPOnStackSize + kPCOnStackSize, 4446 DCHECK_EQ(kFPOnStackSize + kPCOnStackSize,
4444 ExitFrameConstants::kCallerSPDisplacement); 4447 ExitFrameConstants::kCallerSPDisplacement);
4445 DCHECK_EQ(kFPOnStackSize, ExitFrameConstants::kCallerPCOffset); 4448 DCHECK_EQ(kFPOnStackSize, ExitFrameConstants::kCallerPCOffset);
4446 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset); 4449 DCHECK_EQ(0 * kPointerSize, ExitFrameConstants::kCallerFPOffset);
4447 pushq(rbp); 4450 pushq(rbp);
4448 movp(rbp, rsp); 4451 movp(rbp, rsp);
4449 4452
4450 // Reserve room for entry stack pointer and push the code object. 4453 // Reserve room for entry stack pointer and push the code object.
4451 Push(Smi::FromInt(StackFrame::EXIT)); 4454 Push(Smi::FromInt(frame_type));
4452 DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset); 4455 DCHECK_EQ(-2 * kPointerSize, ExitFrameConstants::kSPOffset);
4453 Push(Immediate(0)); // Saved entry sp, patched before call. 4456 Push(Immediate(0)); // Saved entry sp, patched before call.
4454 Move(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); 4457 Move(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
4455 Push(kScratchRegister); // Accessed from EditFrame::code_slot. 4458 Push(kScratchRegister); // Accessed from EditFrame::code_slot.
4456 4459
4457 // Save the frame pointer and the context in top. 4460 // Save the frame pointer and the context in top.
4458 if (save_rax) { 4461 if (save_rax) {
4459 movp(r14, rax); // Backup rax in callee-save register. 4462 movp(r14, rax); // Backup rax in callee-save register.
4460 } 4463 }
4461 4464
(...skipping 30 matching lines...) Expand all
4492 if (kFrameAlignment > 0) { 4495 if (kFrameAlignment > 0) {
4493 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); 4496 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment));
4494 DCHECK(is_int8(kFrameAlignment)); 4497 DCHECK(is_int8(kFrameAlignment));
4495 andp(rsp, Immediate(-kFrameAlignment)); 4498 andp(rsp, Immediate(-kFrameAlignment));
4496 } 4499 }
4497 4500
4498 // Patch the saved entry sp. 4501 // Patch the saved entry sp.
4499 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp); 4502 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp);
4500 } 4503 }
4501 4504
4502 4505 void MacroAssembler::EnterExitFrame(int arg_stack_space, bool save_doubles,
4503 void MacroAssembler::EnterExitFrame(int arg_stack_space, bool save_doubles) { 4506 StackFrame::Type frame_type) {
4504 EnterExitFramePrologue(true); 4507 EnterExitFramePrologue(true, frame_type);
4505 4508
4506 // Set up argv in callee-saved register r15. It is reused in LeaveExitFrame, 4509 // Set up argv in callee-saved register r15. It is reused in LeaveExitFrame,
4507 // so it must be retained across the C-call. 4510 // so it must be retained across the C-call.
4508 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize; 4511 int offset = StandardFrameConstants::kCallerSPOffset - kPointerSize;
4509 leap(r15, Operand(rbp, r14, times_pointer_size, offset)); 4512 leap(r15, Operand(rbp, r14, times_pointer_size, offset));
4510 4513
4511 EnterExitFrameEpilogue(arg_stack_space, save_doubles); 4514 EnterExitFrameEpilogue(arg_stack_space, save_doubles);
4512 } 4515 }
4513 4516
4514 4517
4515 void MacroAssembler::EnterApiExitFrame(int arg_stack_space) { 4518 void MacroAssembler::EnterApiExitFrame(int arg_stack_space) {
4516 EnterExitFramePrologue(false); 4519 EnterExitFramePrologue(false, StackFrame::EXIT);
4517 EnterExitFrameEpilogue(arg_stack_space, false); 4520 EnterExitFrameEpilogue(arg_stack_space, false);
4518 } 4521 }
4519 4522
4520 4523
4521 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) { 4524 void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) {
4522 // Registers: 4525 // Registers:
4523 // r15 : argv 4526 // r15 : argv
4524 if (save_doubles) { 4527 if (save_doubles) {
4525 int offset = -ExitFrameConstants::kFixedFrameSizeFromFp; 4528 int offset = -ExitFrameConstants::kFixedFrameSizeFromFp;
4526 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft(); 4529 const RegisterConfiguration* config = RegisterConfiguration::Crankshaft();
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
5713 movl(rax, dividend); 5716 movl(rax, dividend);
5714 shrl(rax, Immediate(31)); 5717 shrl(rax, Immediate(31));
5715 addl(rdx, rax); 5718 addl(rdx, rax);
5716 } 5719 }
5717 5720
5718 5721
5719 } // namespace internal 5722 } // namespace internal
5720 } // namespace v8 5723 } // namespace v8
5721 5724
5722 #endif // V8_TARGET_ARCH_X64 5725 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | test/cctest/compiler/test-run-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698