8180654: Apply UL to PrintCodeCacheOnCompilation
authorkvn
Mon, 22 May 2017 09:07:16 -0700
changeset 46485 f10c8f2b4651
parent 46484 688e3a206b86
child 46486 314aa24e62d6
child 46497 666f3f01515b
8180654: Apply UL to PrintCodeCacheOnCompilation Reviewed-by: kvn Contributed-by: chihiro.ito@oracle.com
hotspot/src/share/vm/compiler/compileBroker.cpp
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Fri May 19 12:14:38 2017 +0200
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon May 22 09:07:16 2017 -0700
@@ -1726,6 +1726,31 @@
   tty->print("%s", s.as_string());
 }
 
+// wrapper for CodeCache::print_summary() using outputStream
+static void codecache_print(outputStream* out, bool detailed) {
+  ResourceMark rm;
+  stringStream s;
+
+  // Dump code cache into a buffer
+  {
+    MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+    CodeCache::print_summary(&s, detailed);
+  }
+
+  char* remaining_log = s.as_string();
+  while (*remaining_log != '\0') {
+    char* eol = strchr(remaining_log, '\n');
+    if (eol == NULL) {
+      out->print_cr("%s", remaining_log);
+      remaining_log = remaining_log + strlen(remaining_log);
+    } else {
+      *eol = '\0';
+      out->print_cr("%s", remaining_log);
+      remaining_log = eol + 1;
+    }
+  }
+}
+
 void CompileBroker::post_compile(CompilerThread* thread, CompileTask* task, EventCompilation& event, bool success, ciEnv* ci_env) {
 
   if (success) {
@@ -1939,9 +1964,13 @@
     tty->print_cr("time: %d inlined: %d bytes", (int)time.milliseconds(), task->num_inlined_bytecodes());
   }
 
-  if (PrintCodeCacheOnCompilation)
+  Log(compilation, codecache) log;
+  if (log.is_debug()) {
+    codecache_print(log.debug_stream(), /* detailed= */ false);
+  }
+  if (PrintCodeCacheOnCompilation) {
     codecache_print(/* detailed= */ false);
-
+  }
   // Disable compilation, if required.
   switch (compilable) {
   case ciEnv::MethodCompilable_never: