Skip to content

Commit 68f811c

Browse files
committed
8231266: ZGC: Minor cleanups in ZCollectedHeap and ZHeap
Reviewed-by: stefank, eosterlund
1 parent 07144b3 commit 68f811c

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/hotspot/share/gc/z/zCollectedHeap.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
#include "precompiled.hpp"
2525
#include "gc/shared/gcHeapSummary.hpp"
26-
#include "gc/shared/locationPrinter.hpp"
2726
#include "gc/shared/suspendibleThreadSet.hpp"
2827
#include "gc/z/zCollectedHeap.hpp"
2928
#include "gc/z/zGlobals.hpp"
3029
#include "gc/z/zHeap.inline.hpp"
3130
#include "gc/z/zNMethod.hpp"
3231
#include "gc/z/zObjArrayAllocator.hpp"
32+
#include "gc/z/zOop.inline.hpp"
3333
#include "gc/z/zServiceability.hpp"
3434
#include "gc/z/zStat.hpp"
3535
#include "gc/z/zUtils.inline.hpp"
@@ -116,7 +116,7 @@ bool ZCollectedHeap::is_in(const void* p) const {
116116
}
117117

118118
uint32_t ZCollectedHeap::hash_oop(oop obj) const {
119-
return _heap.hash_oop(obj);
119+
return _heap.hash_oop(ZOop::to_address(obj));
120120
}
121121

122122
HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
@@ -352,19 +352,13 @@ void ZCollectedHeap::print_tracing_info() const {
352352
}
353353

354354
bool ZCollectedHeap::print_location(outputStream* st, void* addr) const {
355-
if (LocationPrinter::is_valid_obj(addr)) {
356-
st->print(INTPTR_FORMAT " is a %s oop: ", p2i(addr),
357-
ZAddress::is_good(reinterpret_cast<uintptr_t>(addr)) ? "good" : "bad");
358-
cast_to_oop(addr)->print_on(st);
359-
return true;
360-
}
361-
return false;
355+
return _heap.print_location(st, (uintptr_t)addr);
362356
}
363357

364358
void ZCollectedHeap::verify(VerifyOption option /* ignored */) {
365359
_heap.verify();
366360
}
367361

368362
bool ZCollectedHeap::is_oop(oop object) const {
369-
return CollectedHeap::is_oop(object) && _heap.is_oop(object);
363+
return _heap.is_oop(ZOop::to_address(object));
370364
}

src/hotspot/share/gc/z/zHeap.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include "precompiled.hpp"
25+
#include "gc/shared/locationPrinter.hpp"
2526
#include "gc/z/zAddress.inline.hpp"
2627
#include "gc/z/zGlobals.hpp"
2728
#include "gc/z/zHeap.inline.hpp"
@@ -169,7 +170,7 @@ size_t ZHeap::unsafe_max_tlab_alloc() const {
169170

170171
bool ZHeap::is_in(uintptr_t addr) const {
171172
// An address is considered to be "in the heap" if it points into
172-
// the allocated part of a pages, regardless of which heap view is
173+
// the allocated part of a page, regardless of which heap view is
173174
// used. Note that an address with the finalizable metadata bit set
174175
// is not pointing into a heap view, and therefore not considered
175176
// to be "in the heap".
@@ -502,6 +503,16 @@ void ZHeap::print_extended_on(outputStream* st) const {
502503
st->cr();
503504
}
504505

506+
bool ZHeap::print_location(outputStream* st, uintptr_t addr) const {
507+
if (LocationPrinter::is_valid_obj((void*)addr)) {
508+
st->print(PTR_FORMAT " is a %s oop: ", addr, ZAddress::is_good(addr) ? "good" : "bad");
509+
ZOop::from_address(addr)->print_on(st);
510+
return true;
511+
}
512+
513+
return false;
514+
}
515+
505516
void ZHeap::verify() {
506517
// Heap verification can only be done between mark end and
507518
// relocate start. This is the only window where all oop are

src/hotspot/share/gc/z/zHeap.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ZHeap {
9898
size_t unsafe_max_tlab_alloc() const;
9999

100100
bool is_in(uintptr_t addr) const;
101-
uint32_t hash_oop(oop obj) const;
101+
uint32_t hash_oop(uintptr_t addr) const;
102102

103103
// Workers
104104
uint nconcurrent_worker_threads() const;
@@ -161,9 +161,10 @@ class ZHeap {
161161
// Printing
162162
void print_on(outputStream* st) const;
163163
void print_extended_on(outputStream* st) const;
164+
bool print_location(outputStream* st, uintptr_t addr) const;
164165

165166
// Verification
166-
bool is_oop(oop object) const;
167+
bool is_oop(uintptr_t addr) const;
167168
void verify();
168169
};
169170

src/hotspot/share/gc/z/zHeap.inline.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ inline ReferenceDiscoverer* ZHeap::reference_discoverer() {
4444
return &_reference_processor;
4545
}
4646

47-
inline uint32_t ZHeap::hash_oop(oop obj) const {
48-
const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
47+
inline uint32_t ZHeap::hash_oop(uintptr_t addr) const {
48+
const uintptr_t offset = ZAddress::offset(addr);
4949
return ZHash::address_to_uint32(offset);
5050
}
5151

@@ -133,12 +133,8 @@ inline void ZHeap::check_out_of_memory() {
133133
_page_allocator.check_out_of_memory();
134134
}
135135

136-
inline bool ZHeap::is_oop(oop object) const {
137-
// Verify that we have a good address. Note that ZAddress::is_good()
138-
// would not be a strong enough verification, since it only verifies
139-
// that the metadata bits are good.
140-
const uintptr_t addr = ZOop::to_address(object);
141-
return ZAddress::good(addr) == addr;
136+
inline bool ZHeap::is_oop(uintptr_t addr) const {
137+
return ZAddress::is_good(addr) && is_object_aligned(addr) && is_in(addr);
142138
}
143139

144140
#endif // SHARE_GC_Z_ZHEAP_INLINE_HPP

0 commit comments

Comments
 (0)