Skip to content

Commit 65756ab

Browse files
author
Eric Caspole
committed
8257802: LogCompilation throws couldn't find bytecode on JDK 8 log
Reviewed-by: kvn, redestad
1 parent a372be4 commit 65756ab

File tree

2 files changed

+66
-48
lines changed

2 files changed

+66
-48
lines changed

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,44 +1000,49 @@ public void startElement(String uri, String localName, String qname, Attributes
10001000
}
10011001
methods.put(id, m);
10021002
} else if (qname.equals("call")) {
1003-
if (methodHandleSite != null) {
1004-
methodHandleSite = null;
1005-
}
1006-
Method m = method(search(atts, "method"));
1007-
if (lateInlining && scopes.size() == 0) {
1008-
// re-attempting already seen call site (late inlining for MH invokes)
1009-
if (m != site.getMethod()) {
1010-
if (current_bci != site.getBci()) {
1011-
System.err.println(m + " bci: " + current_bci);
1012-
System.err.println(site.getMethod() + " bci: " + site.getBci());
1013-
reportInternalError("bci mismatch after late inlining");
1014-
}
1015-
site.setMethod(m);
1016-
}
1017-
} else {
1018-
// We're dealing with a new call site; the called method is
1019-
// likely to be parsed next.
1020-
site = new CallSite(current_bci, m);
1021-
}
1022-
site.setCount(Integer.parseInt(search(atts, "count", "0")));
1023-
String receiver = atts.getValue("receiver");
1024-
if (receiver != null) {
1025-
site.setReceiver(type(receiver));
1026-
site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
1027-
}
1028-
int methodHandle = Integer.parseInt(search(atts, "method_handle_intrinsic", "0"));
1029-
if (lateInlining && scopes.size() == 0) {
1030-
// The call was already added before this round of late
1031-
// inlining. Ignore.
1032-
} else if (methodHandle == 0) {
1033-
scopes.peek().add(site);
1034-
} else {
1035-
// method handle call site can be followed by another
1036-
// call (in case it is inlined). If that happens we
1037-
// discard the method handle call site. So we keep
1038-
// track of it but don't add it to the list yet.
1039-
methodHandleSite = site;
1040-
}
1003+
if (scopes.peek() == null) {
1004+
Phase p = phaseStack.peek();
1005+
assert p != null && p.getName().equals("optimizer") : "should not be in parse here";
1006+
} else {
1007+
if (methodHandleSite != null) {
1008+
methodHandleSite = null;
1009+
}
1010+
Method m = method(search(atts, "method"));
1011+
if (lateInlining && scopes.size() == 0) {
1012+
// re-attempting already seen call site (late inlining for MH invokes)
1013+
if (m != site.getMethod()) {
1014+
if (current_bci != site.getBci()) {
1015+
System.err.println(m + " bci: " + current_bci);
1016+
System.err.println(site.getMethod() + " bci: " + site.getBci());
1017+
reportInternalError("bci mismatch after late inlining");
1018+
}
1019+
site.setMethod(m);
1020+
}
1021+
} else {
1022+
// We're dealing with a new call site; the called method is
1023+
// likely to be parsed next.
1024+
site = new CallSite(current_bci, m);
1025+
}
1026+
site.setCount(Integer.parseInt(search(atts, "count", "0")));
1027+
String receiver = atts.getValue("receiver");
1028+
if (receiver != null) {
1029+
site.setReceiver(type(receiver));
1030+
site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
1031+
}
1032+
int methodHandle = Integer.parseInt(search(atts, "method_handle_intrinsic", "0"));
1033+
if (lateInlining && scopes.size() == 0) {
1034+
// The call was already added before this round of late
1035+
// inlining. Ignore.
1036+
} else if (methodHandle == 0) {
1037+
scopes.peek().add(site);
1038+
} else {
1039+
// method handle call site can be followed by another
1040+
// call (in case it is inlined). If that happens we
1041+
// discard the method handle call site. So we keep
1042+
// track of it but don't add it to the list yet.
1043+
methodHandleSite = site;
1044+
}
1045+
}
10411046
} else if (qname.equals("intrinsic")) {
10421047
String id = atts.getValue("id");
10431048
assert id != null : "intrinsic id is null";
@@ -1049,15 +1054,20 @@ public void startElement(String uri, String localName, String qname, Attributes
10491054
} else if (qname.equals("replace_string_concat")) {
10501055
expectStringConcatTrap = true;
10511056
} else if (qname.equals("inline_fail")) {
1052-
if (methodHandleSite != null) {
1053-
scopes.peek().add(methodHandleSite);
1054-
methodHandleSite = null;
1055-
}
1056-
if (lateInlining && scopes.size() == 0) {
1057-
site.setReason("fail: " + search(atts, "reason"));
1058-
lateInlining = false;
1057+
if (scopes.peek() == null) {
1058+
Phase p = phaseStack.peek();
1059+
assert p != null && p.getName().equals("optimizer") : "should not be in parse here";
10591060
} else {
1060-
scopes.peek().last().setReason("fail: " + search(atts, "reason"));
1061+
if (methodHandleSite != null) {
1062+
scopes.peek().add(methodHandleSite);
1063+
methodHandleSite = null;
1064+
}
1065+
if (lateInlining && scopes.size() == 0) {
1066+
site.setReason("fail: " + search(atts, "reason"));
1067+
lateInlining = false;
1068+
} else {
1069+
scopes.peek().last().setReason("fail: " + search(atts, "reason"));
1070+
}
10611071
}
10621072
} else if (qname.equals("inline_success")) {
10631073
if (methodHandleSite != null) {
@@ -1100,10 +1110,11 @@ public void startElement(String uri, String localName, String qname, Attributes
11001110
return;
11011111
}
11021112
try {
1113+
String currBytecode = current_bytecode >= 0 ? bytecodes[current_bytecode] : "<unknown>";
11031114
UncommonTrap unc = new UncommonTrap(Integer.parseInt(search(atts, "bci")),
11041115
search(atts, "reason"),
11051116
search(atts, "action"),
1106-
bytecodes[current_bytecode]);
1117+
currBytecode);
11071118
if (scopes.size() == 0) {
11081119
// There may be a dangling site not yet in scopes after a late_inline
11091120
if (site != null) {
@@ -1292,8 +1303,9 @@ public void endElement(String uri, String localName, String qname) {
12921303
if (scopes.size() == 0) {
12931304
lateInlining = false;
12941305
}
1295-
// Don't carry a stale site to the next parse
1306+
// Clear the bytecode and site from the last parse
12961307
site = null;
1308+
current_bytecode = -1;
12971309
} else if (qname.equals("uncommon_trap")) {
12981310
currentTrap = null;
12991311
} else if (qname.startsWith("eliminate_lock")) {

src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ && getReason().equals("unstable_fused_if")) {
118118
*/
119119
public void setCompilation(Compilation compilation) {
120120
super.setCompilation(compilation);
121+
122+
if (compilation.getSpecial() != null) {
123+
assert compilation.getLevel() == 0 : "Should be 0";
124+
return;
125+
}
126+
121127
// Attempt to associate a bytecode with with this trap
122128
CallSite site = compilation.getCall();
123129
int i = 0;

0 commit comments

Comments
 (0)