Merge changes I69c064b0,I1972c5af

* changes:
  Move image classes options from art to AndroidRuntime [frameworks/base]
  Disable compilation based on vold.decrypt. [frameworks/base]
This commit is contained in:
Brian Carlstrom
2014-08-04 18:27:38 +00:00
committed by Gerrit Code Review
2 changed files with 70 additions and 107 deletions

View File

@@ -357,11 +357,7 @@ int AndroidRuntime::addVmArguments(int argc, const char* const argv[])
if (argv[i][1] == '-' && argv[i][2] == 0) { if (argv[i][1] == '-' && argv[i][2] == 0) {
return i+1; return i+1;
} }
addOption(argv[i]);
JavaVMOption opt;
memset(&opt, 0, sizeof(opt));
opt.optionString = (char*)argv[i];
mOptions.add(opt);
} }
return i; return i;
} }
@@ -395,6 +391,14 @@ static void readLocale(char* language, char* region)
//ALOGD("language=%s region=%s\n", language, region); //ALOGD("language=%s region=%s\n", language, region);
} }
void AndroidRuntime::addOption(const char* optionString, void* extraInfo)
{
JavaVMOption opt;
opt.optionString = optionString;
opt.extraInfo = extraInfo;
mOptions.add(opt);
}
/* /*
* Parse a property containing space-separated options that should be * Parse a property containing space-separated options that should be
* passed directly to the VM, e.g. "-Xmx32m -verbose:gc -Xregenmap". * passed directly to the VM, e.g. "-Xmx32m -verbose:gc -Xregenmap".
@@ -407,8 +411,6 @@ static void readLocale(char* language, char* region)
*/ */
void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg) void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg)
{ {
JavaVMOption opt;
memset(&opt, 0, sizeof(opt));
char* start = extraOptsBuf; char* start = extraOptsBuf;
char* end = NULL; char* end = NULL;
while (*start != '\0') { while (*start != '\0') {
@@ -423,13 +425,10 @@ void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg)
if (*end == ' ') if (*end == ' ')
*end++ = '\0'; /* mark end, advance to indicate more */ *end++ = '\0'; /* mark end, advance to indicate more */
opt.optionString = start;
if (quotingArg != NULL) { if (quotingArg != NULL) {
JavaVMOption quotingOpt; addOption(quotingArg);
quotingOpt.optionString = quotingArg;
mOptions.add(quotingOpt);
} }
mOptions.add(opt); addOption(start);
start = end; start = end;
} }
} }
@@ -457,13 +456,7 @@ bool AndroidRuntime::parseRuntimeOption(const char* property,
if (buffer[runtimeArgLen] == '\0') { if (buffer[runtimeArgLen] == '\0') {
return false; return false;
} }
addOption(buffer);
JavaVMOption opt;
memset(&opt, 0, sizeof(opt));
opt.optionString = buffer;
mOptions.add(opt);
return true; return true;
} }
@@ -490,16 +483,8 @@ bool AndroidRuntime::parseCompilerOption(const char* property,
if (buffer[compilerArgLen] == '\0') { if (buffer[compilerArgLen] == '\0') {
return false; return false;
} }
addOption(quotingArg);
JavaVMOption opt; addOption(buffer);
memset(&opt, 0, sizeof(opt));
opt.optionString = quotingArg;
mOptions.add(opt);
opt.optionString = buffer;
mOptions.add(opt);
return true; return true;
} }
@@ -527,22 +512,10 @@ bool AndroidRuntime::parseCompilerRuntimeOption(const char* property,
if (buffer[runtimeArgLen] == '\0') { if (buffer[runtimeArgLen] == '\0') {
return false; return false;
} }
addOption(quotingArg);
JavaVMOption opt; addOption("--runtime-arg");
memset(&opt, 0, sizeof(opt)); addOption(quotingArg);
addOption(buffer);
opt.optionString = quotingArg;
mOptions.add(opt);
opt.optionString = "--runtime-arg";
mOptions.add(opt);
opt.optionString = quotingArg;
mOptions.add(opt);
opt.optionString = buffer;
mOptions.add(opt);
return true; return true;
} }
@@ -566,7 +539,6 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
{ {
int result = -1; int result = -1;
JavaVMInitArgs initArgs; JavaVMInitArgs initArgs;
JavaVMOption opt;
char propBuf[PROPERTY_VALUE_MAX]; char propBuf[PROPERTY_VALUE_MAX];
char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX]; char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX];
char dexoptFlagsBuf[PROPERTY_VALUE_MAX]; char dexoptFlagsBuf[PROPERTY_VALUE_MAX];
@@ -591,6 +563,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
char dex2oatFlagsBuf[PROPERTY_VALUE_MAX]; char dex2oatFlagsBuf[PROPERTY_VALUE_MAX];
char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX]; char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX];
char extraOptsBuf[PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX];
char voldDecryptBuf[PROPERTY_VALUE_MAX];
enum { enum {
kEMDefault, kEMDefault,
kEMIntPortable, kEMIntPortable,
@@ -626,16 +599,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF"); ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF");
if (checkJni) { if (checkJni) {
/* extended JNI checking */ /* extended JNI checking */
opt.optionString = "-Xcheck:jni"; addOption("-Xcheck:jni");
mOptions.add(opt);
/* set a cap on JNI global references */ /* set a cap on JNI global references */
opt.optionString = "-Xjnigreflimit:2000"; addOption("-Xjnigreflimit:2000");
mOptions.add(opt);
/* with -Xcheck:jni, this provides a JNI function call trace */ /* with -Xcheck:jni, this provides a JNI function call trace */
//opt.optionString = "-verbose:jni"; //addOption("-verbose:jni");
//mOptions.add(opt);
} }
property_get("dalvik.vm.execution-mode", propBuf, ""); property_get("dalvik.vm.execution-mode", propBuf, "");
@@ -652,15 +622,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
property_get("dalvik.vm.check-dex-sum", propBuf, ""); property_get("dalvik.vm.check-dex-sum", propBuf, "");
if (strcmp(propBuf, "true") == 0) { if (strcmp(propBuf, "true") == 0) {
/* perform additional DEX checksum tests */ /* perform additional DEX checksum tests */
opt.optionString = "-Xcheckdexsum"; addOption("-Xcheckdexsum");
mOptions.add(opt);
} }
property_get("log.redirect-stdio", propBuf, ""); property_get("log.redirect-stdio", propBuf, "");
if (strcmp(propBuf, "true") == 0) { if (strcmp(propBuf, "true") == 0) {
/* convert stdout/stderr to log messages */ /* convert stdout/stderr to log messages */
opt.optionString = "-Xlog-stdio"; addOption("-Xlog-stdio");
mOptions.add(opt);
} }
strcpy(enableAssertBuf, "-ea:"); strcpy(enableAssertBuf, "-ea:");
@@ -670,8 +638,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
if (strcmp(enableAssertBuf+sizeof("-ea:")-1, "all") == 0) if (strcmp(enableAssertBuf+sizeof("-ea:")-1, "all") == 0)
enableAssertBuf[3] = '\0'; // truncate to "-ea" enableAssertBuf[3] = '\0'; // truncate to "-ea"
ALOGI("Assertions enabled: '%s'\n", enableAssertBuf); ALOGI("Assertions enabled: '%s'\n", enableAssertBuf);
opt.optionString = enableAssertBuf; addOption(enableAssertBuf);
mOptions.add(opt);
} else { } else {
ALOGV("Assertions disabled\n"); ALOGV("Assertions disabled\n");
} }
@@ -682,27 +649,18 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
} }
/* route exit() to our handler */ /* route exit() to our handler */
opt.extraInfo = (void*) runtime_exit; addOption("exit", (void*) runtime_exit);
opt.optionString = "exit";
mOptions.add(opt);
/* route fprintf() to our handler */ /* route fprintf() to our handler */
opt.extraInfo = (void*) runtime_vfprintf; addOption("vfprintf", (void*) runtime_vfprintf);
opt.optionString = "vfprintf";
mOptions.add(opt);
/* register the framework-specific "is sensitive thread" hook */ /* register the framework-specific "is sensitive thread" hook */
opt.extraInfo = (void*) runtime_isSensitiveThread; addOption("sensitiveThread", (void*) runtime_isSensitiveThread);
opt.optionString = "sensitiveThread";
mOptions.add(opt);
opt.extraInfo = NULL;
/* enable verbose; standard options are { jni, gc, class } */ /* enable verbose; standard options are { jni, gc, class } */
//options[curOpt++].optionString = "-verbose:jni"; //addOption("-verbose:jni");
opt.optionString = "-verbose:gc"; addOption("-verbose:gc");
mOptions.add(opt); //addOption("-verbose:class");
//options[curOpt++].optionString = "-verbose:class";
/* /*
* The default starting and maximum size of the heap. Larger * The default starting and maximum size of the heap. Larger
@@ -712,8 +670,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
parseRuntimeOption("dalvik.vm.heapsize", heapsizeOptsBuf, "-Xmx", "16m"); parseRuntimeOption("dalvik.vm.heapsize", heapsizeOptsBuf, "-Xmx", "16m");
// Increase the main thread's interpreter stack size for bug 6315322. // Increase the main thread's interpreter stack size for bug 6315322.
opt.optionString = "-XX:mainThreadStackSize=24K"; addOption("-XX:mainThreadStackSize=24K");
mOptions.add(opt);
// Set the max jit code cache size. Note: size of 0 will disable the JIT. // Set the max jit code cache size. Note: size of 0 will disable the JIT.
parseRuntimeOption("dalvik.vm.jit.codecachesize", parseRuntimeOption("dalvik.vm.jit.codecachesize",
@@ -729,8 +686,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
property_get("ro.config.low_ram", propBuf, ""); property_get("ro.config.low_ram", propBuf, "");
if (strcmp(propBuf, "true") == 0) { if (strcmp(propBuf, "true") == 0) {
opt.optionString = "-XX:LowMemoryMode"; addOption("-XX:LowMemoryMode");
mOptions.add(opt);
} }
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:"); parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
@@ -755,8 +711,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
} }
if (val != NULL) { if (val != NULL) {
opt.optionString = val; addOption(val);
mOptions.add(opt);
} }
} }
@@ -771,27 +726,22 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
} }
if (val != NULL) { if (val != NULL) {
opt.optionString = val; addOption(val);
mOptions.add(opt);
} }
} }
opc = strstr(dexoptFlagsBuf, "m=y"); /* register map */ opc = strstr(dexoptFlagsBuf, "m=y"); /* register map */
if (opc != NULL) { if (opc != NULL) {
opt.optionString = "-Xgenregmap"; addOption("-Xgenregmap");
mOptions.add(opt);
/* turn on precise GC while we're at it */ /* turn on precise GC while we're at it */
opt.optionString = "-Xgc:precise"; addOption("-Xgc:precise");
mOptions.add(opt);
} }
} }
/* enable debugging; set suspend=y to pause during VM init */ /* enable debugging; set suspend=y to pause during VM init */
/* use android ADB transport */ /* use android ADB transport */
opt.optionString = addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
"-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";
mOptions.add(opt);
parseRuntimeOption("dalvik.vm.lockprof.threshold", parseRuntimeOption("dalvik.vm.lockprof.threshold",
lockProfThresholdBuf, lockProfThresholdBuf,
@@ -804,14 +754,11 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
parseRuntimeOption("dalvik.vm.jit.method", jitMethodBuf, "-Xjitmethod:"); parseRuntimeOption("dalvik.vm.jit.method", jitMethodBuf, "-Xjitmethod:");
if (executionMode == kEMIntPortable) { if (executionMode == kEMIntPortable) {
opt.optionString = "-Xint:portable"; addOption("-Xint:portable");
mOptions.add(opt);
} else if (executionMode == kEMIntFast) { } else if (executionMode == kEMIntFast) {
opt.optionString = "-Xint:fast"; addOption("-Xint:fast");
mOptions.add(opt);
} else if (executionMode == kEMJitCompiler) { } else if (executionMode == kEMJitCompiler) {
opt.optionString = "-Xint:jit"; addOption("-Xint:jit");
mOptions.add(opt);
} }
// libart tolerates libdvm flags, but not vice versa, so only pass some options if libart. // libart tolerates libdvm flags, but not vice versa, so only pass some options if libart.
@@ -819,13 +766,27 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
bool libart = (strncmp(dalvikVmLibBuf, "libart", 6) == 0); bool libart = (strncmp(dalvikVmLibBuf, "libart", 6) == 0);
if (libart) { if (libart) {
// If we booting without the real /data, don't spend time compiling.
property_get("vold.decrypt", voldDecryptBuf, "");
bool skip_compilation = ((strcmp(voldDecryptBuf, "trigger_restart_min_framework") == 0) ||
(strcmp(voldDecryptBuf, "1") == 0));
// Extra options for boot.art/boot.oat image generation. // Extra options for boot.art/boot.oat image generation.
parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xms", dex2oatXmsImageFlagsBuf, parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xms", dex2oatXmsImageFlagsBuf,
"-Xms", "-Ximage-compiler-option"); "-Xms", "-Ximage-compiler-option");
parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xmx", dex2oatXmxImageFlagsBuf, parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xmx", dex2oatXmxImageFlagsBuf,
"-Xmx", "-Ximage-compiler-option"); "-Xmx", "-Ximage-compiler-option");
if (skip_compilation) {
addOption("-Ximage-compiler-option");
addOption("--compiler-filter=verify-none");
} else {
parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf, parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf,
"--compiler-filter=", "-Ximage-compiler-option"); "--compiler-filter=", "-Ximage-compiler-option");
}
addOption("-Ximage-compiler-option");
addOption("--image-classes-zip=/system/framework/framework.jar");
addOption("-Ximage-compiler-option");
addOption("--image-classes=preloaded-classes");
property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, ""); property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, "");
parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option"); parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option");
@@ -834,10 +795,16 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
"-Xms", "-Xcompiler-option"); "-Xms", "-Xcompiler-option");
parseCompilerRuntimeOption("dalvik.vm.dex2oat-Xmx", dex2oatXmxFlagsBuf, parseCompilerRuntimeOption("dalvik.vm.dex2oat-Xmx", dex2oatXmxFlagsBuf,
"-Xmx", "-Xcompiler-option"); "-Xmx", "-Xcompiler-option");
if (skip_compilation) {
addOption("-Xcompiler-option");
addOption("--compiler-filter=interpret-only");
} else {
parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf, parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf,
"--compiler-filter=", "-Xcompiler-option"); "--compiler-filter=", "-Xcompiler-option");
}
property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, ""); property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, "");
parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option"); parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option");
} }
/* extra options; parse this late so it overrides others */ /* extra options; parse this late so it overrides others */
@@ -849,11 +816,8 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
strcpy(langOption, "-Duser.language="); strcpy(langOption, "-Duser.language=");
strcpy(regionOption, "-Duser.region="); strcpy(regionOption, "-Duser.region=");
readLocale(langOption, regionOption); readLocale(langOption, regionOption);
opt.extraInfo = NULL; addOption(langOption);
opt.optionString = langOption; addOption(regionOption);
mOptions.add(opt);
opt.optionString = regionOption;
mOptions.add(opt);
} }
/* /*
@@ -863,16 +827,14 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
// Whether or not the profiler should be enabled. // Whether or not the profiler should be enabled.
property_get("dalvik.vm.profiler", propBuf, "0"); property_get("dalvik.vm.profiler", propBuf, "0");
if (propBuf[0] == '1') { if (propBuf[0] == '1') {
opt.optionString = "-Xenable-profiler"; addOption("-Xenable-profiler");
mOptions.add(opt);
} }
// Whether the profile should start upon app startup or be delayed by some random offset // Whether the profile should start upon app startup or be delayed by some random offset
// (in seconds) that is bound between 0 and a fixed value. // (in seconds) that is bound between 0 and a fixed value.
property_get("dalvik.vm.profile.start-immed", propBuf, "0"); property_get("dalvik.vm.profile.start-immed", propBuf, "0");
if (propBuf[0] == '1') { if (propBuf[0] == '1') {
opt.optionString = "-Xprofile-start-immediately"; addOption("-Xprofile-start-immediately");
mOptions.add(opt);
} }
// Number of seconds during profile runs. // Number of seconds during profile runs.

View File

@@ -116,6 +116,7 @@ public:
private: private:
static int startReg(JNIEnv* env); static int startReg(JNIEnv* env);
void addOption(const char* optionString, void* extra_info = NULL);
bool parseRuntimeOption(const char* property, bool parseRuntimeOption(const char* property,
char* buffer, char* buffer,
const char* runtimeArg, const char* runtimeArg,