diff src/share/vm/oops/methodData.cpp @ 10105:aeaca88565e6

8010862: The Method counter fields used for profiling can be allocated lazily. Summary: Allocate the method's profiling related metadata until they are needed. Reviewed-by: coleenp, roland
author jiangli
date Tue, 09 Apr 2013 17:17:41 -0400
parents 46f6f063b272
children 8df6ddda8090
line wrap: on
line diff
--- a/src/share/vm/oops/methodData.cpp	Thu Apr 04 21:15:43 2013 -0700
+++ b/src/share/vm/oops/methodData.cpp	Tue Apr 09 17:17:41 2013 -0400
@@ -732,14 +732,17 @@
   } else {
     int iic = method->interpreter_invocation_count();
     if (mileage < iic)  mileage = iic;
-    InvocationCounter* ic = method->invocation_counter();
-    InvocationCounter* bc = method->backedge_counter();
-    int icval = ic->count();
-    if (ic->carry()) icval += CompileThreshold;
-    if (mileage < icval)  mileage = icval;
-    int bcval = bc->count();
-    if (bc->carry()) bcval += CompileThreshold;
-    if (mileage < bcval)  mileage = bcval;
+    MethodCounters* mcs = method->method_counters();
+    if (mcs != NULL) {
+      InvocationCounter* ic = mcs->invocation_counter();
+      InvocationCounter* bc = mcs->backedge_counter();
+      int icval = ic->count();
+      if (ic->carry()) icval += CompileThreshold;
+      if (mileage < icval)  mileage = icval;
+      int bcval = bc->count();
+      if (bc->carry()) bcval += CompileThreshold;
+      if (mileage < bcval)  mileage = bcval;
+    }
   }
   return mileage;
 }