OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/frame.h" | 5 #include "src/compiler/frame.h" |
6 | 6 |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/register-allocator.h" | 8 #include "src/compiler/register-allocator.h" |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 namespace compiler { | 13 namespace compiler { |
14 | 14 |
15 Frame::Frame(int fixed_frame_size_in_slots, const CallDescriptor* descriptor) | 15 Frame::Frame(int fixed_frame_size_in_slots, const CallDescriptor* descriptor) |
16 : needs_frame_((descriptor != nullptr) && | 16 : needs_frame_((descriptor != nullptr) && |
17 descriptor->RequiresFrameAsIncoming()), | 17 descriptor->RequiresFrameAsIncoming()), |
18 frame_slot_count_(fixed_frame_size_in_slots), | 18 frame_slot_count_(fixed_frame_size_in_slots), |
19 callee_saved_slot_count_(0), | 19 callee_saved_slot_count_(0), |
20 spill_slot_count_(0), | 20 spill_slot_count_(0), |
21 allocated_registers_(nullptr), | 21 allocated_registers_(nullptr), |
22 allocated_double_registers_(nullptr) {} | 22 allocated_double_registers_(nullptr) {} |
23 | 23 |
| 24 int Frame::AlignFrame(int alignment) { |
| 25 DCHECK_EQ(0, callee_saved_slot_count_); |
| 26 int alignment_slots = alignment / kPointerSize; |
| 27 int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1)); |
| 28 if (delta != alignment_slots) { |
| 29 frame_slot_count_ += delta; |
| 30 if (spill_slot_count_ != 0) { |
| 31 spill_slot_count_ += delta; |
| 32 } |
| 33 } |
| 34 return delta; |
| 35 } |
24 | 36 |
25 void FrameAccessState::SetFrameAccessToDefault() { | 37 void FrameAccessState::SetFrameAccessToDefault() { |
26 if (frame()->needs_frame() && !FLAG_turbo_sp_frame_access) { | 38 if (frame()->needs_frame() && !FLAG_turbo_sp_frame_access) { |
27 SetFrameAccessToFP(); | 39 SetFrameAccessToFP(); |
28 } else { | 40 } else { |
29 SetFrameAccessToSP(); | 41 SetFrameAccessToSP(); |
30 } | 42 } |
31 } | 43 } |
32 | 44 |
33 | 45 |
34 FrameOffset FrameAccessState::GetFrameOffset(int spill_slot) const { | 46 FrameOffset FrameAccessState::GetFrameOffset(int spill_slot) const { |
35 const int offset = | 47 const int offset = |
36 (StandardFrameConstants::kFixedSlotCountAboveFp - spill_slot - 1) * | 48 (StandardFrameConstants::kFixedSlotCountAboveFp - spill_slot - 1) * |
37 kPointerSize; | 49 kPointerSize; |
38 if (access_frame_with_fp()) { | 50 if (access_frame_with_fp()) { |
39 DCHECK(frame()->needs_frame()); | 51 DCHECK(frame()->needs_frame()); |
40 return FrameOffset::FromFramePointer(offset); | 52 return FrameOffset::FromFramePointer(offset); |
41 } else { | 53 } else { |
42 // No frame. Retrieve all parameters relative to stack pointer. | 54 // No frame. Retrieve all parameters relative to stack pointer. |
43 int sp_offset = | 55 int sp_offset = |
44 offset + ((frame()->GetSpToFpSlotCount() + sp_delta()) * kPointerSize); | 56 offset + ((frame()->GetSpToFpSlotCount() + sp_delta()) * kPointerSize); |
45 return FrameOffset::FromStackPointer(sp_offset); | 57 return FrameOffset::FromStackPointer(sp_offset); |
46 } | 58 } |
47 } | 59 } |
48 | 60 |
49 | 61 |
50 } // namespace compiler | 62 } // namespace compiler |
51 } // namespace internal | 63 } // namespace internal |
52 } // namespace v8 | 64 } // namespace v8 |
OLD | NEW |