diff options
author | 2010-07-30 11:26:29 -0700 | |
---|---|---|
committer | 2010-07-30 11:26:29 -0700 | |
commit | 1951356a71f19c9d6a8c11d22a6dd2663a32f40e (patch) | |
tree | ad30b35202ecd87e21ae36f8e3c14289c5f3d355 | |
parent | 48c05739dd7e58552fb5b856c243edc692e9c456 (diff) | |
parent | e4d81f25bd4dc1a5c909b56ab56a56406290da30 (diff) |
Merge "Add support for dalvik.vm.extra-opts property."
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 41 | ||||
-rw-r--r-- | include/android_runtime/AndroidRuntime.h | 1 |
2 files changed, 41 insertions, 1 deletions
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 3b91710be969..b3b33fd2d455 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -519,6 +519,40 @@ static void readLocale(char* language, char* region) } /* + * Parse a property containing space-separated options that should be + * passed directly to the VM, e.g. "-Xmx32m -verbose:gc -Xregenmap". + * + * This will cut up "extraOptsBuf" as we chop it into individual options. + * + * Adds the strings, if any, to mOptions. + */ +void AndroidRuntime::parseExtraOpts(char* extraOptsBuf) +{ + JavaVMOption opt; + char* start; + char* end; + + memset(&opt, 0, sizeof(opt)); + start = extraOptsBuf; + while (*start != '\0') { + while (*start == ' ') /* skip leading whitespace */ + start++; + if (*start == '\0') /* was trailing ws, bail */ + break; + + end = start+1; + while (*end != ' ' && *end != '\0') /* find end of token */ + end++; + if (*end == ' ') + *end++ = '\0'; /* mark end, advance to indicate more */ + + opt.optionString = start; + mOptions.add(opt); + start = end; + } +} + +/* * Start the Dalvik Virtual Machine. * * Various arguments, most determined by system properties, are passed in. @@ -537,6 +571,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) char enableAssertBuf[sizeof("-ea:")-1 + PROPERTY_VALUE_MAX]; char jniOptsBuf[sizeof("-Xjniopts:")-1 + PROPERTY_VALUE_MAX]; char heapsizeOptsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; + char extraOptsBuf[PROPERTY_VALUE_MAX]; char* stackTraceFile = NULL; bool checkJni = false; bool checkDexSum = false; @@ -845,7 +880,11 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) opt.optionString = stackTraceFile; mOptions.add(opt); } - + + /* extra options; parse this late so it overrides others */ + property_get("dalvik.vm.extra-opts", extraOptsBuf, ""); + parseExtraOpts(extraOptsBuf); + /* Set the properties for locale */ { char langOption[sizeof("-Duser.language=") + 3]; diff --git a/include/android_runtime/AndroidRuntime.h b/include/android_runtime/AndroidRuntime.h index 2ded5be99aec..22c9b72b6276 100644 --- a/include/android_runtime/AndroidRuntime.h +++ b/include/android_runtime/AndroidRuntime.h @@ -100,6 +100,7 @@ public: private: static int startReg(JNIEnv* env); + void parseExtraOpts(char* extraOptsBuf); int startVm(JavaVM** pJavaVM, JNIEnv** pEnv); Vector<JavaVMOption> mOptions; |