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

Print this page
rev 2869 : 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() mostly guarantees montonicity depending on the underlying OS implementation and, as a result, a better alternative. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by:


3381   // The destination of the first live object that starts in the region is one
3382   // past the end of the partial object entering the region (if any).
3383   HeapWord* const dest_addr = sd.partial_obj_end(dp_region);
3384   HeapWord* const new_top = _space_info[space_id].new_top();
3385   assert(new_top >= dest_addr, "bad new_top value");
3386   const size_t words = pointer_delta(new_top, dest_addr);
3387 
3388   if (words > 0) {
3389     ObjectStartArray* start_array = _space_info[space_id].start_array();
3390     MoveAndUpdateClosure closure(bitmap, cm, start_array, dest_addr, words);
3391 
3392     ParMarkBitMap::IterationStatus status;
3393     status = bitmap->iterate(&closure, dest_addr, end_addr);
3394     assert(status == ParMarkBitMap::full, "iteration not complete");
3395     assert(bitmap->find_obj_beg(closure.source(), end_addr) == end_addr,
3396            "live objects skipped because closure is full");
3397   }
3398 }
3399 
3400 jlong PSParallelCompact::millis_since_last_gc() {
3401   jlong ret_val = os::javaTimeMillis() - _time_of_last_gc;


3402   // XXX See note in genCollectedHeap::millis_since_last_gc().
3403   if (ret_val < 0) {
3404     NOT_PRODUCT(warning("time warp: %d", ret_val);)
3405     return 0;
3406   }
3407   return ret_val;
3408 }
3409 
3410 void PSParallelCompact::reset_millis_since_last_gc() {
3411   _time_of_last_gc = os::javaTimeMillis();

3412 }
3413 
3414 ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full()
3415 {
3416   if (source() != destination()) {
3417     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3418     Copy::aligned_conjoint_words(source(), destination(), words_remaining());
3419   }
3420   update_state(words_remaining());
3421   assert(is_full(), "sanity");
3422   return ParMarkBitMap::full;
3423 }
3424 
3425 void MoveAndUpdateClosure::copy_partial_obj()
3426 {
3427   size_t words = words_remaining();
3428 
3429   HeapWord* const range_end = MIN2(source() + words, bitmap()->region_end());
3430   HeapWord* const end_addr = bitmap()->find_obj_end(source(), range_end);
3431   if (end_addr < range_end) {




3381   // The destination of the first live object that starts in the region is one
3382   // past the end of the partial object entering the region (if any).
3383   HeapWord* const dest_addr = sd.partial_obj_end(dp_region);
3384   HeapWord* const new_top = _space_info[space_id].new_top();
3385   assert(new_top >= dest_addr, "bad new_top value");
3386   const size_t words = pointer_delta(new_top, dest_addr);
3387 
3388   if (words > 0) {
3389     ObjectStartArray* start_array = _space_info[space_id].start_array();
3390     MoveAndUpdateClosure closure(bitmap, cm, start_array, dest_addr, words);
3391 
3392     ParMarkBitMap::IterationStatus status;
3393     status = bitmap->iterate(&closure, dest_addr, end_addr);
3394     assert(status == ParMarkBitMap::full, "iteration not complete");
3395     assert(bitmap->find_obj_beg(closure.source(), end_addr) == end_addr,
3396            "live objects skipped because closure is full");
3397   }
3398 }
3399 
3400 jlong PSParallelCompact::millis_since_last_gc() {
3401   // os::javaTimeMillis() does not guarantee monotonicity.
3402   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
3403   jlong ret_val = now - _time_of_last_gc;
3404   // XXX See note in genCollectedHeap::millis_since_last_gc().
3405   if (ret_val < 0) {
3406     NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
3407     return 0;
3408   }
3409   return ret_val;
3410 }
3411 
3412 void PSParallelCompact::reset_millis_since_last_gc() {
3413   // os::javaTimeMillis() does not guarantee monotonicity.
3414   _time_of_last_gc = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
3415 }
3416 
3417 ParMarkBitMap::IterationStatus MoveAndUpdateClosure::copy_until_full()
3418 {
3419   if (source() != destination()) {
3420     DEBUG_ONLY(PSParallelCompact::check_new_location(source(), destination());)
3421     Copy::aligned_conjoint_words(source(), destination(), words_remaining());
3422   }
3423   update_state(words_remaining());
3424   assert(is_full(), "sanity");
3425   return ParMarkBitMap::full;
3426 }
3427 
3428 void MoveAndUpdateClosure::copy_partial_obj()
3429 {
3430   size_t words = words_remaining();
3431 
3432   HeapWord* const range_end = MIN2(source() + words, bitmap()->region_end());
3433   HeapWord* const end_addr = bitmap()->find_obj_end(source(), range_end);
3434   if (end_addr < range_end) {