RFR: Apply UL to PrintCodeCacheOnCompilation

chihiro ito chihiro.ito at oracle.com
Thu May 18 06:22:09 UTC 2017


Hi all,

I apply Unified JVM Logging to log of PrintCodeCacheOnCompilation 
option. Logs which applied this is following.
Could you possibly review for this following small change? If review is 
ok, please commit this as cito.

Sample Log:
[1.370s][debug][compilation,codecache] CodeHeap 'non-profiled nmethods': 
size=120036Kb used=13Kb max_used=13Kb free=120022Kb
[1.372s][debug][compilation,codecache] CodeHeap 'profiled nmethods': 
size=120032Kb used=85Kb max_used=85Kb free=119946Kb
[1.372s][debug][compilation,codecache] CodeHeap 'non-nmethods': 
size=5692Kb used=2648Kb max_used=2655Kb free=3043Kb

Source:
diff --git a/src/share/vm/compiler/compileBroker.cpp 
b/src/share/vm/compiler/compileBroker.cpp
--- a/src/share/vm/compiler/compileBroker.cpp
+++ b/src/share/vm/compiler/compileBroker.cpp
@@ -1726,6 +1726,34 @@
    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* summary = s.as_string();
+  char* cr_pos;
+
+  do {
+    cr_pos = strchr(summary, '\n');
+    if (cr_pos != NULL) {
+      *cr_pos = '\0';
+    }
+    if (strlen(summary)!=0) {
+      out->print_cr("%s", summary);
+    }
+
+    summary = cr_pos + 1;
+  } while (cr_pos != NULL);
+}
+
  void CompileBroker::post_compile(CompilerThread* thread, CompileTask* 
task, EventCompilation& event, bool success, ciEnv* ci_env) {

    if (success) {
@@ -1939,6 +1967,10 @@
      tty->print_cr("time: %d inlined: %d bytes", 
(int)time.milliseconds(), task->num_inlined_bytecodes());
    }

+  Log(compilation, codecache) log;
+  if (log.is_debug())
+    codecache_print(log.debug_stream(), /* detailed= */ false);
+
    if (PrintCodeCacheOnCompilation)
      codecache_print(/* detailed= */ false);


Regards,
Chihiro


-- 

Chihiro Ito | Principal Consultant | +81.90.6148.8815
Oracle <http://www.oracle.com> Consultant
ORACLE Japan | Akasaka Center Bldg. | Motoakasaka 1-3-13 | 1070051 
Minato-ku, Tokyo, JAPAN

Oracle is committed to developing practices and products that help 
protect the environment <http://www.oracle.com/commitment>


More information about the jdk10-dev mailing list