src/share/vm/runtime/sweeper.cpp

changeset 6205
908afcc9d1cb
parent 6131
86e6d691f2e1
child 6207
6aa49042b101
     1.1 --- a/src/share/vm/runtime/sweeper.cpp	Sat Jan 11 13:51:01 2014 -0800
     1.2 +++ b/src/share/vm/runtime/sweeper.cpp	Tue Dec 17 08:31:06 2013 +0100
     1.3 @@ -257,9 +257,14 @@
     1.4    // Large ReservedCodeCacheSize:   (e.g., 256M + code Cache is 90% full). The formula
     1.5    //                                              computes: (256 / 16) - 10 = 6.
     1.6    if (!_should_sweep) {
     1.7 -    int time_since_last_sweep = _time_counter - _last_sweep;
     1.8 -    double wait_until_next_sweep = (ReservedCodeCacheSize / (16 * M)) - time_since_last_sweep -
     1.9 -                                CodeCache::reverse_free_ratio();
    1.10 +    const int time_since_last_sweep = _time_counter - _last_sweep;
    1.11 +    // ReservedCodeCacheSize has an 'unsigned' type. We need a 'signed' type for max_wait_time,
    1.12 +    // since 'time_since_last_sweep' can be larger than 'max_wait_time'. If that happens using
    1.13 +    // an unsigned type would cause an underflow (wait_until_next_sweep becomes a large positive
    1.14 +    // value) that disables the intended periodic sweeps.
    1.15 +    const int max_wait_time = ReservedCodeCacheSize / (16 * M);
    1.16 +    double wait_until_next_sweep = max_wait_time - time_since_last_sweep - CodeCache::reverse_free_ratio();
    1.17 +    assert(wait_until_next_sweep <= (double)max_wait_time, "Calculation of code cache sweeper interval is incorrect");
    1.18  
    1.19      if ((wait_until_next_sweep <= 0.0) || !CompileBroker::should_compile_new_jobs()) {
    1.20        _should_sweep = true;

mercurial