changeset 9202:b6629b739a55

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 22 Apr 2013 09:54:57 +0200
parents 59db04ec1598 (current diff) 9be78aeab2e1 (diff)
children f78437ffb8d3
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCast.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicConfiguration.java
diffstat 46 files changed, 896 insertions(+), 280 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java	Mon Apr 22 09:54:57 2013 +0200
@@ -29,6 +29,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.Register.RegisterFlag;
+import com.oracle.graal.api.meta.*;
 
 /**
  * Represents the AMD64 architecture.
@@ -105,7 +106,10 @@
         rip
     };
 
-    public AMD64() {
+    private final int supportedSSEVersion;
+    private final int supportedAVXVersion;
+
+    public AMD64(int supportedSSEVersion, int supportedAVXVersion) {
         super("AMD64",
               8,
               ByteOrder.LITTLE_ENDIAN,
@@ -114,6 +118,65 @@
               1,
               r15.encoding + 1,
               8);
+        assert supportedSSEVersion >= 2;
+        this.supportedSSEVersion = supportedSSEVersion;
+        this.supportedAVXVersion = supportedAVXVersion;
     }
     // @formatter:on
+
+    @Override
+    public int getMaxVectorLength(Kind kind) {
+        if (supportedAVXVersion > 0) {
+            switch (kind) {
+                case Boolean:
+                    return 32;
+                case Byte:
+                    return 32;
+                case Short:
+                    return 16;
+                case Char:
+                    return 16;
+                case Int:
+                    return 8;
+                case Float:
+                    return 8;
+                case Long:
+                    return 4;
+                case Double:
+                    return 4;
+                case Object:
+                    return 4;
+            }
+        } else {
+            switch (kind) {
+                case Boolean:
+                    return 16;
+                case Byte:
+                    return 16;
+                case Short:
+                    return 8;
+                case Char:
+                    return 8;
+                case Int:
+                    return 4;
+                case Float:
+                    return 4;
+                case Long:
+                    return 2;
+                case Double:
+                    return 2;
+                case Object:
+                    return 2;
+            }
+        }
+        return 1;
+    }
+
+    public int getSupportedSSEVersion() {
+        return supportedSSEVersion;
+    }
+
+    public int getSupportedAVXVersion() {
+        return supportedAVXVersion;
+    }
 }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java	Mon Apr 22 09:54:57 2013 +0200
@@ -24,6 +24,8 @@
 
 import java.nio.*;
 
+import com.oracle.graal.api.meta.*;
+
 /**
  * Represents a CPU architecture, including information such as its endianness, CPU registers, word
  * width, etc.
@@ -154,4 +156,12 @@
     public final int requiredBarriers(int barriers) {
         return barriers & ~implicitMemoryBarriers;
     }
+
+    /**
+     * Determine the maximum vector length supported for vector operations on values of a given
+     * {@link Kind}.
+     */
+    public int getMaxVectorLength(@SuppressWarnings("unused") Kind kind) {
+        return 1;
+    }
 }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Mon Apr 22 09:54:57 2013 +0200
@@ -196,6 +196,16 @@
     }
 
     /**
+     * Gets a hash code for this register.
+     * 
+     * @return the value of {@link #number}
+     */
+    @Override
+    public int hashCode() {
+        return number;
+    }
+
+    /**
      * Categorizes a set of registers by {@link RegisterFlag}.
      * 
      * @param registers a list of registers to be categorized
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetTemplateCache.java	Mon Apr 22 09:54:57 2013 +0200
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, 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.api.replacements;
+
+/**
+ * Marker interface for classes that cache snippet templates.
+ */
+public interface SnippetTemplateCache {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java	Mon Apr 22 09:54:57 2013 +0200
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013, 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.concurrent.*;
+
+import junit.framework.Assert;
+
+import org.junit.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.phases.common.*;
+
+public class EliminateNestedCheckCastsTest extends GraalCompilerTest {
+
+    public static long test1Snippet(A1 a1) {
+        A2 a2 = (A2) a1;
+        A3 a3 = (A3) a2;
+        A4 a4 = (A4) a3;
+        A5 a5 = (A5) a4;
+        A6 a6 = (A6) a5;
+        return a6.x6;
+    }
+
+    @Test
+    public void test1() {
+        compileSnippet("test1Snippet", 5, 1);
+    }
+
+    public static long test2Snippet(A1 a1) {
+        A2 a2 = (A2) a1;
+        A3 a3 = (A3) a2;
+        A4 a4 = (A4) a3;
+        A5 a5 = (A5) a4;
+        A6 a6 = (A6) a5;
+        // as a3 has an usage, thus don't remove the A3 checkcast.
+        return a3.x2 + a6.x6;
+    }
+
+    @Test
+    public void test2() {
+        compileSnippet("test2Snippet", 5, 2);
+    }
+
+    private StructuredGraph compileSnippet(final String snippet, final int checkcasts, final int afterCanon) {
+        return Debug.scope(snippet, new Callable<StructuredGraph>() {
+
+            @Override
+            public StructuredGraph call() throws Exception {
+                StructuredGraph graph = parse(snippet);
+                Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count());
+                new CanonicalizerPhase.Instance(runtime(), null).apply(graph);
+                Assert.assertEquals(afterCanon, graph.getNodes(CheckCastNode.class).count());
+                return graph;
+            }
+
+        });
+    }
+
+    public static class A1 {
+
+        public long x1 = 1;
+    }
+
+    public static class A2 extends A1 {
+
+        public long x2 = 2;
+    }
+
+    public static class A3 extends A2 {
+
+        public long x3 = 3;
+    }
+
+    public static class A4 extends A3 {
+
+        public long x4 = 4;
+    }
+
+    public static class A5 extends A4 {
+
+        public long x5 = 5;
+    }
+
+    public static class A6 extends A5 {
+
+        public long x6 = 6;
+    }
+}
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCast.java	Wed Apr 17 23:16:50 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2013, 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.api.code.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.phases.common.*;
-
-/* consider
- *     B b = (B) a;
- *     return b.x10;
- *
- * With snippets a typecheck is performed and if it was successful, a UnsafeCastNode is created.
- * For the read node, however, there is only a dependency to the UnsafeCastNode, but not to the
- * typecheck itself. With special crafting, it's possible to get the scheduler moving the
- * FloatingReadNode before the typecheck. Assuming the object is of the wrong type (here for
- * example A), an invalid field read is done.
- *
- * In order to avoid this situation, an anchor node is introduced in CheckCastSnippts.
- */
-
-public class ReadAfterCheckCast extends GraphScheduleTest {
-
-    public static long foo = 0;
-
-    public static class A {
-
-        public long x1;
-    }
-
-    public static class B extends A {
-
-        public long x10;
-    }
-
-    public static long test1Snippet(A a) {
-        if (foo > 4) {
-            B b = (B) a;
-            b.x10 += 1;
-            return b.x10;
-        } else {
-            B b = (B) a;
-            b.x10 += 1;
-            return b.x10;
-        }
-    }
-
-    @Test
-    public void test1() {
-        test("test1Snippet");
-    }
-
-    private void test(final String snippet) {
-        Debug.scope("FloatingReadTest", new DebugDumpScope(snippet), new Runnable() {
-
-            // check shape of graph, with lots of assumptions. will probably fail if graph
-            // structure changes significantly
-            public void run() {
-                StructuredGraph graph = parse(snippet);
-                new LoweringPhase(null, runtime(), replacements, new Assumptions(false)).apply(graph);
-                new FloatingReadPhase().apply(graph);
-                new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph);
-                new ReadEliminationPhase().apply(graph);
-                new CanonicalizerPhase.Instance(runtime(), null).apply(graph);
-
-                Debug.dump(graph, "After lowering");
-
-                ArrayList<MergeNode> merges = new ArrayList<>();
-                ArrayList<FloatingReadNode> reads = new ArrayList<>();
-                for (Node n : graph.getNodes()) {
-                    if (n instanceof MergeNode) {
-                        // check shape
-                        MergeNode merge = (MergeNode) n;
-
-                        if (merge.inputs().count() == 2) {
-                            for (EndNode m : merge.forwardEnds()) {
-                                if (m.predecessor() != null && m.predecessor() instanceof BeginNode && m.predecessor().predecessor() instanceof IfNode) {
-                                    IfNode o = (IfNode) m.predecessor().predecessor();
-                                    if (o.falseSuccessor().next() instanceof DeoptimizeNode) {
-                                        merges.add(merge);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                    if (n instanceof IntegerAddNode) {
-                        IntegerAddNode ian = (IntegerAddNode) n;
-
-                        Assert.assertTrue(ian.y() instanceof ConstantNode);
-                        Assert.assertTrue(ian.x() instanceof FloatingReadNode);
-                        reads.add((FloatingReadNode) ian.x());
-                    }
-                }
-
-                Assert.assertTrue(merges.size() >= reads.size());
-                for (int i = 0; i < reads.size(); i++) {
-                    assertOrderedAfterSchedule(graph, merges.get(i), reads.get(i));
-                }
-            }
-        });
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java	Mon Apr 22 09:54:57 2013 +0200
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013, 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.api.code.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.phases.common.*;
+
+/* consider
+ *     B b = (B) a;
+ *     return b.x10;
+ *
+ * With snippets a typecheck is performed and if it was successful, a UnsafeCastNode is created.
+ * For the read node, however, there is only a dependency to the UnsafeCastNode, but not to the
+ * typecheck itself. With special crafting, it's possible to get the scheduler moving the
+ * FloatingReadNode before the typecheck. Assuming the object is of the wrong type (here for
+ * example A), an invalid field read is done.
+ *
+ * In order to avoid this situation, an anchor node is introduced in CheckCastSnippts.
+ */
+
+public class ReadAfterCheckCastTest extends GraphScheduleTest {
+
+    public static long foo = 0;
+
+    public static class A {
+
+        public long x1;
+    }
+
+    public static class B extends A {
+
+        public long x10;
+    }
+
+    public static long test1Snippet(A a) {
+        if (foo > 4) {
+            B b = (B) a;
+            b.x10 += 1;
+            return b.x10;
+        } else {
+            B b = (B) a;
+            b.x10 += 1;
+            return b.x10;
+        }
+    }
+
+    @Test
+    public void test1() {
+        test("test1Snippet");
+    }
+
+    private void test(final String snippet) {
+        Debug.scope("FloatingReadTest", new DebugDumpScope(snippet), new Runnable() {
+
+            // check shape of graph, with lots of assumptions. will probably fail if graph
+            // structure changes significantly
+            public void run() {
+                StructuredGraph graph = parse(snippet);
+                new LoweringPhase(null, runtime(), replacements, new Assumptions(false)).apply(graph);
+                new FloatingReadPhase().apply(graph);
+                new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph);
+                new ReadEliminationPhase().apply(graph);
+                new CanonicalizerPhase.Instance(runtime(), null).apply(graph);
+
+                Debug.dump(graph, "After lowering");
+
+                ArrayList<MergeNode> merges = new ArrayList<>();
+                ArrayList<FloatingReadNode> reads = new ArrayList<>();
+                for (Node n : graph.getNodes()) {
+                    if (n instanceof MergeNode) {
+                        // check shape
+                        MergeNode merge = (MergeNode) n;
+
+                        if (merge.inputs().count() == 2) {
+                            for (EndNode m : merge.forwardEnds()) {
+                                if (m.predecessor() != null && m.predecessor() instanceof BeginNode && m.predecessor().predecessor() instanceof IfNode) {
+                                    IfNode o = (IfNode) m.predecessor().predecessor();
+                                    if (o.falseSuccessor().next() instanceof DeoptimizeNode) {
+                                        merges.add(merge);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if (n instanceof IntegerAddNode) {
+                        IntegerAddNode ian = (IntegerAddNode) n;
+
+                        Assert.assertTrue(ian.y() instanceof ConstantNode);
+                        Assert.assertTrue(ian.x() instanceof FloatingReadNode);
+                        reads.add((FloatingReadNode) ian.x());
+                    }
+                }
+
+                Assert.assertTrue(merges.size() >= reads.size());
+                for (int i = 0; i < reads.size(); i++) {
+                    assertOrderedAfterSchedule(graph, merges.get(i), reads.get(i));
+                }
+            }
+        });
+    }
+}
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Apr 22 09:54:57 2013 +0200
@@ -143,7 +143,7 @@
 
         new LoweringPhase(target, runtime, replacements, assumptions).apply(graph);
 
-        MidTierContext midTierContext = new MidTierContext(runtime, assumptions);
+        MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements);
         Suites.DEFAULT.getMidTier().apply(graph, midTierContext);
 
         plan.runPhases(PhasePosition.MID_LEVEL, graph);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java	Mon Apr 22 09:54:57 2013 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013, 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.phases;
+
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.tiers.*;
+
+@ServiceProvider(CompilerConfiguration.class)
+public class BasicCompilerConfiguration implements CompilerConfiguration {
+
+    public PhaseSuite<HighTierContext> createHighTier() {
+        return new HighTier();
+    }
+
+    public PhaseSuite<MidTierContext> createMidTier() {
+        return new MidTier();
+    }
+}
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicConfiguration.java	Wed Apr 17 23:16:50 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2013, 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.phases;
-
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.tiers.*;
-
-@ServiceProvider(CompilerConfiguration.class)
-public class BasicConfiguration implements CompilerConfiguration {
-
-    public PhaseSuite<HighTierContext> createHighTier() {
-        return new HighTier();
-    }
-
-    public PhaseSuite<MidTierContext> createMidTier() {
-        return new MidTier();
-    }
-}
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Mon Apr 22 09:54:57 2013 +0200
@@ -76,9 +76,26 @@
         return callable;
     }
 
-    public static void sandbox(String name, Runnable runnable) {
+    public static void sandbox(String name, DebugConfig config, Runnable runnable) {
         if (ENABLED) {
-            DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]);
+            DebugScope.getInstance().scope(name, runnable, null, true, config, new Object[0]);
+        } else {
+            runnable.run();
+        }
+    }
+
+    /**
+     * Creates a new debug scope that is unrelated to the current scope and runs a given task in the
+     * new scope.
+     * 
+     * @param name new scope name
+     * @param context the context objects of the new scope
+     * @param config the debug configuration to use for the new scope
+     * @param runnable the task to run in the new scope
+     */
+    public static void sandbox(String name, Object[] context, DebugConfig config, Runnable runnable) {
+        if (ENABLED) {
+            DebugScope.getInstance().scope(name, runnable, null, true, config, context);
         } else {
             runnable.run();
         }
@@ -98,7 +115,7 @@
 
     public static void scope(String name, Object[] context, Runnable runnable) {
         if (ENABLED) {
-            DebugScope.getInstance().scope(name, runnable, null, false, context);
+            DebugScope.getInstance().scope(name, runnable, null, false, null, context);
         } else {
             runnable.run();
         }
@@ -118,7 +135,7 @@
 
     public static <T> T scope(String name, Object[] context, Callable<T> callable) {
         if (ENABLED) {
-            return DebugScope.getInstance().scope(name, null, callable, false, context);
+            return DebugScope.getInstance().scope(name, null, callable, false, null, context);
         } else {
             return DebugScope.call(callable);
         }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Mon Apr 22 09:54:57 2013 +0200
@@ -138,13 +138,26 @@
         }
     }
 
-    public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, Object[] newContext) {
+    /**
+     * Runs a task in a new debug scope which is either a child of the current scope or a disjoint
+     * top level scope.
+     * 
+     * @param newName the name of the new scope
+     * @param runnable the task to run (must be null iff {@code callable} is not null)
+     * @param callable the task to run (must be null iff {@code runnable} is not null)
+     * @param sandbox specifies if the scope is a child of the current scope or a top level scope
+     * @param sandboxConfig the config to use of a new top level scope (ignored if
+     *            {@code sandbox == false})
+     * @param newContext context objects of the new scope
+     * @return the value returned by the task
+     */
+    public <T> T scope(String newName, Runnable runnable, Callable<T> callable, boolean sandbox, DebugConfig sandboxConfig, Object[] newContext) {
         DebugScope oldContext = getInstance();
         DebugConfig oldConfig = getConfig();
         DebugScope newChild = null;
         if (sandbox) {
             newChild = new DebugScope(newName, newName, null, newContext);
-            setConfig(null);
+            setConfig(sandboxConfig);
         } else {
             newChild = oldContext.createChild(newName, newContext);
         }
@@ -215,7 +228,7 @@
                         return new RuntimeException("Exception while intercepting exception", t);
                     }
                 }
-            }, false, new Object[]{e});
+            }, false, null, new Object[]{e});
         }
         return null;
     }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Apr 22 09:54:57 2013 +0200
@@ -28,6 +28,7 @@
 import static com.oracle.graal.phases.GraalOptions.*;
 
 import java.lang.reflect.*;
+import java.util.*;
 
 import sun.misc.*;
 
@@ -42,10 +43,13 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.LIRInstruction.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.phases.*;
 
 /**
@@ -154,6 +158,30 @@
         if (deoptimizationRescueSlot != null) {
             tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot));
         }
+
+        Stub stub = runtime().asStub(lirGen.method());
+        if (stub != null) {
+            final Set<Register> definedRegisters = new HashSet<>();
+            ValueProcedure defProc = new ValueProcedure() {
+
+                @Override
+                public Value doValue(Value value) {
+                    if (ValueUtil.isRegister(value)) {
+                        final Register reg = ValueUtil.asRegister(value);
+                        definedRegisters.add(reg);
+                    }
+                    return value;
+                }
+            };
+            for (Block block : lir.codeEmittingOrder()) {
+                for (LIRInstruction op : lir.lir(block)) {
+                    op.forEachTemp(defProc);
+                    op.forEachOutput(defProc);
+                }
+            }
+            stub.initDefinedRegisters(definedRegisters);
+        }
+
         return tasm;
     }
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java	Mon Apr 22 09:54:57 2013 +0200
@@ -49,7 +49,7 @@
     protected TargetDescription createTarget() {
         final int stackFrameAlignment = 16;
         final int implicitNullCheckLimit = 4096;
-        return new TargetDescription(new AMD64(), true, stackFrameAlignment, implicitNullCheckLimit, true);
+        return new TargetDescription(new AMD64(config.useSSE, config.useAVX), true, stackFrameAlignment, implicitNullCheckLimit, true);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRuntime.java	Mon Apr 22 09:54:57 2013 +0200
@@ -105,8 +105,7 @@
                 /* arg0: object */ javaCallingConvention(Kind.Object,
                 /* arg1:   lock */                       word));
 
