Skip to content

Commit 872be63

Browse files
authored
Fix VMStructs::initJvmFunctions call order (async-profiler#1658)
1 parent a89d7dd commit 872be63

11 files changed

+10
-95
lines changed

src/profiler.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,11 +869,6 @@ void Profiler::crashHandler(int signo, siginfo_t* siginfo, void* ucontext) {
869869
StackWalker::checkFault();
870870
}
871871

872-
// Workaround for JDK-8313796. Setting cstack=dwarf also helps
873-
if (VMStructs::isInterpretedFrameValidFunc((const void*)pc) && frame.skipFaultInstruction()) {
874-
return;
875-
}
876-
877872
if (WX_MEMORY && Trap::isFaultInstruction(pc)) {
878873
return;
879874
}

src/stackFrame.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ class StackFrame {
7575

7676
void adjustSP(const void* entry, const void* pc, uintptr_t& sp);
7777

78-
bool skipFaultInstruction();
79-
8078
bool checkInterruptedSyscall();
8179

8280
// Check if PC points to a syscall instruction

src/stackFrame_aarch64.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
353353
}
354354
}
355355

356-
bool StackFrame::skipFaultInstruction() {
357-
return false;
358-
}
359-
360356
bool StackFrame::checkInterruptedSyscall() {
361357
#ifdef __APPLE__
362358
// We are not interested in syscalls that do not check error code, e.g. semaphore_wait_trap

src/stackFrame_arm.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
125125
// Not needed
126126
}
127127

128-
bool StackFrame::skipFaultInstruction() {
129-
return false;
130-
}
131-
132128
bool StackFrame::checkInterruptedSyscall() {
133129
return retval() == (uintptr_t)-EINTR;
134130
}

src/stackFrame_i386.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
146146
// Not needed
147147
}
148148

149-
bool StackFrame::skipFaultInstruction() {
150-
return false;
151-
}
152-
153149
bool StackFrame::checkInterruptedSyscall() {
154150
return retval() == (uintptr_t)-EINTR;
155151
}

src/stackFrame_loongarch64.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
101101
// Not yet implemented
102102
}
103103

104-
bool StackFrame::skipFaultInstruction() {
105-
return false;
106-
}
107-
108104
bool StackFrame::checkInterruptedSyscall() {
109105
return retval() == (uintptr_t)-EINTR;
110106
}

src/stackFrame_ppc64.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
146146
// Not needed
147147
}
148148

149-
bool StackFrame::skipFaultInstruction() {
150-
return false;
151-
}
152-
153149
bool StackFrame::checkInterruptedSyscall() {
154150
return retval() == (uintptr_t)-EINTR;
155151
}

src/stackFrame_riscv64.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
101101
// Not yet implemented
102102
}
103103

104-
bool StackFrame::skipFaultInstruction() {
105-
return false;
106-
}
107-
108104
bool StackFrame::checkInterruptedSyscall() {
109105
return retval() == (uintptr_t)-EINTR;
110106
}

src/stackFrame_x64.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -247,40 +247,6 @@ void StackFrame::adjustSP(const void* entry, const void* pc, uintptr_t& sp) {
247247
// Not needed
248248
}
249249

