changeset 11649:e8dfad9a424f

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 15 Sep 2013 16:44:09 +0200
parents 4ab1f371adc8 (current diff) 269e6794e1ec (diff)
children 932252b772c3
files graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java
diffstat 24 files changed, 333 insertions(+), 275 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Sun Sep 15 16:44:09 2013 +0200
@@ -553,6 +553,14 @@
         emitString(".param" + " " + ".s8" + " " + d + (lastParam ? "" : ","));
     }
 
+    public final void param_16_decl(Register d, boolean lastParam) {
+        emitString(".param" + " " + ".s16" + " " + d + (lastParam ? "" : ","));
+    }
+
+    public final void param_u16_decl(Register d, boolean lastParam) {
+        emitString(".param" + " " + ".s16" + " " + d + (lastParam ? "" : ","));
+    }
+
     public final void param_32_decl(Register d, boolean lastParam) {
         emitString(".param" + " " + ".s32" + " " + d + (lastParam ? "" : ","));
     }
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java	Sun Sep 15 16:44:09 2013 +0200
@@ -31,20 +31,24 @@
     @Ignore
     @Test
     public void testArray() {
-        compile("testArray1I");
-        compile("testArray1J");
-        compile("testArray1B");
-        compile("testArray1S");
-        compile("testArray1C");
-        compile("testArray1F");
-        compile("testArray1D");
-        compile("testArray1L");
-        compile("testStoreArray1I");
-        compile("testStoreArray1J");
-        compile("testStoreArray1B");
-        compile("testStoreArray1S");
-        compile("testStoreArray1F");
-        compile("testStoreArray1D");
+        int[] arrayI = {
+            1, 2, 3, 4, 5
+        };
+        Integer resI = (Integer) invoke(compile("testArray1I"), arrayI, 3);
+        printReport("testArray1I: " + resI);
+        // compile("testArray1J");
+        // compile("testArray1B");
+        // compile("testArray1S");
+        // compile("testArray1C");
+        // compile("testArray1F");
+        // compile("testArray1D");
+        // compile("testArray1L");
+        // compile("testStoreArray1I");
+        // compile("testStoreArray1J");
+        // compile("testStoreArray1B");
+        // compile("testStoreArray1S");
+        // compile("testStoreArray1F");
+        // compile("testStoreArray1D");
     }
 
     public static int testArray1I(int[] array, int i) {
@@ -103,6 +107,13 @@
         array[i] = val;
     }
 
