diff src/cpu/sparc/vm/templateInterpreter_sparc.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 0094485b46c7
children 603ca7e51354
line wrap: on
line diff
--- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Thu Apr 04 21:15:43 2013 -0700
+++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Apr 09 17:17:41 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -292,11 +292,15 @@
 // ??: invocation counter
 //
 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
-  // Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not.
+  // Note: In tiered we increment either counters in MethodCounters* or in
+  // MDO depending if we're profiling or not.
+  const Register Rcounters = G3_scratch;
+  Label done;
+
   if (TieredCompilation) {
     const int increment = InvocationCounter::count_increment;
     const int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
-    Label no_mdo, done;
+    Label no_mdo;
     if (ProfileInterpreter) {
       // If no method data exists, go to profile_continue.
       __ ld_ptr(Lmethod, Method::method_data_offset(), G4_scratch);
@@ -311,23 +315,26 @@
       __ ba_short(done);
     }
 
-    // Increment counter in Method*
+    // Increment counter in MethodCounters*
     __ bind(no_mdo);
-    Address invocation_counter(Lmethod,
-                               in_bytes(Method::invocation_counter_offset()) +
-                               in_bytes(InvocationCounter::counter_offset()));
+    Address invocation_counter(Rcounters,
+            in_bytes(MethodCounters::invocation_counter_offset()) +
+            in_bytes(InvocationCounter::counter_offset()));
+    __ get_method_counters(Lmethod, Rcounters, done);
     __ increment_mask_and_jump(invocation_counter, increment, mask,
-                               G3_scratch, Lscratch,
+                               G4_scratch, Lscratch,
                                Assembler::zero, overflow);
     __ bind(done);
   } else {
     // Update standard invocation counters
-    __ increment_invocation_counter(O0, G3_scratch);
-    if (ProfileInterpreter) {  // %%% Merge this into MethodData*
-      Address interpreter_invocation_counter(Lmethod,in_bytes(Method::interpreter_invocation_counter_offset()));
-      __ ld(interpreter_invocation_counter, G3_scratch);
-      __ inc(G3_scratch);
-      __ st(G3_scratch, interpreter_invocation_counter);
+    __ get_method_counters(Lmethod, Rcounters, done);
+    __ increment_invocation_counter(Rcounters, O0, G4_scratch);
+    if (ProfileInterpreter) {
+      Address interpreter_invocation_counter(Rcounters,
+            in_bytes(MethodCounters::interpreter_invocation_counter_offset()));
+      __ ld(interpreter_invocation_counter, G4_scratch);
+      __ inc(G4_scratch);
+      __ st(G4_scratch, interpreter_invocation_counter);
     }
 
     if (ProfileInterpreter && profile_method != NULL) {
@@ -345,6 +352,7 @@
     __ cmp(O0, G3_scratch);
     __ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow); // Far distance
     __ delayed()->nop();
+    __ bind(done);
   }
 
 }