Avoid making oat files executable for system server profiling

Done so that we will only use JIT + interpreter to get samples for
services.jar.

Bug: 139883463
Test: showmap `pid system_server` and verify

Change-Id: I6f13446948fd92a43a9312988fd6e00ee4a0ed41
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index e4c7dc3..687ec54 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -473,7 +473,7 @@
 
   OatFileAssistant oat_file_assistant(dex_location,
                                       kRuntimeISA,
-                                      !runtime->IsAotCompiler(),
+                                      runtime->GetOatFilesExecutable(),
                                       only_use_system_oat_files_);
 
   // Get the oat file on disk.
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index b6b7501..c6d9bfd 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -986,7 +986,6 @@
         UnloadNativeBridge();
         is_native_bridge_loaded_ = false;
         break;
-
       case NativeBridgeAction::kInitialize:
         InitializeNativeBridge(env, isa);
         break;
@@ -2965,4 +2964,8 @@
   WellKnownClasses::HandleJniIdTypeChange(Thread::Current()->GetJniEnv());
 }
 
+bool Runtime::GetOatFilesExecutable() const {
+  return !IsAotCompiler() && !(IsSystemServer() && jit_options_->GetSaveProfilingInfo());
+}
+
 }  // namespace art
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 71eb7ea..ac84d32 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -92,6 +92,7 @@
 class IsMarkedVisitor;
 class JavaVMExt;
 class LinearAlloc;
+class MethodInspectionCallback;
 class MonitorList;
 class MonitorPool;
 class NullPointerHandler;
@@ -942,6 +943,9 @@
     return verifier_missing_kthrow_fatal_;
   }
 
+  // Return true if we should load oat files as executable or not.
+  bool GetOatFilesExecutable() const;
+
  private:
   static void InitPlatformSignalHandlers();