changeset 13014:ed5be7d0a965

8180654: Apply UL to PrintCodeCacheOnCompilation Reviewed-by: kvn Contributed-by: chihiro.ito@oracle.com
author kvn
date Mon, 22 May 2017 09:07:16 -0700
parents e006ef516938
children 8a0339df658b 792941939a5f
files src/share/vm/compiler/compileBroker.cpp
diffstat 1 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/compiler/compileBroker.cpp	Fri May 19 12:14:38 2017 +0200
+++ b/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: