| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // -n | | Caller | 52 // -n | | Caller |
| 53 // ... | ... | frame slots | 53 // ... | ... | frame slots |
| 54 // -2 | parameter n-1 | (slot < 0) | 54 // -2 | parameter n-1 | (slot < 0) |
| 55 // |- - - - - - - - -| | | 55 // |- - - - - - - - -| | |
| 56 // -1 | parameter n | v | 56 // -1 | parameter n | v |
| 57 // -----+-----------------+-------------------------------- | 57 // -----+-----------------+-------------------------------- |
| 58 // 0 | return addr | ^ ^ | 58 // 0 | return addr | ^ ^ |
| 59 // |- - - - - - - - -| | | | 59 // |- - - - - - - - -| | | |
| 60 // 1 | saved frame ptr | Fixed | | 60 // 1 | saved frame ptr | Fixed | |
| 61 // |- - - - - - - - -| Header <-- frame ptr | | 61 // |- - - - - - - - -| Header <-- frame ptr | |
| 62 // 2 | Context | | | | 62 // 2 |Context/Frm. Type| | | |
| 63 // |- - - - - - - - -| | | | 63 // |- - - - - - - - -| | | |
| 64 // 3 |JSFunction/Marker| v | | 64 // 3 | [JSFunction] | v | |
| 65 // +-----------------+---- | | 65 // +-----------------+---- | |
| 66 // 4 | spill 1 | ^ Callee | 66 // 4 | spill 1 | ^ Callee |
| 67 // |- - - - - - - - -| | frame slots | 67 // |- - - - - - - - -| | frame slots |
| 68 // ... | ... | Spill slots (slot >= 0) | 68 // ... | ... | Spill slots (slot >= 0) |
| 69 // |- - - - - - - - -| | | | 69 // |- - - - - - - - -| | | |
| 70 // m+3 | spill m | v | | 70 // m+3 | spill m | v | |
| 71 // +-----------------+---- | | 71 // +-----------------+---- | |
| 72 // m+4 | callee-saved 1 | ^ | | 72 // m+4 | callee-saved 1 | ^ | |
| 73 // |- - - - - - - - -| | | | 73 // |- - - - - - - - -| | | |
| 74 // | ... | Callee-saved | | 74 // | ... | Callee-saved | |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 void SetAllocatedDoubleRegisters(BitVector* regs) { | 109 void SetAllocatedDoubleRegisters(BitVector* regs) { |
| 110 DCHECK(allocated_double_registers_ == nullptr); | 110 DCHECK(allocated_double_registers_ == nullptr); |
| 111 allocated_double_registers_ = regs; | 111 allocated_double_registers_ = regs; |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool DidAllocateDoubleRegisters() const { | 114 bool DidAllocateDoubleRegisters() const { |
| 115 return !allocated_double_registers_->IsEmpty(); | 115 return !allocated_double_registers_->IsEmpty(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 int AlignSavedCalleeRegisterSlots() { | 118 int AlignSavedCalleeRegisterSlots(int alignment = kDoubleSize) { |
| 119 DCHECK_EQ(0, callee_saved_slot_count_); | 119 DCHECK_EQ(0, callee_saved_slot_count_); |
| 120 needs_frame_ = true; | 120 int alignment_slots = alignment / kPointerSize; |
| 121 int delta = frame_slot_count_ & 1; | 121 int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1)); |
| 122 frame_slot_count_ += delta; | 122 if (delta != alignment_slots) { |
| 123 DCHECK(needs_frame_); |
| 124 frame_slot_count_ += delta; |
| 125 } |
| 123 return delta; | 126 return delta; |
| 124 } | 127 } |
| 125 | 128 |
| 126 void AllocateSavedCalleeRegisterSlots(int count) { | 129 void AllocateSavedCalleeRegisterSlots(int count) { |
| 127 needs_frame_ = true; | 130 needs_frame_ = true; |
| 128 frame_slot_count_ += count; | 131 frame_slot_count_ += count; |
| 129 callee_saved_slot_count_ += count; | 132 callee_saved_slot_count_ += count; |
| 130 } | 133 } |
| 131 | 134 |
| 132 int AllocateSpillSlot(int width) { | 135 int AllocateSpillSlot(int width) { |
| 133 DCHECK_EQ(0, callee_saved_slot_count_); | 136 DCHECK_EQ(0, callee_saved_slot_count_); |
| 134 needs_frame_ = true; | 137 needs_frame_ = true; |
| 135 int frame_slot_count_before = frame_slot_count_; | 138 int frame_slot_count_before = frame_slot_count_; |
| 136 int slot = AllocateAlignedFrameSlot(width); | 139 int slot = AllocateAlignedFrameSlot(width); |
| 137 spill_slot_count_ += (frame_slot_count_ - frame_slot_count_before); | 140 spill_slot_count_ += (frame_slot_count_ - frame_slot_count_before); |
| 138 return slot; | 141 return slot; |
| 139 } | 142 } |
| 140 | 143 |
| 144 int AlignFrame(int alignment = kDoubleSize); |
| 145 |
| 141 int ReserveSpillSlots(size_t slot_count) { | 146 int ReserveSpillSlots(size_t slot_count) { |
| 142 DCHECK_EQ(0, callee_saved_slot_count_); | 147 DCHECK_EQ(0, callee_saved_slot_count_); |
| 143 DCHECK_EQ(0, spill_slot_count_); | 148 DCHECK_EQ(0, spill_slot_count_); |
| 144 needs_frame_ = true; | 149 needs_frame_ = true; |
| 145 spill_slot_count_ += static_cast<int>(slot_count); | 150 spill_slot_count_ += static_cast<int>(slot_count); |
| 146 frame_slot_count_ += static_cast<int>(slot_count); | 151 frame_slot_count_ += static_cast<int>(slot_count); |
| 147 return frame_slot_count_ - 1; | 152 return frame_slot_count_ - 1; |
| 148 } | 153 } |
| 149 | 154 |
| 150 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; | 155 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 private: | 234 private: |
| 230 Frame* const frame_; | 235 Frame* const frame_; |
| 231 bool access_frame_with_fp_; | 236 bool access_frame_with_fp_; |
| 232 int sp_delta_; | 237 int sp_delta_; |
| 233 }; | 238 }; |
| 234 } // namespace compiler | 239 } // namespace compiler |
| 235 } // namespace internal | 240 } // namespace internal |
| 236 } // namespace v8 | 241 } // namespace v8 |
| 237 | 242 |
| 238 #endif // V8_COMPILER_FRAME_H_ | 243 #endif // V8_COMPILER_FRAME_H_ |
| OLD | NEW |