+    public static void printReport(String message) {
+        // CheckStyle: stop system..print check
+        System.out.println(message);
+        // CheckStyle: resume system..print check
+
+    }
+
     public static void main(String[] args) {
         ArrayPTXTest test = new ArrayPTXTest();
         for (Method m : ArrayPTXTest.class.getMethods()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Sun Sep 15 16:44:09 2013 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.compiler.ptx.test;
+
+import org.junit.*;
+
+import java.lang.reflect.Method;
+
+public class ControlPTXTest extends PTXTestBase {
+
+    @Ignore
+    @Test
+    public void testControl() {
+        compile("testLoop");
+        // compile("testSwitch1I");
+        // compile("testStatic");
+        // compile("testCall");
+        // compile("testLookupSwitch1I");
+    }
+
+    public static int testLoop(int n) {
+        int sum = 0;
+
+        for (int i = 0; i < n; i++) {
+            sum++;
+        }
+        return sum;
+    }
+
+    public static int testSwitch1I(int a) {
+        switch (a) {
+            case 1:
+                return 2;
+            case 2:
+                return 3;
+            default:
+                return 4;
+        }
+    }
+
+    public static int testLookupSwitch1I(int a) {
+        switch (a) {
+            case 0:
+                return 1;
+            case 1:
+                return 2;
+            case 2:
+                return 3;
+            case 3:
+                return 1;
+            case 4:
+                return 2;
+            case 5:
+                return 3;
+            case 6:
+                return 1;
+            case 7:
+                return 2;
+            case 8:
+                return 3;
+            case 9:
+                return 1;
+            case 10:
+                return 2;
+            case 11:
+                return 3;
+            default:
+                return -1;
+        }
+    }
+
+    @SuppressWarnings("unused") private static Object foo = null;
+
+    public static boolean testStatic(Object o) {
+        foo = o;
+        return true;
+    }
+
+    private static int method(int a, int b) {
+        return a + b;
+    }
+
+    public static int testCall(@SuppressWarnings("unused") Object o, int a, int b) {
+        return method(a, b);
+    }
+
+    public static void main(String[] args) {
+        ControlPTXTest test = new ControlPTXTest();
+        for (Method m : ControlPTXTest.class.getMethods()) {
+            String name = m.getName();
+            if (m.getAnnotation(Test.class) == null && name.startsWith("test")) {
+                // CheckStyle: stop system..print check
+                System.out.println(name + ": \n" + new String(test.compile(name).getTargetCode()));
+                // CheckStyle: resume system..print check
+            }
+        }
+    }
+}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlTest.java	Sun Sep 15 16:31:32 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import org.junit.*;
-
-import java.lang.reflect.Method;
-
-public class ControlTest extends PTXTestBase {
-
-    @Ignore
-    @Test
-    public void testControl() {
-        compile("testSwitch1I");
-        compile("testStatic");
-        compile("testCall");
-        compile("testLookupSwitch1I");
-    }
-
-    public static int testSwitch1I(int a) {
-        switch (a) {
-            case 1:
-                return 2;
-            case 2:
-                return 3;
-            default:
-                return 4;
-        }
-    }
-
-    public static int testLookupSwitch1I(int a) {
-        switch (a) {
-            case 0:
-                return 1;
-            case 1:
-                return 2;
-            case 2:
-                return 3;
-            case 3:
-                return 1;
-            case 4:
-                return 2;
-            case 5:
-                return 3;
-            case 6:
-                return 1;
-            case 7:
-                return 2;
-            case 8:
-                return 3;
-            case 9:
-                return 1;
-            case 10:
-                return 2;
-            case 11:
-                return 3;
-            default:
-                return -1;
-        }
-    }
-
-    @SuppressWarnings("unused") private static Object foo = null;
-
-    public static boolean testStatic(Object o) {
-        foo = o;
-        return true;
-    }
-
-    private static int method(int a, int b) {
-        return a + b;
-    }
-
-    public static int testCall(@SuppressWarnings("unused") Object o, int a, int b) {
-        return method(a, b);
-    }
-
-    public static void main(String[] args) {
-        ControlTest test = new ControlTest();
-        for (Method m : ControlTest.class.getMethods()) {
-            String name = m.getName();
-            if (m.getAnnotation(Test.class) == null && name.startsWith("test")) {
-                // CheckStyle: stop system..print check
-                System.out.println(name + ": \n" + new String(test.compile(name).getTargetCode()));
-                // CheckStyle: resume system..print check
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java	Sun Sep 15 16:44:09 2013 +0200
@@ -165,6 +165,9 @@
                        case Double:
                            float64.add(regVal.getRegister().encoding());
                            break;
+                       case Object:
+                           signed64.add(regVal.getRegister().encoding());
+                           break;
                        default :
                            throw GraalInternalError.shouldNotReachHere("unhandled register type "  + value.toString());
                     }
@@ -204,6 +207,7 @@
         try {
             emitRegisterDecl(tasm, lirGen, codeCacheOwner);
         } catch (GraalInternalError e) {
+            e.printStackTrace();
             // TODO : Better error handling needs to be done once
             //        all types of parameters are handled.
             codeBuffer.setPosition(0);
@@ -214,6 +218,7 @@
         try {
             lirGen.lir.emitCode(tasm);
         } catch (GraalInternalError e) {
+            e.printStackTrace();
             // TODO : Better error handling needs to be done once
             //        all types of parameters are handled.
             codeBuffer.setPosition(0);
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Sun Sep 15 16:44:09 2013 +0200
@@ -32,6 +32,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.debug.Debug;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.JumpOp;
@@ -786,9 +787,9 @@
 
     @Override
     public void visitSafepointNode(SafepointNode i) {
-        // LIRFrameState info = state();
+        // LIRFrameState info = state(i);
         // append(new PTXSafepointOp(info, runtime().config, this));
-        throw new InternalError("NYI");
+        Debug.log("visitSafePointNode unimplemented");
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Sun Sep 15 16:44:09 2013 +0200
@@ -78,7 +78,7 @@
             param4, param5, param6, param7,
             r0,  r1,  r2,  r3,  r4,  r5,  r6,  r7,
             r8,  r9,  r10, r11, r12, r13, r14, r15,
-            retReg,
+            // retReg,
         };
 
         return registers;
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Sun Sep 15 16:44:09 2013 +0200
@@ -48,21 +48,30 @@
         for (int i = 0; i < argCount; i++) {
             Kind paramKind = params[i].getKind();
             switch (paramKind) {
-            case Byte :
+            case Byte:
                 masm.param_8_decl(asRegister(params[i]), (i == (argCount - 1)));
                 break;
-            case Int :
+            case Short:
+                masm.param_16_decl(asRegister(params[i]), (i == (argCount - 1)));
+                break;
+            case Char:
+                masm.param_u16_decl(asRegister(params[i]), (i == (argCount - 1)));
+                break;
+            case Int:
                 masm.param_32_decl(asIntReg(params[i]), (i == (argCount - 1)));
                 break;
-            case Long :
+            case Long:
                 masm.param_64_decl(asLongReg(params[i]), (i == (argCount - 1)));
                 break;
-            case Float :
+            case Float:
                 masm.param_32_decl(asFloatReg(params[i]), (i == (argCount - 1)));
                 break;
-            case Double :
+            case Double:
                 masm.param_64_decl(asDoubleReg(params[i]), (i == (argCount - 1)));
                 break;
+            case Object:
+                masm.param_64_decl(asObjectReg(params[i]), (i == (argCount - 1)));
+                break;
             default :
                 throw GraalInternalError.shouldNotReachHere("unhandled parameter type "  + paramKind.toString());
             }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Sun Sep 15 16:44:09 2013 +0200
@@ -50,6 +50,7 @@
         this.caller = caller;
         this.arguments = arguments;
         this.locals = new Object[descriptor.getSize()];
+        Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue());
         this.primitiveLocals = new long[descriptor.getSize()];
         this.tags = new byte[descriptor.getSize()];
     }
@@ -90,8 +91,8 @@
     }
 
     @Override
-    public void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException {
-        verifySet(slot, FrameSlotKind.Object);
+    public void setObject(FrameSlot slot, Object value) {
+        verifySetObject(slot);
         setObjectUnsafe(slot, value);
     }
 
@@ -242,43 +243,50 @@
         tags[slotIndex] = (byte) accessKind.ordinal();
     }
 
-    private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
-        FrameSlotKind slotKind = slot.getKind();
-        if (slotKind != accessKind) {
+    private void verifySetObject(FrameSlot slot) {
+        if (slot.getKind() != FrameSlotKind.Object) {
             CompilerDirectives.transferToInterpreter();
-            if (slotKind == FrameSlotKind.Illegal && accessKind == FrameSlotKind.Object) {
-                slot.setKind(FrameSlotKind.Object);
-                this.setObject(slot, descriptor.getTypeConversion().getDefaultValue());
-            } else {
-                throw new FrameSlotTypeException();
-            }
+            slot.setKind(FrameSlotKind.Object);
         }
         int slotIndex = slot.getIndex();
         if (slotIndex >= tags.length) {
             CompilerDirectives.transferToInterpreter();
             resize();
         }
-        if (tags[slotIndex] != accessKind.ordinal()) {
+        tags[slotIndex] = (byte) FrameSlotKind.Object.ordinal();
+    }
+
+    private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
             CompilerDirectives.transferToInterpreter();
-            descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot));
-            if (tags[slotIndex] != accessKind.ordinal()) {
-                throw new FrameSlotTypeException();
+            resize();
+        }
+        byte tag = tags[slotIndex];
+        if (accessKind == FrameSlotKind.Object ? (tag & 0xfe) != 0 : tag != accessKind.ordinal()) {
+            CompilerDirectives.transferToInterpreter();
+            if (slot.getKind() == accessKind || tag == 0) {
+                descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot));
+                if (tags[slotIndex] == accessKind.ordinal()) {
+                    return;
+                }
             }
+            throw new FrameSlotTypeException();
         }
     }
 
     @Override
     public Object getValue(FrameSlot slot) {
-        int index = slot.getIndex();
-        if (index >= tags.length) {
-            assert index >= 0 && index < descriptor.getSize();
-            return descriptor.getTypeConversion().getDefaultValue();
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
+            CompilerDirectives.transferToInterpreter();
+            resize();
         }
-        byte tag = tags[index];
-        if (tag == FrameSlotKind.Illegal.ordinal()) {
-            return descriptor.getTypeConversion().getDefaultValue();
-        } else if (tag == FrameSlotKind.Boolean.ordinal()) {
+        byte tag = tags[slotIndex];
+        if (tag == FrameSlotKind.Boolean.ordinal()) {
             return getBooleanUnsafe(slot);
+        } else if (tag == FrameSlotKind.Byte.ordinal()) {
+            return getByteUnsafe(slot);
         } else if (tag == FrameSlotKind.Int.ordinal()) {
             return getIntUnsafe(slot);
         } else if (tag == FrameSlotKind.Double.ordinal()) {
@@ -288,14 +296,17 @@
         } else if (tag == FrameSlotKind.Float.ordinal()) {
             return getFloatUnsafe(slot);
         } else {
+            assert tag == FrameSlotKind.Object.ordinal() || tag == FrameSlotKind.Illegal.ordinal();
             return getObjectUnsafe(slot);
         }
     }
 
     private void resize() {
+        int oldSize = tags.length;
         int newSize = descriptor.getSize();
-        if (newSize > tags.length) {
+        if (newSize > oldSize) {
             locals = Arrays.copyOf(locals, newSize);
+            Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue());
             primitiveLocals = Arrays.copyOf(primitiveLocals, newSize);
             tags = Arrays.copyOf(tags, newSize);
         }
@@ -303,14 +314,11 @@
 
     @Override
     public boolean isInitialized(FrameSlot slot) {
-        try {
-            return tags[slot.getIndex()] != 0;
-        } catch (ArrayIndexOutOfBoundsException ex) {
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
             CompilerDirectives.transferToInterpreter();
-            if (slot.getIndex() >= 0 && slot.getIndex() < descriptor.getSize()) {
-                return false;
-            }
-            throw ex;
+            resize();
         }
+        return tags[slotIndex] != 0;
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Sun Sep 15 16:44:09 2013 +0200
@@ -214,7 +214,8 @@
     }
 
     private static void verifyGet(FrameWithoutBoxing frame, FrameSlot slot, FrameSlotKind accessType) {
-        if (getTag(frame, slot) != (byte) accessType.ordinal()) {
+        byte tag = getTag(frame, slot);
+        if (accessType == FrameSlotKind.Object ? (tag & 0xfe) != 0 : tag != (byte) accessType.ordinal()) {
             DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.UnreachedCode);
         }
     }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java	Sun Sep 15 16:44:09 2013 +0200
@@ -116,7 +116,7 @@
                     // fall through
                 }
             }
-            FrameUtil.setObjectSafe(frame, slot, o);
+            frame.setObject(slot, o);
             this.replace(new ObjectAssignLocal(slot, value));
             return null;
         }
@@ -134,11 +134,7 @@
         @Override
         Object execute(VirtualFrame frame) {
             Object o = value.execute(frame);
-            try {
-                frame.setObject(slot, o);
-            } catch (FrameSlotTypeException e) {
-                FrameUtil.setObjectSafe(frame, slot, o);
-            }
+            frame.setObject(slot, o);
             return null;
         }
     }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java	Sun Sep 15 16:44:09 2013 +0200
