diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-19 10:34:11 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-31 09:44:40 +0100 |
commit | 8ccc3f5d06fd217cdaabd37e743adab2031d3720 (patch) | |
tree | ec8c904baafb4d9b9bfd582245e2d780bcdfaade /compiler/optimizing/code_generator_arm.cc | |
parent | ad174d1b54bf2fa477bec71a0ca93595f54b8fe9 (diff) | |
download | art-8ccc3f5d06fd217cdaabd37e743adab2031d3720.zip art-8ccc3f5d06fd217cdaabd37e743adab2031d3720.tar.gz art-8ccc3f5d06fd217cdaabd37e743adab2031d3720.tar.bz2 |
Add support for invoke-static in optimizing compiler.
Support is limited to calls without parameters and returning
void. For simplicity, we currently follow the Quick ABI.
Change-Id: I54805161141b7eac5959f1cae0dc138dd0b2e8a5
Diffstat (limited to 'compiler/optimizing/code_generator_arm.cc')
-rw-r--r-- | compiler/optimizing/code_generator_arm.cc | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/compiler/optimizing/code_generator_arm.cc b/compiler/optimizing/code_generator_arm.cc index 04bdc34..c85d67d 100644 --- a/compiler/optimizing/code_generator_arm.cc +++ b/compiler/optimizing/code_generator_arm.cc @@ -18,17 +18,27 @@ #include "utils/assembler.h" #include "utils/arm/assembler_arm.h" +#include "mirror/array.h" +#include "mirror/art_method.h" + #define __ reinterpret_cast<ArmAssembler*>(GetAssembler())-> namespace art { namespace arm { void CodeGeneratorARM::GenerateFrameEntry() { + core_spill_mask_ |= (1 << LR); + // We're currently always using FP, which is callee-saved in Quick. + core_spill_mask_ |= (1 << FP); + __ PushList((1 << FP) | (1 << LR)); __ mov(FP, ShifterOperand(SP)); - if (GetFrameSize() != 0) { - __ AddConstant(SP, -GetFrameSize()); - } + + // Add the current ART method to the frame size, the return pc, and FP. + SetFrameSize(RoundUp(GetFrameSize() + 3 * kWordSize, kStackAlignment)); + // PC and FP have already been pushed on the stack. + __ AddConstant(SP, -(GetFrameSize() - 2 * kWordSize)); + __ str(R0, Address(SP, 0)); } void CodeGeneratorARM::GenerateFrameExit() { @@ -173,5 +183,43 @@ void InstructionCodeGeneratorARM::VisitReturn(HReturn* ret) { codegen_->GenerateFrameExit(); } +void LocationsBuilderARM::VisitInvokeStatic(HInvokeStatic* invoke) { + LocationSummary* locations = new (GetGraph()->GetArena()) LocationSummary(invoke); + CHECK_EQ(invoke->InputCount(), 0); + locations->AddTemp(Location(R0)); + invoke->SetLocations(locations); +} + +void InstructionCodeGeneratorARM::LoadCurrentMethod(Register reg) { + __ ldr(reg, Address(SP, 0)); +} + +void InstructionCodeGeneratorARM::VisitInvokeStatic(HInvokeStatic* invoke) { + Register temp = invoke->GetLocations()->GetTemp(0).reg<Register>(); + size_t index_in_cache = mirror::Array::DataOffset(sizeof(mirror::Object*)).Int32Value() + + invoke->GetIndexInDexCache() * kWordSize; + + // TODO: Implement all kinds of calls: + // 1) boot -> boot + // 2) app -> boot + // 3) app -> app + // + // Currently we implement the app -> app logic, which looks up in the resolve cache. + + // temp = method; + LoadCurrentMethod(temp); + // temp = temp->dex_cache_resolved_methods_; + __ ldr(temp, Address(temp, mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value())); + // temp = temp[index_in_cache] + __ ldr(temp, Address(temp, index_in_cache)); + // LR = temp[offset_of_quick_compiled_code] + __ ldr(LR, Address(temp, + mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value())); + // LR() + __ blx(LR); + + codegen_->RecordPcInfo(invoke->GetDexPc()); +} + } // namespace arm } // namespace art |