changeset 4558:3706975946e4

Make graph dumping a bit more robust when there is no method, enable debug in the startCompiler method, add context and scope for snippets installation Made IGV display graphs even if some edges are problematic When schedule failed don't use it
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 10 Feb 2012 02:22:23 +0100
parents c106c5e4f621
children 723df37192d6
files graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java
diffstat 6 files changed, 71 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Fri Feb 10 02:22:23 2012 +0100
@@ -567,11 +567,15 @@
      * @return
      */
     public static StringBuilder appendLocation(StringBuilder sb, RiResolvedMethod method, int bci) {
-        StackTraceElement ste = method.toStackTraceElement(bci);
-        if (ste.getFileName() != null && ste.getLineNumber() > 0) {
-            sb.append(ste);
+        if (method != null) {
+            StackTraceElement ste = method.toStackTraceElement(bci);
+            if (ste.getFileName() != null && ste.getLineNumber() > 0) {
+                sb.append(ste);
+            } else {
+                sb.append(CiUtil.format("%H.%n(%p)", method));
+            }
         } else {
-            sb.append(CiUtil.format("%H.%n(%p)", method));
+            sb.append("Null method");
         }
         return sb.append(" [bci: ").append(bci).append(']');
     }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Feb 10 02:22:23 2012 +0100
@@ -108,15 +108,26 @@
     public void startCompiler() throws Throwable {
         // Make sure TTY is initialized here such that the correct System.out is used for TTY.
         TTY.initialize();
+        if (GraalOptions.Debug) {
+            Debug.enable();
+            HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter);
+            Debug.setConfig(hotspotDebugConfig);
+        }
 
         // Install intrinsics.
-        HotSpotRuntime runtime = (HotSpotRuntime) compiler.getCompiler().runtime;
+        final HotSpotRuntime runtime = (HotSpotRuntime) compiler.getCompiler().runtime;
         if (GraalOptions.Intrinsify) {
-            this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime);
-            GraalIntrinsics.installIntrinsics(runtime, runtime.getCompiler().getTarget(), PhasePlan.DEFAULT);
-            Snippets.install(runtime, runtime.getCompiler().getTarget(), new SystemSnippets(), PhasePlan.DEFAULT);
-            Snippets.install(runtime, runtime.getCompiler().getTarget(), new UnsafeSnippets(), PhasePlan.DEFAULT);
-            Snippets.install(runtime, runtime.getCompiler().getTarget(), new ArrayCopySnippets(), PhasePlan.DEFAULT);
+            Debug.scope("InstallSnippets", new DebugDumpScope("InstallSnippets"), new Runnable() {
+                @Override
+                public void run() {
+                    VMToCompilerImpl.this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime);
+                    GraalIntrinsics.installIntrinsics(runtime, runtime.getCompiler().getTarget(), PhasePlan.DEFAULT);
+                    Snippets.install(runtime, runtime.getCompiler().getTarget(), new SystemSnippets(), PhasePlan.DEFAULT);
+                    Snippets.install(runtime, runtime.getCompiler().getTarget(), new UnsafeSnippets(), PhasePlan.DEFAULT);
+                    Snippets.install(runtime, runtime.getCompiler().getTarget(), new ArrayCopySnippets(), PhasePlan.DEFAULT);
+                }
+            });
+
         }
 
         // Create compilation queue.
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java	Fri Feb 10 02:22:23 2012 +0100
@@ -590,7 +590,11 @@
     public Map<Object, Object> getDebugProperties() {
         Map<Object, Object> properties = super.getDebugProperties();
         properties.put("bci", bci);
-        properties.put("method", CiUtil.format("%H.%n(%p):%r", method));
+        if (method != null) {
+            properties.put("method", CiUtil.format("%H.%n(%p):%r", method));
+        } else {
+            properties.put("method", "None");
+        }
         StringBuilder str = new StringBuilder();
         for (int i = 0; i < localsSize(); i++) {
             str.append(i == 0 ? "" : ", ").append(localAt(i) == null ? "_" : localAt(i).toString(Verbosity.Id));
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java	Fri Feb 10 02:22:23 2012 +0100
@@ -94,7 +94,7 @@
                 schedule = new SchedulePhase();
                 schedule.apply((StructuredGraph) graph);
             } catch (Throwable t) {
-                // nothing to do here...
+                schedule = null;
             }
         }
 
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java	Fri Feb 10 02:22:23 2012 +0100
@@ -23,6 +23,7 @@
 package com.oracle.max.graal.snippets;
 
 import java.lang.reflect.*;
+import java.util.concurrent.*;
 
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
@@ -86,47 +87,53 @@
         }
     }
 
