Skip to content

Commit

Permalink
Handle has_klass_gap
Browse files Browse the repository at this point in the history
  • Loading branch information
rkennke committed Nov 13, 2024
1 parent f179d17 commit 9e770b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/objLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@

ObjLayout::Mode ObjLayout::_klass_mode = ObjLayout::Undefined;
int ObjLayout::_oop_base_offset_in_bytes = 0;
bool ObjLayout::_oop_has_klass_gap = false;

void ObjLayout::initialize() {
assert(_klass_mode == Undefined, "ObjLayout initialized twice");
if (UseCompactObjectHeaders) {
_klass_mode = Compact;
_oop_base_offset_in_bytes = sizeof(markWord);
_oop_has_klass_gap = false;
} else if (UseCompressedClassPointers) {
_klass_mode = Compressed;
_oop_base_offset_in_bytes = sizeof(markWord) + sizeof(narrowKlass);
_oop_has_klass_gap = true;
} else {
_klass_mode = Uncompressed;
_oop_base_offset_in_bytes = sizeof(markWord) + sizeof(Klass*);
_oop_has_klass_gap = false;
}
}
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/objLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ class ObjLayout {
private:
static Mode _klass_mode;
static int _oop_base_offset_in_bytes;
static bool _oop_has_klass_gap;

public:
static void initialize();
static inline Mode klass_mode();
static inline int oop_base_offset_in_bytes() {
return _oop_base_offset_in_bytes;
}
static inline bool oop_has_klass_gap() {
return _oop_has_klass_gap;
}
};

#endif // SHARE_OOPS_OBJLAYOUT_HPP
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/oop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bool oopDesc::is_objArray_noinline() const { return is_objArray(); }
bool oopDesc::is_typeArray_noinline() const { return is_typeArray(); }

bool oopDesc::has_klass_gap() {
return UseCompressedClassPointers && !UseCompactObjectHeaders;
return ObjLayout::oop_has_klass_gap();
}

#if INCLUDE_CDS_JAVA_HEAP
Expand Down

0 comments on commit 9e770b8

Please sign in to comment.