changeset 10779:c0ce8e825f30

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 16 Jul 2013 15:08:28 +0200
parents f0fdbb2b7135 (current diff) fbeda94727f8 (diff)
children b1f438bf1a40
files
diffstat 25 files changed, 719 insertions(+), 87 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Tue Jul 16 15:08:28 2013 +0200
@@ -79,13 +79,15 @@
      * created by JNI since these JNI global references do not move.
      */
     public final void mov(Register a, Object obj) {
+        String regName = "$d" + a.encoding();
         if (obj instanceof Class) {
             Class<?> clazz = (Class<?>) obj;
             long refHandle = OkraUtil.getRefHandle(clazz);
             String className = clazz.getName();
-            String regName = "$d" + a.encoding();
             emitString("mov_b64 " + regName + ", 0x" + Long.toHexString(refHandle) + ";  // handle for " + className);
             emitString("ld_global_u64 " + regName + ", [" + regName + "];");
+        } else if (obj == null) {
+            emitString("mov_b64 " + regName + ", 0x0;  // null object");
         } else {
             throw GraalInternalError.shouldNotReachHere("mov from object not a class");
         }
@@ -101,16 +103,32 @@
         }
     }
 
+    private void emitAddrOp(String instr, Value reg, HSAILAddress addr) {
+        emitString(instr + " " + HSAIL.mapRegister(reg) + ", " + mapAddress(addr) + ";");
+    }
+
     public final void emitLoad(Value dest, HSAILAddress addr) {
-        emitString("ld_global_" + getArgType(dest) + " " + HSAIL.mapRegister(dest) + ", " + mapAddress(addr) + ";");
+        emitLoad(dest, addr, getArgType(dest));
+    }
+
+    public final void emitLoad(Value dest, HSAILAddress addr, String argTypeStr) {
+        emitAddrOp("ld_global_" + argTypeStr, dest, addr);
+    }
+
+    public final void emitLda(Value dest, HSAILAddress addr) {
+        emitAddrOp("lda_global_u64", dest, addr);
+    }
+
+    public final void emitStore(Value src, HSAILAddress addr) {
+        emitStore(src, addr, getArgType(src));
+    }
+
+    public final void emitStore(Value dest, HSAILAddress addr, String argTypeStr) {
+        emitAddrOp("st_global_" + argTypeStr, dest, addr);
     }
 
     public final void emitSpillLoad(Value dest, Value src) {
-        emitString("ld_spill_" + getArgType(dest) + " " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapStackSlot(src) + ";");
-    }
-
-    public final void emitStore(Value src, HSAILAddress addr) {
-        emitString("st_global_" + getArgType(src) + " " + HSAIL.mapRegister(src) + ", " + mapAddress(addr) + ";");
+        emitString("ld_spill_" + getArgType(dest) + " " + HSAIL.mapRegister(dest) + ", " + mapStackSlot(src, getArgSize(dest)) + ";");
     }
 
     public final void emitSpillStore(Value src, Value dest) {
@@ -122,7 +140,21 @@
         if (maxStackOffset < stackoffset) {
             maxStackOffset = stackoffset;
         }
-        emitString("st_spill_" + getArgType(src) + " " + HSAIL.mapRegister(src) + ", " + HSAIL.mapStackSlot(dest) + ";");
+        emitString("st_spill_" + getArgType(src) + " " + HSAIL.mapRegister(src) + ", " + mapStackSlot(dest, getArgSize(src)) + ";");
+    }
+
+    /**
+     * The mapping to stack slots is always relative to the beginning
+     * of the spillseg.  HSAIL.getStackOffset returns the positive
+     * version of the originally negative offset.  Then we back up
+     * from that by the argSize in bytes.  This ensures that slots of
+     * different size do not overlap, even though we have converted
+     * from negative to positive offsets.
+     */
+    public static String mapStackSlot(Value reg, int argSize) {
+        long offset = HSAIL.getStackOffset(reg);
+        int argSizeBytes = argSize / 8;
+        return "[%spillseg]" + "[" + (offset - argSizeBytes) + "]";
     }
 
     public void cbr(String target1) {
@@ -181,7 +213,9 @@
 
     public void emitCompare(Value src0, Value src1, String condition, boolean unordered, boolean isUnsignedCompare) {
         String prefix = "cmp_" + condition + (unordered ? "u" : "") + "_b1_" + (isUnsignedCompare ? getArgTypeForceUnsigned(src1) : getArgType(src1));
-        emitString(prefix + " $c0, " + mapRegOrConstToString(src0) + ", " + mapRegOrConstToString(src1) + ";");
+        String comment = (isConstant(src1) && (src1.getKind() == Kind.Object)
+                          && (asConstant(src1).asObject() == null) ? " // null test " : "");
+        emitString(prefix + " $c0, " + mapRegOrConstToString(src0) + ", " + mapRegOrConstToString(src1) + ";" + comment);
     }
 
     public void emitConvert(Value dest, Value src) {
@@ -210,7 +244,14 @@
                 case Double:
                     return Double.toString(consrc.asDouble());
                 case Long:
-                    return Long.toString(consrc.asLong());
+                    return "0x" + Long.toHexString(consrc.asLong());
+                case Object:
+                    Object obj = consrc.asObject();
+                    if (obj == null) {
+                        return "0";
+                    } else {
+                        throw GraalInternalError.shouldNotReachHere("unknown type: " + src);
+                    }
                 default:
                     throw GraalInternalError.shouldNotReachHere("unknown type: " + src);
             }
@@ -223,14 +264,68 @@
         emit(mnemonic + "_" + prefix, dest, "", src0, src1);
     }
 
