< prev index next >

src/hotspot/share/opto/parse2.cpp

Print this page

1277     prob = (0+PROB_MIN) / 2;
1278   else if( !not_taken )
1279     prob = (1+PROB_MAX) / 2;
1280   else {                         // Compute probability of true path
1281     prob = (float)taken / (float)(taken + not_taken);
1282     if (prob > PROB_MAX)  prob = PROB_MAX;
1283     if (prob < PROB_MIN)   prob = PROB_MIN;
1284   }
1285 
1286   assert((cnt > 0.0f) && (prob > 0.0f),
1287          "Bad frequency assignment in if cnt=%g prob=%g taken=%d not_taken=%d", cnt, prob, taken, not_taken);
1288 
1289   if (C->log() != nullptr) {
1290     const char* prob_str = nullptr;
1291     if (prob >= PROB_MAX)  prob_str = (prob == PROB_MAX) ? "max" : "always";
1292     if (prob <= PROB_MIN)  prob_str = (prob == PROB_MIN) ? "min" : "never";
1293     char prob_str_buf[30];
1294     if (prob_str == nullptr) {
1295       jio_snprintf(prob_str_buf, sizeof(prob_str_buf), "%20.2f", prob);
1296       prob_str = prob_str_buf;






1297     }
1298     C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%f' prob='%s'",
1299                    iter().get_dest(), taken, not_taken, cnt, prob_str);
1300   }
1301   return prob;
1302 }
1303 
1304 //-----------------------------branch_prediction-------------------------------
1305 float Parse::branch_prediction(float& cnt,
1306                                BoolTest::mask btest,
1307                                int target_bci,
1308                                Node* test) {
1309   float prob = dynamic_branch_prediction(cnt, btest, test);
1310   // If prob is unknown, switch to static prediction
1311   if (prob != PROB_UNKNOWN)  return prob;
1312 
1313   prob = PROB_FAIR;                   // Set default value
1314   if (btest == BoolTest::eq)          // Exactly equal test?
1315     prob = PROB_STATIC_INFREQUENT;    // Assume its relatively infrequent
1316   else if (btest == BoolTest::ne)

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