970 Block* branch_block = successor_for_bci(target_bci); 971 Block* next_block = successor_for_bci(iter().next_bci()); 972 973 float cnt; 974 float prob = branch_prediction(cnt, btest, target_bci); 975 if (prob == PROB_UNKNOWN) { 976 // (An earlier version of do_ifnull omitted this trap for OSR methods.) 977 #ifndef PRODUCT 978 if (PrintOpto && Verbose) 979 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); 980 #endif 981 repush_if_args(); // to gather stats on loop 982 // We need to mark this branch as taken so that if we recompile we will 983 // see that it is possible. In the tiered system the interpreter doesn't 984 // do profiling and by the time we get to the lower tier from the interpreter 985 // the path may be cold again. Make sure it doesn't look untaken 986 profile_taken_branch(target_bci, !ProfileInterpreter); 987 uncommon_trap(Deoptimization::Reason_unreached, 988 Deoptimization::Action_reinterpret, 989 NULL, "cold"); 990 if (EliminateAutoBox) { 991 // Mark the successor blocks as parsed 992 branch_block->next_path_num(); 993 next_block->next_path_num(); 994 } 995 return; 996 } 997 998 explicit_null_checks_inserted++; 999 1000 // Generate real control flow 1001 Node *tst = _gvn.transform( new (C) BoolNode( c, btest ) ); 1002 1003 // Sanity check the probability value 1004 assert(prob > 0.0f,"Bad probability in Parser"); 1005 // Need xform to put node in hash table 1006 IfNode *iff = create_and_xform_if( control(), tst, prob, cnt ); 1007 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1008 // True branch 1009 { PreserveJVMState pjvms(this); 1010 Node* iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); 1011 set_control(iftrue); 1012 1013 if (stopped()) { // Path is dead? 1014 explicit_null_checks_elided++; 1015 if (EliminateAutoBox) { 1016 // Mark the successor block as parsed 1017 branch_block->next_path_num(); 1018 } 1019 } else { // Path is live. 1020 // Update method data 1021 profile_taken_branch(target_bci); 1022 adjust_map_after_if(btest, c, prob, branch_block, next_block); 1023 if (!stopped()) { 1024 merge(target_bci); 1025 } 1026 } 1027 } 1028 1029 // False branch 1030 Node* iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); 1031 set_control(iffalse); 1032 1033 if (stopped()) { // Path is dead? 1034 explicit_null_checks_elided++; 1035 if (EliminateAutoBox) { 1036 // Mark the successor block as parsed 1037 next_block->next_path_num(); 1038 } 1039 } else { // Path is live. 1040 // Update method data 1041 profile_not_taken_branch(); 1042 adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, 1043 next_block, branch_block); 1044 } 1045 } 1046 1047 //------------------------------------do_if------------------------------------ 1048 void Parse::do_if(BoolTest::mask btest, Node* c) { 1049 int target_bci = iter().get_dest(); 1050 1051 Block* branch_block = successor_for_bci(target_bci); 1052 Block* next_block = successor_for_bci(iter().next_bci()); 1053 1054 float cnt; 1055 float prob = branch_prediction(cnt, btest, target_bci); 1056 float untaken_prob = 1.0 - prob; 1057 1058 if (prob == PROB_UNKNOWN) { 1059 #ifndef PRODUCT 1060 if (PrintOpto && Verbose) 1061 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); 1062 #endif 1063 repush_if_args(); // to gather stats on loop 1064 // We need to mark this branch as taken so that if we recompile we will 1065 // see that it is possible. In the tiered system the interpreter doesn't 1066 // do profiling and by the time we get to the lower tier from the interpreter 1067 // the path may be cold again. Make sure it doesn't look untaken 1068 profile_taken_branch(target_bci, !ProfileInterpreter); 1069 uncommon_trap(Deoptimization::Reason_unreached, 1070 Deoptimization::Action_reinterpret, 1071 NULL, "cold"); 1072 if (EliminateAutoBox) { 1073 // Mark the successor blocks as parsed 1074 branch_block->next_path_num(); 1075 next_block->next_path_num(); 1076 } 1077 return; 1078 } 1079 1080 // Sanity check the probability value 1081 assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); 1082 1083 bool taken_if_true = true; 1084 // Convert BoolTest to canonical form: 1085 if (!BoolTest(btest).is_canonical()) { 1086 btest = BoolTest(btest).negate(); 1087 taken_if_true = false; 1088 // prob is NOT updated here; it remains the probability of the taken 1089 // path (as opposed to the prob of the path guarded by an 'IfTrueNode'). 1090 } 1091 assert(btest != BoolTest::eq, "!= is the only canonical exact test"); 1092 1118 } 1119 1120 // Generate real control flow 1121 float true_prob = (taken_if_true ? prob : untaken_prob); 1122 IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt); 1123 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1124 Node* taken_branch = new (C) IfTrueNode(iff); 1125 Node* untaken_branch = new (C) IfFalseNode(iff); 1126 if (!taken_if_true) { // Finish conversion to canonical form 1127 Node* tmp = taken_branch; 1128 taken_branch = untaken_branch; 1129 untaken_branch = tmp; 1130 } 1131 1132 // Branch is taken: 1133 { PreserveJVMState pjvms(this); 1134 taken_branch = _gvn.transform(taken_branch); 1135 set_control(taken_branch); 1136 1137 if (stopped()) { 1138 if (EliminateAutoBox) { 1139 // Mark the successor block as parsed 1140 branch_block->next_path_num(); 1141 } 1142 } else { 1143 // Update method data 1144 profile_taken_branch(target_bci); 1145 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); 1146 if (!stopped()) { 1147 merge(target_bci); 1148 } 1149 } 1150 } 1151 1152 untaken_branch = _gvn.transform(untaken_branch); 1153 set_control(untaken_branch); 1154 1155 // Branch not taken. 1156 if (stopped()) { 1157 if (EliminateAutoBox) { 1158 // Mark the successor block as parsed 1159 next_block->next_path_num(); 1160 } 1161 } else { 1162 // Update method data 1163 profile_not_taken_branch(); 1164 adjust_map_after_if(untaken_btest, c, untaken_prob, 1165 next_block, branch_block); 1166 } 1167 } 1168 1169 //----------------------------adjust_map_after_if------------------------------ 1170 // Adjust the JVM state to reflect the result of taking this path. 1171 // Basically, it means inspecting the CmpNode controlling this 1172 // branch, seeing how it constrains a tested value, and then 1173 // deciding if it's worth our while to encode this constraint 1174 // as graph nodes in the current abstract interpretation map. 1175 void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, 1176 Block* path, Block* other_path) { 1177 if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal) | 970 Block* branch_block = successor_for_bci(target_bci); 971 Block* next_block = successor_for_bci(iter().next_bci()); 972 973 float cnt; 974 float prob = branch_prediction(cnt, btest, target_bci); 975 if (prob == PROB_UNKNOWN) { 976 // (An earlier version of do_ifnull omitted this trap for OSR methods.) 977 #ifndef PRODUCT 978 if (PrintOpto && Verbose) 979 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); 980 #endif 981 repush_if_args(); // to gather stats on loop 982 // We need to mark this branch as taken so that if we recompile we will 983 // see that it is possible. In the tiered system the interpreter doesn't 984 // do profiling and by the time we get to the lower tier from the interpreter 985 // the path may be cold again. Make sure it doesn't look untaken 986 profile_taken_branch(target_bci, !ProfileInterpreter); 987 uncommon_trap(Deoptimization::Reason_unreached, 988 Deoptimization::Action_reinterpret, 989 NULL, "cold"); 990 if (C->eliminate_boxing()) { 991 // Mark the successor blocks as parsed 992 branch_block->next_path_num(); 993 next_block->next_path_num(); 994 } 995 return; 996 } 997 998 explicit_null_checks_inserted++; 999 1000 // Generate real control flow 1001 Node *tst = _gvn.transform( new (C) BoolNode( c, btest ) ); 1002 1003 // Sanity check the probability value 1004 assert(prob > 0.0f,"Bad probability in Parser"); 1005 // Need xform to put node in hash table 1006 IfNode *iff = create_and_xform_if( control(), tst, prob, cnt ); 1007 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1008 // True branch 1009 { PreserveJVMState pjvms(this); 1010 Node* iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); 1011 set_control(iftrue); 1012 1013 if (stopped()) { // Path is dead? 1014 explicit_null_checks_elided++; 1015 if (C->eliminate_boxing()) { 1016 // Mark the successor block as parsed 1017 branch_block->next_path_num(); 1018 } 1019 } else { // Path is live. 1020 // Update method data 1021 profile_taken_branch(target_bci); 1022 adjust_map_after_if(btest, c, prob, branch_block, next_block); 1023 if (!stopped()) { 1024 merge(target_bci); 1025 } 1026 } 1027 } 1028 1029 // False branch 1030 Node* iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); 1031 set_control(iffalse); 1032 1033 if (stopped()) { // Path is dead? 1034 explicit_null_checks_elided++; 1035 if (C->eliminate_boxing()) { 1036 // Mark the successor block as parsed 1037 next_block->next_path_num(); 1038 } 1039 } else { // Path is live. 1040 // Update method data 1041 profile_not_taken_branch(); 1042 adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, 1043 next_block, branch_block); 1044 } 1045 } 1046 1047 //------------------------------------do_if------------------------------------ 1048 void Parse::do_if(BoolTest::mask btest, Node* c) { 1049 int target_bci = iter().get_dest(); 1050 1051 Block* branch_block = successor_for_bci(target_bci); 1052 Block* next_block = successor_for_bci(iter().next_bci()); 1053 1054 float cnt; 1055 float prob = branch_prediction(cnt, btest, target_bci); 1056 float untaken_prob = 1.0 - prob; 1057 1058 if (prob == PROB_UNKNOWN) { 1059 #ifndef PRODUCT 1060 if (PrintOpto && Verbose) 1061 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); 1062 #endif 1063 repush_if_args(); // to gather stats on loop 1064 // We need to mark this branch as taken so that if we recompile we will 1065 // see that it is possible. In the tiered system the interpreter doesn't 1066 // do profiling and by the time we get to the lower tier from the interpreter 1067 // the path may be cold again. Make sure it doesn't look untaken 1068 profile_taken_branch(target_bci, !ProfileInterpreter); 1069 uncommon_trap(Deoptimization::Reason_unreached, 1070 Deoptimization::Action_reinterpret, 1071 NULL, "cold"); 1072 if (C->eliminate_boxing()) { 1073 // Mark the successor blocks as parsed 1074 branch_block->next_path_num(); 1075 next_block->next_path_num(); 1076 } 1077 return; 1078 } 1079 1080 // Sanity check the probability value 1081 assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); 1082 1083 bool taken_if_true = true; 1084 // Convert BoolTest to canonical form: 1085 if (!BoolTest(btest).is_canonical()) { 1086 btest = BoolTest(btest).negate(); 1087 taken_if_true = false; 1088 // prob is NOT updated here; it remains the probability of the taken 1089 // path (as opposed to the prob of the path guarded by an 'IfTrueNode'). 1090 } 1091 assert(btest != BoolTest::eq, "!= is the only canonical exact test"); 1092 1118 } 1119 1120 // Generate real control flow 1121 float true_prob = (taken_if_true ? prob : untaken_prob); 1122 IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt); 1123 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1124 Node* taken_branch = new (C) IfTrueNode(iff); 1125 Node* untaken_branch = new (C) IfFalseNode(iff); 1126 if (!taken_if_true) { // Finish conversion to canonical form 1127 Node* tmp = taken_branch; 1128 taken_branch = untaken_branch; 1129 untaken_branch = tmp; 1130 } 1131 1132 // Branch is taken: 1133 { PreserveJVMState pjvms(this); 1134 taken_branch = _gvn.transform(taken_branch); 1135 set_control(taken_branch); 1136 1137 if (stopped()) { 1138 if (C->eliminate_boxing()) { 1139 // Mark the successor block as parsed 1140 branch_block->next_path_num(); 1141 } 1142 } else { 1143 // Update method data 1144 profile_taken_branch(target_bci); 1145 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); 1146 if (!stopped()) { 1147 merge(target_bci); 1148 } 1149 } 1150 } 1151 1152 untaken_branch = _gvn.transform(untaken_branch); 1153 set_control(untaken_branch); 1154 1155 // Branch not taken. 1156 if (stopped()) { 1157 if (C->eliminate_boxing()) { 1158 // Mark the successor block as parsed 1159 next_block->next_path_num(); 1160 } 1161 } else { 1162 // Update method data 1163 profile_not_taken_branch(); 1164 adjust_map_after_if(untaken_btest, c, untaken_prob, 1165 next_block, branch_block); 1166 } 1167 } 1168 1169 //----------------------------adjust_map_after_if------------------------------ 1170 // Adjust the JVM state to reflect the result of taking this path. 1171 // Basically, it means inspecting the CmpNode controlling this 1172 // branch, seeing how it constrains a tested value, and then 1173 // deciding if it's worth our while to encode this constraint 1174 // as graph nodes in the current abstract interpretation map. 1175 void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, 1176 Block* path, Block* other_path) { 1177 if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal) |