8154059: JVMTI ObjectTagging to UL
authorrehn
Tue, 19 Apr 2016 14:21:26 +0200
changeset 37993 e446184da25e
parent 37992 c7ec6a3275f7
child 37994 1a816b464178
child 37996 c851f9ab9816
child 38051 d092550d625d
8154059: JVMTI ObjectTagging to UL Reviewed-by: sspitsyn, mlarsson
hotspot/src/share/vm/logging/logTag.hpp
hotspot/src/share/vm/prims/jvmtiEnv.cpp
hotspot/src/share/vm/prims/jvmtiTagMap.cpp
hotspot/src/share/vm/runtime/arguments.cpp
--- a/hotspot/src/share/vm/logging/logTag.hpp	Tue Apr 19 14:14:04 2016 +0200
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Tue Apr 19 14:21:26 2016 +0200
@@ -70,6 +70,7 @@
   LOG_TAG(modules) \
   LOG_TAG(monitorinflation) \
   LOG_TAG(monitormismatch) \
+  LOG_TAG(objecttagging) \
   LOG_TAG(os) \
   LOG_TAG(pagesize) \
   LOG_TAG(phases) \
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Tue Apr 19 14:14:04 2016 +0200
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Tue Apr 19 14:21:26 2016 +0200
@@ -1675,7 +1675,7 @@
   HandleMark hm(thread);
   KlassHandle kh (thread, k_oop);
 
-  TraceTime t("FollowReferences", TraceJVMTIObjectTagging);
+  TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data);
   return JVMTI_ERROR_NONE;
 } /* end FollowReferences */
@@ -1706,7 +1706,7 @@
   HandleMark hm(thread);
   KlassHandle kh (thread, k_oop);
 
-  TraceTime t("IterateThroughHeap", TraceJVMTIObjectTagging);
+  TraceTime t("IterateThroughHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, kh, callbacks, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateThroughHeap */
@@ -1738,7 +1738,7 @@
 // tag_result_ptr - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::GetObjectsWithTags(jint tag_count, const jlong* tags, jint* count_ptr, jobject** object_result_ptr, jlong** tag_result_ptr) {
-  TraceTime t("GetObjectsWithTags", TraceJVMTIObjectTagging);
+  TraceTime t("GetObjectsWithTags", TRACETIME_LOG(Debug, jvmti, objecttagging));
   return JvmtiTagMap::tag_map_for(this)->get_objects_with_tags((jlong*)tags, tag_count, count_ptr, object_result_ptr, tag_result_ptr);
 } /* end GetObjectsWithTags */
 
@@ -1771,7 +1771,7 @@
 // user_data - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, const void* user_data) {
-  TraceTime t("IterateOverReachableObjects", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverReachableObjects", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_over_reachable_objects(heap_root_callback, stack_ref_callback, object_ref_callback, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateOverReachableObjects */
@@ -1781,7 +1781,7 @@
 // user_data - NULL is a valid value, must be checked
 jvmtiError
 JvmtiEnv::IterateOverHeap(jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
-  TraceTime t("IterateOverHeap", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging));
   Thread *thread = Thread::current();
   HandleMark hm(thread);
   JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, KlassHandle(), heap_object_callback, user_data);
@@ -1805,7 +1805,7 @@
   Thread *thread = Thread::current();
   HandleMark hm(thread);
   KlassHandle klass (thread, k_oop);
-  TraceTime t("IterateOverInstancesOfClass", TraceJVMTIObjectTagging);
+  TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
   JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
   return JVMTI_ERROR_NONE;
 } /* end IterateOverInstancesOfClass */
--- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp	Tue Apr 19 14:14:04 2016 +0200
+++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp	Tue Apr 19 14:21:26 2016 +0200
@@ -146,11 +146,7 @@
     _size_index = size_index;
     _size = initial_size;
     _entry_count = 0;
-    if (TraceJVMTIObjectTagging) {
-      _trace_threshold = initial_trace_threshold;
-    } else {
-      _trace_threshold = -1;
-    }
+    _trace_threshold = initial_trace_threshold;
     _load_factor = load_factor;
     _resize_threshold = (int)(_load_factor * _size);
     _resizing_enabled = true;
@@ -329,8 +325,7 @@
     }
 
     _entry_count++;
-    if (trace_threshold() > 0 && entry_count() >= trace_threshold()) {
-      assert(TraceJVMTIObjectTagging, "should only get here when tracing");
+    if (log_is_enabled(Debug, jvmti, objecttagging) && entry_count() >= trace_threshold()) {
       print_memory_usage();
       compute_next_trace_threshold();
     }
@@ -409,6 +404,7 @@
 
 // compute threshold for the next trace message
 void JvmtiTagHashmap::compute_next_trace_threshold() {
+  _trace_threshold = entry_count();
   if (trace_threshold() < medium_trace_threshold) {
     _trace_threshold += small_trace_threshold;
   } else {
@@ -3413,12 +3409,6 @@
     delayed_add = next;
   }
 
-  // stats
-  if (TraceJVMTIObjectTagging) {
-    int post_total = hashmap->_entry_count;
-    int pre_total = post_total + freed;
-
-    tty->print_cr("(%d->%d, %d freed, %d total moves)",
-        pre_total, post_total, freed, moved);
-  }
+  log_debug(jvmti, objecttagging)("(%d->%d, %d freed, %d total moves)",
+                                  hashmap->_entry_count + freed, hashmap->_entry_count, freed, moved);
 }
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Apr 19 14:14:04 2016 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Apr 19 14:21:26 2016 +0200
@@ -420,6 +420,7 @@
   { "TraceLoaderConstraints",    LogLevel::Info,  true,  LOG_TAGS(classload, constraints) },
   { "TraceMonitorInflation",     LogLevel::Debug, true,  LOG_TAGS(monitorinflation) },
   { "TraceSafepointCleanupTime", LogLevel::Info,  true,  LOG_TAGS(safepointcleanup) },
+  { "TraceJVMTIObjectTagging",   LogLevel::Debug, true,  LOG_TAGS(jvmti, objecttagging) },
   { NULL,                        LogLevel::Off,   false, LOG_TAGS(_NO_TAG) }
 };