Print this page
rev 2870 : 7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not guarantee montonicity, in GC code to os::javaTimeNanos() with a suitable conversion factor. os::javaTimeNanos is guaranteed monotonic if the underlying platform provides a monotonic timesource. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by: dholmes

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
          +++ new/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
↓ open down ↓ 3390 lines elided ↑ open up ↑
3391 3391  
3392 3392      ParMarkBitMap::IterationStatus status;
3393 3393      status = bitmap->iterate(&closure, dest_addr, end_addr);
3394 3394      assert(status == ParMarkBitMap::full, "iteration not complete");
3395 3395      assert(bitmap->find_obj_beg(closure.source(), end_addr) == end_addr,
3396 3396             "live objects skipped because closure is full");
3397 3397    }
3398 3398  }
3399 3399  
3400 3400  jlong PSParallelCompact::millis_since_last_gc() {
3401      -  jlong ret_val = os::javaTimeMillis() - _time_of_last_gc;
     3401 +  // We need a montonically increasing time in ms but os::javaTimeMillis()
     3402 +  // does not guarantee montonicity.
     3403 +  jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
     3404 +  jlong ret_val = now - _time_of_last_gc;
3402 3405    // XXX See note in genCollectedHeap::millis_since_last_gc().
3403 3406    if (ret_val < 0) {
3404      -    NOT_PRODUCT(warning("time warp: %d", ret_val);)
     3407 +    NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
3405 3408      return 0;
3406 3409    }
3407 3410    return ret_val;
3408 3411  }
3409 3412  
3410 3413  void PSParallelCompact::reset_millis_since_last_gc() {
3411      -  _time_of_last_gc = os::javaTimeMillis();
     3414 +  // We need a montonically increasing time in ms but os::javaTimeMillis()
     3415 +  // does not guarantee montonicity.
     3416 +  _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
3412 3417  }
3413 3418  
3414 3419  ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full()
3415 3420  {
3416 3421    if (source() != destination()) {
3417 3422      DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3418 3423      Copy::aligned_conjoint_words(source(), destination(), words_remaining());
3419 3424    }
3420 3425    update_state(words_remaining());
3421 3426    assert(is_full(), "sanity");
↓ open down ↓ 79 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX