hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp
changeset 41286 802f69f05345
parent 41283 2615c024f3eb
parent 41284 b4276ec89d0d
child 41682 b63330180476
equal deleted inserted replaced
41283:2615c024f3eb 41286:802f69f05345
  1254     _time = MIN2(_time, gen->time_of_last_gc(_now));
  1254     _time = MIN2(_time, gen->time_of_last_gc(_now));
  1255   }
  1255   }
  1256 };
  1256 };
  1257 
  1257 
  1258 jlong GenCollectedHeap::millis_since_last_gc() {
  1258 jlong GenCollectedHeap::millis_since_last_gc() {
  1259   // We need a monotonically non-decreasing time in ms but
  1259   // javaTimeNanos() is guaranteed to be monotonically non-decreasing
  1260   // os::javaTimeMillis() does not guarantee monotonicity.
  1260   // provided the underlying platform provides such a time source
       
  1261   // (and it is bug free). So we still have to guard against getting
       
  1262   // back a time later than 'now'.
  1261   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
  1263   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
  1262   GenTimeOfLastGCClosure tolgc_cl(now);
  1264   GenTimeOfLastGCClosure tolgc_cl(now);
  1263   // iterate over generations getting the oldest
  1265   // iterate over generations getting the oldest
  1264   // time that a generation was collected
  1266   // time that a generation was collected
  1265   generation_iterate(&tolgc_cl, false);
  1267   generation_iterate(&tolgc_cl, false);
  1266 
  1268 
  1267   // javaTimeNanos() is guaranteed to be monotonically non-decreasing
       
  1268   // provided the underlying platform provides such a time source
       
  1269   // (and it is bug free). So we still have to guard against getting
       
  1270   // back a time later than 'now'.
       
  1271   jlong retVal = now - tolgc_cl.time();
  1269   jlong retVal = now - tolgc_cl.time();
  1272   if (retVal < 0) {
  1270   if (retVal < 0) {
  1273     NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);)
  1271     log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT
       
  1272        ". returning zero instead.", retVal);
  1274     return 0;
  1273     return 0;
  1275   }
  1274   }
  1276   return retVal;
  1275   return retVal;
  1277 }
  1276 }
  1278 
  1277