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/debug/debug.h" | 11 #include "src/debug/debug.h" |
12 #include "src/heap/heap.h" | 12 #include "src/heap/heap.h" |
13 #include "src/register-configuration.h" | |
14 #include "src/x64/assembler-x64.h" | 13 #include "src/x64/assembler-x64.h" |
15 #include "src/x64/macro-assembler-x64.h" | 14 #include "src/x64/macro-assembler-x64.h" |
16 | 15 |
17 namespace v8 { | 16 namespace v8 { |
18 namespace internal { | 17 namespace internal { |
19 | 18 |
20 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) | 19 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
21 : Assembler(arg_isolate, buffer, size), | 20 : Assembler(arg_isolate, buffer, size), |
22 generating_stub_(false), | 21 generating_stub_(false), |
23 has_frame_(false), | 22 has_frame_(false), |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 722 |
724 void MacroAssembler::GetBuiltinEntry(Register target, | 723 void MacroAssembler::GetBuiltinEntry(Register target, |
725 int native_context_index) { | 724 int native_context_index) { |
726 DCHECK(!target.is(rdi)); | 725 DCHECK(!target.is(rdi)); |
727 // Load the JavaScript builtin function from the builtins object. | 726 // Load the JavaScript builtin function from the builtins object. |
728 GetBuiltinFunction(rdi, native_context_index); | 727 GetBuiltinFunction(rdi, native_context_index); |
729 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 728 movp(target, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
730 } | 729 } |
731 | 730 |
732 | 731 |
733 #define REG(Name) \ | 732 #define REG(Name) { kRegister_ ## Name ## _Code } |
734 { Register::kCode_##Name } | |
735 | 733 |
736 static const Register saved_regs[] = { | 734 static const Register saved_regs[] = { |
737 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), | 735 REG(rax), REG(rcx), REG(rdx), REG(rbx), REG(rbp), REG(rsi), REG(rdi), REG(r8), |
738 REG(r9), REG(r10), REG(r11) | 736 REG(r9), REG(r10), REG(r11) |
739 }; | 737 }; |
740 | 738 |
741 #undef REG | 739 #undef REG |
742 | 740 |
743 static const int kNumberOfSavedRegs = sizeof(saved_regs) / sizeof(Register); | 741 static const int kNumberOfSavedRegs = sizeof(saved_regs) / sizeof(Register); |
744 | 742 |
(...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3705 | 3703 |
3706 | 3704 |
3707 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, | 3705 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, |
3708 bool save_doubles) { | 3706 bool save_doubles) { |
3709 #ifdef _WIN64 | 3707 #ifdef _WIN64 |
3710 const int kShadowSpace = 4; | 3708 const int kShadowSpace = 4; |
3711 arg_stack_space += kShadowSpace; | 3709 arg_stack_space += kShadowSpace; |
3712 #endif | 3710 #endif |
3713 // Optionally save all XMM registers. | 3711 // Optionally save all XMM registers. |
3714 if (save_doubles) { | 3712 if (save_doubles) { |
3715 int space = XMMRegister::kMaxNumRegisters * kDoubleSize + | 3713 int space = XMMRegister::kMaxNumAllocatableRegisters * kDoubleSize + |
3716 arg_stack_space * kRegisterSize; | 3714 arg_stack_space * kRegisterSize; |
3717 subp(rsp, Immediate(space)); | 3715 subp(rsp, Immediate(space)); |
3718 int offset = -2 * kPointerSize; | 3716 int offset = -2 * kPointerSize; |
3719 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); | 3717 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { |
3720 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 3718 XMMRegister reg = XMMRegister::FromAllocationIndex(i); |
3721 DoubleRegister reg = | |
3722 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); | |
3723 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); | 3719 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); |
3724 } | 3720 } |
3725 } else if (arg_stack_space > 0) { | 3721 } else if (arg_stack_space > 0) { |
3726 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); | 3722 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); |
3727 } | 3723 } |
3728 | 3724 |
3729 // Get the required frame alignment for the OS. | 3725 // Get the required frame alignment for the OS. |
3730 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); | 3726 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); |
3731 if (kFrameAlignment > 0) { | 3727 if (kFrameAlignment > 0) { |
3732 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); | 3728 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); |
(...skipping 22 matching lines...) Expand all Loading... |
3755 EnterExitFramePrologue(false); | 3751 EnterExitFramePrologue(false); |
3756 EnterExitFrameEpilogue(arg_stack_space, false); | 3752 EnterExitFrameEpilogue(arg_stack_space, false); |
3757 } | 3753 } |
3758 | 3754 |
3759 | 3755 |
3760 void MacroAssembler::LeaveExitFrame(bool save_doubles) { | 3756 void MacroAssembler::LeaveExitFrame(bool save_doubles) { |
3761 // Registers: | 3757 // Registers: |
3762 // r15 : argv | 3758 // r15 : argv |
3763 if (save_doubles) { | 3759 if (save_doubles) { |
3764 int offset = -2 * kPointerSize; | 3760 int offset = -2 * kPointerSize; |
3765 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); | 3761 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { |
3766 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { | 3762 XMMRegister reg = XMMRegister::FromAllocationIndex(i); |
3767 DoubleRegister reg = | |
3768 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); | |
3769 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); | 3763 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); |
3770 } | 3764 } |
3771 } | 3765 } |
3772 // Get the return address from the stack and restore the frame pointer. | 3766 // Get the return address from the stack and restore the frame pointer. |
3773 movp(rcx, Operand(rbp, kFPOnStackSize)); | 3767 movp(rcx, Operand(rbp, kFPOnStackSize)); |
3774 movp(rbp, Operand(rbp, 0 * kPointerSize)); | 3768 movp(rbp, Operand(rbp, 0 * kPointerSize)); |
3775 | 3769 |
3776 // Drop everything up to and including the arguments and the receiver | 3770 // Drop everything up to and including the arguments and the receiver |
3777 // from the caller stack. | 3771 // from the caller stack. |
3778 leap(rsp, Operand(r15, 1 * kPointerSize)); | 3772 leap(rsp, Operand(r15, 1 * kPointerSize)); |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4995 movl(rax, dividend); | 4989 movl(rax, dividend); |
4996 shrl(rax, Immediate(31)); | 4990 shrl(rax, Immediate(31)); |
4997 addl(rdx, rax); | 4991 addl(rdx, rax); |
4998 } | 4992 } |
4999 | 4993 |
5000 | 4994 |
5001 } // namespace internal | 4995 } // namespace internal |
5002 } // namespace v8 | 4996 } // namespace v8 |
5003 | 4997 |
5004 #endif // V8_TARGET_ARCH_X64 | 4998 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |