diff src/cpu/x86/vm/cppInterpreter_x86.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 e961c11b85fe
children 603ca7e51354
line wrap: on
line diff
--- a/src/cpu/x86/vm/cppInterpreter_x86.cpp	Thu Apr 04 21:15:43 2013 -0700
+++ b/src/cpu/x86/vm/cppInterpreter_x86.cpp	Tue Apr 09 17:17:41 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -570,20 +570,28 @@
 // rcx: invocation counter
 //
 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
-
-  const Address invocation_counter(rbx, Method::invocation_counter_offset() + InvocationCounter::counter_offset());
-  const Address backedge_counter  (rbx, Method::backedge_counter_offset() + InvocationCounter::counter_offset());
-
-  if (ProfileInterpreter) { // %%% Merge this into MethodData*
-    __ incrementl(Address(rbx,Method::interpreter_invocation_counter_offset()));
+  Label done;
+  const Address invocation_counter(rax,
+                MethodCounters::invocation_counter_offset() +
+                InvocationCounter::counter_offset());
+  const Address backedge_counter  (rax,
+                MethodCounter::backedge_counter_offset() +
+                InvocationCounter::counter_offset());
+
+  __ get_method_counters(rbx, rax, done);
+
+  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);
   __ increment(rcx, InvocationCounter::count_increment);
+  __ movl(invocation_counter, rcx);             // save invocation count
+
+  __ 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
@@ -593,7 +601,7 @@
   __ cmp32(rcx,
            ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit));
   __ jcc(Assembler::aboveEqual, *overflow);
-
+  __ bind(done);
 }
 
 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) {
@@ -977,7 +985,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());
 
@@ -1029,8 +1036,6 @@
   }
 #endif
 
-  if (inc_counter) __ movl(rcx, invocation_counter);  // (pre-)fetch invocation count
-
   const Register unlock_thread = LP64_ONLY(r15_thread) NOT_LP64(rax);
   NOT_LP64(__ movptr(unlock_thread, STATE(_thread));) // get thread
   // Since at this point in the method invocation the exception handler