From 1ca718ec2de53fb5ef2a9211bfcc921311775c90 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 23 Oct 2018 12:55:34 -0700 Subject: Add PreResolved strings dex cache array For app images, this dex cache may be prepopulated to speed up application startup. This new dex cache array is created when --resolve-startup-const-strings=true. Test: test-art-host Bug: 116059983 Bug: 118385560 Change-Id: I379dc15174281665d7f4ceb106f7fbf51f89b921 --- compiler/driver/compiler_driver.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 864b215a90..df6e8a83e1 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -719,6 +719,10 @@ void CompilerDriver::ResolveConstStrings(const std::vector& dex_ for (const DexFile* dex_file : dex_files) { dex_cache.Assign(class_linker->FindDexCache(soa.Self(), *dex_file)); + if (only_startup_strings) { + // When resolving startup strings, create the preresolved strings array. + dex_cache->AddPreResolvedStringsArray(); + } TimingLogger::ScopedTiming t("Resolve const-string Strings", timings); for (ClassAccessor accessor : dex_file->GetClasses()) { @@ -757,6 +761,10 @@ void CompilerDriver::ResolveConstStrings(const std::vector& dex_ : inst->VRegB_31c()); ObjPtr string = class_linker->ResolveString(string_index, dex_cache); CHECK(string != nullptr) << "Could not allocate a string when forcing determinism"; + if (only_startup_strings) { + dex_cache->GetPreResolvedStrings()[string_index.index_] = + GcRoot(string); + } ++num_instructions; break; } -- cgit v1.2.3-59-g8ed1b