hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp
changeset 17000 11bf92e571a2
parent 16624 9dbd4b210bf9
child 17037 34baf792b14d
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Thu Apr 04 21:15:43 2013 -0700
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.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
@@ -344,13 +344,13 @@
 // rcx: invocation counter
 //
 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
-  const Address invocation_counter(rbx, in_bytes(Method::invocation_counter_offset()) +
-                                        in_bytes(InvocationCounter::counter_offset()));
-  // Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not.
+  Label done;
+  // Note: In tiered we increment either counters in MethodCounters* or in MDO
+  // depending if we're profiling or not.
   if (TieredCompilation) {
     int increment = InvocationCounter::count_increment;
     int mask = ((1 << Tier0InvokeNotifyFreqLog)  - 1) << InvocationCounter::count_shift;
-    Label no_mdo, done;
+    Label no_mdo;
     if (ProfileInterpreter) {
       // Are we profiling?
       __ movptr(rax, Address(rbx, Method::method_data_offset()));
@@ -363,23 +363,38 @@
       __ jmpb(done);
     }
     __ bind(no_mdo);
-    // Increment counter in Method* (we don't need to load it, it's in rcx).
-    __ increment_mask_and_jump(invocation_counter, increment, mask, rcx, true, Assembler::zero, overflow);
+    // Increment counter in MethodCounters
+    const Address invocation_counter(rax,
+                  MethodCounters::invocation_counter_offset() +
+                  InvocationCounter::counter_offset());
+
+    __ get_method_counters(rbx, rax, done);
+    __ increment_mask_and_jump(invocation_counter, increment, mask,
+                               rcx, false, Assembler::zero, overflow);
     __ bind(done);
   } else {
-    const Address backedge_counter  (rbx, Method::backedge_counter_offset() +
-                                          InvocationCounter::counter_offset());
+    const Address backedge_counter  (rax,
+                  MethodCounters::backedge_counter_offset() +
+                  InvocationCounter::counter_offset());
+    const Address invocation_counter(rax,
+                  MethodCounters::invocation_counter_offset() +
+                  InvocationCounter::counter_offset());
+
+    __ get_method_counters(rbx, rax, done);
 
-    if (ProfileInterpreter) { // %%% Merge this into MethodData*
-      __ incrementl(Address(rbx,Method::interpreter_invocation_counter_offset()));
+    if (ProfileInterpreter) {
+      __ incrementl(Address(rax,
+              MethodCounters::interpreter_invocation_counter_offset()));
     }
+
     // Update standard invocation counters
-    __ movl(rax, backedge_counter);               // load backedge counter
+    __ movl(rcx, invocation_counter);
+    __ incrementl(rcx, InvocationCounter::count_increment);
+    __ movl(invocation_counter, rcx);             // save invocation count
 
-    __ incrementl(rcx, InvocationCounter::count_increment);
+    __ movl(rax, backedge_counter);               // load backedge counter
     __ andl(rax, InvocationCounter::count_mask_value);  // mask out the status bits
 
-    __ movl(invocation_counter, rcx);             // save invocation count
     __ addl(rcx, rax);                            // add both counters
 
     // profile_method is non-null only for interpreted method so
@@ -399,6 +414,7 @@
     __ cmp32(rcx,
              ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
     __ jcc(Assembler::aboveEqual, *overflow);
+    __ bind(done);
   }
 }
 
@@ -868,7 +884,6 @@
   address entry_point = __ pc();
 
   const Address constMethod       (rbx, Method::const_offset());
-  const Address invocation_counter(rbx, Method::invocation_counter_offset() + InvocationCounter::counter_offset());
   const Address access_flags      (rbx, Method::access_flags_offset());
   const Address size_of_parameters(rcx, ConstMethod::size_of_parameters_offset());
 
@@ -897,9 +912,7 @@
   // NULL oop temp (mirror or jni oop result)
   __ push((int32_t)NULL_WORD);
 
-  if (inc_counter) __ movl(rcx, invocation_counter);  // (pre-)fetch invocation count
   // initialize fixed part of activation frame
-
   generate_fixed_frame(true);
 
   // make sure method is native & not abstract
@@ -1286,7 +1299,6 @@
   address entry_point = __ pc();
 
   const Address constMethod       (rbx, Method::const_offset());
-  const Address invocation_counter(rbx, Method::invocation_counter_offset() + InvocationCounter::counter_offset());
   const Address access_flags      (rbx, Method::access_flags_offset());
   const Address size_of_parameters(rdx, ConstMethod::size_of_parameters_offset());
   const Address size_of_locals    (rdx, ConstMethod::size_of_locals_offset());
@@ -1326,7 +1338,6 @@
     __ bind(exit);
   }
 
-  if (inc_counter) __ movl(rcx, invocation_counter);  // (pre-)fetch invocation count
   // initialize fixed part of activation frame
   generate_fixed_frame(false);