From 2aba7cd68851d79643338f57fcf2dff3cbf81895 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Wed, 3 Feb 2016 12:27:20 +0000 Subject: Implement first kind of polymorphic inlining on MIPS. Change-Id: Ie430d6c5821273143a1872b376e8e24683d00ab0 --- compiler/optimizing/code_generator_mips.cc | 23 +++++++++++++++++++---- compiler/optimizing/inliner.cc | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/code_generator_mips.cc b/compiler/optimizing/code_generator_mips.cc index fa119bbeb1..f9f0491839 100644 --- a/compiler/optimizing/code_generator_mips.cc +++ b/compiler/optimizing/code_generator_mips.cc @@ -5287,12 +5287,27 @@ void InstructionCodeGeneratorMIPS::VisitInvokeUnresolved(HInvokeUnresolved* invo codegen_->GenerateInvokeUnresolvedRuntimeCall(invoke); } -void LocationsBuilderMIPS::VisitClassTableGet(HClassTableGet*) { - UNIMPLEMENTED(FATAL) << "ClassTableGet is unimplemented on mips"; +void LocationsBuilderMIPS::VisitClassTableGet(HClassTableGet* instruction) { + LocationSummary* locations = + new (GetGraph()->GetArena()) LocationSummary(instruction, LocationSummary::kNoCall); + locations->SetInAt(0, Location::RequiresRegister()); + locations->SetOut(Location::RequiresRegister()); } -void InstructionCodeGeneratorMIPS::VisitClassTableGet(HClassTableGet*) { - UNIMPLEMENTED(FATAL) << "ClassTableGet is unimplemented on mips"; +void InstructionCodeGeneratorMIPS::VisitClassTableGet(HClassTableGet* instruction) { + LocationSummary* locations = instruction->GetLocations(); + uint32_t method_offset = 0; + if (instruction->GetTableKind() == HClassTableGet::kVTable) { + method_offset = mirror::Class::EmbeddedVTableEntryOffset( + instruction->GetIndex(), kMipsPointerSize).SizeValue(); + } else { + method_offset = mirror::Class::EmbeddedImTableEntryOffset( + instruction->GetIndex() % mirror::Class::kImtSize, kMipsPointerSize).Uint32Value(); + } + __ LoadFromOffset(kLoadWord, + locations->Out().AsRegister(), + locations->InAt(0).AsRegister(), + method_offset); } #undef __ diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index a839d2dee8..9b91b53813 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -392,8 +392,8 @@ bool HInliner::TryInlinePolymorphicCall(HInvoke* invoke_instruction, << invoke_instruction->DebugName(); // This optimization only works under JIT for now. DCHECK(Runtime::Current()->UseJit()); - if (graph_->GetInstructionSet() == kMips || graph_->GetInstructionSet() == kMips64) { - // TODO: Support HClassTableGet for mips and mips64. + if (graph_->GetInstructionSet() == kMips64) { + // TODO: Support HClassTableGet for mips64. return false; } ClassLinker* class_linker = caller_compilation_unit_.GetClassLinker(); -- cgit v1.2.3-59-g8ed1b