changeset 6334:f8ba3bb81f6f

Renamed com.oracle.graal.tests project to com.oracle.graal.compiler.test
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 07 Sep 2012 16:25:49 +0200
parents 95077eac15af
children 897f5bb96d60 b34b2e874948
files graal/com.oracle.graal.compiler.test/overview.html graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompiledMethodTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EscapeAnalysisTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraphScheduleTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfBoxingEliminationTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InvokeTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewArrayTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewInstanceTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/TypeCheckTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java graal/com.oracle.graal.tests/overview.html graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/BoxingEliminationTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/CompareCanonicalizerTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/CompiledMethodTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/DegeneratedLoopsTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/EscapeAnalysisTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/FloatingReadTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalCompilerTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphScheduleTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/IfBoxingEliminationTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/IfCanonicalizerTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/InvokeExceptionTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/InvokeHintsTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/MonitorTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/NestedLoopTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/PhiCreationTests.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ReassociateAndCanonicalTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ScalarTypeSystemTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/StampCanonicalizerTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/StraighteningTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/TypeSystemTest.java graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/cfg/SimpleCFGTest.java mx/projects
diffstat 52 files changed, 3012 insertions(+), 3012 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/overview.html	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+
+Copyright (c) 2012, 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.  Oracle designates this
+particular file as subject to the "Classpath" exception as provided
+by Oracle in the LICENSE file that accompanied this code.
+
+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.
+-->
+
+</head>
+<body>
+
+Documentation for the <code>com.oracle.graal.tests</code> project.
+
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+
+/**
+ * In the following tests, the usages of local variable "a" are replaced with the integer constant 0. Then boxing
+ * elimination is applied and it is verified that the resulting graph is equal to the graph of the method that just has
+ * a "return 1" statement in it.
+ */
+public class BoxingEliminationTest extends GraalCompilerTest {
+
+    private static final Short s = 2;
+
+    @SuppressWarnings("all")
+    public static short referenceSnippet1() {
+        return 1;
+    }
+
+    @SuppressWarnings("all")
+    public static short referenceSnippet2() {
+        return 2;
+    }
+
+    public static Short boxedShort() {
+        return 1;
+    }
+
+    public static Object boxedObject() {
+        return (short) 1;
+    }
+
+    public static Short constantBoxedShort() {
+        return s;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet", "referenceSnippet1");
+    }
+
+    @SuppressWarnings("all")
+    public static short test1Snippet() {
+        return boxedShort();
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet", "referenceSnippet1");
+    }
+
+    @SuppressWarnings("all")
+    public static short test2Snippet() {
+        return (Short) boxedObject();
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet", "referenceSnippet1");
+    }
+
+    @SuppressWarnings("all")
+    public static short test3Snippet() {
+        short b = boxedShort();
+        if (b < 0) {
+            b = boxedShort();
+        }
+        return b;
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet", "referenceSnippet2");
+    }
+
+    @SuppressWarnings("all")
+    public static short test4Snippet() {
+        return constantBoxedShort();
+    }
+
+    private void test(final String snippet, final String referenceSnippet) {
+        Debug.scope("BoxingEliminationTest", new DebugDumpScope(snippet), new Runnable() {
+            @Override
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                BoxingMethodPool pool = new BoxingMethodPool(runtime());
+                IdentifyBoxingPhase identifyBoxingPhase = new IdentifyBoxingPhase(pool);
+                PhasePlan phasePlan = getDefaultPhasePlan();
+                phasePlan.addPhase(PhasePosition.AFTER_PARSING, identifyBoxingPhase);
+                identifyBoxingPhase.apply(graph);
+                Collection<Invoke> hints = new ArrayList<>();
+                for (Invoke invoke : graph.getInvokes()) {
+                    hints.add(invoke);
+                }
+
+                new InliningPhase(null, runtime(), hints, null, null, phasePlan, OptimisticOptimizations.ALL).apply(graph);
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                Debug.dump(graph, "Graph");
+                new BoxingEliminationPhase().apply(graph);
+                Debug.dump(graph, "Graph");
+                new ExpandBoxingNodesPhase(pool).apply(graph);
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                new DeadCodeEliminationPhase().apply(graph);
+                StructuredGraph referenceGraph = parse(referenceSnippet);
+                assertEquals(referenceGraph, graph);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2012, 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.nodes.*;
+
+public class CompareCanonicalizerTest extends GraalCompilerTest {
+
+    @Test
+    public void testCanonicalComparison() {
+        StructuredGraph referenceGraph = parse("referenceCanonicalComparison");
+        for (int i = 1; i < 4; i++) {
+            StructuredGraph graph = parse("canonicalCompare" + i);
+            assertEquals(referenceGraph, graph);
+        }
+        new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
+        for (int i = 1; i < 4; i++) {
+            StructuredGraph graph = parse("canonicalCompare" + i);
+            new CanonicalizerPhase(null, runtime(), null).apply(graph);
+            assertEquals(referenceGraph, graph);
+        }
+    }
+
+    public static int referenceCanonicalComparison(int a, int b) {
+        if (a < b) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public static int canonicalCompare1(int a, int b) {
+        if (a >= b) {
+            return 2;
+        } else {
+            return 1;
+        }
+    }
+
+    public static int canonicalCompare2(int a, int b) {
+        if (b > a) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public static int canonicalCompare3(int a, int b) {
+        if (b <= a) {
+            return 2;
+        } else {
+            return 1;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompiledMethodTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.lang.reflect.*;
+
+import org.junit.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.InstalledCode.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.java.*;
+import com.oracle.graal.nodes.*;
+
+/**
+ * In the following tests, the usages of local variable "a" are replaced with the integer constant 0. Then
+ * canonicalization is applied and it is verified that the resulting graph is equal to the graph of the method that just
+ * has a "return 1" statement in it.
+ */
+public class CompiledMethodTest extends GraalCompilerTest {
+
+    public static Object testMethod(Object arg1, Object arg2, Object arg3) {
+        return arg1 + " " + arg2 + " " + arg3;
+    }
+
+    Object f1;
+    public Object testMethodVirtual(Object arg1, Object arg2, Object arg3) {
+        return f1 + " " + arg1 + " " + arg2 + " " + arg3;
+    }
+
+    @Test
+    public void test1() {
+        Method method = getMethod("testMethod");
+        final StructuredGraph graph = parse(method);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+
+        for (Node node : graph.getNodes()) {
+            if (node instanceof ConstantNode) {
+                ConstantNode constant = (ConstantNode) node;
+                if (constant.kind() == Kind.Object && " ".equals(constant.value.asObject())) {
+                    graph.replaceFloating(constant, ConstantNode.forObject("-", runtime, graph));
+                }
+            }
+        }
+
+        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
+        InstalledCode compiledMethod = getCode(javaMethod, graph);
+        try {
+            Object result = compiledMethod.execute("1", "2", "3");
+            Assert.assertEquals("1-2-3", result);
+        } catch (MethodInvalidatedException t) {
+            Assert.fail("method invalidated");
+        }
+    }
+
+    @Test
+    public void test3() {
+        Method method = getMethod("testMethod");
+        final StructuredGraph graph = parse(method);
+        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
+        InstalledCode compiledMethod = getCode(javaMethod, graph);
+        try {
+            Object result = compiledMethod.executeVarargs("1", "2", "3");
+            Assert.assertEquals("1 2 3", result);
+        } catch (MethodInvalidatedException t) {
+            Assert.fail("method invalidated");
+        }
+    }
+
+    @Test
+    public void test4() {
+        Method method = getMethod("testMethodVirtual");
+        final StructuredGraph graph = parse(method);
+        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
+        InstalledCode compiledMethod = getCode(javaMethod, graph);
+        try {
+            f1 = "0";
+            Object result = compiledMethod.executeVarargs(this, "1", "2", "3");
+            Assert.assertEquals("0 1 2 3", result);
+        } catch (MethodInvalidatedException t) {
+            Assert.fail("method invalidated");
+        }
+    }
+
+    @Test
+    public void test2() throws NoSuchMethodException, SecurityException {
+        Method method = CompilableObjectImpl.class.getDeclaredMethod("executeHelper", ObjectCompiler.class, String.class);
+        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
+        StructuredGraph graph = new StructuredGraph(javaMethod);
+        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph);
+        new CanonicalizerPhase(null, runtime, null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+
+        for (Node node : graph.getNodes()) {
+            if (node instanceof ConstantNode) {
+                ConstantNode constant = (ConstantNode) node;
+                if (constant.kind() == Kind.Object && "1 ".equals(constant.value.asObject())) {
+                    graph.replaceFloating(constant, ConstantNode.forObject("1-", runtime, graph));
+                }
+            }
+        }
+
+        InstalledCode compiledMethod = getCode(javaMethod, graph);
+        final CompilableObject compilableObject = new CompilableObjectImpl(0);
+
+        Object result;
+        result = compilableObject.execute(new ObjectCompilerImpl(compiledMethod), "3");
+        Assert.assertEquals("1-3", result);
+    }
+
+    public abstract class CompilableObject {
+
+        private CompiledObject compiledObject;
+        private final int compileThreshold;
+        private int counter;
+
+        public CompilableObject(int compileThreshold) {
+            this.compileThreshold = compileThreshold;
+        }
+
+        public final Object execute(ObjectCompiler compiler, String args) {
+            if (counter++ < compileThreshold || compiler == null) {
+                return executeHelper(compiler, args);
+            } else {
+                compiledObject = compiler.compile(this);
+                return compiledObject.execute(compiler, args);
+            }
+        }
+
+        protected abstract Object executeHelper(ObjectCompiler context, String args);
+    }
+
+    private final class CompilableObjectImpl extends CompilableObject {
+
+        private CompilableObjectImpl(int compileThreshold) {
+            super(compileThreshold);
+        }
+
+        @Override
+        protected Object executeHelper(ObjectCompiler compiler, String args) {
+            return "1 " + args;
+        }
+    }
+
+    public interface CompiledObject {
+        Object execute(ObjectCompiler context, String args);
+    }
+
+    public interface ObjectCompiler {
+        CompiledObject compile(CompilableObject node);
+    }
+
+    private final class ObjectCompilerImpl implements ObjectCompiler {
+
+        private final InstalledCode compiledMethod;
+
+        private ObjectCompilerImpl(InstalledCode compiledMethod) {
+            this.compiledMethod = compiledMethod;
+        }
+
+        @Override
+        public CompiledObject compile(final CompilableObject node) {
+            return new CompiledObject() {
+                @Override
+                public Object execute(ObjectCompiler compiler, String args) {
+                    return compiledMethod.execute(node, compiler, args);
+                }
+            };
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, 2012, 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.graal.compiler.test;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.calc.*;
+
+
+public class ConditionTest {
+
+    @Test
+    public void testImplies() {
+        Random rand = new Random(13);
+        for (Condition c1 : Condition.values()) {
+            for (Condition c2 : Condition.values()) {
+                boolean implies = c1.implies(c2);
+                if (implies) {
+                    for (int i = 0; i < 1000; i++) {
+                        Constant a = Constant.forInt(rand.nextInt());
+                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
+                        boolean result1 = c1.foldCondition(a, b, null, false);
+                        boolean result2 = c2.foldCondition(a, b, null, false);
+                        if (result1 && implies) {
+                            assertTrue(result2);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testJoin() {
+        Random rand = new Random(13);
+        for (Condition c1 : Condition.values()) {
+            for (Condition c2 : Condition.values()) {
+                Condition join = c1.join(c2);
+                assertTrue(join == c2.join(c1));
+                if (join != null) {
+                    for (int i = 0; i < 1000; i++) {
+                        Constant a = Constant.forInt(rand.nextInt());
+                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
+                        boolean result1 = c1.foldCondition(a, b, null, false);
+                        boolean result2 = c2.foldCondition(a, b, null, false);
+                        boolean resultJoin = join.foldCondition(a, b, null, false);
+                        if (result1 && result2) {
+                            assertTrue(resultJoin);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testMeet() {
+        Random rand = new Random(13);
+        for (Condition c1 : Condition.values()) {
+            for (Condition c2 : Condition.values()) {
+                Condition meet = c1.meet(c2);
+                assertTrue(meet == c2.meet(c1));
+                if (meet != null) {
+                    for (int i = 0; i < 1000; i++) {
+                        Constant a = Constant.forInt(rand.nextInt());
+                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
+                        boolean result1 = c1.foldCondition(a, b, null, false);
+                        boolean result2 = c2.foldCondition(a, b, null, false);
+                        boolean resultMeet = meet.foldCondition(a, b, null, false);
+                        if (result1 || result2) {
+                            assertTrue(resultMeet);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+
+/**
+ * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
+ * Then canonicalization is applied and it is verified that the resulting graph is equal to the
+ * graph of the method that just has a "return 1" statement in it.
+ */
+public class DegeneratedLoopsTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "referenceSnippet";
+
+    @SuppressWarnings("all")
+    public static int referenceSnippet(int a) {
+        return a;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    private static class UnresolvedException extends RuntimeException {
+        private static final long serialVersionUID = 5215434338750728440L;
+
+        static {
+            if (true) {
+                throw new UnsupportedOperationException("this class may never be initialized");
+            }
+        }
+    }
+
+    @SuppressWarnings("all")
+    public static int test1Snippet(int a) {
+        for (;;) {
+            try {
+                test();
+                break;
+            } catch (UnresolvedException e) {
+            }
+        }
+        return a;
+    }
+
+    private static void test() {
+
+    }
+
+    private void test(final String snippet) {
+        Debug.scope("DegeneratedLoopsTest", new DebugDumpScope(snippet), new Runnable() {
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                Debug.dump(graph, "Graph");
+                for (Invoke invoke : graph.getInvokes()) {
+                    invoke.intrinsify(null);
+                }
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+                Debug.dump(referenceGraph, "Graph");
+                assertEquals(referenceGraph, graph);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EscapeAnalysisTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+/**
+ * In these test cases the probability of all invokes is set to a high value, such that an InliningPhase should inline them all.
+ * After that, the EscapeAnalysisPhase is expected to remove all allocations and return the correct values.
+ */
+public class EscapeAnalysisTest extends GraalCompilerTest {
+
+    @Test
+    public void test1() {
+        test("test1Snippet", Constant.forInt(101));
+    }
+
+    @SuppressWarnings("all")
+    public static int test1Snippet(int a) {
+        Integer x = new Integer(101);
+        return x.intValue();
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet", Constant.forInt(0));
+    }
+
+    @SuppressWarnings("all")
+    public static int test2Snippet(int a) {
+        Integer[] x = new Integer[0];
+        return x.length;
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet", Constant.forObject(null));
+    }
+
+    @SuppressWarnings("all")
+    public static Object test3Snippet(int a) {
+        Integer[] x = new Integer[1];
+        return x[0];
+    }
+
+    @Test
+    public void testMonitor() {
+        test("testMonitorSnippet", Constant.forInt(0));
+    }
+
+    private static native void notInlineable();
+
+    @SuppressWarnings("all")
+    public static int testMonitorSnippet(int a) {
+        Integer x = new Integer(0);
+        Integer[] y = new Integer[0];
+        Integer[] z = new Integer[1];
+        synchronized (x) {
+            synchronized (y) {
+                synchronized (z) {
+                    notInlineable();
+                }
+            }
+        }
+        return x.intValue();
+    }
+
+    public void testMonitor2() {
+        test("testMonitor2Snippet", Constant.forInt(0));
+    }
+
+    /**
+     * This test case differs from the last one in that it requires inlining within a synchronized region.
+     */
+    @SuppressWarnings("all")
+    public static int testMonitor2Snippet(int a) {
+        Integer x = new Integer(0);
+        Integer[] y = new Integer[0];
+        Integer[] z = new Integer[1];
+        synchronized (x) {
+            synchronized (y) {
+                synchronized (z) {
+                    notInlineable();
+                    return x.intValue();
+                }
+            }
+        }
+    }
+
+    private void test(final String snippet, final Constant expectedResult) {
+        Debug.scope("EscapeAnalysisTest", new DebugDumpScope(snippet), new Runnable() {
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                for (Invoke n : graph.getInvokes()) {
+                    n.node().setProbability(100000);
+                }
+
+                new InliningPhase(null, runtime(), null, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
+                new DeadCodeEliminationPhase().apply(graph);
+                Debug.dump(graph, "Graph");
+                new EscapeAnalysisPhase(null, runtime(), null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
+                Debug.dump(graph, "Graph");
+                int retCount = 0;
+                for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
+                    Assert.assertTrue(ret.result().isConstant());
+                    Assert.assertEquals(ret.result().asConstant(), expectedResult);
+                    retCount++;
+                }
+                Assert.assertEquals(1, retCount);
+                int newInstanceCount = 0;
+                for (@SuppressWarnings("unused") NewInstanceNode n : graph.getNodes(NewInstanceNode.class)) {
+                    newInstanceCount++;
+                }
+                for (@SuppressWarnings("unused") NewObjectArrayNode n : graph.getNodes(NewObjectArrayNode.class)) {
+                    newInstanceCount++;
+                }
+                Assert.assertEquals(0, newInstanceCount);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.java.*;
+
+public class FloatingReadTest extends GraphScheduleTest {
+
+    public static class Container {
+        public int a;
+    }
+
+    public static void changeField(Container c) {
+        c.a = 0xcafebabe;
+    }
+
+    public static synchronized int test1Snippet() {
+        Container c = new Container();
+        return c.a;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    private void test(final String snippet) {
+        Debug.scope("FloatingReadTest", new DebugDumpScope(snippet), new Runnable() {
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                new LoweringPhase(runtime(), null).apply(graph);
+                new FloatingReadPhase().apply(graph);
+
+                ReturnNode returnNode = null;
+                MonitorExitNode monitor = null;
+
+                for (Node n : graph.getNodes()) {
+                    if (n instanceof ReturnNode) {
+                        returnNode = (ReturnNode) n;
+                    } else if (n instanceof MonitorExitNode) {
+                        monitor = (MonitorExitNode) n;
+                    }
+                }
+
+                Assert.assertNotNull(returnNode);
+                Assert.assertNotNull(monitor);
+                Assert.assertTrue(returnNode.result() instanceof FloatingReadNode);
+
+                FloatingReadNode read = (FloatingReadNode) returnNode.result();
+
+                assertOrderedAfterSchedule(graph, read, monitor);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import junit.framework.*;
+
+import com.oracle.graal.api.*;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
+import com.oracle.graal.compiler.schedule.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.Node.Verbosity;
+import com.oracle.graal.java.*;
+import com.oracle.graal.lir.cfg.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+
+/**
+ * Base class for Graal compiler unit tests. These are white box tests
+ * for Graal compiler transformations. The general pattern for a test is:
+ * <ol>
+ * <li>Create a graph by {@linkplain #parse(String) parsing} a method.</li>
+ * <li>Manually modify the graph (e.g. replace a parameter node with a constant).</li>
+ * <li>Apply a transformation to the graph.</li>
+ * <li>Assert that the transformed graph is equal to an expected graph.</li>
+ * </ol>
+ * <p>
+ * See {@link InvokeHintsTest} as an example.
+ * <p>
+ * The tests can be run in Eclipse with the "Compiler Unit Test" Eclipse
+ * launch configuration found in the top level of this project or by
+ * running {@code mx unittest} on the command line.
+ */
+public abstract class GraalCompilerTest {
+
+    protected final GraalCodeCacheProvider runtime;
+    protected final GraalCompiler graalCompiler;
+
+    public GraalCompilerTest() {
+        Debug.enable();
+        this.runtime = Graal.getRequiredCapability(GraalCodeCacheProvider.class);
+        this.graalCompiler = Graal.getRequiredCapability(GraalCompiler.class);
+    }
+
+    protected void assertEquals(StructuredGraph expected, StructuredGraph graph) {
+        String expectedString = getCanonicalGraphString(expected);
+        String actualString = getCanonicalGraphString(graph);
+        String mismatchString = "mismatch in graphs:\n========= expected =========\n" + expectedString + "\n\n========= actual =========\n" + actualString;
+
+        if (expected.getNodeCount() != graph.getNodeCount()) {
+            Debug.dump(expected, "Node count not matching - expected");
+            Debug.dump(graph, "Node count not matching - actual");
+            Assert.fail("Graphs do not have the same number of nodes: " + expected.getNodeCount() + " vs. " + graph.getNodeCount() + "\n" + mismatchString);
+        }
+        if (!expectedString.equals(actualString)) {
+            Debug.dump(expected, "mismatching graphs - expected");
+            Debug.dump(graph, "mismatching graphs - actual");
+            Assert.fail(mismatchString);
+        }
+    }
+
+    protected void assertConstantReturn(StructuredGraph graph, int value) {
+        String graphString = getCanonicalGraphString(graph);
+        Assert.assertEquals("unexpected number of ReturnNodes: " + graphString, graph.getNodes(ReturnNode.class).count(), 1);
+        ValueNode result = graph.getNodes(ReturnNode.class).first().result();
+        Assert.assertTrue("unexpected ReturnNode result node: " + graphString, result.isConstant());
+        Assert.assertEquals("unexpected ReturnNode result kind: " + graphString, result.asConstant().getKind(), Kind.Int);
+        Assert.assertEquals("unexpected ReturnNode result: " + graphString, result.asConstant().asInt(), value);
+    }
+
+    protected static String getCanonicalGraphString(StructuredGraph graph) {
+        SchedulePhase schedule = new SchedulePhase();
+        schedule.apply(graph);
+
+        NodeMap<Integer> canonicalId = graph.createNodeMap();
+        int nextId = 0;
+
+        StringBuilder result = new StringBuilder();
+        for (Block block : schedule.getCFG().getBlocks()) {
+            result.append("Block " + block + " ");
+            if (block == schedule.getCFG().getStartBlock()) {
+                result.append("* ");
+            }
+            result.append("-> ");
+            for (Block succ : block.getSuccessors()) {
+                result.append(succ + " ");
+            }
+            result.append("\n");
+            for (Node node : schedule.getBlockToNodesMap().get(block)) {
+                int id;
+                if (canonicalId.get(node) != null) {
+                    id = canonicalId.get(node);
+                } else {
+                    id = nextId++;
+                    canonicalId.set(node, id);
+                }
+                String name = node instanceof ConstantNode ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
+                result.append("  " + id + "|" + name + "    (" + node.usages().size() + ")\n");
+            }
+        }
+        return result.toString();
+    }
+
+    protected GraalCodeCacheProvider runtime() {
+        return runtime;
+    }
+
+    /**
+     * Parses a Java method to produce a graph.
+     *
+     * @param methodName the name of the method in {@code this.getClass()} to be parsed
+     */
+    protected StructuredGraph parse(String methodName) {
+        return parse(getMethod(methodName));
+    }
+
+    protected Method getMethod(String methodName) {
+        Method found = null;
+        for (Method m : this.getClass().getMethods()) {
+            if (m.getName().equals(methodName)) {
+                Assert.assertNull(found);
+                found = m;
+            }
+        }
+        if (found != null) {
+            return found;
+        } else {
+            throw new RuntimeException("method not found: " + methodName);
+        }
+    }
+
+    private static int compilationId = 0;
+
+    protected void assertEquals(Object expected, Object actual) {
+        Assert.assertEquals(expected, actual);
+    }
+
+    protected void test(String name, Object... args) {
+        Method method = getMethod(name);
+        Object expect = null;
+        Throwable exception = null;
+        try {
+            // This gives us both the expected return value as well as ensuring that the method to be compiled is fully resolved
+            expect = method.invoke(null, args);
+        } catch (InvocationTargetException e) {
+            exception = e.getTargetException();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        InstalledCode compiledMethod = getCode(runtime.getResolvedJavaMethod(method), parse(method));
+
+        if (exception != null) {
+            try {
+                compiledMethod.executeVarargs(args);
+                Assert.fail("expected " + exception);
+            } catch (Throwable e) {
+                Assert.assertEquals(exception.getClass(), e.getClass());
+            }
+        } else {
+            Object actual = compiledMethod.executeVarargs(args);
+            assertEquals(expect, actual);
+        }
+    }
+
+    private Map<ResolvedJavaMethod, InstalledCode> cache = new HashMap<>();
+
+    /**
+     * Gets installed code for a given method and graph, compiling it first if necessary.
+     */
+    protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph) {
+        return getCode(method, graph, false);
+    }
+
+    /**
+     * Can be overridden to modify the compilation phases applied for a test.
+     *
+     * @param method the method being compiled
+     * @param graph the graph being compiled
+     * @param phasePlan the phase plan to be edited
+     */
+    protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) {
+    }
+
+    /**
+     * Gets installed code for a given method and graph, compiling it first if necessary.
+     *
+     * @param forceCompile specifies whether to ignore any previous code cached for the (method, key) pair
+     */
+    protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph, boolean forceCompile) {
+        if (!forceCompile) {
+            InstalledCode cached = cache.get(method);
+            if (cached != null && cached.isValid()) {
+                return cached;
+            }
+        }
+        InstalledCode installedCode = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable<InstalledCode>() {
+            public InstalledCode call() throws Exception {
+                PhasePlan phasePlan = new PhasePlan();
+                GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
+                phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
+                editPhasePlan(method, graph, phasePlan);
+                CompilationResult compResult = graalCompiler.compileMethod(method, graph, -1, null, phasePlan, OptimisticOptimizations.ALL);
+                return addMethod(method, compResult);
+            }
+        });
+        cache.put(method, installedCode);
+        return installedCode;
+    }
+
+    protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) {
+        assert graalCompiler != null;
+        return Debug.scope("CodeInstall", new Object[] {graalCompiler, method}, new Callable<InstalledCode>() {
+            @Override
+            public InstalledCode call() throws Exception {
+                final CodeInfo[] info = Debug.isDumpEnabled() ? new CodeInfo[1] : null;
+                InstalledCode installedMethod = runtime.addMethod(method, compResult, info);
+                if (info != null) {
+                    Debug.dump(new Object[] {compResult, info[0]}, "After code installation");
+                }
+                return installedMethod;
+            }
+        });
+    }
+
+    /**
+     * Parses a Java method to produce a graph.
+     *
+     * @param methodName the name of the method in {@code this.getClass()} to be parsed
+     */
+    protected StructuredGraph parseProfiled(String methodName) {
+        return parseProfiled(getMethod(methodName));
+    }
+
+    /**
+     * Parses a Java method to produce a graph.
+     */
+    protected StructuredGraph parse(Method m) {
+        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(m);
+        StructuredGraph graph = new StructuredGraph(javaMethod);
+        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL).apply(graph);
+        return graph;
+    }
+
+    /**
+     * Parses a Java method to produce a graph.
+     */
+    protected StructuredGraph parseProfiled(Method m) {
+        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(m);
+        StructuredGraph graph = new StructuredGraph(javaMethod);
+        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL).apply(graph);
+        return graph;
+    }
+
+    protected PhasePlan getDefaultPhasePlan() {
+        PhasePlan plan = new PhasePlan();
+        plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL));
+        return plan;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraphScheduleTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.schedule.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.cfg.*;
+import com.oracle.graal.nodes.*;
+
+public class GraphScheduleTest extends GraalCompilerTest {
+    protected void assertOrderedAfterSchedule(StructuredGraph graph, Node a, Node b) {
+        SchedulePhase ibp = new SchedulePhase();
+        ibp.apply(graph);
+        NodeMap<Block> nodeToBlock = ibp.getCFG().getNodeToBlock();
+        Block bBlock = nodeToBlock.get(b);
+        Block aBlock = nodeToBlock.get(a);
+
+        if (bBlock == aBlock) {
+            List<ScheduledNode> instructions = ibp.nodesFor(bBlock);
+            Assert.assertTrue(instructions.indexOf(b) > instructions.indexOf(a));
+        } else {
+            Block block = bBlock;
+            while (block != null) {
+                if (block == aBlock) {
+                    break;
+                }
+                block = block.getDominator();
+            }
+            Assert.assertSame(block, aBlock);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfBoxingEliminationTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+
+public class IfBoxingEliminationTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "referenceSnippet";
+
+    public static int referenceSnippet(int a) {
+        int result;
+        if (a < 0) {
+            result = 1;
+        } else {
+            result = 2;
+        }
+        return result;
+    }
+
+    public static Integer boxedInteger() {
+        return 1;
+    }
+
+    public static Object boxedObject() {
+        return 2;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    public static int test1Snippet(int a) {
+        Integer result;
+        if (a < 0) {
+            result = boxedInteger();
+        } else {
+            result = (Integer) boxedObject();
+        }
+        return result;
+    }
+
+    private void test(final String snippet) {
+        Debug.scope("IfBoxingEliminationTest", new DebugDumpScope(snippet), new Runnable() {
+            @Override
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                BoxingMethodPool pool = new BoxingMethodPool(runtime());
+                IdentifyBoxingPhase identifyBoxingPhase = new IdentifyBoxingPhase(pool);
+                PhasePlan phasePlan = getDefaultPhasePlan();
+                phasePlan.addPhase(PhasePosition.AFTER_PARSING, identifyBoxingPhase);
+                phasePlan.addPhase(PhasePosition.AFTER_PARSING, new PhiStampPhase());
+                identifyBoxingPhase.apply(graph);
+                Collection<Invoke> hints = new ArrayList<>();
+                for (Invoke invoke : graph.getInvokes()) {
+                    hints.add(invoke);
+                }
+                new InliningPhase(null, runtime(), hints, null, null, phasePlan, OptimisticOptimizations.ALL).apply(graph);
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                new PhiStampPhase().apply(graph);
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                Debug.dump(graph, "Graph");
+                new BoxingEliminationPhase().apply(graph);
+                Debug.dump(graph, "Graph");
+                new ExpandBoxingNodesPhase(pool).apply(graph);
+                new CanonicalizerPhase(null, runtime(), null).apply(graph);
+                new DeadCodeEliminationPhase().apply(graph);
+                StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+                new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
+                new DeadCodeEliminationPhase().apply(referenceGraph);
+
+                assertEquals(referenceGraph, graph);
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import static com.oracle.graal.graph.iterators.NodePredicates.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+
+/**
+ * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
+ * Then canonicalization is applied and it is verified that the resulting graph is equal to the
+ * graph of the method that just has a "return 1" statement in it.
+ */
+public class IfCanonicalizerTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "referenceSnippet";
+
+    @SuppressWarnings("all")
+    public static int referenceSnippet(int a) {
+        return 1;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static int test1Snippet(int a) {
+        if (a == 0) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static int test2Snippet(int a) {
+        if (a == 0) {
+            if (a == 0) {
+                if (a == 0) {
+                    return 1;
+                }
+            }
+        } else {
+            return 2;
+        }
+        return 3;
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static int test3Snippet(int a) {
+        if (a == 0) {
+            if (a != 1) {
+                if (a == 1) {
+                    return 3;
+                } else {
+                    if (a >= 0) {
+                        if (a <= 0) {
+                            if (a > -1) {
+                                if (a < 1) {
+                                    return 1;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } else {
+            return 2;
+        }
+        return 3;
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet");
+    }
+
+    public static int test4Snippet(int a) {
+        if (a == 0) {
+            return 1;
+        }
+        return 1;
+    }
+
+    @Test
+    public void test5() {
+        test("test5Snippet");
+    }
+
+    public static int test5Snippet(int a) {
+        int val = 2;
+        if (a == 0) {
+            val = 1;
+        }
+        if (a * (3 + val) == 0) {
+            return 1;
+        }
+        return 1;
+    }
+
+    private void test(String snippet) {
+        StructuredGraph graph = parse(snippet);
+        LocalNode local = graph.getNodes(LocalNode.class).iterator().next();
+        ConstantNode constant = ConstantNode.forInt(0, graph);
+        for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
+            n.replaceFirstInput(local, constant);
+        }
+        Debug.dump(graph, "Graph");
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+        assertEquals(referenceGraph, graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.nodes.*;
+
+public class InvokeExceptionTest extends GraalCompilerTest {
+
+    public static synchronized void throwException(int i) {
+        if (i == 1) {
+            throw new RuntimeException();
+        }
+    }
+
+    @Test
+    public void test1() {
+        // fill the profiling data...
+        for (int i = 0; i < 10000; i++) {
+            try {
+                throwException(i & 1);
+                test1Snippet(0);
+            } catch (Throwable t) {
+                // nothing to do...
+            }
+        }
+        test("test1Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static void test1Snippet(int a) {
+        throwException(a);
+    }
+
+    private void test(String snippet) {
+        StructuredGraph graph = parseProfiled(snippet);
+        Collection<Invoke> hints = new ArrayList<>();
+        for (Invoke invoke : graph.getInvokes()) {
+            hints.add(invoke);
+        }
+        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.nodes.*;
+
+public class InvokeHintsTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "referenceSnippet";
+
+    public static int const1() {
+        return 1;
+    }
+
+    public static int const7() {
+        return 7;
+    }
+
+    @SuppressWarnings("all")
+    public static int referenceSnippet() {
+        return 7;
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static int test1Snippet() {
+        return const7();
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static int test2Snippet() {
+        return const1() + const1() + const1() + const1() + const1() + const1() + const1();
+    }
+
+    private void test(String snippet) {
+        StructuredGraph graph = parse(snippet);
+        Collection<Invoke> hints = new ArrayList<>();
+        for (Invoke invoke : graph.getInvokes()) {
+            hints.add(invoke);
+        }
+        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+        assertEquals(referenceGraph, graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import static com.oracle.graal.graph.iterators.NodePredicates.*;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.iterators.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+/**
+ * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
+ * Then canonicalization is applied and it is verified that the resulting graph is equal to the
+ * graph of the method that just has a "return 1" statement in it.
+ */
+public class MonitorTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "referenceSnippet";
+
+    @SuppressWarnings("all")
+    public static synchronized int referenceSnippet(int a) {
+        return 1;
+    }
+
+    public static int const1() {
+        return 1;
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    @SuppressWarnings("all")
+    public static synchronized int test1Snippet(int a) {
+        return const1();
+    }
+
+    @Test
+    public void test2() {
+        StructuredGraph graph = parseAndProcess("test2Snippet");
+        NodeIterable<MonitorExitNode> monitors = graph.getNodes(MonitorExitNode.class);
+        Assert.assertEquals(1, monitors.count());
+        Assert.assertEquals(monitors.first().stateAfter().bci, 3);
+    }
+
+    @SuppressWarnings("all")
+    public static int test2Snippet(int a) {
+        return const2();
+    }
+
+    public static synchronized int const2() {
+        return 1;
+    }
+
+    private StructuredGraph parseAndProcess(String snippet) {
+        StructuredGraph graph = parse(snippet);
+        LocalNode local = graph.getNodes(LocalNode.class).first();
+        ConstantNode constant = ConstantNode.forInt(0, graph);
+        for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
+            n.replaceFirstInput(local, constant);
+        }
+        Collection<Invoke> hints = new ArrayList<>();
+        for (Invoke invoke : graph.getInvokes()) {
+            hints.add(invoke);
+        }
+        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+        return graph;
+    }
+
+    private void test(String snippet) {
+        StructuredGraph graph = parseAndProcess(snippet);
+        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+        assertEquals(referenceGraph, graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.cfg.*;
+import com.oracle.graal.nodes.*;
+
+public class NestedLoopTest extends GraalCompilerTest {
+
+    @Test
+    public void test1() {
+        test("test1Snippet", 1, 2, 2);
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet", 1, 2, 2);
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet", 1, 2, 2);
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet", 1, 3, 2);
+    }
+
+    @SuppressWarnings("all")
+    public static void test1Snippet(int a) {
+        while (a()) { // a() exits root, while() exits root
+            m1: while (b()) { // b() exits nested & root, while() exits nested
+                while (c()) { // c() exits innermost & nested & root, while() exits innermost
+                    if (d()) { // d() exits innermost & nested & root
+                        break m1; // break exits innermost & nested
+                    }
+                }
+            }
+        }
+    }// total : root = 5 exits, nested = 5, innermost = 4
+
+    @SuppressWarnings("all")
+    public static void test2Snippet(int a) {
+        while (a()) { // a() exits root, while() exits root
+            try {
+                m1: while (b()) { // b() exits nested, while() exits nested
+                    while (c()) { // c() exits innermost & nested, while() exits innermost
+                        if (d()) { // d() exits innermost & nested
+                            break m1; // break exits innermost & nested
+                        }
+                    }
+                }
+            } catch (Throwable t) {
+            }
+        }
+    }// total : root = 2 exits, nested = 5, innermost = 4
+
+    @SuppressWarnings("all")
+    public static void test3Snippet(int a) {
+        while (a == 0) { // while() exits root
+            try {
+                m1: while (b()) { // b() exits nested, while() exits nested
+                    while (c()) { // c() exits innermost & nested, while() exits innermost
+                        if (d()) { // d() exits innermost & nested
+                            a(); // a() exits nothing (already outside innermost & nested)
+                            break m1; // break exits innermost & nested
+                        }
+                    }
+                }
+            } catch (Throwable t) {
+            }
+        }
+    }// total : root = 1 exit, nested = 5, innermost = 4
+
+    public static void test4Snippet(int a) {
+        while (a != 0) { // while() exits root
+            try {
+                m1: while (a != 0) { // while() exits nested
+                    b(); // b() exits nested
+                    while (c()) { // c() exits innermost & nested, while() exits innermost
+                        if (d()) { // d() exits innermost & nested
+                            break m1; // break exits innermost & nested
+                        }
+                    }
+                    if (a != 2) {
+                        a(); // a() exits nothing (already outside innermost & nested)
+                        throw new Exception(); // throw exits nested
+                    }
+                }
+            } catch (Throwable t) {
+            }
+        }
+    } // total : root = 1 exit, nested = 6, innermost = 4
+
+    private static boolean a() {
+        return false;
+    }
+
+    private static boolean b() {
+        return false;
+    }
+
+    private static boolean c() {
+        return false;
+    }
+
+    private static boolean d() {
+        return false;
+    }
+
+    private static Invoke getInvoke(String name, StructuredGraph graph) {
+        for (Invoke invoke : graph.getInvokes()) {
+            if (invoke.callTarget().targetMethod().name().equals(name)) {
+                return invoke;
+            }
+        }
+        return null;
+    }
+
+    private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
+        StructuredGraph graph = parse(snippet);
+        Debug.dump(graph, "Graph");
+        ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
+
+        Assert.assertTrue(cfg.getLoops().length == 3);
+        Loop rootLoop = cfg.getLoops()[0];
+        Loop nestedLoop = cfg.getLoops()[1];
+        Loop innerMostLoop = cfg.getLoops()[2];
+        Invoke a = getInvoke("a", graph);
+        Invoke b = getInvoke("b", graph);
+        Invoke c = getInvoke("c", graph);
+        Invoke d = getInvoke("d", graph);
+        Assert.assertTrue(containsDirect(rootLoop, a, cfg));
+        Assert.assertTrue(containsDirect(nestedLoop, b, cfg));
+        Assert.assertTrue(containsDirect(innerMostLoop, c, cfg));
+        Assert.assertTrue(containsDirect(innerMostLoop, d, cfg));
+        Assert.assertTrue(contains(rootLoop, d, cfg));
+        Assert.assertTrue(contains(nestedLoop, d, cfg));
+        Assert.assertEquals(rootExits, rootLoop.exits.size());
+        Assert.assertEquals(nestedExits, nestedLoop.exits.size());
+        Assert.assertEquals(innerExits, innerMostLoop.exits.size());
+        Debug.dump(graph, "Graph");
+    }
+
+    private static boolean contains(Loop loop, Invoke node, ControlFlowGraph cfg) {
+        Block block = cfg.blockFor((Node) node);
+        Assert.assertNotNull(block);
+        return loop.blocks.contains(block);
+    }
+
+    private static boolean containsDirect(Loop loop, Invoke node, ControlFlowGraph cfg) {
+        for (Loop child : loop.children) {
+            if (contains(child, node, cfg)) {
+                return false;
+            }
+        }
+        return contains(loop, node, cfg);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+
+/**
+ * In the following tests, the correct removal of redundant phis during graph building is tested.
+ */
+public class PhiCreationTests extends GraalCompilerTest {
+
+    /**
+     * Dummy method to avoid javac dead code elimination.
+     */
+    private static void test() {
+    }
+
+    @Test
+    public void test1() {
+        StructuredGraph graph = parse("test1Snippet");
+        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
+    }
+
+    public static int test1Snippet(int a) {
+        if (a > 1) {
+            test();
+        }
+        return a;
+    }
+
+    @Test
+    public void test2() {
+        StructuredGraph graph = parse("test2Snippet");
+        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
+    }
+
+    public static int test2Snippet(int a) {
+        while (a > 1) {
+            test();
+        }
+        return a;
+    }
+
+    @Test
+    public void test3() {
+        StructuredGraph graph = parse("test3Snippet");
+        Debug.dump(graph, "Graph");
+        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
+    }
+
+    public static int test3Snippet(int a) {
+        while (a > 1) {
+            while (a > 1) {
+                test();
+            }
+        }
+        return a;
+    }
+
+    @Test
+    public void test4() {
+        StructuredGraph graph = parse("test4Snippet");
+        Debug.dump(graph, "Graph");
+        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
+    }
+
+    public static int test4Snippet(int a) {
+        int b = 5;
+        while (a > 1) {
+            while (a > 1) {
+                while (a > 1) {
+                    try {
+                        test();
+                    } catch (Throwable t) {
+
+                    }
+                }
+            }
+            while (a > 1) {
+                while (a > 1) {
+                    try {
+                        test();
+                    } catch (Throwable t) {
+
+                    }
+                }
+            }
+        }
+        return a + b;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+
+public class ReassociateAndCanonicalTest extends GraalCompilerTest {
+    public static int rnd = (int) (Math.random() * 100);
+
+    @Test
+    public void test1() {
+        test("test1Snippet", "ref1Snippet");
+    }
+
+    public static int test1Snippet() {
+        return 1 + (rnd + 2);
+    }
+
+    public static int ref1Snippet() {
+        return rnd + 3;
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet", "ref2Snippet");
+    }
+
+    public static int test2Snippet() {
+        return rnd + 3;
+    }
+
+    public static int ref2Snippet() {
+        return (rnd + 2) + 1;
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet", "ref3Snippet");
+    }
+
+    public static int test3Snippet() {
+        return rnd + 3;
+    }
+
+    public static int ref3Snippet() {
+        return 1 + (2 + rnd);
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet", "ref4Snippet");
+    }
+
+    public static int test4Snippet() {
+        return rnd + 3;
+    }
+
+    public static int ref4Snippet() {
+        return (2 + rnd) + 1;
+    }
+
+    @Test
+    public void test5() {
+        test("test5Snippet", "ref5Snippet");
+    }
+
+    public static int test5Snippet() {
+        return -1 - rnd;
+    }
+
+    public static int ref5Snippet() {
+        return 1 - (rnd + 2);
+    }
+
+    @Test
+    public void test6() {
+        test("test6Snippet", "ref6Snippet");
+    }
+
+    public static int test6Snippet() {
+        return rnd + 1;
+    }
+
+    public static int ref6Snippet() {
+        return (rnd + 2) - 1;
+    }
+
+    @Test
+    public void test7() {
+        test("test7Snippet", "ref7Snippet");
+    }
+
+    public static int test7Snippet() {
+        return -1 - rnd;
+    }
+
+    public static int ref7Snippet() {
+        return 1 - (2 + rnd);
+    }
+
+    @Test
+    public void test8() {
+        test("test8Snippet", "ref8Snippet");
+    }
+
+    public static int test8Snippet() {
+        return rnd + 1;
+    }
+
+    public static int ref8Snippet() {
+        return (2 + rnd) - 1;
+    }
+
+    @Test
+    public void test9() {
+        test("test9Snippet", "ref9Snippet");
+    }
+
+    public static int test9Snippet() {
+        return rnd - 1;
+    }
+
+    public static int ref9Snippet() {
+        return 1 + (rnd - 2);
+    }
+
+    @Test
+    public void test10() {
+        test("test10Snippet", "ref10Snippet");
+    }
+
+    public static int test10Snippet() {
+        return rnd - 1;
+    }
+
+    public static int ref10Snippet() {
+        return (rnd - 2) + 1;
+    }
+
+    @Test
+    public void test11() {
+        test("test11Snippet", "ref11Snippet");
+    }
+
+    public static int test11Snippet() {
+        return -rnd + 3;
+    }
+
+    public static int ref11Snippet() {
+        return 1 + (2 - rnd);
+    }
+
+    @Test
+    public void test12() {
+        test("test12Snippet", "ref12Snippet");
+    }
+
+    public static int test12Snippet() {
+        return -rnd + 3;
+    }
+
+    public static int ref12Snippet() {
+        return (2 - rnd) + 1;
+    }
+
+    @Test
+    public void test13() {
+        test("test13Snippet", "ref13Snippet");
+    }
+
+    public static int test13Snippet() {
+        return -rnd + 3;
+    }
+
+    public static int ref13Snippet() {
+        return 1 - (rnd - 2);
+    }
+
+    @Test
+    public void test14() {
+        test("test14Snippet", "ref14Snippet");
+    }
+
+    public static int test14Snippet() {
+        return rnd - 3;
+    }
+
+    public static int ref14Snippet() {
+        return (rnd - 2) - 1;
+    }
+
+    @Test
+    public void test15() {
+        test("test15Snippet", "ref15Snippet");
+    }
+
+    public static int test15Snippet() {
+        return rnd + -1;
+    }
+
+    public static int ref15Snippet() {
+        return 1 - (2 - rnd);
+    }
+
+    @Test
+    public void test16() {
+        test("test16Snippet", "ref16Snippet");
+    }
+
+    public static int test16Snippet() {
+        return -rnd + 1;
+    }
+
+    public static int ref16Snippet() {
+        return (2 - rnd) - 1;
+    }
+
+    private <T extends Node & Node.IterableNodeType> void test(String test, String ref) {
+        StructuredGraph testGraph = parse(test);
+        new CanonicalizerPhase(null, runtime(), null).apply(testGraph);
+        StructuredGraph refGraph = parse(ref);
+        new CanonicalizerPhase(null, runtime(), null).apply(refGraph);
+        assertEquals(testGraph, refGraph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+
+/**
+ * In the following tests, the scalar type system of the compiler should be complete enough to see the relation between the different conditions.
+ */
+public class ScalarTypeSystemTest extends GraalCompilerTest {
+
+    public static int referenceSnippet1(int a) {
+        if (a > 0) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test1() {
+        test("test1Snippet", "referenceSnippet1");
+    }
+
+    public static int test1Snippet(int a) {
+        if (a > 0) {
+            if (a > -1) {
+                return 1;
+            } else {
+                return 3;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test2() {
+        test("test2Snippet", "referenceSnippet1");
+    }
+
+    public static int test2Snippet(int a) {
+        if (a > 0) {
+            if (a == -15) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test3() {
+        test("test3Snippet", "referenceSnippet2");
+    }
+
+    public static int referenceSnippet2(int a, int b) {
+        if (a > b) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public static int test3Snippet(int a, int b) {
+        if (a > b) {
+            if (a == b) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet", "referenceSnippet2");
+    }
+
+    public static int test4Snippet(int a, int b) {
+        if (a > b) {
+            if (a <= b) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test
+    public void test5() {
+        test("test5Snippet", "referenceSnippet3");
+    }
+
+    public static int referenceSnippet3(int a, int b) {
+        if (a == b) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public static int test5Snippet(int a, int b) {
+        if (a == b) {
+            if (a != b) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test6() {
+        test("test6Snippet", "referenceSnippet3");
+    }
+
+    public static int test6Snippet(int a, int b) {
+        if (a == b) {
+            if (a == b + 1) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    private void test(final String snippet, final String referenceSnippet) {
+        // No debug scope to reduce console noise for @Test(expected = ...) tests
+        StructuredGraph graph = parse(snippet);
+        Debug.dump(graph, "Graph");
+//        TypeSystemTest.outputGraph(graph);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new CheckCastEliminationPhase().apply(graph);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        StructuredGraph referenceGraph = parse(referenceSnippet);
+        assertEquals(referenceGraph, graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2012, 2012, 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.graal.compiler.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.graal.lir.cfg.*;
+import com.oracle.graal.nodes.*;
+
+public class SimpleCFGTest {
+
+    @Test
+    public void testImplies() {
+        StructuredGraph graph = new StructuredGraph();
+
+        EndNode trueEnd = graph.add(new EndNode());
+        EndNode falseEnd = graph.add(new EndNode());
+
+        BeginNode trueBegin = graph.add(new BeginNode());
+        trueBegin.setNext(trueEnd);
+        BeginNode falseBegin = graph.add(new BeginNode());
+        falseBegin.setNext(falseEnd);
+
+        IfNode ifNode = graph.add(new IfNode(null, trueBegin, falseBegin, 0.5, graph.graphId()));
+        graph.start().setNext(ifNode);
+
+        MergeNode merge = graph.add(new MergeNode());
+        merge.addForwardEnd(trueEnd);
+        merge.addForwardEnd(falseEnd);
+        ReturnNode returnNode = graph.add(new ReturnNode(null));
+        merge.setNext(returnNode);
+
+        ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
+
+        Block[] blocks = cfg.getBlocks();
+        // check number of blocks
+        assertEquals(4, blocks.length);
+
+        // check block - node assignment
+        assertEquals(blocks[0], cfg.blockFor(graph.start()));
+        assertEquals(blocks[0], cfg.blockFor(ifNode));
+        assertEquals(blocks[1], cfg.blockFor(trueBegin));
+        assertEquals(blocks[1], cfg.blockFor(trueEnd));
+        assertEquals(blocks[2], cfg.blockFor(falseBegin));
+        assertEquals(blocks[2], cfg.blockFor(falseEnd));
+        assertEquals(blocks[3], cfg.blockFor(merge));
+        assertEquals(blocks[3], cfg.blockFor(returnNode));
+
+        // check dominators
+        assertDominator(blocks[0], null);
+        assertDominator(blocks[1], blocks[0]);
+        assertDominator(blocks[2], blocks[0]);
+        assertDominator(blocks[3], blocks[0]);
+
+        // check dominated
+        assertDominatedSize(blocks[0], 3);
+        assertDominatedSize(blocks[1], 0);
+        assertDominatedSize(blocks[2], 0);
+        assertDominatedSize(blocks[3], 0);
+
+        // check postdominators
+        assertPostdominator(blocks[0], blocks[3]);
+        assertPostdominator(blocks[1], blocks[3]);
+        assertPostdominator(blocks[2], blocks[3]);
+        assertPostdominator(blocks[3], null);
+    }
+
+    public static void assertDominator(Block block, Block expectedDominator) {
+        assertEquals("dominator of " + block, expectedDominator, block.getDominator());
+    }
+
+    public static void assertDominatedSize(Block block, int size) {
+        assertEquals("number of dominated blocks of " + block, size, block.getDominated().size());
+    }
+
+    public static void assertPostdominator(Block block, Block expectedPostdominator) {
+        assertEquals("postdominator of " + block, expectedPostdominator, block.getPostdominator());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * This class tests some specific patterns the stamp system should be able to canonicalize away using
+ * {@link IntegerStamp#mask()}.
+ */
+public class StampCanonicalizerTest extends GraalCompilerTest {
+
+    public static int andStamp(int a, int b) {
+        int v = (a & 0xffff00) & (b & 0xff0000f);
+        return v & 1;
+    }
+
+    @Test
+    public void testAnd() {
+        testZeroReturn("andStamp");
+    }
+
+    public static int shiftLeftStamp1(int a) {
+        int v = a << 1;
+        return v & 1;
+    }
+
+    public static int shiftLeftStamp2(int a) {
+        int v = a << 1;
+        if (a == 17) {
+            v = a * 4;
+        }
+        return v & 1;
+    }
+
+    @Test
+    public void testShift() {
+        testZeroReturn("shiftLeftStamp1");
+        testZeroReturn("shiftLeftStamp2");
+    }
+
+    public static int upperBoundShiftStamp1(int a) {
+        int v = a & 0xffff;
+        return (v << 4) & 0xff00000;
+    }
+
+    public static int upperBoundShiftStamp2(int a) {
+        int v = a & 0xffff;
+        return (v >> 4) & 0xf000;
+    }
+
+    @Test
+    public void testUpperBoundShift() {
+        testZeroReturn("upperBoundShiftStamp1");
+        testZeroReturn("upperBoundShiftStamp2");
+    }
+
+    public static int divStamp1(int[] a) {
+        int v = a.length / 4;
+        return v & 0x80000000;
+    }
+
+    public static int divStamp2(int[] a) {
+        int v = a.length / 5;
+        return v & 0x80000000;
+    }
+
+    @Test
+    public void testDiv() {
+        testZeroReturn("divStamp1");
+        testZeroReturn("divStamp2");
+    }
+
+    private void testZeroReturn(String methodName) {
+        StructuredGraph graph = parse(methodName);
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        new DeadCodeEliminationPhase().apply(graph);
+        assertConstantReturn(graph, 0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+
+public class StraighteningTest extends GraalCompilerTest {
+
+    private static final String REFERENCE_SNIPPET = "ref";
+
+    public static boolean ref(int a, int b) {
+        return a == b;
+    }
+
+    public static boolean test1Snippet(int a, int b) {
+        int c = a;
+        if (c == b) {
+            c = 0x55;
+        }
+        if (c != 0x55) {
+            return false;
+        }
+        return true;
+    }
+
+    public static boolean test3Snippet(int a, int b) {
+        int val = (int) System.currentTimeMillis();
+        int c = val + 1;
+        if (a == b) {
+            c = val;
+        }
+        if (c != val) {
+            return false;
+        }
+        return true;
+    }
+
+    public static boolean test2Snippet(int a, int b) {
+        int c;
+        if (a == b) {
+            c = 1;
+        } else {
+            c = 0;
+        }
+        return c == 1;
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test2() {
+        test("test2Snippet");
+    }
+
+    @Test(expected = AssertionError.class)
+    public void test3() {
+        test("test3Snippet");
+    }
+
+    private void test(final String snippet) {
+        // No debug scope to reduce console noise for @Test(expected = ...) tests
+        StructuredGraph graph = parse(snippet);
+        Debug.dump(graph, "Graph");
+        new CanonicalizerPhase(null, runtime(), null).apply(graph);
+        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
+        assertEquals(referenceGraph, graph);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 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.graal.compiler.test;
+
+import java.io.*;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.compiler.schedule.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.cfg.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+
+/**
+ * In the following tests, the scalar type system of the compiler should be complete enough to see the relation between the different conditions.
+ */
+public class TypeSystemTest extends GraalCompilerTest {
+
+    @Test
+    public void test1() {
+        test("test1Snippet", CheckCastNode.class);
+    }
+
+    public static int test1Snippet(Object a) {
+        if (a instanceof Boolean) {
+            return ((Boolean) a).booleanValue() ? 0 : 1;
+        }
+        return 1;
+    }
+
+    @Test
+    public void test2() {
+        test("test2Snippet", CheckCastNode.class);
+    }
+
+    public static int test2Snippet(Object a) {
+        if (a instanceof Integer) {
+            return ((Number) a).intValue();
+        }
+        return 1;
+    }
+
+    @Test
+    public void test3() {
+        test("test3Snippet", "referenceSnippet3");
+    }
+
+    public static int referenceSnippet3(Object o) {
+        if (o == null) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    @SuppressWarnings("unused")
+    public static int test3Snippet(Object o) {
+        if (o == null) {
+            if (o != null) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test
+    public void test4() {
+        test("test4Snippet", "referenceSnippet3");
+    }
+
+    public static final Object constantObject1 = "1";
+    public static final Object constantObject2 = "2";
+    public static final Object constantObject3 = "3";
+
+    public static int test4Snippet(Object o) {
+        if (o == null) {
+            if (o == constantObject1) {
+                return 3;
+            } else {
+                return 1;
+            }
+        } else {
+            return 2;
+        }
+    }
+
+    @Test
+    public void test5() {
+        test("test5Snippet", "referenceSnippet5");
+    }
+
+    public static int referenceSnippet5(Object o, Object a) {
+        if (o == null) {
+            if (a == constantObject1 || a == constantObject2) {
+                return 1;
+            }
+        } else {
+            if (a == constantObject2 || a == constantObject3) {
+                if (a != null) {
+                    return 11;
+                }
+                return 2;
+            }
+        }
+        if (a == constantObject1) {
+            return 3;
+        }
+        return 5;
+    }
+
+    public static int test5Snippet(Object o, Object a) {
+        if (o == null) {
+            if (a == constantObject1 || a == constantObject2) {
+                if (a == null) {
+                    return 10;
+                }
+                return 1;
+            }
+        } else {
+            if (a == constantObject2 || a == constantObject3) {
+                if (a != null) {
+                    return 11;
+                }
+                return 2;
+            }
+        }
+        if (a == constantObject1) {
+            return 3;
+        }
+        if (a == constantObject2) {
+            return 4;
+        }
+        return 5;
+    }
+
+    @Test
+    public void test6() {
+        test("test6Snippet", CheckCastNode.class);
+    }
+
+    public static int test6Snippet(int i) throws IOException {
+        Object o = null;
+
+        if (i == 5) {
+            o = new FileInputStream("asdf");
+        }
+        if (i < 10) {
+            o = new ByteArrayInputStream(new byte[]{1, 2, 3});
+        }
+        if (i > 0) {
+            o = new BufferedInputStream(null);
+        }
+
+        return ((InputStream) o).available();
+    }
+
+    @SuppressWarnings("unused")
+    private void test(String snippet, String referenceSnippet) {
+        // TODO(ls) temporarily disabled, reintroduce when a proper type system is available
+        if (false) {
+            StructuredGraph graph = parse(snippet);
+            Debug.dump(graph, "Graph");
+            new CanonicalizerPhase(null, runtime(), null).apply(graph);
+            new CheckCastEliminationPhase().apply(graph);
+            new CanonicalizerPhase(null, runtime(), null).apply(graph);
+            new GlobalValueNumberingPhase().apply(graph);
+            StructuredGraph referenceGraph = parse(referenceSnippet);
+            new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
+            new GlobalValueNumberingPhase().apply(referenceGraph);
+            assertEquals(referenceGraph, graph);
+        }
+    }
+
+    @Override
+    protected void assertEquals(StructuredGraph expected, StructuredGraph graph) {
+        if (expected.getNodeCount() != graph.getNodeCount()) {
+//            Debug.dump(expected, "Node count not matching - expected");
+//            Debug.dump(graph, "Node count not matching - actual");
+//            System.out.println("================ expected");
+//            outputGraph(expected);
+//            System.out.println("================ actual");
+//            outputGraph(graph);
+//            new IdealGraphPrinterDumpHandler().dump(graph, "asdf");
+            Assert.fail("Graphs do not have the same number of nodes: " + expected.getNodeCount() + " vs. " + graph.getNodeCount());
+        }
+    }
+
+    public static void outputGraph(StructuredGraph graph) {
+        SchedulePhase schedule = new SchedulePhase();
+        schedule.apply(graph);
+        for (Block block : schedule.getCFG().getBlocks()) {
+            System.out.print("Block " + block + " ");
+            if (block == schedule.getCFG().getStartBlock()) {
+                System.out.print("* ");
+            }
+            System.out.print("-> ");
+            for (Block succ : block.getSuccessors()) {
+                System.out.print(succ + " ");
+            }
+            System.out.println();
+            for (Node node : schedule.getBlockToNodesMap().get(block)) {
+                System.out.println("  " + node + "    (" + node.usages().size() + ")");
+            }
+        }
+    }
+
+    @SuppressWarnings("unused")
+    private <T extends Node & Node.IterableNodeType> void test(String snippet, Class<T> clazz) {
+        // TODO(ls) temporarily disabled, reintroduce when a proper type system is available
+        if (false) {
+            StructuredGraph graph = parse(snippet);
+            Debug.dump(graph, "Graph");
+            new CanonicalizerPhase(null, runtime(), null).apply(graph);
+            new CheckCastEliminationPhase().apply(graph);
+            new CanonicalizerPhase(null, runtime(), null).apply(graph);
+            Debug.dump(graph, "Graph");
+            Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes(clazz).iterator().hasNext());
+        }
+    }
+}
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InvokeTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InvokeTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.compiler.tests.*;
+import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.*;
 
 /**
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewArrayTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewArrayTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -24,7 +24,7 @@
 
 import org.junit.*;
 
-import com.oracle.graal.compiler.tests.*;
+import com.oracle.graal.compiler.test.*;
 
 /**
  * Tests the implementation of {@code [A]NEWARRAY}.
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewInstanceTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/NewInstanceTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -26,7 +26,7 @@
 
 import org.junit.*;
 
-import com.oracle.graal.compiler.tests.*;
+import com.oracle.graal.compiler.test.*;
 
 /**
  * Tests the implementation of {@code NEW}.
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/TypeCheckTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/TypeCheckTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -25,7 +25,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
-import com.oracle.graal.compiler.tests.*;
+import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.*;
 
 /**
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java	Fri Sep 07 16:25:49 2012 +0200
@@ -30,7 +30,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.tests.*;
+import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.snippets.Snippet.InliningPolicy;
 
--- a/graal/com.oracle.graal.tests/overview.html	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-
-Copyright (c) 2012, 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.  Oracle designates this
-particular file as subject to the "Classpath" exception as provided
-by Oracle in the LICENSE file that accompanied this code.
-
-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.
--->
-
-</head>
-<body>
-
-Documentation for the <code>com.oracle.graal.tests</code> project.
-
-</body>
-</html>
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/BoxingEliminationTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-
-/**
- * In the following tests, the usages of local variable "a" are replaced with the integer constant 0. Then boxing
- * elimination is applied and it is verified that the resulting graph is equal to the graph of the method that just has
- * a "return 1" statement in it.
- */
-public class BoxingEliminationTest extends GraalCompilerTest {
-
-    private static final Short s = 2;
-
-    @SuppressWarnings("all")
-    public static short referenceSnippet1() {
-        return 1;
-    }
-
-    @SuppressWarnings("all")
-    public static short referenceSnippet2() {
-        return 2;
-    }
-
-    public static Short boxedShort() {
-        return 1;
-    }
-
-    public static Object boxedObject() {
-        return (short) 1;
-    }
-
-    public static Short constantBoxedShort() {
-        return s;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet", "referenceSnippet1");
-    }
-
-    @SuppressWarnings("all")
-    public static short test1Snippet() {
-        return boxedShort();
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet", "referenceSnippet1");
-    }
-
-    @SuppressWarnings("all")
-    public static short test2Snippet() {
-        return (Short) boxedObject();
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet", "referenceSnippet1");
-    }
-
-    @SuppressWarnings("all")
-    public static short test3Snippet() {
-        short b = boxedShort();
-        if (b < 0) {
-            b = boxedShort();
-        }
-        return b;
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet", "referenceSnippet2");
-    }
-
-    @SuppressWarnings("all")
-    public static short test4Snippet() {
-        return constantBoxedShort();
-    }
-
-    private void test(final String snippet, final String referenceSnippet) {
-        Debug.scope("BoxingEliminationTest", new DebugDumpScope(snippet), new Runnable() {
-            @Override
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                BoxingMethodPool pool = new BoxingMethodPool(runtime());
-                IdentifyBoxingPhase identifyBoxingPhase = new IdentifyBoxingPhase(pool);
-                PhasePlan phasePlan = getDefaultPhasePlan();
-                phasePlan.addPhase(PhasePosition.AFTER_PARSING, identifyBoxingPhase);
-                identifyBoxingPhase.apply(graph);
-                Collection<Invoke> hints = new ArrayList<>();
-                for (Invoke invoke : graph.getInvokes()) {
-                    hints.add(invoke);
-                }
-
-                new InliningPhase(null, runtime(), hints, null, null, phasePlan, OptimisticOptimizations.ALL).apply(graph);
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                Debug.dump(graph, "Graph");
-                new BoxingEliminationPhase().apply(graph);
-                Debug.dump(graph, "Graph");
-                new ExpandBoxingNodesPhase(pool).apply(graph);
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                new DeadCodeEliminationPhase().apply(graph);
-                StructuredGraph referenceGraph = parse(referenceSnippet);
-                assertEquals(referenceGraph, graph);
-            }
-        });
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/CompareCanonicalizerTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2012, 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.nodes.*;
-
-public class CompareCanonicalizerTest extends GraalCompilerTest {
-
-    @Test
-    public void testCanonicalComparison() {
-        StructuredGraph referenceGraph = parse("referenceCanonicalComparison");
-        for (int i = 1; i < 4; i++) {
-            StructuredGraph graph = parse("canonicalCompare" + i);
-            assertEquals(referenceGraph, graph);
-        }
-        new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
-        for (int i = 1; i < 4; i++) {
-            StructuredGraph graph = parse("canonicalCompare" + i);
-            new CanonicalizerPhase(null, runtime(), null).apply(graph);
-            assertEquals(referenceGraph, graph);
-        }
-    }
-
-    public static int referenceCanonicalComparison(int a, int b) {
-        if (a < b) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    public static int canonicalCompare1(int a, int b) {
-        if (a >= b) {
-            return 2;
-        } else {
-            return 1;
-        }
-    }
-
-    public static int canonicalCompare2(int a, int b) {
-        if (b > a) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    public static int canonicalCompare3(int a, int b) {
-        if (b <= a) {
-            return 2;
-        } else {
-            return 1;
-        }
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/CompiledMethodTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.InstalledCode.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * In the following tests, the usages of local variable "a" are replaced with the integer constant 0. Then
- * canonicalization is applied and it is verified that the resulting graph is equal to the graph of the method that just
- * has a "return 1" statement in it.
- */
-public class CompiledMethodTest extends GraalCompilerTest {
-
-    public static Object testMethod(Object arg1, Object arg2, Object arg3) {
-        return arg1 + " " + arg2 + " " + arg3;
-    }
-
-    Object f1;
-    public Object testMethodVirtual(Object arg1, Object arg2, Object arg3) {
-        return f1 + " " + arg1 + " " + arg2 + " " + arg3;
-    }
-
-    @Test
-    public void test1() {
-        Method method = getMethod("testMethod");
-        final StructuredGraph graph = parse(method);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-
-        for (Node node : graph.getNodes()) {
-            if (node instanceof ConstantNode) {
-                ConstantNode constant = (ConstantNode) node;
-                if (constant.kind() == Kind.Object && " ".equals(constant.value.asObject())) {
-                    graph.replaceFloating(constant, ConstantNode.forObject("-", runtime, graph));
-                }
-            }
-        }
-
-        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
-        InstalledCode compiledMethod = getCode(javaMethod, graph);
-        try {
-            Object result = compiledMethod.execute("1", "2", "3");
-            Assert.assertEquals("1-2-3", result);
-        } catch (MethodInvalidatedException t) {
-            Assert.fail("method invalidated");
-        }
-    }
-
-    @Test
-    public void test3() {
-        Method method = getMethod("testMethod");
-        final StructuredGraph graph = parse(method);
-        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
-        InstalledCode compiledMethod = getCode(javaMethod, graph);
-        try {
-            Object result = compiledMethod.executeVarargs("1", "2", "3");
-            Assert.assertEquals("1 2 3", result);
-        } catch (MethodInvalidatedException t) {
-            Assert.fail("method invalidated");
-        }
-    }
-
-    @Test
-    public void test4() {
-        Method method = getMethod("testMethodVirtual");
-        final StructuredGraph graph = parse(method);
-        final ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
-        InstalledCode compiledMethod = getCode(javaMethod, graph);
-        try {
-            f1 = "0";
-            Object result = compiledMethod.executeVarargs(this, "1", "2", "3");
-            Assert.assertEquals("0 1 2 3", result);
-        } catch (MethodInvalidatedException t) {
-            Assert.fail("method invalidated");
-        }
-    }
-
-    @Test
-    public void test2() throws NoSuchMethodException, SecurityException {
-        Method method = CompilableObjectImpl.class.getDeclaredMethod("executeHelper", ObjectCompiler.class, String.class);
-        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(method);
-        StructuredGraph graph = new StructuredGraph(javaMethod);
-        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph);
-        new CanonicalizerPhase(null, runtime, null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-
-        for (Node node : graph.getNodes()) {
-            if (node instanceof ConstantNode) {
-                ConstantNode constant = (ConstantNode) node;
-                if (constant.kind() == Kind.Object && "1 ".equals(constant.value.asObject())) {
-                    graph.replaceFloating(constant, ConstantNode.forObject("1-", runtime, graph));
-                }
-            }
-        }
-
-        InstalledCode compiledMethod = getCode(javaMethod, graph);
-        final CompilableObject compilableObject = new CompilableObjectImpl(0);
-
-        Object result;
-        result = compilableObject.execute(new ObjectCompilerImpl(compiledMethod), "3");
-        Assert.assertEquals("1-3", result);
-    }
-
-    public abstract class CompilableObject {
-
-        private CompiledObject compiledObject;
-        private final int compileThreshold;
-        private int counter;
-
-        public CompilableObject(int compileThreshold) {
-            this.compileThreshold = compileThreshold;
-        }
-
-        public final Object execute(ObjectCompiler compiler, String args) {
-            if (counter++ < compileThreshold || compiler == null) {
-                return executeHelper(compiler, args);
-            } else {
-                compiledObject = compiler.compile(this);
-                return compiledObject.execute(compiler, args);
-            }
-        }
-
-        protected abstract Object executeHelper(ObjectCompiler context, String args);
-    }
-
-    private final class CompilableObjectImpl extends CompilableObject {
-
-        private CompilableObjectImpl(int compileThreshold) {
-            super(compileThreshold);
-        }
-
-        @Override
-        protected Object executeHelper(ObjectCompiler compiler, String args) {
-            return "1 " + args;
-        }
-    }
-
-    public interface CompiledObject {
-        Object execute(ObjectCompiler context, String args);
-    }
-
-    public interface ObjectCompiler {
-        CompiledObject compile(CompilableObject node);
-    }
-
-    private final class ObjectCompilerImpl implements ObjectCompiler {
-
-        private final InstalledCode compiledMethod;
-
-        private ObjectCompilerImpl(InstalledCode compiledMethod) {
-            this.compiledMethod = compiledMethod;
-        }
-
-        @Override
-        public CompiledObject compile(final CompilableObject node) {
-            return new CompiledObject() {
-                @Override
-                public Object execute(ObjectCompiler compiler, String args) {
-                    return compiledMethod.execute(node, compiler, args);
-                }
-            };
-        }
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, 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.graal.compiler.tests;
-
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.nodes.calc.*;
-
-
-public class ConditionTest {
-
-    @Test
-    public void testImplies() {
-        Random rand = new Random(13);
-        for (Condition c1 : Condition.values()) {
-            for (Condition c2 : Condition.values()) {
-                boolean implies = c1.implies(c2);
-                if (implies) {
-                    for (int i = 0; i < 1000; i++) {
-                        Constant a = Constant.forInt(rand.nextInt());
-                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
-                        boolean result1 = c1.foldCondition(a, b, null, false);
-                        boolean result2 = c2.foldCondition(a, b, null, false);
-                        if (result1 && implies) {
-                            assertTrue(result2);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Test
-    public void testJoin() {
-        Random rand = new Random(13);
-        for (Condition c1 : Condition.values()) {
-            for (Condition c2 : Condition.values()) {
-                Condition join = c1.join(c2);
-                assertTrue(join == c2.join(c1));
-                if (join != null) {
-                    for (int i = 0; i < 1000; i++) {
-                        Constant a = Constant.forInt(rand.nextInt());
-                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
-                        boolean result1 = c1.foldCondition(a, b, null, false);
-                        boolean result2 = c2.foldCondition(a, b, null, false);
-                        boolean resultJoin = join.foldCondition(a, b, null, false);
-                        if (result1 && result2) {
-                            assertTrue(resultJoin);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    @Test
-    public void testMeet() {
-        Random rand = new Random(13);
-        for (Condition c1 : Condition.values()) {
-            for (Condition c2 : Condition.values()) {
-                Condition meet = c1.meet(c2);
-                assertTrue(meet == c2.meet(c1));
-                if (meet != null) {
-                    for (int i = 0; i < 1000; i++) {
-                        Constant a = Constant.forInt(rand.nextInt());
-                        Constant b = Constant.forInt(i < 100 ? a.asInt() : rand.nextInt());
-                        boolean result1 = c1.foldCondition(a, b, null, false);
-                        boolean result2 = c2.foldCondition(a, b, null, false);
-                        boolean resultMeet = meet.foldCondition(a, b, null, false);
-                        if (result1 || result2) {
-                            assertTrue(resultMeet);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/DegeneratedLoopsTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
- * Then canonicalization is applied and it is verified that the resulting graph is equal to the
- * graph of the method that just has a "return 1" statement in it.
- */
-public class DegeneratedLoopsTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "referenceSnippet";
-
-    @SuppressWarnings("all")
-    public static int referenceSnippet(int a) {
-        return a;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    private static class UnresolvedException extends RuntimeException {
-        private static final long serialVersionUID = 5215434338750728440L;
-
-        static {
-            if (true) {
-                throw new UnsupportedOperationException("this class may never be initialized");
-            }
-        }
-    }
-
-    @SuppressWarnings("all")
-    public static int test1Snippet(int a) {
-        for (;;) {
-            try {
-                test();
-                break;
-            } catch (UnresolvedException e) {
-            }
-        }
-        return a;
-    }
-
-    private static void test() {
-
-    }
-
-    private void test(final String snippet) {
-        Debug.scope("DegeneratedLoopsTest", new DebugDumpScope(snippet), new Runnable() {
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                Debug.dump(graph, "Graph");
-                for (Invoke invoke : graph.getInvokes()) {
-                    invoke.intrinsify(null);
-                }
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-                Debug.dump(referenceGraph, "Graph");
-                assertEquals(referenceGraph, graph);
-            }
-        });
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/EscapeAnalysisTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-
-/**
- * In these test cases the probability of all invokes is set to a high value, such that an InliningPhase should inline them all.
- * After that, the EscapeAnalysisPhase is expected to remove all allocations and return the correct values.
- */
-public class EscapeAnalysisTest extends GraalCompilerTest {
-
-    @Test
-    public void test1() {
-        test("test1Snippet", Constant.forInt(101));
-    }
-
-    @SuppressWarnings("all")
-    public static int test1Snippet(int a) {
-        Integer x = new Integer(101);
-        return x.intValue();
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet", Constant.forInt(0));
-    }
-
-    @SuppressWarnings("all")
-    public static int test2Snippet(int a) {
-        Integer[] x = new Integer[0];
-        return x.length;
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet", Constant.forObject(null));
-    }
-
-    @SuppressWarnings("all")
-    public static Object test3Snippet(int a) {
-        Integer[] x = new Integer[1];
-        return x[0];
-    }
-
-    @Test
-    public void testMonitor() {
-        test("testMonitorSnippet", Constant.forInt(0));
-    }
-
-    private static native void notInlineable();
-
-    @SuppressWarnings("all")
-    public static int testMonitorSnippet(int a) {
-        Integer x = new Integer(0);
-        Integer[] y = new Integer[0];
-        Integer[] z = new Integer[1];
-        synchronized (x) {
-            synchronized (y) {
-                synchronized (z) {
-                    notInlineable();
-                }
-            }
-        }
-        return x.intValue();
-    }
-
-    public void testMonitor2() {
-        test("testMonitor2Snippet", Constant.forInt(0));
-    }
-
-    /**
-     * This test case differs from the last one in that it requires inlining within a synchronized region.
-     */
-    @SuppressWarnings("all")
-    public static int testMonitor2Snippet(int a) {
-        Integer x = new Integer(0);
-        Integer[] y = new Integer[0];
-        Integer[] z = new Integer[1];
-        synchronized (x) {
-            synchronized (y) {
-                synchronized (z) {
-                    notInlineable();
-                    return x.intValue();
-                }
-            }
-        }
-    }
-
-    private void test(final String snippet, final Constant expectedResult) {
-        Debug.scope("EscapeAnalysisTest", new DebugDumpScope(snippet), new Runnable() {
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                for (Invoke n : graph.getInvokes()) {
-                    n.node().setProbability(100000);
-                }
-
-                new InliningPhase(null, runtime(), null, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
-                new DeadCodeEliminationPhase().apply(graph);
-                Debug.dump(graph, "Graph");
-                new EscapeAnalysisPhase(null, runtime(), null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
-                Debug.dump(graph, "Graph");
-                int retCount = 0;
-                for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
-                    Assert.assertTrue(ret.result().isConstant());
-                    Assert.assertEquals(ret.result().asConstant(), expectedResult);
-                    retCount++;
-                }
-                Assert.assertEquals(1, retCount);
-                int newInstanceCount = 0;
-                for (@SuppressWarnings("unused") NewInstanceNode n : graph.getNodes(NewInstanceNode.class)) {
-                    newInstanceCount++;
-                }
-                for (@SuppressWarnings("unused") NewObjectArrayNode n : graph.getNodes(NewObjectArrayNode.class)) {
-                    newInstanceCount++;
-                }
-                Assert.assertEquals(0, newInstanceCount);
-            }
-        });
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/FloatingReadTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-
-public class FloatingReadTest extends GraphScheduleTest {
-
-    public static class Container {
-        public int a;
-    }
-
-    public static void changeField(Container c) {
-        c.a = 0xcafebabe;
-    }
-
-    public static synchronized int test1Snippet() {
-        Container c = new Container();
-        return c.a;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    private void test(final String snippet) {
-        Debug.scope("FloatingReadTest", new DebugDumpScope(snippet), new Runnable() {
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                new LoweringPhase(runtime(), null).apply(graph);
-                new FloatingReadPhase().apply(graph);
-
-                ReturnNode returnNode = null;
-                MonitorExitNode monitor = null;
-
-                for (Node n : graph.getNodes()) {
-                    if (n instanceof ReturnNode) {
-                        returnNode = (ReturnNode) n;
-                    } else if (n instanceof MonitorExitNode) {
-                        monitor = (MonitorExitNode) n;
-                    }
-                }
-
-                Assert.assertNotNull(returnNode);
-                Assert.assertNotNull(monitor);
-                Assert.assertTrue(returnNode.result() instanceof FloatingReadNode);
-
-                FloatingReadNode read = (FloatingReadNode) returnNode.result();
-
-                assertOrderedAfterSchedule(graph, read, monitor);
-            }
-        });
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalCompilerTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,287 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import junit.framework.*;
-
-import com.oracle.graal.api.*;
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
-import com.oracle.graal.compiler.schedule.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Node.Verbosity;
-import com.oracle.graal.java.*;
-import com.oracle.graal.lir.cfg.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-
-/**
- * Base class for Graal compiler unit tests. These are white box tests
- * for Graal compiler transformations. The general pattern for a test is:
- * <ol>
- * <li>Create a graph by {@linkplain #parse(String) parsing} a method.</li>
- * <li>Manually modify the graph (e.g. replace a parameter node with a constant).</li>
- * <li>Apply a transformation to the graph.</li>
- * <li>Assert that the transformed graph is equal to an expected graph.</li>
- * </ol>
- * <p>
- * See {@link InvokeHintsTest} as an example.
- * <p>
- * The tests can be run in Eclipse with the "Compiler Unit Test" Eclipse
- * launch configuration found in the top level of this project or by
- * running {@code mx unittest} on the command line.
- */
-public abstract class GraalCompilerTest {
-
-    protected final GraalCodeCacheProvider runtime;
-    protected final GraalCompiler graalCompiler;
-
-    public GraalCompilerTest() {
-        Debug.enable();
-        this.runtime = Graal.getRuntime().getCapability(GraalCodeCacheProvider.class);
-        this.graalCompiler = Graal.getRuntime().getCapability(GraalCompiler.class);
-    }
-
-    protected void assertEquals(StructuredGraph expected, StructuredGraph graph) {
-        String expectedString = getCanonicalGraphString(expected);
-        String actualString = getCanonicalGraphString(graph);
-        String mismatchString = "mismatch in graphs:\n========= expected =========\n" + expectedString + "\n\n========= actual =========\n" + actualString;
-
-        if (expected.getNodeCount() != graph.getNodeCount()) {
-            Debug.dump(expected, "Node count not matching - expected");
-            Debug.dump(graph, "Node count not matching - actual");
-            Assert.fail("Graphs do not have the same number of nodes: " + expected.getNodeCount() + " vs. " + graph.getNodeCount() + "\n" + mismatchString);
-        }
-        if (!expectedString.equals(actualString)) {
-            Debug.dump(expected, "mismatching graphs - expected");
-            Debug.dump(graph, "mismatching graphs - actual");
-            Assert.fail(mismatchString);
-        }
-    }
-
-    protected void assertConstantReturn(StructuredGraph graph, int value) {
-        String graphString = getCanonicalGraphString(graph);
-        Assert.assertEquals("unexpected number of ReturnNodes: " + graphString, graph.getNodes(ReturnNode.class).count(), 1);
-        ValueNode result = graph.getNodes(ReturnNode.class).first().result();
-        Assert.assertTrue("unexpected ReturnNode result node: " + graphString, result.isConstant());
-        Assert.assertEquals("unexpected ReturnNode result kind: " + graphString, result.asConstant().getKind(), Kind.Int);
-        Assert.assertEquals("unexpected ReturnNode result: " + graphString, result.asConstant().asInt(), value);
-    }
-
-    protected static String getCanonicalGraphString(StructuredGraph graph) {
-        SchedulePhase schedule = new SchedulePhase();
-        schedule.apply(graph);
-
-        NodeMap<Integer> canonicalId = graph.createNodeMap();
-        int nextId = 0;
-
-        StringBuilder result = new StringBuilder();
-        for (Block block : schedule.getCFG().getBlocks()) {
-            result.append("Block " + block + " ");
-            if (block == schedule.getCFG().getStartBlock()) {
-                result.append("* ");
-            }
-            result.append("-> ");
-            for (Block succ : block.getSuccessors()) {
-                result.append(succ + " ");
-            }
-            result.append("\n");
-            for (Node node : schedule.getBlockToNodesMap().get(block)) {
-                int id;
-                if (canonicalId.get(node) != null) {
-                    id = canonicalId.get(node);
-                } else {
-                    id = nextId++;
-                    canonicalId.set(node, id);
-                }
-                String name = node instanceof ConstantNode ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
-                result.append("  " + id + "|" + name + "    (" + node.usages().size() + ")\n");
-            }
-        }
-        return result.toString();
-    }
-
-    protected GraalCodeCacheProvider runtime() {
-        return runtime;
-    }
-
-    /**
-     * Parses a Java method to produce a graph.
-     *
-     * @param methodName the name of the method in {@code this.getClass()} to be parsed
-     */
-    protected StructuredGraph parse(String methodName) {
-        return parse(getMethod(methodName));
-    }
-
-    protected Method getMethod(String methodName) {
-        Method found = null;
-        for (Method m : this.getClass().getMethods()) {
-            if (m.getName().equals(methodName)) {
-                Assert.assertNull(found);
-                found = m;
-            }
-        }
-        if (found != null) {
-            return found;
-        } else {
-            throw new RuntimeException("method not found: " + methodName);
-        }
-    }
-
-    private static int compilationId = 0;
-
-    protected void assertEquals(Object expected, Object actual) {
-        Assert.assertEquals(expected, actual);
-    }
-
-    protected void test(String name, Object... args) {
-        Method method = getMethod(name);
-        Object expect = null;
-        Throwable exception = null;
-        try {
-            // This gives us both the expected return value as well as ensuring that the method to be compiled is fully resolved
-            expect = method.invoke(null, args);
-        } catch (InvocationTargetException e) {
-            exception = e.getTargetException();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-        InstalledCode compiledMethod = getCode(runtime.getResolvedJavaMethod(method), parse(method));
-
-        if (exception != null) {
-            try {
-                compiledMethod.executeVarargs(args);
-                Assert.fail("expected " + exception);
-            } catch (Throwable e) {
-                Assert.assertEquals(exception.getClass(), e.getClass());
-            }
-        } else {
-            Object actual = compiledMethod.executeVarargs(args);
-            assertEquals(expect, actual);
-        }
-    }
-
-    private Map<ResolvedJavaMethod, InstalledCode> cache = new HashMap<>();
-
-    /**
-     * Gets installed code for a given method and graph, compiling it first if necessary.
-     */
-    protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph) {
-        return getCode(method, graph, false);
-    }
-
-    /**
-     * Can be overridden to modify the compilation phases applied for a test.
-     *
-     * @param method the method being compiled
-     * @param graph the graph being compiled
-     * @param phasePlan the phase plan to be edited
-     */
-    protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) {
-    }
-
-    /**
-     * Gets installed code for a given method and graph, compiling it first if necessary.
-     *
-     * @param forceCompile specifies whether to ignore any previous code cached for the (method, key) pair
-     */
-    protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph, boolean forceCompile) {
-        if (!forceCompile) {
-            InstalledCode cached = cache.get(method);
-            if (cached != null && cached.isValid()) {
-                return cached;
-            }
-        }
-        InstalledCode installedCode = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable<InstalledCode>() {
-            public InstalledCode call() throws Exception {
-                PhasePlan phasePlan = new PhasePlan();
-                GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
-                phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
-                editPhasePlan(method, graph, phasePlan);
-                CompilationResult compResult = graalCompiler.compileMethod(method, graph, -1, null, phasePlan, OptimisticOptimizations.ALL);
-                return addMethod(method, compResult);
-            }
-        });
-        cache.put(method, installedCode);
-        return installedCode;
-    }
-
-    protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) {
-        assert graalCompiler != null;
-        return Debug.scope("CodeInstall", new Object[] {graalCompiler, method}, new Callable<InstalledCode>() {
-            @Override
-            public InstalledCode call() throws Exception {
-                final CodeInfo[] info = Debug.isDumpEnabled() ? new CodeInfo[1] : null;
-                InstalledCode installedMethod = runtime.addMethod(method, compResult, info);
-                if (info != null) {
-                    Debug.dump(new Object[] {compResult, info[0]}, "After code installation");
-                }
-                return installedMethod;
-            }
-        });
-    }
-
-    /**
-     * Parses a Java method to produce a graph.
-     *
-     * @param methodName the name of the method in {@code this.getClass()} to be parsed
-     */
-    protected StructuredGraph parseProfiled(String methodName) {
-        return parseProfiled(getMethod(methodName));
-    }
-
-    /**
-     * Parses a Java method to produce a graph.
-     */
-    protected StructuredGraph parse(Method m) {
-        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(m);
-        StructuredGraph graph = new StructuredGraph(javaMethod);
-        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL).apply(graph);
-        return graph;
-    }
-
-    /**
-     * Parses a Java method to produce a graph.
-     */
-    protected StructuredGraph parseProfiled(Method m) {
-        ResolvedJavaMethod javaMethod = runtime.getResolvedJavaMethod(m);
-        StructuredGraph graph = new StructuredGraph(javaMethod);
-        new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL).apply(graph);
-        return graph;
-    }
-
-    protected PhasePlan getDefaultPhasePlan() {
-        PhasePlan plan = new PhasePlan();
-        plan.addPhase(PhasePosition.AFTER_PARSING, new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.ALL));
-        return plan;
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraphScheduleTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.schedule.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.lir.cfg.*;
-import com.oracle.graal.nodes.*;
-
-public class GraphScheduleTest extends GraalCompilerTest {
-    protected void assertOrderedAfterSchedule(StructuredGraph graph, Node a, Node b) {
-        SchedulePhase ibp = new SchedulePhase();
-        ibp.apply(graph);
-        NodeMap<Block> nodeToBlock = ibp.getCFG().getNodeToBlock();
-        Block bBlock = nodeToBlock.get(b);
-        Block aBlock = nodeToBlock.get(a);
-
-        if (bBlock == aBlock) {
-            List<ScheduledNode> instructions = ibp.nodesFor(bBlock);
-            Assert.assertTrue(instructions.indexOf(b) > instructions.indexOf(a));
-        } else {
-            Block block = bBlock;
-            while (block != null) {
-                if (block == aBlock) {
-                    break;
-                }
-                block = block.getDominator();
-            }
-            Assert.assertSame(block, aBlock);
-        }
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/IfBoxingEliminationTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.compiler.phases.PhasePlan.PhasePosition;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-
-public class IfBoxingEliminationTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "referenceSnippet";
-
-    public static int referenceSnippet(int a) {
-        int result;
-        if (a < 0) {
-            result = 1;
-        } else {
-            result = 2;
-        }
-        return result;
-    }
-
-    public static Integer boxedInteger() {
-        return 1;
-    }
-
-    public static Object boxedObject() {
-        return 2;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    public static int test1Snippet(int a) {
-        Integer result;
-        if (a < 0) {
-            result = boxedInteger();
-        } else {
-            result = (Integer) boxedObject();
-        }
-        return result;
-    }
-
-    private void test(final String snippet) {
-        Debug.scope("IfBoxingEliminationTest", new DebugDumpScope(snippet), new Runnable() {
-            @Override
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                BoxingMethodPool pool = new BoxingMethodPool(runtime());
-                IdentifyBoxingPhase identifyBoxingPhase = new IdentifyBoxingPhase(pool);
-                PhasePlan phasePlan = getDefaultPhasePlan();
-                phasePlan.addPhase(PhasePosition.AFTER_PARSING, identifyBoxingPhase);
-                phasePlan.addPhase(PhasePosition.AFTER_PARSING, new PhiStampPhase());
-                identifyBoxingPhase.apply(graph);
-                Collection<Invoke> hints = new ArrayList<>();
-                for (Invoke invoke : graph.getInvokes()) {
-                    hints.add(invoke);
-                }
-                new InliningPhase(null, runtime(), hints, null, null, phasePlan, OptimisticOptimizations.ALL).apply(graph);
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                new PhiStampPhase().apply(graph);
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                Debug.dump(graph, "Graph");
-                new BoxingEliminationPhase().apply(graph);
-                Debug.dump(graph, "Graph");
-                new ExpandBoxingNodesPhase(pool).apply(graph);
-                new CanonicalizerPhase(null, runtime(), null).apply(graph);
-                new DeadCodeEliminationPhase().apply(graph);
-                StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-                new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
-                new DeadCodeEliminationPhase().apply(referenceGraph);
-
-                assertEquals(referenceGraph, graph);
-            }
-        });
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/IfCanonicalizerTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import static com.oracle.graal.graph.iterators.NodePredicates.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
- * Then canonicalization is applied and it is verified that the resulting graph is equal to the
- * graph of the method that just has a "return 1" statement in it.
- */
-public class IfCanonicalizerTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "referenceSnippet";
-
-    @SuppressWarnings("all")
-    public static int referenceSnippet(int a) {
-        return 1;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static int test1Snippet(int a) {
-        if (a == 0) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static int test2Snippet(int a) {
-        if (a == 0) {
-            if (a == 0) {
-                if (a == 0) {
-                    return 1;
-                }
-            }
-        } else {
-            return 2;
-        }
-        return 3;
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static int test3Snippet(int a) {
-        if (a == 0) {
-            if (a != 1) {
-                if (a == 1) {
-                    return 3;
-                } else {
-                    if (a >= 0) {
-                        if (a <= 0) {
-                            if (a > -1) {
-                                if (a < 1) {
-                                    return 1;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } else {
-            return 2;
-        }
-        return 3;
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet");
-    }
-
-    public static int test4Snippet(int a) {
-        if (a == 0) {
-            return 1;
-        }
-        return 1;
-    }
-
-    @Test
-    public void test5() {
-        test("test5Snippet");
-    }
-
-    public static int test5Snippet(int a) {
-        int val = 2;
-        if (a == 0) {
-            val = 1;
-        }
-        if (a * (3 + val) == 0) {
-            return 1;
-        }
-        return 1;
-    }
-
-    private void test(String snippet) {
-        StructuredGraph graph = parse(snippet);
-        LocalNode local = graph.getNodes(LocalNode.class).iterator().next();
-        ConstantNode constant = ConstantNode.forInt(0, graph);
-        for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
-            n.replaceFirstInput(local, constant);
-        }
-        Debug.dump(graph, "Graph");
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-        assertEquals(referenceGraph, graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/InvokeExceptionTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.nodes.*;
-
-public class InvokeExceptionTest extends GraalCompilerTest {
-
-    public static synchronized void throwException(int i) {
-        if (i == 1) {
-            throw new RuntimeException();
-        }
-    }
-
-    @Test
-    public void test1() {
-        // fill the profiling data...
-        for (int i = 0; i < 10000; i++) {
-            try {
-                throwException(i & 1);
-                test1Snippet(0);
-            } catch (Throwable t) {
-                // nothing to do...
-            }
-        }
-        test("test1Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static void test1Snippet(int a) {
-        throwException(a);
-    }
-
-    private void test(String snippet) {
-        StructuredGraph graph = parseProfiled(snippet);
-        Collection<Invoke> hints = new ArrayList<>();
-        for (Invoke invoke : graph.getInvokes()) {
-            hints.add(invoke);
-        }
-        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/InvokeHintsTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.nodes.*;
-
-public class InvokeHintsTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "referenceSnippet";
-
-    public static int const1() {
-        return 1;
-    }
-
-    public static int const7() {
-        return 7;
-    }
-
-    @SuppressWarnings("all")
-    public static int referenceSnippet() {
-        return 7;
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static int test1Snippet() {
-        return const7();
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static int test2Snippet() {
-        return const1() + const1() + const1() + const1() + const1() + const1() + const1();
-    }
-
-    private void test(String snippet) {
-        StructuredGraph graph = parse(snippet);
-        Collection<Invoke> hints = new ArrayList<>();
-        for (Invoke invoke : graph.getInvokes()) {
-            hints.add(invoke);
-        }
-        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-        assertEquals(referenceGraph, graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/MonitorTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import static com.oracle.graal.graph.iterators.NodePredicates.*;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.iterators.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-
-/**
- * In the following tests, the usages of local variable "a" are replaced with the integer constant 0.
- * Then canonicalization is applied and it is verified that the resulting graph is equal to the
- * graph of the method that just has a "return 1" statement in it.
- */
-public class MonitorTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "referenceSnippet";
-
-    @SuppressWarnings("all")
-    public static synchronized int referenceSnippet(int a) {
-        return 1;
-    }
-
-    public static int const1() {
-        return 1;
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    @SuppressWarnings("all")
-    public static synchronized int test1Snippet(int a) {
-        return const1();
-    }
-
-    @Test
-    public void test2() {
-        StructuredGraph graph = parseAndProcess("test2Snippet");
-        NodeIterable<MonitorExitNode> monitors = graph.getNodes(MonitorExitNode.class);
-        Assert.assertEquals(1, monitors.count());
-        Assert.assertEquals(monitors.first().stateAfter().bci, 3);
-    }
-
-    @SuppressWarnings("all")
-    public static int test2Snippet(int a) {
-        return const2();
-    }
-
-    public static synchronized int const2() {
-        return 1;
-    }
-
-    private StructuredGraph parseAndProcess(String snippet) {
-        StructuredGraph graph = parse(snippet);
-        LocalNode local = graph.getNodes(LocalNode.class).first();
-        ConstantNode constant = ConstantNode.forInt(0, graph);
-        for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
-            n.replaceFirstInput(local, constant);
-        }
-        Collection<Invoke> hints = new ArrayList<>();
-        for (Invoke invoke : graph.getInvokes()) {
-            hints.add(invoke);
-        }
-        new InliningPhase(null, runtime(), hints, null, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-        return graph;
-    }
-
-    private void test(String snippet) {
-        StructuredGraph graph = parseAndProcess(snippet);
-        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-        assertEquals(referenceGraph, graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/NestedLoopTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.lir.cfg.*;
-import com.oracle.graal.nodes.*;
-
-public class NestedLoopTest extends GraalCompilerTest {
-
-    @Test
-    public void test1() {
-        test("test1Snippet", 1, 2, 2);
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet", 1, 2, 2);
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet", 1, 2, 2);
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet", 1, 3, 2);
-    }
-
-    @SuppressWarnings("all")
-    public static void test1Snippet(int a) {
-        while (a()) { // a() exits root, while() exits root
-            m1: while (b()) { // b() exits nested & root, while() exits nested
-                while (c()) { // c() exits innermost & nested & root, while() exits innermost
-                    if (d()) { // d() exits innermost & nested & root
-                        break m1; // break exits innermost & nested
-                    }
-                }
-            }
-        }
-    }// total : root = 5 exits, nested = 5, innermost = 4
-
-    @SuppressWarnings("all")
-    public static void test2Snippet(int a) {
-        while (a()) { // a() exits root, while() exits root
-            try {
-                m1: while (b()) { // b() exits nested, while() exits nested
-                    while (c()) { // c() exits innermost & nested, while() exits innermost
-                        if (d()) { // d() exits innermost & nested
-                            break m1; // break exits innermost & nested
-                        }
-                    }
-                }
-            } catch (Throwable t) {
-            }
-        }
-    }// total : root = 2 exits, nested = 5, innermost = 4
-
-    @SuppressWarnings("all")
-    public static void test3Snippet(int a) {
-        while (a == 0) { // while() exits root
-            try {
-                m1: while (b()) { // b() exits nested, while() exits nested
-                    while (c()) { // c() exits innermost & nested, while() exits innermost
-                        if (d()) { // d() exits innermost & nested
-                            a(); // a() exits nothing (already outside innermost & nested)
-                            break m1; // break exits innermost & nested
-                        }
-                    }
-                }
-            } catch (Throwable t) {
-            }
-        }
-    }// total : root = 1 exit, nested = 5, innermost = 4
-
-    public static void test4Snippet(int a) {
-        while (a != 0) { // while() exits root
-            try {
-                m1: while (a != 0) { // while() exits nested
-                    b(); // b() exits nested
-                    while (c()) { // c() exits innermost & nested, while() exits innermost
-                        if (d()) { // d() exits innermost & nested
-                            break m1; // break exits innermost & nested
-                        }
-                    }
-                    if (a != 2) {
-                        a(); // a() exits nothing (already outside innermost & nested)
-                        throw new Exception(); // throw exits nested
-                    }
-                }
-            } catch (Throwable t) {
-            }
-        }
-    } // total : root = 1 exit, nested = 6, innermost = 4
-
-    private static boolean a() {
-        return false;
-    }
-
-    private static boolean b() {
-        return false;
-    }
-
-    private static boolean c() {
-        return false;
-    }
-
-    private static boolean d() {
-        return false;
-    }
-
-    private static Invoke getInvoke(String name, StructuredGraph graph) {
-        for (Invoke invoke : graph.getInvokes()) {
-            if (invoke.callTarget().targetMethod().name().equals(name)) {
-                return invoke;
-            }
-        }
-        return null;
-    }
-
-    private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
-        StructuredGraph graph = parse(snippet);
-        Debug.dump(graph, "Graph");
-        ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
-
-        Assert.assertTrue(cfg.getLoops().length == 3);
-        Loop rootLoop = cfg.getLoops()[0];
-        Loop nestedLoop = cfg.getLoops()[1];
-        Loop innerMostLoop = cfg.getLoops()[2];
-        Invoke a = getInvoke("a", graph);
-        Invoke b = getInvoke("b", graph);
-        Invoke c = getInvoke("c", graph);
-        Invoke d = getInvoke("d", graph);
-        Assert.assertTrue(containsDirect(rootLoop, a, cfg));
-        Assert.assertTrue(containsDirect(nestedLoop, b, cfg));
-        Assert.assertTrue(containsDirect(innerMostLoop, c, cfg));
-        Assert.assertTrue(containsDirect(innerMostLoop, d, cfg));
-        Assert.assertTrue(contains(rootLoop, d, cfg));
-        Assert.assertTrue(contains(nestedLoop, d, cfg));
-        Assert.assertEquals(rootExits, rootLoop.exits.size());
-        Assert.assertEquals(nestedExits, nestedLoop.exits.size());
-        Assert.assertEquals(innerExits, innerMostLoop.exits.size());
-        Debug.dump(graph, "Graph");
-    }
-
-    private static boolean contains(Loop loop, Invoke node, ControlFlowGraph cfg) {
-        Block block = cfg.blockFor((Node) node);
-        Assert.assertNotNull(block);
-        return loop.blocks.contains(block);
-    }
-
-    private static boolean containsDirect(Loop loop, Invoke node, ControlFlowGraph cfg) {
-        for (Loop child : loop.children) {
-            if (contains(child, node, cfg)) {
-                return false;
-            }
-        }
-        return contains(loop, node, cfg);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/PhiCreationTests.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * In the following tests, the correct removal of redundant phis during graph building is tested.
- */
-public class PhiCreationTests extends GraalCompilerTest {
-
-    /**
-     * Dummy method to avoid javac dead code elimination.
-     */
-    private static void test() {
-    }
-
-    @Test
-    public void test1() {
-        StructuredGraph graph = parse("test1Snippet");
-        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
-    }
-
-    public static int test1Snippet(int a) {
-        if (a > 1) {
-            test();
-        }
-        return a;
-    }
-
-    @Test
-    public void test2() {
-        StructuredGraph graph = parse("test2Snippet");
-        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
-    }
-
-    public static int test2Snippet(int a) {
-        while (a > 1) {
-            test();
-        }
-        return a;
-    }
-
-    @Test
-    public void test3() {
-        StructuredGraph graph = parse("test3Snippet");
-        Debug.dump(graph, "Graph");
-        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
-    }
-
-    public static int test3Snippet(int a) {
-        while (a > 1) {
-            while (a > 1) {
-                test();
-            }
-        }
-        return a;
-    }
-
-    @Test
-    public void test4() {
-        StructuredGraph graph = parse("test4Snippet");
-        Debug.dump(graph, "Graph");
-        Assert.assertFalse(graph.getNodes(PhiNode.class).iterator().hasNext());
-    }
-
-    public static int test4Snippet(int a) {
-        int b = 5;
-        while (a > 1) {
-            while (a > 1) {
-                while (a > 1) {
-                    try {
-                        test();
-                    } catch (Throwable t) {
-
-                    }
-                }
-            }
-            while (a > 1) {
-                while (a > 1) {
-                    try {
-                        test();
-                    } catch (Throwable t) {
-
-                    }
-                }
-            }
-        }
-        return a + b;
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ReassociateAndCanonicalTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-
-public class ReassociateAndCanonicalTest extends GraalCompilerTest {
-    public static int rnd = (int) (Math.random() * 100);
-
-    @Test
-    public void test1() {
-        test("test1Snippet", "ref1Snippet");
-    }
-
-    public static int test1Snippet() {
-        return 1 + (rnd + 2);
-    }
-
-    public static int ref1Snippet() {
-        return rnd + 3;
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet", "ref2Snippet");
-    }
-
-    public static int test2Snippet() {
-        return rnd + 3;
-    }
-
-    public static int ref2Snippet() {
-        return (rnd + 2) + 1;
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet", "ref3Snippet");
-    }
-
-    public static int test3Snippet() {
-        return rnd + 3;
-    }
-
-    public static int ref3Snippet() {
-        return 1 + (2 + rnd);
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet", "ref4Snippet");
-    }
-
-    public static int test4Snippet() {
-        return rnd + 3;
-    }
-
-    public static int ref4Snippet() {
-        return (2 + rnd) + 1;
-    }
-
-    @Test
-    public void test5() {
-        test("test5Snippet", "ref5Snippet");
-    }
-
-    public static int test5Snippet() {
-        return -1 - rnd;
-    }
-
-    public static int ref5Snippet() {
-        return 1 - (rnd + 2);
-    }
-
-    @Test
-    public void test6() {
-        test("test6Snippet", "ref6Snippet");
-    }
-
-    public static int test6Snippet() {
-        return rnd + 1;
-    }
-
-    public static int ref6Snippet() {
-        return (rnd + 2) - 1;
-    }
-
-    @Test
-    public void test7() {
-        test("test7Snippet", "ref7Snippet");
-    }
-
-    public static int test7Snippet() {
-        return -1 - rnd;
-    }
-
-    public static int ref7Snippet() {
-        return 1 - (2 + rnd);
-    }
-
-    @Test
-    public void test8() {
-        test("test8Snippet", "ref8Snippet");
-    }
-
-    public static int test8Snippet() {
-        return rnd + 1;
-    }
-
-    public static int ref8Snippet() {
-        return (2 + rnd) - 1;
-    }
-
-    @Test
-    public void test9() {
-        test("test9Snippet", "ref9Snippet");
-    }
-
-    public static int test9Snippet() {
-        return rnd - 1;
-    }
-
-    public static int ref9Snippet() {
-        return 1 + (rnd - 2);
-    }
-
-    @Test
-    public void test10() {
-        test("test10Snippet", "ref10Snippet");
-    }
-
-    public static int test10Snippet() {
-        return rnd - 1;
-    }
-
-    public static int ref10Snippet() {
-        return (rnd - 2) + 1;
-    }
-
-    @Test
-    public void test11() {
-        test("test11Snippet", "ref11Snippet");
-    }
-
-    public static int test11Snippet() {
-        return -rnd + 3;
-    }
-
-    public static int ref11Snippet() {
-        return 1 + (2 - rnd);
-    }
-
-    @Test
-    public void test12() {
-        test("test12Snippet", "ref12Snippet");
-    }
-
-    public static int test12Snippet() {
-        return -rnd + 3;
-    }
-
-    public static int ref12Snippet() {
-        return (2 - rnd) + 1;
-    }
-
-    @Test
-    public void test13() {
-        test("test13Snippet", "ref13Snippet");
-    }
-
-    public static int test13Snippet() {
-        return -rnd + 3;
-    }
-
-    public static int ref13Snippet() {
-        return 1 - (rnd - 2);
-    }
-
-    @Test
-    public void test14() {
-        test("test14Snippet", "ref14Snippet");
-    }
-
-    public static int test14Snippet() {
-        return rnd - 3;
-    }
-
-    public static int ref14Snippet() {
-        return (rnd - 2) - 1;
-    }
-
-    @Test
-    public void test15() {
-        test("test15Snippet", "ref15Snippet");
-    }
-
-    public static int test15Snippet() {
-        return rnd + -1;
-    }
-
-    public static int ref15Snippet() {
-        return 1 - (2 - rnd);
-    }
-
-    @Test
-    public void test16() {
-        test("test16Snippet", "ref16Snippet");
-    }
-
-    public static int test16Snippet() {
-        return -rnd + 1;
-    }
-
-    public static int ref16Snippet() {
-        return (2 - rnd) - 1;
-    }
-
-    private <T extends Node & Node.IterableNodeType> void test(String test, String ref) {
-        StructuredGraph testGraph = parse(test);
-        new CanonicalizerPhase(null, runtime(), null).apply(testGraph);
-        StructuredGraph refGraph = parse(ref);
-        new CanonicalizerPhase(null, runtime(), null).apply(refGraph);
-        assertEquals(testGraph, refGraph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ScalarTypeSystemTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * In the following tests, the scalar type system of the compiler should be complete enough to see the relation between the different conditions.
- */
-public class ScalarTypeSystemTest extends GraalCompilerTest {
-
-    public static int referenceSnippet1(int a) {
-        if (a > 0) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test1() {
-        test("test1Snippet", "referenceSnippet1");
-    }
-
-    public static int test1Snippet(int a) {
-        if (a > 0) {
-            if (a > -1) {
-                return 1;
-            } else {
-                return 3;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test2() {
-        test("test2Snippet", "referenceSnippet1");
-    }
-
-    public static int test2Snippet(int a) {
-        if (a > 0) {
-            if (a == -15) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test3() {
-        test("test3Snippet", "referenceSnippet2");
-    }
-
-    public static int referenceSnippet2(int a, int b) {
-        if (a > b) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    public static int test3Snippet(int a, int b) {
-        if (a > b) {
-            if (a == b) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet", "referenceSnippet2");
-    }
-
-    public static int test4Snippet(int a, int b) {
-        if (a > b) {
-            if (a <= b) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test5() {
-        test("test5Snippet", "referenceSnippet3");
-    }
-
-    public static int referenceSnippet3(int a, int b) {
-        if (a == b) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    public static int test5Snippet(int a, int b) {
-        if (a == b) {
-            if (a != b) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test6() {
-        test("test6Snippet", "referenceSnippet3");
-    }
-
-    public static int test6Snippet(int a, int b) {
-        if (a == b) {
-            if (a == b + 1) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    private void test(final String snippet, final String referenceSnippet) {
-        // No debug scope to reduce console noise for @Test(expected = ...) tests
-        StructuredGraph graph = parse(snippet);
-        Debug.dump(graph, "Graph");
-//        TypeSystemTest.outputGraph(graph);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new CheckCastEliminationPhase().apply(graph);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        StructuredGraph referenceGraph = parse(referenceSnippet);
-        assertEquals(referenceGraph, graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/StampCanonicalizerTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2012, 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.type.*;
-
-/**
- * This class tests some specific patterns the stamp system should be able to canonicalize away using
- * {@link IntegerStamp#mask()}.
- */
-public class StampCanonicalizerTest extends GraalCompilerTest {
-
-    public static int andStamp(int a, int b) {
-        int v = (a & 0xffff00) & (b & 0xff0000f);
-        return v & 1;
-    }
-
-    @Test
-    public void testAnd() {
-        testZeroReturn("andStamp");
-    }
-
-    public static int shiftLeftStamp1(int a) {
-        int v = a << 1;
-        return v & 1;
-    }
-
-    public static int shiftLeftStamp2(int a) {
-        int v = a << 1;
-        if (a == 17) {
-            v = a * 4;
-        }
-        return v & 1;
-    }
-
-    @Test
-    public void testShift() {
-        testZeroReturn("shiftLeftStamp1");
-        testZeroReturn("shiftLeftStamp2");
-    }
-
-    public static int upperBoundShiftStamp1(int a) {
-        int v = a & 0xffff;
-        return (v << 4) & 0xff00000;
-    }
-
-    public static int upperBoundShiftStamp2(int a) {
-        int v = a & 0xffff;
-        return (v >> 4) & 0xf000;
-    }
-
-    @Test
-    public void testUpperBoundShift() {
-        testZeroReturn("upperBoundShiftStamp1");
-        testZeroReturn("upperBoundShiftStamp2");
-    }
-
-    public static int divStamp1(int[] a) {
-        int v = a.length / 4;
-        return v & 0x80000000;
-    }
-
-    public static int divStamp2(int[] a) {
-        int v = a.length / 5;
-        return v & 0x80000000;
-    }
-
-    @Test
-    public void testDiv() {
-        testZeroReturn("divStamp1");
-        testZeroReturn("divStamp2");
-    }
-
-    private void testZeroReturn(String methodName) {
-        StructuredGraph graph = parse(methodName);
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        new DeadCodeEliminationPhase().apply(graph);
-        assertConstantReturn(graph, 0);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/StraighteningTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-
-public class StraighteningTest extends GraalCompilerTest {
-
-    private static final String REFERENCE_SNIPPET = "ref";
-
-    public static boolean ref(int a, int b) {
-        return a == b;
-    }
-
-    public static boolean test1Snippet(int a, int b) {
-        int c = a;
-        if (c == b) {
-            c = 0x55;
-        }
-        if (c != 0x55) {
-            return false;
-        }
-        return true;
-    }
-
-    public static boolean test3Snippet(int a, int b) {
-        int val = (int) System.currentTimeMillis();
-        int c = val + 1;
-        if (a == b) {
-            c = val;
-        }
-        if (c != val) {
-            return false;
-        }
-        return true;
-    }
-
-    public static boolean test2Snippet(int a, int b) {
-        int c;
-        if (a == b) {
-            c = 1;
-        } else {
-            c = 0;
-        }
-        return c == 1;
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test2() {
-        test("test2Snippet");
-    }
-
-    @Test(expected = AssertionError.class)
-    public void test3() {
-        test("test3Snippet");
-    }
-
-    private void test(final String snippet) {
-        // No debug scope to reduce console noise for @Test(expected = ...) tests
-        StructuredGraph graph = parse(snippet);
-        Debug.dump(graph, "Graph");
-        new CanonicalizerPhase(null, runtime(), null).apply(graph);
-        StructuredGraph referenceGraph = parse(REFERENCE_SNIPPET);
-        assertEquals(referenceGraph, graph);
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/TypeSystemTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 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.graal.compiler.tests;
-
-import java.io.*;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-import com.oracle.graal.compiler.phases.*;
-import com.oracle.graal.compiler.schedule.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.lir.cfg.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-
-/**
- * In the following tests, the scalar type system of the compiler should be complete enough to see the relation between the different conditions.
- */
-public class TypeSystemTest extends GraalCompilerTest {
-
-    @Test
-    public void test1() {
-        test("test1Snippet", CheckCastNode.class);
-    }
-
-    public static int test1Snippet(Object a) {
-        if (a instanceof Boolean) {
-            return ((Boolean) a).booleanValue() ? 0 : 1;
-        }
-        return 1;
-    }
-
-    @Test
-    public void test2() {
-        test("test2Snippet", CheckCastNode.class);
-    }
-
-    public static int test2Snippet(Object a) {
-        if (a instanceof Integer) {
-            return ((Number) a).intValue();
-        }
-        return 1;
-    }
-
-    @Test
-    public void test3() {
-        test("test3Snippet", "referenceSnippet3");
-    }
-
-    public static int referenceSnippet3(Object o) {
-        if (o == null) {
-            return 1;
-        } else {
-            return 2;
-        }
-    }
-
-    @SuppressWarnings("unused")
-    public static int test3Snippet(Object o) {
-        if (o == null) {
-            if (o != null) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test4() {
-        test("test4Snippet", "referenceSnippet3");
-    }
-
-    public static final Object constantObject1 = "1";
-    public static final Object constantObject2 = "2";
-    public static final Object constantObject3 = "3";
-
-    public static int test4Snippet(Object o) {
-        if (o == null) {
-            if (o == constantObject1) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test5() {
-        test("test5Snippet", "referenceSnippet5");
-    }
-
-    public static int referenceSnippet5(Object o, Object a) {
-        if (o == null) {
-            if (a == constantObject1 || a == constantObject2) {
-                return 1;
-            }
-        } else {
-            if (a == constantObject2 || a == constantObject3) {
-                if (a != null) {
-                    return 11;
-                }
-                return 2;
-            }
-        }
-        if (a == constantObject1) {
-            return 3;
-        }
-        return 5;
-    }
-
-    public static int test5Snippet(Object o, Object a) {
-        if (o == null) {
-            if (a == constantObject1 || a == constantObject2) {
-                if (a == null) {
-                    return 10;
-                }
-                return 1;
-            }
-        } else {
-            if (a == constantObject2 || a == constantObject3) {
-                if (a != null) {
-                    return 11;
-                }
-                return 2;
-            }
-        }
-        if (a == constantObject1) {
-            return 3;
-        }
-        if (a == constantObject2) {
-            return 4;
-        }
-        return 5;
-    }
-
-    @Test
-    public void test6() {
-        test("test6Snippet", CheckCastNode.class);
-    }
-
-    public static int test6Snippet(int i) throws IOException {
-        Object o = null;
-
-        if (i == 5) {
-            o = new FileInputStream("asdf");
-        }
-        if (i < 10) {
-            o = new ByteArrayInputStream(new byte[]{1, 2, 3});
-        }
-        if (i > 0) {
-            o = new BufferedInputStream(null);
-        }
-
-        return ((InputStream) o).available();
-    }
-
-    @SuppressWarnings("unused")
-    private void test(String snippet, String referenceSnippet) {
-        // TODO(ls) temporarily disabled, reintroduce when a proper type system is available
-        if (false) {
-            StructuredGraph graph = parse(snippet);
-            Debug.dump(graph, "Graph");
-            new CanonicalizerPhase(null, runtime(), null).apply(graph);
-            new CheckCastEliminationPhase().apply(graph);
-            new CanonicalizerPhase(null, runtime(), null).apply(graph);
-            new GlobalValueNumberingPhase().apply(graph);
-            StructuredGraph referenceGraph = parse(referenceSnippet);
-            new CanonicalizerPhase(null, runtime(), null).apply(referenceGraph);
-            new GlobalValueNumberingPhase().apply(referenceGraph);
-            assertEquals(referenceGraph, graph);
-        }
-    }
-
-    @Override
-    protected void assertEquals(StructuredGraph expected, StructuredGraph graph) {
-        if (expected.getNodeCount() != graph.getNodeCount()) {
-//            Debug.dump(expected, "Node count not matching - expected");
-//            Debug.dump(graph, "Node count not matching - actual");
-//            System.out.println("================ expected");
-//            outputGraph(expected);
-//            System.out.println("================ actual");
-//            outputGraph(graph);
-//            new IdealGraphPrinterDumpHandler().dump(graph, "asdf");
-            Assert.fail("Graphs do not have the same number of nodes: " + expected.getNodeCount() + " vs. " + graph.getNodeCount());
-        }
-    }
-
-    public static void outputGraph(StructuredGraph graph) {
-        SchedulePhase schedule = new SchedulePhase();
-        schedule.apply(graph);
-        for (Block block : schedule.getCFG().getBlocks()) {
-            System.out.print("Block " + block + " ");
-            if (block == schedule.getCFG().getStartBlock()) {
-                System.out.print("* ");
-            }
-            System.out.print("-> ");
-            for (Block succ : block.getSuccessors()) {
-                System.out.print(succ + " ");
-            }
-            System.out.println();
-            for (Node node : schedule.getBlockToNodesMap().get(block)) {
-                System.out.println("  " + node + "    (" + node.usages().size() + ")");
-            }
-        }
-    }
-
-    @SuppressWarnings("unused")
-    private <T extends Node & Node.IterableNodeType> void test(String snippet, Class<T> clazz) {
-        // TODO(ls) temporarily disabled, reintroduce when a proper type system is available
-        if (false) {
-            StructuredGraph graph = parse(snippet);
-            Debug.dump(graph, "Graph");
-            new CanonicalizerPhase(null, runtime(), null).apply(graph);
-            new CheckCastEliminationPhase().apply(graph);
-            new CanonicalizerPhase(null, runtime(), null).apply(graph);
-            Debug.dump(graph, "Graph");
-            Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes(clazz).iterator().hasNext());
-        }
-    }
-}
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/cfg/SimpleCFGTest.java	Fri Sep 07 16:08:23 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2012, 2012, 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.graal.compiler.tests.cfg;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.graal.lir.cfg.*;
-import com.oracle.graal.nodes.*;
-
-public class SimpleCFGTest {
-
-    @Test
-    public void testImplies() {
-        StructuredGraph graph = new StructuredGraph();
-
-        EndNode trueEnd = graph.add(new EndNode());
-        EndNode falseEnd = graph.add(new EndNode());
-
-        BeginNode trueBegin = graph.add(new BeginNode());
-        trueBegin.setNext(trueEnd);
-        BeginNode falseBegin = graph.add(new BeginNode());
-        falseBegin.setNext(falseEnd);
-
-        IfNode ifNode = graph.add(new IfNode(null, trueBegin, falseBegin, 0.5, graph.graphId()));
-        graph.start().setNext(ifNode);
-
-        MergeNode merge = graph.add(new MergeNode());
-        merge.addForwardEnd(trueEnd);
-        merge.addForwardEnd(falseEnd);
-        ReturnNode returnNode = graph.add(new ReturnNode(null));
-        merge.setNext(returnNode);
-
-        ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
-
-        Block[] blocks = cfg.getBlocks();
-        // check number of blocks
-        assertEquals(4, blocks.length);
-
-        // check block - node assignment
-        assertEquals(blocks[0], cfg.blockFor(graph.start()));
-        assertEquals(blocks[0], cfg.blockFor(ifNode));
-        assertEquals(blocks[1], cfg.blockFor(trueBegin));
-        assertEquals(blocks[1], cfg.blockFor(trueEnd));
-        assertEquals(blocks[2], cfg.blockFor(falseBegin));
-        assertEquals(blocks[2], cfg.blockFor(falseEnd));
-        assertEquals(blocks[3], cfg.blockFor(merge));
-        assertEquals(blocks[3], cfg.blockFor(returnNode));
-
-        // check dominators
-        assertDominator(blocks[0], null);
-        assertDominator(blocks[1], blocks[0]);
-        assertDominator(blocks[2], blocks[0]);
-        assertDominator(blocks[3], blocks[0]);
-
-        // check dominated
-        assertDominatedSize(blocks[0], 3);
-        assertDominatedSize(blocks[1], 0);
-        assertDominatedSize(blocks[2], 0);
-        assertDominatedSize(blocks[3], 0);
-
-        // check postdominators
-        assertPostdominator(blocks[0], blocks[3]);
-        assertPostdominator(blocks[1], blocks[3]);
-        assertPostdominator(blocks[2], blocks[3]);
-        assertPostdominator(blocks[3], null);
-    }
-
-    public static void assertDominator(Block block, Block expectedDominator) {
-        assertEquals("dominator of " + block, expectedDominator, block.getDominator());
-    }
-
-    public static void assertDominatedSize(Block block, int size) {
-        assertEquals("number of dominated blocks of " + block, size, block.getDominated().size());
-    }
-
-    public static void assertPostdominator(Block block, Block expectedPostdominator) {
-        assertEquals("postdominator of " + block, expectedPostdominator, block.getPostdominator());
-    }
-
-}
--- a/mx/projects	Fri Sep 07 16:08:23 2012 +0200
+++ b/mx/projects	Fri Sep 07 16:25:49 2012 +0200
@@ -119,7 +119,7 @@
 # graal.snippets.test
 project@com.oracle.graal.snippets.test@subDir=graal
 project@com.oracle.graal.snippets.test@sourceDirs=src
-project@com.oracle.graal.snippets.test@dependencies=com.oracle.graal.snippets,com.oracle.graal.tests
+project@com.oracle.graal.snippets.test@dependencies=com.oracle.graal.snippets,com.oracle.graal.compiler.test
 project@com.oracle.graal.snippets.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.snippets.test@javaCompliance=1.7
 
@@ -178,12 +178,12 @@
 project@com.oracle.graal.printer@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.printer@javaCompliance=1.7
 
-# graal.test
-project@com.oracle.graal.tests@subDir=graal
-project@com.oracle.graal.tests@sourceDirs=src
-project@com.oracle.graal.tests@dependencies=JUNIT,com.oracle.graal.printer,com.oracle.graal.api
-project@com.oracle.graal.tests@checkstyle=com.oracle.graal.graph
-project@com.oracle.graal.tests@javaCompliance=1.7
+# graal.compiler.test
+project@com.oracle.graal.compiler.test@subDir=graal
+project@com.oracle.graal.compiler.test@sourceDirs=src
+project@com.oracle.graal.compiler.test@dependencies=JUNIT,com.oracle.graal.printer,com.oracle.graal.api
+project@com.oracle.graal.compiler.test@checkstyle=com.oracle.graal.graph
+project@com.oracle.graal.compiler.test@javaCompliance=1.7
 
 # graal.jtt
 project@com.oracle.graal.jtt@subDir=graal