@@ -120,11 +120,11 @@
                 try {
                     frame.setInt(slot, result);
                 } catch (FrameSlotTypeException e) {
-                    FrameUtil.setObjectSafe(frame, slot, result);
+                    frame.setObject(slot, result);
                     replace(new ObjectAssignLocal(slot, value));
                 }
             } catch (UnexpectedResultException e) {
-                FrameUtil.setObjectSafe(frame, slot, e.getResult());
+                frame.setObject(slot, e.getResult());
                 replace(new ObjectAssignLocal(slot, value));
             }
             return null;
@@ -143,11 +143,7 @@
         @Override
         Object execute(VirtualFrame frame) {
             Object o = value.execute(frame);
-            try {
-                frame.setObject(slot, o);
-            } catch (FrameSlotTypeException e) {
-                FrameUtil.setObjectSafe(frame, slot, o);
-            }
+            frame.setObject(slot, o);
             return null;
         }
     }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java	Sun Sep 15 16:44:09 2013 +0200
@@ -64,7 +64,7 @@
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
-    void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException;
+    void setObject(FrameSlot slot, Object value);
 
     /**
      * Read access to a local variable of type byte.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotImpl.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlotImpl.java	Sun Sep 15 16:44:09 2013 +0200
@@ -51,9 +51,10 @@
     }
 
     public void setKind(final FrameSlotKind kind) {
-        assert this.kind != kind;
-        this.kind = kind;
-        this.descriptor.updateVersion();
+        if (this.kind != kind) {
+            this.kind = kind;
+            this.descriptor.updateVersion();
+        }
     }
 
     @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameUtil.java	Sun Sep 15 16:44:09 2013 +0200
@@ -35,14 +35,7 @@
      * @param value the new value of the local variable
      */
     public static void setObjectSafe(Frame frame, FrameSlot slot, Object value) {
-        if (slot.getKind() != FrameSlotKind.Object) {
-            slot.setKind(FrameSlotKind.Object);
-        }
-        try {
-            frame.setObject(slot, value);
-        } catch (FrameSlotTypeException e) {
-            throw new IllegalStateException();
-        }
+        frame.setObject(slot, value);
     }
 
     /**
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultFrameTypeConversion.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultFrameTypeConversion.java	Sun Sep 15 16:44:09 2013 +0200
@@ -40,7 +40,7 @@
 
     @Override
     public void updateFrameSlot(Frame frame, FrameSlot slot, Object value) {
-        FrameUtil.setObjectSafe(frame, slot, value);
+        frame.setObject(slot, value);
     }
 
     public static DefaultFrameTypeConversion getInstance() {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java	Sun Sep 15 16:44:09 2013 +0200
@@ -46,7 +46,7 @@
     }
 
     @Override
-    public void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException {
+    public void setObject(FrameSlot slot, Object value) {
         wrapped.setObject(slot, value);
     }
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Sun Sep 15 16:44:09 2013 +0200
@@ -42,6 +42,7 @@
         this.caller = caller;
         this.arguments = arguments;
         this.locals = new Object[descriptor.getSize()];
+        Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue());
         this.tags = new byte[descriptor.getSize()];
     }
 
@@ -73,8 +74,8 @@
     }
 
     @Override
-    public void setObject(FrameSlot slot, Object value) throws FrameSlotTypeException {
-        verifySet(slot, FrameSlotKind.Object);
+    public void setObject(FrameSlot slot, Object value) {
+        verifySetObject(slot);
         locals[slot.getIndex()] = value;
     }
 
@@ -157,17 +158,11 @@
 
     @Override
     public Object getValue(FrameSlot slot) {
-        int index = slot.getIndex();
-        if (index >= tags.length) {
-            assert index >= 0 && index < descriptor.getSize();
-            return descriptor.getTypeConversion().getDefaultValue();
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
+            resize();
         }
-        byte tag = tags[index];
-        if (tag == FrameSlotKind.Illegal.ordinal()) {
-            return descriptor.getTypeConversion().getDefaultValue();
-        } else {
-            return locals[index];
-        }
+        return locals[slotIndex];
     }
 
     private void verifySet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
@@ -186,45 +181,50 @@
         tags[slotIndex] = (byte) accessKind.ordinal();
     }
 
-    private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
-        FrameSlotKind slotKind = slot.getKind();
-        if (slotKind != accessKind) {
-            if (slotKind == FrameSlotKind.Illegal && accessKind == FrameSlotKind.Object) {
-                slot.setKind(FrameSlotKind.Object);
-                this.setObject(slot, descriptor.getTypeConversion().getDefaultValue());
-            } else {
-                throw new FrameSlotTypeException();
-            }
+    private void verifySetObject(FrameSlot slot) {
+        if (slot.getKind() != FrameSlotKind.Object) {
+            slot.setKind(FrameSlotKind.Object);
         }
         int slotIndex = slot.getIndex();
         if (slotIndex >= tags.length) {
             resize();
         }
-        if (tags[slotIndex] != accessKind.ordinal()) {
-            descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot));
-            if (tags[slotIndex] != accessKind.ordinal()) {
-                throw new FrameSlotTypeException();
+        tags[slotIndex] = (byte) FrameSlotKind.Object.ordinal();
+    }
+
+    private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
+            resize();
+        }
+        byte tag = tags[slotIndex];
+        if (accessKind == FrameSlotKind.Object ? (tag & 0xfe) != 0 : tag != accessKind.ordinal()) {
+            if (slot.getKind() == accessKind || tag == 0) {
+                descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot));
+                if (tags[slotIndex] == accessKind.ordinal()) {
+                    return;
+                }
             }
+            throw new FrameSlotTypeException();
         }
     }
 
     private void resize() {
+        int oldSize = tags.length;
         int newSize = descriptor.getSize();
-        if (newSize > tags.length) {
+        if (newSize > oldSize) {
             locals = Arrays.copyOf(locals, newSize);
+            Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue());
             tags = Arrays.copyOf(tags, newSize);
         }
     }
 
     @Override
     public boolean isInitialized(FrameSlot slot) {
-        try {
-            return tags[slot.getIndex()] != 0;
-        } catch (ArrayIndexOutOfBoundsException ex) {
-            if (slot.getIndex() >= 0 && slot.getIndex() < descriptor.getSize()) {
-                return false;
-            }
-            throw ex;
+        int slotIndex = slot.getIndex();
+        if (slotIndex >= tags.length) {
+            resize();
         }
+        return tags[slotIndex] != 0;
     }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Sun Sep 15 16:44:09 2013 +0200
@@ -218,8 +218,10 @@
                 }
             }
             setNodeProperty(node, "class", node.getClass().getSimpleName());
-            readNodeProperties((Node) node);
-            copyDebugProperties(node);
+            if (node instanceof Node) {
+                readNodeProperties((Node) node);
+                copyDebugProperties((Node) node);
+            }
         }
     }
 
@@ -252,12 +254,10 @@
         propElem.setTextContent(String.valueOf(value));
     }
 
-    private void copyDebugProperties(Object node) {
-        if (node instanceof Node) {
-            Map<String, Object> debugProperties = ((Node) node).getDebugProperties();
-            for (Map.Entry<String, Object> property : debugProperties.entrySet()) {
-                setNodeProperty(node, property.getKey(), property.getValue());
-            }
+    private void copyDebugProperties(Node node) {
+        Map<String, Object> debugProperties = node.getDebugProperties();
+        for (Map.Entry<String, Object> property : debugProperties.entrySet()) {
+            setNodeProperty(node, property.getKey(), property.getValue());
         }
     }
 
@@ -274,7 +274,7 @@
         }
     }
 
-    protected void connectNodes(Object a, Object b) {
+    protected void connectNodes(Object a, Object b, String label) {
         if (nodeMap.get(a) == null || nodeMap.get(b) == null) {
             return;
         }
@@ -294,6 +294,9 @@
         edgeElem.setAttribute("from", fromId);
         edgeElem.setAttribute("to", toId);
         edgeElem.setAttribute("index", String.valueOf(count));
+        if (label != null) {
+            edgeElem.setAttribute("label", label);
+        }
         edgesElement.appendChild(edgeElem);
         edgeList.add(edgeElem);
     }
@@ -304,45 +307,60 @@
         }
 
         // if node is visited once again, skip
-        if (getElementByObject(node) == null || NodeUtil.findAnnotation(node.getClass(), GraphDuplicate.class) != null) {
-            visitAny(node);
+        if (getElementByObject(node) != null && NodeUtil.findAnnotation(node.getClass(), GraphDuplicate.class) == null) {
+            return this;
+        }
+
+        // respect node's custom handler
+        if (NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class) != null) {
+            Class<? extends GraphPrintHandler> customHandlerClass = NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class).handler();
+            try {
+                GraphPrintHandler customHandler = customHandlerClass.newInstance();
+                customHandler.visit(node, new GraphPrintAdapter());
+            } catch (InstantiationException | IllegalAccessException e) {
+                assert false : e;
+            }
+        } else if (NodeUtil.findAnnotation(node.getClass(), NullGraphPrintHandler.class) != null) {
+            // ignore
+        } else {
+            // default handler
+            createElementForNode(node);
+
+            if (node instanceof Node) {
+                for (Map.Entry<String, Node> child : findNamedNodeChildren((Node) node).entrySet()) {
+                    visit(child.getValue());
+                    connectNodes(node, child.getValue(), child.getKey());
+                }
+            }
         }
 
         return this;
     }
 
-    private void visitAny(Object node) {
-        // respect node's custom handler
-        if (NodeUtil.findAnnotation(node.getClass(), NullGraphPrintHandler.class) != null) {
-            return;
-        }
-        if (NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class) != null) {
-            Class<? extends GraphPrintHandler> gpHandlerClass = NodeUtil.findAnnotation(node.getClass(), CustomGraphPrintHandler.class).handler();
-            try {
-                GraphPrintHandler gpHandler = gpHandlerClass.newInstance();
-                gpHandler.visit(node, new GraphPrintAdapter());
-            } catch (InstantiationException e) {
-                assert false;
-            } catch (IllegalAccessException e) {
-                assert false;
+    private static LinkedHashMap<String, Node> findNamedNodeChildren(Node node) {
+        LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
+        NodeClass nodeClass = NodeClass.get(node.getClass());
+
+        for (NodeField field : nodeClass.getFields()) {
+            NodeFieldKind kind = field.getKind();
+            if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) {
+                Object value = field.loadValue(node);
+                if (value != null) {
+                    if (kind == NodeFieldKind.CHILD) {
+                        nodes.put(field.getName(), (Node) value);
+                    } else if (kind == NodeFieldKind.CHILDREN) {
+                        Object[] children = (Object[]) value;
+                        for (int i = 0; i < children.length; i++) {
+                            if (children[i] != null) {
+                                nodes.put(field.getName() + "[" + i + "]", (Node) children[i]);
+                            }
+                        }
+                    }
+                }
             }
-            return;
         }
 
-        // default handler
-        createElementForNode(node);
-
-        List<Node> children = NodeUtil.findNodeChildren((Node) node);
-        for (Object child : children) {
-            if (child == null) {
-                continue;
-            } else if (child instanceof Node) {
-                visit(child);
-            } else {
-                continue;
-            }
-            connectNodes(node, child);
-        }
+        return nodes;
     }
 
     public class GraphPrintAdapter {
@@ -356,7 +374,7 @@
         }
 
         public void connectNodes(Object node, Object child) {
-            GraphPrintVisitor.this.connectNodes(node, child);
+            GraphPrintVisitor.this.connectNodes(node, child, null);
         }
 
         public void setNodeProperty(Object node, String propertyName, Object value) {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Sun Sep 15 16:44:09 2013 +0200
@@ -37,7 +37,7 @@
 /**
  * Utility class that manages the special access methods for node instances.
  */
