< prev index next >

src/share/vm/gc/shared/genCollectedHeap.cpp

Print this page




1239     Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size);
1240   }
1241   return oop(result);
1242 }
1243 
1244 class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure {
1245   jlong _time;   // in ms
1246   jlong _now;    // in ms
1247 
1248  public:
1249   GenTimeOfLastGCClosure(jlong now) : _time(now), _now(now) { }
1250 
1251   jlong time() { return _time; }
1252 
1253   void do_generation(Generation* gen) {
1254     _time = MIN2(_time, gen->time_of_last_gc(_now));
1255   }
1256 };
1257 
1258 jlong GenCollectedHeap::millis_since_last_gc() {
1259   // javaTimeNanos() is guaranteed to be monotonically non-decreasing
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'.
1263   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
1264   GenTimeOfLastGCClosure tolgc_cl(now);
1265   // iterate over generations getting the oldest
1266   // time that a generation was collected
1267   generation_iterate(&tolgc_cl, false);
1268 




1269   jlong retVal = now - tolgc_cl.time();
1270   if (retVal < 0) {
1271     log_warning(gc)("Detected clock going backwards. "
1272       "Milliseconds since last GC would be " JLONG_FORMAT
1273       ". returning zero instead.", retVal);
1274     return 0;
1275   }
1276   return retVal;
1277 }
1278 
1279 void GenCollectedHeap::stop() {
1280 #if INCLUDE_ALL_GCS
1281   if (UseConcMarkSweepGC) {
1282     ConcurrentMarkSweepThread::cmst()->stop();
1283   }
1284 #endif
1285 }


1239     Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size);
1240   }
1241   return oop(result);
1242 }
1243 
1244 class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure {
1245   jlong _time;   // in ms
1246   jlong _now;    // in ms
1247 
1248  public:
1249   GenTimeOfLastGCClosure(jlong now) : _time(now), _now(now) { }
1250 
1251   jlong time() { return _time; }
1252 
1253   void do_generation(Generation* gen) {
1254     _time = MIN2(_time, gen->time_of_last_gc(_now));
1255   }
1256 };
1257 
1258 jlong GenCollectedHeap::millis_since_last_gc() {
1259   // We need a monotonically non-decreasing time in ms but
1260   // os::javaTimeMillis() does not guarantee monotonicity.


1261   jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
1262   GenTimeOfLastGCClosure tolgc_cl(now);
1263   // iterate over generations getting the oldest
1264   // time that a generation was collected
1265   generation_iterate(&tolgc_cl, false);
1266 
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();
1272   if (retVal < 0) {
1273     NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);)


1274     return 0;
1275   }
1276   return retVal;
1277 }
1278 
1279 void GenCollectedHeap::stop() {
1280 #if INCLUDE_ALL_GCS
1281   if (UseConcMarkSweepGC) {
1282     ConcurrentMarkSweepThread::cmst()->stop();
1283   }
1284 #endif
1285 }
< prev index next >