+    public final void emitForceUnsigned(String mnemonic, Value dest, Value src0, Value src1) {
+        String prefix = getArgTypeForceUnsigned(dest);
+        emit(mnemonic + "_" + prefix, dest, "", src0, src1);
+    }
+
+
     private void emit(String instr, Value dest, String controlRegString, Value src0, Value src1) {
         assert (!isConstant(dest));
         emitString(String.format("%s %s, %s%s, %s;", instr, HSAIL.mapRegister(dest), controlRegString, mapRegOrConstToString(src0), mapRegOrConstToString(src1)));
     }
 
+    private void emit(String instr, Value dest, Value src0, Value src1, Value src2) {
+        assert (!isConstant(dest));
+        emitString(String.format("%s %s, %s, %s, %s;", instr, HSAIL.mapRegister(dest), mapRegOrConstToString(src0),
+                                 mapRegOrConstToString(src1), mapRegOrConstToString(src2)));
+    }
+
+
     public final void cmovCommon(Value dest, Value trueReg, Value falseReg, int width) {
         String instr = (width == 32 ? "cmov_b32" : "cmov_b64");
         emit(instr, dest, "$c0, ", trueReg, falseReg);
     }
 
+
+    /**
+     * Emit code to build a 64-bit pointer from a compressed-oop and the associated base and shift.
+     * We only emit this if base and shift are not both zero.
+     */
+    public void emitCompressedOopDecode(Value result, long narrowOopBase, int narrowOopShift) {
+        if (narrowOopBase == 0) {
+            emit("shl", result, result, Constant.forInt(narrowOopShift));
+        } else if (narrowOopShift == 0) {
+            // only use add if result is not starting as null (unsigned compare)
+            emitCompare(result, Constant.forLong(0), "eq", false, true);
+            emit("add", result, result, Constant.forLong(narrowOopBase));
+            cmovCommon(result, Constant.forLong(0), result, 64);
+        } else {
+            // only use mad if result is not starting as null (unsigned compare)
+            emitCompare(result, Constant.forLong(0), "eq", false, true);
+            emit("mad_u64 ", result, result, Constant.forInt(1 << narrowOopShift), Constant.forLong(narrowOopBase));
+            cmovCommon(result, Constant.forLong(0), result, 64);
+        }
+    }
+
+    /**
+     * Emit code to build a 32-bit compressed pointer from a full
+     * 64-bit pointer using the associated base and shift.  We only
+     * emit this if base and shift are not both zero.
+     */
+    public void emitCompressedOopEncode(Value result, long narrowOopBase, int narrowOopShift) {
+        if (narrowOopBase != 0) {
+            // only use sub if result is not starting as null (unsigned compare)
+            emitCompare(result, Constant.forLong(0), "eq", false, true);
+            emit("sub", result, result, Constant.forLong(narrowOopBase));
+            cmovCommon(result, Constant.forLong(0), result, 64);
+        }
+        if (narrowOopShift != 0) {
+            emit("shr", result, result, Constant.forInt(narrowOopShift));
+        }
+    }
+
+    public void emitComment(String comment) {
+        emitString(comment);
+    }
 }
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Tue Jul 16 15:08:28 2013 +0200
@@ -30,6 +30,7 @@
 import com.oracle.graal.compiler.hsail.HSAILCompilationResult;
 import java.lang.reflect.Method;
 import java.io.*;
+import static com.oracle.graal.phases.GraalOptions.*;
 
 public abstract class GraalKernelTester extends KernelTester {
 
@@ -61,4 +62,15 @@
         return hsailSource;
     }
 
