comparison src/share/vm/opto/parse2.cpp @ 20440:42460b71ba70

8046289: compiler/6340864/TestLongVect.java timeout with Reviewed-by: iveresov, vlivanov
author rbackman
date Mon, 23 Jun 2014 13:33:23 +0200
parents f6f9aec27858
children 7848fc12602b
comparison
equal deleted inserted replaced
20439:f6f9aec27858 20440:42460b71ba70
882 // branch_prediction() when the profile reports a zero taken count. 882 // branch_prediction() when the profile reports a zero taken count.
883 // It is important to distinguish zero counts unambiguously, because 883 // It is important to distinguish zero counts unambiguously, because
884 // some branches (e.g., _213_javac.Assembler.eliminate) validly produce 884 // some branches (e.g., _213_javac.Assembler.eliminate) validly produce
885 // very small but nonzero probabilities, which if confused with zero 885 // very small but nonzero probabilities, which if confused with zero
886 // counts would keep the program recompiling indefinitely. 886 // counts would keep the program recompiling indefinitely.
887 bool Parse::seems_never_taken(float prob) { 887 bool Parse::seems_never_taken(float prob) const {
888 return prob < PROB_MIN; 888 return prob < PROB_MIN;
889 } 889 }
890 890
891 // True if the comparison seems to be the kind that will not change its 891 // True if the comparison seems to be the kind that will not change its
892 // statistics from true to false. See comments in adjust_map_after_if. 892 // statistics from true to false. See comments in adjust_map_after_if.
894 // classifed as untaken (by seems_never_taken), so really, 894 // classifed as untaken (by seems_never_taken), so really,
895 // if a path is never taken, its controlling comparison is 895 // if a path is never taken, its controlling comparison is
896 // already acting in a stable fashion. If the comparison 896 // already acting in a stable fashion. If the comparison
897 // seems stable, we will put an expensive uncommon trap 897 // seems stable, we will put an expensive uncommon trap
898 // on the untaken path. 898 // on the untaken path.
899 bool Parse::seems_stable_comparison(BoolTest::mask btest, Node* cmp) { 899 bool Parse::seems_stable_comparison() const {
900 if (C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if)) { 900 if (C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if)) {
901 return false; 901 return false;
902 } 902 }
903 return true; 903 return true;
904 } 904 }
1123 adjust_map_after_if(untaken_btest, c, untaken_prob, 1123 adjust_map_after_if(untaken_btest, c, untaken_prob,
1124 next_block, branch_block); 1124 next_block, branch_block);
1125 } 1125 }
1126 } 1126 }
1127 1127
1128 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
1129 // Don't want to speculate on uncommon traps when running with -Xcomp
1130 if (!UseInterpreter) {
1131 return false;
1132 }
1133 return (seems_never_taken(prob) && seems_stable_comparison());
1134 }
1135
1128 //----------------------------adjust_map_after_if------------------------------ 1136 //----------------------------adjust_map_after_if------------------------------
1129 // Adjust the JVM state to reflect the result of taking this path. 1137 // Adjust the JVM state to reflect the result of taking this path.
1130 // Basically, it means inspecting the CmpNode controlling this 1138 // Basically, it means inspecting the CmpNode controlling this
1131 // branch, seeing how it constrains a tested value, and then 1139 // branch, seeing how it constrains a tested value, and then
1132 // deciding if it's worth our while to encode this constraint 1140 // deciding if it's worth our while to encode this constraint
1136 if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal) 1144 if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal)
1137 return; // nothing to do 1145 return; // nothing to do
1138 1146
1139 bool is_fallthrough = (path == successor_for_bci(iter().next_bci())); 1147 bool is_fallthrough = (path == successor_for_bci(iter().next_bci()));
1140 1148
1141 if (seems_never_taken(prob) && seems_stable_comparison(btest, c)) { 1149 if (path_is_suitable_for_uncommon_trap(prob)) {
1142 repush_if_args(); 1150 repush_if_args();
1143 uncommon_trap(Deoptimization::Reason_unstable_if, 1151 uncommon_trap(Deoptimization::Reason_unstable_if,
1144 Deoptimization::Action_reinterpret, 1152 Deoptimization::Action_reinterpret,
1145 NULL, 1153 NULL,
1146 (is_fallthrough ? "taken always" : "taken never")); 1154 (is_fallthrough ? "taken always" : "taken never"));