JDK-8043063 : Code aging should allocate MethodCounters when flushing a method
Type:Enhancement
Component:hotspot
Sub-Component:compiler
Affected Version:9
Priority:P5
Status:Resolved
Resolution:Fixed
Submitted:2014-05-13
Updated:2014-05-30
Resolved:2014-05-14
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
In some edge cases we may not have MethodCounters allocated for a method that was compiled.
Comments
Suggested fix:
diff --git a/src/share/vm/runtime/sweeper.cpp b/src/share/vm/runtime/sweeper.cpp
--- a/src/share/vm/runtime/sweeper.cpp
+++ b/src/share/vm/runtime/sweeper.cpp
@@ -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();