+    public boolean aggressiveInliningEnabled() {
+        return (InlineEverything.getValue());
+    }
+
+    public boolean canHandleHSAILMethodCalls() {
+        // needs 2 things, backend needs to be able to generate such calls, and target needs to be
+        // able to run them
+        boolean canGenerateCalls = false;   // not implemented yet
+        boolean canExecuteCalls = runningOnSimulator();
+        return (canGenerateCalls && canExecuteCalls);
+    }
 }
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Tue Jul 16 15:08:28 2013 +0200
@@ -150,6 +150,12 @@
     }
 
     private boolean compareObjects(Object first, Object second) {
+        if (first == null) {
+            return (second == null);
+        }
+        if (second == null) {
+            return (first == null);
+        }
         Class<?> clazz = first.getClass();
         if (clazz != second.getClass()) {
             return false;
@@ -265,6 +271,11 @@
         Object getElement(Object ary, int index) {
             return Array.get(ary, index);
         }
+
+        @Override
+        boolean isEquals(Object firstElement, Object secondElement) {
+            return compareObjects(firstElement, secondElement);
+        }
     }
 
     /**
@@ -496,7 +507,7 @@
         String hsailSource = getHSAILSource(testMethod);
         if (!okraLibExists) {
             if (!gaveNoOkraWarning) {
-                logger.fine("No Okra library detected, skipping all KernelTester tests in " + this.getClass().getPackage().getName());
+                logger.severe("No Okra library detected, skipping all KernelTester tests in " + this.getClass().getPackage().getName());
                 gaveNoOkraWarning = true;
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixBase.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Base class used by other Float2DMatrix tests.
+ */
+public abstract class Float2DMatrixBase extends GraalKernelTester {
+
+    float[][] matrixA;
+    float[][] matrixB;
+    @Result float[][] outMatrix;
+
+    public void setupArrays(int range) {
+        matrixA = new float[range][];
+        matrixB = new float[range][];
+        outMatrix = new float[range][];
+        for (int j = 0; j < range; j++) {
+            matrixA[j] = new float[range];
+            matrixB[j] = new float[range];
+            outMatrix[j] = new float[range];
+            for (int k = 0; k < range; k++) {
+                matrixA[j][k] = (j + k) % 7;
+                matrixB[j][k] = (j + k + 1) % 8;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyRangeFinalTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import org.junit.*;
+
+/**
+ * Tests the mixing of 32-bit and 64-bit spills caused by loop unrolling.
+ */
+public class Float2DMatrixMultiplyRangeFinalTest extends Float2DMatrixBase {
+
+    static final int range = 6;
+
+    public void run(int gid) {
+        for (int j = 0; j < range; j++) {
+            float sum = 0;
+            for (int k = 0; k < range; k++) {
+                sum += (matrixA[gid][k] * matrixB[k][j]);
+            }
+            outMatrix[gid][j] = sum;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays(range);
+        dispatchMethodKernel(range);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import org.junit.Test;
+
+/**
+ * Tests 2D array access for Matrix Multiplication.
+ */
+public class Float2DMatrixMultiplyTest extends Float2DMatrixBase {
+    int range = 20;
+
+    public void run(int gid) {
+        for (int j = 0; j < range; j++) {
+            float sum = 0;
+            for (int k = 0; k < range; k++) {
+                sum += (matrixA[gid][k] * matrixB[k][j]);
+            }
+            outMatrix[gid][j] = sum;
+        }
+    }
+    @Override
+    public void runTest() {
+        setupArrays(range);
+        dispatchMethodKernel(range);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreNullTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import org.junit.*;
+
+/**
+ * Tests the storing of null in an Object array.
+ */
+public class ObjectStoreNullTest extends ObjectStoreTest {
+
+    @Override
+    public void run(int gid) {
+        outIntegerArray[gid] = (gid % 3 == 1 ? null : inIntegerArray[gid]);
+    }
+
+    @Test
+    @Override
+    public void test() {
+        testGeneratedHsail();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests the storing of objects into an array.
+ */
+public class ObjectStoreTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Integer[] outIntegerArray = new Integer[NUM];
+    public Integer[] inIntegerArray = new Integer[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inIntegerArray[i] = new Integer(i);
+            outIntegerArray[i] = null;
+        }
+    }
+
+    public void run(int gid) {
+        outIntegerArray[gid] = inIntegerArray[gid];
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchMethodKernel(NUM);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -25,6 +25,7 @@
 
 import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
 import org.junit.Test;
+import static org.junit.Assume.*;
 
 /**
  * Unit test that simulates the Mandelbrot application. The run method here is a static method
@@ -79,6 +80,7 @@
 
     @Test
     public void test() {
+        assumeTrue(runningOnSimulator());
         testGeneratedHsail();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyCallTest.java	Tue Jul 16 15:08:28 2013 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.graal.compiler.hsail.test;
+
+import static org.junit.Assume.*;
+
+import org.junit.*;
+
+/**
+ * Unit test of NBody demo app. This version uses a call to the main routine which would normally be
+ * too large to inline.
+ */
+public class StaticNBodyCallTest extends StaticNBodyTest {
+
+    public static void run(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int gid) {
+        StaticNBodyTest.run(inxyz, outxyz, invxyz, outvxyz, gid);
+    }
+
+    @Test
+    @Override
+    public void test() {
+        assumeTrue(aggressiveInliningEnabled() || canHandleHSAILMethodCalls());
+        testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILCompilationResult.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILCompilationResult.java	Tue Jul 16 15:08:28 2013 +0200
@@ -98,7 +98,7 @@
 
     public static HSAILCompilationResult getHSAILCompilationResult(StructuredGraph graph) {
         Debug.dump(graph, "Graph");
-        TargetDescription target = new TargetDescription(new HSAIL(), true, 1, 0, true);
+        TargetDescription target = new TargetDescription(new HSAIL(), true, 8, 0, true);
         HSAILBackend hsailBackend = new HSAILBackend(Graal.getRequiredCapability(GraalCodeCacheProvider.class), target);
         PhasePlan phasePlan = new PhasePlan();
         GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE);
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Tue Jul 16 15:08:28 2013 +0200
@@ -47,20 +47,29 @@
 import com.oracle.graal.lir.hsail.HSAILControlFlow.FloatCompareBranchOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.FloatCondMoveOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.ReturnOp;
+import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCallNoArgOp;
+import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall1ArgOp;
 import com.oracle.graal.lir.hsail.HSAILMove.LeaOp;
 import com.oracle.graal.lir.hsail.HSAILMove.LoadOp;
 import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp;
 import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp;
 import com.oracle.graal.lir.hsail.HSAILMove.StoreOp;
+import com.oracle.graal.lir.hsail.HSAILMove.LoadCompressedPointer;
+import com.oracle.graal.lir.hsail.HSAILMove.StoreCompressedPointer;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.hotspot.meta.*;
 
 /**
  * This class implements the HSAIL specific portion of the LIR generator.
  */
 public class HSAILLIRGenerator extends LIRGenerator {
 
+    private HotSpotRuntime runtime() {
+        return (HotSpotRuntime) runtime;
+    }
+
     public static class HSAILSpillMoveFactory implements LIR.SpillMoveFactory {
 
         @Override
@@ -123,6 +132,14 @@
         }
     }
 
+    protected HSAILAddressValue asAddressValue(Value address) {
+        if (address instanceof HSAILAddressValue) {
+            return (HSAILAddressValue) address;
+        } else {
+            return emitAddress(address, 0, Value.ILLEGAL, 0);
+        }
+    }
+
     public HSAILAddressValue emitAddress(Value base, long displacement, Value index, int scale) {
         AllocatableValue baseRegister;
         long finalDisp = displacement;
@@ -163,27 +180,36 @@
         return new HSAILAddressValue(target().wordKind, baseRegister, finalDisp);
     }
 
-    private HSAILAddressValue asAddress(Value address) {
-        if (address instanceof HSAILAddressValue) {
-            return (HSAILAddressValue) address;
-        } else {
-            return emitAddress(address, 0, Value.ILLEGAL, 0);
-        }
+    private static boolean isCompressCandidate(DeoptimizingNode access) {
+        return access != null && ((HeapAccess) access).compress();
     }
 
     @Override
-    public Variable emitLoad(Kind kind, Value address, DeoptimizingNode deopting) {
-        HSAILAddressValue loadAddress = asAddress(address);
+    public Variable emitLoad(Kind kind, Value address, DeoptimizingNode access) {
+        HSAILAddressValue loadAddress = asAddressValue(address);
         Variable result = newVariable(kind);
-        append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null));
+        LIRFrameState state = access != null ? state(access) : null;
+        assert access == null || access instanceof HeapAccess;
+        if (runtime().config.useCompressedOops && isCompressCandidate(access)) {
+            Variable scratch = newVariable(Kind.Long);
+            append(new LoadCompressedPointer(kind, result, scratch, loadAddress, state, runtime().config.narrowOopBase, runtime().config.narrowOopShift, runtime().config.logMinObjAlignment));
+        } else {
+            append(new LoadOp(kind, result, loadAddress, state));
+        }
         return result;
     }
 
     @Override
-    public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) {
-        HSAILAddressValue storeAddress = asAddress(address);
+    public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode access) {
+        HSAILAddressValue storeAddress = asAddressValue(address);
+        LIRFrameState state = access != null ? state(access) : null;
         Variable input = load(inputVal);
-        append(new StoreOp(kind, storeAddress, input, deopting != null ? state(deopting) : null));
+        if (runtime().config.useCompressedOops && isCompressCandidate(access)) {
+            Variable scratch = newVariable(Kind.Long);
+            append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, runtime().config.narrowOopBase, runtime().config.narrowOopShift, runtime().config.logMinObjAlignment));
+        } else {
+            append(new StoreOp(kind, storeAddress, input, state));
+        }
     }
 
     @Override
@@ -460,6 +486,9 @@
             case Int:
                 append(new Op2Stack(IAND, result, a, loadNonConst(b)));
                 break;
+            case Long:
+                append(new Op2Stack(LAND, result, a, loadNonConst(b)));
+                break;
             default:
                 throw GraalInternalError.shouldNotReachHere();
         }
@@ -483,6 +512,9 @@
             case Int:
                 append(new ShiftOp(ISHL, result, a, b));
                 break;
+            case Long:
+                append(new ShiftOp(LSHL, result, a, b));
+                break;
             default:
                 GraalInternalError.shouldNotReachHere();
         }
@@ -501,6 +533,9 @@
             case Int:
                 append(new ShiftOp(IUSHR, result, a, b));
                 break;
+            case Long:
+                append(new ShiftOp(LUSHR, result, a, b));
+                break;
             default:
                 GraalInternalError.shouldNotReachHere();
         }
@@ -561,7 +596,23 @@
 
     @Override
     protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
-        throw new InternalError("NYI emitForeignCall");
+        String callName = linkage.getDescriptor().getName();
+        if (callName.equals("createOutOfBoundsException") || callName.equals("createNullPointerException")) {
+            // hack Alert !!
+            switch (arguments.length) {
+                case 0:
+                    append(new ForeignCallNoArgOp(callName, result));
+                    break;
+                case 1:
+                    append(new ForeignCall1ArgOp(callName, result, arguments[0]));
+                    break;
+                default:
+                    throw new InternalError("NYI emitForeignCall");
+            }
+
+        } else {
+            throw new InternalError("NYI emitForeignCall");
+        }
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Tue Jul 16 15:08:28 2013 +0200
@@ -25,6 +25,7 @@
 import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
@@ -35,9 +36,6 @@
 /**
  * A direct call that complies with the conventions for such calls in HotSpot. In particular, for
  * calls using an inline cache, a MOVE instruction is emitted just prior to the aligned direct call.
- * This instruction (which moves 0L in RAX) is patched by the C++ Graal code to replace the 0L
- * constant with Universe::non_oop_word(), a special sentinel used for the initial value of the
- * Klass in an inline cache. It puts the called method into rbx before calling.
  */
 @Opcode("CALL_DIRECT")
 final class AMD64HotspotDirectStaticCallOp extends DirectCallOp {
@@ -55,12 +53,10 @@
     @Override
     public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
         // The mark for an invocation that uses an inline cache must be placed at the
-        // instruction
-        // that loads the Klass from the inline cache so that the C++ code can find it
-        // and replace the inline 0L value with Universe::non_oop_word()
+        // instruction that loads the Klass from the inline cache.
         AMD64Move.move(tasm, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod);
         tasm.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL);
-        AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.LONG_0);
+        AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.graalRuntime().getConfig().nonOopBits));
         super.emitCode(tasm, masm);
     }
 }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java	Tue Jul 16 15:08:28 2013 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
@@ -37,9 +38,6 @@
 /**
  * A direct call that complies with the conventions for such calls in HotSpot. In particular, for
  * calls using an inline cache, a MOVE instruction is emitted just prior to the aligned direct call.
- * This instruction (which moves 0L in RAX) is patched by the C++ Graal code to replace the 0L
- * constant with Universe::non_oop_word(), a special sentinel used for the initial value of the
- * Klass in an inline cache.
  */
 @Opcode("CALL_DIRECT")
 final class AMD64HotspotDirectVirtualCallOp extends DirectCallOp {
@@ -55,11 +53,9 @@
     @Override
     public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
         // The mark for an invocation that uses an inline cache must be placed at the
-        // instruction
-        // that loads the Klass from the inline cache so that the C++ code can find it
-        // and replace the inline 0L value with Universe::non_oop_word()
+        // instruction that loads the Klass from the inline cache.
         tasm.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE);
-        AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.LONG_0);
+        AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.graalRuntime().getConfig().nonOopBits));
         super.emitCode(tasm, masm);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Jul 16 15:08:28 2013 +0200
