From a3fecdb2f417bd32e528f907bc293cc494746955 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 15 Apr 2024 13:21:18 +0000 Subject: [PATCH] 8329764: G1: Handle null references during verification first Reviewed-by: stefank, iwalulya --- src/hotspot/share/gc/g1/g1HeapRegion.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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);