-public class NodeUtil {
+public final class NodeUtil {
 
     /**
      * Interface that allows the customization of field offsets used for {@link Unsafe} field
@@ -274,7 +274,7 @@
         return array;
     }
 
-    protected static final Unsafe unsafe = getUnsafe();
+    private static final Unsafe unsafe = getUnsafe();
 
     private static Unsafe getUnsafe() {
         try {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadLocalNode.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/ReadLocalNode.java	Sun Sep 15 16:44:09 2013 +0200
@@ -50,7 +50,7 @@
         try {
             return frame.getObject(slot);
         } catch (FrameSlotTypeException e) {
-            throw new RuntimeException("uninitialized variable " + slot.getIdentifier());
+            throw new IllegalStateException();
         }
     }
 
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/WriteLocalNode.java	Sun Sep 15 16:44:09 2013 +0200
@@ -50,11 +50,7 @@
 
     @Specialization
     public Object writeGeneric(VirtualFrame frame, Object right) {
-        try {
-            frame.setObject(slot, right);
-        } catch (FrameSlotTypeException e) {
-            FrameUtil.setObjectSafe(frame, slot, right);
-        }
+        frame.setObject(slot, right);
         return right;
     }
 
--- a/src/gpu/ptx/vm/gpu_ptx.cpp	Sun Sep 15 16:31:32 2013 +0200
+++ b/src/gpu/ptx/vm/gpu_ptx.cpp	Sun Sep 15 16:44:09 2013 +0200
@@ -170,7 +170,7 @@
   int status = _cuda_cu_ctx_create(&_device_context, 0, _cu_device);
 
   if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to create CUDA context for device: %d", _cu_device);
+    tty->print_cr("[CUDA] Failed to create CUDA context for device(%d): %d", _cu_device, status);
     return NULL;
   }
 
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java	Sun Sep 15 16:31:32 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java	Sun Sep 15 16:44:09 2013 +0200
@@ -69,7 +69,7 @@
 import org.openide.windows.WindowManager;
 
 /**
- * 
+ *
  * @author Thomas Wuerthinger
  */
 public final class EditorTopComponent extends TopComponent implements PropertyChangeListener {
@@ -140,7 +140,7 @@
     };
 
     private ChangedEvent<DiagramProvider> diagramChangedEvent = new ChangedEvent<>(diagramProvider);
-    
+
 
     private void updateDisplayName() {
         setDisplayName(getDiagram().getName());
@@ -254,6 +254,11 @@
         toolBar.add(Box.createHorizontalGlue());
         Action action = Utilities.actionsForPath("QuickSearchShadow").get(0);
         Component quicksearch = ((Presenter.Toolbar) action).getToolbarPresenter();
+        try {
+            // (aw) workaround for disappearing search bar due to reparenting one shared component instance.
+            quicksearch = (Component) quicksearch.getClass().getConstructor(KeyStroke.class).newInstance(new Object[]{null});
+        } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
+        }
         quicksearch.setMinimumSize(quicksearch.getPreferredSize()); // necessary for GTK LAF
         toolBar.add(quicksearch);
 
@@ -420,7 +425,7 @@
             graphContent.set(list, null);
             diagramProvider.getChangedEvent().fire();
         }
-        
+
     };
 
     public boolean showPredSucc() {