@@ -1000,44 +1000,49 @@ public void startElement(String uri, String localName, String qname, Attributes
1000
1000
}
1001
1001
methods .put (id , m );
1002
1002
} 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
+ }
1041
1046
} else if (qname .equals ("intrinsic" )) {
1042
1047
String id = atts .getValue ("id" );
1043
1048
assert id != null : "intrinsic id is null" ;
@@ -1049,15 +1054,20 @@ public void startElement(String uri, String localName, String qname, Attributes
1049
1054
} else if (qname .equals ("replace_string_concat" )) {
1050
1055
expectStringConcatTrap = true ;
1051
1056
} 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" ;
1059
1060
} 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
+ }
1061
1071
}
1062
1072
} else if (qname .equals ("inline_success" )) {
1063
1073
if (methodHandleSite != null ) {
@@ -1100,10 +1110,11 @@ public void startElement(String uri, String localName, String qname, Attributes
1100
1110
return ;
1101
1111
}
1102
1112
try {
1113
+ String currBytecode = current_bytecode >= 0 ? bytecodes [current_bytecode ] : "<unknown>" ;
1103
1114
UncommonTrap unc = new UncommonTrap (Integer .parseInt (search (atts , "bci" )),
1104
1115
search (atts , "reason" ),
1105
1116
search (atts , "action" ),
1106
- bytecodes [ current_bytecode ] );
1117
+ currBytecode );
1107
1118
if (scopes .size () == 0 ) {
1108
1119
// There may be a dangling site not yet in scopes after a late_inline
1109
1120
if (site != null ) {
@@ -1292,8 +1303,9 @@ public void endElement(String uri, String localName, String qname) {
1292
1303
if (scopes .size () == 0 ) {
1293
1304
lateInlining = false ;
1294
1305
}
1295
- // Don't carry a stale site to the next parse
1306
+ // Clear the bytecode and site from the last parse
1296
1307
site = null ;
1308
+ current_bytecode = -1 ;
1297
1309
} else if (qname .equals ("uncommon_trap" )) {
1298
1310
currentTrap = null ;
1299
1311
} else if (qname .startsWith ("eliminate_lock" )) {
0 commit comments