changeset 5022:cbedef8b4d15

Merge
author Christian Haeubl <christian.haeubl@oracle.com>
date Sun, 04 Mar 2012 18:56:25 -0800
parents a7c079d5dc87 (diff) 0b781cdb0cfb (current diff)
children db072eec897e 8e6db1a5c537
files
diffstat 9 files changed, 66 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Fri Mar 02 09:23:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Sun Mar 04 18:56:25 2012 -0800
@@ -64,7 +64,8 @@
     // DynamicSizeBasedInliningPolicy (3)
     public static int     MaximumInlineSize                  = 35;
     // GreedySizeBasedInlining (4)
-    public static int     MaximumGreedyInlineSize            = 200;
+    public static int     MaximumGreedyInlineSize            = 100;
+    public static int     InliningBonusPerTransferredValue   = 10;
     // Common options for inlining policies 1 to 4
     public static float   NestedInliningSizeRatio            = 1f;
     public static float   BoostInliningForEscapeAnalysis     = 2f;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Fri Mar 02 09:23:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Sun Mar 04 18:56:25 2012 -0800
@@ -85,32 +85,31 @@
 
         while (!inlineCandidates.isEmpty() && graph.getNodeCount() < GraalOptions.MaximumDesiredSize) {
             InlineInfo info = inlineCandidates.remove();
-            if (inliningPolicy.isWorthInlining(graph, info)) {
+            if (info.invoke.node().isAlive() && inliningPolicy.isWorthInlining(graph, info)) {
                 Iterable<Node> newNodes = null;
-                if (info.invoke.node().isAlive()) {
-                    try {
-                        info.inline(graph, runtime, this);
-                        Debug.dump(graph, "after %s", info);
-                        // get the new nodes here, the canonicalizer phase will reset the mark
-                        newNodes = graph.getNewNodes();
-                        if (GraalOptions.OptCanonicalizer) {
-                            new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
-                        }
-                        if (GraalOptions.Intrinsify) {
-                            new IntrinsificationPhase(runtime).apply(graph);
-                        }
-                        metricInliningPerformed.increment();
-                    } catch (CiBailout bailout) {
-                        // TODO determine if we should really bail out of the whole compilation.
-                        throw bailout;
-                    } catch (AssertionError e) {
-                        throw new GraalInternalError(e).addContext(info.toString());
-                    } catch (RuntimeException e) {
-                        throw new GraalInternalError(e).addContext(info.toString());
-                    } catch (GraalInternalError e) {
-                        throw e.addContext(info.toString());
+                try {
+                    info.inline(graph, runtime, this);
+                    Debug.dump(graph, "after %s", info);
+                    // get the new nodes here, the canonicalizer phase will reset the mark
+                    newNodes = graph.getNewNodes();
+                    if (GraalOptions.OptCanonicalizer) {
+                        new CanonicalizerPhase(target, runtime, true, assumptions).apply(graph);
+                    }
+                    if (GraalOptions.Intrinsify) {
+                        new IntrinsificationPhase(runtime).apply(graph);
                     }
+                    metricInliningPerformed.increment();
+                } catch (CiBailout bailout) {
+                    // TODO determine if we should really bail out of the whole compilation.
+                    throw bailout;
+                } catch (AssertionError e) {
+                    throw new GraalInternalError(e).addContext(info.toString());
+                } catch (RuntimeException e) {
+                    throw new GraalInternalError(e).addContext(info.toString());
+                } catch (GraalInternalError e) {
+                    throw e.addContext(info.toString());
                 }
+
                 if (newNodes != null && info.level < GraalOptions.MaximumInlineLevel) {
                     scanInvokes(newNodes, info.level + 1, graph);
                 }
@@ -290,10 +289,10 @@
             maxSize = Math.max(GraalOptions.MaximumTrivialSize, maxSize);
 
             if (info.weight <= maxSize) {
-                Debug.log("inlining (size %f): %s", info.weight, info);
+                Debug.log("inlining (size %f <= %f): %s", info.weight, maxSize, info);
                 return true;
             } else {
-                Debug.log("not inlining (too large %f): %s", info.weight, info);
+                Debug.log("not inlining (too large %f > %f): %s", info.weight, maxSize, info);
                 return false;
             }
         }
@@ -314,10 +313,10 @@
             maxSize = Math.min(GraalOptions.MaximumGreedyInlineSize, Math.max(GraalOptions.MaximumTrivialSize, maxSize));
 
             if (info.weight <= maxSize) {
-                Debug.log("inlining (size %f): %s", info.weight, info);
+                Debug.log("inlining (size %f <= %f): %s", info.weight, maxSize, info);
                 return true;
             } else {
-                Debug.log("not inlining (too large %f): %s", info.weight, info);
+                Debug.log("not inlining (too large %f > %f): %s", info.weight, maxSize, info);
                 return false;
             }
         }
@@ -332,15 +331,25 @@
                 return false;
             }
 
+            double maxSize = GraalOptions.MaximumGreedyInlineSize;
+            if (GraalOptions.InliningBonusPerTransferredValue != 0) {
+                RiSignature signature = info.invoke.callTarget().targetMethod().signature();
+                int transferredValues = signature.argumentCount(true);
+                if (signature.returnKind(false) != CiKind.Void) {
+                    transferredValues++;
+                }
+                maxSize += transferredValues * GraalOptions.InliningBonusPerTransferredValue;
+            }
+
             double inlineRatio = Math.min(GraalOptions.ProbabilityCapForInlining, info.invoke.probability());
-            double maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * GraalOptions.MaximumGreedyInlineSize * inlineRatio;
+            maxSize = Math.pow(GraalOptions.NestedInliningSizeRatio, info.level) * maxSize * inlineRatio;
             maxSize = Math.max(maxSize, GraalOptions.MaximumTrivialSize);
 
             if (info.weight <= maxSize) {
-                Debug.log("inlining (size %f): %s", info.weight, info);
+                Debug.log("inlining (size %f <= %f): %s", info.weight, maxSize, info);
                 return true;
             } else {
-                Debug.log("not inlining (too large %f): %s", info.weight, info);
+                Debug.log("not inlining (too large %f > %f): %s", info.weight, maxSize, info);
                 return false;
             }
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Fri Mar 02 09:23:18 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Sun Mar 04 18:56:25 2012 -0800
@@ -141,7 +141,7 @@
 
         @Override
         public String toString() {
-            return "exact inlining " + CiUtil.format("%H.%n(%p):%r", concrete);
+            return "exact " + CiUtil.format("%H.%n(%p):%r", concrete);
         }
 
         @Override
@@ -187,8 +187,6 @@
             graph.addBeforeFixed(invoke.node(), guard);
             graph.addBeforeFixed(invoke.node(), anchor);
 
-            Debug.log("inlining 1 method using 1 type check");
-
             StructuredGraph calleeGraph = getGraph(concrete, callback);
             assert !IntrinsificationPhase.canIntrinsify(invoke, concrete, runtime);
             callback.recordMethodContentsAssumption(concrete);
@@ -197,7 +195,7 @@
 
         @Override
         public String toString() {
-            return "type-checked inlining " + CiUtil.format("%H.%n(%p):%r", concrete);
+            return "type-checked " + CiUtil.format("%H.%n(%p):%r", concrete);
         }
 
         @Override
@@ -251,8 +249,6 @@
             } else {
                 inlineSingleMethod(graph, runtime, callback);
             }
-
-            Debug.log("inlining %d methods with %d type checks and falling back to %s if violated", numberOfMethods, types.length, shouldFallbackToInvoke() ? "invocation" : "deoptimization");
         }
 
         private boolean shouldFallbackToInvoke() {
@@ -487,7 +483,8 @@
 
         @Override
         public String toString() {
-            StringBuilder builder = new StringBuilder(String.format("inlining %d methods with %d type checks: ", concretes.size(), types.length));
+            StringBuilder builder = new StringBuilder(shouldFallbackToInvoke() ? "megamorphic" : "polymorphic");
+            builder.append(String.format(", %d methods with %d type checks:", concretes.size(), types.length));
             for (int i = 0; i < concretes.size(); i++) {
                 builder.append(CiUtil.format("  %H.%n(%p):%r", concretes.get(i)));
             }
@@ -527,7 +524,7 @@
 
         @Override
         public String toString() {
-            return "inlining with assumption " + CiUtil.format("%H.%n(%p):%r", concrete);
+            return "assumption " + CiUtil.format("%H.%n(%p):%r", concrete);
         }
 
         @Override
@@ -661,7 +658,11 @@
                             return null;
                         }
                     } else {
-                        Debug.log("not inlining %s because GraalOptions.InlineMonomorphicCalls == false", methodName(targetMethod, invoke));
+                        if (!GraalOptions.InlinePolymorphicCalls && notRecordedTypeProbability == 0) {
+                            Debug.log("not inlining %s because GraalOptions.InlinePolymorphicCalls == false", methodName(targetMethod, invoke));
+                        } else {
+                            Debug.log("not inlining %s because GraalOptions.InlineMegamorphicCalls == false", methodName(targetMethod, invoke));
+                        }
                         return null;
                     }
                 }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompiler.java	Fri Mar 02 09:23:18 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompiler.java	Sun Mar 04 18:56:25 2012 -0800
