*
* Returns 0 on success.
*/
- int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
+ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote)
{
- int result = -1;
JavaVMInitArgs initArgs;
char propBuf[PROPERTY_VALUE_MAX];
char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX];
parseRuntimeOption("dalvik.vm.gctype", gctypeOptsBuf, "-Xgc:");
parseRuntimeOption("dalvik.vm.backgroundgctype", backgroundgcOptsBuf, "-XX:BackgroundGC=");
- /* enable debugging; set suspend=y to pause during VM init */
- /* use android ADB transport */
- addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
+ /*
- * Enable or disable dexopt features, such as bytecode verification and
- * calculation of register maps for precise GC.
- */
- property_get("dalvik.vm.dexopt-flags", dexoptFlagsBuf, "");
- if (dexoptFlagsBuf[0] != '\0') {
- const char* opc;
- const char* val;
-
- opc = strstr(dexoptFlagsBuf, "v="); /* verification */
- if (opc != NULL) {
- switch (*(opc+2)) {
- case 'n': val = "-Xverify:none"; break;
- case 'r': val = "-Xverify:remote"; break;
- case 'a': val = "-Xverify:all"; break;
- default: val = NULL; break;
- }
-
- if (val != NULL) {
- addOption(val);
- }
- }
-
- opc = strstr(dexoptFlagsBuf, "o="); /* optimization */
- if (opc != NULL) {
- switch (*(opc+2)) {
- case 'n': val = "-Xdexopt:none"; break;
- case 'v': val = "-Xdexopt:verified"; break;
- case 'a': val = "-Xdexopt:all"; break;
- case 'f': val = "-Xdexopt:full"; break;
- default: val = NULL; break;
- }
-
- if (val != NULL) {
- addOption(val);
- }
- }
-
- opc = strstr(dexoptFlagsBuf, "m=y"); /* register map */
- if (opc != NULL) {
- addOption("-Xgenregmap");
-
- /* turn on precise GC while we're at it */
- addOption("-Xgc:precise");
- }
- }
-
- /*
+ * Enable debugging only for apps forked from zygote.
+ * Set suspend=y to pause during VM init and use android ADB transport.
+ */
+ if (zygote) {
+ addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
+ }
parseRuntimeOption("dalvik.vm.lockprof.threshold",
lockProfThresholdBuf,