OSDN Git Service

Make system server profiling an explicit runtime intent
authorCalin Juravle <calin@google.com>
Fri, 4 May 2018 02:51:18 +0000 (19:51 -0700)
committerCalin Juravle <calin@google.com>
Fri, 4 May 2018 03:06:10 +0000 (20:06 -0700)
Pass an explicit flag to the runtime when we need to profile the system
server. This ensures that we only start the ProfileSaver and allocate the
code cache when needed.

Test: manual, on a device with system server profiling enabled
Bug: 74081010
Change-Id: I5647e0bfb47d31c0e39bb3f59650cc956f49c4db

core/java/com/android/internal/os/Zygote.java
core/java/com/android/internal/os/ZygoteInit.java

index 0d10888..e187862 100644 (file)
@@ -70,6 +70,10 @@ public final class Zygote {
      */
     public static final int API_ENFORCEMENT_POLICY_SHIFT =
             Integer.numberOfTrailingZeros(API_ENFORCEMENT_POLICY_MASK);
+    /**
+     * Enable system server ART profiling.
+     */
+    public static final int PROFILE_SYSTEM_SERVER = 1 << 14;
 
     /** No external storage should be mounted. */
     public static final int MOUNT_EXTERNAL_NONE = 0;
index c8e7102..1df2dca 100644 (file)
@@ -671,6 +671,12 @@ public class ZygoteInit {
             ZygoteConnection.applyDebuggerSystemProperty(parsedArgs);
             ZygoteConnection.applyInvokeWithSystemProperty(parsedArgs);
 
+            boolean profileSystemServer = SystemProperties.getBoolean(
+                    "dalvik.vm.profilesystemserver", false);
+            if (profileSystemServer) {
+                parsedArgs.runtimeFlags |= Zygote.PROFILE_SYSTEM_SERVER;
+            }
+
             /* Request to fork the system server process */
             pid = Zygote.forkSystemServer(
                     parsedArgs.uid, parsedArgs.gid,