# HG changeset patch # User Lukas Stadler # Date 1310632415 -7200 # Node ID 3d66094eeda1e762dd14987c05b243fd446c6dcc # Parent 1ba9612f6d6ec6b4c1dc481caff988c8a3ffcd7d cleanup, new shell scripts for examples diff -r 1ba9612f6d6e -r 3d66094eeda1 .hgignore --- a/.hgignore Tue Jul 12 18:14:45 2011 +0200 +++ b/.hgignore Thu Jul 14 10:33:35 2011 +0200 @@ -21,6 +21,7 @@ ^diff1.txt$ ^diff2.txt$ ^examples.jar$ +^graal/com.oracle.max.graal.examples/examples.jar$ ^test.xml$ java\.hprof\.txt$ /nbproject/private/ diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Thu Jul 14 10:33:35 2011 +0200 @@ -91,6 +91,7 @@ // Ideal graph visualizer output settings public static boolean Plot = ____; + public static boolean PlotVerbose = ____; public static boolean PlotOnError = ____; public static int PrintIdealGraphLevel = 0; public static boolean PrintIdealGraphFile = ____; diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Thu Jul 14 10:33:35 2011 +0200 @@ -123,7 +123,7 @@ IdentifyBlocksPhase schedule = null; try { schedule = new IdentifyBlocksPhase(true); - schedule.apply(graph, false); + schedule.apply(graph, false, false); } catch (Throwable t) { // nothing to do here... //t.printStackTrace(); diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Thu Jul 14 10:33:35 2011 +0200 @@ -97,6 +97,8 @@ if (GraalOptions.Inline) { new InliningPhase(compilation, this, null).apply(compilation.graph); + new CanonicalizerPhase().apply(compilation.graph); + new DeadCodeEliminationPhase().apply(compilation.graph); } Graph graph = compilation.graph; diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/MergeableState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/MergeableState.java Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.compiler.graph; + +import java.util.*; + +import com.oracle.max.graal.compiler.ir.*; + +public interface MergeableState { + T clone(); + boolean merge(Merge merge, Collection withStates); + void loopBegin(LoopBegin loopBegin); + void loopEnd(LoopEnd loopEnd, T loopEndState); + void afterSplit(FixedNode node); +} diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.compiler.graph; + +import java.util.*; + +import com.oracle.max.graal.compiler.ir.*; +import com.oracle.max.graal.graph.*; + +public abstract class PostOrderNodeIterator> { + + private final NodeBitMap visitedEnds; + private final Deque nodeQueue; + private final HashMap nodeStates; + private final FixedNode start; + + protected T state; + + public PostOrderNodeIterator(FixedNode start, T initialState) { + visitedEnds = start.graph().createNodeBitMap(); + nodeQueue = new ArrayDeque(); + nodeStates = new HashMap(); + this.start = start; + this.state = initialState; + } + + public void apply() { + FixedNode current = start; + + do { + if (current instanceof Invoke) { + invoke((Invoke) current); + queueSuccessors(current); + current = nextQueuedNode(); + } else if (current instanceof LoopBegin) { + state.loopBegin((LoopBegin) current); + nodeStates.put(current, state); + state = state.clone(); + loopBegin((LoopBegin) current); + current = ((LoopBegin) current).next(); + assert current != null; + } else if (current instanceof LoopEnd) { + T loopBeginState = nodeStates.get(((LoopEnd) current).loopBegin()); + if (loopBeginState != null) { + loopBeginState.loopEnd((LoopEnd) current, state); + } + loopEnd((LoopEnd) current); + current = nextQueuedNode(); + } else if (current instanceof Merge) { + merge((Merge) current); + current = ((Merge) current).next(); + assert current != null; + } else if (current instanceof FixedNodeWithNext) { + FixedNode next = ((FixedNodeWithNext) current).next(); + node(current); + current = next; + assert current != null; + } else if (current instanceof EndNode) { + end((EndNode) current); + queueMerge((EndNode) current); + current = nextQueuedNode(); + } else if (current instanceof Deoptimize) { + deoptimize((Deoptimize) current); + current = nextQueuedNode(); + } else if (current instanceof Return) { + returnNode((Return) current); + current = nextQueuedNode(); + } else if (current instanceof Unwind) { + unwind((Unwind) current); + current = nextQueuedNode(); + } else if (current instanceof ControlSplit) { + controlSplit((ControlSplit) current); + queueSuccessors(current); + current = nextQueuedNode(); + } else { + assert false : current.shortName(); + } + } while(current != null); + } + + private void queueSuccessors(FixedNode x) { + nodeStates.put(x, state); + for (Node node : x.successors()) { + if (node != null) { + nodeQueue.addFirst((FixedNode) node); + } + } + } + + private FixedNode nextQueuedNode() { + int maxIterations = nodeQueue.size(); + while (maxIterations-- > 0) { + FixedNode node = nodeQueue.removeFirst(); + if (node instanceof Merge) { + Merge merge = (Merge) node; + state = nodeStates.get(merge.endAt(0)).clone(); + ArrayList states = new ArrayList(merge.endCount() - 1); + for (int i = 1; i < merge.endCount(); i++) { + T other = nodeStates.get(merge.endAt(i)); + assert other != null; + states.add(other); + } + boolean ready = state.merge(merge, states); + if (ready) { + return merge; + } else { + nodeQueue.addLast(merge); + } + } else { + assert node.predecessors().size() == 1; + state = nodeStates.get(node.predecessors().get(0)).clone(); + state.afterSplit(node); + return node; + } + } + return null; + } + + private void queueMerge(EndNode end) { + assert !visitedEnds.isMarked(end); + assert !nodeStates.containsKey(end); + nodeStates.put(end, state); + visitedEnds.mark(end); + Merge merge = end.merge(); + boolean endsVisited = true; + for (int i = 0; i < merge.endCount(); i++) { + if (!visitedEnds.isMarked(merge.endAt(i))) { + endsVisited = false; + break; + } + } + if (endsVisited) { + nodeQueue.add(merge); + } + } + + protected abstract void node(FixedNode node); + + protected void end(EndNode endNode) { + node(endNode); + } + + protected void merge(Merge merge) { + node(merge); + } + + protected void loopBegin(LoopBegin loopBegin) { + node(loopBegin); + } + + protected void loopEnd(LoopEnd loopEnd) { + node(loopEnd); + } + + protected void deoptimize(Deoptimize deoptimize) { + node(deoptimize); + } + + protected void controlSplit(ControlSplit controlSplit) { + node(controlSplit); + } + + protected void returnNode(Return returnNode) { + node(returnNode); + } + + protected void invoke(Invoke invoke) { + node(invoke); + } + + protected void unwind(Unwind unwind) { + node(unwind); + } +} diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/FixedNode.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/FixedNode.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/FixedNode.java Thu Jul 14 10:33:35 2011 +0200 @@ -50,7 +50,7 @@ @Override public Map getDebugProperties() { Map properties = super.getDebugProperties(); - properties.put("probability", String.format("%7.5f", probability)); + properties.put("probability", String.format(Locale.ENGLISH, "%7.5f", probability)); return properties; } diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ComputeProbabilityPhase.java Thu Jul 14 10:33:35 2011 +0200 @@ -26,10 +26,9 @@ import com.oracle.max.graal.compiler.*; import com.oracle.max.graal.compiler.debug.*; +import com.oracle.max.graal.compiler.graph.*; import com.oracle.max.graal.compiler.ir.*; import com.oracle.max.graal.compiler.observer.*; -import com.oracle.max.graal.compiler.phases.EscapeAnalysisPhase.MergeableState; -import com.oracle.max.graal.compiler.phases.EscapeAnalysisPhase.PostOrderNodeIterator; import com.oracle.max.graal.graph.*; public class ComputeProbabilityPhase extends Phase { diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java Thu Jul 14 10:33:35 2011 +0200 @@ -39,180 +39,6 @@ public class EscapeAnalysisPhase extends Phase { - public interface MergeableState { - T clone(); - boolean merge(Merge merge, Collection withStates); - void loopBegin(LoopBegin loopBegin); - void loopEnd(LoopEnd loopEnd, T loopEndState); - void afterSplit(FixedNode node); - } - - public abstract static class PostOrderNodeIterator> { - - private final NodeBitMap visitedEnds; - private final Deque nodeQueue; - private final HashMap nodeStates; - private final FixedNode start; - - protected T state; - - public PostOrderNodeIterator(FixedNode start, T initialState) { - visitedEnds = start.graph().createNodeBitMap(); - nodeQueue = new ArrayDeque(); - nodeStates = new HashMap(); - this.start = start; - this.state = initialState; - } - - public void apply() { - FixedNode current = start; - - do { - if (current instanceof Invoke) { - invoke((Invoke) current); - queueSuccessors(current); - current = nextQueuedNode(); - } else if (current instanceof LoopBegin) { - state.loopBegin((LoopBegin) current); - nodeStates.put(current, state); - state = state.clone(); - loopBegin((LoopBegin) current); - current = ((LoopBegin) current).next(); - assert current != null; - } else if (current instanceof LoopEnd) { - T loopBeginState = nodeStates.get(((LoopEnd) current).loopBegin()); - if (loopBeginState != null) { - loopBeginState.loopEnd((LoopEnd) current, state); - } - loopEnd((LoopEnd) current); - current = nextQueuedNode(); - } else if (current instanceof Merge) { - merge((Merge) current); - current = ((Merge) current).next(); - assert current != null; - } else if (current instanceof FixedNodeWithNext) { - FixedNode next = ((FixedNodeWithNext) current).next(); - node(current); - current = next; - assert current != null; - } else if (current instanceof EndNode) { - end((EndNode) current); - queueMerge((EndNode) current); - current = nextQueuedNode(); - } else if (current instanceof Deoptimize) { - deoptimize((Deoptimize) current); - current = nextQueuedNode(); - } else if (current instanceof Return) { - returnNode((Return) current); - current = nextQueuedNode(); - } else if (current instanceof Unwind) { - unwind((Unwind) current); - current = nextQueuedNode(); - } else if (current instanceof ControlSplit) { - controlSplit((ControlSplit) current); - queueSuccessors(current); - current = nextQueuedNode(); - } else { - assert false : current.shortName(); - } - } while(current != null); - } - - private void queueSuccessors(FixedNode x) { - nodeStates.put(x, state); - for (Node node : x.successors()) { - if (node != null) { - nodeQueue.addFirst((FixedNode) node); - } - } - } - - private FixedNode nextQueuedNode() { - int maxIterations = nodeQueue.size(); - while (maxIterations-- > 0) { - FixedNode node = nodeQueue.removeFirst(); - if (node instanceof Merge) { - Merge merge = (Merge) node; - state = nodeStates.get(merge.endAt(0)).clone(); - ArrayList states = new ArrayList(merge.endCount() - 1); - for (int i = 1; i < merge.endCount(); i++) { - T other = nodeStates.get(merge.endAt(i)); - assert other != null; - states.add(other); - } - boolean ready = state.merge(merge, states); - if (ready) { - return merge; - } else { - nodeQueue.addLast(merge); - } - } else { - assert node.predecessors().size() == 1; - state = nodeStates.get(node.predecessors().get(0)).clone(); - state.afterSplit(node); - return node; - } - } - return null; - } - - private void queueMerge(EndNode end) { - assert !visitedEnds.isMarked(end); - assert !nodeStates.containsKey(end); - nodeStates.put(end, state); - visitedEnds.mark(end); - Merge merge = end.merge(); - boolean endsVisited = true; - for (int i = 0; i < merge.endCount(); i++) { - if (!visitedEnds.isMarked(merge.endAt(i))) { - endsVisited = false; - break; - } - } - if (endsVisited) { - nodeQueue.add(merge); - } - } - - protected abstract void node(FixedNode node); - - protected void end(EndNode endNode) { - node(endNode); - } - - protected void merge(Merge merge) { - node(merge); - } - - protected void loopBegin(LoopBegin loopBegin) { - node(loopBegin); - } - - protected void loopEnd(LoopEnd loopEnd) { - node(loopEnd); - } - - protected void deoptimize(Deoptimize deoptimize) { - node(deoptimize); - } - - protected void controlSplit(ControlSplit controlSplit) { - node(controlSplit); - } - - protected void returnNode(Return returnNode) { - node(returnNode); - } - - protected void invoke(Invoke invoke) { - node(invoke); - } - - protected void unwind(Unwind unwind) { - node(unwind); - } - } - public static class BlockExitState implements MergeableState { public final Value[] fieldState; public final VirtualObject virtualObject; diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java Thu Jul 14 10:33:35 2011 +0200 @@ -446,10 +446,10 @@ TTY.println("Building graph for %s, locals: %d, stack: %d", methodName(method, invoke), method.maxLocals(), method.maxStackSize()); } graph = new CompilerGraph(null); - new GraphBuilderPhase(compilation, method, true).apply(graph); + new GraphBuilderPhase(compilation, method, true).apply(graph, true, false); if (GraalOptions.ProbabilityAnalysis) { - new DeadCodeEliminationPhase().apply(graph); - new ComputeProbabilityPhase().apply(graph); + new DeadCodeEliminationPhase().apply(graph, true, false); + new ComputeProbabilityPhase().apply(graph, true, false); } } diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Thu Jul 14 10:33:35 2011 +0200 @@ -34,17 +34,17 @@ private static final ThreadLocal currentPhase = new ThreadLocal(); private final boolean shouldVerify; - public Phase() { + protected Phase() { this.name = this.getClass().getSimpleName(); this.shouldVerify = true; this.detailedName = name; } - public Phase(String name) { + protected Phase(String name) { this(name, true); } - public Phase(String name, boolean shouldVerify) { + protected Phase(String name, boolean shouldVerify) { this.name = name; this.shouldVerify = shouldVerify; this.detailedName = name; @@ -55,10 +55,10 @@ } public final void apply(Graph graph) { - apply(graph, true); + apply(graph, true, true); } - public final void apply(Graph graph, boolean plotOnError) { + public final void apply(Graph graph, boolean plotOnError, boolean plot) { assert graph != null && (!shouldVerify || graph.verify()); int startDeletedNodeCount = graph.getDeletedNodeCount(); @@ -104,7 +104,7 @@ GraalMetrics.get(getName().concat(".createdNodes")).increment(createdNodeCount); } GraalCompilation compilation = GraalCompilation.compilation(); - if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class) { + if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class && (plot || GraalOptions.PlotVerbose)) { compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, "After " + detailedName, graph, true, false)); } diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningExample.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/extensions/InliningExample.java Tue Jul 12 18:14:45 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.max.graal.extensions; - - -public class InliningExample { - - public static void run() { - System.out.println(test()); - long start = System.currentTimeMillis(); - System.out.println(testFib()); - System.out.println(System.currentTimeMillis() - start); - } - - public static int testFib() { - int sum = 0; - for (int i = 0; i < 10000000; ++i) { - sum += fib(5); - } - return sum; - } - - private static int test() { - return alwaysInline(30); - } - - public static int alwaysInline(int value) { - if (value < 0) { - return neverInline(value); - } - return alwaysInline(value - 1); - } - - public static int neverInline(int value) { - return value; - } - - public static int fib(int val) { - if (val == 0 || val == 1) { - return 1; - } - return fib(val - 1) + fib(val - 2); - } -} diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/create_examples.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/create_examples.xml Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/runexample.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/runexample.sh Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,23 @@ +#!/bin/bash +if [ -z "${JDK7}" ]; then + echo "JDK7 is not defined." + exit 1; +fi +if [ -z "${MAXINE}" ]; then + echo "MAXINE is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${GRAAL}" ]; then + echo "GRAAL is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${DACAPO}" ]; then + echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." + exit 1; +fi +TEST=$1 +shift +ant -f create_examples.xml +COMMAND="${JDK7}/bin/java -client -d64 -graal -Xmx1g -esa -G:Extend -G:Plot -G:CacheGraphs -XX:+PrintCompilation -Xcomp -XX:CompileOnly=examples -XX:CompileCommand=quiet -XX:CompileCommand=exclude,*, -XX:CompileCommand=exclude,*,run -XX:CompileCommand=exclude,com.oracle.max.graal.examples.Main::main $* -jar examples.jar ${TEST}" +# echo $COMMAND +$COMMAND diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/runexample_c1.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/runexample_c1.sh Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,23 @@ +#!/bin/bash +if [ -z "${JDK7}" ]; then + echo "JDK7 is not defined." + exit 1; +fi +if [ -z "${MAXINE}" ]; then + echo "MAXINE is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${GRAAL}" ]; then + echo "GRAAL is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${DACAPO}" ]; then + echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." + exit 1; +fi +TEST=$1 +shift +ant -f create_examples.xml +COMMAND="${JDK7G}/bin/java -client -d64 -Xmx1g -esa -XX:+PrintCFGToFile -XX:+PrintCompilation -Xcomp -XX:CompileOnly=examples -XX:CompileCommand=quiet -XX:CompileCommand=exclude,*, -XX:CompileCommand=exclude,*,run -XX:CompileCommand=exclude,com.oracle.max.graal.examples.Main::main $* -jar examples.jar ${TEST}" +# echo $COMMAND +$COMMAND diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/runexample_c2.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/runexample_c2.sh Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,23 @@ +#!/bin/bash +if [ -z "${JDK7}" ]; then + echo "JDK7 is not defined." + exit 1; +fi +if [ -z "${MAXINE}" ]; then + echo "MAXINE is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${GRAAL}" ]; then + echo "GRAAL is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${DACAPO}" ]; then + echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." + exit 1; +fi +TEST=$1 +shift +ant -f create_examples.xml +COMMAND="${JDK7G}/bin/java -d64 -Xmx1g -esa -XX:+PrintCompilation -XX:PrintIdealGraphLevel=1 -Xcomp -XX:CompileOnly=examples -XX:CompileCommand=quiet -XX:CompileCommand=exclude,*, -XX:CompileCommand=exclude,*,run -XX:CompileCommand=exclude,com.oracle.max.graal.examples.Main::main $* -jar examples.jar ${TEST}" +# echo $COMMAND +$COMMAND diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/runexamplescompare.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/runexamplescompare.sh Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,29 @@ +#!/bin/bash +if [ -z "${JDK7}" ]; then + echo "JDK7 is not defined." + exit 1; +fi +if [ -z "${MAXINE}" ]; then + echo "MAXINE is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${GRAAL}" ]; then + echo "GRAAL is not defined. It must point to a maxine repository directory." + exit 1; +fi +if [ -z "${DACAPO}" ]; then + echo "DACAPO is not defined. It must point to a Dacapo benchmark directory." + exit 1; +fi +TEST=$1 +shift +ant -f create_examples.xml +COMMAND="${JDK7}/bin/java -client -d64 -graal -Xms1g -Xmx2g -esa -G:Extend -Xcomp -XX:CompileOnly=examples $* -jar examples.jar ${TEST}" +echo $COMMAND +$COMMAND +COMMAND="${JDK7}/bin/java -client -d64 -Xms1g -Xmx2g -esa -Xcomp -XX:CompileOnly=examples $* -jar examples.jar ${TEST}" +echo $COMMAND +$COMMAND +COMMAND="${JDK7}/bin/java -server -d64 -Xms1g -Xmx2g -esa -Xcomp -XX:CompileOnly=examples $* -jar examples.jar ${TEST}" +echo $COMMAND +$COMMAND diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/Main.java --- a/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/Main.java Tue Jul 12 18:14:45 2011 +0200 +++ b/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/Main.java Thu Jul 14 10:33:35 2011 +0200 @@ -26,15 +26,28 @@ import com.oracle.max.graal.examples.inlining.*; import com.oracle.max.graal.examples.intrinsics.*; import com.oracle.max.graal.examples.opt.*; - +import com.oracle.max.graal.examples.simple.*; public class Main { public static void main(String[] args) { -// InliningExample.run(); -// SafeAddExample.run(); -// OptimizationExample.run(); - DeoptExample.run(); + System.err.println("== Graal Examples =="); + if (args.length == 1) { + if (args[0].equals("simple")) { + SimpleExample.run(); + } else if (args[0].equals("inlining")) { + InliningExample.run(); + } else if (args[0].equals("safeadd")) { + SafeAddExample.run(); + } else if (args[0].equals("opt")) { + OptimizationExample.run(); + } else if (args[0].equals("deopt")) { + DeoptExample.run(); + } else { + System.out.println("unknown example: " + args[0]); + } + } else { + System.out.println("usage: java " + Main.class.getSimpleName() + " "); + } } - } diff -r 1ba9612f6d6e -r 3d66094eeda1 graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/simple/SimpleExample.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.max.graal.examples/src/com/oracle/max/graal/examples/simple/SimpleExample.java Thu Jul 14 10:33:35 2011 +0200 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.max.graal.examples.simple; + + +public class SimpleExample { + + public static void run() { + System.out.println(mulAdd(1, 2, 3)); + System.out.println(divAdd(1, 2, 3)); + } + + private static int mulAdd(int a, int b, int c) { + return a * b + c; + } + + private static int divAdd(int a, int b, int c) { + return a / b + c; + } +}