Deoptimize boot image when profiling boot class path

Used for getting JIT samples for boot image methods.

Test: adb shell profman --dump-classes-and-methods --profile-file=/data/misc/profiles/cur/0/android/primary.prof --apk=/apex/com.android.art/javalib/core-oj.jar
Bug: 139883463

Change-Id: Ib22b4539a24c7e57be8ac3e974e6681e754b06ff
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 9af2f41..8f68b55 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1578,9 +1578,9 @@
       }
       class_linker_->AddExtraBootDexFiles(self, std::move(extra_boot_class_path));
     }
-    if (IsJavaDebuggable()) {
-      // Now that we have loaded the boot image, deoptimize its methods if we are running
-      // debuggable, as the code may have been compiled non-debuggable.
+    if (IsJavaDebuggable() || jit_options_->GetProfileSaverOptions().GetProfileBootClassPath()) {
+      // Deoptimize the boot image if debuggable  as the code may have been compiled non-debuggable.
+      // Also deoptimize if we are profiling the boot class path.
       ScopedThreadSuspension sts(self, ThreadState::kNative);
       ScopedSuspendAll ssa(__FUNCTION__);
       DeoptimizeBootImage();