Skip to content

Commit

Permalink
8292910: Remove root to oop cast in HeapDumper
Browse files Browse the repository at this point in the history
Reviewed-by: eosterlund, coleenp
  • Loading branch information
stefank committed Aug 26, 2022
1 parent f694f8a commit 4732abf
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ class AbstractDumpWriter : public StackObj {

// Returns true if we have enough room in the buffer for 'len' bytes.
bool can_write_fast(size_t len);

void write_address(address a);

public:
AbstractDumpWriter() :
_buffer(NULL),
Expand All @@ -429,6 +432,7 @@ class AbstractDumpWriter : public StackObj {
void write_u4(u4 x);
void write_u8(u8 x);
void write_objectID(oop o);
void write_rootID(oop* p);
void write_symbolID(Symbol* o);
void write_classID(Klass* k);
void write_id(u4 x);
Expand Down Expand Up @@ -511,22 +515,24 @@ void AbstractDumpWriter::write_u8(u8 x) {
WRITE_KNOWN_TYPE(&v, 8);
}

void AbstractDumpWriter::write_objectID(oop o) {
address a = cast_from_oop<address>(o);
void AbstractDumpWriter::write_address(address a) {
#ifdef _LP64
write_u8((u8)a);
#else
write_u4((u4)a);
#endif
}

void AbstractDumpWriter::write_objectID(oop o) {
write_address(cast_from_oop<address>(o));
}

void AbstractDumpWriter::write_rootID(oop* p) {
write_address((address)p);
}

void AbstractDumpWriter::write_symbolID(Symbol* s) {
address a = (address)((uintptr_t)s);
#ifdef _LP64
write_u8((u8)a);
#else
write_u4((u4)a);
#endif
write_address((address)((uintptr_t)s));
}

void AbstractDumpWriter::write_id(u4 x) {
Expand Down Expand Up @@ -1581,7 +1587,7 @@ void JNIGlobalsDumper::do_oop(oop* obj_p) {
u4 size = 1 + 2 * sizeof(address);
writer()->start_sub_record(HPROF_GC_ROOT_JNI_GLOBAL, size);
writer()->write_objectID(o);
writer()->write_objectID((oopDesc*)obj_p); // global ref ID
writer()->write_rootID(obj_p); // global ref ID
writer()->end_sub_record();
}
};
Expand Down

1 comment on commit 4732abf

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.