@@ -32,7 +32,7 @@
  */
 public interface VMToCompiler {
 
-    void compileMethod(HotSpotMethodResolved method, int entryBCI, boolean blocking) throws Throwable;
+    boolean compileMethod(HotSpotMethodResolved method, int entryBCI, boolean blocking) throws Throwable;
 
     void shutdownCompiler() throws Throwable;
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Mar 02 09:23:18 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Sun Mar 04 18:56:25 2012 -0800
@@ -282,7 +282,7 @@
     }
 
     @Override
-    public void compileMethod(final HotSpotMethodResolved method, final int entryBCI, boolean blocking) throws Throwable {
+    public boolean compileMethod(final HotSpotMethodResolved method, final int entryBCI, boolean blocking) throws Throwable {
         try {
             if (Thread.currentThread() instanceof CompilerThread) {
                 if (method.holder().name().contains("java/util/concurrent")) {
@@ -290,7 +290,7 @@
                     // java.util.concurrent.BlockingQueue is used to implement the compilation worker
                     // queues. If a compiler thread triggers a compilation, then it may be blocked trying
                     // to add something to its own queue.
-                    return;
+                    return false;
                 }
             }
 
@@ -350,8 +350,9 @@
             }
         } catch (RejectedExecutionException e) {
             // The compile queue was already shut down.
-            return;
+            return false;
         }
+        return true;
     }
 
     @Override