@@ -268,6 +268,12 @@
      */
     public int threadIsMethodHandleReturnOffset;
 
+    /**
+     * Bit pattern that represents a non-oop. Neither the high bits nor the low bits of this value
+     * are allowed to look like (respectively) the high or low bits of a real oop.
+     */
+    public long nonOopBits;
+
     public long verifyOopCounterAddress;
     public long verifyOopMask;
     public long verifyOopBits;
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Tue Jul 16 15:08:28 2013 +0200
@@ -44,10 +44,11 @@
     IMIN, LMIN, IUMIN, LUMIN, IREM,
     LREM, FREM, DREM, IUREM, LUREM,
     ICARRY, LCARRY, IUCARRY, LUCARRY,
-    IAND, INEG, IUSHR, I2B, I2S, I2L,
+    IAND, LAND, INEG, I2B, I2S, I2L,
     F2D, F2I, F2L, D2F, I2F, I2D, D2I,
     L2F, D2L, MOV_F2I, MOV_D2L, L2D, MOV_I2F,
-    MOV_L2D, ISHL, SQRT, UNDEF, CALL, L2I;
+    MOV_L2D, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR,
+    SQRT, UNDEF, CALL, L2I;
 
     public static class Op1Stack extends HSAILLIRInstruction {
         @Opcode private final HSAILArithmetic opcode;
@@ -245,6 +246,22 @@
     }
 
     public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) {
+        /**
+         * First check if one of src1 or src2 is an AddressValue.  If it is,
+         * convert the address to a register using an lda instruction.  We can
+         * just reuse the eventual dst register for this.
+         */
+        if (src1 instanceof HSAILAddressValue) {
+            assert (!(src2 instanceof HSAILAddressValue));
+            masm.emitLda(dst, ((HSAILAddressValue) src1).toAddress());
+            emit(tasm, masm, opcode, dst, dst, src2, info);
+            return;
+        } else if (src2 instanceof HSAILAddressValue) {
+            assert (!(src1 instanceof HSAILAddressValue));
+            masm.emitLda(dst, ((HSAILAddressValue) src2).toAddress());
+            emit(tasm, masm, opcode, dst, src1, dst, info);
+            return;
+        }
         int exceptionOffset = -1;
         switch (opcode) {
             case IADD:
@@ -276,7 +293,14 @@
             case LMIN:
                 masm.emit("min", dst, src1, src2); break;
             case ISHL:
+            case LSHL:
                 masm.emit("shl", dst, src1, src2); break;
+            case ISHR:
+            case LSHR:
+                masm.emit("shr", dst, src1, src2); break;
+            case IUSHR:
+            case LUSHR:
+                masm.emitForceUnsigned("shr", dst, src1, src2); break;
             case IREM:
                 masm.emit("rem", dst, src1, src2); break;
             default:    throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Tue Jul 16 15:08:28 2013 +0200
@@ -53,6 +53,34 @@
         }
     }
 
