< prev index next >

src/hotspot/share/opto/parse2.cpp

Print this page

1259     prob = (0+PROB_MIN) / 2;
1260   else if( !not_taken )
1261     prob = (1+PROB_MAX) / 2;
1262   else {                         // Compute probability of true path
1263     prob = (float)taken / (float)(taken + not_taken);
1264     if (prob > PROB_MAX)  prob = PROB_MAX;
1265     if (prob < PROB_MIN)   prob = PROB_MIN;
1266   }
1267 
1268   assert((cnt > 0.0f) && (prob > 0.0f),
1269          "Bad frequency assignment in if cnt=%g prob=%g taken=%d not_taken=%d", cnt, prob, taken, not_taken);
1270 
1271   if (C->log() != nullptr) {
1272     const char* prob_str = nullptr;
1273     if (prob >= PROB_MAX)  prob_str = (prob == PROB_MAX) ? "max" : "always";
1274     if (prob <= PROB_MIN)  prob_str = (prob == PROB_MIN) ? "min" : "never";
1275     char prob_str_buf[30];
1276     if (prob_str == nullptr) {
1277       jio_snprintf(prob_str_buf, sizeof(prob_str_buf), "%20.2f", prob);
1278       prob_str = prob_str_buf;






1279     }
1280     C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%f' prob='%s'",
1281                    iter().get_dest(), taken, not_taken, cnt, prob_str);
1282   }
1283   return prob;
1284 }
1285 
1286 //-----------------------------branch_prediction-------------------------------
1287 float Parse::branch_prediction(float& cnt,
1288                                BoolTest::mask btest,
1289                                int target_bci,
1290                                Node* test) {
1291   float prob = dynamic_branch_prediction(cnt, btest, test);
1292   // If prob is unknown, switch to static prediction
1293   if (prob != PROB_UNKNOWN)  return prob;
1294 
1295   prob = PROB_FAIR;                   // Set default value
1296   if (btest == BoolTest::eq)          // Exactly equal test?
1297     prob = PROB_STATIC_INFREQUENT;    // Assume its relatively infrequent
1298   else if (btest == BoolTest::ne)

1259     prob = (0+PROB_MIN) / 2;
1260   else if( !not_taken )
1261     prob = (1+PROB_MAX) / 2;
1262   else {                         // Compute probability of true path
1263     prob = (float)taken / (float)(taken + not_taken);
1264     if (prob > PROB_MAX)  prob = PROB_MAX;
1265     if (prob < PROB_MIN)   prob = PROB_MIN;
1266   }
1267 
1268   assert((cnt > 0.0f) && (prob > 0.0f),
1269          "Bad frequency assignment in if cnt=%g prob=%g taken=%d not_taken=%d", cnt, prob, taken, not_taken);
1270 
1271   if (C->log() != nullptr) {
1272     const char* prob_str = nullptr;
1273     if (prob >= PROB_MAX)  prob_str = (prob == PROB_MAX) ? "max" : "always";
1274     if (prob <= PROB_MIN)  prob_str = (prob == PROB_MIN) ? "min" : "never";
1275     char prob_str_buf[30];
1276     if (prob_str == nullptr) {
1277       jio_snprintf(prob_str_buf, sizeof(prob_str_buf), "%20.2f", prob);
1278       prob_str = prob_str_buf;
1279       // The %20.2f adds many spaces to the string, to avoid some
1280       // picky overflow warning as noted in 8211929.  But, 20 is the
1281       // *minimum* width, not *maximum*, so it's not clear how this
1282       // helps prevent overflow.  Looks like we were forced to work
1283       // around a bug in gcc.  In any case, strip the blanks.
1284       while (*prob_str == ' ')  ++prob_str;
1285     }
1286     C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%f' prob='%s'",
1287                    iter().get_dest(), taken, not_taken, cnt, prob_str);
1288   }
1289   return prob;
1290 }
1291 
1292 //-----------------------------branch_prediction-------------------------------
1293 float Parse::branch_prediction(float& cnt,
1294                                BoolTest::mask btest,
1295                                int target_bci,
1296                                Node* test) {
1297   float prob = dynamic_branch_prediction(cnt, btest, test);
1298   // If prob is unknown, switch to static prediction
1299   if (prob != PROB_UNKNOWN)  return prob;
1300 
1301   prob = PROB_FAIR;                   // Set default value
1302   if (btest == BoolTest::eq)          // Exactly equal test?
1303     prob = PROB_STATIC_INFREQUENT;    // Assume its relatively infrequent
1304   else if (btest == BoolTest::ne)
< prev index next >