--- old/src/hotspot/share/gc/z/zAddress.hpp 2019-05-29 11:24:59.653607312 +0200 +++ new/src/hotspot/share/gc/z/zAddress.hpp 2019-05-29 11:24:59.441600653 +0200 @@ -49,6 +49,7 @@ static bool is_finalizable(uintptr_t value); static bool is_finalizable_good(uintptr_t value); static bool is_remapped(uintptr_t value); + static bool is_in(uintptr_t value); static uintptr_t address(uintptr_t value); static uintptr_t offset(uintptr_t value); --- old/src/hotspot/share/gc/z/zAddress.inline.hpp 2019-05-29 11:24:59.950616641 +0200 +++ new/src/hotspot/share/gc/z/zAddress.inline.hpp 2019-05-29 11:24:59.753610453 +0200 @@ -26,6 +26,7 @@ #include "gc/z/zAddress.hpp" #include "gc/z/zGlobals.hpp" +#include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" inline bool ZAddress::is_null(uintptr_t value) { @@ -81,6 +82,16 @@ return value & ZAddressMetadataRemapped; } +inline bool ZAddress::is_in(uintptr_t value) { + // Check that exactly one non-offset bit is set + if (!is_power_of_2(value & ~ZAddressOffsetMask)) { + return false; + } + + // Check that one of the non-finalizable metadata is set + return value & (ZAddressMetadataMask & ~ZAddressMetadataFinalizable); +} + inline uintptr_t ZAddress::address(uintptr_t value) { return value | ZAddressBase; } --- old/src/hotspot/share/gc/z/zCollectedHeap.cpp 2019-05-29 11:25:00.295627478 +0200 +++ new/src/hotspot/share/gc/z/zCollectedHeap.cpp 2019-05-29 11:25:00.053619876 +0200 @@ -109,7 +109,7 @@ } bool ZCollectedHeap::is_in(const void* p) const { - return is_in_reserved(p) && _heap.is_in((uintptr_t)p); + return _heap.is_in((uintptr_t)p); } uint32_t ZCollectedHeap::hash_oop(oop obj) const { --- old/src/hotspot/share/gc/z/zHeap.cpp 2019-05-29 11:25:00.603637153 +0200 +++ new/src/hotspot/share/gc/z/zHeap.cpp 2019-05-29 11:25:00.405630933 +0200 @@ -177,13 +177,17 @@ } bool ZHeap::is_in(uintptr_t addr) const { - if (addr < ZAddressReservedStart || addr >= ZAddressReservedEnd) { - return false; - } + // An address is considered to be "in the heap" if it points into + // the allocated part of a pages, regardless of which heap view is + // used. Note that an address with the finalizable metadata bit set + // is not pointing into a heap view, and therefore not considered + // to be "in the heap". - const ZPage* const page = _page_table.get(addr); - if (page != NULL) { - return page->is_in(addr); + if (ZAddress::is_in(addr)) { + const ZPage* const page = _page_table.get(addr); + if (page != NULL) { + return page->is_in(addr); + } } return false;