diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 986495cbeaf2b66159d2e7ef84d1c6d3cecda1b6..ac8ac93ff9e6d6ee7d72c77567bcdf81d6f0649e 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -6092,7 +6092,11 @@ void CMSCollector::sweep(bool asynch) { _inter_sweep_timer.reset(); _inter_sweep_timer.start(); - update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); // NOTE on abstract state transitions: // Mutators allocate-live and/or mark the mod-union table dirty diff --git a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index 91445947c33b0126cf7cf3a044242bf8702b5988..4f64dff08243ca8d12afbfd8f73052840607c82c 100644 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1042,7 +1042,11 @@ void ParNewGeneration::collect(bool full, size_policy->avg_survived()->sample(from()->used()); } - update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); SpecializationStats::print(); diff --git a/src/share/vm/memory/defNewGeneration.cpp b/src/share/vm/memory/defNewGeneration.cpp index 5913b2c78f9901bf0397abff80e0743d2978df2e..69ae3624a25befc08a439f188b462ee42f34a39a 100644 --- a/src/share/vm/memory/defNewGeneration.cpp +++ b/src/share/vm/memory/defNewGeneration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -655,7 +655,12 @@ void DefNewGeneration::collect(bool full, from()->set_concurrent_iteration_safe_limit(from()->top()); to()->set_concurrent_iteration_safe_limit(to()->top()); SpecializationStats::print(); - update_time_of_last_gc(os::javaTimeMillis()); + + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); } class RemoveForwardPointerClosure: public ObjectClosure { diff --git a/src/share/vm/memory/genMarkSweep.cpp b/src/share/vm/memory/genMarkSweep.cpp index 925d968b6bc49c9adbf5b48f9f34fbc38a2bbb97..d5cf4dc756261b24c2ee413871a8c5fba5739ca7 100644 --- a/src/share/vm/memory/genMarkSweep.cpp +++ b/src/share/vm/memory/genMarkSweep.cpp @@ -176,7 +176,11 @@ void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp, // Update time of last gc for all generations we collected // (which curently is all the generations in the heap). - gch->update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + gch->update_time_of_last_gc(now); } void GenMarkSweep::allocate_stacks() {