diff options
author | 2024-10-30 12:02:05 +0000 | |
---|---|---|
committer | 2024-10-30 14:53:00 +0000 | |
commit | bc3ae299266d177ef7e9d50c956cbc366454cf67 (patch) | |
tree | 9cfca5a5f79ad637b81a49049ff3e140bb087f6d | |
parent | cbf82dafb9bfe0543a64a4a471765069516e9456 (diff) |
cleanup FixUpInstructionType
It was expecting to have an HSelect as an input, so we might
as well encode that with the C++ types. Rename it to
FixUpSelectType.
Also move the instructions around so that the ScopedObjectAccess
scope is smaller.
As a drive-by, move ScopedObjectAccess to CheckAgainstUpperBound
so that we only call it in a subset of cases.
Test: art/test/testrunner/testrunner.py --host --64 -b --optimizing
Change-Id: Id6f179e68e0a460577d5e42b8c431f3d035405a4
-rw-r--r-- | compiler/optimizing/nodes.cc | 6 | ||||
-rw-r--r-- | compiler/optimizing/reference_type_propagation.cc | 17 | ||||
-rw-r--r-- | compiler/optimizing/reference_type_propagation.h | 8 | ||||
-rw-r--r-- | compiler/optimizing/select_generator.cc | 2 |
4 files changed, 13 insertions, 20 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 9c41aef8b6..e7aabb223a 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -3131,9 +3131,9 @@ HBasicBlock* HGraph::TransformLoopForVectorization(HBasicBlock* header, return new_pre_header; } -static void CheckAgainstUpperBound(ReferenceTypeInfo rti, ReferenceTypeInfo upper_bound_rti) - REQUIRES_SHARED(Locks::mutator_lock_) { +static void CheckAgainstUpperBound(ReferenceTypeInfo rti, ReferenceTypeInfo upper_bound_rti) { if (rti.IsValid()) { + ScopedObjectAccess soa(Thread::Current()); DCHECK(upper_bound_rti.IsSupertypeOf(rti)) << " upper_bound_rti: " << upper_bound_rti << " rti: " << rti; @@ -3146,7 +3146,6 @@ static void CheckAgainstUpperBound(ReferenceTypeInfo rti, ReferenceTypeInfo uppe void HInstruction::SetReferenceTypeInfo(ReferenceTypeInfo rti) { if (kIsDebugBuild) { DCHECK_EQ(GetType(), DataType::Type::kReference); - ScopedObjectAccess soa(Thread::Current()); DCHECK(rti.IsValid()) << "Invalid RTI for " << DebugName(); if (IsBoundType()) { // Having the test here spares us from making the method virtual just for @@ -3174,7 +3173,6 @@ bool HBoundType::InstructionDataEquals(const HInstruction* other) const { void HBoundType::SetUpperBound(const ReferenceTypeInfo& upper_bound, bool can_be_null) { if (kIsDebugBuild) { - ScopedObjectAccess soa(Thread::Current()); DCHECK(upper_bound.IsValid()); DCHECK(!upper_bound_.IsValid()) << "Upper bound should only be set once."; CheckAgainstUpperBound(GetReferenceTypeInfo(), upper_bound); diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index 43079f9eee..b647a14407 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -750,17 +750,12 @@ void ReferenceTypePropagation::RTPVisitor::VisitPhi(HPhi* phi) { } } -void ReferenceTypePropagation::FixUpInstructionType(HInstruction* instruction, - HandleCache* handle_cache) { - if (instruction->IsSelect()) { - ScopedObjectAccess soa(Thread::Current()); - HSelect* select = instruction->AsSelect(); - ReferenceTypeInfo false_rti = select->GetFalseValue()->GetReferenceTypeInfo(); - ReferenceTypeInfo true_rti = select->GetTrueValue()->GetReferenceTypeInfo(); - select->SetReferenceTypeInfo(MergeTypes(false_rti, true_rti, handle_cache)); - } else { - LOG(FATAL) << "Invalid instruction in FixUpInstructionType"; - } +void ReferenceTypePropagation::FixUpSelectType(HSelect* select, HandleCache* handle_cache) { + ReferenceTypeInfo false_rti = select->GetFalseValue()->GetReferenceTypeInfo(); + ReferenceTypeInfo true_rti = select->GetTrueValue()->GetReferenceTypeInfo(); + ReferenceTypeInfo rti = ReferenceTypeInfo::CreateInvalid(); + ScopedObjectAccess soa(Thread::Current()); + select->SetReferenceTypeInfo(MergeTypes(false_rti, true_rti, handle_cache)); } ReferenceTypeInfo ReferenceTypePropagation::MergeTypes(const ReferenceTypeInfo& a, diff --git a/compiler/optimizing/reference_type_propagation.h b/compiler/optimizing/reference_type_propagation.h index 56c4af8fa5..773f603db1 100644 --- a/compiler/optimizing/reference_type_propagation.h +++ b/compiler/optimizing/reference_type_propagation.h @@ -60,10 +60,10 @@ class ReferenceTypePropagation : public HOptimization { static constexpr const char* kReferenceTypePropagationPassName = "reference_type_propagation"; - // Fix the reference type for an instruction whose inputs have changed. - // For a select instruction, the reference types of the inputs are merged - // and the resulting reference type is set on the select instruction. - static void FixUpInstructionType(HInstruction* instruction, HandleCache* handle_cache); + // Fix the reference type for an HSelect instruction whose inputs have changed. The reference + // types of the inputs are merged and the resulting reference type is set on the HSelect + // instruction. + static void FixUpSelectType(HSelect* select, HandleCache* handle_cache); private: class RTPVisitor; diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/select_generator.cc index 07065efbb7..d5781c8d38 100644 --- a/compiler/optimizing/select_generator.cc +++ b/compiler/optimizing/select_generator.cc @@ -156,7 +156,7 @@ bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( if (both_successors_return) { if (true_value->GetType() == DataType::Type::kReference) { DCHECK(false_value->GetType() == DataType::Type::kReference); - ReferenceTypePropagation::FixUpInstructionType(select, graph_->GetHandleCache()); + ReferenceTypePropagation::FixUpSelectType(select, graph_->GetHandleCache()); } } else if (phi->GetType() == DataType::Type::kReference) { select->SetReferenceTypeInfoIfValid(phi->GetReferenceTypeInfo()); |