@@ -458,9 +458,10 @@ void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
458458
459459// remove activation
460460//
461- // Apply stack watermark barrier.
462461// Unlock the receiver if this is a synchronized method.
463462// Unlock any Java monitors from synchronized blocks.
463+ // Apply stack watermark barrier.
464+ // Notify JVMTI.
464465// Remove the activation from the stack.
465466//
466467// If there are locked Java monitors
@@ -470,30 +471,14 @@ void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
470471// installs IllegalMonitorStateException
471472// Else
472473// no error processing
473- void InterpreterMacroAssembler::remove_activation (
474- TosState state,
475- bool throw_monitor_exception,
476- bool install_monitor_exception,
477- bool notify_jvmdi) {
474+ void InterpreterMacroAssembler::remove_activation (TosState state,
475+ bool throw_monitor_exception,
476+ bool install_monitor_exception,
477+ bool notify_jvmdi) {
478478 // Note: Registers r3 xmm0 may be in use for the
479479 // result check if synchronized method
480480 Label unlocked, unlock, no_unlock;
481481
482- // The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
483- // that would normally not be safe to use. Such bad returns into unsafe territory of
484- // the stack, will call InterpreterRuntime::at_unwind.
485- Label slow_path;
486- Label fast_path;
487- safepoint_poll (slow_path, true /* at_return */ , false /* acquire */ , false /* in_nmethod */ );
488- br (Assembler::AL, fast_path);
489- bind (slow_path);
490- push (state);
491- set_last_Java_frame (esp, rfp, (address)pc (), rscratch1);
492- super_call_VM_leaf (CAST_FROM_FN_PTR (address, InterpreterRuntime::at_unwind), rthread);
493- reset_last_Java_frame (true );
494- pop (state);
495- bind (fast_path);
496-
497482 // get the value of _do_not_unlock_if_synchronized into r3
498483 const Address do_not_unlock_if_synchronized (rthread,
499484 in_bytes (JavaThread::do_not_unlock_if_synchronized_offset ()));
@@ -611,7 +596,24 @@ void InterpreterMacroAssembler::remove_activation(
611596
612597 bind (no_unlock);
613598
614- // jvmti support
599+ JFR_ONLY (enter_jfr_critical_section ();)
600+
601+ // The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
602+ // that would normally not be safe to use. Such bad returns into unsafe territory of
603+ // the stack, will call InterpreterRuntime::at_unwind.
604+ Label slow_path;
605+ Label fast_path;
606+ safepoint_poll (slow_path, true /* at_return */ , false /* acquire */ , false /* in_nmethod */ );
607+ br (Assembler::AL, fast_path);
608+ bind (slow_path);
609+ push (state);
610+ set_last_Java_frame (esp, rfp, pc (), rscratch1);
611+ super_call_VM_leaf (CAST_FROM_FN_PTR (address, InterpreterRuntime::at_unwind), rthread);
612+ reset_last_Java_frame (true );
613+ pop (state);
614+ bind (fast_path);
615+
616+ // JVMTI support. Make sure the safepoint poll test is issued prior.
615617 if (notify_jvmdi) {
616618 notify_method_exit (state, NotifyJVMTI); // preserve TOSCA
617619 } else {
@@ -638,6 +640,8 @@ void InterpreterMacroAssembler::remove_activation(
638640 cmp (rscratch2, rscratch1);
639641 br (Assembler::LS, no_reserved_zone_enabling);
640642
643+ JFR_ONLY (leave_jfr_critical_section ();)
644+
641645 call_VM_leaf (
642646 CAST_FROM_FN_PTR (address, SharedRuntime::enable_stack_reserved_zone), rthread);
643647 call_VM (noreg, CAST_FROM_FN_PTR (address,
@@ -647,17 +651,34 @@ void InterpreterMacroAssembler::remove_activation(
647651 bind (no_reserved_zone_enabling);
648652 }
649653
650- // restore sender esp
651- mov (esp, rscratch2);
652654 // remove frame anchor
653655 leave ();
656+
657+ JFR_ONLY (leave_jfr_critical_section ();)
658+
659+ // restore sender esp
660+ mov (esp, rscratch2);
661+
654662 // If we're returning to interpreted code we will shortly be
655663 // adjusting SP to allow some space for ESP. If we're returning to
656664 // compiled code the saved sender SP was saved in sender_sp, so this
657665 // restores it.
658666 andr (sp, esp, -16 );
659667}
660668
669+ #if INCLUDE_JFR
670+ void InterpreterMacroAssembler::enter_jfr_critical_section () {
671+ const Address sampling_critical_section (rthread, in_bytes (SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
672+ mov (rscratch1, true );
673+ strb (rscratch1, sampling_critical_section);
674+ }
675+
676+ void InterpreterMacroAssembler::leave_jfr_critical_section () {
677+ const Address sampling_critical_section (rthread, in_bytes (SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
678+ strb (zr, sampling_critical_section);
679+ }
680+ #endif // INCLUDE_JFR
681+
661682// Lock object
662683//
663684// Args:
0 commit comments