Preload const-strings only for profile methods.

This fixes a boot image size regression due to including all
the const-strings.

Note that this re-introduces one source of non-determinism
when compiling the boot image, i.e. string resolution for
inlined methods not present in the profile. This shall be
fixed by a follow-up CL.

Boot image sizes for aosp_taimen-userdebug:
 - before:
   arm/boot*.art: 14483456
   arm64/boot*.art: 18751488
 - after:
   arm/boot*.art: 12349440 (-2.0MiB)
   arm64/boot*.art: 16609280 (-2.0MiB)

Test: aosp_taimen-userdebug boots.
Test: m test-art-host-gtest
Bug: 76145463
Bug: 26687569
Change-Id: I5127d58bc7bdf24532fda6cc7d32a1bd2068452e
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index 4b6115a..b73a7d8 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -696,11 +696,12 @@
             (method.GetAccessFlags() & kAccStatic) != 0;
         const bool is_startup_clinit = is_startup_class && is_clinit;
 
-        if (only_startup_strings &&
-            profile_compilation_info != nullptr &&
-            (!profile_compilation_info->GetMethodHotness(method.GetReference()).IsStartup() &&
-             !is_startup_clinit)) {
-          continue;
+        if (profile_compilation_info != nullptr && !is_startup_clinit) {
+          ProfileCompilationInfo::MethodHotness hotness =
+              profile_compilation_info->GetMethodHotness(method.GetReference());
+          if (only_startup_strings ? !hotness.IsStartup() : !hotness.IsInProfile()) {
+            continue;
+          }
         }
 
         // Resolve const-strings in the code. Done to have deterministic allocation behavior. Right