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