+
+    public static class ForeignCallNoArgOp extends HSAILLIRInstruction {
+
+        @Def({REG}) protected Value out;
+        String callName;
+
+        public ForeignCallNoArgOp(String callName, Value out) {
+            this.out = out;
+            this.callName = callName;
+        }
+
+        @Override
+        public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
+            masm.emitComment("//ForeignCall to " + callName + " would have gone here");
+        }
+    }
+
+    public static class ForeignCall1ArgOp extends ForeignCallNoArgOp {
+
+        @Use({REG, ILLEGAL}) protected Value arg1;
+
+        public ForeignCall1ArgOp(String callName, Value out, Value arg1) {
+            super(callName, out);
+            this.arg1 = arg1;
+        }
+    }
+
+
     public static class CompareBranchOp extends HSAILLIRInstruction implements StandardOp.BranchOp {
 
         @Opcode protected final HSAILCompare opcode;
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Tue Jul 16 15:08:28 2013 +0200
@@ -129,49 +129,147 @@
         }
     }
 
-    public static class LoadOp extends HSAILLIRInstruction {
 
-        @SuppressWarnings("unused") private final Kind kind;
-        @Def({REG}) protected AllocatableValue result;
+    public abstract static class MemOp extends HSAILLIRInstruction {
+
+        protected final Kind kind;
         @Use({COMPOSITE}) protected HSAILAddressValue address;
         @State protected LIRFrameState state;
 
-        public LoadOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
+        public MemOp(Kind kind, HSAILAddressValue address, LIRFrameState state) {
             this.kind = kind;
-            this.result = result;
             this.address = address;
             this.state = state;
         }
 
+        protected abstract void emitMemAccess(HSAILAssembler masm);
+
         @Override
         public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
+            if (state != null) {
+                // tasm.recordImplicitException(masm.codeBuffer.position(), state);
+                throw new InternalError("NYI");
+            }
+            emitMemAccess(masm);
+        }
+    }
+
+    public static class LoadOp extends MemOp {
+
+        @Def({REG}) protected AllocatableValue result;
+
+        public LoadOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
+            super(kind, address, state);
+            this.result = result;
+        }
+
+        @Override
+        public void emitMemAccess(HSAILAssembler masm) {
             HSAILAddress addr = address.toAddress();
             masm.emitLoad(result, addr);
         }
     }
 
