diff options
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/bounds_check_elimination_test.cc | 27 | ||||
-rw-r--r-- | compiler/optimizing/builder.cc | 21 | ||||
-rw-r--r-- | compiler/optimizing/gvn_test.cc | 20 | ||||
-rw-r--r-- | compiler/optimizing/induction_var_analysis_test.cc | 3 | ||||
-rw-r--r-- | compiler/optimizing/licm_test.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 13 | ||||
-rw-r--r-- | compiler/optimizing/nodes_test.cc | 15 | ||||
-rw-r--r-- | compiler/optimizing/reference_type_propagation.cc | 19 | ||||
-rw-r--r-- | compiler/optimizing/register_allocator_test.cc | 27 |
9 files changed, 46 insertions, 101 deletions
diff --git a/compiler/optimizing/bounds_check_elimination_test.cc b/compiler/optimizing/bounds_check_elimination_test.cc index c9afdf2147..ce6dc75741 100644 --- a/compiler/optimizing/bounds_check_elimination_test.cc +++ b/compiler/optimizing/bounds_check_elimination_test.cc @@ -71,9 +71,9 @@ TEST_F(BoundsCheckEliminationTest, NarrowingRangeArrayBoundsElimination) { graph_->AddBlock(entry); graph_->SetEntryBlock(entry); HInstruction* parameter1 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); // array + HParameterValue(0, Primitive::kPrimNot); // array HInstruction* parameter2 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimInt); // i + HParameterValue(0, Primitive::kPrimInt); // i entry->AddInstruction(parameter1); entry->AddInstruction(parameter2); @@ -168,9 +168,9 @@ TEST_F(BoundsCheckEliminationTest, OverflowArrayBoundsElimination) { graph_->AddBlock(entry); graph_->SetEntryBlock(entry); HInstruction* parameter1 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); // array + HParameterValue(0, Primitive::kPrimNot); // array HInstruction* parameter2 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimInt); // i + HParameterValue(0, Primitive::kPrimInt); // i entry->AddInstruction(parameter1); entry->AddInstruction(parameter2); @@ -232,9 +232,9 @@ TEST_F(BoundsCheckEliminationTest, UnderflowArrayBoundsElimination) { graph_->AddBlock(entry); graph_->SetEntryBlock(entry); HInstruction* parameter1 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); // array + HParameterValue(0, Primitive::kPrimNot); // array HInstruction* parameter2 = new (&allocator_) - HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimInt); // i + HParameterValue(0, Primitive::kPrimInt); // i entry->AddInstruction(parameter1); entry->AddInstruction(parameter2); @@ -295,8 +295,7 @@ TEST_F(BoundsCheckEliminationTest, ConstantArrayBoundsElimination) { HBasicBlock* entry = new (&allocator_) HBasicBlock(graph_); graph_->AddBlock(entry); graph_->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator_) HParameterValue( - graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (&allocator_) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HInstruction* constant_5 = graph_->GetIntConstant(5); @@ -364,8 +363,7 @@ static HInstruction* BuildSSAGraph1(HGraph* graph, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HInstruction* constant_initial = graph->GetIntConstant(initial); @@ -479,8 +477,7 @@ static HInstruction* BuildSSAGraph2(HGraph *graph, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HInstruction* constant_initial = graph->GetIntConstant(initial); @@ -692,8 +689,7 @@ static HInstruction* BuildSSAGraph4(HGraph* graph, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HInstruction* constant_initial = graph->GetIntConstant(initial); @@ -795,8 +791,7 @@ TEST_F(BoundsCheckEliminationTest, BubbleSortArrayBoundsElimination) { HBasicBlock* entry = new (&allocator_) HBasicBlock(graph_); graph_->AddBlock(entry); graph_->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator_) HParameterValue( - graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (&allocator_) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HInstruction* constant_0 = graph_->GetIntConstant(0); diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 5dd5be3259..21540e8ed7 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -159,13 +159,9 @@ void HGraphBuilder::InitializeParameters(uint16_t number_of_parameters) { int locals_index = locals_.size() - number_of_parameters; int parameter_index = 0; - const DexFile::MethodId& referrer_method_id = - dex_file_->GetMethodId(dex_compilation_unit_->GetDexMethodIndex()); if (!dex_compilation_unit_->IsStatic()) { // Add the implicit 'this' argument, not expressed in the signature. - HParameterValue* parameter = new (arena_) HParameterValue(*dex_file_, - referrer_method_id.class_idx_, - parameter_index++, + HParameterValue* parameter = new (arena_) HParameterValue(parameter_index++, Primitive::kPrimNot, true); entry_block_->AddInstruction(parameter); @@ -174,16 +170,11 @@ void HGraphBuilder::InitializeParameters(uint16_t number_of_parameters) { number_of_parameters--; } - const DexFile::ProtoId& proto = dex_file_->GetMethodPrototype(referrer_method_id); - const DexFile::TypeList* arg_types = dex_file_->GetProtoParameters(proto); - for (int i = 0, shorty_pos = 1; i < number_of_parameters; i++) { - HParameterValue* parameter = new (arena_) HParameterValue( - *dex_file_, - arg_types->GetTypeItem(shorty_pos - 1).type_idx_, - parameter_index++, - Primitive::GetType(shorty[shorty_pos]), - false); - ++shorty_pos; + uint32_t pos = 1; + for (int i = 0; i < number_of_parameters; i++) { + HParameterValue* parameter = new (arena_) HParameterValue(parameter_index++, + Primitive::GetType(shorty[pos++]), + false); entry_block_->AddInstruction(parameter); HLocal* local = GetLocalAt(locals_index++); // Store the parameter value in the local that the dex code will use diff --git a/compiler/optimizing/gvn_test.cc b/compiler/optimizing/gvn_test.cc index aa375f697b..56f2718264 100644 --- a/compiler/optimizing/gvn_test.cc +++ b/compiler/optimizing/gvn_test.cc @@ -34,10 +34,7 @@ TEST(GVNTest, LocalFieldElimination) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator) HParameterValue(graph->GetDexFile(), - 0, - 0, - Primitive::kPrimNot); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HBasicBlock* block = new (&allocator) HBasicBlock(graph); @@ -114,10 +111,7 @@ TEST(GVNTest, GlobalFieldElimination) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator) HParameterValue(graph->GetDexFile(), - 0, - 0, - Primitive::kPrimNot); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HBasicBlock* block = new (&allocator) HBasicBlock(graph); @@ -194,10 +188,7 @@ TEST(GVNTest, LoopFieldElimination) { graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator) HParameterValue(graph->GetDexFile(), - 0, - 0, - Primitive::kPrimNot); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HBasicBlock* block = new (&allocator) HBasicBlock(graph); @@ -337,10 +328,7 @@ TEST(GVNTest, LoopSideEffects) { inner_loop_body->AddSuccessor(inner_loop_header); inner_loop_exit->AddSuccessor(outer_loop_header); - HInstruction* parameter = new (&allocator) HParameterValue(graph->GetDexFile(), - 0, - 0, - Primitive::kPrimBoolean); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimBoolean); entry->AddInstruction(parameter); entry->AddInstruction(new (&allocator) HGoto()); outer_loop_header->AddInstruction(new (&allocator) HIf(parameter)); diff --git a/compiler/optimizing/induction_var_analysis_test.cc b/compiler/optimizing/induction_var_analysis_test.cc index 19af2fb5db..20492e7152 100644 --- a/compiler/optimizing/induction_var_analysis_test.cc +++ b/compiler/optimizing/induction_var_analysis_test.cc @@ -78,8 +78,7 @@ class InductionVarAnalysisTest : public testing::Test { graph_->SetExitBlock(exit_); // Provide entry and exit instructions. - parameter_ = new (&allocator_) HParameterValue( - graph_->GetDexFile(), 0, 0, Primitive::kPrimNot, true); + parameter_ = new (&allocator_) HParameterValue(0, Primitive::kPrimNot, true); entry_->AddInstruction(parameter_); constant0_ = graph_->GetIntConstant(0); constant1_ = graph_->GetIntConstant(1); diff --git a/compiler/optimizing/licm_test.cc b/compiler/optimizing/licm_test.cc index a036bd5aa9..558892d01c 100644 --- a/compiler/optimizing/licm_test.cc +++ b/compiler/optimizing/licm_test.cc @@ -61,7 +61,7 @@ class LICMTest : public testing::Test { loop_body_->AddSuccessor(loop_header_); // Provide boiler-plate instructions. - parameter_ = new (&allocator_) HParameterValue(graph_->GetDexFile(), 0, 0, Primitive::kPrimNot); + parameter_ = new (&allocator_) HParameterValue(0, Primitive::kPrimNot); entry_->AddInstruction(parameter_); constant_ = graph_->GetIntConstant(42); loop_preheader_->AddInstruction(new (&allocator_) HGoto()); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 224c635fd2..82909c41b6 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -3927,31 +3927,24 @@ class HXor : public HBinaryOperation { // the calling convention. class HParameterValue : public HExpression<0> { public: - HParameterValue(const DexFile& dex_file, - uint16_t type_index, - uint8_t index, + HParameterValue(uint8_t index, Primitive::Type parameter_type, bool is_this = false) : HExpression(parameter_type, SideEffects::None(), kNoDexPc), - dex_file_(dex_file), - type_index_(type_index), index_(index), is_this_(is_this), can_be_null_(!is_this) {} - const DexFile& GetDexFile() const { return dex_file_; } - uint16_t GetTypeIndex() const { return type_index_; } uint8_t GetIndex() const { return index_; } - bool IsThis() const { return is_this_; } bool CanBeNull() const OVERRIDE { return can_be_null_; } void SetCanBeNull(bool can_be_null) { can_be_null_ = can_be_null; } + bool IsThis() const { return is_this_; } + DECLARE_INSTRUCTION(ParameterValue); private: - const DexFile& dex_file_; - const uint16_t type_index_; // The index of this parameter in the parameters list. Must be less // than HGraph::number_of_in_vregs_. const uint8_t index_; diff --git a/compiler/optimizing/nodes_test.cc b/compiler/optimizing/nodes_test.cc index 764f5fec5b..8eeac56ceb 100644 --- a/compiler/optimizing/nodes_test.cc +++ b/compiler/optimizing/nodes_test.cc @@ -34,8 +34,7 @@ TEST(Node, RemoveInstruction) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); entry->AddInstruction(new (&allocator) HGoto()); @@ -77,10 +76,8 @@ TEST(Node, InsertInstruction) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter1 = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); - HInstruction* parameter2 = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter1 = new (&allocator) HParameterValue(0, Primitive::kPrimNot); + HInstruction* parameter2 = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter1); entry->AddInstruction(parameter2); entry->AddInstruction(new (&allocator) HExit()); @@ -105,8 +102,7 @@ TEST(Node, AddInstruction) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (&allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); ASSERT_FALSE(parameter->HasUses()); @@ -126,8 +122,7 @@ TEST(Node, ParentEnvironment) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter1 = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter1 = new (&allocator) HParameterValue(0, Primitive::kPrimNot); HInstruction* with_environment = new (&allocator) HNullCheck(parameter1, 0); entry->AddInstruction(parameter1); entry->AddInstruction(with_environment); diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index abfbcacef7..f7a7e420bb 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -428,21 +428,12 @@ void RTPVisitor::VisitNewArray(HNewArray* instr) { UpdateReferenceTypeInfo(instr, instr->GetTypeIndex(), instr->GetDexFile(), /* is_exact */ true); } -static mirror::Class* GetClassFromDexCache(Thread* self, const DexFile& dex_file, uint16_t type_idx) - SHARED_REQUIRES(Locks::mutator_lock_) { - mirror::DexCache* dex_cache = - Runtime::Current()->GetClassLinker()->FindDexCache(self, dex_file, false); - // Get type from dex cache assuming it was populated by the verifier. - return dex_cache->GetResolvedType(type_idx); -} - void RTPVisitor::VisitParameterValue(HParameterValue* instr) { ScopedObjectAccess soa(Thread::Current()); // We check if the existing type is valid: the inliner may have set it. if (instr->GetType() == Primitive::kPrimNot && !instr->GetReferenceTypeInfo().IsValid()) { - mirror::Class* resolved_class = - GetClassFromDexCache(soa.Self(), instr->GetDexFile(), instr->GetTypeIndex()); - SetClassAsTypeInfo(instr, resolved_class, /* is_exact */ false); + // TODO: parse the signature and add precise types for the parameters. + SetClassAsTypeInfo(instr, nullptr, /* is_exact */ false); } } @@ -488,9 +479,11 @@ void RTPVisitor::VisitUnresolvedStaticFieldGet(HUnresolvedStaticFieldGet* instr) void RTPVisitor::VisitLoadClass(HLoadClass* instr) { ScopedObjectAccess soa(Thread::Current()); + mirror::DexCache* dex_cache = + Runtime::Current()->GetClassLinker()->FindDexCache(soa.Self(), instr->GetDexFile(), false); // Get type from dex cache assuming it was populated by the verifier. - mirror::Class* resolved_class = - GetClassFromDexCache(soa.Self(), instr->GetDexFile(), instr->GetTypeIndex()); + mirror::Class* resolved_class = dex_cache->GetResolvedType(instr->GetTypeIndex()); + // TODO: investigating why we are still getting unresolved classes: b/22821472. if (resolved_class != nullptr) { instr->SetLoadedClassRTI(ReferenceTypeInfo::Create( handles_->NewHandle(resolved_class), /* is_exact */ true)); diff --git a/compiler/optimizing/register_allocator_test.cc b/compiler/optimizing/register_allocator_test.cc index ed5419ee49..1511606950 100644 --- a/compiler/optimizing/register_allocator_test.cc +++ b/compiler/optimizing/register_allocator_test.cc @@ -475,8 +475,7 @@ static HGraph* BuildIfElseWithPhi(ArenaAllocator* allocator, NullHandle<mirror::DexCache> dex_cache; graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HBasicBlock* block = new (allocator) HBasicBlock(graph); @@ -625,8 +624,7 @@ static HGraph* BuildFieldReturn(ArenaAllocator* allocator, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimNot); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimNot); entry->AddInstruction(parameter); HBasicBlock* block = new (allocator) HBasicBlock(graph); @@ -700,8 +698,7 @@ static HGraph* BuildTwoSubs(ArenaAllocator* allocator, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* parameter = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); + HInstruction* parameter = new (allocator) HParameterValue(0, Primitive::kPrimInt); entry->AddInstruction(parameter); HInstruction* constant1 = graph->GetIntConstant(1); @@ -771,10 +768,8 @@ static HGraph* BuildDiv(ArenaAllocator* allocator, HBasicBlock* entry = new (allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* first = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); - HInstruction* second = new (allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); + HInstruction* first = new (allocator) HParameterValue(0, Primitive::kPrimInt); + HInstruction* second = new (allocator) HParameterValue(0, Primitive::kPrimInt); entry->AddInstruction(first); entry->AddInstruction(second); @@ -825,14 +820,10 @@ TEST(RegisterAllocatorTest, SpillInactive) { HBasicBlock* entry = new (&allocator) HBasicBlock(graph); graph->AddBlock(entry); graph->SetEntryBlock(entry); - HInstruction* one = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); - HInstruction* two = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); - HInstruction* three = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); - HInstruction* four = new (&allocator) HParameterValue( - graph->GetDexFile(), 0, 0, Primitive::kPrimInt); + HInstruction* one = new (&allocator) HParameterValue(0, Primitive::kPrimInt); + HInstruction* two = new (&allocator) HParameterValue(0, Primitive::kPrimInt); + HInstruction* three = new (&allocator) HParameterValue(0, Primitive::kPrimInt); + HInstruction* four = new (&allocator) HParameterValue(0, Primitive::kPrimInt); entry->AddInstruction(one); entry->AddInstruction(two); entry->AddInstruction(three); |