| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_FRAME_H_ | 5 #ifndef V8_COMPILER_FRAME_H_ |
| 6 #define V8_COMPILER_FRAME_H_ | 6 #define V8_COMPILER_FRAME_H_ |
| 7 | 7 |
| 8 #include "src/bit-vector.h" | 8 #include "src/bit-vector.h" |
| 9 #include "src/frames.h" | 9 #include "src/frames.h" |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 spill_slot_count_ += delta; | 107 spill_slot_count_ += delta; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void AllocateSavedCalleeRegisterSlots(int count) { | 110 void AllocateSavedCalleeRegisterSlots(int count) { |
| 111 frame_slot_count_ += count; | 111 frame_slot_count_ += count; |
| 112 } | 112 } |
| 113 | 113 |
| 114 int AllocateSpillSlot(int width) { | 114 int AllocateSpillSlot(int width) { |
| 115 int frame_slot_count_before = frame_slot_count_; | 115 int frame_slot_count_before = frame_slot_count_; |
| 116 int slot = AllocateAlignedFrameSlot(width); | 116 AllocateAlignedFrameSlots(width); |
| 117 spill_slot_count_ += (frame_slot_count_ - frame_slot_count_before); | 117 spill_slot_count_ += frame_slot_count_ - frame_slot_count_before; |
| 118 return slot; | 118 return frame_slot_count_ - 1; |
| 119 } | 119 } |
| 120 | 120 |
| 121 int AlignFrame(int alignment = kDoubleSize); | 121 int AlignFrame(int alignment = kDoubleSize); |
| 122 | 122 |
| 123 int ReserveSpillSlots(size_t slot_count) { | 123 int ReserveSpillSlots(size_t slot_count) { |
| 124 DCHECK_EQ(0, spill_slot_count_); | 124 DCHECK_EQ(0, spill_slot_count_); |
| 125 spill_slot_count_ += static_cast<int>(slot_count); | 125 spill_slot_count_ += static_cast<int>(slot_count); |
| 126 frame_slot_count_ += static_cast<int>(slot_count); | 126 frame_slot_count_ += static_cast<int>(slot_count); |
| 127 return frame_slot_count_ - 1; | 127 return frame_slot_count_ - 1; |
| 128 } | 128 } |
| 129 | 129 |
| 130 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; | 130 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; |
| 131 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; | 131 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 int AllocateAlignedFrameSlot(int width) { | 134 void AllocateAlignedFrameSlots(int width) { |
| 135 DCHECK(width == 4 || width == 8 || width == 16); | 135 DCHECK_LT(0, width); |
| 136 if (kPointerSize == 4) { | 136 int new_frame_slots = (width + kPointerSize - 1) / kPointerSize; |
| 137 // Skip one slot if necessary. | 137 // Align to 8 bytes if width is a multiple of 8 bytes, and to 16 bytes if |
| 138 if (width > kPointerSize) { | 138 // multiple of 16. |
| 139 frame_slot_count_++; | 139 int align_to = (width & 15) == 0 ? 16 : (width & 7) == 0 ? 8 : kPointerSize; |
| 140 frame_slot_count_ |= 1; | 140 frame_slot_count_ = |
| 141 // 2 extra slots if width == 16. | 141 RoundUp(frame_slot_count_ + new_frame_slots, align_to / kPointerSize); |
| 142 frame_slot_count_ += (width & 16) / 8; | 142 DCHECK_LT(0, frame_slot_count_); |
| 143 } | |
| 144 } else { | |
| 145 // No alignment when slots are 8 bytes. | |
| 146 DCHECK_EQ(8, kPointerSize); | |
| 147 // 1 extra slot if width == 16. | |
| 148 frame_slot_count_ += (width & 16) / 16; | |
| 149 } | |
| 150 return frame_slot_count_++; | |
| 151 } | 143 } |
| 152 | 144 |
| 153 private: | 145 private: |
| 154 int frame_slot_count_; | 146 int frame_slot_count_; |
| 155 int spill_slot_count_; | 147 int spill_slot_count_; |
| 156 BitVector* allocated_registers_; | 148 BitVector* allocated_registers_; |
| 157 BitVector* allocated_double_registers_; | 149 BitVector* allocated_double_registers_; |
| 158 | 150 |
| 159 DISALLOW_COPY_AND_ASSIGN(Frame); | 151 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 160 }; | 152 }; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 const Frame* const frame_; | 223 const Frame* const frame_; |
| 232 bool access_frame_with_fp_; | 224 bool access_frame_with_fp_; |
| 233 int sp_delta_; | 225 int sp_delta_; |
| 234 bool has_frame_; | 226 bool has_frame_; |
| 235 }; | 227 }; |
| 236 } // namespace compiler | 228 } // namespace compiler |
| 237 } // namespace internal | 229 } // namespace internal |
| 238 } // namespace v8 | 230 } // namespace v8 |
| 239 | 231 |
| 240 #endif // V8_COMPILER_FRAME_H_ | 232 #endif // V8_COMPILER_FRAME_H_ |
| OLD | NEW |