| 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 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 namespace compiler { | 12 namespace compiler { |
| 13 | 13 |
| 14 // Collects the spill slot requirements and the allocated general and double | 14 // Collects the spill slot requirements and the allocated general and double |
| 15 // registers for a compiled function. Frames are usually populated by the | 15 // registers for a compiled function. Frames are usually populated by the |
| 16 // register allocator and are used by Linkage to generate code for the prologue | 16 // register allocator and are used by Linkage to generate code for the prologue |
| 17 // and epilogue to compiled code. | 17 // and epilogue to compiled code. |
| 18 class Frame : public ZoneObject { | 18 class Frame : public ZoneObject { |
| 19 public: | 19 public: |
| 20 Frame() | 20 Frame() |
| 21 : register_save_area_size_(0), | 21 : register_save_area_size_(0), |
| 22 spill_slot_count_(0), | 22 spill_slot_count_(0), |
| 23 osr_stack_slot_count_(0), | 23 osr_stack_slot_count_(0), |
| 24 allocated_registers_(NULL), | 24 allocated_registers_(NULL), |
| 25 allocated_double_registers_(NULL), | 25 allocated_double_registers_(NULL) {} |
| 26 pc_on_stack_(true) {} | |
| 27 | 26 |
| 28 inline int GetSpillSlotCount() { return spill_slot_count_; } | 27 inline int GetSpillSlotCount() { return spill_slot_count_; } |
| 29 | 28 |
| 30 void SetAllocatedRegisters(BitVector* regs) { | 29 void SetAllocatedRegisters(BitVector* regs) { |
| 31 DCHECK(allocated_registers_ == NULL); | 30 DCHECK(allocated_registers_ == NULL); |
| 32 allocated_registers_ = regs; | 31 allocated_registers_ = regs; |
| 33 } | 32 } |
| 34 | 33 |
| 35 void SetAllocatedDoubleRegisters(BitVector* regs) { | 34 void SetAllocatedDoubleRegisters(BitVector* regs) { |
| 36 DCHECK(allocated_double_registers_ == NULL); | 35 DCHECK(allocated_double_registers_ == NULL); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 spill_slot_count_ |= 1; | 64 spill_slot_count_ |= 1; |
| 66 } | 65 } |
| 67 return spill_slot_count_++; | 66 return spill_slot_count_++; |
| 68 } | 67 } |
| 69 | 68 |
| 70 void ReserveSpillSlots(size_t slot_count) { | 69 void ReserveSpillSlots(size_t slot_count) { |
| 71 DCHECK_EQ(0, spill_slot_count_); // can only reserve before allocation. | 70 DCHECK_EQ(0, spill_slot_count_); // can only reserve before allocation. |
| 72 spill_slot_count_ = static_cast<int>(slot_count); | 71 spill_slot_count_ = static_cast<int>(slot_count); |
| 73 } | 72 } |
| 74 | 73 |
| 75 void SetPCOnStack(bool val) { pc_on_stack_ = val; } | |
| 76 | |
| 77 int PCOnStackSize() { return pc_on_stack_ ? kRegisterSize : 0; } | |
| 78 | |
| 79 private: | 74 private: |
| 80 int register_save_area_size_; | 75 int register_save_area_size_; |
| 81 int spill_slot_count_; | 76 int spill_slot_count_; |
| 82 int osr_stack_slot_count_; | 77 int osr_stack_slot_count_; |
| 83 BitVector* allocated_registers_; | 78 BitVector* allocated_registers_; |
| 84 BitVector* allocated_double_registers_; | 79 BitVector* allocated_double_registers_; |
| 85 bool pc_on_stack_; | |
| 86 | 80 |
| 87 DISALLOW_COPY_AND_ASSIGN(Frame); | 81 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 88 }; | 82 }; |
| 89 | 83 |
| 90 | 84 |
| 91 // Represents an offset from either the stack pointer or frame pointer. | 85 // Represents an offset from either the stack pointer or frame pointer. |
| 92 class FrameOffset { | 86 class FrameOffset { |
| 93 public: | 87 public: |
| 94 inline bool from_stack_pointer() { return (offset_ & 1) == kFromSp; } | 88 inline bool from_stack_pointer() { return (offset_ & 1) == kFromSp; } |
| 95 inline bool from_frame_pointer() { return (offset_ & 1) == kFromFp; } | 89 inline bool from_frame_pointer() { return (offset_ & 1) == kFromFp; } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 111 int offset_; // Encodes SP or FP in the low order bit. | 105 int offset_; // Encodes SP or FP in the low order bit. |
| 112 | 106 |
| 113 static const int kFromSp = 1; | 107 static const int kFromSp = 1; |
| 114 static const int kFromFp = 0; | 108 static const int kFromFp = 0; |
| 115 }; | 109 }; |
| 116 } | 110 } |
| 117 } | 111 } |
| 118 } // namespace v8::internal::compiler | 112 } // namespace v8::internal::compiler |
| 119 | 113 |
| 120 #endif // V8_COMPILER_FRAME_H_ | 114 #endif // V8_COMPILER_FRAME_H_ |
| OLD | NEW |