if (argv[i][1] == '-' && argv[i][2] == 0) {
return i+1;
}
-
- JavaVMOption opt;
- memset(&opt, 0, sizeof(opt));
- opt.optionString = (char*)argv[i];
- mOptions.add(opt);
+ addOption(argv[i]);
}
return i;
}
//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
* passed directly to the VM, e.g. "-Xmx32m -verbose:gc -Xregenmap".
*/
void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg)
{
- JavaVMOption opt;
- memset(&opt, 0, sizeof(opt));
char* start = extraOptsBuf;
char* end = NULL;
while (*start != '\0') {
if (*end == ' ')
*end++ = '\0'; /* mark end, advance to indicate more */
- opt.optionString = start;
if (quotingArg != NULL) {
- JavaVMOption quotingOpt;
- quotingOpt.optionString = quotingArg;
- mOptions.add(quotingOpt);
+ addOption(quotingArg);
}
- mOptions.add(opt);
+ addOption(start);
start = end;
}
}
if (buffer[runtimeArgLen] == '\0') {
return false;
}
-
- JavaVMOption opt;
- memset(&opt, 0, sizeof(opt));
-
- opt.optionString = buffer;
- mOptions.add(opt);
-
+ addOption(buffer);
return true;
}
if (buffer[compilerArgLen] == '\0') {
return false;
}
-
- JavaVMOption opt;
- memset(&opt, 0, sizeof(opt));
-
- opt.optionString = quotingArg;
- mOptions.add(opt);
-
- opt.optionString = buffer;
- mOptions.add(opt);
-
+ addOption(quotingArg);
+ addOption(buffer);
return true;
}
if (buffer[runtimeArgLen] == '\0') {
return false;
}
-
- JavaVMOption opt;
- memset(&opt, 0, sizeof(opt));
-
- 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);
-
+ addOption(quotingArg);
+ addOption("--runtime-arg");
+ addOption(quotingArg);
+ addOption(buffer);
return true;
}
{
int result = -1;
JavaVMInitArgs initArgs;
- JavaVMOption opt;
char propBuf[PROPERTY_VALUE_MAX];
char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX];
char dexoptFlagsBuf[PROPERTY_VALUE_MAX];
char dex2oatFlagsBuf[PROPERTY_VALUE_MAX];
char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX];
char extraOptsBuf[PROPERTY_VALUE_MAX];
+ char voldDecryptBuf[PROPERTY_VALUE_MAX];
enum {
kEMDefault,
kEMIntPortable,
ALOGD("CheckJNI is %s\n", checkJni ? "ON" : "OFF");
if (checkJni) {
/* extended JNI checking */
- opt.optionString = "-Xcheck:jni";
- mOptions.add(opt);
+ addOption("-Xcheck:jni");
/* set a cap on JNI global references */
- opt.optionString = "-Xjnigreflimit:2000";
- mOptions.add(opt);
+ addOption("-Xjnigreflimit:2000");
/* with -Xcheck:jni, this provides a JNI function call trace */
- //opt.optionString = "-verbose:jni";
- //mOptions.add(opt);
+ //addOption("-verbose:jni");
}
property_get("dalvik.vm.execution-mode", propBuf, "");
property_get("dalvik.vm.check-dex-sum", propBuf, "");
if (strcmp(propBuf, "true") == 0) {
/* perform additional DEX checksum tests */
- opt.optionString = "-Xcheckdexsum";
- mOptions.add(opt);
+ addOption("-Xcheckdexsum");
}
property_get("log.redirect-stdio", propBuf, "");
if (strcmp(propBuf, "true") == 0) {
/* convert stdout/stderr to log messages */
- opt.optionString = "-Xlog-stdio";
- mOptions.add(opt);
+ addOption("-Xlog-stdio");
}
strcpy(enableAssertBuf, "-ea:");
if (strcmp(enableAssertBuf+sizeof("-ea:")-1, "all") == 0)
enableAssertBuf[3] = '\0'; // truncate to "-ea"
ALOGI("Assertions enabled: '%s'\n", enableAssertBuf);
- opt.optionString = enableAssertBuf;
- mOptions.add(opt);
+ addOption(enableAssertBuf);
} else {
ALOGV("Assertions disabled\n");
}
}
/* route exit() to our handler */
- opt.extraInfo = (void*) runtime_exit;
- opt.optionString = "exit";
- mOptions.add(opt);
+ addOption("exit", (void*) runtime_exit);
/* route fprintf() to our handler */
- opt.extraInfo = (void*) runtime_vfprintf;
- opt.optionString = "vfprintf";
- mOptions.add(opt);
+ addOption("vfprintf", (void*) runtime_vfprintf);
/* register the framework-specific "is sensitive thread" hook */
- opt.extraInfo = (void*) runtime_isSensitiveThread;
- opt.optionString = "sensitiveThread";
- mOptions.add(opt);
-
- opt.extraInfo = NULL;
+ addOption("sensitiveThread", (void*) runtime_isSensitiveThread);
/* enable verbose; standard options are { jni, gc, class } */
- //options[curOpt++].optionString = "-verbose:jni";
- opt.optionString = "-verbose:gc";
- mOptions.add(opt);
- //options[curOpt++].optionString = "-verbose:class";
+ //addOption("-verbose:jni");
+ addOption("-verbose:gc");
+ //addOption("-verbose:class");
/*
* The default starting and maximum size of the heap. Larger
parseRuntimeOption("dalvik.vm.heapsize", heapsizeOptsBuf, "-Xmx", "16m");
// Increase the main thread's interpreter stack size for bug 6315322.
- opt.optionString = "-XX:mainThreadStackSize=24K";
- mOptions.add(opt);
+ addOption("-XX:mainThreadStackSize=24K");
// Set the max jit code cache size. Note: size of 0 will disable the JIT.
parseRuntimeOption("dalvik.vm.jit.codecachesize",
property_get("ro.config.low_ram", propBuf, "");
if (strcmp(propBuf, "true") == 0) {
- opt.optionString = "-XX:LowMemoryMode";
- mOptions.add(opt);
+ addOption("-XX:LowMemoryMode");
}
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
}
if (val != NULL) {
- opt.optionString = val;
- mOptions.add(opt);
+ addOption(val);
}
}
}
if (val != NULL) {
- opt.optionString = val;
- mOptions.add(opt);
+ addOption(val);
}
}
opc = strstr(dexoptFlagsBuf, "m=y"); /* register map */
if (opc != NULL) {
- opt.optionString = "-Xgenregmap";
- mOptions.add(opt);
+ addOption("-Xgenregmap");
/* turn on precise GC while we're at it */
- opt.optionString = "-Xgc:precise";
- mOptions.add(opt);
+ addOption("-Xgc:precise");
}
}
/* enable debugging; set suspend=y to pause during VM init */
/* use android ADB transport */
- opt.optionString =
- "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";
- mOptions.add(opt);
+ addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
parseRuntimeOption("dalvik.vm.lockprof.threshold",
lockProfThresholdBuf,
parseRuntimeOption("dalvik.vm.jit.method", jitMethodBuf, "-Xjitmethod:");
if (executionMode == kEMIntPortable) {
- opt.optionString = "-Xint:portable";
- mOptions.add(opt);
+ addOption("-Xint:portable");
} else if (executionMode == kEMIntFast) {
- opt.optionString = "-Xint:fast";
- mOptions.add(opt);
+ addOption("-Xint:fast");
} else if (executionMode == kEMJitCompiler) {
- opt.optionString = "-Xint:jit";
- mOptions.add(opt);
+ addOption("-Xint:jit");
}
// libart tolerates libdvm flags, but not vice versa, so only pass some options if libart.
bool libart = (strncmp(dalvikVmLibBuf, "libart", 6) == 0);
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.
parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xms", dex2oatXmsImageFlagsBuf,
"-Xms", "-Ximage-compiler-option");
parseCompilerRuntimeOption("dalvik.vm.image-dex2oat-Xmx", dex2oatXmxImageFlagsBuf,
"-Xmx", "-Ximage-compiler-option");
- parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf,
- "--compiler-filter=", "-Ximage-compiler-option");
+ if (skip_compilation) {
+ addOption("-Ximage-compiler-option");
+ addOption("--compiler-filter=verify-none");
+ } else {
+ parseCompilerOption("dalvik.vm.image-dex2oat-filter", dex2oatImageCompilerFilterBuf,
+ "--compiler-filter=", "-Ximage-compiler-option");
+ }
property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, "");
parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option");
"-Xms", "-Xcompiler-option");
parseCompilerRuntimeOption("dalvik.vm.dex2oat-Xmx", dex2oatXmxFlagsBuf,
"-Xmx", "-Xcompiler-option");
- parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf,
- "--compiler-filter=", "-Xcompiler-option");
+ if (skip_compilation) {
+ addOption("-Xcompiler-option");
+ addOption("--compiler-filter=interpret-only");
+ } else {
+ parseCompilerOption("dalvik.vm.dex2oat-filter", dex2oatCompilerFilterBuf,
+ "--compiler-filter=", "-Xcompiler-option");
+ }
property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, "");
parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option");
+
}
/* extra options; parse this late so it overrides others */
strcpy(langOption, "-Duser.language=");
strcpy(regionOption, "-Duser.region=");
readLocale(langOption, regionOption);
- opt.extraInfo = NULL;
- opt.optionString = langOption;
- mOptions.add(opt);
- opt.optionString = regionOption;
- mOptions.add(opt);
+ addOption(langOption);
+ addOption(regionOption);
}
/*
// Whether or not the profiler should be enabled.
property_get("dalvik.vm.profiler", propBuf, "0");
if (propBuf[0] == '1') {
- opt.optionString = "-Xenable-profiler";
- mOptions.add(opt);
+ addOption("-Xenable-profiler");
}
// 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.
property_get("dalvik.vm.profile.start-immed", propBuf, "0");
if (propBuf[0] == '1') {
- opt.optionString = "-Xprofile-start-immediately";
- mOptions.add(opt);
+ addOption("-Xprofile-start-immediately");
}
// Number of seconds during profile runs.