--- old/src/hotspot/share/gc/cms/cmsHeap.hpp 2019-09-17 15:01:28.576016220 +0200 +++ new/src/hotspot/share/gc/cms/cmsHeap.hpp 2019-09-17 15:01:28.325008005 +0200 @@ -138,7 +138,7 @@ // CMS forwards some non-heap value into the mark oop to reserve oops during // promotion, so we can't assert about obj alignment or that the forwardee is in heap - virtual void check_oop_location(void* addr) const {} + virtual bool is_oop_location(void* addr) const { return true; } }; #endif // SHARE_GC_CMS_CMSHEAP_HPP --- old/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp 2019-09-17 15:01:28.984029574 +0200 +++ new/src/hotspot/share/gc/g1/g1OopClosures.inline.hpp 2019-09-17 15:01:28.684019755 +0200 @@ -115,7 +115,7 @@ G1CollectedHeap* g1h = G1CollectedHeap::heap(); // can't do because of races // assert(oopDesc::is_oop_or_null(obj), "expected an oop"); - g1h->check_oop_location(obj); + assert(g1h->is_oop_location(obj), "invalid oop location"); HeapRegion* from = g1h->heap_region_containing(p); --- old/src/hotspot/share/gc/serial/markSweep.inline.hpp 2019-09-17 15:01:29.402043256 +0200 +++ new/src/hotspot/share/gc/serial/markSweep.inline.hpp 2019-09-17 15:01:29.099033338 +0200 @@ -87,7 +87,7 @@ "should be forwarded"); if (new_obj != NULL) { - DEBUG_ONLY(Universe::heap()->check_oop_location((HeapWord*)new_obj);) + assert(Universe::heap()->is_oop_location(new_obj), "invalid oop location"); RawAccess::oop_store(p, new_obj); } } --- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2019-09-17 15:01:29.771055333 +0200 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2019-09-17 15:01:29.514046921 +0200 @@ -173,6 +173,18 @@ return false; } +bool CollectedHeap::is_oop_location(void* addr) const { + if (!is_object_aligned(addr)) { + return false; + } + + if (!_reserved.contains(addr)) { + return false; + } + + return true; +} + bool CollectedHeap::is_oop(oop object) const { if (!is_object_aligned(object)) { return false; @@ -343,11 +355,6 @@ } #endif // PRODUCT -void CollectedHeap::check_oop_location(void* addr) const { - assert(is_object_aligned(addr), "address is not aligned"); - assert(_reserved.contains(addr), "address is not in reserved heap"); -} - size_t CollectedHeap::max_tlab_size() const { // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE]. // This restriction could be removed by enabling filling with multiple arrays. @@ -376,8 +383,8 @@ { assert(words >= min_fill_size(), "too small to fill"); assert(is_object_aligned(words), "unaligned size"); - DEBUG_ONLY(Universe::heap()->check_oop_location(start);) - DEBUG_ONLY(Universe::heap()->check_oop_location(start + words - MinObjAlignment);) + assert(Universe::heap()->is_oop_location(start), "invalid address"); + assert(Universe::heap()->is_oop_location(start + words - MinObjAlignment), "invalid address"); } void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap) --- old/src/hotspot/share/gc/shared/collectedHeap.hpp 2019-09-17 15:01:30.199069342 +0200 +++ new/src/hotspot/share/gc/shared/collectedHeap.hpp 2019-09-17 15:01:29.887059130 +0200 @@ -233,11 +233,6 @@ DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == NULL || is_in(p); }) - // This function verifies that "addr" is a valid oop location, w.r.t. heap - // datastructures such as bitmaps and virtual memory address. It does *not* - // check if the location is within committed heap memory. - virtual void check_oop_location(void* addr) const; - virtual uint32_t hash_oop(oop obj) const; void set_gc_cause(GCCause::Cause v) { @@ -507,6 +502,10 @@ // Deduplicate the string, iff the GC supports string deduplication. virtual void deduplicate_string(oop str); + // This function verifies that "addr" is a valid oop location, w.r.t. heap + // datastructures such as bitmaps and virtual memory address. It does *not* + // check if the location is within committed heap memory. + virtual bool is_oop_location(void* addr) const; virtual bool is_oop(oop object) const; virtual size_t obj_size(oop obj) const; --- old/src/hotspot/share/gc/z/zCollectedHeap.cpp 2019-09-17 15:01:30.573081583 +0200 +++ new/src/hotspot/share/gc/z/zCollectedHeap.cpp 2019-09-17 15:01:30.317073204 +0200 @@ -365,14 +365,12 @@ _heap.verify(); } -bool ZCollectedHeap::is_oop(oop object) const { - return CollectedHeap::is_oop(object) && _heap.is_oop(object); +bool ZCollectedHeap::is_oop_location(void* addr) const { + return is_object_aligned(addr) && + (uintptr_t)addr >= ZAddressSpaceStart && + (uintptr_t)addr < ZAddressSpaceEnd; } -void ZCollectedHeap::check_oop_location(void* addr) const { - assert(is_object_aligned(addr), "address is not aligned"); - - const uintptr_t addr_int = reinterpret_cast(addr); - assert(addr_int >= ZAddressSpaceStart, "address is outside of the heap"); - assert(addr_int < ZAddressSpaceEnd, "address is outside of the heap"); +bool ZCollectedHeap::is_oop(oop object) const { + return CollectedHeap::is_oop(object) && _heap.is_oop(object); } --- old/src/hotspot/share/gc/z/zCollectedHeap.hpp 2019-09-17 15:01:30.934093398 +0200 +++ new/src/hotspot/share/gc/z/zCollectedHeap.hpp 2019-09-17 15:01:30.680085085 +0200 @@ -126,7 +126,7 @@ virtual void prepare_for_verify(); virtual void verify(VerifyOption option /* ignored */); virtual bool is_oop(oop object) const; - virtual void check_oop_location(void* addr) const; + virtual bool is_oop_location(void* addr) const; }; #endif // SHARE_GC_Z_ZCOLLECTEDHEAP_HPP --- old/src/hotspot/share/oops/compressedOops.inline.hpp 2019-09-17 15:01:31.358107276 +0200 +++ new/src/hotspot/share/oops/compressedOops.inline.hpp 2019-09-17 15:01:31.040096868 +0200 @@ -58,7 +58,7 @@ inline narrowOop CompressedOops::encode_not_null(oop v) { assert(!is_null(v), "oop value can never be zero"); - DEBUG_ONLY(Universe::heap()->check_oop_location(v);) + assert(Universe::heap()->is_oop_location(v), "invalid oop location"); uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)base(), 1)); assert(OopEncodingHeapMax > pd, "change encoding max if new encoding"); uint64_t result = pd >> shift(); --- old/src/hotspot/share/oops/oop.cpp 2019-09-17 15:01:31.733119550 +0200 +++ new/src/hotspot/share/oops/oop.cpp 2019-09-17 15:01:31.471110974 +0200 @@ -209,7 +209,7 @@ #ifdef ASSERT void oopDesc::verify_forwardee(oop forwardee) { - Universe::heap()->check_oop_location(forwardee); + assert(Universe::heap()->is_oop_location(forwardee), "invalid oop location"); #if INCLUDE_CDS_JAVA_HEAP assert(!HeapShared::is_archived_object(forwardee) && !HeapShared::is_archived_object(this), "forwarding archive object");