mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 03:24:38 +02:00
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
Make sure cnt doesn't become negative and integer overflow doesn't happen. Reviewed-by: kvn, twisti
This commit is contained in:
parent
5001776189
commit
aac4b1553e
1 changed files with 5 additions and 4 deletions
|
@ -795,8 +795,9 @@ float Parse::dynamic_branch_prediction(float &cnt) {
|
||||||
taken = method()->scale_count(taken);
|
taken = method()->scale_count(taken);
|
||||||
not_taken = method()->scale_count(not_taken);
|
not_taken = method()->scale_count(not_taken);
|
||||||
|
|
||||||
// Give up if too few counts to be meaningful
|
// Give up if too few (or too many, in which case the sum will overflow) counts to be meaningful.
|
||||||
if (taken + not_taken < 40) {
|
// We also check that individual counters are positive first, overwise the sum can become positive.
|
||||||
|
if (taken < 0 || not_taken < 0 || taken + not_taken < 40) {
|
||||||
if (C->log() != NULL) {
|
if (C->log() != NULL) {
|
||||||
C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken);
|
C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken);
|
||||||
}
|
}
|
||||||
|
@ -804,13 +805,13 @@ float Parse::dynamic_branch_prediction(float &cnt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute frequency that we arrive here
|
// Compute frequency that we arrive here
|
||||||
int sum = taken + not_taken;
|
float sum = taken + not_taken;
|
||||||
// Adjust, if this block is a cloned private block but the
|
// Adjust, if this block is a cloned private block but the
|
||||||
// Jump counts are shared. Taken the private counts for
|
// Jump counts are shared. Taken the private counts for
|
||||||
// just this path instead of the shared counts.
|
// just this path instead of the shared counts.
|
||||||
if( block()->count() > 0 )
|
if( block()->count() > 0 )
|
||||||
sum = block()->count();
|
sum = block()->count();
|
||||||
cnt = (float)sum / (float)FreqCountInvocations;
|
cnt = sum / FreqCountInvocations;
|
||||||
|
|
||||||
// Pin probability to sane limits
|
// Pin probability to sane limits
|
||||||
float prob;
|
float prob;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue