hotspot/src/share/vm/compiler/compileBroker.cpp
changeset 46485 f10c8f2b4651
parent 46375 1b360c12efc7
child 46560 388aa8d67c80
--- 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: