summaryrefslogtreecommitdiff
path: root/dalvik
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2019-04-01 22:44:48 +0000
committerDavid Brazdil <dbrazdil@google.com>2019-04-01 23:54:00 +0100
commitd1aa7cd9588a3108ea8e81b1009d7fc2f752d4c9 (patch)
tree701de5ed27f5a9fc6042c2885a6869daed54d19f /dalvik
parent57d69bd0bac0ccd6d7d604b449109027f9bb7d78 (diff)
Revert^2: Spawn background verification for InMemoryDexClassLoader
After dex files have been loaded with InMemoryDexClassLoader, call DexFile.verifyInBackground which instructs ART to spawn a background thread and verify all newly loaded classes. This thread will be used for creating a vdex file to speed up subsequent loads of the same bytecode. This reverts commit f501b1226e786d1eedb638fa0292970827f4343a. Bug: 72131483 Change-Id: I46cd8f854642ff3d30d3b595ffa035aeb6f2c8ec Test: art/tools/run-libcore-tests.sh Test: art/test.py -b -r -t 692
Diffstat (limited to 'dalvik')
-rw-r--r--dalvik/src/main/java/dalvik/system/DexFile.java12
-rw-r--r--dalvik/src/main/java/dalvik/system/DexPathList.java5
2 files changed, 17 insertions, 0 deletions
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 8d32931afc..48e34c85da 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -389,6 +389,18 @@ public final class DexFile {
int[] starts, int[] ends);
/*
+ * Initiates background verification of this DexFile. This is a sepearate down-call
+ * from openDexFile and openInMemoryDexFiles because it requires the class loader's
+ * DexPathList to have been initialized for its classes to be resolvable by ART.
+ * DexPathList will open the dex files first, finalize `dexElements` and then call this.
+ */
+ /*package*/ void verifyInBackground(ClassLoader classLoader) {
+ verifyInBackgroundNative(mCookie, classLoader);
+ }
+
+ private static native void verifyInBackgroundNative(Object mCookie, ClassLoader classLoader);
+
+ /*
* Returns true if the dex file is backed by a valid oat file.
*/
@UnsupportedAppUsage
diff --git a/dalvik/src/main/java/dalvik/system/DexPathList.java b/dalvik/src/main/java/dalvik/system/DexPathList.java
index fc57dc0a25..5efefddc78 100644
--- a/dalvik/src/main/java/dalvik/system/DexPathList.java
+++ b/dalvik/src/main/java/dalvik/system/DexPathList.java
@@ -268,6 +268,11 @@ public final class DexPathList {
Element[] null_elements = null;
DexFile dex = new DexFile(dexFiles);
dexElements = new Element[] { new Element(dex) };
+ // Spawn background thread to verify all classes and cache verification results.
+ // Must be called *after* `dexElements` has been initialized for ART to find
+ // its classes (the field is hardcoded in ART and dex files iterated over in
+ // the order of the array).
+ dex.verifyInBackground(definingContext);
} catch (IOException suppressed) {
System.logE("Unable to load dex files", suppressed);
suppressedExceptions.add(suppressed);