changeset 23266:f78e658f5c43

Merge
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Wed, 06 Jan 2016 13:57:17 -0800
parents 1239452bbde2 (current diff) 75150687d044 (diff)
children 345f08efb500
files
diffstat 4 files changed, 42 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompileTheWorldTest.java	Tue Jan 05 17:06:06 2016 -0800
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompileTheWorldTest.java	Wed Jan 06 13:57:17 2016 -0800
@@ -43,7 +43,7 @@
         boolean originalSetting = ExitVMOnException.getValue();
         // Compile a couple classes in rt.jar
         HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
-        new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), CompileTheWorld.SUN_BOOT_CLASS_PATH, new Config(null), 1, 5, null, null, true).compile();
+        new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), CompileTheWorld.SUN_BOOT_CLASS_PATH, new Config("-Inline"), 1, 5, null, null, true).compile();
         assert ExitVMOnException.getValue() == originalSetting;
     }
 }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java	Tue Jan 05 17:06:06 2016 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java	Wed Jan 06 13:57:17 2016 -0800
@@ -24,6 +24,9 @@
 
 import java.util.Map;
 
+import jdk.vm.ci.code.BailoutException;
+
+import com.oracle.graal.compiler.common.util.Util;
 import com.oracle.graal.nodes.Invoke;
 import com.oracle.graal.nodes.StructuredGraph;
 import com.oracle.graal.options.Option;
@@ -40,10 +43,16 @@
 
     public static class Options {
 
-        // @formatter:off
-        @Option(help = "Unconditionally inline intrinsics", type = OptionType.Debug)
+        @Option(help = "Unconditionally inline intrinsics", type = OptionType.Debug)//
         public static final OptionValue<Boolean> AlwaysInlineIntrinsics = new OptionValue<>(false);
-        // @formatter:on
+
+        /**
+         * This is a defensive measure against known pathologies of the inliner where the breadth of
+         * the inlining call tree exploration can be wide enough to prevent inlining from completing
+         * in reasonable time.
+         */
+        @Option(help = "Per-compilation method inlining limit before bailing out (use 0 to disable)", type = OptionType.Debug)//
+        public static final OptionValue<Integer> MethodInlineBailoutLimit = new OptionValue<>(5000);
     }
 
     private final InliningPolicy inliningPolicy;
@@ -85,15 +94,21 @@
     protected void run(final StructuredGraph graph, final HighTierContext context) {
         final InliningData data = new InliningData(graph, context, maxMethodPerInlining, canonicalizer, inliningPolicy);
 
+        int count = 0;
         assert data.repOK();
+        int limit = Options.MethodInlineBailoutLimit.getValue();
         while (data.hasUnprocessedGraphs()) {
             boolean wasInlined = data.moveForward();
             assert data.repOK();
             if (wasInlined) {
-                inliningCount++;
+                count++;
+                if (limit > 0 && count == limit) {
+                    throw new BailoutException("Reached method inline limit %d%nInvocation stack:%n  %s", limit, Util.join(data.getInvocationStackTrace(), "\n  "));
+                }
             }
         }
 
+        inliningCount += count;
         assert data.inliningDepth() == 0;
         assert data.graphCount() == 0;
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Tue Jan 05 17:06:06 2016 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Wed Jan 06 13:57:17 2016 -0800
@@ -32,6 +32,7 @@
 import java.util.BitSet;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 import jdk.vm.ci.code.BailoutException;
@@ -629,6 +630,18 @@
         return result.toString();
     }
 
+    /**
+     * Gets a stack trace representing the current inlining stack represented by this object.
+     */
+    public Collection<StackTraceElement> getInvocationStackTrace() {
+        List<StackTraceElement> result = new ArrayList<>();
+        for (CallsiteHolder graph : graphQueue) {
+            result.add(graph.method().asStackTraceElement(0));
+        }
+
+        return result;
+    }
+
     private boolean contains(StructuredGraph graph) {
         assert graph != null;
         for (CallsiteHolder info : graphQueue) {
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/LazyInitializationTest.java	Tue Jan 05 17:06:06 2016 -0800
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/LazyInitializationTest.java	Wed Jan 06 13:57:17 2016 -0800
@@ -28,6 +28,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 
 import jdk.vm.ci.runtime.JVMCICompilerFactory;
@@ -80,6 +81,14 @@
     private void spawnUnitTests(String... tests) throws IOException, InterruptedException {
         ArrayList<String> args = new ArrayList<>(SubprocessUtil.getVMCommandLine());
 
+        // Remove debugger arguments
+        for (Iterator<String> i = args.iterator(); i.hasNext();) {
+            String arg = i.next();
+            if (arg.equals("-Xdebug") || arg.startsWith("-Xrunjdwp:")) {
+                i.remove();
+            }
+        }
+
         int jvmciArg = args.indexOf("-jvmci");
         if (jvmciArg >= 0) {
             args.set(jvmciArg, "-server");