changeset 4526:0e1f15ec0e94

fixed profiling of typechecks
author Christian Haeubl <christian.haeubl@oracle.com>
date Tue, 07 Feb 2012 11:43:05 -0800
parents 00efac2934d3
children a0cca63cd366
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java src/cpu/x86/vm/interp_masm_x86_64.cpp
diffstat 4 files changed, 14 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Mon Feb 06 19:04:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Tue Feb 07 11:43:05 2012 -0800
@@ -129,7 +129,7 @@
     public static int     MatureInvocationCount              = 100;
     public static boolean GenSafepoints                      = true;
     public static boolean GenLoopSafepoints                  = true;
-    public static boolean UseInstanceOfHints                 = true;
+    public static boolean UseTypeCheckHints                  = true;
 
     public static boolean GenAssertionCode                   = ____;
     public static boolean AlignCallsForPatching              = true;
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Mon Feb 06 19:04:18 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java	Tue Feb 07 11:43:05 2012 -0800
@@ -363,7 +363,11 @@
             return createRiTypeProfile(sparseTypes, counts, totalCount, entries);
         }
 
-        protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position);
+        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
+            // checkcast/aastore/instanceof profiling in the HotSpot template-based interpreter was adjusted so that the counter
+            // is incremented to indicate the polymorphic case instead of decrementing it for failed type checks
+            return getCounterValue(data, position);
+        }
 
         private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) {
             RiResolvedType[] types;
@@ -410,12 +414,6 @@
         public int getExecutionCount(HotSpotMethodData data, int position) {
             return -1;
         }
-
-        @Override
-        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
-            // TODO (ch) if types do not fit, profiling is skipped for typechecks
-            return 0;
-        }
     }
 
     private static class VirtualCallData extends AbstractTypeData {
@@ -437,11 +435,6 @@
             total += getCounterValue(data, position);
             return truncateLongToInt(total);
         }
-
-        @Override
-        protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
-            return getCounterValue(data, position);
-        }
     }
 
     private static class RetData extends CounterData {
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Mon Feb 06 19:04:18 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Tue Feb 07 11:43:05 2012 -0800
@@ -691,7 +691,7 @@
     private static final RiResolvedType[] EMPTY_TYPE_ARRAY = new RiResolvedType[0];
 
     private RiResolvedType[] getTypeCheckHints(RiResolvedType type, int maxHints) {
-        if (!GraalOptions.UseInstanceOfHints || Util.isFinalClass(type)) {
+        if (!GraalOptions.UseTypeCheckHints || Util.isFinalClass(type)) {
             return new RiResolvedType[] {type};
         } else {
             RiResolvedType uniqueSubtype = type.uniqueConcreteSubtype();
--- a/src/cpu/x86/vm/interp_masm_x86_64.cpp	Mon Feb 06 19:04:18 2012 -0800
+++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp	Tue Feb 07 11:43:05 2012 -0800
@@ -1126,8 +1126,11 @@
                                         Register receiver, Register mdp,
                                         Register reg2, int start_row,
                                         Label& done, bool is_virtual_call) {
+  // change for GRAAL (use counter to indicate polymorphic case instead of failed typechecks)
+  bool use_counter_for_polymorphic_case = is_virtual_call || UseGraal;
+
   if (TypeProfileWidth == 0) {
-    if (is_virtual_call) {
+    if (use_counter_for_polymorphic_case) {
       increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset()));
     }
     return;
@@ -1164,7 +1167,7 @@
       testptr(reg2, reg2);
       if (start_row == last_row) {
         // The only thing left to do is handle the null case.
-        if (is_virtual_call) {
+        if (use_counter_for_polymorphic_case) {
           jccb(Assembler::zero, found_null);
           // Receiver did not match any saved receiver and there is no empty row for it.
           // Increment total counter to indicate polymorphic case.
@@ -1297,7 +1300,8 @@
 
 
 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) {
-  if (ProfileInterpreter && TypeProfileCasts) {
+  // changed for GRAAL (use counter to indicate polymorphism instead of failed typechecks)
+  if (ProfileInterpreter && TypeProfileCasts && !UseGraal) {
     Label profile_continue;
 
     // If no method data exists, go to profile_continue.