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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
| 9 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 11 #include "src/codegen.h" |
11 #include "src/cpu-profiler.h" | 12 #include "src/cpu-profiler.h" |
12 #include "src/debug.h" | 13 #include "src/debug.h" |
13 #include "src/heap/heap.h" | 14 #include "src/heap/heap.h" |
14 #include "src/isolate-inl.h" | 15 #include "src/isolate-inl.h" |
15 #include "src/serialize.h" | 16 #include "src/serialize.h" |
16 #include "src/x64/assembler-x64.h" | 17 #include "src/x64/assembler-x64.h" |
17 #include "src/x64/macro-assembler-x64.h" | 18 #include "src/x64/macro-assembler-x64.h" |
18 | 19 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 Abort(reason); | 538 Abort(reason); |
538 // Control will not return here. | 539 // Control will not return here. |
539 bind(&L); | 540 bind(&L); |
540 } | 541 } |
541 | 542 |
542 | 543 |
543 void MacroAssembler::CheckStackAlignment() { | 544 void MacroAssembler::CheckStackAlignment() { |
544 int frame_alignment = base::OS::ActivationFrameAlignment(); | 545 int frame_alignment = base::OS::ActivationFrameAlignment(); |
545 int frame_alignment_mask = frame_alignment - 1; | 546 int frame_alignment_mask = frame_alignment - 1; |
546 if (frame_alignment > kPointerSize) { | 547 if (frame_alignment > kPointerSize) { |
547 DCHECK(IsPowerOf2(frame_alignment)); | 548 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
548 Label alignment_as_expected; | 549 Label alignment_as_expected; |
549 testp(rsp, Immediate(frame_alignment_mask)); | 550 testp(rsp, Immediate(frame_alignment_mask)); |
550 j(zero, &alignment_as_expected, Label::kNear); | 551 j(zero, &alignment_as_expected, Label::kNear); |
551 // Abort if stack is not aligned. | 552 // Abort if stack is not aligned. |
552 int3(); | 553 int3(); |
553 bind(&alignment_as_expected); | 554 bind(&alignment_as_expected); |
554 } | 555 } |
555 } | 556 } |
556 | 557 |
557 | 558 |
(...skipping 3536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4094 XMMRegister reg = XMMRegister::FromAllocationIndex(i); | 4095 XMMRegister reg = XMMRegister::FromAllocationIndex(i); |
4095 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); | 4096 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); |
4096 } | 4097 } |
4097 } else if (arg_stack_space > 0) { | 4098 } else if (arg_stack_space > 0) { |
4098 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); | 4099 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); |
4099 } | 4100 } |
4100 | 4101 |
4101 // Get the required frame alignment for the OS. | 4102 // Get the required frame alignment for the OS. |
4102 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); | 4103 const int kFrameAlignment = base::OS::ActivationFrameAlignment(); |
4103 if (kFrameAlignment > 0) { | 4104 if (kFrameAlignment > 0) { |
4104 DCHECK(IsPowerOf2(kFrameAlignment)); | 4105 DCHECK(base::bits::IsPowerOfTwo32(kFrameAlignment)); |
4105 DCHECK(is_int8(kFrameAlignment)); | 4106 DCHECK(is_int8(kFrameAlignment)); |
4106 andp(rsp, Immediate(-kFrameAlignment)); | 4107 andp(rsp, Immediate(-kFrameAlignment)); |
4107 } | 4108 } |
4108 | 4109 |
4109 // Patch the saved entry sp. | 4110 // Patch the saved entry sp. |
4110 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp); | 4111 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp); |
4111 } | 4112 } |
4112 | 4113 |
4113 | 4114 |
4114 void MacroAssembler::EnterExitFrame(int arg_stack_space, bool save_doubles) { | 4115 void MacroAssembler::EnterExitFrame(int arg_stack_space, bool save_doubles) { |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4983 } | 4984 } |
4984 | 4985 |
4985 | 4986 |
4986 void MacroAssembler::PrepareCallCFunction(int num_arguments) { | 4987 void MacroAssembler::PrepareCallCFunction(int num_arguments) { |
4987 int frame_alignment = base::OS::ActivationFrameAlignment(); | 4988 int frame_alignment = base::OS::ActivationFrameAlignment(); |
4988 DCHECK(frame_alignment != 0); | 4989 DCHECK(frame_alignment != 0); |
4989 DCHECK(num_arguments >= 0); | 4990 DCHECK(num_arguments >= 0); |
4990 | 4991 |
4991 // Make stack end at alignment and allocate space for arguments and old rsp. | 4992 // Make stack end at alignment and allocate space for arguments and old rsp. |
4992 movp(kScratchRegister, rsp); | 4993 movp(kScratchRegister, rsp); |
4993 DCHECK(IsPowerOf2(frame_alignment)); | 4994 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
4994 int argument_slots_on_stack = | 4995 int argument_slots_on_stack = |
4995 ArgumentStackSlotsForCFunctionCall(num_arguments); | 4996 ArgumentStackSlotsForCFunctionCall(num_arguments); |
4996 subp(rsp, Immediate((argument_slots_on_stack + 1) * kRegisterSize)); | 4997 subp(rsp, Immediate((argument_slots_on_stack + 1) * kRegisterSize)); |
4997 andp(rsp, Immediate(-frame_alignment)); | 4998 andp(rsp, Immediate(-frame_alignment)); |
4998 movp(Operand(rsp, argument_slots_on_stack * kRegisterSize), kScratchRegister); | 4999 movp(Operand(rsp, argument_slots_on_stack * kRegisterSize), kScratchRegister); |
4999 } | 5000 } |
5000 | 5001 |
5001 | 5002 |
5002 void MacroAssembler::CallCFunction(ExternalReference function, | 5003 void MacroAssembler::CallCFunction(ExternalReference function, |
5003 int num_arguments) { | 5004 int num_arguments) { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5375 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5376 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); |
5376 movl(rax, dividend); | 5377 movl(rax, dividend); |
5377 shrl(rax, Immediate(31)); | 5378 shrl(rax, Immediate(31)); |
5378 addl(rdx, rax); | 5379 addl(rdx, rax); |
5379 } | 5380 } |
5380 | 5381 |
5381 | 5382 |
5382 } } // namespace v8::internal | 5383 } } // namespace v8::internal |
5383 | 5384 |
5384 #endif // V8_TARGET_ARCH_X64 | 5385 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |