changeset 10598:5b9abb0cc9d8

Merge.
author Christian Humer <christian.humer@gmail.com>
date Mon, 01 Jul 2013 21:07:21 +0200
parents 79041ab43660 (current diff) e43bb3295475 (diff)
children ebf5c5c23564
files
diffstat 66 files changed, 1360 insertions(+), 386 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ExternalCompilationResult.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009, 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.code;
+
+public class ExternalCompilationResult extends CompilationResult {
+
+  private static final long serialVersionUID = 1L;
+
+    private long kernel;
+
+    public ExternalCompilationResult() {
+        super();
+    }
+
+    public void setKernel(long k) {
+        kernel = k;
+    }
+
+    public long getKernel() {
+      return kernel;
+    }
+}
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Mon Jul 01 21:07:21 2013 +0200
@@ -26,6 +26,7 @@
 import com.oracle.graal.api.meta.Kind;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.hotspot.HotSpotGraalRuntime;
+import com.oracle.graal.sparc.*;
 
 import static com.oracle.graal.sparc.SPARC.*;
 
@@ -401,7 +402,23 @@
 
     public static class Fmt3p {
 
-        public Fmt3p(SPARCAssembler masm, int op, int op3, int opf, int rs1, int rs2, int rd) {
+        private int op;
+        private int op3;
+        private int opf;
+        private int rs1;
+        private int rs2;
+        private int rd;
+
+        public Fmt3p(Ops op, Op3s op3, Opfs opf, Register rs1, Register rs2, Register rd) {
+            this.op = op.getValue();
+            this.op3 = op3.getValue();
+            this.opf = opf.getValue();
+            this.rs1 = rs1.encoding();
+            this.rs2 = rs2.encoding();
+            this.rd = rd.encoding();
+        }
+
+        public void emit(SPARCAssembler masm) {
             assert op == 2 || op == 3;
             assert op3 >= 0 && op3 < 0x40;
             assert opf >= 0 && opf < 0x200;
@@ -754,6 +771,14 @@
         Array32(0x14, "array32"),
         AlignAddress(0x18, "alignaddress"),
         AlignAddressLittle(0x1A, "alignaddress_little"),
+        Fpcmple16(0x20, "fpcmple16"),
+        Fpcmpne16(0x22, "fpcmpne16"),
+        Fpcmple32(0x24, "fpcmple32"),
+        Fpcmpne32(0x26, "fpcmpne32"),
+        Fpcmpgt16(0x28, "fpcmpgt16"),
+        Fpcmpeq16(0x2A, "fpcmpeq16"),
+        Fpcmpgt32(0x2C, "fpcmpgt32"),
+        Fpcmpeq32(0x2E, "fpcmpeq32"),
         Fmul8x16(0x31, "fmul8x16"),
         Fmul8x16au(0x33, "fmul8x16au"),
         Fmul8x16al(0x35, "fmul8x16al"),
@@ -761,9 +786,31 @@
         Fmul8ulx16(0x37, "fmul8ulx16"),
         Fmuld8sux16(0x38, "fmuld8sux16"),
         Fmuld8ulx16(0x39, "fmuld8ulx16"),
+        Fpack32(0x3A, "fpack32"),
+        Fpack16(0x3B, "fpack16"),
+        Fpackfix(0x3D, "fpackfix"),
         Faligndatag(0x48, "faligndata"),
-        Fnhadds(0x71, "fnhadds"),
-        Fnhaddd(0x72, "fnhaddd"),
+        Fpmerge(0x4B, "fpmerge"),
+        Fpadd16(0x50, "fpadd16"),
+        Fpadd16s(0x51, "fpadd16s"),
+        Fpadd32(0x52, "fpadd32"),
+        Fpadd32s(0x53, "fpadd32s"),
+        Fpsub16(0x54, "fpadd16"),
+        Fpsub16s(0x55, "fpadd16s"),
+        Fpsub32(0x56, "fpadd32"),
+        Fpsub32s(0x57, "fpadd32s"),
+        Fzerod(0x60, "fzerod"),
+        Fzeros(0x61, "fzeros"),
+        Fnot2d(0x66, "fnot1d"),
+        Fnot2s(0x67, "fnot1s"),
+        Fnot1d(0x6A, "fnot1d"),
+        Fnot1s(0x6B, "fnot1s"),
+        Fsrc1d(0x74, "fsrc1d"),
+        Fsrc1s(0x75, "fsrc1s"),
+        Fsrc2d(0x78, "fsrc2d"),
+        Fsrc2s(0x79, "fsrc2s"),
+        Foned(0x7E, "foned"),
+        Fones(0x7F, "fones"),
         // end VIS1
 
         // start VIS2
@@ -780,6 +827,11 @@
         Fmean16(0x40, "fmean16"),
         Fnadds(0x51, "fnadds"),
         Fnaddd(0x52, "fnaddd"),
+        Fnmuls(0x59, "fnmuls"),
+        Fnmuld(0x5A, "fnmuld"),
+        Fnsmuld(0x79, "fnsmuld"),
+        Fnhadds(0x71, "fnhadds"),
+        Fnhaddd(0x72, "fnhaddd"),
         // end VIS3
 
         // start CAMMELLIA
@@ -791,6 +843,21 @@
         Crc32c(0x147, "crc32c"),
         // end CRYPTO
 
+        // start OSA 2011
+        Fpadd64(0x44, "fpadd64"),
+        Fpsub64(0x46, "fpsub64"),
+        Fpadds16(0x58, "fpadds16"),
+        Fpadds16s(0x59, "fpadds16"),
+        Fpadds32(0x5A, "fpadds32"),
+        Fpadds32s(0x5B, "fpadds32s"),
+        Fpsubs16(0x5C, "fpsubs16"),
+        Fpsubs16s(0x5D, "fpsubs16s"),
+        Fpsubs32(0x5E, "fpsubs32"),
+        Fpsubs32s(0x5F, "fpsubs32s"),
+        Fpcmpne8(0x122, "fpcmpne8"),
+        Fpcmpeq8(0x12C, "fpcmpeq8"),
+        // end OSA 2011
+
         Fadds(0x41, "fadds"),
         Faddd(0x42, "faddd"),
         Faddq(0x43, "faddq"),
@@ -1039,33 +1106,33 @@
 
     public static class Addxc extends Fmt3p {
 
-        public Addxc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Addxc(Register src1, Register src2, Register dst) {
             /* VIS3 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Addxc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Addxc, src1, src2, dst);
         }
     }
 
     public static class Addxccc extends Fmt3p {
 
-        public Addxccc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Addxccc(Register src1, Register src2, Register dst) {
             /* VIS3 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Addxccc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Addxccc, src1, src2, dst);
         }
     }
 
     public static class Alignaddr extends Fmt3p {
 
-        public Alignaddr(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Alignaddr(Register src1, Register src2, Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.AlignAddress.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.AlignAddress, src1, src2, dst);
         }
     }
 
     public static class Alignaddrl extends Fmt3p {
 
-        public Alignaddrl(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Alignaddrl(Register src1, Register src2, Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.AlignAddressLittle.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.AlignAddressLittle, src1, src2, dst);
         }
     }
 
@@ -1115,33 +1182,33 @@
 
     public static class Array8 extends Fmt3p {
 
-        public Array8(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Array8(Register src1, Register src2, Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Array8.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Array8, src1, src2, dst);
         }
     }
 
     public static class Array16 extends Fmt3p {
 
-        public Array16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Array16(Register src1, Register src2, Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Array16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Array16, src1, src2, dst);
         }
     }
 
     public static class Array32 extends Fmt3p {
 
-        public Array32(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Array32(Register src1, Register src2, Register dst) {
             /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Array32.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Array32, src1, src2, dst);
         }
     }
 
     public static class Bmask extends Fmt3p {
 
-        public Bmask(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Bmask(Register src1, Register src2, Register dst) {
             /* VIS2 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Bmask.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Bmask, src1, src2, dst);
         }
     }
 
@@ -1323,25 +1390,25 @@
 
     public static class Bshuffle extends Fmt3p {
 
-        public Bshuffle(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Bshuffle(Register src1, Register src2, Register dst) {
             /* VIS2 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Bshuffle.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Bshuffle, src1, src2, dst);
         }
     }
 
     public static class CammelliaFl extends Fmt3p {
 
-        public CammelliaFl(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public CammelliaFl(Register src1, Register src2, Register dst) {
             /* CAMELLIA only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.CammelliaFl.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.CammelliaFl, src1, src2, dst);
         }
     }
 
     public static class CammelliaFli extends Fmt3p {
 
-        public CammelliaFli(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public CammelliaFli(Register src1, Register src2, Register dst) {
             /* CAMELLIA only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.CammelliaFli.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.CammelliaFli, src1, src2, dst);
         }
     }
 
@@ -1373,9 +1440,9 @@
 
     public static class Crc32c extends Fmt3p {
 
-        public Crc32c(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Crc32c(Register src1, Register src2, Register dst) {
             /* CRYPTO only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Crc32c.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Crc32c, src1, src2, dst);
         }
     }
 
@@ -1689,127 +1756,127 @@
 
     public static class Edge8cc extends Fmt3p {
 
-        public Edge8cc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge8cc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge8cc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge8cc, src1, src2, dst);
         }
     }
 
     public static class Edge8n extends Fmt3p {
 
-        public Edge8n(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge8n.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge8n(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge8n, src1, src2, dst);
         }
     }
 
     public static class Edge8lcc extends Fmt3p {
 
-        public Edge8lcc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge8lcc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge8lcc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge8lcc, src1, src2, dst);
         }
     }
 
     public static class Edge8ln extends Fmt3p {
 
-        public Edge8ln(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge8ln.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge8ln(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge8ln, src1, src2, dst);
         }
     }
 
     public static class Edge16cc extends Fmt3p {
 
-        public Edge16cc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge16cc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge16cc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge16cc, src1, src2, dst);
         }
     }
 
     public static class Edge16n extends Fmt3p {
 
-        public Edge16n(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge16n.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge16n(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge16n, src1, src2, dst);
         }
     }
 
     public static class Edge16lcc extends Fmt3p {
 
-        public Edge16lcc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge16lcc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge16lcc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge16lcc, src1, src2, dst);
         }
     }
 
     public static class Edge16ln extends Fmt3p {
 
-        public Edge16ln(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge16ln.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge16ln(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge16ln, src1, src2, dst);
         }
     }
 
     public static class Edge32cc extends Fmt3p {
 
-        public Edge32cc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge32cc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge32cc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge32cc, src1, src2, dst);
         }
     }
 
     public static class Edge32n extends Fmt3p {
 
-        public Edge32n(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge32n.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge32n(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge32n, src1, src2, dst);
         }
     }
 
     public static class Edge32lcc extends Fmt3p {
 
-        public Edge32lcc(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge32lcc.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge32lcc(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge32lcc, src1, src2, dst);
         }
     }
 
     public static class Edge32ln extends Fmt3p {
 
-        public Edge32ln(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Edge32ln.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Edge32ln(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Edge32ln, src1, src2, dst);
         }
     }
 
     public static class Fadds extends Fmt3p {
 
-        public Fadds(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fadds.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fadds(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fadds, src1, src2, dst);
         }
     }
 
     public static class Faddd extends Fmt3p {
 
-        public Faddd(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Faddd.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Faddd(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Faddd, src1, src2, dst);
         }
     }
 
     public static class Faddq extends Fmt3p {
 
-        public Faddq(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Faddq.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Faddq(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Faddq, src1, src2, dst);
         }
     }
 
     public static class Faligndata extends Fmt3p {
 
-        public Faligndata(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Faligndatag.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Faligndata(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Faligndatag, src1, src2, dst);
         }
     }
 
     public static class Fdivs extends Fmt3p {
 
-        public Fdivs(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdivs.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fdivs(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fdivs, src1, src2, dst);
         }
     }
 
     public static class Fdivd extends Fmt3p {
 
-        public Fdivd(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fdivd.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fdivd(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fdivd, src1, src2, dst);
         }
     }
 
@@ -1829,9 +1896,9 @@
 
     public static class Fmean16 extends Fmt3p {
 
-        public Fmean16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Fmean16(Register src1, Register src2, Register dst) {
             /* VIS3 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmean16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmean16, src1, src2, dst);
         }
     }
 
@@ -1849,19 +1916,119 @@
         }
     }
 
+    public static class Fmuls extends Fmt3p {
+
+        public Fmuls(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fmuls, src1, src2, dst);
+        }
+    }
+
+    public static class Fmuld extends Fmt3p {
+
+        public Fmuld(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fmuld, src1, src2, dst);
+        }
+    }
+
+    public static class Fmul8x16 extends Fmt3p {
+
+        public Fmul8x16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmul8x16, src1, src2, dst);
+        }
+    }
+
+    public static class Fmul8x16au extends Fmt3p {
+
+        public Fmul8x16au(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmul8x16, src1, src2, dst);
+        }
+    }
+
+    public static class Fmul8x16al extends Fmt3p {
+
+        public Fmul8x16al(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmul8x16al, src1, src2, dst);
+        }
+    }
+
+    public static class Fmul8sux16 extends Fmt3p {
+
+        public Fmul8sux16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmul8sux16, src1, src2, dst);
+        }
+    }
+
+    public static class Fmul8ulx16 extends Fmt3p {
+
+        public Fmul8ulx16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmul8ulx16, src1, src2, dst);
+        }
+    }
+
+    public static class Fmuld8sux16 extends Fmt3p {
+
+        public Fmuld8sux16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmuld8sux16, src1, src2, dst);
+        }
+    }
+
+    public static class Fmuld8ulx16 extends Fmt3p {
+
+        public Fmuld8ulx16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fmuld8ulx16, src1, src2, dst);
+        }
+    }
+
     public static class Fnadds extends Fmt3p {
 
-        public Fnadds(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Fnadds(Register src1, Register src2, Register dst) {
             /* VIS3 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnadds.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnadds, src1, src2, dst);
         }
     }
 
     public static class Fnaddd extends Fmt3p {
 
-        public Fnaddd(SPARCAssembler asm, Register src1, Register src2, Register dst) {
+        public Fnaddd(Register src1, Register src2, Register dst) {
             /* VIS3 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnaddd.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnaddd, src1, src2, dst);
+        }
+    }
+
+    public static class Fnegs extends Fmt3n {
+
+        public Fnegs(SPARCAssembler masm, Register src2, Register dst) {
+            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegs.getValue(), src2.encoding(), dst.encoding());
+        }
+    }
+
+    public static class Fnegd extends Fmt3n {
+
+        public Fnegd(SPARCAssembler masm, Register src2, Register dst) {
+            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegd.getValue(), src2.encoding(), dst.encoding());
+        }
+    }
+
+    public static class Fnhadds extends Fmt3p {
+
+        public Fnhadds(Register src1, Register src2, Register dst) {
+            /* VIS3 only */
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnhadds, src1, src2, dst);
+        }
+    }
+
+    public static class Fnhaddd extends Fmt3p {
+
+        public Fnhaddd(Register src1, Register src2, Register dst) {
+            /* VIS3 only */
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnhaddd, src1, src2, dst);
         }
     }
 
@@ -1893,87 +2060,27 @@
         }
     }
 
-    public static class Fmuls extends Fmt3p {
-
-        public Fmuls(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fmuls.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmuld extends Fmt3p {
-
-        public Fmuld(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fmuld.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmul8x16 extends Fmt3p {
-
-        public Fmul8x16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmul8x16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmul8x16au extends Fmt3p {
-
-        public Fmul8x16au(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmul8x16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmul8x16al extends Fmt3p {
-
-        public Fmul8x16al(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmul8x16al.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+    public static class Fnmuls extends Fmt3p {
+
+        public Fnmuls(Register src1, Register src2, Register dst) {
+            /* VIS3 only */
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnmuls, src1, src2, dst);
         }
     }
 
-    public static class Fmul8sux16 extends Fmt3p {
-
-        public Fmul8sux16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmul8sux16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmul8ulx16 extends Fmt3p {
-
-        public Fmul8ulx16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmul8ulx16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+    public static class Fnmuld extends Fmt3p {
+
+        public Fnmuld(Register src1, Register src2, Register dst) {
+            /* VIS3 only */
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnmuld, src1, src2, dst);
         }
     }
 
-    public static class Fmuld8sux16 extends Fmt3p {
-
-        public Fmuld8sux16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmuld8sux16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fmuld8ulx16 extends Fmt3p {
-
-        public Fmuld8ulx16(SPARCAssembler asm, Register src1, Register src2, Register dst) {
-            /* VIS1 only */
-            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep1.getValue(), Opfs.Fmuld8ulx16.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fnegs extends Fmt3n {
-
-        public Fnegs(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegs.getValue(), src2.encoding(), dst.encoding());
-        }
-    }
-
-    public static class Fnegd extends Fmt3n {
-
-        public Fnegd(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fnegd.getValue(), src2.encoding(), dst.encoding());
+    public static class Fnsmuld extends Fmt3p {
+
+        public Fnsmuld(Register src1, Register src2, Register dst) {
+            /* VIS3 only */
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fnsmuld, src1, src2, dst);
         }
     }
 
@@ -1998,31 +2105,194 @@
         }
     }
 
+    public static class Fpack16 extends Fmt3p {
+
+        public Fpack16(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpack16, src1, src2, dst);
+        }
+    }
+
+    public static class Fpack32 extends Fmt3p {
+
+        public Fpack32(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpack32, src1, src2, dst);
+        }
+    }
+
+    public static class Fpackfix extends Fmt3p {
+
+        public Fpackfix(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpackfix, src1, src2, dst);
+        }
+    }
+
+    public static class Fpmaddx extends Fmt5a {
+
+        public Fpmaddx(SPARCAssembler asm, Register src1, Register src2, Register src3, Register dst) {
+            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep2.getValue(), 0, src1.encoding(), src2.encoding(), src3.encoding(), dst.encoding());
+        }
+    }
+
+    public static class Fpmaddxhi extends Fmt5a {
+
+        public Fpmaddxhi(SPARCAssembler asm, Register src1, Register src2, Register src3, Register dst) {
+            super(asm, Ops.ArithOp.getValue(), Op3s.Impdep2.getValue(), 4, src1.encoding(), src2.encoding(), src3.encoding(), dst.encoding());
+        }
+    }
+
+    public static class Fpmerge extends Fmt3p {
+
+        public Fpmerge(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpmerge, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsub16 extends Fmt3p {
+
+        public Fpsub16(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsub16, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsub16s extends Fmt3p {
+
+        public Fpsub16s(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsub16s, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsub32 extends Fmt3p {
+
+        public Fpsub32(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsub32, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsub32s extends Fmt3p {
+
+        public Fpsub32s(Register src1, Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsub32s, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsub64 extends Fmt3p {
+
+        public Fpsub64(Register src1, Register src2, Register dst) {
+            /* OSA 2011 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsub64, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsubs16 extends Fmt3p {
+
+        public Fpsubs16(Register src1, Register src2, Register dst) {
+            /* OSA 2011 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsubs16, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsubs16s extends Fmt3p {
+
+        public Fpsubs16s(Register src1, Register src2, Register dst) {
+            /* OSA 2011 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsubs16s, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsubs32 extends Fmt3p {
+
+        public Fpsubs32(Register src1, Register src2, Register dst) {
+            /* OSA 2011 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsubs32, src1, src2, dst);
+        }
+    }
+
+    public static class Fpsubs32s extends Fmt3p {
+
+        public Fpsubs32s(Register src1, Register src2, Register dst) {
+            /* OSA 2011 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fpsubs32s, src1, src2, dst);
+        }
+    }
+
     public static class Fsqrtd extends Fmt3p {
 
-        public Fsqrtd(SPARCAssembler masm, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsqrtd.getValue(), 0, src2.encoding(), dst.encoding());
+        public Fsqrtd(Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fsqrtd, SPARC.r0, src2, dst);
+        }
+    }
+
+    public static class Fsrc1d extends Fmt3p {
+
+        public Fsrc1d(Register src1, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fsrc1d, src1, SPARC.r0, dst);
+        }
+    }
+
+    public static class Fsrc1s extends Fmt3p {
+
+        public Fsrc1s(Register src1, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fsrc1s, src1, SPARC.r0, dst);
+        }
+    }
+
+    public static class Fsrc2d extends Fmt3p {
+
+        public Fsrc2d(Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fsrc2d, SPARC.r0, src2, dst);
+        }
+    }
+
+    public static class Fsrc2s extends Fmt3p {
+
+        public Fsrc2s(Register src2, Register dst) {
+            /* VIS1 only */
+            super(Ops.ArithOp, Op3s.Impdep1, Opfs.Fsrc2s, SPARC.r0, src2, dst);
         }
     }
 
     public static class Fsubs extends Fmt3p {
 
-        public Fsubs(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsubs.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fsubs(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fsubs, src1, src2, dst);
         }
     }
 
     public static class Fsubd extends Fmt3p {
 
-        public Fsubd(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsubd.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fsubd(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fsubd, src1, src2, dst);
         }
     }
 
     public static class Fsubq extends Fmt3p {
 
-        public Fsubq(SPARCAssembler masm, Register src1, Register src2, Register dst) {
-            super(masm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fsubq.getValue(), src1.encoding(), src2.encoding(), dst.encoding());
+        public Fsubq(Register src1, Register src2, Register dst) {
+            super(Ops.ArithOp, Op3s.Fpop1, Opfs.Fsubq, src1, src2, dst);
+        }
+    }
+
+    public static class Fzeros extends Fmt3n {
+
+        public Fzeros(SPARCAssembler asm, Register dst) {
+            /* VIS1 only */
+            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzeros.getValue(), 0, dst.encoding());
+        }
+    }
+
+    public static class Fzerod extends Fmt3n {
+
+        public Fzerod(SPARCAssembler asm, Register dst) {
+            /* VIS1 only */
+            super(asm, Ops.ArithOp.getValue(), Op3s.Fpop1.getValue(), Opfs.Fzerod.getValue(), 0, dst.encoding());
         }
     }
 
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/BasicPTXTest.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/BasicPTXTest.java	Mon Jul 01 21:07:21 2013 +0200
@@ -34,16 +34,16 @@
 
     @Test
     public void testAdd() {
-        compile("testAddConst1I");
+        compile("testConstI");
     }
 
     @Ignore
-    public void testAddInvoke() {
-        invoke(compile("testAddConst1I"), new Integer(42));
+    public void testInvoke() {
+        invoke(compile("testConstI"));
     }
 
-    public int testAddConst1I(int a) {
-        return a + 1;
+    public int testConstI() {
+        return 42;
     }
 
     public static void main(String[] args) {
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java	Mon Jul 01 21:07:21 2013 +0200
@@ -32,6 +32,7 @@
 import com.oracle.graal.compiler.ptx.PTXBackend;
 import com.oracle.graal.compiler.test.GraalCompilerTest;
 import com.oracle.graal.debug.Debug;
+import com.oracle.graal.hotspot.meta.HotSpotRuntime;
 import com.oracle.graal.java.GraphBuilderConfiguration;
 import com.oracle.graal.java.GraphBuilderPhase;
 import com.oracle.graal.nodes.StructuredGraph;
@@ -63,9 +64,14 @@
          * GraalCompilerTest.suites variable contains the Suites for the HotSpotRuntime. This code
          * will not run on hotspot, so it should use the plain Graal default suites, without hotspot
          * specific phases.
+         *
+         * Ultimately we might want to have both the kernel and the code natively compiled for GPU fallback to CPU in cases
+         * of ECC failure on kernel invocation.  
          */
-        CompilationResult result = GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, graalRuntime().getReplacements(), ptxBackend, target, null, phasePlan, OptimisticOptimizations.NONE,
-                        new SpeculationLog(), Suites.createDefaultSuites());
+        CompilationResult result = GraalCompiler.compileGraph(graph, cc, graph.method(), runtime,
+                                                              graalRuntime().getReplacements(), ptxBackend, target, null, phasePlan,
+                                                              OptimisticOptimizations.NONE, new SpeculationLog(),
+                                                              Suites.createDefaultSuites(), new ExternalCompilationResult());
         return result;
     }
 
@@ -73,14 +79,12 @@
         return sg;
     }
 
-    @SuppressWarnings("unused")
     protected void invoke(CompilationResult result, Object... args) {
         try {
-            // not quite yet - need multi-architecture Method changes from JDK-8013168
-            // Object[] executeArgs = argsWithReceiver(this, args);
-            // InstalledCode installedCode =
-            // runtime.addMethod(getStructuredGraph().method(), result);
-            // installedCode.executeVarargs(executeArgs);
+            Object[] executeArgs = argsWithReceiver(this, args);
+            HotSpotRuntime hsr = (HotSpotRuntime) runtime;
+            InstalledCode installedCode = hsr.addExternalMethod(sg.method(), result, sg);
+            installedCode.executeVarargs(executeArgs);
         } catch (Throwable th) {
             th.printStackTrace();
         }
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java	Mon Jul 01 21:07:21 2013 +0200
@@ -38,7 +38,8 @@
 
     // detach ??
 
-    public PTXTargetMethodAssembler(TargetDescription target, CodeCacheProvider runtime, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, CompilationResult compilationResult) {
+    public PTXTargetMethodAssembler(TargetDescription target, CodeCacheProvider runtime, FrameMap frameMap,
+                                    AbstractAssembler asm, FrameContext frameContext, CompilationResult compilationResult) {
         super(target, runtime, frameMap, asm, frameContext, compilationResult);
     }
 
@@ -46,16 +47,17 @@
     public CompilationResult finishTargetMethod(StructuredGraph graph) {
         ResolvedJavaMethod method = graph.method();
         assert method != null : graph + " is not associated wth a method";
-        CompilationResult graalCompile = super.finishTargetMethod(graph);
+        ExternalCompilationResult graalCompile = (ExternalCompilationResult) super.finishTargetMethod(graph);
 
         try {
             if (validDevice) {
-                toGPU.generateKernel(graalCompile.getTargetCode(), method.getName());
+                long kernel = toGPU.generateKernel(graalCompile.getTargetCode(), method.getName());
+                graalCompile.setKernel(kernel);
             }
         } catch (Throwable th) {
             th.printStackTrace();
         }
 
-        return graalCompile;  // for now
+        return graalCompile;
     }
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Mon Jul 01 21:07:21 2013 +0200
@@ -442,7 +442,7 @@
                 editPhasePlan(method, graph, phasePlan);
                 CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
                 final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, backend, runtime().getTarget(), null, phasePlan, OptimisticOptimizations.ALL,
-                                new SpeculationLog(), suites);
+                                new SpeculationLog(), suites, new CompilationResult());
                 if (printCompilation) {
                     TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize()));
                 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java	Mon Jul 01 21:07:21 2013 +0200
@@ -60,7 +60,7 @@
         final StructuredGraph graph = parse(method);
         CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
         final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, getDefaultPhasePlan(),
-                        OptimisticOptimizations.ALL, new SpeculationLog(), suites);
+                        OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult());
         for (Infopoint sp : cr.getInfopoints()) {
             assertNotNull(sp.reason);
             if (sp instanceof Call) {
@@ -82,7 +82,7 @@
         assertTrue(graphLineSPs > 0);
         CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
         final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, getDefaultPhasePlan(true),
-                        OptimisticOptimizations.ALL, new SpeculationLog(), suites);
+                        OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult());
         int lineSPs = 0;
         for (Infopoint sp : cr.getInfopoints()) {
             assertNotNull(sp.reason);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jul 01 21:07:21 2013 +0200
@@ -72,10 +72,13 @@
      *            argument can be null.
      * @return the result of the compilation
      */
-    public static CompilationResult compileGraph(final StructuredGraph graph, final CallingConvention cc, final ResolvedJavaMethod installedCodeOwner, final GraalCodeCacheProvider runtime,
-                    final Replacements replacements, final Backend backend, final TargetDescription target, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts,
-                    final SpeculationLog speculationLog, final Suites suites) {
-        final CompilationResult compilationResult = new CompilationResult();
+    public static CompilationResult compileGraph(final StructuredGraph graph, final CallingConvention cc,
+                                                 final ResolvedJavaMethod installedCodeOwner, final GraalCodeCacheProvider runtime,
+                                                 final Replacements replacements, final Backend backend,
+                                                 final TargetDescription target, final GraphCache cache,
+                                                 final PhasePlan plan, final OptimisticOptimizations optimisticOpts,
+                                                 final SpeculationLog speculationLog, final Suites suites,
+                                                 final CompilationResult compilationResult) {
         Debug.scope("GraalCompiler", new Object[]{graph, runtime}, new Runnable() {
 
             public void run() {
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Mon Jul 01 21:07:21 2013 +0200
@@ -207,7 +207,7 @@
         // create suites everytime, as we modify options for the compiler
         final Suites suitesLocal = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
         final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, backend, runtime().getTarget(), null, phasePlan, OptimisticOptimizations.ALL,
-                        new SpeculationLog(), suitesLocal);
+                        new SpeculationLog(), suitesLocal, new CompilationResult());
         addMethod(method, compResult);
 
         AOTCompilation.setValue(originalSetting);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Mon Jul 01 21:07:21 2013 +0200
@@ -161,7 +161,7 @@
                         HotSpotRuntime runtime = graalRuntime.getRuntime();
                         CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
                         return GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, graalRuntime.getBackend(), graalRuntime.getTarget(), graalRuntime.getCache(), plan, optimisticOpts,
-                                        method.getSpeculationLog(), suitesProvider.getDefaultSuites());
+                                        method.getSpeculationLog(), suitesProvider.getDefaultSuites(), new CompilationResult());
                     }
                 });
             } finally {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Mon Jul 01 21:07:21 2013 +0200
@@ -165,12 +165,11 @@
                 }
 
                 String className = je.getName().substring(0, je.getName().length() - ".class".length());
-                className = className.replace('/', '.');
                 classFileCounter++;
 
                 try {
                     // Load and initialize class
-                    Class<?> javaClass = Class.forName(className, true, loader);
+                    Class<?> javaClass = Class.forName(className.replace('/', '.'), true, loader);
 
                     // Pre-load all classes in the constant pool.
                     try {
@@ -181,7 +180,7 @@
                         }
                     } catch (Throwable t) {
                         // If something went wrong during pre-loading we just ignore it.
-                        TTY.println("CompileTheWorld (%d) : Preloading failed for %s", classFileCounter, className);
+                        TTY.println("Preloading failed for (%d) %s", classFileCounter, className);
                     }
 
                     // Are we compiling this class?
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Jul 01 21:07:21 2013 +0200
@@ -408,6 +408,7 @@
     public long newInstanceAddress;
     public long newArrayAddress;
     public long newMultiArrayAddress;
+    public long dynamicNewArrayAddress;
     public long registerFinalizerAddress;
     public long threadIsInterruptedAddress;
     public long vmMessageAddress;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPU.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPU.java	Mon Jul 01 21:07:21 2013 +0200
@@ -24,6 +24,7 @@
 package com.oracle.graal.hotspot.bridge;
 
 import com.oracle.graal.api.code.InvalidInstalledCodeException;
+import com.oracle.graal.hotspot.meta.HotSpotInstalledCode;
 
 /**
  * Calls from Java into the GPU.
@@ -52,4 +53,6 @@
      * @return the value of the bound kernel in GPU space.
      */
     long generateKernel(byte[] code, String name) throws InvalidInstalledCodeException;
+
+    Object executeExternalMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPUImpl.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToGPUImpl.java	Mon Jul 01 21:07:21 2013 +0200
@@ -24,6 +24,7 @@
 package com.oracle.graal.hotspot.bridge;
 
 import com.oracle.graal.api.code.InvalidInstalledCodeException;
+import com.oracle.graal.hotspot.meta.HotSpotInstalledCode;
 
 
 /**
@@ -37,4 +38,5 @@
 
     public native boolean deviceDetach();
 
+    public native Object executeExternalMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Mon Jul 01 21:07:21 2013 +0200
@@ -45,11 +45,20 @@
 
     private final HotSpotResolvedJavaMethod method;
     private final boolean isDefault;
+    private final boolean isExternal;
     private final Graph graph;
 
     public HotSpotNmethod(HotSpotResolvedJavaMethod method, boolean isDefault, Graph graph) {
         this.method = method;
         this.isDefault = isDefault;
+        this.isExternal = false;
+        this.graph = graph;
+    }
+
+    public HotSpotNmethod(HotSpotResolvedJavaMethod method, boolean isDefault, boolean isExternal, Graph graph) {
+        this.method = method;
+        this.isDefault = isDefault;
+        this.isExternal = isExternal;
         this.graph = graph;
     }
 
@@ -57,6 +66,10 @@
         return isDefault;
     }
 
+    public boolean isExternal() {
+        return isExternal;
+    }
+
     public Graph getGraph() {
         return graph;
     }
@@ -107,7 +120,11 @@
     @Override
     public Object executeVarargs(Object... args) throws InvalidInstalledCodeException {
         assert checkArgs(args);
-        return graalRuntime().getCompilerToVM().executeCompiledMethodVarargs(args, this);
+        if (isExternal()) {
+            return graalRuntime().getCompilerToGPU().executeExternalMethodVarargs(args, this);
+        } else {
+            return graalRuntime().getCompilerToVM().executeCompiledMethodVarargs(args, this);
+        }
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Mon Jul 01 21:07:21 2013 +0200
@@ -200,12 +200,12 @@
         if (receiver == null) {
             assert Modifier.isStatic(flags);
             if (holder.isInitialized()) {
-                return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset, true);
+                return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset, graalRuntime().getRuntime().config.useCompressedOops);
             }
             return null;
         } else {
             assert !Modifier.isStatic(flags);
-            return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset, true);
+            return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset, graalRuntime().getRuntime().config.useCompressedOops);
         }
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Mon Jul 01 21:07:21 2013 +0200
@@ -32,7 +32,6 @@
 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*;
 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static com.oracle.graal.hotspot.replacements.WriteBarrierSnippets.*;
 import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*;
@@ -40,8 +39,10 @@
 import static com.oracle.graal.hotspot.nodes.VMErrorNode.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 import static com.oracle.graal.hotspot.replacements.MonitorSnippets.*;
+import static com.oracle.graal.hotspot.replacements.NewObjectSnippets.*;
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
 import static com.oracle.graal.hotspot.replacements.ThreadSubstitutions.*;
+import static com.oracle.graal.hotspot.replacements.WriteBarrierSnippets.*;
 import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*;
 import static com.oracle.graal.hotspot.stubs.NewArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
@@ -288,7 +289,8 @@
         linkForeignCall(r, CREATE_OUT_OF_BOUNDS_EXCEPTION, c.createOutOfBoundsExceptionAddress, PREPEND_THREAD, REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(r, MONITORENTER, c.monitorenterAddress, PREPEND_THREAD, NOT_REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(r, MONITOREXIT, c.monitorexitAddress, PREPEND_THREAD, NOT_REEXECUTABLE, ANY_LOCATION);
-        linkForeignCall(r, NEW_MULTI_ARRAY, c.newMultiArrayAddress, PREPEND_THREAD, NOT_REEXECUTABLE, ANY_LOCATION);
+        linkForeignCall(r, NEW_MULTI_ARRAY, c.newMultiArrayAddress, PREPEND_THREAD, REEXECUTABLE, ANY_LOCATION);
+        linkForeignCall(r, DYNAMIC_NEW_ARRAY, c.dynamicNewArrayAddress, PREPEND_THREAD, REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(r, LOG_PRINTF, c.logPrintfAddress, PREPEND_THREAD, REEXECUTABLE, NO_LOCATIONS);
         linkForeignCall(r, LOG_OBJECT, c.logObjectAddress, PREPEND_THREAD, REEXECUTABLE, NO_LOCATIONS);
         linkForeignCall(r, LOG_PRIMITIVE, c.logPrimitiveAddress, PREPEND_THREAD, REEXECUTABLE, NO_LOCATIONS);
@@ -616,7 +618,7 @@
         } else if (n instanceof UnsafeLoadNode) {
             UnsafeLoadNode load = (UnsafeLoadNode) n;
             assert load.kind() != Kind.Illegal;
-            lowerUnsafeLoad(load);
+            lowerUnsafeLoad(load, tool);
         } else if (n instanceof UnsafeStoreNode) {
             UnsafeStoreNode store = (UnsafeStoreNode) n;
             IndexedLocationNode location = IndexedLocationNode.create(ANY_LOCATION, store.accessKind(), store.displacement(), store.offset(), graph, 1);
@@ -781,6 +783,10 @@
             writeBarrierSnippets.lower((SerialWriteBarrier) n, tool);
         } else if (n instanceof SerialArrayRangeWriteBarrier) {
             writeBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool);
+        } else if (n instanceof G1ArrayRangePreWriteBarrier) {
+            writeBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, tool);
+        } else if (n instanceof G1ArrayRangePostWriteBarrier) {
+            writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool);
         } else if (n instanceof NewMultiArrayNode) {
             if (tool.getLoweringType() == LoweringType.AFTER_GUARDS) {
                 newObjectSnippets.lower((NewMultiArrayNode) n);
@@ -793,9 +799,9 @@
         } else if (n instanceof UnwindNode || n instanceof DeoptimizeNode) {
             // Nothing to do, using direct LIR lowering for these nodes.
         } else if (n instanceof BoxNode) {
-            boxingSnippets.lower((BoxNode) n);
+            boxingSnippets.lower((BoxNode) n, tool);
         } else if (n instanceof UnboxNode) {
-            boxingSnippets.lower((UnboxNode) n);
+            boxingSnippets.lower((UnboxNode) n, tool);
         } else {
             assert false : "Node implementing Lowerable not handled: " + n;
             throw GraalInternalError.shouldNotReachHere();
@@ -849,17 +855,18 @@
      * 
      * </pre>
      * 
-     * TODO (ck): Replace the code below with a snippet.
+     * TODO (ck): Replace the code below with a snippet, properly fix the issue with the unsafe
+     * loads generated by the array copy intrinsics (robust assertions).
      * 
      */
-    private void lowerUnsafeLoad(UnsafeLoadNode load) {
+    private void lowerUnsafeLoad(UnsafeLoadNode load, LoweringTool tool) {
         StructuredGraph graph = load.graph();
         boolean compress = (!load.object().isNullConstant() && load.accessKind() == Kind.Object);
         if (config().useG1GC && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object && !load.object().objectStamp().alwaysNull() && load.object().objectStamp().type() != null &&
-                        !(load.object().objectStamp().type().isArray())) {
+                        !(load.object().objectStamp().type().isArray()) && tool.getLoweringType() != LoweringType.AFTER_GUARDS) {
             IndexedLocationNode location = IndexedLocationNode.create(ANY_LOCATION, load.accessKind(), load.displacement(), load.offset(), graph, 1);
             // Calculate offset+displacement
-            IntegerAddNode addNode = graph.add(new IntegerAddNode(Kind.Long, load.offset(), ConstantNode.forInt(load.displacement(), graph)));
+            IntegerAddNode addNode = graph.add(new IntegerAddNode(Kind.Long, load.offset(), ConstantNode.forLong(load.displacement(), graph)));
             // Compare previous result with referent offset (16)
             CompareNode offsetCondition = CompareNode.createCompareNode(Condition.EQ, addNode, ConstantNode.forLong(referentOffset(), graph));
             // Instance of unsafe load is java.lang.ref.Reference
@@ -1046,6 +1053,21 @@
         return code;
     }
 
+    public InstalledCode addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult, Graph graph) {
+
+        // compResult.getTargetCode() == assembled PTX method string
+
+        HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method;
+        HotSpotInstalledCode icode = new HotSpotNmethod(javaMethod, false, true, graph);
+        HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, -1, compResult);
+        CompilerToVM vm = graalRuntime.getCompilerToVM();
+        CodeInstallResult result = vm.installCode(compiled, icode, null);
+        if (result != CodeInstallResult.OK) {
+            return null;
+        }
+        return icode;
+    }
+
     @Override
     public int encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason) {
         final int actionShift = 0;
@@ -1133,7 +1155,7 @@
                 return Constant.forDouble(base == null ? unsafe.getDouble(displacement) : unsafe.getDouble(base, displacement));
             case Object: {
                 Object o = null;
-                if (compressedPointer) {
+                if (compressedPointer || !this.getGraalRuntime().getRuntime().config.useCompressedOops) {
                     o = unsafe.getObject(base, displacement);
                 } else {
                     o = this.getGraalRuntime().getCompilerToVM().readUnsafeUncompressedPointer(base, displacement);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Mon Jul 01 21:07:21 2013 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.hotspot.phases;
 
-import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.replacements.*;
+import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
+
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.HeapAccess.WriteBarrierType;
 import com.oracle.graal.nodes.extended.*;
@@ -55,7 +55,7 @@
 
     private static void addReadNodeBarriers(ReadNode node, StructuredGraph graph) {
         if (node.getWriteBarrierType() == WriteBarrierType.PRECISE) {
-            assert HotSpotReplacementsUtil.useG1GC();
+            assert useG1GC();
             graph.addAfterFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node, node.location(), false)));
         } else {
             assert node.getWriteBarrierType() == WriteBarrierType.NONE : "Non precise write barrier has been attached to read node.";
@@ -65,14 +65,14 @@
     private static void addWriteNodeBarriers(WriteNode node, StructuredGraph graph) {
         WriteBarrierType barrierType = node.getWriteBarrierType();
         if (barrierType == WriteBarrierType.PRECISE) {
-            if (HotSpotReplacementsUtil.useG1GC()) {
+            if (useG1GC()) {
                 graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true)));
                 graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), true)));
             } else {
                 graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.location(), true)));
             }
         } else if (barrierType == WriteBarrierType.IMPRECISE) {
-            if (HotSpotReplacementsUtil.useG1GC()) {
+            if (useG1GC()) {
                 graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true)));
                 graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), false)));
             } else {
@@ -87,14 +87,14 @@
     private static void addCASBarriers(CompareAndSwapNode node, StructuredGraph graph) {
         WriteBarrierType barrierType = node.getWriteBarrierType();
         if (barrierType == WriteBarrierType.PRECISE) {
-            if (HotSpotReplacementsUtil.useG1GC()) {
+            if (useG1GC()) {
                 graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.expected(), node.getLocation(), false)));
                 graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.newValue(), node.getLocation(), true)));
             } else {
                 graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getLocation(), true)));
             }
         } else if (barrierType == WriteBarrierType.IMPRECISE) {
-            if (HotSpotReplacementsUtil.useG1GC()) {
+            if (useG1GC()) {
                 graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.expected(), node.getLocation(), false)));
                 graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.newValue(), node.getLocation(), false)));
             } else {
@@ -106,8 +106,11 @@
     }
 
     private static void addArrayRangeBarriers(ArrayRangeWriteNode node, StructuredGraph graph) {
-        if (HotSpotReplacementsUtil.useG1GC()) {
-            throw new GraalInternalError("G1 does not yet support barriers for ArrayCopy Intrinsics. Run with -G:-IntrinsifyArrayCopy");
+        if (useG1GC()) {
+            G1ArrayRangePreWriteBarrier g1ArrayRangePreWriteBarrier = graph.add(new G1ArrayRangePreWriteBarrier(node.getArray(), node.getIndex(), node.getLength()));
+            G1ArrayRangePostWriteBarrier g1ArrayRangePostWriteBarrier = graph.add(new G1ArrayRangePostWriteBarrier(node.getArray(), node.getIndex(), node.getLength()));
+            graph.addBeforeFixed(node, g1ArrayRangePreWriteBarrier);
+            graph.addAfterFixed(node, g1ArrayRangePostWriteBarrier);
         } else {
             SerialArrayRangeWriteBarrier serialArrayRangeWriteBarrier = graph.add(new SerialArrayRangeWriteBarrier(node.getArray(), node.getIndex(), node.getLength()));
             graph.addAfterFixed(node, serialArrayRangeWriteBarrier);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Mon Jul 01 21:07:21 2013 +0200
@@ -38,6 +38,7 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -101,7 +102,10 @@
             // This handles both negative array sizes and very large array sizes
             DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
         }
+        return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents);
+    }
 
+    private static Object allocateArrayImpl(Word hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents) {
         Object result;
         int alignment = wordSize();
         int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
@@ -121,12 +125,16 @@
         return unsafeArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic(), anchorNode);
     }
 
+    public static final ForeignCallDescriptor DYNAMIC_NEW_ARRAY = new ForeignCallDescriptor("dynamic_new_array", Object.class, Class.class, int.class);
+
+    @NodeIntrinsic(ForeignCallNode.class)
+    public static native Object dynamicNewArrayStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Class<?> elementType, int length);
+
     @Snippet
     public static Object allocateArrayDynamic(Class<?> elementType, int length, @ConstantParameter boolean fillContents) {
         Word hub = loadWordFromObject(elementType, arrayKlassOffset());
-        if (hub.equal(Word.zero())) {
-            // the array class is not yet loaded
-            DeoptimizeNode.deopt(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved);
+        if (hub.equal(Word.zero()) || !belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
+            return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length);
         }
 
         int layoutHelper = readLayoutHelper(hub);
@@ -147,7 +155,7 @@
         int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask();
         Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION);
 
-        return allocateArray(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents);
+        return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents);
     }
 
     /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Mon Jul 01 21:07:21 2013 +0200
@@ -111,7 +111,7 @@
             // If the previous value has to be loaded (before the write), the load is issued.
             // The load is always issued except the cases of CAS and referent field.
             if (doLoad) {
-                previousOop = (Word) Word.fromObject(UnsafeLoadNode.load(field, 0, 0, Kind.Object));
+                previousOop = (Word) Word.fromObject(field.readObjectCompressed(0));
             }
             // If the previous value is null the barrier should not be issued.
             if (previousOop.notEqual(0)) {
@@ -187,6 +187,79 @@
         }
     }
 
+    @Snippet
+    public static void g1ArrayRangePreWriteBarrier(Object object, int startIndex, int length) {
+        Object dest = FixedValueAnchorNode.getObject(object);
+        Word thread = thread();
+        byte markingValue = thread.readByte(g1SATBQueueMarkingOffset());
+        Word bufferAddress = thread.readWord(g1SATBQueueBufferOffset());
+        Word indexAddress = thread.add(g1SATBQueueIndexOffset());
+        Word indexValue = indexAddress.readWord(0);
+
+        // If the concurrent marker is not enabled return.
+        if (markingValue == (byte) 0) {
+            return;
+        }
+        Word oop;
+        final int scale = arrayIndexScale(Kind.Object);
+        int header = arrayBaseOffset(Kind.Object);
+
+        for (int i = startIndex; i < length; i++) {
+            Word address = (Word) Word.fromObject(dest).add(header).add(Word.unsigned(i * (long) scale));
+            oop = (Word) Word.fromObject(address.readObjectCompressed(0));
+            if (oop.notEqual(0)) {
+                if (indexValue.notEqual(0)) {
+                    Word nextIndex = indexValue.subtract(wordSize());
+                    Word logAddress = bufferAddress.add(nextIndex);
+                    // Log the object to be marked as well as update the SATB's buffer next index.
+                    logAddress.writeWord(0, oop);
+                    indexAddress.writeWord(0, nextIndex);
+                } else {
+                    g1PreBarrierStub(G1WBPRECALL, oop.toObject());
+                }
+            }
+        }
+    }
+
+    @Snippet
+    public static void g1ArrayRangePostWriteBarrier(Object object, int startIndex, int length) {
+        Object dest = FixedValueAnchorNode.getObject(object);
+        Word thread = thread();
+        Word bufferAddress = thread.readWord(g1CardQueueBufferOffset());
+        Word indexAddress = thread.add(g1CardQueueIndexOffset());
+        Word indexValue = thread.readWord(g1CardQueueIndexOffset());
+
+        int cardShift = cardTableShift();
+        long cardStart = cardTableStart();
+        final int scale = arrayIndexScale(Kind.Object);
+        int header = arrayBaseOffset(Kind.Object);
+        long dstAddr = GetObjectAddressNode.get(dest);
+        long start = (dstAddr + header + (long) startIndex * scale) >>> cardShift;
+        long end = (dstAddr + header + ((long) startIndex + length - 1) * scale) >>> cardShift;
+        long count = end - start + 1;
+
+        while (count-- > 0) {
+            Word cardAddress = Word.unsigned((start + cardStart) + count);
+            byte cardByte = cardAddress.readByte(0);
+            // If the card is already dirty, (hence already enqueued) skip the insertion.
+            if (cardByte != (byte) 0) {
+                cardAddress.writeByte(0, (byte) 0);
+                // If the thread local card queue is full, issue a native call which will
+                // initialize a new one and add the card entry.
+                if (indexValue.notEqual(0)) {
+                    Word nextIndex = indexValue.subtract(wordSize());
+                    Word logAddress = bufferAddress.add(nextIndex);
+                    // Log the object to be scanned as well as update
+                    // the card queue's next index.
+                    logAddress.writeWord(0, cardAddress);
+                    indexAddress.writeWord(0, nextIndex);
+                } else {
+                    g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
+                }
+            }
+        }
+    }
+
     public static final ForeignCallDescriptor G1WBPRECALL = new ForeignCallDescriptor("write_barrier_pre", void.class, Object.class);
 
     @NodeIntrinsic(ForeignCallNode.class)
@@ -203,6 +276,8 @@
         private final SnippetInfo serialArrayRangeWriteBarrier = snippet(WriteBarrierSnippets.class, "serialArrayRangeWriteBarrier");
         private final SnippetInfo g1PreWriteBarrier = snippet(WriteBarrierSnippets.class, "g1PreWriteBarrier");
         private final SnippetInfo g1PostWriteBarrier = snippet(WriteBarrierSnippets.class, "g1PostWriteBarrier");
+        private final SnippetInfo g1ArrayRangePreWriteBarrier = snippet(WriteBarrierSnippets.class, "g1ArrayRangePreWriteBarrier");
+        private final SnippetInfo g1ArrayRangePostWriteBarrier = snippet(WriteBarrierSnippets.class, "g1ArrayRangePostWriteBarrier");
 
         public Templates(CodeCacheProvider runtime, Replacements replacements, TargetDescription target) {
             super(runtime, replacements, target);
@@ -241,5 +316,21 @@
             args.addConst("usePrecise", writeBarrierPost.usePrecise());
             template(args).instantiate(runtime, writeBarrierPost, DEFAULT_REPLACER, args);
         }
+
+        public void lower(G1ArrayRangePreWriteBarrier arrayRangeWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) {
+            Arguments args = new Arguments(g1ArrayRangePreWriteBarrier);
+            args.add("object", arrayRangeWriteBarrier.getObject());
+            args.add("startIndex", arrayRangeWriteBarrier.getStartIndex());
+            args.add("length", arrayRangeWriteBarrier.getLength());
+            template(args).instantiate(runtime, arrayRangeWriteBarrier, DEFAULT_REPLACER, args);
+        }
+
+        public void lower(G1ArrayRangePostWriteBarrier arrayRangeWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) {
+            Arguments args = new Arguments(g1ArrayRangePostWriteBarrier);
+            args.add("object", arrayRangeWriteBarrier.getObject());
+            args.add("startIndex", arrayRangeWriteBarrier.getStartIndex());
+            args.add("length", arrayRangeWriteBarrier.getLength());
+            template(args).instantiate(runtime, arrayRangeWriteBarrier, DEFAULT_REPLACER, args);
+        }
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Jul 01 21:07:21 2013 +0200
@@ -156,7 +156,7 @@
                     phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
                     CallingConvention cc = linkage.getCallingConvention();
                     final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, getInstalledCodeOwner(), runtime, replacements, backend, runtime.getTarget(), null, phasePlan,
-                                    OptimisticOptimizations.ALL, new SpeculationLog(), runtime.getDefaultSuites());
+                                    OptimisticOptimizations.ALL, new SpeculationLog(), runtime.getDefaultSuites(), new CompilationResult());
 
                     assert destroyedRegisters != null;
                     code = Debug.scope("CodeInstall", new Callable<InstalledCode>() {
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java	Mon Jul 01 21:07:21 2013 +0200
@@ -50,6 +50,6 @@
         phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
         CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
         Backend backend = Graal.getRequiredCapability(Backend.class);
-        GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, backend, runtime.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites);
+        GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, backend, runtime.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult());
     }
 }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_newarray.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_newarray.java	Mon Jul 01 21:07:21 2013 +0200
@@ -23,12 +23,14 @@
 package com.oracle.graal.jtt.bytecode;
 
 import com.oracle.graal.jtt.*;
+
 import org.junit.*;
 
 /*
  */
 public class BC_newarray extends JTTTest {
 
+    @SuppressWarnings("all")
     public static int test(int a) {
         if (new boolean[3] == null) {
             return -1;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_newarray.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_newarray.java	Mon Jul 01 21:07:21 2013 +0200
@@ -26,12 +26,14 @@
 package com.oracle.graal.jtt.except;
 
 import com.oracle.graal.jtt.*;
+
 import org.junit.*;
 
 /*
  */
 public class BC_newarray extends JTTTest {
 
+    @SuppressWarnings("all")
     public static int test(int a) {
         if (new boolean[a] == null) {
             return -1;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis02.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis02.java	Mon Jul 01 21:07:21 2013 +0200
@@ -29,15 +29,26 @@
  */
 public class System_currentTimeMillis02 extends JTTTest {
 
+    static void m(long[] times) {
+        times[1] = System.currentTimeMillis() - times[0];
+    }
+
     public static boolean test() {
-        long start = System.currentTimeMillis();
-        long delta = 0;
-        for (int i = 0; delta == 0 && i < 5000000; i++) {
-            delta = System.currentTimeMillis() - start;
+        long[] times = new long[2];  // { start, delta }
+        times[0] = System.currentTimeMillis();
+        times[1] = 0;
+        // force compilation:
+        for (int i = 0; i < 5000; i++) {
+            m(times);
+        }
+        times[0] = System.currentTimeMillis();
+        times[1] = 0;
+        for (int i = 0; times[1] == 0 && i < 5000000; i++) {
+            m(times);
             // do nothing.
         }
         // better get at least 100 millisecond resolution.
-        return delta >= 1 && delta < 100;
+        return times[1] >= 1 && times[1] < 100;
     }
 
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/InferStamp01.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,110 @@
+/*
+ * 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.jtt.optimize;
+
+import com.oracle.graal.jtt.*;
+import org.junit.*;
+
+/**
+ * test some stamps in combination with full loop unrolling and shifts.
+ */
+public class InferStamp01 extends JTTTest {
+
+    public static int testi0(int arg) {
+        int a = arg;
+        for (int i = 0; i < 2; i++) {
+            a = a >> 16;
+        }
+        return a;
+    }
+
+    @Test
+    public void runi0() throws Throwable {
+        runTest("testi0", 0x7788_99aa);
+    }
+
+    public static int testi1(int arg) {
+        int a = arg;
+        for (int i = 0; i < 2; i++) {
+            a = a >>> 16;
+        }
+        return a;
+    }
+
+    @Test
+    public void runi1() throws Throwable {
+        runTest("testi1", 0x7788_99aa);
+    }
+
+    public static int testi2(int arg) {
+        int a = arg;
+        for (int i = 0; i < 2; i++) {
+            a = a << 16;
+        }
+        return a;
+    }
+
+    @Test
+    public void runi2() throws Throwable {
+        runTest("testi2", 0x7788_99aa);
+    }
+
+    public static long testl0(long arg) {
+        long a = arg;
+        for (long i = 0; i < 2; i++) {
+            a = a >> 32;
+        }
+        return a;
+    }
+
+    @Test
+    public void runl0() throws Throwable {
+        runTest("testl0", 0x3344_5566_7788_99aaL);
+    }
+
+    public static long testl1(long arg) {
+        long a = arg;
+        for (long i = 0; i < 2; i++) {
+            a = a >>> 32;
+        }
+        return a;
+    }
+
+    @Test
+    public void runl1() throws Throwable {
+        runTest("testl1", 0x3344_5566_7788_99aaL);
+    }
+
+    public static long testl2(long arg) {
+        long a = arg;
+        for (long i = 0; i < 2; i++) {
+            a = a << 32;
+        }
+        return a;
+    }
+
+    @Test
+    public void runl2() throws Throwable {
+        runTest("testl2", 0x3344_5566_7788_99aaL);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/LongToSomethingArray01.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2011, 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.jtt.optimize;
+
+import org.junit.*;
+
+import com.oracle.graal.jtt.*;
+
+/**
+ * inspired by java.security.SecureRandom.longToByteArray(long).
+ * 
+ */
+public class LongToSomethingArray01 extends JTTTest {
+
+    public static byte[] longToByteArray(long arg) {
+        long l = arg;
+        byte[] ret = new byte[8];
+        for (int i = 0; i < 8; i++) {
+            ret[i] = (byte) (l & 0xff);
+            l = l >> 8;
+        }
+        return ret;
+    }
+
+    @Test
+    public void runB0() throws Throwable {
+        runTest("longToByteArray", 0x1122_3344_5566_7788L);
+    }
+
+    public static short[] longToShortArray(long arg) {
+        long l = arg;
+        short[] ret = new short[4];
+        for (int i = 0; i < 4; i++) {
+            ret[i] = (short) (l & 0xffff);
+            l = l >> 16;
+        }
+        return ret;
+    }
+
+    @Test
+    public void runS0() throws Throwable {
+        runTest("longToShortArray", 0x1122_3344_5566_7788L);
+    }
+
+    public static int[] longToIntArray(long arg) {
+        long l = arg;
+        int[] ret = new int[2];
+        for (int i = 0; i < 2; i++) {
+            ret[i] = (int) (l & 0xffff_ffff);
+            l = l >> 32;
+        }
+        return ret;
+    }
+
+    @Test
+    public void runI0() throws Throwable {
+        runTest("longToIntArray", 0x1122_3344_5566_7788L);
+    }
+
+    public static long[] longToLongArray(long arg) {
+        long l = arg;
+        long[] ret = new long[1];
+        for (int i = 0; i < 1; i++) {
+            ret[i] = l & 0xffff_ffff_ffff_ffffL;
+            l = l >> 64;
+        }
+        return ret;
+    }
+
+    @Test
+    public void runL0() throws Throwable {
+        runTest("longToLongArray", 0x1122_3344_5566_7788L);
+    }
+}
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Mon Jul 01 21:07:21 2013 +0200
@@ -230,7 +230,6 @@
         }
     }
 
-    @SuppressWarnings("unused")
     public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) {
         int exceptionOffset = -1;
         if (isConstant(src1)) {
@@ -382,30 +381,30 @@
                 case LREM:
                     throw new InternalError("NYI");
                 case FADD:
-                    new Fadds(masm, asFloatReg(src1), asFloatReg(src2), asFloatReg(dst));
+                    new Fadds(asFloatReg(src1), asFloatReg(src2), asFloatReg(dst)).emit(masm);
                     break;
                 case FSUB:
-                    new Fsubs(masm, asFloatReg(src1), asFloatReg(src2), asFloatReg(dst));
+                    new Fsubs(asFloatReg(src1), asFloatReg(src2), asFloatReg(dst)).emit(masm);
                     break;
                 case FMUL:
-                    new Fmuls(masm, asFloatReg(src1), asFloatReg(src2), asFloatReg(dst));
+                    new Fmuls(asFloatReg(src1), asFloatReg(src2), asFloatReg(dst)).emit(masm);
                     break;
                 case FDIV:
-                    new Fdivs(masm, asFloatReg(src1), asFloatReg(src2), asFloatReg(dst));
+                    new Fdivs(asFloatReg(src1), asFloatReg(src2), asFloatReg(dst)).emit(masm);
                     break;
                 case FREM:
                     throw new InternalError("NYI");
                 case DADD:
-                    new Faddd(masm, asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst));
+                    new Faddd(asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst)).emit(masm);
                     break;
                 case DSUB:
-                    new Fsubd(masm, asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst));
+                    new Fsubd(asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst)).emit(masm);
                     break;
                 case DMUL:
-                    new Fmuld(masm, asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst));
+                    new Fmuld(asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst)).emit(masm);
                     break;
                 case DDIV:
-                    new Fdivd(masm, asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst));
+                    new Fdivd(asDoubleReg(src1), asDoubleReg(src2), asDoubleReg(dst)).emit(masm);
                     break;
                 case DREM:
                     throw new InternalError("NYI");
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java	Mon Jul 01 21:07:21 2013 +0200
@@ -48,11 +48,10 @@
     }
 
     @Override
-    @SuppressWarnings("unused")
     public void emitCode(TargetMethodAssembler tasm, SPARCAssembler asm) {
         switch (opcode) {
             case SQRT:
-                new Fsqrtd(asm, asDoubleReg(result), asDoubleReg(input));
+                new Fsqrtd(asDoubleReg(result), asDoubleReg(input)).emit(asm);
                 break;
             case LOG:
             case LOG10:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ArrayRangeWriteBarrier.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,43 @@
+/*
+ * 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.nodes;
+
+public abstract class ArrayRangeWriteBarrier extends WriteBarrier {
+
+    @Input private ValueNode startIndex;
+    @Input private ValueNode length;
+
+    public ValueNode getStartIndex() {
+        return startIndex;
+    }
+
+    public ValueNode getLength() {
+        return length;
+    }
+
+    public ArrayRangeWriteBarrier(ValueNode object, ValueNode startIndex, ValueNode length) {
+        super(object, null, true);
+        this.startIndex = startIndex;
+        this.length = length;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/G1ArrayRangePostWriteBarrier.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,30 @@
+/*
+ * 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.nodes;
+
+public final class G1ArrayRangePostWriteBarrier extends ArrayRangeWriteBarrier {
+
+    public G1ArrayRangePostWriteBarrier(ValueNode object, ValueNode startIndex, ValueNode length) {
+        super(object, startIndex, length);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/G1ArrayRangePreWriteBarrier.java	Mon Jul 01 21:07:21 2013 +0200
@@ -0,0 +1,30 @@
+/*
+ * 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.nodes;
+
+public final class G1ArrayRangePreWriteBarrier extends ArrayRangeWriteBarrier {
+
+    public G1ArrayRangePreWriteBarrier(ValueNode object, ValueNode startIndex, ValueNode length) {
+        super(object, startIndex, length);
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/SerialArrayRangeWriteBarrier.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/SerialArrayRangeWriteBarrier.java	Mon Jul 01 21:07:21 2013 +0200
@@ -22,37 +22,9 @@
  */
 package com.oracle.graal.nodes;
 
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-
-public final class SerialArrayRangeWriteBarrier extends FixedWithNextNode implements Lowerable {
-
-    @Input private ValueNode object;
-    @Input private ValueNode startIndex;
-    @Input private ValueNode length;
-
-    public ValueNode getObject() {
-        return object;
-    }
-
-    public ValueNode getStartIndex() {
-        return startIndex;
-    }
-
-    public ValueNode getLength() {
-        return length;
-    }
+public final class SerialArrayRangeWriteBarrier extends ArrayRangeWriteBarrier {
 
     public SerialArrayRangeWriteBarrier(ValueNode object, ValueNode startIndex, ValueNode length) {
-        super(StampFactory.forVoid());
-        this.object = object;
-        this.startIndex = startIndex;
-        this.length = length;
-
+        super(object, startIndex, length);
     }
-
-    public void lower(LoweringTool generator, LoweringType loweringType) {
-        generator.getRuntime().lower(this, generator);
-    }
-
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/LeftShiftNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/LeftShiftNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -71,7 +71,7 @@
                     if (other instanceof LeftShiftNode) {
                         int total = amount + otherAmount;
                         if (total != (total & mask)) {
-                            return ConstantNode.forInt(0, graph());
+                            return ConstantNode.forIntegerKind(kind(), 0, graph());
                         }
                         return graph().unique(new LeftShiftNode(kind(), other.x(), ConstantNode.forInt(total, graph())));
                     } else if ((other instanceof RightShiftNode || other instanceof UnsignedRightShiftNode) && otherAmount == amount) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/RightShiftNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/RightShiftNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -68,7 +68,7 @@
                     if (other instanceof RightShiftNode) {
                         int total = amount + otherAmount;
                         if (total != (total & mask)) {
-                            return ConstantNode.forInt(0, graph());
+                            return ConstantNode.forIntegerKind(kind(), 0, graph());
                         }
                         return graph().unique(new RightShiftNode(kind(), other.x(), ConstantNode.forInt(total, graph())));
                     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRightShiftNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRightShiftNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -71,7 +71,7 @@
                     if (other instanceof UnsignedRightShiftNode) {
                         int total = amount + otherAmount;
                         if (total != (total & mask)) {
-                            return ConstantNode.forInt(0, graph());
+                            return ConstantNode.forIntegerKind(kind(), 0, graph());
                         }
                         return graph().unique(new UnsignedRightShiftNode(kind(), other.x(), ConstantNode.forInt(total, graph())));
                     } else if (other instanceof LeftShiftNode && otherAmount == amount) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.virtual.*;
@@ -32,7 +33,7 @@
  * This node represents the boxing of a primitive value. This corresponds to a call to the valueOf
  * methods in Integer, Long, etc.
  */
-public class BoxNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable, Canonicalizable {
+public class BoxNode extends FloatingNode implements VirtualizableAllocation, Lowerable, Canonicalizable {
 
     @Input private ValueNode value;
     private final Kind boxingKind;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -24,10 +24,11 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-public class UnboxNode extends FixedWithNextNode implements Virtualizable, Lowerable, Canonicalizable {
+public class UnboxNode extends FloatingNode implements Virtualizable, Lowerable, Canonicalizable {
 
     @Input private ValueNode value;
     private final Kind boxingKind;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Mon Jul 01 21:07:21 2013 +0200
@@ -22,8 +22,6 @@
  */
 package com.oracle.graal.nodes.java;
 
-import java.lang.reflect.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
@@ -81,7 +79,5 @@
     }
 
     @NodeIntrinsic
-    public static Object newArray(Class<?> componentType, int length) {
-        return Array.newInstance(componentType, length);
-    }
+    public static native Object newArray(Class<?> componentType, int length);
 }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java	Mon Jul 01 21:07:21 2013 +0200
@@ -23,11 +23,9 @@
 package com.oracle.graal.replacements.test;
 
 import java.lang.reflect.*;
-import java.util.*;
 
 import org.junit.*;
 
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.test.*;
 
 /**
@@ -74,10 +72,12 @@
     }
 
     @Test
-    public void testDeopt() {
+    public void testStub() {
         Method method = getMethod("dynamic");
+        // this will use the stub call because Element[] is not loaded
         Result actual1 = executeActual(method, null, Element.class, 7);
-        Result actual2 = executeActualCheckDeopt(method, Collections.<DeoptimizationReason> singleton(DeoptimizationReason.Unresolved), null, Element.class, 7);
+        // this call will use the fast path
+        Result actual2 = executeActual(method, null, Element.class, 7);
         Result expected = executeExpected(method, null, Element.class, 7);
         assertEquals(actual1, expected);
         assertEquals(actual2, expected);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java	Mon Jul 01 21:07:21 2013 +0200
@@ -35,7 +35,7 @@
 public class ArraySubstitutions {
 
     @MethodSubstitution
-    public static Object newArray(Class<?> componentType, int length) throws NegativeArraySizeException {
+    public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeException {
         if (componentType == null) {
             DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.NullCheckException);
         }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Mon Jul 01 21:07:21 2013 +0200
@@ -37,6 +37,7 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
@@ -213,28 +214,30 @@
             }
         }
 
-        public void lower(BoxNode box) {
+        public void lower(BoxNode box, LoweringTool tool) {
             FloatingNode canonical = canonicalizeBoxing(box, runtime);
             // if in AOT mode, we don't want to embed boxed constants.
-            if (!AOTCompilation.getValue() && canonical != null) {
-                box.graph().replaceFixedWithFloating(box, canonical);
+            if (canonical != null && !AOTCompilation.getValue()) {
+                box.graph().replaceFloating(box, canonical);
             } else {
                 Arguments args = new Arguments(boxSnippets.get(box.getBoxingKind()));
                 args.add("value", box.getValue());
 
                 SnippetTemplate template = template(args);
                 Debug.log("Lowering integerValueOf in %s: node=%s, template=%s, arguments=%s", box.graph(), box, template, args);
-                template.instantiate(runtime, box, DEFAULT_REPLACER, args);
+                template.instantiate(runtime, box, DEFAULT_REPLACER, tool, args);
+                GraphUtil.killWithUnusedFloatingInputs(box);
             }
         }
 
-        public void lower(UnboxNode unbox) {
+        public void lower(UnboxNode unbox, LoweringTool tool) {
             Arguments args = new Arguments(unboxSnippets.get(unbox.getBoxingKind()));
             args.add("value", unbox.getValue());
 
             SnippetTemplate template = template(args);
             Debug.log("Lowering integerValueOf in %s: node=%s, template=%s, arguments=%s", unbox.graph(), unbox, template, args);
-            template.instantiate(runtime, unbox, DEFAULT_REPLACER, args);
+            template.instantiate(runtime, unbox, DEFAULT_REPLACER, tool, args);
+            GraphUtil.killWithUnusedFloatingInputs(unbox);
         }
     }
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Mon Jul 01 21:07:21 2013 +0200
@@ -304,7 +304,7 @@
         } else if (usage instanceof UnboxNode) {
             UnboxNode unbox = (UnboxNode) usage;
             unbox.replaceAtUsages(intrinsifiedNode);
-            graph.removeFixed(unbox);
+            graph.removeFloating(unbox);
             Debug.log("%s: Removed an UnboxNode", Debug.contextSnapshot(JavaMethod.class));
         } else if (usage instanceof MethodCallTargetNode) {
             MethodCallTargetNode checkCastCallTarget = (MethodCallTargetNode) usage;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Mon Jul 01 21:07:21 2013 +0200
@@ -142,7 +142,7 @@
             @Override
             public CompilationResult call() {
                 CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false);
-                return GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, plan, OptimisticOptimizations.ALL, new SpeculationLog(), suites);
+                return GraalCompiler.compileGraph(graph, cc, graph.method(), runtime, replacements, backend, runtime.getTarget(), null, plan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, new CompilationResult());
             }
         });
 
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java	Mon Jul 01 21:07:21 2013 +0200
@@ -586,6 +586,19 @@
     Object readObject(WordBase offset);
 
     /**
+     * Reads the memory at address {@code (this + offset)} and uncompresses it. Both the base
+     * address and offset are in bytes.
+     * <p>
+     * The offset is always treated as a {@link Signed} value. However, the static type is
+     * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller
+     * knows that the highest-order bit of the unsigned value is never used).
+     * 
+     * @param offset the signed offset for the memory access
+     * @return the result of the memory access
+     */
+    Object readObjectCompressed(WordBase offset);
+
+    /**
      * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
      * bytes.
      * 
@@ -667,6 +680,15 @@
     Object readObject(int offset);
 
     /**
+     * Reads the memory at address {@code (this + offset)} and decompressed it. Both the base
+     * address and offset are in bytes.
+     * 
+     * @param offset the signed offset for the memory access
+     * @return the result of the memory access
+     */
+    Object readObjectCompressed(int offset);
+
+    /**
      * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
      * bytes.
      * <p>
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Mon Jul 01 21:07:21 2013 +0200
@@ -59,6 +59,7 @@
          COMPARISON,
          NOT,
          READ,
+         READ_COMPRESSED,
          WRITE,
          ZERO,
          FROM_UNSIGNED,
@@ -867,6 +868,10 @@
     public native Object readObject(WordBase offset);
 
     @Override
+    @Operation(opcode = Opcode.READ_COMPRESSED)
+    public native Object readObjectCompressed(WordBase offset);
+
+    @Override
     @Operation(opcode = Opcode.READ)
     public byte readByte(int offset) {
         return readByte(signed(offset));
@@ -921,6 +926,12 @@
     }
 
     @Override
+    @Operation(opcode = Opcode.READ_COMPRESSED)
+    public Object readObjectCompressed(int offset) {
+        return readObjectCompressed(signed(offset));
+    }
+
+    @Override
     @Operation(opcode = Opcode.WRITE)
     public void writeByte(WordBase offset, byte val) {
         unsafe.putByte(add((Word) offset).unbox(), val);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Mon Jul 01 20:58:32 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Mon Jul 01 21:07:21 2013 +0200
@@ -169,7 +169,19 @@
                         } else {
                             location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
                         }
-                        replace(invoke, readOp(graph, arguments.get(0), invoke, location));
+                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, false));
+                        break;
+                    }
+                    case READ_COMPRESSED: {
+                        assert arguments.size() == 2 || arguments.size() == 3;
+                        Kind readKind = asKind(callTargetNode.returnType());
+                        LocationNode location;
+                        if (arguments.size() == 2) {
+                            location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
+                        } else {
+                            location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
+                        }
+                        replace(invoke, readOp(graph, arguments.get(0), invoke, location, true));
                         break;
                     }
                     case WRITE: {
@@ -309,8 +321,8 @@
         return IndexedLocationNode.create(locationIdentity, readKind, 0, offset, graph, 1);
     }
 
-    private static ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location) {
-        ReadNode read = graph.add(new ReadNode(base, location, invoke.asNode().stamp(), WriteBarrierType.NONE, false));
+    private static ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location, boolean compress) {
+        ReadNode read = graph.add(new ReadNode(base, location, invoke.asNode().stamp(), WriteBarrierType.NONE, compress));
         graph.addBeforeFixed(invoke.asNode(), read);
         // The read must not float outside its block otherwise it may float above an explicit zero
         // check on its base address
--- a/mx/commands.py	Mon Jul 01 20:58:32 2013 +0200
+++ b/mx/commands.py	Mon Jul 01 21:07:21 2013 +0200
@@ -33,6 +33,7 @@
 import sanitycheck
 import json, textwrap
 
+# This works because when mx loads this file, it makes sure __file__ gets an absolute path
 _graal_home = dirname(dirname(__file__))
 
 """ Used to distinguish an exported GraalVM (see 'mx export'). """
@@ -56,6 +57,8 @@
 
 _workdir = None
 
+_vmdir = None
+
 _native_dbg = None
 
 _make_eclipse_launch = False
@@ -266,20 +269,20 @@
     return join(_vmLibDirInJdk(jdk), 'jvm.cfg')
 
 def _jdksDir():
-    return join(_graal_home, 'jdk' + str(mx.java().version))
+    return os.path.abspath(_vmdir if _vmdir else join(_graal_home, 'jdk' + str(mx.java().version)))
 
-def _jdk(build='product', vmToCheck=None, create=False):
+def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=True):
     """
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
     jdk = join(_jdksDir(), build)
-    srcJdk = mx.java().jdk
-    jdkContents = ['bin', 'include', 'jre', 'lib']
-    if exists(join(srcJdk, 'db')):
-        jdkContents.append('db')
-    if mx.get_os() != 'windows' and exists(join(srcJdk, 'man')):
-        jdkContents.append('man')
     if create:
+        srcJdk = mx.java().jdk
+        jdkContents = ['bin', 'include', 'jre', 'lib']
+        if exists(join(srcJdk, 'db')):
+            jdkContents.append('db')
+        if mx.get_os() != 'windows' and exists(join(srcJdk, 'man')):
+            jdkContents.append('man')
         if not exists(jdk):
             mx.log('Creating ' + jdk + ' from ' + srcJdk)
             os.makedirs(jdk)
@@ -330,7 +333,8 @@
             vmOption = ' --vm ' + vmToCheck if vmToCheck else ''
             mx.abort('The ' + build + ' VM has not been created - run "mx' + vmOption + ' build ' + build + '"')
             
-    _installGraalJarInJdks(mx.distribution('GRAAL'))
+    if installGraalJar:
+        _installGraalJarInJdks(mx.distribution('GRAAL'))
     
     if vmToCheck is not None:
         jvmCfg = _vmCfgInJdk(jdk)
@@ -348,7 +352,7 @@
 def _installGraalJarInJdks(graalDist):
     graalJar = graalDist.path
     graalOptions = join(_graal_home, 'graal.options')
-    jdks = join(_graal_home, 'jdk' + str(mx.java().version))
+    jdks = _jdksDir()
     if exists(jdks):
         for e in os.listdir(jdks):
             jreLibDir = join(jdks, e, 'jre', 'lib')
@@ -424,7 +428,7 @@
     """print the JDK directory selected for the 'vm' command"""
 
     build = _vmbuild if _vmSourcesAvailable else 'product'
-    print join(_graal_home, 'jdk' + str(mx.java().version), build)
+    print _jdk(build, installGraalJar=False)
 
 def buildvars(args):
     """Describes the variables that can be set by the -D option to the 'mx build' commmand"""
@@ -495,7 +499,7 @@
         if build == 'ide-build-target':
             build = os.environ.get('IDE_BUILD_TARGET', 'product')
             if len(build) == 0:
-                mx.log('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]')
+                mx.logv('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]')
                 continue
 
         jdk = _jdk(build, create=True)
@@ -536,7 +540,7 @@
                     break
 
         if not mustBuild:
-            mx.log('[all files in src and make directories are older than ' + timestampFile[len(_graal_home) + 1:] + ' - skipping native build]')
+            mx.logv('[all files in src and make directories are older than ' + timestampFile[len(_graal_home) + 1:] + ' - skipping native build]')
             continue
 
         if platform.system() == 'Windows':
@@ -1034,17 +1038,17 @@
 def gv(args):
     """run the Graal Visualizer"""
     with open(join(_graal_home, '.graal_visualizer.log'), 'w') as fp:
-        mx.log('[Graal Visualizer log is in ' + fp.name + ']')
+        mx.logv('[Graal Visualizer log is in ' + fp.name + ']')
         if not exists(join(_graal_home, 'visualizer', 'build.xml')):
-            mx.log('[This initial execution may take a while as the NetBeans platform needs to be downloaded]')
+            mx.logv('[This initial execution may take a while as the NetBeans platform needs to be downloaded]')
         mx.run(['ant', '-f', join(_graal_home, 'visualizer', 'build.xml'), '-l', fp.name, 'run'])
 
 def igv(args):
     """run the Ideal Graph Visualizer"""
     with open(join(_graal_home, '.ideal_graph_visualizer.log'), 'w') as fp:
-        mx.log('[Ideal Graph Visualizer log is in ' + fp.name + ']')
+        mx.logv('[Ideal Graph Visualizer log is in ' + fp.name + ']')
         if not exists(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'nbplatform')):
-            mx.log('[This initial execution may take a while as the NetBeans platform needs to be downloaded]')
+            mx.logv('[This initial execution may take a while as the NetBeans platform needs to be downloaded]')
         mx.run(['ant', '-f', join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'), '-l', fp.name, 'run'])
 
 def bench(args):
@@ -1310,6 +1314,7 @@
 
     mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])
     mx.add_argument('--workdir', help='runs the VM in the given directory', default=None)
+    mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None)
 
     if (_vmSourcesAvailable):
         mx.add_argument('--vm', action='store', dest='vm', default='graal', choices=_vmChoices, help='the VM to build/run (default: ' + _vmChoices[0] + ')')
@@ -1344,6 +1349,8 @@
     _jacoco = opts.jacoco
     global _workdir
     _workdir = opts.workdir
+    global _vmdir
+    _vmdir = opts.vmdir
     global _native_dbg
     _native_dbg = opts.native_dbg
 
--- a/mxtool/mx.py	Mon Jul 01 20:58:32 2013 +0200
+++ b/mxtool/mx.py	Mon Jul 01 21:07:21 2013 +0200
@@ -606,12 +606,15 @@
         e = join(mxDir, 'env')
         if exists(e):
             with open(e) as f:
+                lineNum = 0
                 for line in f:
+                    lineNum = lineNum + 1
                     line = line.strip()
                     if len(line) != 0 and line[0] != '#':
+                        if not '=' in line:
+                            abort(e + ':' + str(lineNum) + ': line does not match pattern "key=value"')
                         key, value = line.split('=', 1)
                         os.environ[key.strip()] = expandvars_in_property(value.strip())
-
     def _post_init(self, opts):
         mxDir = join(self.dir, 'mx')
         self._load_projects(mxDir)
@@ -1226,6 +1229,10 @@
     value = os.environ.get(key, default)
     return value
 
+def logv(msg=None):
+    if _opts.verbose:
+        log(msg)
+    
 def log(msg=None):
     """
     Write a message to the console.
@@ -1528,11 +1535,11 @@
                             break
 
         if not mustBuild:
-            log('[all class files for {0} are up to date - skipping]'.format(p.name))
+            logv('[all class files for {0} are up to date - skipping]'.format(p.name))
             continue
 
         if len(javafilelist) == 0:
-            log('[no Java sources for {0} - skipping]'.format(p.name))
+            logv('[no Java sources for {0} - skipping]'.format(p.name))
             continue
 
         built.add(p.name)
@@ -1668,7 +1675,8 @@
         batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs'))
 
         if not exists(batch.path):
-            log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path))
+            if _opts.verbose:
+                log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path))
             continue
 
         for sourceDir in sourceDirs:
@@ -1676,7 +1684,7 @@
                 for f in [join(root, name) for name in files if name.endswith('.java')]:
                     batch.javafiles.append(FileInfo(f))
         if len(batch.javafiles) == 0:
-            log('[no Java sources in {0} - skipping]'.format(p.name))
+            logv('[no Java sources in {0} - skipping]'.format(p.name))
             continue
 
         res = batches.setdefault(batch.settings(), batch)
@@ -1729,33 +1737,57 @@
             d = distribution(dname)
             fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
             services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
+
+            def overwriteCheck(zf, arcname, source):
+                if arcname in zf.namelist():
+                    log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']')
+                
             try:
                 zf = zipfile.ZipFile(tmp, 'w')
-                for p in sorted_deps(d.deps):
-                    # skip a  Java project if its Java compliance level is "higher" than the configured JDK
-                    if java().javaCompliance < p.javaCompliance:
-                        log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path))
-                        continue
-
-                    outputDir = p.output_dir()
-                    for root, _, files in os.walk(outputDir):
-                        relpath = root[len(outputDir) + 1:]
-                        if relpath == join('META-INF', 'services'):
-                            for f in files:
-                                with open(join(services, f), 'a') as outfile:
+                for dep in sorted_deps(d.deps, includeLibs=True):
+                    if dep.isLibrary():
+                        l = dep
+                        # merge library jar into distribution jar
+                        logv('[' + d.path + ': adding library ' + l.name + ']')
+                        lpath = l.get_path(resolve=True)
+                        with zipfile.ZipFile(lpath, 'r') as lp:
+                            for arcname in lp.namelist():
+                                if arcname.startswith('META-INF/services/'):
+                                    f = arcname[len('META-INF/services/'):].replace('/', os.sep)
+                                    with open(join(services, f), 'a') as outfile:
+                                        for line in lp.read(arcname).splitlines():
+                                            outfile.write(line)
+                                else:
+                                    overwriteCheck(zf, arcname, lpath + '!' + arcname)
+                                    zf.writestr(arcname, lp.read(arcname))
+                    else:
+                        p = dep
+                        # skip a  Java project if its Java compliance level is "higher" than the configured JDK
+                        if java().javaCompliance < p.javaCompliance:
+                            log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path))
+                            continue
+    
+                        logv('[' + d.path + ': adding project ' + p.name + ']')
+                        outputDir = p.output_dir()
+                        for root, _, files in os.walk(outputDir):
+                            relpath = root[len(outputDir) + 1:]
+                            if relpath == join('META-INF', 'services'):
+                                for f in files:
+                                    with open(join(services, f), 'a') as outfile:
+                                        with open(join(root, f), 'r') as infile:
+                                            for line in infile:
+                                                outfile.write(line)
+                            elif relpath == join('META-INF', 'providers'):
+                                for f in files:
                                     with open(join(root, f), 'r') as infile:
                                         for line in infile:
-                                            outfile.write(line)
-                        elif relpath == join('META-INF', 'providers'):
-                            for f in files:
-                                with open(join(root, f), 'r') as infile:
-                                    for line in infile:
-                                        with open(join(services, line.strip()), 'a') as outfile:
-                                            outfile.write(f + '\n')
-                        else:
-                            for f in files:
-                                arcname = join(relpath, f).replace(os.sep, '/')
-                                zf.write(join(root, f), arcname)
+                                            with open(join(services, line.strip()), 'a') as outfile:
+                                                outfile.write(f + '\n')
+                            else:
+                                for f in files:
+                                    arcname = join(relpath, f).replace(os.sep, '/')
+                                    overwriteCheck(zf, arcname, join(root, f))
+                                    zf.write(join(root, f), arcname)
                 for f in os.listdir(services):
                     arcname = join('META-INF', 'services', f).replace(os.sep, '/')
                     zf.write(join(services, f), arcname)
@@ -1880,7 +1912,7 @@
             for root, _, files in os.walk(sourceDir):
                 javafilelist += [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java']
             if len(javafilelist) == 0:
-                log('[no Java sources in {0} - skipping]'.format(sourceDir))
+                logv('[no Java sources in {0} - skipping]'.format(sourceDir))
                 continue
 
             timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp')
@@ -1916,7 +1948,7 @@
                 else:
                     config = join(p.dir, configLocation)
             else:
-                log('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir))
+                logv('[unknown Checkstyle configuration type "' + configType + '" in {0} - skipping]'.format(sourceDir))
                 continue
 
             exclude = join(p.dir, '.checkstyle.exclude')
@@ -2875,7 +2907,7 @@
                 for d in deps:
                     assess_candidate(d, projects)
             if not assess_candidate(p, projects):
-                log('[package-list file exists - skipping {0}]'.format(p.name))
+                logv('[package-list file exists - skipping {0}]'.format(p.name))
 
 
     def find_packages(sourceDirs, pkgs=set()):
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -1680,15 +1680,15 @@
     // fourth argument (j_rarg3) is a pointer to the HotSpotInstalledCode object.
 
     // Load the nmethod pointer from the HotSpotInstalledCode object
-    __ movq(j_rarg3, Address(j_rarg3, sizeof(oopDesc)));
+    __ movq(j_rarg4, Address(j_rarg3, sizeof(oopDesc)));
 
     // Check whether the nmethod was invalidated
-    __ testq(j_rarg3, j_rarg3);
+    __ testq(j_rarg4, j_rarg4);
     Label invalid_nmethod;
     __ jcc(Assembler::zero, invalid_nmethod);
 
     // Perform a tail call to the verified entry point of the nmethod.
-    __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset()));
+    __ jmp(Address(j_rarg4, nmethod::verified_entry_point_offset()));
 
     __ bind(invalid_nmethod);
 
--- a/src/gpu/ptx/gpu_ptx.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/gpu/ptx/gpu_ptx.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -55,9 +55,19 @@
   }
 }
 
-void gpu::generate_kernel(unsigned char *code, int code_len, const char *name) {
+void * gpu::generate_kernel(unsigned char *code, int code_len, const char *name) {
   if (gpu::has_gpu_linkage()) {
-    gpu::Ptx::generate_kernel(code, code_len, name);
+    return (gpu::Ptx::generate_kernel(code, code_len, name));
+  } else {
+    return NULL;
+  }
+}
+
+bool gpu::execute_kernel(address kernel) {
+  if (gpu::has_gpu_linkage()) {
+    return (gpu::Ptx::execute_kernel(kernel));
+  } else {
+    return false;
   }
 }
 
@@ -102,7 +112,7 @@
   return status == 0;  // CUDA_SUCCESS
 }
 
-void gpu::Ptx::generate_kernel(unsigned char *code, int code_len, const char *name) {
+void *gpu::Ptx::generate_kernel(unsigned char *code, int code_len, const char *name) {
 
   void *cu_module;
   const unsigned int jit_num_options = 3;
@@ -134,8 +144,29 @@
   if (TraceWarpLoading) {
     tty->print_cr("gpu_ptx::_cuda_cu_module_get_function(%s):%x %d", name, cu_function, status);
   }
+  return cu_function;
 }
 
+bool gpu::Ptx::execute_kernel(address kernel) {
+  // grid dimensionality
+  unsigned int gridX = 1;
+  unsigned int gridY = 1;
+  unsigned int gridZ = 1;
+
+  // thread dimensionality
+  unsigned int blockX = 1;
+  unsigned int blockY = 1;
+  unsigned int blockZ = 1;
+  
+  int *cu_function = (int *)kernel;
+
+  int status = _cuda_cu_launch_kernel(cu_function,
+                                      gridX, gridY, gridZ,
+                                      blockX, blockY, blockZ,
+                                      0, NULL, NULL, NULL);
+  tty->print_cr("gpu_ptx::_cuda_cu_launch_kernel(%x): %d", kernel, status);
+  return status == 0;  // CUDA_SUCCESS
+}
 
 #ifdef __APPLE__
 bool gpu::Ptx::probe_linkage_apple() {
@@ -161,6 +192,8 @@
         CAST_TO_FN_PTR(cuda_cu_module_get_function_func_t, dlsym(handle, "cuModuleGetFunction"));
     _cuda_cu_module_load_data_ex =
         CAST_TO_FN_PTR(cuda_cu_module_load_data_ex_func_t, dlsym(handle, "cuModuleLoadDataEx"));
+    _cuda_cu_launch_kernel =
+        CAST_TO_FN_PTR(cuda_cu_launch_kernel_func_t, dlsym(handle, "cuLaunchKernel"));
     return true;
   }
   return false;
--- a/src/gpu/ptx/gpu_ptx.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/gpu/ptx/gpu_ptx.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -34,7 +34,8 @@
   static bool probe_linkage_apple();
 #endif
   static bool initialize_gpu();
-  static void generate_kernel(unsigned char *code, int code_len, const char *name);
+  static void * generate_kernel(unsigned char *code, int code_len, const char *name);
+  static bool execute_kernel(address kernel);
   
 private:
   typedef int (*cuda_cu_init_func_t)(unsigned int, int);
@@ -45,7 +46,10 @@
   typedef int (*cuda_cu_device_get_name_func_t)(char *, int, int);
   typedef int (*cuda_cu_device_get_func_t)(int *, int);
   typedef int (*cuda_cu_device_compute_capability_func_t)(int *, int *, int);
-  typedef int (*cuda_cu_launch_kernel_func_t)(int *, int *, int);
+  typedef int (*cuda_cu_launch_kernel_func_t)(void *,
+                                              unsigned int, unsigned int, unsigned int,
+                                              unsigned int, unsigned int, unsigned int,
+                                              unsigned int, void *, void **, void **);
   typedef int (*cuda_cu_module_get_function_func_t)(void *, void *, const char *);
   typedef int (*cuda_cu_module_load_data_ex_func_t)(void *, void *, unsigned int, int *, void **);
 
--- a/src/share/vm/classfile/systemDictionary.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/classfile/systemDictionary.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -220,6 +220,7 @@
   do_klass(CompilationResult_Mark_klass,          com_oracle_graal_api_code_CompilationResult_Mark,             Opt) \
   do_klass(CompilationResult_Infopoint_klass,     com_oracle_graal_api_code_CompilationResult_Infopoint,        Opt) \
   do_klass(CompilationResult_Site_klass,          com_oracle_graal_api_code_CompilationResult_Site,             Opt) \
+  do_klass(ExternalCompilationResult_klass,       com_oracle_graal_api_code_ExternalCompilationResult,          Opt) \
   do_klass(InfopointReason_klass,                 com_oracle_graal_api_code_InfopointReason,                    Opt) \
   do_klass(code_Register_klass,                   com_oracle_graal_api_code_Register,                           Opt) \
   do_klass(RegisterValue_klass,                   com_oracle_graal_api_code_RegisterValue,                      Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -338,6 +338,7 @@
   template(com_oracle_graal_api_code_CompilationResult_Mark,         "com/oracle/graal/api/code/CompilationResult$Mark")              \
   template(com_oracle_graal_api_code_CompilationResult_Infopoint,    "com/oracle/graal/api/code/CompilationResult$Infopoint")         \
   template(com_oracle_graal_api_code_CompilationResult_Site,         "com/oracle/graal/api/code/CompilationResult$Site")              \
+  template(com_oracle_graal_api_code_ExternalCompilationResult,      "com/oracle/graal/api/code/ExternalCompilationResult")           \
   template(com_oracle_graal_api_code_InfopointReason,                "com/oracle/graal/api/code/InfopointReason")                     \
   template(com_oracle_graal_api_code_BytecodeFrame,                  "com/oracle/graal/api/code/BytecodeFrame")                       \
   template(com_oracle_graal_api_code_BytecodePosition,               "com/oracle/graal/api/code/BytecodePosition")                    \
--- a/src/share/vm/code/nmethod.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/code/nmethod.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -1307,6 +1307,7 @@
   // Java wrapper is no longer alive. Here we need to clear out this weak
   // reference to the dead object.
   if (_graal_installed_code != NULL) {
+    HotSpotInstalledCode::set_codeBlob(_graal_installed_code, 0);
     _graal_installed_code = NULL;
   }
 #endif
--- a/src/share/vm/code/nmethod.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/code/nmethod.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -185,6 +185,7 @@
   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
   unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
   unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
+  unsigned int _external_method:1;           // Set for GPU methods
 
   // Protected by Patching_lock
   unsigned char _state;                      // {alive, not_entrant, zombie, unloaded}
@@ -462,6 +463,9 @@
   bool  is_speculatively_disconnected() const     { return _speculatively_disconnected; }
   void  set_speculatively_disconnected(bool z)    { _speculatively_disconnected = z; }
 
+  bool  is_external_method() const                { return _external_method; }
+  void  set_external_method(bool z)               { _external_method = z; }
+
   bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
   void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
 
--- a/src/share/vm/graal/graalCompiler.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalCompiler.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -85,23 +85,13 @@
 
   static int to_cp_index_u2(int index) {
     // Tag.
-    return to_index_u2(index) + ConstantPool::CPCACHE_INDEX_TAG;
-  }
-
-  static int to_index_u2(int index) {
-    // Swap.
-    return ((index & 0xFF) << 8) | (index >> 8);
-  }
-
-  static int to_index_u4(int index) {
-    // Swap.
-    return ((index & 0xFF) << 24) | ((index & 0xFF00) << 8) | ((index & 0xFF0000) >> 8) | ((index & 0xFF000000) >> 24);
+    return index + ConstantPool::CPCACHE_INDEX_TAG;
   }
 
   static int to_cp_index(int raw_index, Bytecodes::Code bc) {
     int cp_index;
     if (bc == Bytecodes::_invokedynamic) {
-      cp_index = to_index_u4(raw_index);
+      cp_index = raw_index;
       assert(ConstantPool::is_invokedynamic_index(cp_index), "not an invokedynamic constant pool index");
     } else {
       assert(bc == Bytecodes::_getfield        || bc == Bytecodes::_putfield  ||
--- a/src/share/vm/graal/graalCompilerToGPU.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToGPU.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -24,7 +24,9 @@
 #include "precompiled.hpp"
 
 #include "graal/graalCompiler.hpp"
+#include "graal/graalCompilerToVM.hpp"
 #include "graal/graalEnv.hpp"
+#include "graal/graalJavaAccess.hpp"
 #include "runtime/gpu.hpp"
 
 
@@ -52,11 +54,47 @@
   jbyte *bytes = env->GetByteArrayElements(code, &is_copy);
   jint len = env->GetArrayLength(code);
   const char *namestr = env->GetStringUTFChars(name, &is_copy);
-  gpu::generate_kernel((unsigned char *)bytes, len, namestr);
+  void *kernel = gpu::generate_kernel((unsigned char *)bytes, len, namestr);
+  tty->print_cr("generateKernel: %x", kernel);
   env->ReleaseByteArrayElements(code, bytes, 0);
   env->ReleaseStringUTFChars(name, namestr);
 
-  return 42;
+  return (jlong)kernel;
+C2V_END
+
+C2V_VMENTRY(jobject, executeExternalMethodVarargs, (JNIEnv *env, jobject, jobject args, jobject hotspotInstalledCode))
+  ResourceMark rm;
+  HandleMark hm;
+
+  if (gpu::is_available() == false || gpu::has_gpu_linkage() == false && gpu::is_initialized()) {
+    tty->print_cr("executeExternalMethodVarargs - not available / no linkage / not initialized");
+    return NULL;
+  }
+  jlong nmethodValue = HotSpotInstalledCode::codeBlob(hotspotInstalledCode);
+  nmethod* nm = (nmethod*) (address) nmethodValue;
+  methodHandle mh = nm->method();
+  Symbol* signature = mh->signature();
+  JavaCallArguments jca(mh->size_of_parameters());
+
+  JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static());
+  JavaValue result(jap.get_ret_type());
+  jca.set_alternative_target(nm);
+
+  // start value is the kernel
+  jlong startValue = HotSpotInstalledCode::start(hotspotInstalledCode);
+
+  // JavaCalls::call(&result, mh, &jca, CHECK_NULL);
+  tty->print_cr("executeExternalMethodVarargs: start: %x", (address)startValue);
+  gpu::execute_kernel((address)startValue);
+
+  if (jap.get_ret_type() == T_VOID) {
+    return NULL;
+  } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) {
+    return JNIHandles::make_local((oop) result.get_jobject());
+  } else {
+    oop o = java_lang_boxing_object::create(jap.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL);
+    return JNIHandles::make_local(o);
+  }
 C2V_END
 
 C2V_VMENTRY(jboolean, deviceInit, (JNIEnv *env, jobject))
@@ -113,9 +151,10 @@
 #define GPUSPACE_METHOD       "J"
 
 JNINativeMethod CompilerToGPU_methods[] = {
-  {CC"generateKernel", CC"([B" STRING ")"GPUSPACE_METHOD, FN_PTR(generateKernel)},
-  {CC"deviceInit",     CC"()Z",                           FN_PTR(deviceInit)},
-  {CC"deviceDetach",   CC"()Z",                           FN_PTR(deviceDetach)},
+  {CC"generateKernel",                CC"([B" STRING ")"GPUSPACE_METHOD,        FN_PTR(generateKernel)},
+  {CC"deviceInit",                    CC"()Z",                                  FN_PTR(deviceInit)},
+  {CC"deviceDetach",                  CC"()Z",                                  FN_PTR(deviceDetach)},
+  {CC"executeExternalMethodVarargs",  CC"(["OBJECT HS_INSTALLED_CODE")"OBJECT,  FN_PTR(executeExternalMethodVarargs)},
 };
 
 int CompilerToGPU_methods_count() {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -85,24 +85,57 @@
       reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
       memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size);
     }
-    BytecodeStream s(method);
-    while (!s.is_last_bytecode()) {
-      s.next();
-      Bytecodes::Code opcode = s.raw_code();
-      if (!Bytecodes::is_java_code(opcode)) {
-        jbyte original_opcode = Bytecodes::java_code(opcode);
-        int bci = s.bci();
-        reconstituted_code[bci] = original_opcode;
-        if (opcode == Bytecodes::_fast_aldc_w) {
-          int cpci = Bytes::get_native_u2((address) reconstituted_code + bci + 1);
-          int i = method->constants()->object_to_cp_index(cpci);
-          assert(i < method->constants()->length(), "sanity check");
-          Bytes::put_Java_u2((address) reconstituted_code + bci + 1, (u2)i);
-        } else if (opcode == Bytecodes::_fast_aldc) {
-          int cpci = reconstituted_code[bci + 1] & 0xff;
-          int i = method->constants()->object_to_cp_index(cpci);
-          assert(i < method->constants()->length(), "sanity check");
-          reconstituted_code[bci + 1] = (jbyte)i;
+
+    for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) {
+      Bytecodes::Code code = s.code();
+      Bytecodes::Code raw_code = s.raw_code();
+      int bci = s.bci();
+
+      // Restore original byte code.  The Bytecodes::is_java_code check
+      // also avoids overwriting wide bytecodes.
+      if (!Bytecodes::is_java_code(raw_code)) {
+        reconstituted_code[bci] = (jbyte) code;
+      }
+
+      // Restore the big-endian constant pool indexes.
+      // Cf. Rewriter::scan_method
+      switch (code) {
+        case Bytecodes::_getstatic:
+        case Bytecodes::_putstatic:
+        case Bytecodes::_getfield:
+        case Bytecodes::_putfield:
+        case Bytecodes::_invokevirtual:
+        case Bytecodes::_invokespecial:
+        case Bytecodes::_invokestatic:
+        case Bytecodes::_invokeinterface:
+        case Bytecodes::_invokehandle: {
+          int cp_index = Bytes::get_native_u2((address) &reconstituted_code[bci + 1]);
+          Bytes::put_Java_u2((address) &reconstituted_code[bci + 1], (u2) cp_index);
+          break;
+        }
+
+        case Bytecodes::_invokedynamic:
+          int cp_index = Bytes::get_native_u4((address) &reconstituted_code[bci + 1]);
+          Bytes::put_Java_u4((address) &reconstituted_code[bci + 1], (u4) cp_index);
+          break;
+      }
+
+      // Not all ldc byte code are rewritten.
+      switch (raw_code) {
+        case Bytecodes::_fast_aldc: {
+          int cpc_index = reconstituted_code[bci + 1] & 0xff;
+          int cp_index = method->constants()->object_to_cp_index(cpc_index);
+          assert(cp_index < method->constants()->length(), "sanity check");
+          reconstituted_code[bci + 1] = (jbyte) cp_index;
+          break;
+        }
+
+        case Bytecodes::_fast_aldc_w: {
+          int cpc_index = Bytes::get_native_u2((address) &reconstituted_code[bci + 1]);
+          int cp_index = method->constants()->object_to_cp_index(cpc_index);
+          assert(cp_index < method->constants()->length(), "sanity check");
+          Bytes::put_Java_u2((address) &reconstituted_code[bci + 1], (u2) cp_index);
+          break;
         }
       }
     }
@@ -456,19 +489,19 @@
   instanceKlassHandle pool_holder(cp->pool_holder());
 
   Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
-  index = GraalCompiler::to_cp_index(index, bc);
+  int cp_index = GraalCompiler::to_cp_index(index, bc);
 
-  methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder);
+  methodHandle method = GraalEnv::get_method_by_index(cp, cp_index, bc, pool_holder);
   if (!method.is_null()) {
     Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL);
     return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD));
   } else {
     // Get the method's name and signature.
-    Handle name = java_lang_String::create_from_symbol(cp->name_ref_at(index), CHECK_NULL);
-    Handle signature  = java_lang_String::create_from_symbol(cp->signature_ref_at(index), CHECK_NULL);
+    Handle name = java_lang_String::create_from_symbol(cp->name_ref_at(cp_index), CHECK_NULL);
+    Handle signature  = java_lang_String::create_from_symbol(cp->signature_ref_at(cp_index), CHECK_NULL);
     Handle type;
     if (bc != Bytecodes::_invokedynamic) {
-      int holder_index = cp->klass_ref_index_at(index);
+      int holder_index = cp->klass_ref_index_at(cp_index);
       type = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL);
     } else {
       type = Handle(SystemDictionary::MethodHandle_klass()->java_mirror());
@@ -509,15 +542,15 @@
 C2V_VMENTRY(jobject, lookupFieldInPool, (JNIEnv *env, jobject, jobject constantPoolHolder, jint index, jbyte opcode))
   ResourceMark rm;
 
-  index = GraalCompiler::to_cp_index_u2(index);
+  int cp_index = GraalCompiler::to_cp_index_u2(index);
   constantPoolHandle cp = InstanceKlass::cast(java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(constantPoolHolder)))->constants();
 
-  int nt_index = cp->name_and_type_ref_index_at(index);
+  int nt_index = cp->name_and_type_ref_index_at(cp_index);
   int sig_index = cp->signature_ref_index_at(nt_index);
   Symbol* signature = cp->symbol_at(sig_index);
   int name_index = cp->name_ref_index_at(nt_index);
   Symbol* name = cp->symbol_at(name_index);
-  int holder_index = cp->klass_ref_index_at(index);
+  int holder_index = cp->klass_ref_index_at(cp_index);
   Handle holder = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL);
   instanceKlassHandle holder_klass;
 
@@ -527,7 +560,7 @@
   BasicType basic_type;
   if (holder->klass() == SystemDictionary::HotSpotResolvedObjectType_klass()) {
     FieldAccessInfo result;
-    LinkResolver::resolve_field(result, cp, index,
+    LinkResolver::resolve_field(result, cp, cp_index,
                                 Bytecodes::java_code(code),
                                 true, false, Thread::current());
     if (HAS_PENDING_EXCEPTION) {
@@ -809,6 +842,7 @@
   set_address("newInstanceAddress", GraalRuntime::new_instance);
   set_address("newArrayAddress", GraalRuntime::new_array);
   set_address("newMultiArrayAddress", GraalRuntime::new_multi_array);
+  set_address("dynamicNewArrayAddress", GraalRuntime::dynamic_new_array);
   set_address("registerFinalizerAddress", SharedRuntime::register_finalizer);
   set_address("threadIsInterruptedAddress", GraalRuntime::thread_is_interrupted);
   set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap());
@@ -935,7 +969,13 @@
     if (!installed_code_handle.is_null()) {
       assert(installed_code_handle->is_a(HotSpotInstalledCode::klass()), "wrong type");
       HotSpotInstalledCode::set_codeBlob(installed_code_handle, (jlong) cb);
-      HotSpotInstalledCode::set_start(installed_code_handle, (jlong) cb->code_begin());
+      oop comp_result = HotSpotCompiledCode::comp(compiled_code_handle);
+      if (comp_result->is_a(ExternalCompilationResult::klass())) {
+        tty->print_cr("installCode0: ExternalCompilationResult");
+        HotSpotInstalledCode::set_start(installed_code_handle, ExternalCompilationResult::kernel(comp_result));
+      } else {
+        HotSpotInstalledCode::set_start(installed_code_handle, (jlong) cb->code_begin());
+      }
       nmethod* nm = cb->as_nmethod_or_null();
       assert(nm == NULL || !installed_code_handle->is_scavengable() || nm->on_scavenge_root_list(), "nm should be scavengable if installed_code is scavengable");
     }
--- a/src/share/vm/graal/graalEnv.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalEnv.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -565,6 +565,10 @@
 
         }
       }
+      
+      if (HotSpotNmethod::isExternal(installed_code())) {
+        tty->print_cr("External method:%s", method()->name_and_sig_as_C_string());
+      }
     }
   }
   // JVMTI -- compiled method notification (must be done outside lock)
--- a/src/share/vm/graal/graalJavaAccess.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -82,6 +82,7 @@
   end_class                                                                                                                                                    \
   start_class(HotSpotNmethod)                                                                                                                                  \
     boolean_field(HotSpotNmethod, isDefault)                                                                                                                   \
+    boolean_field(HotSpotNmethod, isExternal)                                                                                                                   \
   end_class                                                                                                                                                    \
   start_class(HotSpotCompiledCode)                                                                                                                             \
     oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/graal/api/code/CompilationResult;")                                                                      \
@@ -110,6 +111,9 @@
     int_field(ExceptionHandler, catchTypeCPI)                                                                                                                  \
     oop_field(ExceptionHandler, catchType, "Lcom/oracle/graal/api/meta/JavaType;")                                                                             \
   end_class                                                                                                                                                    \
+  start_class(ExternalCompilationResult)                                                                                                                       \
+    long_field(ExternalCompilationResult, kernel)                                                                                                              \
+  end_class                                                                                                                                                    \
   start_class(CompilationResult)                                                                                                                               \
     int_field(CompilationResult, frameSize)                                                                                                                    \
     int_field(CompilationResult, customStackAreaOffset)                                                                                                        \
--- a/src/share/vm/graal/graalRuntime.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -29,6 +29,7 @@
 #include "prims/jvm.h"
 #include "runtime/biasedLocking.hpp"
 #include "runtime/interfaceSupport.hpp"
+#include "runtime/reflection.hpp"
 #include "utilities/debug.hpp"
 
 // Simple helper to see if the caller of a runtime stub which
@@ -101,6 +102,11 @@
   thread->set_vm_result(obj);
 JRT_END
 
+JRT_ENTRY(void, GraalRuntime::dynamic_new_array(JavaThread* thread, oop element_mirror, jint length))
+  oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
+  thread->set_vm_result(obj);
+JRT_END
+
 extern void vm_exit(int code);
 
 // Enter this method from compiled code handler below. This is where we transition
--- a/src/share/vm/graal/graalRuntime.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -33,6 +33,7 @@
   static void new_instance(JavaThread* thread, Klass* klass);
   static void new_array(JavaThread* thread, Klass* klass, jint length);
   static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims);
+  static void dynamic_new_array(JavaThread* thread, oop element_mirror, jint length);
   static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupte);
   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
   static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
--- a/src/share/vm/prims/jvm.cpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/prims/jvm.cpp	Mon Jul 01 21:07:21 2013 +0200
@@ -671,7 +671,7 @@
   JVMWrapper("JVM_GetCallerClass");
 
   // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation.
-  if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) {
+  if (!JDK_Version::is_gte_jdk18x_version() || SystemDictionary::reflect_CallerSensitive_klass() == NULL) {
     Klass* k = thread->security_get_caller_class(depth);
     return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror());
   } else {
--- a/src/share/vm/runtime/globals.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/runtime/globals.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -1251,7 +1251,7 @@
   develop(bool, TraceClassInitialization, false,                            \
           "Trace class initialization")                                     \
                                                                             \
-  develop(bool, TraceExceptions, false,                                     \
+  product(bool, TraceExceptions, false,                                     \
           "Trace exceptions")                                               \
                                                                             \
   develop(bool, TraceICs, false,                                            \
--- a/src/share/vm/runtime/gpu.hpp	Mon Jul 01 20:58:32 2013 +0200
+++ b/src/share/vm/runtime/gpu.hpp	Mon Jul 01 21:07:21 2013 +0200
@@ -41,7 +41,9 @@
   
   static void initialize_gpu();
   
-  static void generate_kernel(unsigned char *code, int code_len, const char *name);
+  static void * generate_kernel(unsigned char *code, int code_len, const char *name);
+
+  static bool execute_kernel(address kernel);
 
   static void set_available(bool value) {
     _available = value;