src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp

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


 655 
 656   // All pointers are now adjusted, move objects accordingly
 657 
 658   // It is imperative that we traverse perm_gen first in phase4. All
 659   // classes must be allocated earlier than their instances, and traversing
 660   // perm_gen first makes sure that all klassOops have moved to their new
 661   // location before any instance does a dispatch through it's klass!
 662   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 663   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 664 
 665   PSYoungGen* young_gen = heap->young_gen();
 666   PSOldGen* old_gen = heap->old_gen();
 667   PSPermGen* perm_gen = heap->perm_gen();
 668 
 669   perm_gen->compact();
 670   old_gen->compact();
 671   young_gen->compact();
 672 }
 673 
 674 jlong PSMarkSweep::millis_since_last_gc() {
 675   jlong ret_val = os::javaTimeMillis() - _time_of_last_gc;



 676   // XXX See note in genCollectedHeap::millis_since_last_gc().
 677   if (ret_val < 0) {
 678     NOT_PRODUCT(warning("time warp: %d", ret_val);)
 679     return 0;
 680   }
 681   return ret_val;
 682 }
 683 
 684 void PSMarkSweep::reset_millis_since_last_gc() {
 685   _time_of_last_gc = os::javaTimeMillis();


 686 }


 655 
 656   // All pointers are now adjusted, move objects accordingly
 657 
 658   // It is imperative that we traverse perm_gen first in phase4. All
 659   // classes must be allocated earlier than their instances, and traversing
 660   // perm_gen first makes sure that all klassOops have moved to their new
 661   // location before any instance does a dispatch through it's klass!
 662   ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
 663   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 664 
 665   PSYoungGen* young_gen = heap->young_gen();
 666   PSOldGen* old_gen = heap->old_gen();
 667   PSPermGen* perm_gen = heap->perm_gen();
 668 
 669   perm_gen->compact();
 670   old_gen->compact();
 671   young_gen->compact();
 672 }
 673 
 674 jlong PSMarkSweep::millis_since_last_gc() {
 675   // We need a montonically increasing time in ms but os::javaTimeMillis()
 676   // does not guarantee montonicity.
 677   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
 678   jlong ret_val = now - _time_of_last_gc;
 679   // XXX See note in genCollectedHeap::millis_since_last_gc().
 680   if (ret_val < 0) {
 681     NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
 682     return 0;
 683   }
 684   return ret_val;
 685 }
 686 
 687 void PSMarkSweep::reset_millis_since_last_gc() {
 688   // We need a montonically increasing time in ms but os::javaTimeMillis()
 689   // does not guarantee montonicity.
 690   _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
 691 }