@@ -394,7 +394,53 @@ __attribute__((no_sanitize("address"))) int StackWalker::walkVM(void* ucontext,
394394 anchor = NULL ;
395395 }
396396
397- if (nm->isNMethod ()) {
397+ if (nm->isInterpreter ()) {
398+ if (vm_thread != NULL && vm_thread->inDeopt ()) {
399+ fillFrame (frames[depth++], BCI_ERROR , " break_deopt" );
400+ break ;
401+ }
402+
403+ bool is_plausible_interpreter_frame = StackWalkValidation::isPlausibleInterpreterFrame (fp, sp, bcp_offset);
404+ if (is_plausible_interpreter_frame) {
405+ VMMethod* method = ((VMMethod**)fp)[InterpreterFrame::method_offset];
406+ jmethodID method_id = getMethodId (method);
407+ if (method_id != NULL ) {
408+ Counters::increment (WALKVM_JAVA_FRAME_OK );
409+ const char * bytecode_start = method->bytecode ();
410+ const char * bcp = ((const char **)fp)[bcp_offset];
411+ int bci = bytecode_start == NULL || bcp < bytecode_start ? 0 : bcp - bytecode_start;
412+ fillFrame (frames[depth++], FRAME_INTERPRETED , bci, method_id);
413+
414+ sp = ((uintptr_t *)fp)[InterpreterFrame::sender_sp_offset];
415+ pc = stripPointer (((void **)fp)[FRAME_PC_SLOT ]);
416+ fp = *(uintptr_t *)fp;
417+ continue ;
418+ }
419+ }
420+
421+ if (depth == 0 ) {
422+ VMMethod* method = (VMMethod*)frame.method ();
423+ jmethodID method_id = getMethodId (method);
424+ if (method_id != NULL ) {
425+ Counters::increment (WALKVM_JAVA_FRAME_OK );
426+ fillFrame (frames[depth++], FRAME_INTERPRETED , 0 , method_id);
427+
428+ if (is_plausible_interpreter_frame) {
429+ pc = stripPointer (((void **)fp)[FRAME_PC_SLOT ]);
430+ sp = frame.senderSP ();
431+ fp = *(uintptr_t *)fp;
432+ } else {
433+ pc = stripPointer (SafeAccess::load ((void **)sp));
434+ sp = frame.senderSP ();
435+ }
436+ continue ;
437+ }
438+ }
439+
440+ Counters::increment (WALKVM_BREAK_INTERPRETED );
441+ fillFrame (frames[depth++], BCI_ERROR , " break_interpreted" );
442+ break ;
443+ } else if (nm->isNMethod ()) {
398444 // Check if deoptimization is in progress before walking compiled frames
399445 if (vm_thread != NULL && vm_thread->inDeopt ()) {
400446 fillFrame (frames[depth++], BCI_ERROR , " break_deopt_compiled" );
@@ -453,52 +499,6 @@ __attribute__((no_sanitize("address"))) int StackWalker::walkVM(void* ucontext,
453499 Counters::increment (WALKVM_BREAK_COMPILED );
454500 fillFrame (frames[depth++], BCI_ERROR , " break_compiled" );
455501 break ;
456- } else if (nm->isInterpreter ()) {
457- if (vm_thread != NULL && vm_thread->inDeopt ()) {
458- fillFrame (frames[depth++], BCI_ERROR , " break_deopt" );
459- break ;
460- }
461-
462- bool is_plausible_interpreter_frame = StackWalkValidation::isPlausibleInterpreterFrame (fp, sp, bcp_offset);
463- if (is_plausible_interpreter_frame) {
464- VMMethod* method = ((VMMethod**)fp)[InterpreterFrame::method_offset];
465- jmethodID method_id = getMethodId (method);
466- if (method_id != NULL ) {
467- Counters::increment (WALKVM_JAVA_FRAME_OK );
468- const char * bytecode_start = method->bytecode ();
469- const char * bcp = ((const char **)fp)[bcp_offset];
470- int bci = bytecode_start == NULL || bcp < bytecode_start ? 0 : bcp - bytecode_start;
471- fillFrame (frames[depth++], FRAME_INTERPRETED , bci, method_id);
472-
473- sp = ((uintptr_t *)fp)[InterpreterFrame::sender_sp_offset];
474- pc = stripPointer (((void **)fp)[FRAME_PC_SLOT ]);
475- fp = *(uintptr_t *)fp;
476- continue ;
477- }
478- }
479-
480- if (depth == 0 ) {
481- VMMethod* method = (VMMethod*)frame.method ();
482- jmethodID method_id = getMethodId (method);
483- if (method_id != NULL ) {
484- Counters::increment (WALKVM_JAVA_FRAME_OK );
485- fillFrame (frames[depth++], FRAME_INTERPRETED , 0 , method_id);
486-
487- if (is_plausible_interpreter_frame) {
488- pc = stripPointer (((void **)fp)[FRAME_PC_SLOT ]);
489- sp = frame.senderSP ();
490- fp = *(uintptr_t *)fp;
491- } else {
492- pc = stripPointer (SafeAccess::load ((void **)sp));
493- sp = frame.senderSP ();
494- }
495- continue ;
496- }
497- }
498-
499- Counters::increment (WALKVM_BREAK_INTERPRETED );
500- fillFrame (frames[depth++], BCI_ERROR , " break_interpreted" );
501- break ;
502502 } else if (nm->isEntryFrame (pc) && !features.mixed ) {
503503 VMJavaFrameAnchor* next_anchor = VMJavaFrameAnchor::fromEntryFrame (fp);
504504 if (next_anchor == NULL ) {
0 commit comments