Combine JDWP location events

The runtime now sends location events BREAKPOINT, SINGLE_STEP, METHOD_ENTRY,
METHOD_EXIT and METHOD_EXIT_WITH_RETURN_VALUE in the same JDWP event packet
when they relate to the same location.

We update the Dbg::UpdateDebugger method to take initial event flags and
returned value. It allows to call this method from DebugInstrumentationListener
so we can treat method entry/exit events with breakpoint and single-step.

In the interpreter, we ensure we do not call Instrumentation::DexPcMovedEvent
when Instrumentation::MethodEnterEvent has just been called or when we're about
to call Instrumentation::MethodExitEvent. This prevents from sending duplicated
events.

I measured the average performance impact on some benchmarks with a Nexus 4
without a debugger attached:
* 1%-2% for the computed-goto-based interpreter (default interpreter)
* 5%-10% for the switch-based interpreter.
This is mostly due to the test of the boolean flag for the method entry event.

Bug: https://code.google.com/p/android/issues/detail?id=68427
Bug: 11874828
Change-Id: Ic4ff61375ff6b4ed5825adeac09f61f97b4be619
diff --git a/runtime/debugger.h b/runtime/debugger.h
index bef708c..1ad1a00 100644
--- a/runtime/debugger.h
+++ b/runtime/debugger.h
@@ -417,10 +417,6 @@
     kMethodEntry    = 0x04,
     kMethodExit     = 0x08,
   };
-  static void PostLocationEvent(mirror::ArtMethod* method, int pcOffset,
-                                mirror::Object* thisPtr, int eventFlags,
-                                const JValue* return_value)
-      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static void PostFieldAccessEvent(mirror::ArtMethod* m, int dex_pc, mirror::Object* this_object,
                                    mirror::ArtField* f)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -439,7 +435,8 @@
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   static void UpdateDebugger(Thread* thread, mirror::Object* this_object,
-                             mirror::ArtMethod* method, uint32_t new_dex_pc)
+                             mirror::ArtMethod* method, uint32_t new_dex_pc,
+                             int event_flags, const JValue* return_value)
       LOCKS_EXCLUDED(Locks::breakpoint_lock_)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
@@ -561,6 +558,11 @@
   static void PostThreadStartOrStop(Thread*, uint32_t)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
+  static void PostLocationEvent(mirror::ArtMethod* method, int pcOffset,
+                                mirror::Object* thisPtr, int eventFlags,
+                                const JValue* return_value)
+      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
   static JDWP::ObjectId GetThisObjectIdForEvent(mirror::Object* this_object)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);