-    private static StructuredGraph buildSnippetGraph(RiResolvedMethod snippetRiMethod, GraalRuntime runtime, CiTarget target, BoxingMethodPool pool, PhasePlan plan) {
+    private static StructuredGraph buildSnippetGraph(final RiResolvedMethod snippetRiMethod, final GraalRuntime runtime, final CiTarget target, final BoxingMethodPool pool, final PhasePlan plan) {
+        return Debug.scope("BuildSnippetGraph", snippetRiMethod, new Callable<StructuredGraph>() {
 
-        GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault();
-        GraphBuilderPhase graphBuilder = new GraphBuilderPhase(runtime, config);
-        StructuredGraph graph = new StructuredGraph(snippetRiMethod);
-        graphBuilder.apply(graph);
+            @Override
+            public StructuredGraph call() throws Exception {
+                GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault();
+                GraphBuilderPhase graphBuilder = new GraphBuilderPhase(runtime, config);
+                StructuredGraph graph = new StructuredGraph(snippetRiMethod);
+                graphBuilder.apply(graph);
 
-        Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName());
+                Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName());
 
-        new SnippetIntrinsificationPhase(runtime, pool).apply(graph);
+                new SnippetIntrinsificationPhase(runtime, pool).apply(graph);
 
-        for (Invoke invoke : graph.getInvokes()) {
-            MethodCallTargetNode callTarget = invoke.callTarget();
-            RiResolvedMethod targetMethod = callTarget.targetMethod();
-            RiResolvedType holder = targetMethod.holder();
-            if (holder.isSubtypeOf(runtime.getType(SnippetsInterface.class))) {
-                StructuredGraph targetGraph = (StructuredGraph) targetMethod.compilerStorage().get(Graph.class);
-                if (targetGraph == null) {
-                    targetGraph = buildSnippetGraph(targetMethod, runtime, target, pool, plan);
+                for (Invoke invoke : graph.getInvokes()) {
+                    MethodCallTargetNode callTarget = invoke.callTarget();
+                    RiResolvedMethod targetMethod = callTarget.targetMethod();
+                    RiResolvedType holder = targetMethod.holder();
+                    if (holder.isSubtypeOf(runtime.getType(SnippetsInterface.class))) {
+                        StructuredGraph targetGraph = (StructuredGraph) targetMethod.compilerStorage().get(Graph.class);
+                        if (targetGraph == null) {
+                            targetGraph = buildSnippetGraph(targetMethod, runtime, target, pool, plan);
+                        }
+                        InliningUtil.inline(invoke, targetGraph, true);
+                        new CanonicalizerPhase(target, runtime, null).apply(graph);
+                    }
                 }
-                InliningUtil.inline(invoke, targetGraph, true);
-                new CanonicalizerPhase(target, runtime, null).apply(graph);
-            }
-        }
+
+                new SnippetIntrinsificationPhase(runtime, pool).apply(graph);
 
-        new SnippetIntrinsificationPhase(runtime, pool).apply(graph);
-
-        Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName());
-        new DeadCodeEliminationPhase().apply(graph);
-        new CanonicalizerPhase(target, runtime, null).apply(graph);
+                Debug.dump(graph, "%s: %s", snippetRiMethod.name(), GraphBuilderPhase.class.getSimpleName());
+                new DeadCodeEliminationPhase().apply(graph);
+                new CanonicalizerPhase(target, runtime, null).apply(graph);
 
-        // TODO (gd) remove when we have safepoint polling elimination
-        for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) {
-            end.setSafepointPolling(false);
-        }
-        new InsertStateAfterPlaceholderPhase().apply(graph);
+                // TODO (gd) remove when we have safepoint polling elimination
+                for (LoopEndNode end : graph.getNodes(LoopEndNode.class)) {
+                    end.setSafepointPolling(false);
+                }
+                new InsertStateAfterPlaceholderPhase().apply(graph);
 
-        Debug.dump(graph, "%s: Final", snippetRiMethod.name());
+                Debug.dump(graph, "%s: Final", snippetRiMethod.name());
+
+                snippetRiMethod.compilerStorage().put(Graph.class, graph);
 
-        snippetRiMethod.compilerStorage().put(Graph.class, graph);
+                return graph;
+            }
+        });
 
-        return graph;
     }
 }
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Thu Feb 09 13:50:52 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Fri Feb 10 02:22:23 2012 +0100
@@ -128,9 +128,9 @@
             int to = e.getTo();
             Figure fromFigure = figureHash.get(from);
             Figure toFigure = figureHash.get(to);
-            assert fromFigure != null && toFigure != null;
             
             if(fromFigure == null || toFigure == null) continue;
+            assert fromFigure != null && toFigure != null;
 
             int fromIndex = e.getFromIndex();
             while (fromFigure.getOutputSlots().size() <= fromIndex) {