Revert^4 "Rewrite JVMTI method tracing to use trampolines"

Since we are unable to change the semantics of ClassLoaded and
ClassPrepared due to b/111394423 for the moment changes were made in
libjdwp to remove the deadlock between the jit being stopped and
jit-threads trying to lock JVMTI monitors in libjdwp.

Until some resolution for b/111394423 is implemented agents should be
very careful about gaining locks in the ClassLoaded, ClassPrepared or
VMObjectAlloc events if said lock is held over a call to
SetEventNotificationMode, SetExtensionEventCallback,
RetransformClasses, or RedefineClasses. These locks can only be
safely held if the object argument to the event is not an array-class
object or the thread is known not to be a jit thread.

This reverts commit bf2ca05ccf658a9f626d1cb3f1adca6087ece7b8.

Bug: 111394423
Test: ./art/tools/run-libjdwp-tests.sh --mode=host --debug

Reason for revert: Fixed issue with libjdwp deadlocking on jit threads

Change-Id: I8baeb8311f67062cbc26286eb221da34e1972f27
diff --git a/openjdkjvmti/events.cc b/openjdkjvmti/events.cc
index f71a5dc..10a4923 100644
--- a/openjdkjvmti/events.cc
+++ b/openjdkjvmti/events.cc
@@ -888,16 +888,29 @@
     case ArtJvmtiEvent::kBreakpoint:
     case ArtJvmtiEvent::kException:
       return false;
-    // TODO We should support more of these or at least do something to make them discriminate by
-    // thread.
+    default:
+      return true;
+  }
+}
+
+static FullDeoptRequirement GetFullDeoptRequirement(ArtJvmtiEvent event) {
+  switch (event) {
+    // TODO We should support more of these as Limited or at least do something to make them
+    // discriminate by thread.
     case ArtJvmtiEvent::kMethodEntry:
-    case ArtJvmtiEvent::kExceptionCatch:
     case ArtJvmtiEvent::kMethodExit:
+      // We only need MethodEntered and MethodExited for these so we can use Stubs. We will need to
+      // disable intrinsics.
+      // TODO Offer a version of this without disabling intrinsics.
+      return FullDeoptRequirement::kStubs;
+    case ArtJvmtiEvent::kExceptionCatch:
     case ArtJvmtiEvent::kFieldModification:
     case ArtJvmtiEvent::kFieldAccess:
     case ArtJvmtiEvent::kSingleStep:
+    // NB If we ever make this runnable using stubs or some other method we will need to be careful
+    // that it doesn't require disabling intrinsics.
     case ArtJvmtiEvent::kFramePop:
-      return true;
+      return FullDeoptRequirement::kInterpreter;
     default:
       LOG(FATAL) << "Unexpected event type!";
       UNREACHABLE();
@@ -907,19 +920,18 @@
 void EventHandler::SetupTraceListener(JvmtiMethodTraceListener* listener,
                                       ArtJvmtiEvent event,
                                       bool enable) {
-  bool needs_full_deopt = EventNeedsFullDeopt(event);
   // Make sure we can deopt.
   {
     art::ScopedObjectAccess soa(art::Thread::Current());
     DeoptManager* deopt_manager = DeoptManager::Get();
     if (enable) {
       deopt_manager->AddDeoptimizationRequester();
-      if (needs_full_deopt) {
-        deopt_manager->AddDeoptimizeAllMethods();
+      if (EventNeedsFullDeopt(event)) {
+        deopt_manager->AddDeoptimizeAllMethods(GetFullDeoptRequirement(event));
       }
     } else {
-      if (needs_full_deopt) {
-        deopt_manager->RemoveDeoptimizeAllMethods();
+      if (EventNeedsFullDeopt(event)) {
+        deopt_manager->RemoveDeoptimizeAllMethods(GetFullDeoptRequirement(event));
       }
       deopt_manager->RemoveDeoptimizationRequester();
     }