OSDN Git Service

ART: Better handle multiple event enables
authorAndreas Gampe <agampe@google.com>
Tue, 18 Oct 2016 00:49:59 +0000 (17:49 -0700)
committerAndreas Gampe <agampe@google.com>
Tue, 18 Oct 2016 00:49:59 +0000 (17:49 -0700)
Only do extra work like allocation listener registration when the
global state changes.

Bug: 31684920
Test: m test-art-host
Change-Id: Id927f2b504e02f2d68bc6e4af2658a6017920d8a

runtime/openjdkjvmti/events.cc

index 9ff6c93..59e01ea 100644 (file)
@@ -219,6 +219,8 @@ jvmtiError EventHandler::SetEvent(ArtJvmTiEnv* env,
     return ERR(INVALID_EVENT_TYPE);
   }
 
+  bool old_state = global_mask.Test(event);
+
   if (mode == JVMTI_ENABLE) {
     env->event_masks.EnableEvent(thread, event);
     global_mask.Set(event);
@@ -239,8 +241,12 @@ jvmtiError EventHandler::SetEvent(ArtJvmTiEnv* env,
     global_mask.Set(event, union_value);
   }
 
+  bool new_state = global_mask.Test(event);
+
   // Handle any special work required for the event type.
-  HandleEventType(event, mode == JVMTI_ENABLE);
+  if (new_state != old_state) {
+    HandleEventType(event, mode == JVMTI_ENABLE);
+  }
 
   return ERR(NONE);
 }