Skip to content

Dwarf and JVMFlag related downports #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 15, 2025
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
Adjust for missing functionality for downports
  • Loading branch information
jbachorik committed Apr 11, 2025
commit e343b13f7d8480cbd793b6086a9e62984499c100
9 changes: 0 additions & 9 deletions ddprof-lib/src/main/cpp/codeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,6 @@ void CodeCache::sort() {
_max_address = _blobs[_count - 1]._end;
}

void CodeCache::mark(NamePredicate predicate) {
for (int i = 0; i < _count; i++) {
const char *blob_name = _blobs[i]._name;
if (blob_name != NULL && predicate(blob_name)) {
NativeFunc::mark(blob_name);
}
}
}

CodeBlob *CodeCache::findBlob(const char *name) {
for (int i = 0; i < _count; i++) {
const char *blob_name = _blobs[i]._name;
Expand Down
30 changes: 28 additions & 2 deletions ddprof-lib/src/main/cpp/codeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ enum ImportType {
NUM_IMPORT_TYPES
};

enum Mark {
MARK_VM_RUNTIME = 1,
MARK_INTERPRETER = 2,
MARK_COMPILER_ENTRY = 3,
MARK_ASYNC_PROFILER = 4, // async-profiler internals such as native hooks.
};

class NativeFunc {
private:
short _lib_index;
Expand All @@ -63,7 +70,13 @@ class NativeFunc {

static bool isMarked(const char *name) { return from(name)->_mark != 0; }

static void mark(const char *name) { from(name)->_mark = 1; }
static char mark(const char* name) {
return from(name)->_mark;
}

static void mark(const char* name, char value) {
from(name)->_mark = value;
}
};

class CodeBlob {
Expand Down Expand Up @@ -154,7 +167,20 @@ class CodeCache {
bool update_bounds = false);
void updateBounds(const void *start, const void *end);
void sort();
void mark(NamePredicate predicate);
template <typename NamePredicate>
inline void mark(NamePredicate predicate, char value) {
for (int i = 0; i < _count; i++) {
const char* blob_name = _blobs[i]._name;
if (blob_name != NULL && predicate(blob_name)) {
NativeFunc::mark(blob_name, value);
}
}

if (value == MARK_VM_RUNTIME && _name != NULL) {
// In case a library has no debug symbols
NativeFunc::mark(_name, value);
}
}

void addImport(void **entry, const char *name);
void **findImport(ImportId id);
Expand Down
35 changes: 27 additions & 8 deletions ddprof-lib/src/main/cpp/vmEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ JVM_GetManagement VM::_getManagement;

static void wakeupHandler(int signo) {
// Dummy handler for interrupting syscalls
}

static bool isVmRuntimeEntry(const char* blob_name) {
return strcmp(blob_name, "_ZNK12MemAllocator8allocateEv") == 0
Expand Down Expand Up @@ -302,14 +303,32 @@ bool VM::initShared(JavaVM* vm) {
}

VMStructs::init(lib);
if (is_zero_vm) {
lib->mark(isZeroInterpreterMethod);
} else if (isOpenJ9()) {
lib->mark(isOpenJ9InterpreterMethod);
CodeCache *libjit = libraries->findJvmLibrary("libj9jit");
if (libjit != NULL) {
libjit->mark(isOpenJ9JitStub);
}
if (isOpenJ9()) {
Libraries* libraries = Libraries::instance();
lib->mark(isOpenJ9InterpreterMethod, MARK_INTERPRETER);
lib->mark(isOpenJ9Resolve, MARK_VM_RUNTIME);
CodeCache* libjit = libraries->findJvmLibrary("libj9jit");
if (libjit != NULL) {
libjit->mark(isOpenJ9JitStub, MARK_INTERPRETER);
libjit->mark(isOpenJ9JitAlloc, MARK_VM_RUNTIME);
}
CodeCache* libgc = libraries->findJvmLibrary("libj9gc");
if (libgc != NULL) {
libgc->mark(isOpenJ9GcAlloc, MARK_VM_RUNTIME);
}
CodeCache* libjvmti = libraries->findJvmLibrary("libj9jvmti");
if (libjvmti != NULL) {
libjvmti->mark(isOpenJ9JvmtiAlloc, MARK_VM_RUNTIME);
}
} else {
lib->mark(isVmRuntimeEntry, MARK_VM_RUNTIME);
if (isZing()) {
lib->mark(isZingRuntimeEntry, MARK_VM_RUNTIME);
} else if (is_zero_vm) {
lib->mark(isZeroInterpreterMethod, MARK_INTERPRETER);
} else {
lib->mark(isCompilerEntry, MARK_COMPILER_ENTRY);
}
}
return true;
}
Expand Down
17 changes: 17 additions & 0 deletions ddprof-lib/src/main/cpp/vmStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ class CodeHeap : VMStructs {

class JVMFlag : VMStructs {
private:
enum {
ORIGIN_DEFAULT = 0,
ORIGIN_MASK = 15,
SET_ON_CMDLINE = 1 << 17
};

static JVMFlag* find(const char *name, int type_mask);
public:
enum Type {
Expand All @@ -570,10 +576,21 @@ class JVMFlag : VMStructs {
int type();

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

char origin() {
return _flag_origin_offset >= 0 ? (*(char*) at(_flag_origin_offset)) & 15 : 0;
}

bool isDefault() {
return _flag_origin_offset < 0 || (*(int*) at(_flag_origin_offset) & ORIGIN_MASK) == ORIGIN_DEFAULT;
}

void setCmdline() {
if (_flag_origin_offset >= 0) {
*(int*) at(_flag_origin_offset) |= SET_ON_CMDLINE;
}
}

char get() {
return *((char*)addr());
}
Expand Down
Loading