mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8352422: [ubsan] Out-of-range reported in ciMethod.cpp:917:20: runtime error: 2.68435e+09 is outside the range of representable values of type 'int'
Reviewed-by: epeter, dlong
This commit is contained in:
parent
7d9a43839a
commit
d802fd0da2
@ -914,8 +914,14 @@ int ciMethod::scale_count(int count, float prof_factor) {
|
||||
method_life = counter_life;
|
||||
}
|
||||
if (counter_life > 0) {
|
||||
count = (int)((double)count * prof_factor * method_life / counter_life + 0.5);
|
||||
count = (count > 0) ? count : 1;
|
||||
double count_d = (double)count * prof_factor * method_life / counter_life + 0.5;
|
||||
if (count_d >= static_cast<double>(INT_MAX)) {
|
||||
// Clamp in case of overflowing int range.
|
||||
count = INT_MAX;
|
||||
} else {
|
||||
count = int(count_d);
|
||||
count = (count > 0) ? count : 1;
|
||||
}
|
||||
} else {
|
||||
count = 1;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user