< prev index next >

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

Print this page
rev 60257 : [mq]: 8248401-unify-millis-since-last-gc

*** 1360,1398 **** if (result != NULL) { Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size); } return oop(result); } - - class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure { - jlong _time; // in ms - jlong _now; // in ms - - public: - GenTimeOfLastGCClosure(jlong now) : _time(now), _now(now) { } - - jlong time() { return _time; } - - void do_generation(Generation* gen) { - _time = MIN2(_time, gen->time_of_last_gc(_now)); - } - }; - - jlong GenCollectedHeap::millis_since_last_gc() { - // javaTimeNanos() is guaranteed to be monotonically non-decreasing - // provided the underlying platform provides such a time source - // (and it is bug free). So we still have to guard against getting - // back a time later than 'now'. - jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; - GenTimeOfLastGCClosure tolgc_cl(now); - // iterate over generations getting the oldest - // time that a generation was collected - generation_iterate(&tolgc_cl, false); - - jlong retVal = now - tolgc_cl.time(); - if (retVal < 0) { - log_warning(gc)("millis_since_last_gc() would return : " JLONG_FORMAT - ". returning zero instead.", retVal); - return 0; - } - return retVal; - } --- 1360,1364 ----
< prev index next >