OLD | NEW |
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" |
11 #include "src/cpu-profiler.h" | 11 #include "src/cpu-profiler.h" |
12 #include "src/debug/debug.h" | 12 #include "src/debug/debug.h" |
13 #include "src/heap/heap.h" | 13 #include "src/heap/heap.h" |
| 14 #include "src/register-configuration.h" |
14 #include "src/x64/assembler-x64.h" | 15 #include "src/x64/assembler-x64.h" |
15 #include "src/x64/macro-assembler-x64.h" | 16 #include "src/x64/macro-assembler-x64.h" |
16 | 17 |
17 namespace v8 { | 18 namespace v8 { |
18 namespace internal { | 19 namespace internal { |
19 | 20 |
20 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) | 21 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
21 : Assembler(arg_isolate, buffer, size), | 22 : Assembler(arg_isolate, buffer, size), |
22 generating_stub_(false), | 23 generating_stub_(false), |
23 has_frame_(false), | 24 has_frame_(false), |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 724 |
724 void MacroAssembler::GetBuiltinEntry(Register target, | 725 void MacroAssembler::GetBuiltinEntry(Register target, |
725 int native_context_index) { | 726 int native_context_index) { |
726 DCHECK(!target.is(rdi)); | 727 DCHECK(!target.is(rdi)); |
727 // Load the JavaScript builtin function from the builtins object. | 728 // Load the JavaScript builtin function from the builtins object. |
728 GetBuiltinFunction(rdi, native_context_index); | 729 GetBuiltinFunction(rdi, native_context_index); |
729 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 730 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
730 } | 731 } |
731 | 732 |
732 | 733 |
733 #define REG(Name) { kRegister_ ## Name ## _Code } | 734 #define REG(Name) \ |
| 735 { Register::kCode_##Name } |
734 | 736 |
735 static const Register saved_regs[] = { | 737 static const Register saved_regs[] = { |
736 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), | 738 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), |
737 REG(r9), REG(r10), REG(r11) | 739 REG(r9), REG(r10), REG(r11) |
738 }; | 740 }; |
739 | 741 |
740 #undef REG | 742 #undef REG |
741 | 743 |
742 static const int kNumberOfSavedRegs = sizeof(saved_regs) / sizeof(Register); | 744 static const int kNumberOfSavedRegs = sizeof(saved_regs) / sizeof(Register); |
743 | 745 |
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3781 | 3783 |
3782 | 3784 |
3783 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, | 3785 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, |
3784 bool save_doubles) { | 3786 bool save_doubles) { |
3785 #ifdef _WIN64 | 3787 #ifdef _WIN64 |
3786 const int kShadowSpace = 4; | 3788 const int kShadowSpace = 4; |
3787 arg_stack_space += kShadowSpace; | 3789 arg_stack_space += kShadowSpace; |
3788 #endif | 3790 #endif |
3789 // Optionally save all XMM registers. | 3791 // Optionally save all XMM registers. |
3790 if (save_doubles) { | 3792 if (save_doubles) { |
3791 int space = XMMRegister::kMaxNumAllocatableRegisters * kDoubleSize + | 3793 int space = XMMRegister::kMaxNumRegisters * kDoubleSize + |
3792 arg_stack_space * kRegisterSize; | 3794 arg_stack_space * kRegisterSize; |
3793 subp(rsp, Immediate(space)); | 3795 subp(rsp, Immediate(space)); |
3794 int offset = -2 * kPointerSize; | 3796 int offset = -2 * kPointerSize; |
3795 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 3797 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); |
3796 XMMRegister reg = XMMRegister::FromAllocationIndex(i); | 3798 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
| 3799 DoubleRegister reg = |
| 3800 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); |
3797 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); | 3801 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); |
3798 } | 3802 } |
3799 } else if (arg_stack_space > 0) { | 3803 } else if (arg_stack_space > 0) { |
3800 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); | 3804 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); |
3801 } | 3805 } |
3802 | 3806 |
3803 // Get the required frame alignment for the OS. | 3807 // Get the required frame alignment for the OS. |
3804 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); | 3808 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); |
3805 if (kFrameAlignment > 0) { | 3809 if (kFrameAlignment > 0) { |
3806 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); | 3810 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); |
(...skipping 22 matching lines...) Expand all Loading... |
3829 EnterExitFramePrologue(false); | 3833 EnterExitFramePrologue(false); |
3830 EnterExitFrameEpilogue(arg_stack_space, false); | 3834 EnterExitFrameEpilogue(arg_stack_space, false); |
3831 } | 3835 } |
3832 | 3836 |
3833 | 3837 |
3834 void MacroAssembler::LeaveExitFrame(bool save_doubles) { | 3838 void MacroAssembler::LeaveExitFrame(bool save_doubles) { |
3835 // Registers: | 3839 // Registers: |
3836 // r15 : argv | 3840 // r15 : argv |
3837 if (save_doubles) { | 3841 if (save_doubles) { |
3838 int offset = -2 * kPointerSize; | 3842 int offset = -2 * kPointerSize; |
3839 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 3843 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); |
3840 XMMRegister reg = XMMRegister::FromAllocationIndex(i); | 3844 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
| 3845 DoubleRegister reg = |
| 3846 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); |
3841 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); | 3847 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); |
3842 } | 3848 } |
3843 } | 3849 } |
3844 // Get the return address from the stack and restore the frame pointer. | 3850 // Get the return address from the stack and restore the frame pointer. |
3845 movp(rcx, Operand(rbp, kFPOnStackSize)); | 3851 movp(rcx, Operand(rbp, kFPOnStackSize)); |
3846 movp(rbp, Operand(rbp, 0 * kPointerSize)); | 3852 movp(rbp, Operand(rbp, 0 * kPointerSize)); |
3847 | 3853 |
3848 // Drop everything up to and including the arguments and the receiver | 3854 // Drop everything up to and including the arguments and the receiver |
3849 // from the caller stack. | 3855 // from the caller stack. |
3850 leap(rsp, Operand(r15, 1 * kPointerSize)); | 3856 leap(rsp, Operand(r15, 1 * kPointerSize)); |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5067 movl(rax, dividend); | 5073 movl(rax, dividend); |
5068 shrl(rax, Immediate(31)); | 5074 shrl(rax, Immediate(31)); |
5069 addl(rdx, rax); | 5075 addl(rdx, rax); |
5070 } | 5076 } |
5071 | 5077 |
5072 | 5078 |
5073 } // namespace internal | 5079 } // namespace internal |
5074 } // namespace v8 | 5080 } // namespace v8 |
5075 | 5081 |
5076 #endif // V8_TARGET_ARCH_X64 | 5082 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |