diff options
author | 2015-05-06 14:12:42 +0100 | |
---|---|---|
committer | 2015-08-19 12:23:37 +0100 | |
commit | 9b688a095afbae21112df5d495487ac5231b12d0 (patch) | |
tree | e5e881d4d124803e66f1e90c1e0a0e4c90d22e13 /compiler/optimizing/optimizing_compiler.cc | |
parent | 009c34cba875885d9540696f33255a9b355d6e15 (diff) |
Optimizing: Better invoke-static/-direct dispatch.
Add framework for different types of loading ArtMethod*
and code pointer retrieval. Implement invoke-static and
invoke-direct calls the same way as Quick. Document the
dispatch kinds in HInvokeStaticOrDirect's new enumerations
MethodLoadKind and CodePtrLocation.
PC-relative loads from dex cache arrays are used only for
x86-64 and arm64. The implementation for other architectures
will be done in separate CLs.
Change-Id: I468ca4d422dbd14748e1ba6b45289f0d31734d94
Diffstat (limited to 'compiler/optimizing/optimizing_compiler.cc')
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 6a50b7d4a4..b18c921b2c 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -488,6 +488,19 @@ static void AllocateRegisters(HGraph* graph, } } +static ArenaVector<LinkerPatch> EmitAndSortLinkerPatches(CodeGenerator* codegen) { + ArenaVector<LinkerPatch> linker_patches(codegen->GetGraph()->GetArena()->Adapter()); + codegen->EmitLinkerPatches(&linker_patches); + + // Sort patches by literal offset. Required for .oat_patches encoding. + std::sort(linker_patches.begin(), linker_patches.end(), + [](const LinkerPatch& lhs, const LinkerPatch& rhs) { + return lhs.LiteralOffset() < rhs.LiteralOffset(); + }); + + return linker_patches; +} + CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph, CodeGenerator* codegen, CompilerDriver* compiler_driver, @@ -502,6 +515,8 @@ CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph, CodeVectorAllocator allocator; codegen->CompileOptimized(&allocator); + ArenaVector<LinkerPatch> linker_patches = EmitAndSortLinkerPatches(codegen); + DefaultSrcMap src_mapping_table; if (compiler_driver->GetCompilerOptions().GetGenerateDebugInfo()) { codegen->BuildSourceMap(&src_mapping_table); @@ -527,7 +542,7 @@ CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph, ArrayRef<const uint8_t>(stack_map), ArrayRef<const uint8_t>(), // native_gc_map. ArrayRef<const uint8_t>(*codegen->GetAssembler()->cfi().data()), - ArrayRef<const LinkerPatch>()); + ArrayRef<const LinkerPatch>(linker_patches)); pass_observer->DumpDisassembly(); return compiled_method; } @@ -540,6 +555,8 @@ CompiledMethod* OptimizingCompiler::CompileBaseline( CodeVectorAllocator allocator; codegen->CompileBaseline(&allocator); + ArenaVector<LinkerPatch> linker_patches = EmitAndSortLinkerPatches(codegen); + std::vector<uint8_t> mapping_table; codegen->BuildMappingTable(&mapping_table); DefaultSrcMap src_mapping_table; @@ -567,7 +584,7 @@ CompiledMethod* OptimizingCompiler::CompileBaseline( AlignVectorSize(vmap_table), AlignVectorSize(gc_map), ArrayRef<const uint8_t>(*codegen->GetAssembler()->cfi().data()), - ArrayRef<const LinkerPatch>()); + ArrayRef<const LinkerPatch>(linker_patches)); pass_observer->DumpDisassembly(); return compiled_method; } |