diff options
| author | David Srbecky <dsrbecky@google.com> | 2019-08-05 15:43:34 +0100 |
|---|---|---|
| committer | Nicolas Geoffray <ngeoffray@google.com> | 2019-08-08 07:57:35 +0000 |
| commit | 6d0d7066cf4076abe63d64149041fc43634fc7aa (patch) | |
| tree | 9a2167718d8157b0c0bc7d6634f42b34d9def425 /core/java | |
| parent | 0473b08b6bee3da76b9bc300ba941b20159a22e0 (diff) | |
Notify the ART runtime when boot is complete.
Needed for jit-zygote performance improvements.
Test: device boots
Bug: 119800099
Change-Id: I1e46f49d94440384473430d8afebe29fbee9c68e
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/ZygoteProcess.java | 25 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteArguments.java | 13 | ||||
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteConnection.java | 9 |
3 files changed, 46 insertions, 1 deletions
diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java index e8f46417dd7d..d438103a22b5 100644 --- a/core/java/android/os/ZygoteProcess.java +++ b/core/java/android/os/ZygoteProcess.java @@ -648,6 +648,31 @@ public class ZygoteProcess { } /** + * Notify the Zygote processes that boot completed. + */ + public void bootCompleted() { + // Notify both the 32-bit and 64-bit zygote. + if (Build.SUPPORTED_32_BIT_ABIS.length > 0) { + bootCompleted(Build.SUPPORTED_32_BIT_ABIS[0]); + } + if (Build.SUPPORTED_64_BIT_ABIS.length > 0) { + bootCompleted(Build.SUPPORTED_64_BIT_ABIS[0]); + } + } + + private void bootCompleted(String abi) { + try { + synchronized (mLock) { + ZygoteState state = openZygoteSocketIfNeeded(abi); + state.mZygoteOutputWriter.write("1\n--boot-completed\n"); + state.mZygoteOutputWriter.flush(); + } + } catch (Exception ex) { + throw new RuntimeException("Failed to inform zygote of boot_completed", ex); + } + } + + /** * Push hidden API blacklisting exemptions into the zygote process(es). * * <p>The list of exemptions will take affect for all new processes forked from the zygote after diff --git a/core/java/com/android/internal/os/ZygoteArguments.java b/core/java/com/android/internal/os/ZygoteArguments.java index af90b150b4c6..c64103f4baf9 100644 --- a/core/java/com/android/internal/os/ZygoteArguments.java +++ b/core/java/com/android/internal/os/ZygoteArguments.java @@ -169,6 +169,11 @@ class ZygoteArguments { boolean mPidQuery; /** + * Whether the current arguments constitute a notification that boot completed. + */ + boolean mBootCompleted; + + /** * Exemptions from API blacklisting. These are sent to the pre-forked zygote at boot time, or * when they change, via --set-api-blacklist-exemptions. */ @@ -330,6 +335,8 @@ class ZygoteArguments { mAbiListQuery = true; } else if (arg.equals("--get-pid")) { mPidQuery = true; + } else if (arg.equals("--boot-completed")) { + mBootCompleted = true; } else if (arg.startsWith("--instruction-set=")) { mInstructionSet = arg.substring(arg.indexOf('=') + 1); } else if (arg.startsWith("--app-data-dir=")) { @@ -364,7 +371,11 @@ class ZygoteArguments { } } - if (mAbiListQuery || mPidQuery) { + if (mBootCompleted) { + if (args.length - curArg > 0) { + throw new IllegalArgumentException("Unexpected arguments after --boot-completed"); + } + } else if (mAbiListQuery || mPidQuery) { if (args.length - curArg > 0) { throw new IllegalArgumentException("Unexpected arguments after --query-abi-list."); } diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java index ad9f64cd2b0b..fc25a47b0edd 100644 --- a/core/java/com/android/internal/os/ZygoteConnection.java +++ b/core/java/com/android/internal/os/ZygoteConnection.java @@ -149,6 +149,11 @@ class ZygoteConnection { parsedArgs = new ZygoteArguments(args); + if (parsedArgs.mBootCompleted) { + handleBootCompleted(); + return null; + } + if (parsedArgs.mAbiListQuery) { handleAbiListQuery(); return null; @@ -291,6 +296,10 @@ class ZygoteConnection { } } + private void handleBootCompleted() { + VMRuntime.bootCompleted(); + } + /** * Preloads resources if the zygote is in lazily preload mode. Writes the result of the * preload operation; {@code 0} when a preload was initiated due to this request and {@code 1} |
