OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #ifndef V8_LITHIUM_ALLOCATOR_INL_H_ |
| 29 #define V8_LITHIUM_ALLOCATOR_INL_H_ |
| 30 |
| 31 #include "lithium-allocator.h" |
| 32 |
| 33 #if V8_TARGET_ARCH_IA32 |
| 34 #include "ia32/lithium-ia32.h" |
| 35 #elif V8_TARGET_ARCH_X64 |
| 36 #include "x64/lithium-x64.h" |
| 37 #elif V8_TARGET_ARCH_ARM |
| 38 #include "arm/lithium-arm.h" |
| 39 #else |
| 40 #error "Unknown architecture." |
| 41 #endif |
| 42 |
| 43 namespace v8 { |
| 44 namespace internal { |
| 45 |
| 46 bool LAllocator::IsGapAt(int index) { return chunk_->IsGapAt(index); } |
| 47 |
| 48 |
| 49 LInstruction* LAllocator::InstructionAt(int index) { |
| 50 return chunk_->instructions()->at(index); |
| 51 } |
| 52 |
| 53 |
| 54 LGap* LAllocator::GapAt(int index) { |
| 55 return chunk_->GetGapAt(index); |
| 56 } |
| 57 |
| 58 |
| 59 TempIterator::TempIterator(LInstruction* instr) |
| 60 : instr_(instr), |
| 61 limit_(instr->TempCount()), |
| 62 current_(0) { |
| 63 current_ = AdvanceToNext(0); |
| 64 } |
| 65 |
| 66 |
| 67 bool TempIterator::HasNext() { return current_ < limit_; } |
| 68 |
| 69 |
| 70 LOperand* TempIterator::Next() { |
| 71 ASSERT(HasNext()); |
| 72 return instr_->TempAt(current_); |
| 73 } |
| 74 |
| 75 |
| 76 int TempIterator::AdvanceToNext(int start) { |
| 77 while (start < limit_ && instr_->TempAt(start) == NULL) start++; |
| 78 return start; |
| 79 } |
| 80 |
| 81 |
| 82 void TempIterator::Advance() { |
| 83 current_ = AdvanceToNext(current_ + 1); |
| 84 } |
| 85 |
| 86 |
| 87 InputIterator::InputIterator(LInstruction* instr) |
| 88 : instr_(instr), |
| 89 limit_(instr->InputCount()), |
| 90 current_(0) { |
| 91 current_ = AdvanceToNext(0); |
| 92 } |
| 93 |
| 94 |
| 95 bool InputIterator::HasNext() { return current_ < limit_; } |
| 96 |
| 97 |
| 98 LOperand* InputIterator::Next() { |
| 99 ASSERT(HasNext()); |
| 100 return instr_->InputAt(current_); |
| 101 } |
| 102 |
| 103 |
| 104 void InputIterator::Advance() { |
| 105 current_ = AdvanceToNext(current_ + 1); |
| 106 } |
| 107 |
| 108 |
| 109 int InputIterator::AdvanceToNext(int start) { |
| 110 while (start < limit_ && instr_->InputAt(start)->IsConstantOperand()) start++; |
| 111 return start; |
| 112 } |
| 113 |
| 114 |
| 115 UseIterator::UseIterator(LInstruction* instr) |
| 116 : input_iterator_(instr), env_iterator_(instr->environment()) { } |
| 117 |
| 118 |
| 119 bool UseIterator::HasNext() { |
| 120 return input_iterator_.HasNext() || env_iterator_.HasNext(); |
| 121 } |
| 122 |
| 123 |
| 124 LOperand* UseIterator::Next() { |
| 125 ASSERT(HasNext()); |
| 126 return input_iterator_.HasNext() |
| 127 ? input_iterator_.Next() |
| 128 : env_iterator_.Next(); |
| 129 } |
| 130 |
| 131 |
| 132 void UseIterator::Advance() { |
| 133 input_iterator_.HasNext() |
| 134 ? input_iterator_.Advance() |
| 135 : env_iterator_.Advance(); |
| 136 } |
| 137 |
| 138 } } // namespace v8::internal |
| 139 |
| 140 #endif // V8_LITHIUM_ALLOCATOR_INL_H_ |
OLD | NEW |