--- a/src/share/vm/classfile/vmSymbols.hpp	Fri Mar 02 09:23:18 2012 -0800
+++ b/src/share/vm/classfile/vmSymbols.hpp	Sun Mar 04 18:56:25 2012 -0800
@@ -317,7 +317,7 @@
   template(bootstrap_name,                            "bootstrap")                                                      \
   template(shutdownCompiler_name,                     "shutdownCompiler")                                               \
   template(compileMethod_name,                        "compileMethod")                                                  \
-  template(compileMethod_signature,                   "(Lcom/oracle/max/graal/hotspot/ri/HotSpotMethodResolved;IZ)V")   \
+  template(compileMethod_signature,                   "(Lcom/oracle/max/graal/hotspot/ri/HotSpotMethodResolved;IZ)Z")   \
   template(setOption_name,                            "setOption")                                                      \
   template(setDefaultOptions_name,                    "setDefaultOptions")                                              \
   template(setOption_signature,                       "(Ljava/lang/String;)Z")                                          \
--- a/src/share/vm/graal/graalCompiler.cpp	Fri Mar 02 09:23:18 2012 -0800
+++ b/src/share/vm/graal/graalCompiler.cpp	Sun Mar 04 18:56:25 2012 -0800
@@ -120,9 +120,12 @@
   JavaThread::current()->set_env(NULL);
   JavaThread::current()->set_compiling(true);
   Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK);
-  VMToCompiler::compileMethod(hotspot_method, entry_bci, blocking);
+  jboolean success = VMToCompiler::compileMethod(hotspot_method, entry_bci, blocking);
   JavaThread::current()->set_compiling(false);
   JavaThread::current()->set_env(current_env);
+  if (success != JNI_TRUE) {
+    method->clear_queued_for_compilation();
+  }
 }
 
 // Compilation entry point for methods
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Fri Mar 02 09:23:18 2012 -0800
+++ b/src/share/vm/graal/graalVMToCompiler.cpp	Sun Mar 04 18:56:25 2012 -0800
@@ -97,10 +97,10 @@
   check_pending_exception("Error while calling setDefaultOptions");
 }
 
-void VMToCompiler::compileMethod(Handle hotspot_method, int entry_bci, jboolean blocking) {
+jboolean VMToCompiler::compileMethod(Handle hotspot_method, int entry_bci, jboolean blocking) {
   assert(!hotspot_method.is_null(), "just checking");
   Thread* THREAD = Thread::current();
-  JavaValue result(T_VOID);
+  JavaValue result(T_BOOLEAN);
   JavaCallArguments args;
   args.push_oop(instance());
   args.push_oop(hotspot_method);
@@ -108,6 +108,7 @@
   args.push_int(blocking);
   JavaCalls::call_interface(&result, vmExitsKlass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
   check_pending_exception("Error while calling compileMethod");
+  return result.get_jboolean();
 }
 
 void VMToCompiler::shutdownCompiler() {
--- a/src/share/vm/graal/graalVMToCompiler.hpp	Fri Mar 02 09:23:18 2012 -0800
+++ b/src/share/vm/graal/graalVMToCompiler.hpp	Sun Mar 04 18:56:25 2012 -0800
@@ -50,8 +50,8 @@
   // public static void HotSpotOptions.setDefaultOptions();
   static void setDefaultOptions();
 
-  // public abstract void compileMethod(long vmId, String name, int entry_bci, boolean blocking);
-  static void compileMethod(Handle hotspot_method, int entry_bci, jboolean blocking);
+  // public abstract boolean compileMethod(long vmId, String name, int entry_bci, boolean blocking);
+  static jboolean compileMethod(Handle hotspot_method, int entry_bci, jboolean blocking);
 
   // public abstract void shutdownCompiler();
   static void shutdownCompiler();