@@ -1468,19 +1468,102 @@ JavaCoreDumpWriter::writeEnvUserArgsHelper(J9VMInitArgs *vmArgs)
1468
1468
}
1469
1469
1470
1470
{
1471
- /* write ignored options */
1472
- bool anyIgnored = false ;
1471
+ /* Write ignored options.
1472
+ *
1473
+ * An option is printed as ignored if it has been consumed or if it is an -Xjit or
1474
+ * -Xaot option that fall under the rules below.
1475
+ *
1476
+ * Ignored options for -Xjit and -Xaot follows these rules:
1477
+ * 1. If -Xjit is followed by -Xint or -Xnojit,
1478
+ * then any -Xjit:optionString beforehand appears as ignored.
1479
+ * 2. If -XX:+MergeCompilerOptions is present,
1480
+ * then all -Xjit options after -Xint or -Xnojit should not be ignored.
1481
+ * 3. If multiple -Xjit strings appear, all but the last one will appear as ignored.
1482
+ *
1483
+ * Similar rules apply for -Xaot.
1484
+ */
1485
+
1486
+ jint numXjit = 0 ;
1487
+ jint numXaot = 0 ;
1488
+ bool hasXXMerge = false ;
1489
+
1490
+ /* These indices ensure all the options before them will be printed as ignored. */
1491
+ jint ignoreXjitBefore = 0 ;
1492
+ jint ignoreXaotBefore = 0 ;
1473
1493
1474
1494
for (jint i = 0 ; i < args->nOptions ; i++) {
1495
+ const char *optionString = args->options [i].optionString ;
1496
+
1497
+ if (0 == strncmp (optionString, " -Xint" , 6 )) {
1498
+ /* Case 1: ignore all options before. */
1499
+ ignoreXjitBefore = numXjit;
1500
+ ignoreXaotBefore = numXaot;
1501
+ } else if (0 == strncmp (optionString, " -Xnojit" , 8 )) {
1502
+ /* Case 1: ignore all -Xjit options before. */
1503
+ ignoreXjitBefore = numXjit;
1504
+ } else if (0 == strncmp (optionString, " -Xnoaot" , 8 )) {
1505
+ /* Case 1: ignore all -Xaot options before. */
1506
+ ignoreXaotBefore = numXaot;
1507
+ } else if (0 == strncmp (optionString, " -XX:+MergeCompilerOptions" , 26 )) {
1508
+ /* Case 2. */
1509
+ hasXXMerge = true ;
1510
+ } else if (0 == strncmp (optionString, " -XX:-MergeCompilerOptions" , 26 )) {
1511
+ /* If -XX:-MergeCompilerOptions is encountered after
1512
+ * -XX:+MergeCompilerOptions, the latter is overriden.
1513
+ */
1514
+ hasXXMerge = false ;
1515
+ } else if (0 == strncmp (optionString, " -Xjit:" , 6 )) {
1516
+ /* Case 3. */
1517
+ numXjit += 1 ;
1518
+ } else if (0 == strncmp (optionString, " -Xaot:" , 6 )) {
1519
+ /* Case 3. */
1520
+ numXaot += 1 ;
1521
+ }
1522
+ }
1523
+
1524
+ bool anyIgnored = false ;
1525
+ jint countXjit = 0 ;
1526
+ jint countXaot = 0 ;
1527
+ for (jint i = 0 ; i < args->nOptions ; i++) {
1528
+ bool optionIgnored = false ;
1529
+ const char *optionString = args->options [i].optionString ;
1530
+
1475
1531
if (IS_CONSUMABLE (vmArgs, i) && !IS_CONSUMED (vmArgs, i)) {
1532
+ /* Argument consumed. */
1533
+ optionIgnored = true ;
1534
+ } else if (0 == strncmp (optionString, " -Xjit:" , 6 )) {
1535
+ countXjit += 1 ;
1536
+ if (countXjit <= ignoreXjitBefore) {
1537
+ /* Case 1: Anything before -Xint/-Xnojit is ignored. */
1538
+ optionIgnored = true ;
1539
+ } else {
1540
+ /* Cases 2 & 3: Only the last option is not ignored
1541
+ * unless -XX:+MergeCompilerOptions is in effect.
1542
+ */
1543
+ optionIgnored = (!hasXXMerge) && (countXjit < numXjit);
1544
+ }
1545
+ } else if (0 == strncmp (optionString, " -Xaot:" , 6 )) {
1546
+ countXaot += 1 ;
1547
+ if (countXaot <= ignoreXaotBefore) {
1548
+ /* Case 1: Anything before -Xint/-Xnoaot is ignored. */
1549
+ optionIgnored = true ;
1550
+ } else {
1551
+ /* Cases 2 & 3: Only the last option is not ignored
1552
+ * unless -XX:+MergeCompilerOptions is in effect.
1553
+ */
1554
+ optionIgnored = (!hasXXMerge) && (countXaot < numXaot);
1555
+ }
1556
+ }
1557
+
1558
+ if (optionIgnored) {
1476
1559
if (!anyIgnored) {
1477
1560
_OutputStream.writeCharacters (" NULL\n " );
1478
1561
_OutputStream.writeCharacters (ignoredArgsHeader);
1479
1562
anyIgnored = true ;
1480
1563
}
1481
1564
1482
1565
_OutputStream.writeCharacters (singleIgnoredArgHeader);
1483
- _OutputStream.writeCharacters (args-> options [i]. optionString );
1566
+ _OutputStream.writeCharacters (optionString);
1484
1567
_OutputStream.writeCharacters (" \n " );
1485
1568
}
1486
1569
}
0 commit comments