Check if current method needs a deopt after method exit callbacks

Method exit listeners could request a frame pop. These are handled only
in the interpreter so we need to deopt at the method exit to handle
these. We were only deoptiming at the method exit if the caller needs a
deoptimization and hence missing frame pops if the caller didn't need a
deoptimization.

Bug: 266175266
Test: art/testrunner.py -t 1955
Change-Id: I10589e10c6b160a75f828302837d97189a79d175
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 8bb4a7c..56011c6 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -2580,7 +2580,11 @@
     UNREACHABLE();
   }
 
-  bool deoptimize = instr->ShouldDeoptimizeCaller(self, sp, frame_size);
+  // We should deoptimize here if the caller requires a deoptimization or if the current method
+  // needs a deoptimization. We may need deoptimization for the current method if method exit
+  // hooks requested this frame to be popped. IsForcedInterpreterNeededForUpcall checks for that.
+  const bool deoptimize = instr->ShouldDeoptimizeCaller(self, sp, frame_size) ||
+                          Dbg::IsForcedInterpreterNeededForUpcall(self, method);
   if (deoptimize) {
     JValue ret_val = instr->GetReturnValue(method, &is_ref, gpr_result, fpr_result);
     DeoptimizationMethodType deopt_method_type = instr->GetDeoptimizationMethodType(method);