250-
// Skip failed MOV instruction by writing 0 to destination register
251-
bool StackFrame::skipFaultInstruction() {
252-
unsigned int insn = *(unsigned int*)pc();
253-
if ((insn & 0x80fff8) == 0x008b48) {
254-
// mov r64, [r64 + offs]
255-
unsigned int reg = ((insn << 1) & 8) | ((insn >> 19) & 7);
256-
switch (reg) {
257-
case 0x0: REG(RAX, rax) = 0; break;
258-
case 0x1: REG(RCX, rcx) = 0; break;
259-
case 0x2: REG(RDX, rdx) = 0; break;
260-
case 0x3: REG(RBX, rbx) = 0; break;
261-
case 0x4: return false; // Do not modify RSP
262-
case 0x5: REG(RBP, rbp) = 0; break;
263-
case 0x6: REG(RSI, rsi) = 0; break;
264-
case 0x7: REG(RDI, rdi) = 0; break;
265-
case 0x8: REG(R8 , r8 ) = 0; break;
266-
case 0x9: REG(R9 , r9 ) = 0; break;
267-
case 0xa: REG(R10, r10) = 0; break;
268-
case 0xb: REG(R11, r11) = 0; break;
269-
case 0xc: REG(R12, r12) = 0; break;
270-
case 0xd: REG(R13, r13) = 0; break;
271-
case 0xe: REG(R14, r14) = 0; break;
272-
case 0xf: REG(R15, r15) = 0; break;
273-
}
274-
275-
unsigned int insn_size = 3;
276-
if ((insn & 0x070000) == 0x040000) insn_size++;
277-
if ((insn & 0x400000) == 0x400000) insn_size++;
278-
pc() += insn_size;
279-
return true;
280-
}
281-
return false;
282-
}
283-
284250
bool StackFrame::checkInterruptedSyscall() {
285251
#ifdef __APPLE__
286252
// We are not interested in syscalls that do not check error code, e.g. semaphore_wait_trap

src/vmStructs.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ int VMStructs::_interpreter_frame_bcp_offset = 0;
105105
unsigned char VMStructs::_unsigned5_base = 0;
106106
const void** VMStructs::_call_stub_return_addr = NULL;
107107
const void* VMStructs::_call_stub_return = NULL;
108-
const void* VMStructs::_interpreted_frame_valid_start = NULL;
109-
const void* VMStructs::_interpreted_frame_valid_end = NULL;
110108

111109
jfieldID VMStructs::_eetop;
112110
jfieldID VMStructs::_tid;
@@ -133,7 +131,6 @@ void VMStructs::init(CodeCache* libjvm) {
133131
if (libjvm != NULL) {
134132
_libjvm = libjvm;
135133
initOffsets();
136-
initJvmFunctions();
137134
}
138135
}
139136

@@ -479,11 +476,16 @@ void VMStructs::resolveOffsets() {
479476
&& _comp_task_offset >= 0
480477
&& _comp_method_offset >= 0;
481478

482-
_has_class_loader_data = _class_loader_data_offset >= 0
483-
&& _class_loader_data_next_offset == sizeof(uintptr_t) * 8 + 8
484-
&& _methods_offset >= 0
485-
&& _klass != NULL
486-
&& _lock_func != NULL && _unlock_func != NULL;
479+
if (VM::hotspot_version() == 8) {
480+
_lock_func = (LockFunc)_libjvm->findSymbol("_ZN7Monitor28lock_without_safepoint_checkEv");
481+
_unlock_func = (LockFunc)_libjvm->findSymbol("_ZN7Monitor6unlockEv");
482+
_has_class_loader_data = _class_loader_data_offset >= 0
483+
&& _class_loader_data_next_offset == sizeof(uintptr_t) * 8 + 8
484+
&& _methods_offset >= 0
485+
&& _klass != NULL
486+
&& _lock_func != NULL
487+
&& _unlock_func != NULL;
488+
}
487489

488490
#if defined(__x86_64__) || defined(__i386__)
489491
_interpreter_frame_bcp_offset = VM::hotspot_version() >= 11 ? -8 : VM::hotspot_version() == 8 ? -7 : 0;
@@ -556,21 +558,6 @@ void VMStructs::resolveOffsets() {
556558
}
557559
}
558560

559-
void VMStructs::initJvmFunctions() {
560-
if (VM::hotspot_version() == 8) {
561-
_lock_func = (LockFunc)_libjvm->findSymbol("_ZN7Monitor28lock_without_safepoint_checkEv");
562-
_unlock_func = (LockFunc)_libjvm->findSymbol("_ZN7Monitor6unlockEv");
563-
}
564-
565-
if (VM::hotspot_version() > 0) {
566-
CodeBlob* blob = _libjvm->findBlob("_ZNK5frame26is_interpreted_frame_validEP10JavaThread");
567-
if (blob != NULL) {
568-
_interpreted_frame_valid_start = blob->_start;
569-
_interpreted_frame_valid_end = blob->_end;
570-
}
571-
}
572-
}
573-
574561
void VMStructs::patchSafeFetch() {
575562
// Workarounds for JDK-8307549 and JDK-8321116
576563
if (WX_MEMORY && VM::hotspot_version() == 17) {

0 commit comments

Comments
 (0)