@@ -395,16 +395,16 @@ static void readLocale(char* language, char* region)
395
395
*
396
396
* This will cut up "extraOptsBuf" as we chop it into individual options.
397
397
*
398
+ * If "quotingArg" is non-null, it is passed before each extra option in mOptions.
399
+ *
398
400
* Adds the strings, if any, to mOptions.
399
401
*/
400
- void AndroidRuntime::parseExtraOpts (char * extraOptsBuf)
402
+ void AndroidRuntime::parseExtraOpts (char * extraOptsBuf, const char * quotingArg )
401
403
{
402
404
JavaVMOption opt;
403
- char * start;
404
- char * end;
405
-
406
405
memset (&opt, 0 , sizeof (opt));
407
- start = extraOptsBuf;
406
+ char * start = extraOptsBuf;
407
+ char * end = NULL ;
408
408
while (*start != ' \0 ' ) {
409
409
while (*start == ' ' ) /* skip leading whitespace */
410
410
start++;
@@ -418,6 +418,11 @@ void AndroidRuntime::parseExtraOpts(char* extraOptsBuf)
418
418
*end++ = ' \0 ' ; /* mark end, advance to indicate more */
419
419
420
420
opt.optionString = start;
421
+ if (quotingArg != NULL ) {
422
+ JavaVMOption quotingOpt;
423
+ quotingOpt.optionString = quotingArg;
424
+ mOptions .add (quotingOpt);
425
+ }
421
426
mOptions .add (opt);
422
427
start = end;
423
428
}
@@ -449,6 +454,9 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
449
454
char gctypeOptsBuf[sizeof (" -Xgc:" )-1 + PROPERTY_VALUE_MAX];
450
455
char heaptargetutilizationOptsBuf[sizeof (" -XX:HeapTargetUtilization=" )-1 + PROPERTY_VALUE_MAX];
451
456
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];
452
460
char extraOptsBuf[PROPERTY_VALUE_MAX];
453
461
char * stackTraceFile = NULL ;
454
462
bool checkJni = false ;
@@ -741,9 +749,22 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv)
741
749
mOptions .add (opt);
742
750
}
743
751
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
+
744
765
/* extra options; parse this late so it overrides others */
745
766
property_get (" dalvik.vm.extra-opts" , extraOptsBuf, " " );
746
- parseExtraOpts (extraOptsBuf);
767
+ parseExtraOpts (extraOptsBuf, NULL );
747
768
748
769
/* Set the properties for locale */
749
770
{
0 commit comments