Skip to content

Commit 3beff1e

Browse files
committed
Add dex2oat-flags plumbing to AndroidRuntime
Change-Id: Idaa7e5351e146d76e1972cbe4d93af69f0b999a6
1 parent 22f66b7 commit 3beff1e

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

core/jni/AndroidRuntime.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,16 @@ static void readLocale(char* language, char* region)
395395
*
396396
* This will cut up "extraOptsBuf" as we chop it into individual options.
397397
*
398+
* If "quotingArg" is non-null, it is passed before each extra option in mOptions.
399+
*
398400
* Adds the strings, if any, to mOptions.
399401
*/
400-
void AndroidRuntime::parseExtraOpts(char* extraOptsBuf)
402+
void AndroidRuntime::parseExtraOpts(char* extraOptsBuf, const char* quotingArg)
401403
{
402404
JavaVMOption opt;
403-
char* start;
404-
char* end;
405-
406405
memset(&opt, 0, sizeof(opt));
407-
start = extraOptsBuf;
406+
char* start = extraOptsBuf;
407+
char* end = NULL;
408408
while (*start != '\0') {
409409
while (*start == ' ') /* skip leading whitespace */
410410
start++;
@@ -418,6 +418,11 @@ void AndroidRuntime::parseExtraOpts(char* extraOptsBuf)
418418
*end++ = '\0'; /* mark end, advance to indicate more */
419419

420420
opt.optionString = start;
421+
if (quotingArg != NULL) {
422+
JavaVMOption quotingOpt;
423+
quotingOpt.optionString = quotingArg;
424+
mOptions.add(quotingOpt);
425+
}
421426
mOptions.add(opt);
422427
start = end;
423428
}
@@ -449,6 +454,9 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
449454
char gctypeOptsBuf[sizeof("-Xgc:")-1 + PROPERTY_VALUE_MAX];
450455
char heaptargetutilizationOptsBuf[sizeof("-XX:HeapTargetUtilization=")-1 + PROPERTY_VALUE_MAX];
451456
char jitcodecachesizeOptsBuf[sizeof("-Xjitcodecachesize:")-1 + PROPERTY_VALUE_MAX];
457+
char dalvikVmLibBuf[PROPERTY_VALUE_MAX];
458+
char dex2oatFlagsBuf[PROPERTY_VALUE_MAX];
459+
char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX];
452460
char extraOptsBuf[PROPERTY_VALUE_MAX];
453461
char* stackTraceFile = NULL;
454462
bool checkJni = false;
@@ -741,9 +749,22 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
741749
mOptions.add(opt);
742750
}
743751

752+
// libart tolerates libdvm flags, but not vice versa, so only pass these if libart.
753+
property_get("persist.sys.dalvik.vm.lib.1", dalvikVmLibBuf, "libdvm.so");
754+
if (strncmp(dalvikVmLibBuf, "libart", 6) == 0) {
755+
756+
// Extra options for DexClassLoader.
757+
property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, "");
758+
parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option");
759+
760+
// Extra options for boot.art/boot.oat image generation.
761+
property_get("dalvik.vm.image-dex2oat-flags", dex2oatImageFlagsBuf, "");
762+
parseExtraOpts(dex2oatImageFlagsBuf, "-Ximage-compiler-option");
763+
}
764+
744765
/* extra options; parse this late so it overrides others */
745766
property_get("dalvik.vm.extra-opts", extraOptsBuf, "");
746-
parseExtraOpts(extraOptsBuf);
767+
parseExtraOpts(extraOptsBuf, NULL);
747768

748769
/* Set the properties for locale */
749770
{

include/android_runtime/AndroidRuntime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class AndroidRuntime
115115

116116
private:
117117
static int startReg(JNIEnv* env);
118-
void parseExtraOpts(char* extraOptsBuf);
118+
void parseExtraOpts(char* extraOptsBuf, const char* quotingArg);
119119
int startVm(JavaVM** pJavaVM, JNIEnv** pEnv);
120120

121121
Vector<JavaVMOption> mOptions;

0 commit comments

Comments
 (0)