-    public static class StoreOp extends HSAILLIRInstruction {
+    public static class StoreOp extends MemOp {
 
-        @SuppressWarnings("unused") private final Kind kind;
-        @Use({COMPOSITE}) protected HSAILAddressValue address;
         @Use({REG}) protected AllocatableValue input;
-        @State protected LIRFrameState state;
 
         public StoreOp(Kind kind, HSAILAddressValue address, AllocatableValue input, LIRFrameState state) {
-            this.kind = kind;
-            this.address = address;
+            super(kind, address, state);
             this.input = input;
-            this.state = state;
         }
 
         @Override
-        public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
+        public void emitMemAccess(HSAILAssembler masm) {
             assert isRegister(input);
             HSAILAddress addr = address.toAddress();
             masm.emitStore(input, addr);
         }
     }
 
+    public static class LoadCompressedPointer extends LoadOp {
+
+        private long narrowOopBase;
+        private int narrowOopShift;
+        private int logMinObjAlignment;
+        @Temp({REG}) private AllocatableValue scratch;
+
+        public LoadCompressedPointer(Kind kind, AllocatableValue result, AllocatableValue scratch, HSAILAddressValue address, LIRFrameState state, long narrowOopBase, int narrowOopShift,
+                        int logMinObjAlignment) {
+            super(kind, result, address, state);
+            this.narrowOopBase = narrowOopBase;
+            this.narrowOopShift = narrowOopShift;
+            this.logMinObjAlignment = logMinObjAlignment;
+            this.scratch = scratch;
+            assert kind == Kind.Object;
+        }
+
+        @Override
+        public void emitMemAccess(HSAILAssembler masm) {
+            // we will do a 32 bit load, zero extending into a 64 bit register
+            masm.emitLoad(result, address.toAddress(), "u32");
+            decodePointer(masm, result, narrowOopBase, narrowOopShift, logMinObjAlignment);
+        }
+    }
+
+    public static class StoreCompressedPointer extends HSAILLIRInstruction {
+
+        protected final Kind kind;
+        private long narrowOopBase;
+        private int narrowOopShift;
+        private int logMinObjAlignment;
+        @Temp({REG}) private AllocatableValue scratch;
+        @Alive({REG}) protected AllocatableValue input;
+        @Alive({COMPOSITE}) protected HSAILAddressValue address;
+        @State protected LIRFrameState state;
+
+        public StoreCompressedPointer(Kind kind, HSAILAddressValue address, AllocatableValue input, AllocatableValue scratch, LIRFrameState state, long narrowOopBase, int narrowOopShift,
+                        int logMinObjAlignment) {
+            this.narrowOopBase = narrowOopBase;
+            this.narrowOopShift = narrowOopShift;
+            this.logMinObjAlignment = logMinObjAlignment;
+            this.scratch = scratch;
+            this.kind = kind;
+            this.address = address;
+            this.state = state;
+            this.input = input;
+            assert kind == Kind.Object;
+        }
+
+        @Override
+        public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) {
+            masm.emitMov(scratch, input);
+            encodePointer(masm, scratch, narrowOopBase, narrowOopShift, logMinObjAlignment);
+            if (state != null) {
+                throw new InternalError("NYI");
+                // tasm.recordImplicitException(masm.codeBuffer.position(), state);
+            }
+            masm.emitStore(scratch, address.toAddress(), "u32");
+        }
+    }
+
+    private static void encodePointer(HSAILAssembler masm, Value scratch, long narrowOopBase, int narrowOopShift, int logMinObjAlignment) {
+        if (narrowOopBase == 0 && narrowOopShift == 0) {
+            return;
+        }
+        if (narrowOopShift != 0) {
+            assert logMinObjAlignment == narrowOopShift : "Encode algorithm is wrong";
+        }
+        masm.emitCompressedOopEncode(scratch, narrowOopBase, narrowOopShift);
+    }
+
+    private static void decodePointer(HSAILAssembler masm, Value result, long narrowOopBase, int narrowOopShift, int logMinObjAlignment) {
+        if (narrowOopBase == 0 && narrowOopShift == 0) {
+            return;
+        }
+        if (narrowOopShift != 0) {
+            assert logMinObjAlignment == narrowOopShift : "Decode algorithm is wrong";
+        }
+        masm.emitCompressedOopDecode(result, narrowOopBase, narrowOopShift);
+    }
+
+
+
     public static class LeaOp extends HSAILLIRInstruction {
 
         @Def({REG}) protected AllocatableValue result;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Tue Jul 16 15:08:28 2013 +0200
@@ -448,6 +448,10 @@
 
         @Override
         public boolean isWorthInlining(InlineInfo info, int inliningDepth, double probability, double relevance, boolean fullyProcessed) {
+            if (InlineEverything.getValue()) {
+                return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "inline everything");
+            }
+
             if (isIntrinsic(info)) {
                 return InliningUtil.logInlinedMethod(info, inliningDepth, fullyProcessed, "intrinsic");
             }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Tue Jul 16 15:07:09 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java	Tue Jul 16 15:08:28 2013 +0200
@@ -63,6 +63,8 @@
     public static final OptionValue<Integer> SmallCompiledLowLevelGraphSize = new OptionValue<>(300);
     @Option(help = "")
     public static final OptionValue<Double> LimitInlinedInvokes = new OptionValue<>(5.0);
+    @Option(help = "")
+    public static final OptionValue<Boolean> InlineEverything = new OptionValue<>(false);
 
     // escape analysis settings
     @Option(help = "")
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jul 16 15:07:09 2013 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Tue Jul 16 15:08:28 2013 +0200
@@ -788,7 +788,7 @@
     assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected");
     jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT));
 
