Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
fi
fi
check-formatting:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: check-for-pr
if: needs.check-for-pr.outputs.skip != 'true'
steps:
Expand Down
10 changes: 8 additions & 2 deletions ddprof-lib/src/main/cpp/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,15 @@ void VMStructs::resolveOffsets() {
_call_stub_return = *_call_stub_return_addr;
}

// Since JDK 23, _metadata_offset is relative to _data_offset. See metadata()
if (_nmethod_immutable_offset < 0) {
_data_offset = 0;
}

_has_stack_structs =
_has_method_structs && _interpreter_frame_bcp_offset != 0 &&
_code_offset != -1 && _scopes_data_offset != -1 &&
_data_offset >= 0 &&
_scopes_pcs_offset >= 0 &&
_nmethod_immutable_offset < 0 // TODO: not yet supported
&& _nmethod_metadata_offset >= 0 && _thread_vframe_offset >= 0 &&
Expand Down Expand Up @@ -854,8 +860,8 @@ int NMethod::findScopeOffset(const void *pc) {
}

const int *scopes_pcs = (const int *)at(_scopes_pcs_offset);
PcDesc *pcd = (PcDesc *)at(scopes_pcs[0]);
PcDesc *pcd_end = (PcDesc *)at(scopes_pcs[1]);
PcDesc* pcd = (PcDesc*) immutableDataAt(scopes_pcs[0]);
PcDesc* pcd_end = (PcDesc*) immutableDataAt(scopes_pcs[1]);
int low = 0;
int high = (pcd_end - pcd) - 1;

Expand Down
32 changes: 25 additions & 7 deletions ddprof-lib/src/main/cpp/vmStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,20 @@ class NMethod : VMStructs {

short frameCompleteOffset() { return *(short *)at(_frame_complete_offset); }

// TODO: offset is short on JDK 23+
void setFrameCompleteOffset(int offset) {
*(int *)at(_frame_complete_offset) = offset;
if (_nmethod_immutable_offset > 0) {
// _frame_complete_offset is short on JDK 23+
*(short*) at(_frame_complete_offset) = offset;
} else {
*(int*) at(_frame_complete_offset) = offset;
}
}

const char* immutableDataAt(int offset) {
if (_nmethod_immutable_offset > 0) {
return *(const char**) at(_nmethod_immutable_offset) + offset;
}
return at(offset);
}

const char *code() {
Expand All @@ -344,7 +355,7 @@ class NMethod : VMStructs {

const char *scopes() {
if (_scopes_data_offset > 0) {
return at(*(int *)at(_scopes_data_offset));
return immutableDataAt(*(int*) at(_scopes_data_offset));
} else {
return *(const char **)at(-_scopes_data_offset);
}
Expand Down Expand Up @@ -391,6 +402,9 @@ class NMethod : VMStructs {
}

VMMethod **metadata() {
if (_data_offset > 0) {
return (VMMethod**) at(*(int*) at(_data_offset) + *(unsigned short*) at(_nmethod_metadata_offset));
}
return (VMMethod **)at(*(int *)at(_nmethod_metadata_offset));
}

Expand Down Expand Up @@ -663,26 +677,30 @@ class PcDesc {

class ScopeDesc : VMStructs {
private:
NMethod *_nm;
const unsigned char* _scopes;
VMMethod** _metadata;
const unsigned char *_stream;
int _method_offset;
int _bci;

int readInt();

public:
ScopeDesc(NMethod *nm) : _nm(nm) {}
ScopeDesc(NMethod *nm) {
_scopes = (const unsigned char*)nm->scopes();
_metadata = nm->metadata();
}

int decode(int offset) {
_stream = (const unsigned char *)_nm->scopes() + offset;
_stream = _scopes + offset;
int sender_offset = readInt();
_method_offset = readInt();
_bci = readInt() - 1;
return sender_offset;
}

VMMethod *method() {
return _method_offset > 0 ? _nm->metadata()[_method_offset - 1] : NULL;
return _method_offset > 0 ? _metadata[_method_offset - 1] : NULL;
}

int bci() { return _bci; }
Expand Down
Loading