diff options
Diffstat (limited to 'compiler/optimizing/nodes.cc')
| -rw-r--r-- | compiler/optimizing/nodes.cc | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 594255c625..a599c2aa84 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1108,13 +1108,23 @@ size_t HInstruction::EnvironmentSize() const { return HasEnvironment() ? environment_->Size() : 0; } -void HPhi::AddInput(HInstruction* input) { +void HVariableInputSizeInstruction::AddInput(HInstruction* input) { DCHECK(input->GetBlock() != nullptr); inputs_.push_back(HUserRecord<HInstruction*>(input)); input->AddUseAt(this, inputs_.size() - 1); } -void HPhi::RemoveInputAt(size_t index) { +void HVariableInputSizeInstruction::InsertInputAt(size_t index, HInstruction* input) { + inputs_.insert(inputs_.begin() + index, HUserRecord<HInstruction*>(input)); + input->AddUseAt(this, index); + // Update indexes in use nodes of inputs that have been pushed further back by the insert(). + for (size_t i = index + 1u, e = inputs_.size(); i < e; ++i) { + DCHECK_EQ(inputs_[i].GetUseNode()->GetIndex(), i - 1u); + inputs_[i].GetUseNode()->SetIndex(i); + } +} + +void HVariableInputSizeInstruction::RemoveInputAt(size_t index) { RemoveAsUserOfInput(index); inputs_.erase(inputs_.begin() + index); // Update indexes in use nodes of inputs that have been pulled forward by the erase(). @@ -1347,7 +1357,9 @@ std::ostream& operator<<(std::ostream& os, const HInstruction::InstructionKind& void HInstruction::MoveBefore(HInstruction* cursor) { DCHECK(!IsPhi()); DCHECK(!IsControlFlow()); - DCHECK(CanBeMoved()); + DCHECK(CanBeMoved() || + // HShouldDeoptimizeFlag can only be moved by CHAGuardOptimization. + IsShouldDeoptimizeFlag()); DCHECK(!cursor->IsPhi()); next_->previous_ = previous_; @@ -2386,26 +2398,6 @@ bool HInvokeStaticOrDirect::NeedsDexCacheOfDeclaringClass() const { return !opt.GetDoesNotNeedDexCache(); } -void HInvokeStaticOrDirect::InsertInputAt(size_t index, HInstruction* input) { - inputs_.insert(inputs_.begin() + index, HUserRecord<HInstruction*>(input)); - input->AddUseAt(this, index); - // Update indexes in use nodes of inputs that have been pushed further back by the insert(). - for (size_t i = index + 1u, e = inputs_.size(); i < e; ++i) { - DCHECK_EQ(inputs_[i].GetUseNode()->GetIndex(), i - 1u); - inputs_[i].GetUseNode()->SetIndex(i); - } -} - -void HInvokeStaticOrDirect::RemoveInputAt(size_t index) { - RemoveAsUserOfInput(index); - inputs_.erase(inputs_.begin() + index); - // Update indexes in use nodes of inputs that have been pulled forward by the erase(). - for (size_t i = index, e = inputs_.size(); i < e; ++i) { - DCHECK_EQ(inputs_[i].GetUseNode()->GetIndex(), i + 1u); - inputs_[i].GetUseNode()->SetIndex(i); - } -} - std::ostream& operator<<(std::ostream& os, HInvokeStaticOrDirect::MethodLoadKind rhs) { switch (rhs) { case HInvokeStaticOrDirect::MethodLoadKind::kStringInit: @@ -2414,8 +2406,6 @@ std::ostream& operator<<(std::ostream& os, HInvokeStaticOrDirect::MethodLoadKind return os << "recursive"; case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddress: return os << "direct"; - case HInvokeStaticOrDirect::MethodLoadKind::kDirectAddressWithFixup: - return os << "direct_fixup"; case HInvokeStaticOrDirect::MethodLoadKind::kDexCachePcRelative: return os << "dex_cache_pc_relative"; case HInvokeStaticOrDirect::MethodLoadKind::kDexCacheViaMethod: @@ -2440,6 +2430,17 @@ std::ostream& operator<<(std::ostream& os, HInvokeStaticOrDirect::ClinitCheckReq } } +// Helper for InstructionDataEquals to fetch the mirror Class out +// from a kJitTableAddress LoadClass kind. +// NO_THREAD_SAFETY_ANALYSIS because even though we're accessing +// mirrors, they are stored in a variable size handle scope which is always +// visited during a pause. Also, the only caller of this helper +// only uses the mirror for pointer comparison. +static inline mirror::Class* AsMirrorInternal(uint64_t address) + NO_THREAD_SAFETY_ANALYSIS { + return reinterpret_cast<StackReference<mirror::Class>*>(address)->AsMirrorPtr(); +} + bool HLoadClass::InstructionDataEquals(const HInstruction* other) const { const HLoadClass* other_load_class = other->AsLoadClass(); // TODO: To allow GVN for HLoadClass from different dex files, we should compare the type @@ -2448,16 +2449,14 @@ bool HLoadClass::InstructionDataEquals(const HInstruction* other) const { GetPackedFields() != other_load_class->GetPackedFields()) { return false; } - LoadKind load_kind = GetLoadKind(); - if (HasAddress(load_kind)) { - return GetAddress() == other_load_class->GetAddress(); - } else if (HasTypeReference(load_kind)) { - return IsSameDexFile(GetDexFile(), other_load_class->GetDexFile()); - } else { - DCHECK(HasDexCacheReference(load_kind)) << load_kind; - // If the type indexes and dex files are the same, dex cache element offsets - // must also be the same, so we don't need to compare them. - return IsSameDexFile(GetDexFile(), other_load_class->GetDexFile()); + switch (GetLoadKind()) { + case LoadKind::kBootImageAddress: + return GetAddress() == other_load_class->GetAddress(); + case LoadKind::kJitTableAddress: + return AsMirrorInternal(GetAddress()) == AsMirrorInternal(other_load_class->GetAddress()); + default: + DCHECK(HasTypeReference(GetLoadKind()) || HasDexCacheReference(GetLoadKind())); + return IsSameDexFile(GetDexFile(), other_load_class->GetDexFile()); } } @@ -2487,8 +2486,8 @@ std::ostream& operator<<(std::ostream& os, HLoadClass::LoadKind rhs) { return os << "BootImageLinkTimePcRelative"; case HLoadClass::LoadKind::kBootImageAddress: return os << "BootImageAddress"; - case HLoadClass::LoadKind::kDexCacheAddress: - return os << "DexCacheAddress"; + case HLoadClass::LoadKind::kJitTableAddress: + return os << "JitTableAddress"; case HLoadClass::LoadKind::kDexCachePcRelative: return os << "DexCachePcRelative"; case HLoadClass::LoadKind::kDexCacheViaMethod: |