8224965: ZGC: Strengthen ZHeap::is_in()
Reviewed-by: eosterlund
This commit is contained in:
parent
06c7a66c22
commit
8db95fbee9
src/hotspot/share/gc/z
@ -49,6 +49,7 @@ public:
|
||||
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);
|
||||
|
@ -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 @@ inline bool ZAddress::is_remapped(uintptr_t value) {
|
||||
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;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ bool ZCollectedHeap::is_maximal_no_gc() const {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -177,13 +177,17 @@ size_t ZHeap::unsafe_max_tlab_alloc() const {
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user