JVMTI NotifyFramePop support

Adds support for the JVMTI can_generate_frame_pop_events capability.
This includes the NotifyFramePop function and the FramePop event.

We mark the interpreter shadowframes directly to get the events. This
relies on the fact that we never replace extant shadow-frames on the
interpreter stack to ensure that we can distinguish which jvmti-envs
requested the frame pops.

Test: ./test.py --host -j50
Bug: 34414072
Bug: 62821960
Bug: 65129403

Change-Id: I6e79e39f62fdf79268540c5c1be6311df704cff7
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 474e368..87caf1b 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -106,6 +106,7 @@
       have_field_read_listeners_(false),
       have_field_write_listeners_(false),
       have_exception_thrown_listeners_(false),
+      have_watched_frame_pop_listeners_(false),
       have_branch_listeners_(false),
       have_invoke_virtual_or_interface_listeners_(false),
       deoptimized_methods_lock_("deoptimized methods lock", kDeoptimizedMethodsLock),
@@ -506,6 +507,11 @@
                            exception_thrown_listeners_,
                            listener,
                            &have_exception_thrown_listeners_);
+  PotentiallyAddListenerTo(kWatchedFramePop,
+                           events,
+                           watched_frame_pop_listeners_,
+                           listener,
+                           &have_watched_frame_pop_listeners_);
   UpdateInterpreterHandlerTable();
 }
 
@@ -583,6 +589,11 @@
                                 exception_thrown_listeners_,
                                 listener,
                                 &have_exception_thrown_listeners_);
+  PotentiallyRemoveListenerFrom(kWatchedFramePop,
+                                events,
+                                watched_frame_pop_listeners_,
+                                listener,
+                                &have_watched_frame_pop_listeners_);
   UpdateInterpreterHandlerTable();
 }
 
@@ -1045,6 +1056,14 @@
   }
 }
 
+void Instrumentation::WatchedFramePopImpl(Thread* thread, const ShadowFrame& frame) const {
+  for (InstrumentationListener* listener : watched_frame_pop_listeners_) {
+    if (listener != nullptr) {
+      listener->WatchedFramePop(thread, frame);
+    }
+  }
+}
+
 void Instrumentation::FieldReadEventImpl(Thread* thread,
                                          ObjPtr<mirror::Object> this_object,
                                          ArtMethod* method,