diff options
| author | 2014-01-27 16:50:29 -0800 | |
|---|---|---|
| committer | 2014-01-27 16:50:29 -0800 | |
| commit | bb8f0ab736b61db8f543e433859272e83f96ee9b (patch) | |
| tree | 7b7bac5c0e7d0ac9aba91a40e0fbf761cfacb412 /compiler/dex/quick/gen_common.cc | |
| parent | 6e65720d99bd3387b72d528a46291f1ed8184ede (diff) | |
Embed array class pointers at array allocation sites.
Following https://android-review.googlesource.com/#/c/79302, embed
array class pointers at array allocation sites in the compiled code.
Change-Id: I67a1292466dfbb7f48e746e5060e992dd93525c5
Diffstat (limited to 'compiler/dex/quick/gen_common.cc')
| -rw-r--r-- | compiler/dex/quick/gen_common.cc | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index 1f00b2a6a5..19a43b2099 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -207,13 +207,43 @@ void Mir2Lir::GenNewArray(uint32_t type_idx, RegLocation rl_dest, RegLocation rl_src) { FlushAllRegs(); /* Everything to home location */ ThreadOffset func_offset(-1); - if (cu_->compiler_driver->CanAccessTypeWithoutChecks(cu_->method_idx, *cu_->dex_file, + const DexFile* dex_file = cu_->dex_file; + CompilerDriver* driver = cu_->compiler_driver; + if (cu_->compiler_driver->CanAccessTypeWithoutChecks(cu_->method_idx, *dex_file, type_idx)) { - func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArray); + bool is_type_initialized; // Ignored as an array does not have an initializer. + bool use_direct_type_ptr; + uintptr_t direct_type_ptr; + if (kEmbedClassInCode && + driver->CanEmbedTypeInCode(*dex_file, type_idx, + &is_type_initialized, &use_direct_type_ptr, &direct_type_ptr)) { + // The fast path. + if (!use_direct_type_ptr) { + // Use the literal pool and a PC-relative load from a data word. + LIR* data_target = ScanLiteralPool(class_literal_list_, type_idx, 0); + if (data_target == nullptr) { + data_target = AddWordData(&class_literal_list_, type_idx); + } + LIR* load_pc_rel = OpPcRelLoad(TargetReg(kArg0), data_target); + AppendLIR(load_pc_rel); + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArrayResolved); + CallRuntimeHelperRegMethodRegLocation(func_offset, TargetReg(kArg0), rl_src, true); + } else { + // Use the direct pointer. + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArrayResolved); + CallRuntimeHelperImmMethodRegLocation(func_offset, direct_type_ptr, rl_src, true); + } + } else { + // The slow path. + DCHECK_EQ(func_offset.Int32Value(), -1); + func_offset = QUICK_ENTRYPOINT_OFFSET(pAllocArray); + CallRuntimeHelperImmMethodRegLocation(func_offset, type_idx, rl_src, true); + } + DCHECK_NE(func_offset.Int32Value(), -1); } else { func_offset= QUICK_ENTRYPOINT_OFFSET(pAllocArrayWithAccessCheck); + CallRuntimeHelperImmMethodRegLocation(func_offset, type_idx, rl_src, true); } - CallRuntimeHelperImmMethodRegLocation(func_offset, type_idx, rl_src, true); RegLocation rl_result = GetReturn(false); StoreValue(rl_dest, rl_result); } |