| 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 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 | 3699 |
| 3698 | 3700 |
| 3699 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, | 3701 void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, |
| 3700 bool save_doubles) { | 3702 bool save_doubles) { |
| 3701 #ifdef _WIN64 | 3703 #ifdef _WIN64 |
| 3702 const int kShadowSpace = 4; | 3704 const int kShadowSpace = 4; |
| 3703 arg_stack_space += kShadowSpace; | 3705 arg_stack_space += kShadowSpace; |
| 3704 #endif | 3706 #endif |
| 3705 // Optionally save all XMM registers. | 3707 // Optionally save all XMM registers. |
| 3706 if (save_doubles) { | 3708 if (save_doubles) { |
| 3707 int space = XMMRegister::kMaxNumAllocatableRegisters * kDoubleSize + | 3709 int space = XMMRegister::kMaxNumRegisters * kDoubleSize + |
| 3708 arg_stack_space * kRegisterSize; | 3710 arg_stack_space * kRegisterSize; |
| 3709 subp(rsp, Immediate(space)); | 3711 subp(rsp, Immediate(space)); |
| 3710 int offset = -2 * kPointerSize; | 3712 int offset = -2 * kPointerSize; |
| 3711 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 3713 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); |
| 3712 XMMRegister reg = XMMRegister::FromAllocationIndex(i); | 3714 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
| 3715 DoubleRegister reg = |
| 3716 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); |
| 3713 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); | 3717 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); |
| 3714 } | 3718 } |
| 3715 } else if (arg_stack_space > 0) { | 3719 } else if (arg_stack_space > 0) { |
| 3716 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); | 3720 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); |
| 3717 } | 3721 } |
| 3718 | 3722 |
| 3719 // Get the required frame alignment for the OS. | 3723 // Get the required frame alignment for the OS. |
| 3720 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); | 3724 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); |
| 3721 if (kFrameAlignment > 0) { | 3725 if (kFrameAlignment > 0) { |
| 3722 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); | 3726 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 3745 EnterExitFramePrologue(false); | 3749 EnterExitFramePrologue(false); |
| 3746 EnterExitFrameEpilogue(arg_stack_space, false); | 3750 EnterExitFrameEpilogue(arg_stack_space, false); |
| 3747 } | 3751 } |
| 3748 | 3752 |
| 3749 | 3753 |
| 3750 void MacroAssembler::LeaveExitFrame(bool save_doubles) { | 3754 void MacroAssembler::LeaveExitFrame(bool save_doubles) { |
| 3751 // Registers: | 3755 // Registers: |
| 3752 // r15 : argv | 3756 // r15 : argv |
| 3753 if (save_doubles) { | 3757 if (save_doubles) { |
| 3754 int offset = -2 * kPointerSize; | 3758 int offset = -2 * kPointerSize; |
| 3755 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { | 3759 const RegisterConfiguration* config = RegisterConfiguration::ArchDefault(); |
| 3756 XMMRegister reg = XMMRegister::FromAllocationIndex(i); | 3760 for (int i = 0; i < config->num_allocatable_double_registers(); ++i) { |
| 3761 DoubleRegister reg = |
| 3762 DoubleRegister::from_code(config->GetAllocatableDoubleCode(i)); |
| 3757 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); | 3763 movsd(reg, Operand(rbp, offset - ((i + 1) * kDoubleSize))); |
| 3758 } | 3764 } |
| 3759 } | 3765 } |
| 3760 // 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. |
| 3761 movp(rcx, Operand(rbp, kFPOnStackSize)); | 3767 movp(rcx, Operand(rbp, kFPOnStackSize)); |
| 3762 movp(rbp, Operand(rbp, 0 * kPointerSize)); | 3768 movp(rbp, Operand(rbp, 0 * kPointerSize)); |
| 3763 | 3769 |
| 3764 // Drop everything up to and including the arguments and the receiver | 3770 // Drop everything up to and including the arguments and the receiver |
| 3765 // from the caller stack. | 3771 // from the caller stack. |
| 3766 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... |
| 4983 movl(rax, dividend); | 4989 movl(rax, dividend); |
| 4984 shrl(rax, Immediate(31)); | 4990 shrl(rax, Immediate(31)); |
| 4985 addl(rdx, rax); | 4991 addl(rdx, rax); |
| 4986 } | 4992 } |
| 4987 | 4993 |
| 4988 | 4994 |
| 4989 } // namespace internal | 4995 } // namespace internal |
| 4990 } // namespace v8 | 4996 } // namespace v8 |
| 4991 | 4997 |
| 4992 #endif // V8_TARGET_ARCH_X64 | 4998 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |