Chromium Code Reviews| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 int AlignFrame(int alignment = kDoubleSize); | 128 int AlignFrame(int alignment = kDoubleSize); |
| 129 | 129 |
| 130 int ReserveSpillSlots(size_t slot_count) { | 130 int ReserveSpillSlots(size_t slot_count) { |
| 131 DCHECK_EQ(0, callee_saved_slot_count_); | 131 DCHECK_EQ(0, callee_saved_slot_count_); |
| 132 DCHECK_EQ(0, spill_slot_count_); | 132 DCHECK_EQ(0, spill_slot_count_); |
| 133 spill_slot_count_ += static_cast<int>(slot_count); | 133 spill_slot_count_ += static_cast<int>(slot_count); |
| 134 frame_slot_count_ += static_cast<int>(slot_count); | 134 frame_slot_count_ += static_cast<int>(slot_count); |
| 135 return frame_slot_count_ - 1; | 135 return frame_slot_count_ - 1; |
| 136 } | 136 } |
| 137 | 137 |
| 138 int stack_shrink_slots() const { return stack_shrink_slots_; } | |
| 139 void set_stack_shrink_slots(int value) { stack_shrink_slots_ = value; } | |
| 140 | |
| 138 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; | 141 static const int kContextSlot = 2 + StandardFrameConstants::kCPSlotCount; |
| 139 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; | 142 static const int kJSFunctionSlot = 3 + StandardFrameConstants::kCPSlotCount; |
| 140 | 143 |
| 141 private: | 144 private: |
| 142 int AllocateAlignedFrameSlot(int width) { | 145 int AllocateAlignedFrameSlot(int width) { |
| 143 DCHECK(width == 4 || width == 8); | 146 DCHECK(width == 4 || width == 8); |
| 144 // Skip one slot if necessary. | 147 // Skip one slot if necessary. |
| 145 if (width > kPointerSize) { | 148 if (width > kPointerSize) { |
| 146 DCHECK(width == kPointerSize * 2); | 149 DCHECK(width == kPointerSize * 2); |
| 147 frame_slot_count_++; | 150 frame_slot_count_++; |
| 148 frame_slot_count_ |= 1; | 151 frame_slot_count_ |= 1; |
| 149 } | 152 } |
| 150 return frame_slot_count_++; | 153 return frame_slot_count_++; |
| 151 } | 154 } |
| 152 | 155 |
| 153 private: | 156 private: |
| 154 int frame_slot_count_; | 157 int frame_slot_count_; |
| 155 int callee_saved_slot_count_; | 158 int callee_saved_slot_count_; |
| 156 int spill_slot_count_; | 159 int spill_slot_count_; |
| 160 int stack_shrink_slots_; | |
|
danno
2016/04/01 15:56:26
I don't think this has to/should be separate from,
Mircea Trofin
2016/04/01 18:27:39
Do we even have a reason to handle callee saved re
Mircea Trofin
2016/04/16 04:25:10
Done, except with the moving of the callee saved r
| |
| 157 BitVector* allocated_registers_; | 161 BitVector* allocated_registers_; |
| 158 BitVector* allocated_double_registers_; | 162 BitVector* allocated_double_registers_; |
| 159 | 163 |
| 160 DISALLOW_COPY_AND_ASSIGN(Frame); | 164 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 | 167 |
| 164 // Represents an offset from either the stack pointer or frame pointer. | 168 // Represents an offset from either the stack pointer or frame pointer. |
| 165 class FrameOffset { | 169 class FrameOffset { |
| 166 public: | 170 public: |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 184 int offset_; // Encodes SP or FP in the low order bit. | 188 int offset_; // Encodes SP or FP in the low order bit. |
| 185 | 189 |
| 186 static const int kFromSp = 1; | 190 static const int kFromSp = 1; |
| 187 static const int kFromFp = 0; | 191 static const int kFromFp = 0; |
| 188 }; | 192 }; |
| 189 | 193 |
| 190 // Encapsulates the mutable state maintained during code generation about the | 194 // Encapsulates the mutable state maintained during code generation about the |
| 191 // current function's frame. | 195 // current function's frame. |
| 192 class FrameAccessState : public ZoneObject { | 196 class FrameAccessState : public ZoneObject { |
| 193 public: | 197 public: |
| 194 explicit FrameAccessState(Frame* const frame) | 198 explicit FrameAccessState(const Frame* const frame) |
| 195 : frame_(frame), | 199 : frame_(frame), |
| 196 access_frame_with_fp_(false), | 200 access_frame_with_fp_(false), |
| 197 sp_delta_(0), | 201 sp_delta_(0), |
| 198 has_frame_(false) {} | 202 has_frame_(false) {} |
| 199 | 203 |
| 200 Frame* frame() const { return frame_; } | 204 const Frame* frame() const { return frame_; } |
| 201 void MarkHasFrame(bool state); | 205 void MarkHasFrame(bool state); |
| 202 | 206 |
| 203 int sp_delta() const { return sp_delta_; } | 207 int sp_delta() const { return sp_delta_; } |
| 204 void ClearSPDelta() { sp_delta_ = 0; } | 208 void ClearSPDelta() { sp_delta_ = 0; } |
| 205 void IncreaseSPDelta(int amount) { sp_delta_ += amount; } | 209 void IncreaseSPDelta(int amount) { sp_delta_ += amount; } |
| 206 | 210 |
| 207 bool access_frame_with_fp() const { return access_frame_with_fp_; } | 211 bool access_frame_with_fp() const { return access_frame_with_fp_; } |
| 208 | 212 |
| 209 // Regardless of how we access slots on the stack - using sp or fp - do we | 213 // Regardless of how we access slots on the stack - using sp or fp - do we |
| 210 // have a frame, at the current stage in code generation. | 214 // have a frame, at the current stage in code generation. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 222 } | 226 } |
| 223 int GetSPToFPOffset() const { return GetSPToFPSlotCount() * kPointerSize; } | 227 int GetSPToFPOffset() const { return GetSPToFPSlotCount() * kPointerSize; } |
| 224 | 228 |
| 225 // Get the frame offset for a given spill slot. The location depends on the | 229 // Get the frame offset for a given spill slot. The location depends on the |
| 226 // calling convention and the specific frame layout, and may thus be | 230 // calling convention and the specific frame layout, and may thus be |
| 227 // architecture-specific. Negative spill slots indicate arguments on the | 231 // architecture-specific. Negative spill slots indicate arguments on the |
| 228 // caller's frame. | 232 // caller's frame. |
| 229 FrameOffset GetFrameOffset(int spill_slot) const; | 233 FrameOffset GetFrameOffset(int spill_slot) const; |
| 230 | 234 |
| 231 private: | 235 private: |
| 232 Frame* const frame_; | 236 const Frame* const frame_; |
| 233 bool access_frame_with_fp_; | 237 bool access_frame_with_fp_; |
| 234 int sp_delta_; | 238 int sp_delta_; |
| 235 bool has_frame_; | 239 bool has_frame_; |
| 236 }; | 240 }; |
| 237 } // namespace compiler | 241 } // namespace compiler |
| 238 } // namespace internal | 242 } // namespace internal |
| 239 } // namespace v8 | 243 } // namespace v8 |
| 240 | 244 |
| 241 #endif // V8_COMPILER_FRAME_H_ | 245 #endif // V8_COMPILER_FRAME_H_ |
| OLD | NEW |