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