RFR: Protect risky conversion in ShenandoahHeap::millis_since_last_gc
Zhengyu Gu
zgu at redhat.com
Thu Nov 1 16:50:33 UTC 2018
Good.
-Zhengyu
On 11/01/2018 12:49 PM, Aleksey Shipilev wrote:
> This was found when building sh/jdk8u on Mac OS X: implicit double -> jlong conversion makes clang
> unhappy. The fix goes to sh/jdk and then proliferates with backports:
>
> diff -r 2302522f94c4 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
> --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Thu Nov 01 15:46:15 2018 +0100
> +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Thu Nov 01 17:22:43 2018 +0100
> @@ -1147,7 +1147,9 @@
> }
>
> jlong ShenandoahHeap::millis_since_last_gc() {
> - return heuristics()->time_since_last_gc() * 1000;
> + double v = heuristics()->time_since_last_gc() * 1000;
> + assert(0 <= v && v <= max_jlong, "value should fit: %f", v);
> + return (jlong)v;
> }
>
> void ShenandoahHeap::prepare_for_verify() {
>
> Testing: sh/jdk tier3_gc_shenandoah, sh/jdk8u Mac OS X builds
>
> Thanks,
> -Aleksey
>
More information about the shenandoah-dev
mailing list