-    address instruction = _instructions->start() + pc_offset;
+    address pc = _instructions->start() + pc_offset;
 
     switch (id) {
       case MARK_UNVERIFIED_ENTRY:
@@ -807,40 +807,34 @@
         _offsets.set_value(CodeOffsets::Deopt, pc_offset);
         break;
       case MARK_INVOKEVIRTUAL:
-      case MARK_INVOKEINTERFACE: {
-        // Convert the initial value of the Klass* slot in an inline cache
-        // from 0L to Universe::non_oop_word().
-        NativeMovConstReg* n_copy = nativeMovConstReg_at(instruction);
-        assert(n_copy->data() == 0, "inline cache Klass* initial value should be 0L");
-        n_copy->set_data((intptr_t)Universe::non_oop_word());
-      }
+      case MARK_INVOKEINTERFACE:
       case MARK_INLINE_INVOKE:
       case MARK_INVOKESTATIC:
       case MARK_INVOKESPECIAL:
         _next_call_type = (MarkId) id;
-        _invoke_mark_pc = instruction;
+        _invoke_mark_pc = pc;
         break;
       case MARK_POLL_NEAR: {
-        NativeInstruction* ni = nativeInstruction_at(instruction);
-        int32_t* disp = (int32_t*) pd_locate_operand(instruction);
+        NativeInstruction* ni = nativeInstruction_at(pc);
+        int32_t* disp = (int32_t*) pd_locate_operand(pc);
         // int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand);
         int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand
         intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni;
         *disp = (int32_t)new_disp;
       }
       case MARK_POLL_FAR:
-        _instructions->relocate(instruction, relocInfo::poll_type);
+        _instructions->relocate(pc, relocInfo::poll_type);
         break;
       case MARK_POLL_RETURN_NEAR: {
-        NativeInstruction* ni = nativeInstruction_at(instruction);
-        int32_t* disp = (int32_t*) pd_locate_operand(instruction);
+        NativeInstruction* ni = nativeInstruction_at(pc);
+        int32_t* disp = (int32_t*) pd_locate_operand(pc);
         // int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand);
         int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand
         intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni;
         *disp = (int32_t)new_disp;
       }
       case MARK_POLL_RETURN_FAR:
-        _instructions->relocate(instruction, relocInfo::poll_return_type);
+        _instructions->relocate(pc, relocInfo::poll_return_type);
         break;
       default:
         ShouldNotReachHere();
--- a/src/share/vm/graal/graalCompiler.cpp	Tue Jul 16 15:07:09 2013 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Tue Jul 16 15:08:28 2013 +0200
@@ -203,12 +203,12 @@
   if (field_type == T_OBJECT || field_type == T_ARRAY) {
     KlassHandle handle = GraalEnv::get_klass_by_name(loading_klass, signature, false);
     if (handle.is_null()) {
-      return get_JavaType(signature, CHECK_NULL);
+      return get_JavaType(signature, CHECK_NH);
     } else {
-      return get_JavaType(handle, CHECK_NULL);
+      return get_JavaType(handle, CHECK_NH);
     }
   } else {
-    return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NULL);
+    return VMToCompiler::createPrimitiveJavaType(field_type, CHECK_NH);
   }
 }
 
