# HG changeset patch # User Gilles Duboscq # Date 1328836943 -3600 # Node ID 3706975946e4c67d31122e4fec7c3f05f220f3c3 # Parent c106c5e4f6219186707e81a61efe7fad7dabe592 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 diff -r c106c5e4f621 -r 3706975946e4 graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java --- 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(']'); } diff -r c106c5e4f621 -r 3706975946e4 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- 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. diff -r c106c5e4f621 -r 3706975946e4 graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java --- 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 getDebugProperties() { Map 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)); diff -r c106c5e4f621 -r 3706975946e4 graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/IdealGraphPrinter.java --- 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; } } diff -r c106c5e4f621 -r 3706975946e4 graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/Snippets.java --- 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() { - 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; } } diff -r c106c5e4f621 -r 3706975946e4 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java --- 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) {