-        addRuntimeCall(NEW_ARRAY, 0L,
-                /*        temps */ null,
+        addStubCall(NEW_ARRAY,
                 /*          ret */ rax.asValue(Kind.Object),
                 /* arg0:    hub */ rdx.asValue(word),
                 /* arg1: length */ rbx.asValue(Kind.Int));
@@ -117,8 +116,7 @@
                 /* arg0:    hub */ rdx.asValue(word),
                 /* arg1: length */ rbx.asValue(Kind.Int));
 
-        addRuntimeCall(NEW_INSTANCE, 0L,
-                /*        temps */ null,
+        addStubCall(NEW_INSTANCE,
                 /*          ret */ rax.asValue(Kind.Object),
                 /* arg0:    hub */ rdx.asValue(word));
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java	Mon Apr 22 09:54:57 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.hotspot;
 
+import java.util.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.target.*;
@@ -51,7 +53,7 @@
     /**
      * Where the stub gets its arguments and where it places its result.
      */
-    public final CallingConvention cc;
+    private CallingConvention cc;
 
     private final CompilerToVM vm;
 
@@ -87,12 +89,28 @@
     public void finalizeAddress(Backend backend) {
         if (address == 0) {
             assert stub != null : "linkage without an address must be a stub";
-            address = stub.getAddress(backend);
+            InstalledCode code = stub.getCode(backend);
+
+            Value[] argumentLocations = new Value[cc.getArgumentCount()];
+            for (int i = 0; i < argumentLocations.length; i++) {
+                argumentLocations[i] = cc.getArgument(i);
+            }
+
+            Set<Register> definedRegisters = stub.getDefinedRegisters();
+            Value[] temporaryLocations = new Value[definedRegisters.size()];
+            int i = 0;
+            for (Register reg : definedRegisters) {
+                temporaryLocations[i++] = reg.asValue();
+            }
+            // Update calling convention with temporaries
+            cc = new CallingConvention(temporaryLocations, cc.getStackSize(), cc.getReturn(), argumentLocations);
+            address = code.getStart();
         }
     }
 
     @Override
     public boolean preservesRegisters() {
-        return stub == null;
+        assert address != 0;
+        return true;
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Apr 22 09:54:57 2013 +0200
@@ -49,6 +49,10 @@
     public boolean useAESIntrinsics;
     public boolean useG1GC;
 
+    // CPU capabilities
+    public int useSSE;
+    public int useAVX;
+
     // offsets, ...
     public int stackShadowPages;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Mon Apr 22 09:54:57 2013 +0200
@@ -155,7 +155,7 @@
                 public void run() {
                     ServiceLoader<ReplacementsProvider> serviceLoader = ServiceLoader.loadInstalled(ReplacementsProvider.class);
                     for (ReplacementsProvider provider : serviceLoader) {
-                        provider.registerReplacements(replacements);
+                        provider.registerReplacements(runtime, replacements, runtime.getTarget());
                     }
                     runtime.registerReplacements(replacements);
                     if (GraalOptions.BootstrapReplacements) {
@@ -740,6 +740,10 @@
             phasePlan.addPhase(PhasePosition.AFTER_PARSING, new OnStackReplacementPhase());
         }
         phasePlan.addPhase(PhasePosition.LOW_LEVEL, new WriteBarrierAdditionPhase());
+        if (GraalOptions.VerifyPhases) {
+            phasePlan.addPhase(PhasePosition.LOW_LEVEL, new WriteBarrierVerificationPhase());
+
+        }
         return phasePlan;
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon Apr 22 09:54:57 2013 +0200
@@ -271,6 +271,17 @@
     }
 
     /**
+     * Registers the details for linking a call to a compiled {@link Stub}.
+     * 
+     * @param descriptor name and signature of the call
+     * @param ret where the call returns its result
+     * @param args where arguments are passed to the call
+     */
+    protected RuntimeCallTarget addStubCall(Descriptor descriptor, Value ret, Value... args) {
+        return addRuntimeCall(descriptor, 0L, null, ret, args);
+    }
+
+    /**
      * Registers the details for linking a runtime call.
      * 
      * @param descriptor name and signature of the call
@@ -580,6 +591,8 @@
         } else if (n instanceof CompareAndSwapNode) {
             // Separate out GC barrier semantics
             CompareAndSwapNode cas = (CompareAndSwapNode) n;
+            LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, cas.expected().kind(), cas.displacement(), cas.offset(), graph, 1);
+            cas.setLocation(location);
             cas.setWriteBarrierType(getCompareAndSwapBarrier(cas));
         } else if (n instanceof LoadIndexedNode) {
             LoadIndexedNode loadIndexed = (LoadIndexedNode) n;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java	Mon Apr 22 09:54:57 2013 +0200
@@ -36,7 +36,7 @@
  * Causes the VM to exit with a description of the current Java location and an optional
  * {@linkplain Log#printf(String, long) formatted} error message specified.
  */
-public final class VMErrorNode extends FixedWithNextNode implements LIRGenLowerable {
+public final class VMErrorNode extends DeoptimizingStubCall implements LIRGenLowerable {
 
     @Input private ValueNode format;
     @Input private ValueNode value;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Mon Apr 22 09:54:57 2013 +0200
@@ -61,11 +61,9 @@
     private static void addCASBarriers(CompareAndSwapNode node, StructuredGraph graph) {
         WriteBarrierType barrierType = node.getWriteBarrierType();
         if (barrierType == WriteBarrierType.PRECISE) {
-            LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, node.expected().kind(), node.displacement(), node.offset(), graph, 1);
-            graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), location, true)));
+            graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), true)));
         } else if (barrierType == WriteBarrierType.IMPRECISE) {
-            LocationNode location = IndexedLocationNode.create(LocationNode.ANY_LOCATION, node.expected().kind(), node.displacement(), node.offset(), graph, 1);
-            graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), location, false)));
+            graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), false)));
         } else {
             assert barrierType == WriteBarrierType.NONE;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java	Mon Apr 22 09:54:57 2013 +0200
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2013, 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.hotspot.phases;
+
+import java.util.*;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.extended.WriteNode.WriteBarrierType;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.graph.*;
+
+public class WriteBarrierVerificationPhase extends Phase {
+
+    private class MemoryMap implements MergeableState<MemoryMap> {
+
+        private IdentityHashMap<Object, LinkedList<LocationNode>> lastMemorySnapshot;
+        private IdentityHashMap<Object, LinkedList<SerialWriteBarrier>> lastWriteBarrierSnapshot;
+
+        public MemoryMap(MemoryMap memoryMap) {
+            lastMemorySnapshot = new IdentityHashMap<>(memoryMap.lastMemorySnapshot);
+            lastWriteBarrierSnapshot = new IdentityHashMap<>(memoryMap.lastWriteBarrierSnapshot);
+        }
+
+        public MemoryMap() {
+            lastMemorySnapshot = new IdentityHashMap<>();
+            lastWriteBarrierSnapshot = new IdentityHashMap<>();
+        }
+
+        @Override
+        public String toString() {
+            return "Map=" + lastMemorySnapshot.toString();
+        }
+
+        @Override
+        public boolean merge(MergeNode merge, List<MemoryMap> withStates) {
+            if (withStates.size() == 0) {
+                return true;
+            }
+
+            for (MemoryMap other : withStates) {
+                for (Object otherObject : other.lastMemorySnapshot.keySet()) {
+                    LinkedList<LocationNode> currentLocations = lastMemorySnapshot.get(otherObject);
+                    LinkedList<LocationNode> otherLocations = other.lastMemorySnapshot.get(otherObject);
+                    if (otherLocations != null) {
+                        if (currentLocations == null) {
+                            currentLocations = new LinkedList<>();
+                        }
+                        for (LocationNode location : otherLocations) {
+                            if (!currentLocations.contains(location)) {
+                                currentLocations.add(location);
+                            }
+                        }
+                    }
+                }
+                for (Object otherObject : other.lastWriteBarrierSnapshot.keySet()) {
+                    LinkedList<SerialWriteBarrier> currentWriteBarriers = lastWriteBarrierSnapshot.get(otherObject);
+                    LinkedList<SerialWriteBarrier> otherWriteBarriers = other.lastWriteBarrierSnapshot.get(otherObject);
+                    if (otherWriteBarriers != null) {
+                        if (currentWriteBarriers == null) {
+                            currentWriteBarriers = new LinkedList<>();
+                        }
+                        for (SerialWriteBarrier barrier : otherWriteBarriers) {
+                            if (!currentWriteBarriers.contains(barrier)) {
+                                currentWriteBarriers.add(barrier);
+                            }
+                        }
+                    }
+                }
+            }
+            return true;
+        }
+
+        @Override
+        public void loopBegin(LoopBeginNode loopBegin) {
+        }
+
+        @Override
+        public void loopEnds(LoopBeginNode loopBegin, List<MemoryMap> loopEndStates) {
+        }
+
+        @Override
+        public void afterSplit(BeginNode node) {
+        }
+
+        @Override
+        public MemoryMap clone() {
+            return new MemoryMap(this);
+        }
+    }
+
+    @Override
+    protected void run(StructuredGraph graph) {
+        new PostOrderNodeIterator<MemoryMap>(graph.start(), new MemoryMap()) {
+
+            @Override
+            protected void node(FixedNode node) {
+                processNode(node, state);
+            }
+        }.apply();
+    }
+
+    private static void processNode(FixedNode node, MemoryMap state) {
+        if (node instanceof WriteNode) {
+            processWriteNode((WriteNode) node, state);
+        } else if (node instanceof CompareAndSwapNode) {
+            processCASNode((CompareAndSwapNode) node, state);
+        } else if (node instanceof SerialWriteBarrier) {
+            processWriteBarrier((SerialWriteBarrier) node, state);
+        } else if ((node instanceof DeoptimizingNode)) {
+            if (((DeoptimizingNode) node).canDeoptimize()) {
+                validateWriteBarriers(state);
+                processSafepoint(state);
+            }
+        }
+    }
+
+    private static void processWriteNode(WriteNode node, MemoryMap state) {
+        if (node.getWriteBarrierType() != WriteBarrierType.NONE) {
+            LinkedList<LocationNode> locations = state.lastMemorySnapshot.get(node.object());
+            if (locations == null) {
+                locations = new LinkedList<>();
+                locations.add(node.location());
+                state.lastMemorySnapshot.put(node.object(), locations);
+            } else if ((node.getWriteBarrierType() == WriteBarrierType.PRECISE) && !locations.contains(node.location())) {
+                locations.add(node.location());
+            }
+        }
+    }
+
+    private static void processCASNode(CompareAndSwapNode node, MemoryMap state) {
+        if (node.getWriteBarrierType() != WriteBarrierType.NONE) {
+            LinkedList<LocationNode> locations = state.lastMemorySnapshot.get(node.object());
+            if (locations == null) {
+                locations = new LinkedList<>();
+                locations.add(node.getLocation());
+                state.lastMemorySnapshot.put(node.object(), locations);
+            } else if ((node.getWriteBarrierType() == WriteBarrierType.PRECISE) && !locations.contains(node.getLocation())) {
+                locations.add(node.getLocation());
+            }
+        }
+    }
+
+    private static void processWriteBarrier(SerialWriteBarrier currentBarrier, MemoryMap state) {
+        LinkedList<SerialWriteBarrier> writeBarriers = state.lastWriteBarrierSnapshot.get(currentBarrier.getObject());
+        if (writeBarriers == null) {
+            writeBarriers = new LinkedList<>();
+            writeBarriers.add(currentBarrier);
+            state.lastWriteBarrierSnapshot.put(currentBarrier.getObject(), writeBarriers);
+        } else if (currentBarrier.usePrecise()) {
+            boolean found = false;
+            for (SerialWriteBarrier barrier : writeBarriers) {
+                if (barrier.getLocation() == currentBarrier.getLocation()) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                writeBarriers.add(currentBarrier);
+            }
+        }
+    }
+
+    private static void validateWriteBarriers(MemoryMap state) {
+        Set<Object> objects = state.lastMemorySnapshot.keySet();
+        for (Object write : objects) {
+            LinkedList<SerialWriteBarrier> writeBarriers = state.lastWriteBarrierSnapshot.get(write);
+            if (writeBarriers == null) {
+                throw new GraalInternalError("Failed to find any write barrier at safepoint for written object");
+            }
+            /*
+             * Check the first write barrier of the object to determine if it is precise or not. If
+             * it is not, the validation for this object has passed (since we had a hit in the write
+             * barrier hashmap), otherwise we have to ensure the presence of write barriers for
+             * every written location.
+             */
+            final boolean precise = writeBarriers.getFirst().usePrecise();
+            if (precise) {
+                LinkedList<LocationNode> locations = state.lastMemorySnapshot.get(write);
+                for (LocationNode location : locations) {
+                    boolean found = false;
+                    for (SerialWriteBarrier barrier : writeBarriers) {
+                        if (location == barrier.getLocation()) {
+                            found = true;
+                            break;
+                        }
+                    }
+                    if (!found) {
+                        throw new GraalInternalError("Failed to find write barrier at safepoint for precise written object");
+                    }
+                }
+            }
+        }
+    }
+
+    private static void processSafepoint(MemoryMap state) {
+        state.lastMemorySnapshot.clear();
+        state.lastWriteBarrierSnapshot.clear();
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java	Mon Apr 22 09:54:57 2013 +0200
@@ -79,7 +79,7 @@
         }
     }
 
-    abstract static class CryptBlockStubCall extends FixedWithNextNode implements LIRGenLowerable {
+    abstract static class CryptBlockStubCall extends DeoptimizingStubCall implements LIRGenLowerable {
 
         @Input private final ValueNode in;
         @Input private final ValueNode out;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteSubstitutions.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteSubstitutions.java	Mon Apr 22 09:54:57 2013 +0200
@@ -24,6 +24,8 @@
 
 import java.lang.invoke.*;
 
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.nodes.spi.*;
@@ -33,7 +35,7 @@
 public class CallSiteSubstitutions implements ReplacementsProvider {
 
     @Override
-    public void registerReplacements(Replacements replacements) {
+    public void registerReplacements(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
         if (GraalOptions.IntrinsifyCallSiteTarget) {
             replacements.registerSubstitutions(ConstantCallSiteSubstitutions.class);
             replacements.registerSubstitutions(MutableCallSiteSubstitutions.class);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Mon Apr 22 09:54:57 2013 +0200
@@ -96,7 +96,7 @@
         }
     }
 
-    abstract static class AESCryptStubCall extends FixedWithNextNode implements LIRGenLowerable {
+    abstract static class AESCryptStubCall extends DeoptimizingStubCall implements LIRGenLowerable {
 
         @Input private final ValueNode in;
         @Input private final ValueNode out;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotInstalledCodeIntrinsics.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotInstalledCodeIntrinsics.java	Mon Apr 22 09:54:57 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
@@ -30,7 +32,7 @@
 public class HotSpotInstalledCodeIntrinsics implements ReplacementsProvider {
 
     @Override
-    public void registerReplacements(Replacements replacements) {
+    public void registerReplacements(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
         if (GraalOptions.IntrinsifyInstalledCodeMethods) {
             replacements.registerSubstitutions(HotSpotInstalledCodeSubstitutions.class);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Apr 22 09:54:57 2013 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.stubs;
 
+import java.util.*;
 import java.util.concurrent.*;
 
 import com.oracle.graal.api.code.*;
@@ -29,6 +30,7 @@
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.java.*;
@@ -64,11 +66,26 @@
     /**
      * The code installed for the stub.
      */
-    protected InstalledCode stubCode;
+    protected InstalledCode code;
 
     /**
-     * Creates a new stub container. The new stub still needs to be
-     * {@linkplain #getAddress(Backend) installed}.
+     * The registers defined by this stub.
+     */
+    private Set<Register> definedRegisters;
+
+    public void initDefinedRegisters(Set<Register> registers) {
+        assert registers != null;
+        assert definedRegisters == null : "cannot redefine";
+        definedRegisters = registers;
+    }
+
+    public Set<Register> getDefinedRegisters() {
+        assert definedRegisters != null : "not yet initialized";
+        return definedRegisters;
+    }
+
+    /**
+     * Creates a new stub container..
      * 
      * @param linkage linkage details for a call to the stub
      */
@@ -100,37 +117,43 @@
     }
 
     /**
-     * Ensures the code for this stub is installed.
-     * 
-     * @return the entry point address for calls to this stub
+     * Gets the code for this stub, compiling it first if necessary.
      */
-    public synchronized long getAddress(Backend backend) {
-        if (stubCode == null) {
-            Arguments args = makeArguments(stubInfo);
-            SnippetTemplate template = template(args);
-            StructuredGraph graph = template.copySpecializedGraph();
-
-            PhasePlan phasePlan = new PhasePlan();
-            GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
-            phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
-            final CompilationResult compResult = GraalCompiler.compileMethod(runtime(), replacements, backend, runtime().getTarget(), getMethod(), graph, null, phasePlan, OptimisticOptimizations.ALL,
-                            new SpeculationLog());
-
-            stubCode = Debug.scope("CodeInstall", new Object[]{runtime(), getMethod()}, new Callable<InstalledCode>() {
+    public synchronized InstalledCode getCode(final Backend backend) {
+        if (code == null) {
+            Debug.sandbox("CompilingStub", new Object[]{runtime(), getMethod()}, DebugScope.getConfig(), new Runnable() {
 
                 @Override
-                public InstalledCode call() {
-                    InstalledCode installedCode = runtime().addMethod(getMethod(), compResult);
-                    assert installedCode != null : "error installing stub " + getMethod();
-                    if (Debug.isDumpEnabled()) {
-                        Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
-                    }
-                    return installedCode;
+                public void run() {
+
+                    Arguments args = makeArguments(stubInfo);
+                    SnippetTemplate template = template(args);
+                    StructuredGraph graph = template.copySpecializedGraph();
+
+                    PhasePlan phasePlan = new PhasePlan();
+                    GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
+                    phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
+                    final CompilationResult compResult = GraalCompiler.compileMethod(runtime(), replacements, backend, runtime().getTarget(), getMethod(), graph, null, phasePlan,
+                                    OptimisticOptimizations.ALL, new SpeculationLog());
+
+                    assert definedRegisters != null;
+                    code = Debug.scope("CodeInstall", new Callable<InstalledCode>() {
+
+                        @Override
+                        public InstalledCode call() {
+                            InstalledCode installedCode = runtime().addMethod(getMethod(), compResult);
+                            assert installedCode != null : "error installing stub " + getMethod();
+                            if (Debug.isDumpEnabled()) {
+                                Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
+                            }
+                            return installedCode;
+                        }
+                    });
+
                 }
             });
-
-            assert stubCode != null : "error installing stub " + getMethod();
+            assert code != null : "error installing stub " + getMethod();
         }
-        return stubCode.getStart();
+        return code;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Mon Apr 22 09:54:57 2013 +0200
@@ -75,11 +75,20 @@
                 // checkcast.
                 return object();
             }
+
+            // remove checkcast if the only usage is a more specific checkcast
+            if (usages().count() == 1) {
+                CheckCastNode ccn = usages().filter(CheckCastNode.class).first();
+                if (ccn != null && ccn.type() != null && type.isAssignableFrom(ccn.type())) {
+                    return object();
+                }
+            }
         }
 
         if (object().objectStamp().alwaysNull()) {
             return object();
         }
+
         return this;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Mon Apr 22 09:54:57 2013 +0200
@@ -42,6 +42,7 @@
     @Input private ValueNode offset;
     @Input private ValueNode expected;
     @Input private ValueNode newValue;
+    @Input private LocationNode location;
     private final int displacement;
     private WriteBarrierType barrierType;
 
@@ -65,6 +66,15 @@
         return displacement;
     }
 
+    public LocationNode getLocation() {
+        return location;
+    }
+
+    public void setLocation(LocationNode location) {
+        updateUsages(this.location, location);
+        this.location = location;
+    }
+
     public WriteBarrierType getWriteBarrierType() {
         return barrierType;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java	Mon Apr 22 09:54:57 2013 +0200
@@ -63,7 +63,7 @@
         ObjectStamp stamp = object().objectStamp();
         ResolvedJavaType stampType = stamp.type();
 
-        if (stamp.isExactType()) {
+        if (stamp.isExactType() || stampType != null) {
             boolean subType = type().isAssignableFrom(stampType);
 
             if (subType) {
@@ -77,27 +77,15 @@
                     return graph().unique(new IsNullNode(object()));
                 }
             } else {
-                // since this type check failed for an exact type we know that it can never succeed
-                // at run time.
-                // we also don't care about null values, since they will also make the check fail.
-                return LogicConstantNode.contradiction(graph());
-            }
-        } else if (stampType != null) {
-            boolean subType = type().isAssignableFrom(stampType);
-
-            if (subType) {
-                if (stamp.nonNull()) {
-                    // the instanceOf matches, so return true
-                    return LogicConstantNode.tautology(graph());
+                if (stamp.isExactType()) {
+                    // since this type check failed for an exact type we know that it can never
+                    // succeed at run time. we also don't care about null values, since they will
+                    // also make the check fail.
+                    return LogicConstantNode.contradiction(graph());
                 } else {
-                    // the instanceof matches if the object is non-null, so return true depending on
-                    // the null-ness.
-                    negateUsages();
-                    return graph().unique(new IsNullNode(object()));
+                    // since the subtype comparison was only performed on a declared type we don't
+                    // really know if it might be true at run time...
                 }
-            } else {
-                // since the subtype comparison was only performed on a declared type we don't
-                // really know if it might be true at run time...
             }
         }
         if (object().objectStamp().alwaysNull()) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Mon Apr 22 09:54:57 2013 +0200
@@ -78,4 +78,15 @@
      * Determines whether the replacement of this method is flagged as being inlined always.
      */
     boolean isForcedSubstitution(ResolvedJavaMethod methodAt);
+
+    /**
+     * Register snippet templates.
+     */
+    void registerSnippetTemplateCache(SnippetTemplateCache snippetTemplates);
+
+    /**
+     * Get snippet templates that were registered with
+     * {@link Replacements#registerSnippetTemplateCache(SnippetTemplateCache)}.
+     */
+    <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ReplacementsProvider.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ReplacementsProvider.java	Mon Apr 22 09:54:57 2013 +0200
@@ -22,10 +22,13 @@
  */
 package com.oracle.graal.nodes.spi;
 
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+
 /**
  * Interface for service providers that register replacements with the compiler.
  */
 public interface ReplacementsProvider {
 
-    void registerReplacements(Replacements replacements);
+    void registerReplacements(MetaAccessProvider runtime, Replacements replacements, TargetDescription target);
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Mon Apr 22 09:54:57 2013 +0200
@@ -114,7 +114,7 @@
     // debugging settings
     public static boolean ZapStackOnMethodEntry              = ____;
     public static boolean DeoptALot                          = ____;
-    public static boolean VerifyPhases                       = true;
+    public static boolean VerifyPhases                       = false;
 
     public static String  PrintFilter                        = null;
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Mon Apr 22 09:54:57 2013 +0200
@@ -24,10 +24,18 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.spi.*;
 
 public class MidTierContext extends PhaseContext {
 
-    public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions) {
+    private final Replacements replacements;
+
+    public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
         super(runtime, assumptions);
+        this.replacements = replacements;
+    }
+
+    public Replacements getReplacements() {
+        return replacements;
     }
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Mon Apr 22 09:54:57 2013 +0200
@@ -48,8 +48,8 @@
         configurations = new HashMap<>();
         for (CompilerConfiguration config : ServiceLoader.loadInstalled(CompilerConfiguration.class)) {
             String name = config.getClass().getSimpleName();
-            if (name.endsWith("Configuration")) {
-                name = name.substring(0, name.length() - "Configuration".length());
+            if (name.endsWith("CompilerConfiguration")) {
+                name = name.substring(0, name.length() - "CompilerConfiguration".length());
             }
             configurations.put(name.toLowerCase(), config);
         }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Mon Apr 22 09:54:57 2013 +0200
@@ -161,7 +161,7 @@
                 previousInlineContext = inlineContext;
 
                 final SchedulePhase predefinedSchedule = getPredefinedSchedule();
-                Debug.sandbox("PrintingGraph", new Runnable() {
+                Debug.sandbox("PrintingGraph", null, new Runnable() {
 
                     @Override
                     public void run() {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Mon Apr 22 09:54:57 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.replacements;
 
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
@@ -32,7 +34,7 @@
 @ServiceProvider(ReplacementsProvider.class)
 public class GraalMethodSubstitutions implements ReplacementsProvider {
 
-    public void registerReplacements(Replacements replacements) {
+    public void registerReplacements(MetaAccessProvider runtime, Replacements replacements, TargetDescription target) {
         for (Class<?> clazz : BoxingSubstitutions.getClasses()) {
             replacements.registerSubstitutions(clazz);
         }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Mon Apr 22 09:54:57 2013 +0200
@@ -62,6 +62,7 @@
     private final Map<ResolvedJavaMethod, ResolvedJavaMethod> registeredMethodSubstitutions;
     private final Map<ResolvedJavaMethod, Class<? extends FixedWithNextNode>> registerMacroSubstitutions;
     private final Set<ResolvedJavaMethod> forcedSubstitutions;
+    private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache;
 
     public ReplacementsImpl(MetaAccessProvider runtime, Assumptions assumptions, TargetDescription target) {
         this.runtime = runtime;
@@ -71,6 +72,7 @@
         this.registeredMethodSubstitutions = new HashMap<>();
         this.registerMacroSubstitutions = new HashMap<>();
         this.forcedSubstitutions = new HashSet<>();
+        this.snippetTemplateCache = new HashMap<>();
     }
 
     public StructuredGraph getSnippet(ResolvedJavaMethod method) {
@@ -479,4 +481,16 @@
     public boolean isForcedSubstitution(ResolvedJavaMethod method) {
         return forcedSubstitutions.contains(method);
     }
+
+    @Override
+    public void registerSnippetTemplateCache(SnippetTemplateCache templates) {
+        assert snippetTemplateCache.get(templates.getClass()) == null;
+        snippetTemplateCache.put(templates.getClass(), templates);
+    }
+
+    @Override
+    public <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass) {
+        SnippetTemplateCache ret = snippetTemplateCache.get(templatesClass);
+        return templatesClass.cast(ret);
+    }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Apr 17 23:16:50 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Mon Apr 22 09:54:57 2013 +0200
@@ -28,6 +28,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.loop.*;
@@ -268,7 +269,7 @@
     /**
      * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s.
      */
-    public abstract static class AbstractTemplates {
+    public abstract static class AbstractTemplates implements SnippetTemplateCache {
 
         protected final MetaAccessProvider runtime;
         protected final Replacements replacements;
--- a/make/build-graal.xml	Wed Apr 17 23:16:50 2013 +0200
+++ b/make/build-graal.xml	Mon Apr 22 09:54:57 2013 +0200
@@ -81,7 +81,7 @@
         <provider classname="com.oracle.graal.replacements.GraalMethodSubstitutions"/>
       </service>
       <service type="com.oracle.graal.phases.tiers.CompilerConfiguration">
-        <provider classname="com.oracle.graal.compiler.phases.BasicConfiguration"/>
+        <provider classname="com.oracle.graal.compiler.phases.BasicCompilerConfiguration"/>
       </service>
     </jar>
   </target>
--- a/mx/projects	Wed Apr 17 23:16:50 2013 +0200
+++ b/mx/projects	Mon Apr 22 09:54:57 2013 +0200
@@ -1,5 +1,7 @@
 # The format of this file is described in the documentation for my.py.
 
+suite=graal
+
 library@JDK_TOOLS@path=${JAVA_HOME}/lib/tools.jar
 library@JDK_TOOLS@optional=true
 
--- a/mxtool/mx.py	Wed Apr 17 23:16:50 2013 +0200
+++ b/mxtool/mx.py	Mon Apr 22 09:54:57 2013 +0200
@@ -459,7 +459,11 @@
         self._load_env(mxDir)
         self._load_commands(mxDir)
         self._load_includes(mxDir)
-
+        self.name = d # re-initialized in _load_projects
+
+    def __str__(self):
+        return self.name
+    
     def _load_projects(self, mxDir):
         libsMap = dict()
         projsMap = dict()
@@ -475,8 +479,11 @@
 
                     parts = key.split('@')
 
-                    if len(parts) == 2:
-                        pass
+                    if len(parts) == 1:
+                        if parts[0] != 'suite':
+                            abort('Single part property must be "suite": ' + key)
+                        self.name = value
+                        continue
                     if len(parts) != 3:
                         abort('Property name does not have 3 parts separated by "@": ' + key)
                     kind, name, attr = parts
@@ -539,6 +546,9 @@
             d = Distribution(self, name, path, deps)
             d.__dict__.update(attrs)
             self.dists.append(d)
+            
+        if self.name is None:
+            abort('Missing "suite=<name>" in ' + projectsFile)
 
     def _load_commands(self, mxDir):
         commands = join(mxDir, 'commands.py')
@@ -547,7 +557,8 @@
             sys.path.insert(0, mxDir)
             mod = __import__('commands')
             
-            sys.modules[join(mxDir, 'commands')] = sys.modules.pop('commands')
+            self.commands = sys.modules.pop('commands')
+            sys.modules[join(mxDir, 'commands')] = self.commands
 
             # revert the Python path
             del sys.path[0]
@@ -582,6 +593,7 @@
     def _post_init(self, opts):
         mxDir = join(self.dir, 'mx')
         self._load_projects(mxDir)
+        _suites[self.name] = self
         for p in self.projects:
             existing = _projects.get(p.name)
             if existing is not None:
@@ -703,6 +715,15 @@
     """
     return _suites.values()
 
+def suite(name, fatalIfMissing=True):
+    """
+    Get the suite for a given name.
+    """
+    s = _suites.get(name)
+    if s is None and fatalIfMissing:
+        abort('suite named ' + name + ' not found')
+    return s
+
 def projects():
     """
     Get the list of all loaded projects.
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Wed Apr 17 23:16:50 2013 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Mon Apr 22 09:54:57 2013 +0200
@@ -348,26 +348,7 @@
   GrowableArray<jlong>* leaf_graph_ids = get_leaf_graph_ids(comp_result);
 
   result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
-    GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, leaf_graph_ids, installed_code, triggered_deoptimizations);
-}
-
-// constructor used to create a stub
-CodeInstaller::CodeInstaller(Handle& target_method, BufferBlob*& blob, jlong& id) {
-  No_Safepoint_Verifier no_safepoint;
-
-  _oop_recorder = new OopRecorder(&_arena);
-  initialize_fields(target_method(), NULL);
-  assert(_name != NULL, "installMethod needs NON-NULL name");
-
-  // (very) conservative estimate: each site needs a relocation
-  GraalCompiler::initialize_buffer_blob();
-  CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
-  initialize_buffer(buffer);
-
-  const char* cname = java_lang_String::as_utf8_string(_name);
-  blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created
-  IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob);
-  id = (jlong)blob->code_begin();
+    GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, false, leaf_graph_ids, installed_code, triggered_deoptimizations);
 }
 
 void CodeInstaller::initialize_fields(oop comp_result, methodHandle method) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Apr 17 23:16:50 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon Apr 22 09:54:57 2013 +0200
@@ -643,6 +643,8 @@
   set_boolean("useAESIntrinsics", UseAESIntrinsics);
   set_boolean("useTLAB", UseTLAB);
   set_boolean("useG1GC", UseG1GC);
+  set_int("useSSE", UseSSE);
+  set_int("useAVX", UseAVX);
   set_int("codeEntryAlignment", CodeEntryAlignment);
   set_int("stackShadowPages", StackShadowPages);
   set_int("hubOffset", oopDesc::klass_offset_in_bytes());
--- a/src/share/vm/graal/graalEnv.cpp	Wed Apr 17 23:16:50 2013 +0200
+++ b/src/share/vm/graal/graalEnv.cpp	Mon Apr 22 09:54:57 2013 +0200
@@ -449,7 +449,6 @@
                                 Dependencies* dependencies,
                                 CompileTask* task,
                                 int compile_id,
-                                bool has_debug_info,
                                 bool has_unsafe_access,
                                 GrowableArray<jlong>* leaf_graph_ids,
                                 Handle installed_code,
--- a/src/share/vm/graal/graalEnv.hpp	Wed Apr 17 23:16:50 2013 +0200
+++ b/src/share/vm/graal/graalEnv.hpp	Mon Apr 22 09:54:57 2013 +0200
@@ -143,7 +143,6 @@
                        Dependencies*             dependencies,
                        CompileTask*              task,
                        int                       compile_id,
-                       bool                      has_debug_info,
                        bool                      has_unsafe_access,
                        GrowableArray<jlong>*     leaf_graph_ids,
                        Handle                    installed_code,