8043063: Code aging should allocate MethodCounters when flushing a method

Make sure that MethodCounters are present when the method is flushed for the first time to switch on code aging

Reviewed-by: kvn
This commit is contained in:
Igor Veresov 2014-05-14 14:28:09 -07:00
parent 397abe646b
commit d7b76028a4

View File

@ -615,6 +615,11 @@ void NMethodSweeper::possibly_flush(nmethod* nm) {
// 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();