From be1ca55db3362f5b100c4c65da5342fd299520bb Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Wed, 15 Jan 2014 11:46:48 -0800 Subject: Use direct class pointers at allocation sites in the compiled code. - Rather than looking up a class from its type ID (and checking if it's resolved/initialized, resolving/initializing if not), use direct class pointers, if possible (boot-code-to-boot-class pointers and app-code-to-boot-class pointers.) - This results in a 1-2% speedup in Ritz MemAllocTest on Nexus 4. - Embedding the object size (along with class pointers) caused a 1-2% slowdown in MemAllocTest and isn't implemented in this change. - TODO: do the same for array allocations. - TODO: when/if an application gets its own image, implement app-code-to-app-class pointers. - Fix a -XX:gc bug. cf. https://android-review.googlesource.com/79460/ - Add /tmp/android-data/dalvik-cache to the list of locations to remove oat files in clean-oat-host. cf. https://android-review.googlesource.com/79550 - Add back a dropped UNLIKELY in FindMethodFromCode(). cf. https://android-review.googlesource.com/74205 Bug: 9986565 Change-Id: I590b96bd21f7a7472f88e36752e675547559a5b1 --- compiler/dex/quick/codegen_util.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (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 29554c0977..2ce7ecdecc 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -440,6 +440,20 @@ void Mir2Lir::InstallLiteralPools() { PushPointer(code_buffer_, &id); data_lir = NEXT_LIR(data_lir); } + // Push class literals. + data_lir = class_literal_list_; + while (data_lir != NULL) { + uint32_t target = data_lir->operands[0]; + cu_->compiler_driver->AddClassPatch(cu_->dex_file, + cu_->class_def_idx, + cu_->method_idx, + target, + code_buffer_.size()); + const DexFile::TypeId& id = cu_->dex_file->GetTypeId(target); + // unique value based on target to ensure code deduplication works + PushPointer(code_buffer_, &id); + data_lir = NEXT_LIR(data_lir); + } } /* Write the switch tables to the output stream */ @@ -772,6 +786,7 @@ int Mir2Lir::AssignLiteralOffset(CodeOffset offset) { offset = AssignLiteralOffsetCommon(literal_list_, offset); offset = AssignLiteralPointerOffsetCommon(code_literal_list_, offset); offset = AssignLiteralPointerOffsetCommon(method_literal_list_, offset); + offset = AssignLiteralPointerOffsetCommon(class_literal_list_, offset); return offset; } @@ -960,6 +975,7 @@ Mir2Lir::Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena : Backend(arena), literal_list_(NULL), method_literal_list_(NULL), + class_literal_list_(NULL), code_literal_list_(NULL), first_fixup_(NULL), cu_(cu), -- cgit v1.2.3-59-g8ed1b