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 --- runtime/class_linker.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'runtime/class_linker.cc') diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index f2c2f03003..32ad422158 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -7024,6 +7024,23 @@ mirror::String* ClassLinker::ResolveString(const DexFile& dex_file, return string; } +mirror::String* ClassLinker::LookupString(const DexFile& dex_file, + uint32_t string_idx, + Handle dex_cache) { + DCHECK(dex_cache.Get() != nullptr); + mirror::String* resolved = dex_cache->GetResolvedString(string_idx); + if (resolved != nullptr) { + return resolved; + } + uint32_t utf16_length; + const char* utf8_data = dex_file.StringDataAndUtf16LengthByIdx(string_idx, &utf16_length); + mirror::String* string = intern_table_->LookupStrong(Thread::Current(), utf16_length, utf8_data); + if (string != nullptr) { + dex_cache->SetResolvedString(string_idx, string); + } + return string; +} + mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, uint16_t type_idx, mirror::Class* referrer) { -- cgit v1.2.3-59-g8ed1b