Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 4712:e7dead7e90af
7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not (and cannot) guarantee monotonicity, in GC code to an equivalent expression that uses os::javaTimeNanos(). os::javaTimeNanos is guaranteed monotonically non-decreasing if the underlying platform provides a monotonic time source. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by: dholmes, ysr
author | johnc |
---|---|
date | Mon, 19 Dec 2011 10:02:05 -0800 |
parents | 7913e93dca52 |
children | aa3d708d67c4 |
comparison
equal
deleted
inserted
replaced
4711:adedfbbf0360 | 4712:e7dead7e90af |
---|---|
3396 "live objects skipped because closure is full"); | 3396 "live objects skipped because closure is full"); |
3397 } | 3397 } |
3398 } | 3398 } |
3399 | 3399 |
3400 jlong PSParallelCompact::millis_since_last_gc() { | 3400 jlong PSParallelCompact::millis_since_last_gc() { |
3401 jlong ret_val = os::javaTimeMillis() - _time_of_last_gc; | 3401 // We need a monotonically non-deccreasing time in ms but |
3402 // os::javaTimeMillis() does not guarantee monotonicity. | |
3403 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; | |
3404 jlong ret_val = now - _time_of_last_gc; | |
3402 // XXX See note in genCollectedHeap::millis_since_last_gc(). | 3405 // XXX See note in genCollectedHeap::millis_since_last_gc(). |
3403 if (ret_val < 0) { | 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 return 0; | 3408 return 0; |
3406 } | 3409 } |
3407 return ret_val; | 3410 return ret_val; |
3408 } | 3411 } |
3409 | 3412 |
3410 void PSParallelCompact::reset_millis_since_last_gc() { | 3413 void PSParallelCompact::reset_millis_since_last_gc() { |
3411 _time_of_last_gc = os::javaTimeMillis(); | 3414 // We need a monotonically non-deccreasing time in ms but |
3415 // os::javaTimeMillis() does not guarantee monotonicity. | |
3416 _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; | |
3412 } | 3417 } |
3413 | 3418 |
3414 ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full() | 3419 ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full() |
3415 { | 3420 { |
3416 if (source() != destination()) { | 3421 if (source() != destination()) { |