From cac5a7e871f1f346b317894359ad06fa7bd67fba Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Mon, 22 Feb 2016 10:39:50 +0000 Subject: Optimizing: Improve const-string code generation. For strings in the boot image, use either direct pointers or pc-relative addresses. For other strings, use PC-relative access to the dex cache arrays for AOT and direct address of the string's dex cache slot for JIT. For aosp_flounder-userdebug: - 32-bit boot.oat: -692KiB (-0.9%) - 64-bit boot.oat: -948KiB (-1.1%) - 32-bit dalvik cache total: -900KiB (-0.9%) - 64-bit dalvik cache total: -3672KiB (-1.5%) (contains more files than the 32-bit dalvik cache) For aosp_flounder-userdebug forced to compile PIC: - 32-bit boot.oat: -380KiB (-0.5%) - 64-bit boot.oat: -928KiB (-1.0%) - 32-bit dalvik cache total: -468KiB (-0.4%) - 64-bit dalvik cache total: -1928KiB (-0.8%) (contains more files than the 32-bit dalvik cache) Bug: 26884697 Change-Id: Iec7266ce67e6fedc107be78fab2e742a8dab2696 --- compiler/linker/relative_patcher_test.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'compiler/linker/relative_patcher_test.h') diff --git a/compiler/linker/relative_patcher_test.h b/compiler/linker/relative_patcher_test.h index 704135a7b5..c9fb543d2e 100644 --- a/compiler/linker/relative_patcher_test.h +++ b/compiler/linker/relative_patcher_test.h @@ -150,12 +150,19 @@ class RelativePatcherTest : public testing::Test { offset + patch.LiteralOffset(), target_offset); } else if (patch.Type() == kLinkerPatchDexCacheArray) { uint32_t target_offset = dex_cache_arrays_begin_ + patch.TargetDexCacheElementOffset(); - patcher_->PatchDexCacheReference(&patched_code_, - patch, - offset + patch.LiteralOffset(), - target_offset); + patcher_->PatchPcRelativeReference(&patched_code_, + patch, + offset + patch.LiteralOffset(), + target_offset); + } else if (patch.Type() == kLinkerPatchStringRelative) { + uint32_t target_offset = string_index_to_offset_map_.Get(patch.TargetStringIndex()); + patcher_->PatchPcRelativeReference(&patched_code_, + patch, + offset + patch.LiteralOffset(), + target_offset); } else { - LOG(FATAL) << "Bad patch type."; + LOG(FATAL) << "Bad patch type. " << patch.Type(); + UNREACHABLE(); } } } @@ -257,6 +264,7 @@ class RelativePatcherTest : public testing::Test { MethodOffsetMap method_offset_map_; std::unique_ptr patcher_; uint32_t dex_cache_arrays_begin_; + SafeMap string_index_to_offset_map_; std::vector compiled_method_refs_; std::vector> compiled_methods_; std::vector patched_code_; -- cgit v1.2.3-59-g8ed1b