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
--- 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();