Skip to content

Commit f06ea27

Browse files
authored
Merge pull request #19990 from luke-li-2003/DumpIgnoredArgs
Display ignored -Xjit and -Xaot args in IGNOREDARGS list
2 parents beeb96b + ee032fc commit f06ea27

File tree

1 file changed

+77
-4
lines changed

1 file changed

+77
-4
lines changed

runtime/rasdump/javadump.cpp

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,19 +1468,92 @@ JavaCoreDumpWriter::writeEnvUserArgsHelper(J9VMInitArgs *vmArgs)
14681468
}
14691469

14701470
{
1471-
/* write ignored options */
1472-
bool anyIgnored = false;
1471+
/* Write ignored options.
1472+
*
1473+
* An option is printed as ignored if it has not been consumed or if
1474+
* it is an -Xjit or -Xaot option that falls 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+
/* The indices for the relevant options in args->options. */
1487+
jint lastXjit = -1;
1488+
jint lastXaot = -1;
1489+
jint lastXnojitOrXint = -1; /* The last occurence of either -Xnojit or -Xint. */
1490+
jint lastXnoaotOrXint = -1; /* The last occurence of either -Xnoaot or -Xint. */
1491+
bool hasXXMerge = false;
14731492

14741493
for (jint i = 0; i < args->nOptions; i++) {
1475-
if (IS_CONSUMABLE(vmArgs, i) && !IS_CONSUMED(vmArgs, i)) {
1494+
const char *optionString = args->options[i].optionString;
1495+
1496+
if (0 == strncmp(optionString, "-Xint", 6)) {
1497+
/* Case 1: ignore all -Xjit or -Xaot options before. */
1498+
lastXnojitOrXint = i;
1499+
lastXnoaotOrXint = i;
1500+
} else if (0 == strncmp(optionString, "-Xnojit", 8)) {
1501+
/* Case 1: ignore all -Xjit options before. */
1502+
lastXnojitOrXint = i;
1503+
} else if (0 == strncmp(optionString, "-Xnoaot", 8)) {
1504+
/* Case 1: ignore all -Xaot options before. */
1505+
lastXnoaotOrXint = i;
1506+
} else if (0 == strncmp(optionString, "-XX:+MergeCompilerOptions", 26)) {
1507+
/* Case 2. */
1508+
hasXXMerge = true;
1509+
} else if (0 == strncmp(optionString, "-XX:-MergeCompilerOptions", 26)) {
1510+
/* If -XX:-MergeCompilerOptions is encountered after
1511+
* -XX:+MergeCompilerOptions, the latter is overriden.
1512+
*/
1513+
hasXXMerge = false;
1514+
} else if ((0 == strncmp(optionString, "-Xjit", 5))
1515+
&& (('\0' == optionString[5]) || (':' == optionString[5]))
1516+
) {
1517+
/* Case 3. */
1518+
lastXjit = i;
1519+
} else if ((0 == strncmp(optionString, "-Xaot", 5))
1520+
&& (('\0' == optionString[5]) || (':' == optionString[5]))
1521+
) {
1522+
/* Case 3. */
1523+
lastXaot = i;
1524+
}
1525+
}
1526+
1527+
bool anyIgnored = false;
1528+
for (jint i = 0; i < args->nOptions; i++) {
1529+
bool optionIgnored = false;
1530+
const char *optionString = args->options[i].optionString;
1531+
1532+
if ((0 == strncmp(optionString, "-Xjit", 5))
1533+
&& (('\0' == optionString[5]) || (':' == optionString[5]))
1534+
) {
1535+
if ((i < lastXnojitOrXint) || ((i < lastXjit) && !hasXXMerge)) {
1536+
optionIgnored = true;
1537+
}
1538+
} else if ((0 == strncmp(optionString, "-Xaot", 5))
1539+
&& (('\0' == optionString[5]) || (':' == optionString[5]))
1540+
) {
1541+
if ((i < lastXnoaotOrXint) || ((i < lastXaot) && !hasXXMerge)) {
1542+
optionIgnored = true;
1543+
}
1544+
}
1545+
1546+
if (optionIgnored
1547+
|| (IS_CONSUMABLE(vmArgs, i) && !IS_CONSUMED(vmArgs, i))
1548+
) {
14761549
if (!anyIgnored) {
14771550
_OutputStream.writeCharacters("NULL\n");
14781551
_OutputStream.writeCharacters(ignoredArgsHeader);
14791552
anyIgnored = true;
14801553
}
14811554

14821555
_OutputStream.writeCharacters(singleIgnoredArgHeader);
1483-
_OutputStream.writeCharacters(args->options[i].optionString);
1556+
_OutputStream.writeCharacters(optionString);
14841557
_OutputStream.writeCharacters("\n");
14851558
}
14861559
}

0 commit comments

Comments
 (0)