Skip to content

Commit 5339948

Browse files
committed
wip
1 parent 44642a5 commit 5339948

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/hotspot/share/memory/metaspace.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,13 +1041,18 @@ bool Metaspace::is_in_nonclass_metaspace(const void* ptr) {
10411041
return VirtualSpaceList::vslist_nonclass()->contains((MetaWord*)ptr);
10421042
}
10431043

1044-
#ifdef ASSERT
10451044
bool Metaspace::metadata_is_live(const Metadata* md) {
1045+
#ifndef ASSERT
1046+
return contains(md);
1047+
#else
10461048
return md->metadata_token_is_valid() && contains(md); // flesh out later
1049+
#endif
10471050
}
10481051

10491052
bool Metaspace::klass_is_live(const Klass* k, bool must_have_narrow_klass_id) {
1053+
#ifndef ASSERT
1054+
return contains(k);
1055+
#else
10501056
return ((const Metadata*)k)->metadata_token_is_valid_klass() && contains(k); // flesh out later
1057+
#endif
10511058
}
1052-
1053-
#endif // ASSERT

src/hotspot/share/memory/metaspace.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,15 @@ class Metaspace : public AllStatic {
155155
return ptr < _class_space_end && ptr >= _class_space_start;
156156
}
157157

158-
#ifdef ASSERT
159158
// xxx_is_live functions returns true if the pointer given points to
160-
// valid metadata. In detail, it checks that:
159+
// valid metadata. In release builds, it is equivalent to Metaspace::contains. In debug
160+
// builds, it checks that:
161161
// - the specified metadata is inside class-space or metaspace in committed, readable memory
162162
// - not marked as dead space (i.e. not returned prematurely via Metaspace::deallocate)
163163
// - correctly aligned for the type (esp. Klass)
164164
// - Metadata token is valid specific to this type
165165
static bool metadata_is_live(const Metadata* md);
166166
static bool klass_is_live(const Klass* k, bool must_have_narrow_klass_id);
167-
#endif
168167

169168
// Free empty virtualspaces
170169
static void purge(bool classes_unloaded);

0 commit comments

Comments
 (0)