changeset 4464:f304ba0d4e24

inlining seems stable but deoptimizes too frequently
author Christian Haeubl <christian.haeubl@oracle.com>
date Thu, 02 Feb 2012 20:45:36 -0800
parents 6616513a42de
children df8fcff41b70
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java src/cpu/x86/vm/c1_globals_x86.hpp src/cpu/x86/vm/c2_globals_x86.hpp src/share/vm/runtime/globals.hpp
diffstat 5 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java	Thu Feb 02 19:50:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/CanonicalizerPhase.java	Thu Feb 02 20:45:36 2012 -0800
@@ -219,7 +219,7 @@
                         pred.replaceFirstSuccessor(replacedSux, next);
                         FrameState stateAfter = merge.stateAfter();
                         merge.setStateAfter(null);
-                        if (stateAfter.usages().isEmpty()) {
+                        if (stateAfter != null && stateAfter.usages().isEmpty()) {
                             stateAfter.safeDelete();
                         }
                         merge.safeDelete();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Thu Feb 02 19:50:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Thu Feb 02 20:45:36 2012 -0800
@@ -386,7 +386,7 @@
         public String toString() {
             StringBuilder builder = new StringBuilder(String.format("type-checked inlining of %d methods with %d type checks: ", concretes.size(), types.length));
             for (int i = 0; i < concretes.size(); i++) {
-                builder.append(CiUtil.format("\n        %H.%n(%p):%r", concretes.get(i)));
+                builder.append(CiUtil.format("  %H.%n(%p):%r", concretes.get(i)));
             }
             return builder.toString();
         }
@@ -514,8 +514,13 @@
                     }
                 } else {
                     if (GraalOptions.InlinePolymorphicCalls) {
-                        // TODO (ch) allow inlining only the most frequent calls (e.g. 8 different methods, inline only 2 and invoke others)
-                        // may affect peak performance negatively if immature profiling information is used
+                        if (notRecordedTypeProbability > 0) {
+                            // TODO (ch) allow inlining only the most frequent calls (e.g. 8 different methods, inline only 2 and invoke others)
+                            // may affect peak performance negatively if immature profiling information is used
+                            Debug.log("not inlining %s because not all seen types were could be recorded during profiling", methodName(callTarget.targetMethod(), invoke));
+                            return null;
+                        }
+
                         // TODO (ch) sort types by probability
 
                         // determine concrete methods and map type to specific method
@@ -534,12 +539,12 @@
 
                         double totalWeight = 0;
                         boolean canInline = true;
-                        for (RiResolvedMethod method: concreteMethods) {
-                            if (method == null || !checkTargetConditions(method)) {
+                        for (RiResolvedMethod concrete: concreteMethods) {
+                            if (concrete == null || !checkTargetConditions(concrete)) {
                                 canInline = false;
                                 break;
                             }
-                            totalWeight += callback == null ? 0 : callback.inliningWeight(parent, method, invoke);
+                            totalWeight += callback == null ? 0 : callback.inliningWeight(parent, concrete, invoke);
                         }
 
                         if (canInline) {
--- a/src/cpu/x86/vm/c1_globals_x86.hpp	Thu Feb 02 19:50:18 2012 -0800
+++ b/src/cpu/x86/vm/c1_globals_x86.hpp	Thu Feb 02 20:45:36 2012 -0800
@@ -57,7 +57,7 @@
 define_pd_global(uint64_t,MaxRAM,                    1ULL*G);
 define_pd_global(bool, CICompileOSR,                 true );
 #endif // !TIERED
-define_pd_global(bool, UseTypeProfile,               true );    // changed for GRAAL
+define_pd_global(intx, TypeProfileWidth,             8    );    // changed for GRAAL
 define_pd_global(bool, RoundFPResults,               true );
 
 define_pd_global(bool, LIRFillDelaySlots,            false);
--- a/src/cpu/x86/vm/c2_globals_x86.hpp	Thu Feb 02 19:50:18 2012 -0800
+++ b/src/cpu/x86/vm/c2_globals_x86.hpp	Thu Feb 02 20:45:36 2012 -0800
@@ -39,6 +39,7 @@
 define_pd_global(bool, PreferInterpreterNativeStubs, false);
 define_pd_global(bool, ProfileTraps,                 true);
 define_pd_global(bool, UseOnStackReplacement,        true);
+define_pd_global(intx, TypeProfileWidth,             2   );
 #ifdef CC_INTERP
 define_pd_global(bool, ProfileInterpreter,           false);
 #else
--- a/src/share/vm/runtime/globals.hpp	Thu Feb 02 19:50:18 2012 -0800
+++ b/src/share/vm/runtime/globals.hpp	Thu Feb 02 20:45:36 2012 -0800
@@ -3124,7 +3124,7 @@
           "if non-zero, start verifying C heap after Nth call to "          \
           "malloc/realloc/free")                                            \
                                                                             \
-  product(intx, TypeProfileWidth,     2,                                   \
+  product_pd(intx, TypeProfileWidth,                                        \
           "number of receiver types to record in call/cast profile")        \
                                                                             \
   develop(intx, BciProfileWidth,      2,                                    \