Skip to content

Commit 04e986f

Browse files
committed
8202081: Introduce CollectedHeap::is_oop()
Reviewed-by: eosterlund, rkennke
1 parent 0bf9838 commit 04e986f

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/hotspot/share/gc/shared/collectedHeap.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ bool CollectedHeap::request_concurrent_phase(const char* phase) {
172172
return false;
173173
}
174174

175+
bool CollectedHeap::is_oop(oop object) const {
176+
if (!check_obj_alignment(object)) {
177+
return false;
178+
}
179+
180+
if (!is_in_reserved(object)) {
181+
return false;
182+
}
183+
184+
if (is_in_reserved(object->klass_or_null())) {
185+
return false;
186+
}
187+
188+
return true;
189+
}
190+
175191
// Memory state functions.
176192

177193

src/hotspot/share/gc/shared/collectedHeap.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ class CollectedHeap : public CHeapObj<mtInternal> {
591591
virtual oop pin_object(JavaThread* thread, oop obj);
592592
virtual void unpin_object(JavaThread* thread, oop obj);
593593

594+
virtual bool is_oop(oop object) const;
595+
594596
// Non product verification and debugging.
595597
#ifndef PRODUCT
596598
// Support for PromotionFailureALot. Return true if it's time to cause a

src/hotspot/share/oops/oop.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ unsigned int oopDesc::new_hash(juint seed) {
122122

123123
// used only for asserts and guarantees
124124
bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
125-
if (!check_obj_alignment(obj)) return false;
126-
if (!Universe::heap()->is_in_reserved(obj)) return false;
127-
// obj is aligned and accessible in heap
128-
if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
125+
if (!Universe::heap()->is_oop(obj)) {
126+
return false;
127+
}
129128

130129
// Header verification: the mark is typically non-NULL. If we're
131130
// at a safepoint, it must not be null.

0 commit comments

Comments
 (0)