@@ -229,7 +229,7 @@
       if (tag.is_klass()) {
         // The klass has been inserted into the constant pool
         // very recently.
-        return GraalCompiler::get_JavaType(cp->resolved_klass_at(index), CHECK_NULL);
+        return GraalCompiler::get_JavaType(cp->resolved_klass_at(index), CHECK_NH);
       } else if (tag.is_symbol()) {
         klass_name = cp->symbol_at(index);
       } else {
@@ -237,9 +237,9 @@
         klass_name = cp->unresolved_klass_at(index);
       }
     }
-    return GraalCompiler::get_JavaType(klass_name, CHECK_NULL);
+    return GraalCompiler::get_JavaType(klass_name, CHECK_NH);
   } else {
-    return GraalCompiler::get_JavaType(klass, CHECK_NULL);
+    return GraalCompiler::get_JavaType(klass, CHECK_NH);
   }
 }
 
@@ -254,19 +254,19 @@
     return VMToCompiler::createPrimitiveJavaType((int) basicType, THREAD);
   } else {
     KlassHandle klass = java_lang_Class::as_Klass(java_class());
-    Handle name = java_lang_String::create_from_symbol(klass->name(), CHECK_NULL);
-    return GraalCompiler::createHotSpotResolvedObjectType(klass, name, CHECK_NULL);
+    Handle name = java_lang_String::create_from_symbol(klass->name(), CHECK_NH);
+    return GraalCompiler::createHotSpotResolvedObjectType(klass, name, CHECK_NH);
   }
 }
 
 Handle GraalCompiler::get_JavaType(KlassHandle klass, TRAPS) {
   Handle name = java_lang_String::create_from_symbol(klass->name(), THREAD);
-  return createHotSpotResolvedObjectType(klass, name, CHECK_NULL);
+  return createHotSpotResolvedObjectType(klass, name, CHECK_NH);
 }
 
 Handle GraalCompiler::get_JavaField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, TRAPS) {
-  Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NULL);
-  return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NULL);
+  Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NH);
+  return VMToCompiler::createJavaField(field_holder, name, field_type, offset, flags, false, CHECK_NH);
 }
 
 Handle GraalCompiler::createHotSpotResolvedObjectType(methodHandle method, TRAPS) {
@@ -277,8 +277,8 @@
     assert(graal_mirror->is_a(HotSpotResolvedObjectType::klass()), "unexpected class...");
     return graal_mirror;
   }
-  Handle name = java_lang_String::create_from_symbol(klass->name(), CHECK_NULL);
-  return GraalCompiler::createHotSpotResolvedObjectType(klass, name, CHECK_NULL);
+  Handle name = java_lang_String::create_from_symbol(klass->name(), CHECK_NH);
+  return GraalCompiler::createHotSpotResolvedObjectType(klass, name, CHECK_NH);
 }
 
 Handle GraalCompiler::createHotSpotResolvedObjectType(KlassHandle klass, Handle name, TRAPS) {
@@ -293,7 +293,7 @@
   if (klass->oop_is_instance()) {
     ResourceMark rm;
     InstanceKlass* ik = (InstanceKlass*) klass();
-    name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL);
+    name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NH);
   }
 
   int sizeOrSpecies;
@@ -308,7 +308,7 @@
     }
   }
 
-  return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, sizeOrSpecies, CHECK_NULL);
+  return VMToCompiler::createResolvedJavaType(klass(), name, simpleName, java_class, sizeOrSpecies, CHECK_NH);
 }
 
 BasicType GraalCompiler::kindToBasicType(jchar ch) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Jul 16 15:07:09 2013 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Tue Jul 16 15:08:28 2013 +0200
@@ -786,6 +786,7 @@
   set_boolean("tlabStats", TLABStats);
   set_boolean("inlineContiguousAllocationSupported", !CMSIncrementalMode && Universe::heap()->supports_inline_contig_alloc());
 
+  set_address("nonOopBits", Universe::non_oop_word());
   set_long("verifyOopCounterAddress", (jlong)(address) StubRoutines::verify_oop_count_addr());
   set_long("verifyOopMask", Universe::verify_oop_mask());
   set_long("verifyOopBits", Universe::verify_oop_bits());
--- a/src/share/vm/graal/graalRuntime.hpp	Tue Jul 16 15:07:09 2013 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Tue Jul 16 15:08:28 2013 +0200
@@ -34,9 +34,9 @@
   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 jboolean thread_is_interrupted(JavaThread* thread, oop obj, jboolean clear_interrupted);
   static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
-  static jint identity_hash_code(JavaThread* thread, oopDesc* objd);
+  static jint identity_hash_code(JavaThread* thread, oop obj);
   static address exception_handler_for_pc(JavaThread* thread);
   static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
   static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Tue Jul 16 15:07:09 2013 +0200
+++ b/src/share/vm/graal/graalVMToCompiler.cpp	Tue Jul 16 15:08:28 2013 +0200
@@ -22,6 +22,7 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/systemDictionary.hpp"
 #include "graal/graalVMToCompiler.hpp"
 
 // this is a *global* handle
@@ -30,7 +31,7 @@
 Klass* VMToCompiler::_vmToCompilerPermKlass = NULL;
 
 static Klass* loadClass(Symbol* name) {
-  Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), NULL, Thread::current());
+  Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), Handle(), Thread::current());
   if (klass == NULL) {
     tty->print_cr("Could not load class %s", name->as_C_string());
     vm_abort(false);