Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Deal with the JVM flag implementation differences
  • Loading branch information
jbachorik committed Nov 8, 2024
commit 6dd9ae7d47b370d00c33e053484ea1a484473ec0
34 changes: 34 additions & 0 deletions ddprof-lib/src/main/cpp/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,40 @@ void *JVMFlag::find(const char *name) {
return NULL;
}

int JVMFlag::type() {
if (VM::hotspot_version() < 16) { // in JDK 16 the JVM flag implementation has changed
char* type_name = *(char **)at(_flag_type_offset);
if (type_name == NULL) {
return JVMFlag::Type::Unknown;
}
if (strcmp(type_name, "bool") == 0) {
return JVMFlag::Type::Bool;
} else if (strcmp(type_name, "int") == 0) {
return JVMFlag::Type::Int;
} else if (strcmp(type_name, "uint") == 0) {
return JVMFlag::Type::Uint;
} else if (strcmp(type_name, "intx") == 0) {
return JVMFlag::Type::Intx;
} else if (strcmp(type_name, "uintx") == 0) {
return JVMFlag::Type::Uintx;
} else if (strcmp(type_name, "uint64_t") == 0) {
return JVMFlag::Type::Uint64_t;
} else if (strcmp(type_name, "size_t") == 0) {
return JVMFlag::Type::Size_t;
} else if (strcmp(type_name, "double") == 0) {
return JVMFlag::Type::Double;
} else if (strcmp(type_name, "ccstr") == 0) {
return JVMFlag::Type::String;
} else if (strcmp(type_name, "ccstrlist") == 0) {
return JVMFlag::Type::Stringlist;
} else {
return JVMFlag::Type::Unknown;
}
} else {
return *(int *)at(_flag_type_offset);
}
}

void *JVMFlag::find(const char *name, int type_mask) {
if (_flags_addr != NULL && _flag_size > 0) {
for (int i = 0; i < _flag_count; i++) {
Expand Down
16 changes: 15 additions & 1 deletion ddprof-lib/src/main/cpp/vmStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,25 @@ class CodeHeap : VMStructs {

class JVMFlag : VMStructs {
public:
enum Type {
Bool = 0,
Int = 1,
Uint = 2,
Intx = 3,
Uintx = 4,
Uint64_t = 5,
Size_t = 6,
Double = 7,
String = 8,
Stringlist = 9,
Unknown = -1
};

static void *find(const char *name);
static void *find(const char *name, int type_mask);

const char *name() { return *(const char **)at(_flag_name_offset); }
int type() { return *(int *)at(_flag_type_offset); }
int type();

void *addr() { return *(void **)at(_flag_addr_offset); }
};
Expand Down