comparison src/share/vm/opto/parse2.cpp @ 2383:9dc311b8473e

7008866: Missing loop predicate for loop with multiple entries Summary: Add predicates when loop head bytecode is parsed instead of when back branch bytecode is parsed. Reviewed-by: never
author kvn
date Mon, 21 Mar 2011 11:28:14 -0700
parents f95d63e2154a
children 1d1603768966
comparison
equal deleted inserted replaced
2382:3ef1a1866a60 2383:9dc311b8473e
291 int len = hi_index - lo_index + 1; 291 int len = hi_index - lo_index + 1;
292 292
293 if (len < 1) { 293 if (len < 1) {
294 // If this is a backward branch, add safepoint 294 // If this is a backward branch, add safepoint
295 maybe_add_safepoint(default_dest); 295 maybe_add_safepoint(default_dest);
296 if (should_add_predicate(default_dest)){
297 _sp += 1; // set original stack for use by uncommon_trap
298 add_predicate();
299 _sp -= 1;
300 }
301 merge(default_dest); 296 merge(default_dest);
302 return; 297 return;
303 } 298 }
304 299
305 // generate decision tree, using trichotomy when possible 300 // generate decision tree, using trichotomy when possible
342 int default_dest = iter().get_dest_table(0); 337 int default_dest = iter().get_dest_table(0);
343 int len = iter().get_int_table(1); 338 int len = iter().get_int_table(1);
344 339
345 if (len < 1) { // If this is a backward branch, add safepoint 340 if (len < 1) { // If this is a backward branch, add safepoint
346 maybe_add_safepoint(default_dest); 341 maybe_add_safepoint(default_dest);
347 if (should_add_predicate(default_dest)){
348 _sp += 1; // set original stack for use by uncommon_trap
349 add_predicate();
350 _sp -= 1;
351 }
352 merge(default_dest); 342 merge(default_dest);
353 return; 343 return;
354 } 344 }
355 345
356 // generate decision tree, using trichotomy when possible 346 // generate decision tree, using trichotomy when possible
754 744
755 // Effect on jsr on stack 745 // Effect on jsr on stack
756 push(_gvn.makecon(ret_addr)); 746 push(_gvn.makecon(ret_addr));
757 747
758 // Flow to the jsr. 748 // Flow to the jsr.
759 if (should_add_predicate(jsr_bci)){
760 add_predicate();
761 }
762 merge(jsr_bci); 749 merge(jsr_bci);
763 } 750 }
764 751
765 // Handle ret bytecode 752 // Handle ret bytecode
766 void Parse::do_ret() { 753 void Parse::do_ret() {
1038 } else { // Path is live. 1025 } else { // Path is live.
1039 // Update method data 1026 // Update method data
1040 profile_taken_branch(target_bci); 1027 profile_taken_branch(target_bci);
1041 adjust_map_after_if(btest, c, prob, branch_block, next_block); 1028 adjust_map_after_if(btest, c, prob, branch_block, next_block);
1042 if (!stopped()) { 1029 if (!stopped()) {
1043 if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
1044 int nargs = repush_if_args(); // set original stack for uncommon_trap
1045 add_predicate();
1046 _sp -= nargs;
1047 }
1048 merge(target_bci); 1030 merge(target_bci);
1049 } 1031 }
1050 } 1032 }
1051 } 1033 }
1052 1034
1166 } else { 1148 } else {
1167 // Update method data 1149 // Update method data
1168 profile_taken_branch(target_bci); 1150 profile_taken_branch(target_bci);
1169 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); 1151 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
1170 if (!stopped()) { 1152 if (!stopped()) {
1171 if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
1172 int nargs = repush_if_args(); // set original stack for the uncommon_trap
1173 add_predicate();
1174 _sp -= nargs;
1175 }
1176 merge(target_bci); 1153 merge(target_bci);
1177 } 1154 }
1178 } 1155 }
1179 } 1156 }
1180 1157
2164 maybe_add_safepoint(target_bci); 2141 maybe_add_safepoint(target_bci);
2165 2142
2166 // Update method data 2143 // Update method data
2167 profile_taken_branch(target_bci); 2144 profile_taken_branch(target_bci);
2168 2145
2169 // Add loop predicate if it goes to a loop
2170 if (should_add_predicate(target_bci)){
2171 add_predicate();
2172 }
2173 // Merge the current control into the target basic block 2146 // Merge the current control into the target basic block
2174 merge(target_bci); 2147 merge(target_bci);
2175 2148
2176 // See if we can get some profile data and hand it off to the next block 2149 // See if we can get some profile data and hand it off to the next block
2177 Block *target_block = block()->successor_for_bci(target_bci); 2150 Block *target_block = block()->successor_for_bci(target_bci);