RFR(XXS): 8029091: Bug in calculation of code cache sweeping interval

Vladimir Kozlov vladimir.kozlov at oracle.com
Mon Nov 25 09:33:16 PST 2013


Albert,

What if you use double type for calculations?:

+     const double max_wait_time = (double)ReservedCodeCacheSize / (16 * M);

Thanks,
Vladimir

On 11/25/13 5:27 AM, Albert Noll wrote:
> Hi all,
>
> could I have reviews for this small patch?
>
> Bug: _
> _https://bugs.openjdk.java.net/browse/JDK-8029091
>
> Webrev:
> http://cr.openjdk.java.net/~anoll/8029091/webrev.00/
>
> Problem:
> The calculation of 'wait_until_next_sweep' in 'NMethodSweeper::possibly_sweep() {}' has a signed
> to unsigned conversion bug. The calculation is currently done as follows:
>
> double wait_until_next_sweep = (ReservedCodeCacheSize / (16 * M)) - time_since_last_sweep -
> CodeCache::reverse_free_ratio();
>
> Since the type of 'ReservedCodeCacheSize' (uintx) has a higher rank than 'time_since_last_sleep' (int) and
> 'time_since_last_sweep' can be larger than ' (ReservedCodeCacheSize / (16 * M))' there is an underflow. Consequently,
> 'wait_until_next_sweep' is assigned a wrong value, which disables the intended periodic code cache sweeps.
>
> Solution:
> Use only signed types for the calculation of 'wait_until_next_sweep'. Furthermore, an assert checks that
> 'wait_until_next_sweep' is never larger than ' (ReservedCodeCacheSize / (16 * M))', which is the
> maximum time between two sweeps.
>
>
> Many thanks in advance,
> Albert


More information about the hotspot-compiler-dev mailing list