summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-08-04 19:17:06 +0100
committerCalin Juravle <calin@google.com>2014-08-06 19:28:28 +0100
commit576c384ed84cfcc5658e785af79aa925155e81fa (patch)
tree140b546c836f37cd42ef8d358cc0974299fdbbe6
parent8b8c718cbb4ac8d2e6210567d9b6097f428be222 (diff)
downloadbase-576c384ed84cfcc5658e785af79aa925155e81fa.tar.gz
Use native ISA for dex code (in case there's a NativeBridge)
In the presence of a native bridge it is more efficient to compile the dex directly to the native ISA than to use the shared library ISA as a reference. This can be achieve by configuring the readonly system properties to map between the .so ISA and the desired dex code .ISA (e.g. ro.dalvik.vm.isa.ISA1=ISA2). Bug: 16185267 Change-Id: I50baa7b37e1465b9adf72d6f6b96f526a08d59c7
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java46
1 files changed, 30 insertions, 16 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index f076fa0199b8..f98d90f37175 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -1350,7 +1350,7 @@ public class PackageManagerService extends IPackageManager.Stub {
boolean didDexOptLibraryOrTool = false;
- final List<String> instructionSets = getAllInstructionSets();
+ final List<String> dexCodeInstructionSets = getAllDexCodeInstructionSets();
/**
* Ensure all external libraries have had dexopt run on them.
@@ -1360,7 +1360,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// (and framework jars) into all available architectures. It's possible
// to compile them only when we come across an app that uses them (there's
// already logic for that in scanPackageLI) but that adds some complexity.
- for (String instructionSet : instructionSets) {
+ for (String dexCodeInstructionSet : dexCodeInstructionSets) {
for (SharedLibraryEntry libEntry : mSharedLibraries.values()) {
final String lib = libEntry.path;
if (lib == null) {
@@ -1369,16 +1369,16 @@ public class PackageManagerService extends IPackageManager.Stub {
try {
byte dexoptRequired = DexFile.isDexOptNeededInternal(lib, null,
- instructionSet,
+ dexCodeInstructionSet,
false);
if (dexoptRequired != DexFile.UP_TO_DATE) {
alreadyDexOpted.add(lib);
// The list of "shared libraries" we have at this point is
if (dexoptRequired == DexFile.DEXOPT_NEEDED) {
- mInstaller.dexopt(lib, Process.SYSTEM_UID, true, instructionSet);
+ mInstaller.dexopt(lib, Process.SYSTEM_UID, true, dexCodeInstructionSet);
} else {
- mInstaller.patchoat(lib, Process.SYSTEM_UID, true, instructionSet);
+ mInstaller.patchoat(lib, Process.SYSTEM_UID, true, dexCodeInstructionSet);
}
didDexOptLibraryOrTool = true;
}
@@ -1413,7 +1413,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// TODO: We could compile these only for the most preferred ABI. We should
// first double check that the dex files for these commands are not referenced
// by other system apps.
- for (String instructionSet : instructionSets) {
+ for (String dexCodeInstructionSet : dexCodeInstructionSets) {
for (int i=0; i<frameworkFiles.length; i++) {
File libPath = new File(frameworkDir, frameworkFiles[i]);
String path = libPath.getPath();
@@ -1427,13 +1427,13 @@ public class PackageManagerService extends IPackageManager.Stub {
}
try {
byte dexoptRequired = DexFile.isDexOptNeededInternal(path, null,
- instructionSet,
+ dexCodeInstructionSet,
false);
if (dexoptRequired == DexFile.DEXOPT_NEEDED) {
- mInstaller.dexopt(path, Process.SYSTEM_UID, true, instructionSet);
+ mInstaller.dexopt(path, Process.SYSTEM_UID, true, dexCodeInstructionSet);
didDexOptLibraryOrTool = true;
} else if (dexoptRequired == DexFile.PATCHOAT_NEEDED) {
- mInstaller.patchoat(path, Process.SYSTEM_UID, true, instructionSet);
+ mInstaller.patchoat(path, Process.SYSTEM_UID, true, dexCodeInstructionSet);
didDexOptLibraryOrTool = true;
}
} catch (FileNotFoundException e) {
@@ -1457,8 +1457,8 @@ public class PackageManagerService extends IPackageManager.Stub {
// small maintenance release update that the library and tool
// jars may be unchanged but APK could be removed resulting in
// unused dalvik-cache files.
- for (String instructionSet : instructionSets) {
- mInstaller.pruneDexCache(instructionSet);
+ for (String dexCodeInstructionSet : dexCodeInstructionSets) {
+ mInstaller.pruneDexCache(dexCodeInstructionSet);
}
// Additionally, delete all dex files from the root directory
@@ -4280,14 +4280,14 @@ public class PackageManagerService extends IPackageManager.Stub {
boolean forceDex, boolean defer, HashSet<String> done) {
final String instructionSet = instructionSetOverride != null ?
instructionSetOverride : getAppInstructionSet(pkg.applicationInfo);
-
+ final String dexCodeInstructionSet = getDexCodeInstructionSet(instructionSet);
if (done != null) {
done.add(pkg.packageName);
if (pkg.usesLibraries != null) {
- performDexOptLibsLI(pkg.usesLibraries, instructionSet, forceDex, defer, done);
+ performDexOptLibsLI(pkg.usesLibraries, dexCodeInstructionSet, forceDex, defer, done);
}
if (pkg.usesOptionalLibraries != null) {
- performDexOptLibsLI(pkg.usesOptionalLibraries, instructionSet, forceDex, defer, done);
+ performDexOptLibsLI(pkg.usesOptionalLibraries, dexCodeInstructionSet, forceDex, defer, done);
}
}
@@ -4301,7 +4301,7 @@ public class PackageManagerService extends IPackageManager.Stub {
// odex file and it matches the checksum of the image but not its base address,
// meaning we need to move it.
byte isDexOptNeededInternal = DexFile.isDexOptNeededInternal(path, pkg.packageName,
- instructionSet, defer);
+ dexCodeInstructionSet, defer);
// There are three basic cases here:
// 1.) we need to dexopt, either because we are forced or it is needed
// 2.) we are defering a needed dexopt
@@ -4310,7 +4310,7 @@ public class PackageManagerService extends IPackageManager.Stub {
Log.i(TAG, "Running dexopt on: " + pkg.applicationInfo.packageName);
final int sharedGid = UserHandle.getSharedAppGid(pkg.applicationInfo.uid);
int ret = mInstaller.dexopt(path, sharedGid, !isForwardLocked(pkg),
- pkg.packageName, instructionSet);
+ pkg.packageName, dexCodeInstructionSet);
// Note that we ran dexopt, since rerunning will
// probably just result in an error again.
pkg.mDexOptNeeded = false;
@@ -4399,6 +4399,20 @@ public class PackageManagerService extends IPackageManager.Stub {
return allInstructionSets;
}
+ public static String getDexCodeInstructionSet(String sharedLibraryIsa) {
+ String dexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + sharedLibraryIsa);
+ return (dexCodeIsa.isEmpty() ? sharedLibraryIsa : dexCodeIsa);
+ }
+
+ private static List<String> getAllDexCodeInstructionSets() {
+ List<String> instructionSets = getAllInstructionSets();
+ List<String> dexCodeInstructionSets = new ArrayList<String>(instructionSets.size());
+ for (String instructionSet : instructionSets) {
+ dexCodeInstructionSets.add(getDexCodeInstructionSet(instructionSet));
+ }
+ return dexCodeInstructionSets;
+ }
+
private int performDexOptLI(PackageParser.Package pkg, boolean forceDex, boolean defer,
boolean inclDependencies) {
HashSet<String> done;