8043063: Code aging should allocate MethodCounters when flushing a method
authoriveresov
Wed, 14 May 2014 14:28:09 -0700
changeset 24445 518f34b4384e
parent 24444 6620ba171a94
child 24446 dca843327b90
child 24476 912595db2e75
child 24478 e7dad659b819
8043063: Code aging should allocate MethodCounters when flushing a method Summary: Make sure that MethodCounters are present when the method is flushed for the first time to switch on code aging Reviewed-by: kvn
hotspot/src/share/vm/runtime/sweeper.cpp
--- a/hotspot/src/share/vm/runtime/sweeper.cpp	Wed May 14 12:09:13 2014 -0400
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp	Wed May 14 14:28:09 2014 -0700
@@ -615,6 +615,11 @@
       // flat profiles). Check the age counter for possible data.
       if (UseCodeAging && make_not_entrant && (nm->is_compiled_by_c2() || nm->is_compiled_by_c1())) {
         MethodCounters* mc = nm->method()->method_counters();
+        if (mc == NULL) {
+          // Sometimes we can get here without MethodCounters. For example if we run with -Xcomp.
+          // Try to allocate them.
+          mc = Method::build_method_counters(nm->method(), Thread::current());
+        }
         if (mc != NULL) {
           // Snapshot the value as it's changed concurrently
           int age = mc->nmethod_age();