OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_LITHIUM_ALLOCATOR_H_ | 5 #ifndef V8_LITHIUM_ALLOCATOR_H_ |
6 #define V8_LITHIUM_ALLOCATOR_H_ | 6 #define V8_LITHIUM_ALLOCATOR_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 // Returns a numeric representation of this lifetime position. | 46 // Returns a numeric representation of this lifetime position. |
47 int Value() const { | 47 int Value() const { |
48 return value_; | 48 return value_; |
49 } | 49 } |
50 | 50 |
51 // Returns the index of the instruction to which this lifetime position | 51 // Returns the index of the instruction to which this lifetime position |
52 // corresponds. | 52 // corresponds. |
53 int InstructionIndex() const { | 53 int InstructionIndex() const { |
54 ASSERT(IsValid()); | 54 DCHECK(IsValid()); |
55 return value_ / kStep; | 55 return value_ / kStep; |
56 } | 56 } |
57 | 57 |
58 // Returns true if this lifetime position corresponds to the instruction | 58 // Returns true if this lifetime position corresponds to the instruction |
59 // start. | 59 // start. |
60 bool IsInstructionStart() const { | 60 bool IsInstructionStart() const { |
61 return (value_ & (kStep - 1)) == 0; | 61 return (value_ & (kStep - 1)) == 0; |
62 } | 62 } |
63 | 63 |
64 // Returns the lifetime position for the start of the instruction which | 64 // Returns the lifetime position for the start of the instruction which |
65 // corresponds to this lifetime position. | 65 // corresponds to this lifetime position. |
66 LifetimePosition InstructionStart() const { | 66 LifetimePosition InstructionStart() const { |
67 ASSERT(IsValid()); | 67 DCHECK(IsValid()); |
68 return LifetimePosition(value_ & ~(kStep - 1)); | 68 return LifetimePosition(value_ & ~(kStep - 1)); |
69 } | 69 } |
70 | 70 |
71 // Returns the lifetime position for the end of the instruction which | 71 // Returns the lifetime position for the end of the instruction which |
72 // corresponds to this lifetime position. | 72 // corresponds to this lifetime position. |
73 LifetimePosition InstructionEnd() const { | 73 LifetimePosition InstructionEnd() const { |
74 ASSERT(IsValid()); | 74 DCHECK(IsValid()); |
75 return LifetimePosition(InstructionStart().Value() + kStep/2); | 75 return LifetimePosition(InstructionStart().Value() + kStep/2); |
76 } | 76 } |
77 | 77 |
78 // Returns the lifetime position for the beginning of the next instruction. | 78 // Returns the lifetime position for the beginning of the next instruction. |
79 LifetimePosition NextInstruction() const { | 79 LifetimePosition NextInstruction() const { |
80 ASSERT(IsValid()); | 80 DCHECK(IsValid()); |
81 return LifetimePosition(InstructionStart().Value() + kStep); | 81 return LifetimePosition(InstructionStart().Value() + kStep); |
82 } | 82 } |
83 | 83 |
84 // Returns the lifetime position for the beginning of the previous | 84 // Returns the lifetime position for the beginning of the previous |
85 // instruction. | 85 // instruction. |
86 LifetimePosition PrevInstruction() const { | 86 LifetimePosition PrevInstruction() const { |
87 ASSERT(IsValid()); | 87 DCHECK(IsValid()); |
88 ASSERT(value_ > 1); | 88 DCHECK(value_ > 1); |
89 return LifetimePosition(InstructionStart().Value() - kStep); | 89 return LifetimePosition(InstructionStart().Value() - kStep); |
90 } | 90 } |
91 | 91 |
92 // Constructs the lifetime position which does not correspond to any | 92 // Constructs the lifetime position which does not correspond to any |
93 // instruction. | 93 // instruction. |
94 LifetimePosition() : value_(-1) {} | 94 LifetimePosition() : value_(-1) {} |
95 | 95 |
96 // Returns true if this lifetime positions corrensponds to some | 96 // Returns true if this lifetime positions corrensponds to some |
97 // instruction. | 97 // instruction. |
98 bool IsValid() const { return value_ != -1; } | 98 bool IsValid() const { return value_ != -1; } |
(...skipping 16 matching lines...) Expand all Loading... |
115 | 115 |
116 int value_; | 116 int value_; |
117 }; | 117 }; |
118 | 118 |
119 | 119 |
120 // Representation of the non-empty interval [start,end[. | 120 // Representation of the non-empty interval [start,end[. |
121 class UseInterval: public ZoneObject { | 121 class UseInterval: public ZoneObject { |
122 public: | 122 public: |
123 UseInterval(LifetimePosition start, LifetimePosition end) | 123 UseInterval(LifetimePosition start, LifetimePosition end) |
124 : start_(start), end_(end), next_(NULL) { | 124 : start_(start), end_(end), next_(NULL) { |
125 ASSERT(start.Value() < end.Value()); | 125 DCHECK(start.Value() < end.Value()); |
126 } | 126 } |
127 | 127 |
128 LifetimePosition start() const { return start_; } | 128 LifetimePosition start() const { return start_; } |
129 LifetimePosition end() const { return end_; } | 129 LifetimePosition end() const { return end_; } |
130 UseInterval* next() const { return next_; } | 130 UseInterval* next() const { return next_; } |
131 | 131 |
132 // Split this interval at the given position without effecting the | 132 // Split this interval at the given position without effecting the |
133 // live range that owns it. The interval must contain the position. | 133 // live range that owns it. The interval must contain the position. |
134 void SplitAt(LifetimePosition pos, Zone* zone); | 134 void SplitAt(LifetimePosition pos, Zone* zone); |
135 | 135 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // live range to the result live range. | 236 // live range to the result live range. |
237 void SplitAt(LifetimePosition position, LiveRange* result, Zone* zone); | 237 void SplitAt(LifetimePosition position, LiveRange* result, Zone* zone); |
238 | 238 |
239 RegisterKind Kind() const { return kind_; } | 239 RegisterKind Kind() const { return kind_; } |
240 bool HasRegisterAssigned() const { | 240 bool HasRegisterAssigned() const { |
241 return assigned_register_ != kInvalidAssignment; | 241 return assigned_register_ != kInvalidAssignment; |
242 } | 242 } |
243 bool IsSpilled() const { return spilled_; } | 243 bool IsSpilled() const { return spilled_; } |
244 | 244 |
245 LOperand* current_hint_operand() const { | 245 LOperand* current_hint_operand() const { |
246 ASSERT(current_hint_operand_ == FirstHint()); | 246 DCHECK(current_hint_operand_ == FirstHint()); |
247 return current_hint_operand_; | 247 return current_hint_operand_; |
248 } | 248 } |
249 LOperand* FirstHint() const { | 249 LOperand* FirstHint() const { |
250 UsePosition* pos = first_pos_; | 250 UsePosition* pos = first_pos_; |
251 while (pos != NULL && !pos->HasHint()) pos = pos->next(); | 251 while (pos != NULL && !pos->HasHint()) pos = pos->next(); |
252 if (pos != NULL) return pos->hint(); | 252 if (pos != NULL) return pos->hint(); |
253 return NULL; | 253 return NULL; |
254 } | 254 } |
255 | 255 |
256 LifetimePosition Start() const { | 256 LifetimePosition Start() const { |
257 ASSERT(!IsEmpty()); | 257 DCHECK(!IsEmpty()); |
258 return first_interval()->start(); | 258 return first_interval()->start(); |
259 } | 259 } |
260 | 260 |
261 LifetimePosition End() const { | 261 LifetimePosition End() const { |
262 ASSERT(!IsEmpty()); | 262 DCHECK(!IsEmpty()); |
263 return last_interval_->end(); | 263 return last_interval_->end(); |
264 } | 264 } |
265 | 265 |
266 bool HasAllocatedSpillOperand() const; | 266 bool HasAllocatedSpillOperand() const; |
267 LOperand* GetSpillOperand() const { return spill_operand_; } | 267 LOperand* GetSpillOperand() const { return spill_operand_; } |
268 void SetSpillOperand(LOperand* operand); | 268 void SetSpillOperand(LOperand* operand); |
269 | 269 |
270 void SetSpillStartIndex(int start) { | 270 void SetSpillStartIndex(int start) { |
271 spill_start_index_ = Min(start, spill_start_index_); | 271 spill_start_index_ = Min(start, spill_start_index_); |
272 } | 272 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // Maintain the invariant that we return something below the maximum. | 357 // Maintain the invariant that we return something below the maximum. |
358 return 0; | 358 return 0; |
359 } | 359 } |
360 return next_virtual_register_++; | 360 return next_virtual_register_++; |
361 } | 361 } |
362 | 362 |
363 bool AllocationOk() { return allocation_ok_; } | 363 bool AllocationOk() { return allocation_ok_; } |
364 | 364 |
365 void MarkAsOsrEntry() { | 365 void MarkAsOsrEntry() { |
366 // There can be only one. | 366 // There can be only one. |
367 ASSERT(!has_osr_entry_); | 367 DCHECK(!has_osr_entry_); |
368 // Simply set a flag to find and process instruction later. | 368 // Simply set a flag to find and process instruction later. |
369 has_osr_entry_ = true; | 369 has_osr_entry_ = true; |
370 } | 370 } |
371 | 371 |
372 #ifdef DEBUG | 372 #ifdef DEBUG |
373 void Verify() const; | 373 void Verify() const; |
374 #endif | 374 #endif |
375 | 375 |
376 BitVector* assigned_registers() { | 376 BitVector* assigned_registers() { |
377 return assigned_registers_; | 377 return assigned_registers_; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 LAllocator* allocator_; | 566 LAllocator* allocator_; |
567 unsigned allocator_zone_start_allocation_size_; | 567 unsigned allocator_zone_start_allocation_size_; |
568 | 568 |
569 DISALLOW_COPY_AND_ASSIGN(LAllocatorPhase); | 569 DISALLOW_COPY_AND_ASSIGN(LAllocatorPhase); |
570 }; | 570 }; |
571 | 571 |
572 | 572 |
573 } } // namespace v8::internal | 573 } } // namespace v8::internal |
574 | 574 |
575 #endif // V8_LITHIUM_ALLOCATOR_H_ | 575 #endif // V8_LITHIUM_ALLOCATOR_H_ |
OLD | NEW |