From 754ddad084ccb610d0cf486f6131bdc69bae5bc6 Mon Sep 17 00:00:00 2001 From: Dave Allison Date: Wed, 19 Feb 2014 14:05:39 -0800 Subject: Use trampolines for calls to helpers This is an ARM specific optimization to the compiler that uses trampoline islands to make calls to runtime helper functions. The intention is to reduce the size of the generated code (by 2 bytes per call) without affecting performance. By default this is on when generating an OAT file. It is off when compiling to memory. To switch this off in dex2oat, use the command line option: --no-helper-trampolines Enhances disassembler to print the trampoline entry on the BL instruction like this: 0xb6a850c0: f7ffff9e bl -196 (0xb6a85000) ; pTestSuspend Bug: 12607709 Change-Id: I9202bdb7cf21252ad807bd48701f1f6ce8e3d0fe --- compiler/dex/quick/codegen_util.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'compiler/dex/quick/codegen_util.cc') diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index 6e6b8f0a30..b163ef7e06 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -1012,11 +1012,26 @@ CompiledMethod* Mir2Lir::GetCompiledMethod() { vmap_encoder.PushBackUnsigned(0u); // Size is 0. } + // All relocations + UniquePtr all_relocs(new FinalRelocations()); + + // Build the final relocations for this method. + if (trampoline_calls_.size() != 0) { + FinalEntrypointRelocationSet* ep_relocs = + cu_->compiler_driver->AllocateFinalEntrypointRelocationSet(cu_); + for (size_t i = 0 ; i < trampoline_calls_.size(); ++i) { + const TrampolineCall& call = trampoline_calls_[i]; + ep_relocs->Add(call.code_offset_, call.trampoline_offset_); + } + all_relocs->push_back(ep_relocs); + } + UniquePtr > cfi_info(ReturnCallFrameInformation()); CompiledMethod* result = new CompiledMethod(*cu_->compiler_driver, cu_->instruction_set, code_buffer_, frame_size_, core_spill_mask_, fp_spill_mask_, encoded_mapping_table_, - vmap_encoder.GetData(), native_gc_map_, cfi_info.get()); + vmap_encoder.GetData(), native_gc_map_, cfi_info.get(), + all_relocs.release()); return result; } -- cgit v1.2.3-59-g8ed1b