diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.cpp b/src/hotspot/share/gc/g1/g1HeapRegion.cpp index 698a4e0e39f..ff5ac4ab3a1 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.cpp @@ -621,14 +621,18 @@ class G1VerifyLiveAndRemSetClosure : public BasicOopIterateClosure { template void do_oop_work(T* p) { - if (_failures->count() >= G1MaxVerifyFailures) { - return; - } - + // Check for null references first - they are fairly common and since there is + // nothing to do for them anyway (they can't fail verification), it makes sense + // to handle them first. T heap_oop = RawAccess<>::oop_load(p); if (CompressedOops::is_null(heap_oop)) { return; } + + if (_failures->count() >= G1MaxVerifyFailures) { + return; + } + oop obj = CompressedOops::decode_raw_not_null(heap_oop); LiveChecker live_check(_failures, _containing_obj, p, obj, _vo);