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