OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_INL_H_ | 5 #ifndef V8_LITHIUM_ALLOCATOR_INL_H_ |
6 #define V8_LITHIUM_ALLOCATOR_INL_H_ | 6 #define V8_LITHIUM_ALLOCATOR_INL_H_ |
7 | 7 |
8 #include "src/lithium-allocator.h" | 8 #include "src/lithium-allocator.h" |
9 | 9 |
10 #if V8_TARGET_ARCH_IA32 | 10 #if V8_TARGET_ARCH_IA32 |
(...skipping 23 matching lines...) Expand all Loading... |
34 LInstruction* LAllocator::InstructionAt(int index) { | 34 LInstruction* LAllocator::InstructionAt(int index) { |
35 return chunk_->instructions()->at(index); | 35 return chunk_->instructions()->at(index); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 LGap* LAllocator::GapAt(int index) { | 39 LGap* LAllocator::GapAt(int index) { |
40 return chunk_->GetGapAt(index); | 40 return chunk_->GetGapAt(index); |
41 } | 41 } |
42 | 42 |
43 | 43 |
44 TempIterator::TempIterator(LInstruction* instr) | |
45 : instr_(instr), | |
46 limit_(instr->TempCount()), | |
47 current_(0) { | |
48 SkipUninteresting(); | |
49 } | |
50 | |
51 | |
52 bool TempIterator::Done() { return current_ >= limit_; } | |
53 | |
54 | |
55 LOperand* TempIterator::Current() { | |
56 ASSERT(!Done()); | |
57 return instr_->TempAt(current_); | |
58 } | |
59 | |
60 | |
61 void TempIterator::SkipUninteresting() { | |
62 while (current_ < limit_ && instr_->TempAt(current_) == NULL) ++current_; | |
63 } | |
64 | |
65 | |
66 void TempIterator::Advance() { | |
67 ++current_; | |
68 SkipUninteresting(); | |
69 } | |
70 | |
71 | |
72 InputIterator::InputIterator(LInstruction* instr) | |
73 : instr_(instr), | |
74 limit_(instr->InputCount()), | |
75 current_(0) { | |
76 SkipUninteresting(); | |
77 } | |
78 | |
79 | |
80 bool InputIterator::Done() { return current_ >= limit_; } | |
81 | |
82 | |
83 LOperand* InputIterator::Current() { | |
84 ASSERT(!Done()); | |
85 ASSERT(instr_->InputAt(current_) != NULL); | |
86 return instr_->InputAt(current_); | |
87 } | |
88 | |
89 | |
90 void InputIterator::Advance() { | |
91 ++current_; | |
92 SkipUninteresting(); | |
93 } | |
94 | |
95 | |
96 void InputIterator::SkipUninteresting() { | |
97 while (current_ < limit_) { | |
98 LOperand* current = instr_->InputAt(current_); | |
99 if (current != NULL && !current->IsConstantOperand()) break; | |
100 ++current_; | |
101 } | |
102 } | |
103 | |
104 | |
105 UseIterator::UseIterator(LInstruction* instr) | |
106 : input_iterator_(instr), env_iterator_(instr->environment()) { } | |
107 | |
108 | |
109 bool UseIterator::Done() { | |
110 return input_iterator_.Done() && env_iterator_.Done(); | |
111 } | |
112 | |
113 | |
114 LOperand* UseIterator::Current() { | |
115 ASSERT(!Done()); | |
116 LOperand* result = input_iterator_.Done() | |
117 ? env_iterator_.Current() | |
118 : input_iterator_.Current(); | |
119 ASSERT(result != NULL); | |
120 return result; | |
121 } | |
122 | |
123 | |
124 void UseIterator::Advance() { | |
125 input_iterator_.Done() | |
126 ? env_iterator_.Advance() | |
127 : input_iterator_.Advance(); | |
128 } | |
129 | |
130 | |
131 void LAllocator::SetLiveRangeAssignedRegister(LiveRange* range, int reg) { | 44 void LAllocator::SetLiveRangeAssignedRegister(LiveRange* range, int reg) { |
132 if (range->Kind() == DOUBLE_REGISTERS) { | 45 if (range->Kind() == DOUBLE_REGISTERS) { |
133 assigned_double_registers_->Add(reg); | 46 assigned_double_registers_->Add(reg); |
134 } else { | 47 } else { |
135 ASSERT(range->Kind() == GENERAL_REGISTERS); | 48 ASSERT(range->Kind() == GENERAL_REGISTERS); |
136 assigned_registers_->Add(reg); | 49 assigned_registers_->Add(reg); |
137 } | 50 } |
138 range->set_assigned_register(reg, chunk()->zone()); | 51 range->set_assigned_register(reg, chunk()->zone()); |
139 } | 52 } |
140 | 53 |
141 | 54 |
142 } } // namespace v8::internal | 55 } } // namespace v8::internal |
143 | 56 |
144 #endif // V8_LITHIUM_ALLOCATOR_INL_H_ | 57 #endif // V8_LITHIUM_ALLOCATOR_INL_H_ |
OLD | NEW |