| 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) {} | 
|   26  |   27  | 
|   27   inline int GetSpillSlotCount() { return spill_slot_count_; } |   28   inline int GetSpillSlotCount() { return spill_slot_count_; } | 
|   28  |   29  | 
|   29   void SetAllocatedRegisters(BitVector* regs) { |   30   void SetAllocatedRegisters(BitVector* regs) { | 
|   30     DCHECK(allocated_registers_ == NULL); |   31     DCHECK(allocated_registers_ == NULL); | 
|   31     allocated_registers_ = regs; |   32     allocated_registers_ = regs; | 
|   32   } |   33   } | 
|   33  |   34  | 
|   34   void SetAllocatedDoubleRegisters(BitVector* regs) { |   35   void SetAllocatedDoubleRegisters(BitVector* regs) { | 
|   35     DCHECK(allocated_double_registers_ == NULL); |   36     DCHECK(allocated_double_registers_ == NULL); | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|   64       spill_slot_count_ |= 1; |   65       spill_slot_count_ |= 1; | 
|   65     } |   66     } | 
|   66     return spill_slot_count_++; |   67     return spill_slot_count_++; | 
|   67   } |   68   } | 
|   68  |   69  | 
|   69   void ReserveSpillSlots(size_t slot_count) { |   70   void ReserveSpillSlots(size_t slot_count) { | 
|   70     DCHECK_EQ(0, spill_slot_count_);  // can only reserve before allocation. |   71     DCHECK_EQ(0, spill_slot_count_);  // can only reserve before allocation. | 
|   71     spill_slot_count_ = static_cast<int>(slot_count); |   72     spill_slot_count_ = static_cast<int>(slot_count); | 
|   72   } |   73   } | 
|   73  |   74  | 
 |   75   void SetPCOnStack(bool val) { pc_on_stack_ = val; } | 
 |   76  | 
 |   77   int PCOnStackSize() { return pc_on_stack_ ? kRegisterSize : 0; } | 
 |   78  | 
|   74  private: |   79  private: | 
|   75   int register_save_area_size_; |   80   int register_save_area_size_; | 
|   76   int spill_slot_count_; |   81   int spill_slot_count_; | 
|   77   int osr_stack_slot_count_; |   82   int osr_stack_slot_count_; | 
|   78   BitVector* allocated_registers_; |   83   BitVector* allocated_registers_; | 
|   79   BitVector* allocated_double_registers_; |   84   BitVector* allocated_double_registers_; | 
 |   85   bool pc_on_stack_; | 
|   80  |   86  | 
|   81   DISALLOW_COPY_AND_ASSIGN(Frame); |   87   DISALLOW_COPY_AND_ASSIGN(Frame); | 
|   82 }; |   88 }; | 
|   83  |   89  | 
|   84  |   90  | 
|   85 // Represents an offset from either the stack pointer or frame pointer. |   91 // Represents an offset from either the stack pointer or frame pointer. | 
|   86 class FrameOffset { |   92 class FrameOffset { | 
|   87  public: |   93  public: | 
|   88   inline bool from_stack_pointer() { return (offset_ & 1) == kFromSp; } |   94   inline bool from_stack_pointer() { return (offset_ & 1) == kFromSp; } | 
|   89   inline bool from_frame_pointer() { return (offset_ & 1) == kFromFp; } |   95   inline bool from_frame_pointer() { return (offset_ & 1) == kFromFp; } | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  105   int offset_;  // Encodes SP or FP in the low order bit. |  111   int offset_;  // Encodes SP or FP in the low order bit. | 
|  106  |  112  | 
|  107   static const int kFromSp = 1; |  113   static const int kFromSp = 1; | 
|  108   static const int kFromFp = 0; |  114   static const int kFromFp = 0; | 
|  109 }; |  115 }; | 
|  110 } |  116 } | 
|  111 } |  117 } | 
|  112 }  // namespace v8::internal::compiler |  118 }  // namespace v8::internal::compiler | 
|  113  |  119  | 
|  114 #endif  // V8_COMPILER_FRAME_H_ |  120 #endif  // V8_COMPILER_FRAME_H_ | 
| OLD | NEW |