changeset 15132:844cfee4041a

Merge.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 16 Apr 2014 14:02:52 +0200
parents 9c1e53adc159 (current diff) bd4c7b669bd8 (diff)
children f9c9eedef118
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ObjectLocationIdentity.java graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/nodes/LoweredAtomicGetAndAddNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/FastNodeClassRegistry.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NotNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/DeferredForeignCallNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SnippetLocationNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/GenericStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CompositeValueClassSubstitutions.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNodeProfile.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PackedFrameImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetImplSubstitutions.java graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/SnippetLocationNode.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Arguments.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/PackedFrame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallNode.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultPackedFrame.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLArguments.java src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp src/cpu/x86/vm/graalCodeInstaller_x86.hpp
diffstat 1678 files changed, 23327 insertions(+), 9021 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Apr 15 19:08:29 2014 +0200
+++ b/.hgignore	Wed Apr 16 14:02:52 2014 +0200
@@ -70,6 +70,7 @@
 .idea/
 ^cscope.out
 ^tags
+graal.src.zip*
 syntax: glob
 *.bgv
 core.*
--- a/CHANGELOG.md	Tue Apr 15 19:08:29 2014 +0200
+++ b/CHANGELOG.md	Wed Apr 16 14:02:52 2014 +0200
@@ -4,9 +4,19 @@
 ### Graal
 * Explicit support for oop compression/uncompression in high level graph.
 * LIRGenerator refactoring.
+* Explicit types for inputs (InputType enum).
+* Added graal.version system property to Graal enabled VM builds.
+* Transitioned to JDK 8 as minimum JDK level for Graal.
+* Added support for stack introspection
 * ...
 
 ### Truffle
+* Support for collecting stack traces and for accessing the current frame in slow paths
+* Renamed CallNode to DirectCallNode.
+* Renamed TruffleRuntime#createCallNode to TruffleRuntime#createDirectCallNode.
+* Added IndirectCallNode for calls with a changing CallTarget. 
+* Added TruffleRuntime#createIndirectCallNode to create an IndirectCallNode.
+* DirectCallNode#inline was renamed to DirectCallNode#forceInlining().
 * ...
 
 ## Version 0.2
@@ -20,7 +30,8 @@
 * New (tested) invariant that equality comparisons for `JavaType`/`JavaMethod`/`JavaField` values use `.equals()` instead of `==`.
 * Made graph caching compilation-local.
 * Added AllocSpy tool for analyzing allocation in Graal using the [Java Allocation Instrumenter](https://code.google.com/p/java-allocation-instrumenter/).
-* Initial support for memory arithmetic operations on x86
+* Initial support for memory arithmetic operations on x86.
+* Expanded Debug logging/dumping API to avoid allocation when this Debug facilities are not enabled.
 
 ### Truffle
 * New API `TruffleRuntime#createCallNode` to create call nodes and to give the runtime system control over its implementation.
--- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,12 +34,12 @@
  * with the most likely path that was left out during this process. The process iteratively
  * continues until all blocks are scheduled. Additionally, it is guaranteed that all blocks of a
  * loop are scheduled before any block following the loop is scheduled.
- * 
+ *
  * The machine code generator order includes reordering of loop headers such that the backward jump
  * is a conditional jump if there is only one loop end block. Additionally, the target of loop
  * backward jumps are always marked as aligned. Aligning the target of conditional jumps does not
  * bring a measurable benefit and is therefore avoided to keep the code size small.
- * 
+ *
  * The linear scan register allocator order has an additional mechanism that prevents merge nodes
  * from being scheduled if there is at least one highly likely predecessor still unscheduled. This
  * increases the probability that the merge node and the corresponding predecessor are more closely
@@ -63,7 +63,7 @@
 
     /**
      * Computes the block order used for the linear scan register allocator.
-     * 
+     *
      * @return sorted list of blocks
      */
     public static <T extends AbstractBlock<T>> List<T> computeLinearScanOrder(int blockCount, T startBlock, BlocksToDoubles blockProbabilities) {
@@ -77,7 +77,7 @@
 
     /**
      * Computes the block order used for code emission.
-     * 
+     *
      * @return sorted list of blocks
      */
     public static <T extends AbstractBlock<T>> List<T> computeCodeEmittingOrder(int blockCount, T startBlock, BlocksToDoubles blockProbabilities) {
@@ -151,7 +151,6 @@
     /**
      * Add a linear path to the code emission order greedily following the most likely successor.
      */
-    @SuppressWarnings("unchecked")
     private static <T extends AbstractBlock<T>> void addPathToCodeEmittingOrder(T initialBlock, List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks, BlocksToDoubles blockProbabilities) {
         T block = initialBlock;
         while (block != null) {
@@ -166,17 +165,17 @@
                 addBlock(block, order);
             }
 
-            Loop loop = block.getLoop();
+            Loop<T> loop = block.getLoop();
             if (block.isLoopEnd() && skipLoopHeader(loop.header)) {
 
                 // This is the only loop end of a skipped loop header.
                 // Add the header immediately afterwards.
-                addBlock((T) loop.header, order);
+                addBlock(loop.header, order);
 
                 // Make sure the loop successors of the loop header are aligned
                 // as they are the target
                 // of the backward jump.
-                for (Block successor : loop.header.getSuccessors()) {
+                for (T successor : loop.header.getSuccessors()) {
                     if (successor.getLoopDepth() == block.getLoopDepth()) {
                         successor.setAlign(true);
                     }
@@ -230,8 +229,8 @@
      * Skip the loop header block if the loop consists of more than one block and it has only a
      * single loop end block.
      */
-    private static boolean skipLoopHeader(AbstractBlock<?> block) {
-        return (block.isLoopHeader() && !block.isLoopEnd() && block.getLoop().loopBegin().loopEnds().count() == 1);
+    private static <T extends AbstractBlock<T>> boolean skipLoopHeader(AbstractBlock<T> block) {
+        return (block.isLoopHeader() && !block.isLoopEnd() && block.getLoop().numBackedges() == 1);
     }
 
     /**
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -79,9 +79,8 @@
     int getMinimumOutgoingSize();
 
     /**
-     * Determines if a {@link DataPatch} should be created for a given
-     * {@linkplain Constant#getPrimitiveAnnotation() annotated} primitive constant that part of a
-     * {@link CompilationResult}. A data patch is always created for an object constant.
+     * Determines if a {@link DataPatch} should be created for a given primitive constant that is
+     * part of a {@link CompilationResult}. A data patch is always created for an object constant.
      */
     boolean needsDataPatch(Constant constant);
 
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 import java.nio.*;
 import java.util.*;
 
-import com.oracle.graal.api.code.CodeUtil.*;
+import com.oracle.graal.api.code.CodeUtil.RefMapFormatter;
 import com.oracle.graal.api.meta.*;
 
 /**
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/InstalledCode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/InstalledCode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,18 +59,8 @@
     void invalidate();
 
     /**
-     * Executes the installed code with three object arguments.
-     * 
-     * @param arg1 the first argument
-     * @param arg2 the second argument
-     * @param arg3 the third argument
-     * @return the value returned by the executed code
-     */
-    Object execute(Object arg1, Object arg2, Object arg3) throws InvalidInstalledCodeException;
-
-    /**
      * Executes the installed code with a variable number of arguments.
-     * 
+     *
      * @param args the array of object arguments
      * @return the value returned by the executed code
      */
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/NativeFunctionInterface.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/NativeFunctionInterface.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
     /**
      * Resolves and returns a handle to an open native library. This method will open the library
      * only if it is not already open.
-     * 
+     *
      * @param libPath the absolute path to the library
      * @return the resolved library handle
      * @throws UnsatisfiedLinkError if the library could not be found or opened
@@ -48,7 +48,7 @@
 
     /**
      * Resolves the function pointer {@code NativeFunctionPointer} of a native function.
-     * 
+     *
      * @param libraries the ordered list of libraries to search for the function
      * @param name the name of the function to be resolved
      * @return a pointer to the native function
@@ -60,7 +60,7 @@
      * Resolves a function name to a {@linkplain NativeFunctionHandle handle} that can be called
      * with a given signature. The signature contains the types of the arguments that will be passed
      * to the handle when it is {@linkplain NativeFunctionHandle#call(Object...) called}.
-     * 
+     *
      * @param library the handle to a resolved library
      * @param name the name of the function to be resolved
      * @param returnType the type of the return value
@@ -68,26 +68,26 @@
      * @return the function handle of the native function
      * @throws UnsatisfiedLinkError if the function handle could not be resolved
      */
-    NativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, String name, Class returnType, Class... argumentTypes);
+    NativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, String name, Class<?> returnType, Class<?>... argumentTypes);
 
     /**
      * Resolves a function pointer to a {@linkplain NativeFunctionHandle handle} that can be called
      * with a given signature. The signature contains the types of the arguments that will be passed
      * to the handle when it is {@linkplain NativeFunctionHandle#call(Object...) called}.
-     * 
+     *
      * @param functionPointer a function pointer
      * @param returnType the type of the return value
      * @param argumentTypes the types of the arguments
      * @return the function handle of the native function
      * @throws UnsatisfiedLinkError the function handle could not be created
      */
-    NativeFunctionHandle getFunctionHandle(NativeFunctionPointer functionPointer, Class returnType, Class... argumentTypes);
+    NativeFunctionHandle getFunctionHandle(NativeFunctionPointer functionPointer, Class<?> returnType, Class<?>... argumentTypes);
 
     /**
      * Resolves a function name to a {@linkplain NativeFunctionHandle handle} that can be called
      * with a given signature. The signature contains the types of the arguments that will be passed
      * to the handle when it is {@linkplain NativeFunctionHandle#call(Object...) called}.
-     * 
+     *
      * @param libraries the ordered list of libraries to search for the function
      * @param name the name of the function to be resolved
      * @param returnType the type of the return value
@@ -95,13 +95,13 @@
      * @return the function handle of the native function
      * @throws UnsatisfiedLinkError if the function handle could not be created
      */
-    NativeFunctionHandle getFunctionHandle(NativeLibraryHandle[] libraries, String name, Class returnType, Class... argumentTypes);
+    NativeFunctionHandle getFunctionHandle(NativeLibraryHandle[] libraries, String name, Class<?> returnType, Class<?>... argumentTypes);
 
     /**
      * Resolves a function name to a {@linkplain NativeFunctionHandle handle} that can be called
      * with a given signature. The signature contains the types of the arguments that will be passed
      * to the handle when it is {@linkplain NativeFunctionHandle#call(Object...) called}.
-     * 
+     *
      * @param name the name of the function to be resolved
      * @param returnType the type of the return value
      * @param argumentTypes the types of the arguments
@@ -110,11 +110,11 @@
      *             {@linkplain #isDefaultLibrarySearchSupported() supported} or if the function
      *             could not be resolved
      */
-    NativeFunctionHandle getFunctionHandle(String name, Class returnType, Class... argumentTypes);
+    NativeFunctionHandle getFunctionHandle(String name, Class<?> returnType, Class<?>... argumentTypes);
 
     /**
      * Creates a {@link NativeFunctionPointer} from a raw value.
-     * 
+     *
      * @param rawValue raw function pointer
      * @return {@code NativeFunctionPointer} for {@code rawValue}
      */
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,13 +37,20 @@
     Register getReturnRegister(Kind kind);
 
     /**
+     * Gets the maximum allowed size of the frame.
+     */
+    default int getMaximumFrameSize() {
+        return Integer.MAX_VALUE;
+    }
+
+    /**
      * Gets the register to which {@link Register#Frame} and {@link Register#CallerFrame} are bound.
      */
     Register getFrameRegister();
 
     /**
      * Gets the calling convention describing how arguments are passed.
-     * 
+     *
      * @param type the type of calling convention being requested
      * @param returnType the return type (can be null for methods returning {@code void})
      * @param parameterTypes the types of the arguments of the call
@@ -55,7 +62,7 @@
     /**
      * Gets the ordered set of registers that are can be used to pass parameters according to a
      * given calling convention.
-     * 
+     *
      * @param type the type of calling convention
      * @param kind specifies what kind of registers is being requested
      * @return the ordered set of registers that may be used to pass parameters in a call conforming
@@ -81,7 +88,7 @@
 
     /**
      * Gets the layout of the callee save area of this register configuration.
-     * 
+     *
      * @return {@code null} if there is no callee save area
      */
     CalleeSaveLayout getCalleeSaveLayout();
@@ -89,7 +96,7 @@
     /**
      * Gets a map from register {@linkplain Register#number numbers} to register
      * {@linkplain RegisterAttributes attributes} for this register configuration.
-     * 
+     *
      * @return an array where an element at index i holds the attributes of the register whose
      *         number is i
      */
@@ -97,7 +104,7 @@
 
     /**
      * Gets the register corresponding to a runtime-defined role.
-     * 
+     *
      * @param id the identifier of a runtime-defined register role
      * @return the register playing the role specified by {@code id}
      */
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/SpeculationLog.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/SpeculationLog.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,7 @@
  * Manages a list of unique deoptimization reasons.
  * 
  */
-public final class SpeculationLog {
+public abstract class SpeculationLog {
     private volatile Object lastFailed;
     private volatile Collection<Object> speculations;
     private Set<Object> failedSpeculations;
@@ -54,7 +54,7 @@
         return true;
     }
 
-    public Constant speculate(Object reason) {
+    protected void addSpeculation(Object reason) {
         assert maySpeculate(reason);
         if (speculations == null) {
             synchronized (this) {
@@ -64,6 +64,7 @@
             }
         }
         speculations.add(reason);
-        return Constant.forObject(reason);
     }
+
+    public abstract Constant speculate(Object reason);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/stack/InspectedFrame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.code.stack;
+
+import com.oracle.graal.api.meta.*;
+
+public interface InspectedFrame {
+
+    /**
+     * Returns the value of the local at the given index. Currently only works for object values.
+     * This value is a copy iff {@link #isVirtual(int)} is true.
+     */
+    Object getLocal(int index);
+
+    /**
+     * Returns whether the local at the given index is a virtual object, and therefore the object
+     * returned by {@link #getLocal(int)} is a copy.
+     */
+    boolean isVirtual(int index);
+
+    /**
+     * Returns true if the stack frame is a compiled stack frame and there are virtual objects
+     * anywhere in the current state of the compiled method. This can return true even if
+     * {@link #isVirtual(int)} return false for all locals.
+     */
+    boolean hasVirtualObjects();
+
+    /**
+     * This method will materialize all virtual objects, deoptimize the stack frame and make sure
+     * that subsequent execution of the deoptimized frame uses the materialized values.
+     */
+    void materializeVirtualObjects(boolean invalidateCode);
+
+    /**
+     * @return the current bytecode index
+     */
+    int getBytecodeIndex();
+
+    /**
+     * @return the current method
+     */
+    ResolvedJavaMethod getMethod();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/stack/StackIntrospection.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.code.stack;
+
+import com.oracle.graal.api.meta.*;
+
+public interface StackIntrospection {
+
+    /**
+     * Accesses the current stack, returning a collection of {@long InspectedFrame}s that can be
+     * used to inspect the stack frames' contents.
+     *
+     * @param initialMethods if this is non-{@code null}, then the stack trace will start at these
+     *            methods
+     * @param matchingMethods if this is non-{@code null}, then only matching stack frames are
+     *            returned
+     */
+    Iterable<InspectedFrame> getStackTrace(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip);
+}
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/FieldUniverse.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/FieldUniverse.java	Wed Apr 16 14:02:52 2014 +0200
@@ -35,7 +35,7 @@
     public final Map<Field, ResolvedJavaField> fields = new HashMap<>();
 
     public FieldUniverse() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             for (Field f : c.getDeclaredFields()) {
                 ResolvedJavaField field = metaAccess.lookupJavaField(f);
                 fields.put(f, field);
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/MethodUniverse.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/MethodUniverse.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,12 +36,12 @@
     public final Map<Constructor<?>, ResolvedJavaMethod> constructors = new HashMap<>();
 
     public MethodUniverse() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             for (Method m : c.getDeclaredMethods()) {
                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
                 methods.put(m, method);
             }
-            for (Constructor m : c.getDeclaredConstructors()) {
+            for (Constructor<?> m : c.getDeclaredConstructors()) {
                 constructors.put(m, metaAccess.lookupJavaConstructor(m));
             }
         }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/NameAndSignature.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/NameAndSignature.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,8 +34,8 @@
     public static final MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
 
     final String name;
-    final Class returnType;
-    final Class[] parameterTypes;
+    final Class<?> returnType;
+    final Class<?>[] parameterTypes;
 
     public NameAndSignature(Method m) {
         this.name = m.getName();
@@ -61,7 +61,7 @@
     public String toString() {
         StringBuilder sb = new StringBuilder(name + "(");
         String sep = "";
-        for (Class p : parameterTypes) {
+        for (Class<?> p : parameterTypes) {
             sb.append(sep);
             sep = ", ";
             sb.append(p.getName());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestConstantReflectionProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.meta.test;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.*;
+
+import org.junit.*;
+
+import com.oracle.graal.api.meta.*;
+
+/**
+ * Tests for {@link ConstantReflectionProvider}. It assumes an implementation of the interface that
+ * actually returns non-null results for access operations that are possible, i.e., the tests will
+ * fail for an implementation that spuriously returns null (which is allowed by the specification).
+ */
+public class TestConstantReflectionProvider extends TypeUniverse {
+
+    @Test
+    public void constantEqualsTest() {
+        for (Constant c1 : constants) {
+            for (Constant c2 : constants) {
+                // test symmetry
+                assertEquals(constantReflection.constantEquals(c1, c2), constantReflection.constantEquals(c2, c1));
+                if (c1.getKind() != Kind.Object && c2.getKind() != Kind.Object) {
+                    assertEquals(c1.equals(c2), constantReflection.constantEquals(c2, c1));
+                }
+            }
+        }
+    }
+
+    @Test
+    public void readArrayLengthTest() {
+        for (Constant c : constants) {
+            Integer actual = constantReflection.readArrayLength(c);
+            if (c.getKind() != Kind.Object || c.isNull() || !snippetReflection.asObject(c).getClass().isArray()) {
+                assertNull(actual);
+            } else {
+                assertNotNull(actual);
+                int actualInt = actual;
+                assertEquals(Array.getLength(snippetReflection.asObject(c)), actualInt);
+            }
+        }
+    }
+
+    @Test
+    public void boxTest() {
+        for (Constant c : constants) {
+            Constant boxed = constantReflection.boxPrimitive(c);
+            if (c.getKind().isPrimitive()) {
+                assertTrue(boxed.getKind().isObject());
+                assertFalse(boxed.isNull());
+            }
+        }
+
+        assertEquals(Long.valueOf(42), snippetReflection.asObject(constantReflection.boxPrimitive(Constant.forLong(42))));
+        assertEquals(Integer.valueOf(666), snippetReflection.asObject(constantReflection.boxPrimitive(Constant.forInt(666))));
+        assertEquals(Byte.valueOf((byte) 123), snippetReflection.asObject(constantReflection.boxPrimitive(Constant.forByte((byte) 123))));
+        assertSame(Boolean.TRUE, snippetReflection.asObject(constantReflection.boxPrimitive(Constant.forBoolean(true))));
+
+        assertNull(constantReflection.boxPrimitive(Constant.NULL_OBJECT));
+        assertNull(constantReflection.boxPrimitive(snippetReflection.forObject("abc")));
+    }
+
+    @Test
+    public void unboxTest() {
+        for (Constant c : constants) {
+            Constant unboxed = constantReflection.unboxPrimitive(c);
+            if (unboxed != null) {
+                assertFalse(unboxed.getKind().isObject());
+            }
+        }
+
+        assertEquals(Constant.forLong(42), constantReflection.unboxPrimitive(snippetReflection.forObject(Long.valueOf(42))));
+        assertEquals(Constant.forInt(666), constantReflection.unboxPrimitive(snippetReflection.forObject(Integer.valueOf(666))));
+        assertEquals(Constant.forByte((byte) 123), constantReflection.unboxPrimitive(snippetReflection.forObject(Byte.valueOf((byte) 123))));
+        assertSame(Constant.forBoolean(true), constantReflection.unboxPrimitive(snippetReflection.forObject(Boolean.TRUE)));
+
+        assertNull(constantReflection.unboxPrimitive(Constant.NULL_OBJECT));
+        assertNull(constantReflection.unboxPrimitive(snippetReflection.forObject("abc")));
+    }
+
+    @Test
+    public void testAsJavaType() {
+        for (Constant c : constants) {
+            ResolvedJavaType type = constantReflection.asJavaType(c);
+
+            Object o = snippetReflection.asBoxedValue(c);
+            if (o instanceof Class) {
+                assertEquals(metaAccess.lookupJavaType((Class<?>) o), type);
+            } else {
+                assertNull(type);
+            }
+        }
+
+    }
+}
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaField.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaField.java	Wed Apr 16 14:02:52 2014 +0200
@@ -68,7 +68,7 @@
     @Test
     public void getDeclaringClassTest() {
         for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
-            Class expected = e.getKey().getDeclaringClass();
+            Class<?> expected = e.getKey().getDeclaringClass();
             ResolvedJavaType actual = e.getValue().getDeclaringClass();
             assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
         }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaMethod.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaMethod.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,7 +48,7 @@
     @Test
     public void getDeclaringClassTest() {
         for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
-            Class expected = e.getKey().getDeclaringClass();
+            Class<?> expected = e.getKey().getDeclaringClass();
             ResolvedJavaType actual = e.getValue().getDeclaringClass();
             assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
         }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaType.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestJavaType.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
 
     @Test
     public void getKindTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             JavaType type = metaAccess.lookupJavaType(c);
             Kind expected = Kind.fromJavaClass(c);
             Kind actual = type.getKind();
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
 
     @Test
     public void lookupJavaTypeTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             assertNotNull(type);
             assertEquals(c.getModifiers(), type.getModifiers());
@@ -51,7 +51,7 @@
 
     @Test
     public void lookupJavaMethodTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             for (Method reflect : c.getDeclaredMethods()) {
                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(reflect);
                 assertNotNull(method);
@@ -65,7 +65,7 @@
 
     @Test
     public void lookupJavaFieldTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             for (Field reflect : c.getDeclaredFields()) {
                 ResolvedJavaField field = metaAccess.lookupJavaField(reflect);
                 assertNotNull(field);
@@ -81,7 +81,7 @@
     public void lookupJavaTypeConstantTest() {
         for (Constant c : constants) {
             if (c.getKind() == Kind.Object && !c.isNull()) {
-                Object o = c.asObject();
+                Object o = snippetReflection.asObject(c);
                 ResolvedJavaType type = metaAccess.lookupJavaType(c);
                 assertNotNull(type);
                 assertTrue(type.equals(metaAccess.lookupJavaType(o.getClass())));
@@ -90,31 +90,4 @@
             }
         }
     }
-
-    @Test
-    public void constantEqualsTest() {
-        for (Constant c1 : constants) {
-            for (Constant c2 : constants) {
-                // test symmetry
-                assertEquals(constantReflection.constantEquals(c1, c2), constantReflection.constantEquals(c2, c1));
-                if (c1.getKind() != Kind.Object && c2.getKind() != Kind.Object) {
-                    assertEquals(c1.equals(c2), constantReflection.constantEquals(c2, c1));
-                }
-            }
-        }
-    }
-
-    @Test
-    public void lookupArrayLengthTest() {
-        for (Constant c : constants) {
-            Integer actual = constantReflection.lookupArrayLength(c);
-            if (c.getKind() != Kind.Object || c.isNull() || !c.asObject().getClass().isArray()) {
-                assertNull(actual);
-            } else {
-                assertNotNull(actual);
-                int actualInt = actual;
-                assertEquals(Array.getLength(c.asObject()), actualInt);
-            }
-        }
-    }
 }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaField.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaField.java	Wed Apr 16 14:02:52 2014 +0200
@@ -78,7 +78,7 @@
             if (isStatic(field.getModifiers())) {
                 try {
                     Object expected = field.get(null);
-                    Object actual = e.getValue().readConstantValue(null).asBoxedValue();
+                    Object actual = snippetReflection.asBoxedValue(e.getValue().readConstantValue(null));
                     assertEquals(expected, actual);
                 } catch (IllegalArgumentException | IllegalAccessException e1) {
                 }
@@ -86,7 +86,7 @@
                 try {
                     Object receiver = field.getDeclaringClass().newInstance();
                     Object expected = field.get(receiver);
-                    Object actual = e.getValue().readConstantValue(Constant.forObject(receiver)).asBoxedValue();
+                    Object actual = snippetReflection.asBoxedValue(e.getValue().readConstantValue(snippetReflection.forObject(receiver)));
                     assertEquals(expected, actual);
                 } catch (InstantiationException | IllegalArgumentException | IllegalAccessException e1) {
                 }
@@ -95,16 +95,16 @@
 
         ResolvedJavaField field = metaAccess.lookupJavaField(getClass().getDeclaredField("stringField"));
         for (Object receiver : new Object[]{this, null, new String()}) {
-            Constant value = field.readConstantValue(Constant.forObject(receiver));
+            Constant value = field.readConstantValue(snippetReflection.forObject(receiver));
             assertNull(value);
         }
 
         ResolvedJavaField constField = metaAccess.lookupJavaField(getClass().getDeclaredField("constantStringField"));
         for (Object receiver : new Object[]{this, null, new String()}) {
-            Constant value = constField.readConstantValue(Constant.forObject(receiver));
+            Constant value = constField.readConstantValue(snippetReflection.forObject(receiver));
             if (value != null) {
                 Object expected = "constantField";
-                assertTrue(value.asObject() == expected);
+                assertTrue(snippetReflection.asObject(value) == expected);
             }
         }
     }
@@ -117,7 +117,7 @@
             if (isStatic(field.getModifiers())) {
                 try {
                     Object expected = field.get(null);
-                    Object actual = e.getValue().readValue(null).asBoxedValue();
+                    Object actual = snippetReflection.asBoxedValue(e.getValue().readValue(null));
                     assertEquals(expected, actual);
                 } catch (IllegalArgumentException | IllegalAccessException e1) {
                 }
@@ -131,7 +131,7 @@
             ResolvedJavaField rf = metaAccess.lookupJavaField(f);
             Object receiver = isStatic(f.getModifiers()) ? null : testString;
             Object expected = f.get(receiver);
-            Object actual = rf.readValue(receiver == null ? null : Constant.forObject(receiver)).asBoxedValue();
+            Object actual = snippetReflection.asBoxedValue(rf.readValue(receiver == null ? null : snippetReflection.forObject(receiver)));
             assertEquals(expected, actual);
         }
     }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java	Wed Apr 16 14:02:52 2014 +0200
@@ -131,16 +131,18 @@
     public void canBeStaticallyBoundTest() {
         for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
             ResolvedJavaMethod m = e.getValue();
-            assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey().getModifiers()));
+            assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey()));
         }
         for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) {
             ResolvedJavaMethod m = e.getValue();
-            assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey().getModifiers()));
+            assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey()));
         }
     }
 
-    private static boolean canBeStaticallyBound(int modifiers) {
-        return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers)) && !Modifier.isAbstract(modifiers);
+    private static boolean canBeStaticallyBound(Member method) {
+        int modifiers = method.getModifiers();
+        return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(method.getDeclaringClass().getModifiers())) &&
+                        !Modifier.isAbstract(modifiers);
     }
 
     private static String methodWithExceptionHandlers(String p1, Object o2) {
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.api.meta.test;
 
-import static java.lang.Integer.*;
 import static java.lang.reflect.Modifier.*;
 import static org.junit.Assert.*;
 
@@ -40,7 +39,6 @@
 /**
  * Tests for {@link ResolvedJavaType}.
  */
-@SuppressWarnings("unused")
 public class TestResolvedJavaType extends TypeUniverse {
 
     public TestResolvedJavaType() {
@@ -48,7 +46,7 @@
 
     @Test
     public void findInstanceFieldWithOffsetTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             Set<Field> reflectionFields = getInstanceFields(c, true);
             for (Field f : reflectionFields) {
@@ -64,7 +62,7 @@
 
     @Test
     public void isInterfaceTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             boolean expected = c.isInterface();
             boolean actual = type.isInterface();
@@ -74,7 +72,7 @@
 
     @Test
     public void isInstanceClassTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             boolean expected = !c.isArray() && !c.isPrimitive() && !c.isInterface();
             boolean actual = type.isInstanceClass();
@@ -84,7 +82,7 @@
 
     @Test
     public void isArrayTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             boolean expected = c.isArray();
             boolean actual = type.isArray();
@@ -94,7 +92,7 @@
 
     @Test
     public void getModifiersTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             int expected = c.getModifiers();
             int actual = type.getModifiers();
@@ -104,7 +102,7 @@
 
     @Test
     public void isAssignableFromTest() {
-        Class[] all = classes.toArray(new Class[classes.size()]);
+        Class<?>[] all = classes.toArray(new Class[classes.size()]);
         for (int i = 0; i < all.length; i++) {
             Class<?> c1 = all[i];
             for (int j = i; j < all.length; j++) {
@@ -125,7 +123,7 @@
     public void isInstanceTest() {
         for (Constant c : constants) {
             if (c.getKind() == Kind.Object && !c.isNull()) {
-                Object o = c.asObject();
+                Object o = snippetReflection.asObject(c);
                 Class<? extends Object> cls = o.getClass();
                 while (cls != null) {
                     ResolvedJavaType type = metaAccess.lookupJavaType(cls);
@@ -138,7 +136,7 @@
         }
     }
 
-    private static Class asExactClass(Class c) {
+    private static Class<?> asExactClass(Class<?> c) {
         if (c.isArray()) {
             if (asExactClass(c.getComponentType()) != null) {
                 return c;
@@ -153,10 +151,10 @@
 
     @Test
     public void asExactTypeTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             ResolvedJavaType exactType = type.asExactType();
-            Class expected = asExactClass(c);
+            Class<?> expected = asExactClass(c);
             if (expected == null) {
                 assertTrue("exact(" + c.getName() + ") != null", exactType == null);
             } else {
@@ -168,9 +166,9 @@
 
     @Test
     public void getSuperclassTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
-            Class expected = c.getSuperclass();
+            Class<?> expected = c.getSuperclass();
             ResolvedJavaType actual = type.getSuperclass();
             if (expected == null) {
                 assertTrue(actual == null);
@@ -183,9 +181,9 @@
 
     @Test
     public void getInterfacesTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
-            Class[] expected = c.getInterfaces();
+            Class<?>[] expected = c.getInterfaces();
             ResolvedJavaType[] actual = type.getInterfaces();
             assertEquals(expected.length, actual.length);
             for (int i = 0; i < expected.length; i++) {
@@ -194,10 +192,10 @@
         }
     }
 
-    public Class getSupertype(Class c) {
+    public Class<?> getSupertype(Class<?> c) {
         assert !c.isPrimitive();
         if (c.isArray()) {
-            Class componentType = c.getComponentType();
+            Class<?> componentType = c.getComponentType();
             if (componentType.isPrimitive() || componentType == Object.class) {
                 return Object.class;
             }
@@ -209,7 +207,7 @@
         return c.getSuperclass();
     }
 
-    public Class findLeastCommonAncestor(Class<?> c1Initial, Class<?> c2Initial) {
+    public Class<?> findLeastCommonAncestor(Class<?> c1Initial, Class<?> c2Initial) {
         if (c1Initial.isPrimitive() || c2Initial.isPrimitive()) {
             return null;
         } else {
@@ -230,14 +228,14 @@
 
     @Test
     public void findLeastCommonAncestorTest() {
-        Class[] all = classes.toArray(new Class[classes.size()]);
+        Class<?>[] all = classes.toArray(new Class[classes.size()]);
         for (int i = 0; i < all.length; i++) {
             Class<?> c1 = all[i];
             for (int j = i; j < all.length; j++) {
                 Class<?> c2 = all[j];
                 ResolvedJavaType t1 = metaAccess.lookupJavaType(c1);
                 ResolvedJavaType t2 = metaAccess.lookupJavaType(c2);
-                Class expected = findLeastCommonAncestor(c1, c2);
+                Class<?> expected = findLeastCommonAncestor(c1, c2);
                 ResolvedJavaType actual = t1.findLeastCommonAncestor(t2);
                 if (expected == null) {
                     assertTrue(actual == null);
@@ -270,7 +268,7 @@
     abstract static class Abstract4 extends Concrete3 {
     }
 
-    void checkConcreteSubtype(ResolvedJavaType type, Class expected) {
+    void checkConcreteSubtype(ResolvedJavaType type, Class<?> expected) {
         ResolvedJavaType subtype = type.findUniqueConcreteSubtype();
         if (subtype == null) {
             // findUniqueConcreteSubtype() is conservative
@@ -325,9 +323,9 @@
 
     @Test
     public void getComponentTypeTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
-            Class expected = c.getComponentType();
+            Class<?> expected = c.getComponentType();
             ResolvedJavaType actual = type.getComponentType();
             if (expected == null) {
                 assertNull(actual);
@@ -339,10 +337,10 @@
 
     @Test
     public void getArrayClassTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             if (c != void.class) {
                 ResolvedJavaType type = metaAccess.lookupJavaType(c);
-                Class expected = getArrayClass(c);
+                Class<?> expected = getArrayClass(c);
                 ResolvedJavaType actual = type.getArrayClass();
                 assertTrue(actual.equals(metaAccess.lookupJavaType(expected)));
             }
@@ -383,14 +381,14 @@
         return false;
     }
 
-    static final Map<Class, VTable> vtables = new HashMap<>();
+    static final Map<Class<?>, VTable> vtables = new HashMap<>();
 
     static class VTable {
 
         final Map<NameAndSignature, Method> methods = new HashMap<>();
     }
 
-    static synchronized VTable getVTable(Class c) {
+    static synchronized VTable getVTable(Class<?> c) {
         VTable vtable = vtables.get(c);
         if (vtable == null) {
             vtable = new VTable();
@@ -413,7 +411,7 @@
         return vtable;
     }
 
-    static Set<Method> findDeclarations(Method impl, Class c) {
+    static Set<Method> findDeclarations(Method impl, Class<?> c) {
         Set<Method> declarations = new HashSet<>();
         NameAndSignature implSig = new NameAndSignature(impl);
         if (c != null) {
@@ -426,7 +424,7 @@
             if (!c.isInterface()) {
                 declarations.addAll(findDeclarations(impl, c.getSuperclass()));
             }
-            for (Class i : c.getInterfaces()) {
+            for (Class<?> i : c.getInterfaces()) {
                 declarations.addAll(findDeclarations(impl, i));
             }
         }
@@ -440,7 +438,7 @@
 
     @Test
     public void resolveMethodTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             if (c.isInterface() || c.isPrimitive()) {
                 ResolvedJavaType type = metaAccess.lookupJavaType(c);
                 for (Method m : c.getDeclaredMethods()) {
@@ -480,7 +478,7 @@
         assertEquals(thisMethod, ucm);
     }
 
-    public static Set<Field> getInstanceFields(Class c, boolean includeSuperclasses) {
+    public static Set<Field> getInstanceFields(Class<?> c, boolean includeSuperclasses) {
         if (c.isArray() || c.isPrimitive() || c.isInterface()) {
             return Collections.emptySet();
         }
@@ -531,7 +529,7 @@
 
     @Test
     public void getInstanceFieldsTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             for (boolean includeSuperclasses : new boolean[]{true, false}) {
                 Set<Field> expected = getInstanceFields(c, includeSuperclasses);
@@ -554,7 +552,7 @@
 
     @Test
     public void getDeclaredMethodsTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             Method[] raw = c.getDeclaredMethods();
             Set<ResolvedJavaMethod> expected = new HashSet<>();
@@ -597,7 +595,7 @@
 
     @Test
     public void getAnnotationTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             for (Annotation a : c.getAnnotations()) {
                 assertEquals(a, type.getAnnotation(a.annotationType()));
@@ -607,11 +605,11 @@
 
     @Test
     public void memberClassesTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             assertEquals(c.isLocalClass(), type.isLocal());
             assertEquals(c.isMemberClass(), type.isMember());
-            Class enclc = c.getEnclosingClass();
+            Class<?> enclc = c.getEnclosingClass();
             ResolvedJavaType enclt = type.getEnclosingType();
             assertFalse(enclc == null ^ enclt == null);
             if (enclc != null) {
@@ -622,7 +620,7 @@
 
     @Test
     public void classFilePathTest() {
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             ResolvedJavaType type = metaAccess.lookupJavaType(c);
             URL path = type.getClassFilePath();
             if (type.isPrimitive() || type.isArray()) {
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,6 +32,7 @@
 import sun.misc.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.runtime.*;
@@ -46,6 +47,7 @@
 
     public final MetaAccessProvider metaAccess;
     public final ConstantReflectionProvider constantReflection;
+    public final SnippetReflectionProvider snippetReflection;
     public final Collection<Class<?>> classes = new HashSet<>();
     public final Map<Class<?>, Class<?>> arrayClasses = new HashMap<>();
     public final List<Constant> constants = new ArrayList<>();
@@ -54,6 +56,7 @@
         Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
         metaAccess = providers.getMetaAccess();
         constantReflection = providers.getConstantReflection();
+        snippetReflection = Graal.getRequiredCapability(SnippetReflectionProvider.class);
         Unsafe theUnsafe = null;
         try {
             theUnsafe = Unsafe.getUnsafe();
@@ -68,10 +71,10 @@
         }
         unsafe = theUnsafe;
 
-        Class[] initialClasses = {void.class, boolean.class, byte.class, short.class, char.class, int.class, float.class, long.class, double.class, Object.class, Class.class, ClassLoader.class,
+        Class<?>[] initialClasses = {void.class, boolean.class, byte.class, short.class, char.class, int.class, float.class, long.class, double.class, Object.class, Class.class, ClassLoader.class,
                         String.class, Serializable.class, Cloneable.class, Test.class, TestMetaAccessProvider.class, List.class, Collection.class, Map.class, Queue.class, HashMap.class,
                         LinkedHashMap.class, IdentityHashMap.class, AbstractCollection.class, AbstractList.class, ArrayList.class};
-        for (Class c : initialClasses) {
+        for (Class<?> c : initialClasses) {
             addClass(c);
         }
         for (Field f : Constant.class.getDeclaredFields()) {
@@ -86,22 +89,24 @@
                 }
             }
         }
-        for (Class c : classes) {
+        for (Class<?> c : classes) {
             if (c != void.class && !c.isArray()) {
-                constants.add(Constant.forObject(Array.newInstance(c, 42)));
+                constants.add(snippetReflection.forObject(Array.newInstance(c, 42)));
             }
         }
-        constants.add(Constant.forObject(new ArrayList<>()));
-        constants.add(Constant.forObject(new IdentityHashMap<>()));
-        constants.add(Constant.forObject(new LinkedHashMap<>()));
-        constants.add(Constant.forObject(new TreeMap<>()));
-        constants.add(Constant.forObject(new ArrayDeque<>()));
-        constants.add(Constant.forObject(new LinkedList<>()));
-        constants.add(Constant.forObject("a string"));
-        constants.add(Constant.forObject(42));
+        constants.add(snippetReflection.forObject(new ArrayList<>()));
+        constants.add(snippetReflection.forObject(new IdentityHashMap<>()));
+        constants.add(snippetReflection.forObject(new LinkedHashMap<>()));
+        constants.add(snippetReflection.forObject(new TreeMap<>()));
+        constants.add(snippetReflection.forObject(new ArrayDeque<>()));
+        constants.add(snippetReflection.forObject(new LinkedList<>()));
+        constants.add(snippetReflection.forObject("a string"));
+        constants.add(snippetReflection.forObject(42));
+        constants.add(snippetReflection.forObject(String.class));
+        constants.add(snippetReflection.forObject(String[].class));
     }
 
-    public synchronized Class<?> getArrayClass(Class componentType) {
+    public synchronized Class<?> getArrayClass(Class<?> componentType) {
         Class<?> arrayClass = arrayClasses.get(componentType);
         if (arrayClass == null) {
             arrayClass = Array.newInstance(componentType, 0).getClass();
@@ -110,27 +115,27 @@
         return arrayClass;
     }
 
-    public static int dimensions(Class c) {
+    public static int dimensions(Class<?> c) {
         if (c.getComponentType() != null) {
             return 1 + dimensions(c.getComponentType());
         }
         return 0;
     }
 
-    private void addClass(Class c) {
+    private void addClass(Class<?> c) {
         if (classes.add(c)) {
             if (c.getSuperclass() != null) {
                 addClass(c.getSuperclass());
             }
-            for (Class sc : c.getInterfaces()) {
+            for (Class<?> sc : c.getInterfaces()) {
                 addClass(sc);
             }
-            for (Class dc : c.getDeclaredClasses()) {
+            for (Class<?> dc : c.getDeclaredClasses()) {
                 addClass(dc);
             }
             for (Method m : c.getDeclaredMethods()) {
                 addClass(m.getReturnType());
-                for (Class p : m.getParameterTypes()) {
+                for (Class<?> p : m.getParameterTypes()) {
                     addClass(p);
                 }
             }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractJavaProfile.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractJavaProfile.java	Wed Apr 16 14:02:52 2014 +0200
@@ -131,7 +131,7 @@
         if (!(obj instanceof AbstractJavaProfile)) {
             return false;
         }
-        AbstractJavaProfile that = (AbstractJavaProfile) obj;
+        AbstractJavaProfile<?, ?> that = (AbstractJavaProfile<?, ?>) obj;
         if (that.notRecordedProbability != notRecordedProbability) {
             return false;
         }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractProfiledItem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractProfiledItem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
  * A profiled type that has a probability. Profiled types are naturally sorted in descending order
  * of their probabilities.
  */
-public abstract class AbstractProfiledItem<T> implements Comparable<AbstractProfiledItem>, Serializable {
+public abstract class AbstractProfiledItem<T> implements Comparable<AbstractProfiledItem<?>>, Serializable {
 
     private static final long serialVersionUID = 7838575753661305744L;
 
@@ -56,7 +56,7 @@
     }
 
     @Override
-    public int compareTo(AbstractProfiledItem o) {
+    public int compareTo(AbstractProfiledItem<?> o) {
         if (getProbability() > o.getProbability()) {
             return -1;
         } else if (getProbability() < o.getProbability()) {
@@ -87,7 +87,7 @@
         if (getClass() != obj.getClass()) {
             return false;
         }
-        AbstractProfiledItem other = (AbstractProfiledItem) obj;
+        AbstractProfiledItem<?> other = (AbstractProfiledItem<?>) obj;
         if (Double.doubleToLongBits(probability) != Double.doubleToLongBits(other.probability)) {
             return false;
         }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,42 +22,40 @@
  */
 package com.oracle.graal.api.meta;
 
-import static com.oracle.graal.api.meta.MetaUtil.*;
-
 /**
  * Represents a constant (boxed) value, such as an integer, floating point number, or object
  * reference, within the compiler and across the compiler/runtime interface. Exports a set of
  * {@code Constant} instances that represent frequently used constant values, such as
  * {@link #NULL_OBJECT}.
  */
-public final class Constant extends Value {
+public abstract class Constant extends Value {
 
     private static final long serialVersionUID = -6355452536852663986L;
 
     private static final Constant[] INT_CONSTANT_CACHE = new Constant[100];
     static {
         for (int i = 0; i < INT_CONSTANT_CACHE.length; ++i) {
-            INT_CONSTANT_CACHE[i] = new Constant(Kind.Int, null, i);
+            INT_CONSTANT_CACHE[i] = new PrimitiveConstant(Kind.Int, i);
         }
     }
 
-    public static final Constant NULL_OBJECT = new Constant(Kind.Object, null, 0);
-    public static final Constant INT_MINUS_1 = new Constant(Kind.Int, null, -1);
+    public static final Constant NULL_OBJECT = new NullConstant();
+    public static final Constant INT_MINUS_1 = new PrimitiveConstant(Kind.Int, -1);
     public static final Constant INT_0 = forInt(0);
     public static final Constant INT_1 = forInt(1);
     public static final Constant INT_2 = forInt(2);
     public static final Constant INT_3 = forInt(3);
     public static final Constant INT_4 = forInt(4);
     public static final Constant INT_5 = forInt(5);
-    public static final Constant LONG_0 = new Constant(Kind.Long, null, 0L);
-    public static final Constant LONG_1 = new Constant(Kind.Long, null, 1L);
-    public static final Constant FLOAT_0 = new Constant(Kind.Float, null, Float.floatToRawIntBits(0.0F));
-    public static final Constant FLOAT_1 = new Constant(Kind.Float, null, Float.floatToRawIntBits(1.0F));
-    public static final Constant FLOAT_2 = new Constant(Kind.Float, null, Float.floatToRawIntBits(2.0F));
-    public static final Constant DOUBLE_0 = new Constant(Kind.Double, null, Double.doubleToRawLongBits(0.0D));
-    public static final Constant DOUBLE_1 = new Constant(Kind.Double, null, Double.doubleToRawLongBits(1.0D));
-    public static final Constant TRUE = new Constant(Kind.Boolean, null, 1L);
-    public static final Constant FALSE = new Constant(Kind.Boolean, null, 0L);
+    public static final Constant LONG_0 = new PrimitiveConstant(Kind.Long, 0L);
+    public static final Constant LONG_1 = new PrimitiveConstant(Kind.Long, 1L);
+    public static final Constant FLOAT_0 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(0.0F));
+    public static final Constant FLOAT_1 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(1.0F));
+    public static final Constant FLOAT_2 = new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(2.0F));
+    public static final Constant DOUBLE_0 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(0.0D));
+    public static final Constant DOUBLE_1 = new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(1.0D));
+    public static final Constant TRUE = new PrimitiveConstant(Kind.Boolean, 1L);
+    public static final Constant FALSE = new PrimitiveConstant(Kind.Boolean, 0L);
 
     static {
         assert FLOAT_0 != forFloat(-0.0F) : "Constant for 0.0f must be different from -0.0f";
@@ -65,56 +63,82 @@
         assert NULL_OBJECT.isNull();
     }
 
-    /**
-     * The boxed object value if {@code !kind.isObject()} otherwise the (possibly null)
-     * {@link #getPrimitiveAnnotation() annotation} for a primitive value.
-     */
-    private final Object object;
-
-    /**
-     * The boxed primitive value as a {@code long}. This is ignored iff {@code kind.isObject()}. For
-     * {@code float} and {@code double} values, this value is the result of
-     * {@link Float#floatToRawIntBits(float)} and {@link Double#doubleToRawLongBits(double)}
-     * respectively.
-     */
-    private final long primitive;
-
-    private Constant(Kind kind, Object object, long primitive) {
+    protected Constant(Kind kind) {
         super(kind);
-        this.object = object;
-        this.primitive = primitive;
-    }
-
-    /**
-     * Checks whether this constant is non-null.
-     * 
-     * @return {@code true} if this constant is a primitive, or an object constant that is not null
-     */
-    public boolean isNonNull() {
-        return getKind() != Kind.Object || object != null;
     }
 
     /**
      * Checks whether this constant is null.
-     * 
+     *
      * @return {@code true} if this constant is the null constant
      */
-    public boolean isNull() {
-        return getKind() == Kind.Object && object == null;
+    public abstract boolean isNull();
+
+    /**
+     * Checks whether this constant is non-null.
+     *
+     * @return {@code true} if this constant is a primitive, or an object constant that is not null
+     */
+    public final boolean isNonNull() {
+        return !isNull();
     }
 
     /**
      * Checks whether this constant is the default value for its kind (null, 0, 0.0, false).
-     * 
+     *
      * @return {@code true} if this constant is the default value for its kind
      */
-    public boolean isDefaultForKind() {
-        return object == null && primitive == 0;
-    }
+    public abstract boolean isDefaultForKind();
+
+    /**
+     * Returns the value of this constant as a boxed Java value.
+     *
+     * @return the value of this constant
+     */
+    public abstract Object asBoxedPrimitive();
+
+    /**
+     * Returns the primitive int value this constant represents. The constant must have a
+     * {@link Kind#getStackKind()} of {@link Kind#Int}.
+     *
+     * @return the constant value
+     */
+    public abstract int asInt();
+
+    /**
+     * Returns the primitive boolean value this constant represents. The constant must have kind
+     * {@link Kind#Boolean}.
+     *
+     * @return the constant value
+     */
+    public abstract boolean asBoolean();
 
-    public long getPrimitive() {
-        assert getKind().isPrimitive();
-        return primitive;
+    /**
+     * Returns the primitive long value this constant represents. The constant must have kind
+     * {@link Kind#Long}, a {@link Kind#getStackKind()} of {@link Kind#Int}.
+     *
+     * @return the constant value
+     */
+    public abstract long asLong();
+
+    /**
+     * Returns the primitive float value this constant represents. The constant must have kind
+     * {@link Kind#Float}.
+     *
+     * @return the constant value
+     */
+    public abstract float asFloat();
+
+    /**
+     * Returns the primitive double value this constant represents. The constant must have kind
+     * {@link Kind#Double}.
+     *
+     * @return the constant value
+     */
+    public abstract double asDouble();
+
+    public String toValueString() {
+        return getKind().format(asBoxedPrimitive());
     }
 
     @Override
@@ -122,165 +146,13 @@
         if (getKind() == Kind.Illegal) {
             return "illegal";
         } else {
-            String annotationSuffix = "";
-            Object primitiveAnnotation = getPrimitiveAnnotation();
-            if (getKind() != Kind.Object && primitiveAnnotation != null) {
-                try {
-                    annotationSuffix = "{" + primitiveAnnotation + "}";
-                } catch (Throwable t) {
-                    annotationSuffix = "{" + getSimpleName(primitiveAnnotation.getClass(), true) + "@" + System.identityHashCode(primitiveAnnotation) + "}";
-                }
-            }
-            return getKind().getJavaName() + "[" + getKind().format(asBoxedValue()) + (getKind() != Kind.Object ? "|0x" + Long.toHexString(primitive) : "") + "]" + annotationSuffix;
+            return getKind().getJavaName() + "[" + toValueString() + "]";
         }
     }
 
     /**
-     * Returns the value of this constant as a boxed Java value.
-     * 
-     * @return the value of this constant
-     */
-    public Object asBoxedValue() {
-        switch (getKind()) {
-            case Byte:
-                return (byte) asInt();
-            case Boolean:
-                return asInt() == 0 ? Boolean.FALSE : Boolean.TRUE;
-            case Short:
-                return (short) primitive;
-            case Char:
-                return (char) primitive;
-            case Int:
-                return (int) primitive;
-            case Long:
-                return primitive;
-            case Float:
-                return asFloat();
-            case Double:
-                return asDouble();
-            case Object:
-                return object;
-            case Illegal:
-                return this;
-        }
-        throw new IllegalArgumentException();
-    }
-
-    private boolean valueEqual(Constant other, boolean ignoreKind) {
-        // must have equivalent kinds to be equal
-        if (!ignoreKind && getKind() != other.getKind()) {
-            return false;
-        }
-        if (getKind() == Kind.Object) {
-            return object == other.object;
-        }
-        return primitive == other.primitive && getPrimitiveAnnotation() == other.getPrimitiveAnnotation();
-    }
-
-    /**
-     * Returns the primitive int value this constant represents. The constant must have a
-     * {@link Kind#getStackKind()} of {@link Kind#Int}.
-     * 
-     * @return the constant value
-     */
-    public int asInt() {
-        assert getKind().getStackKind() == Kind.Int;
-        return (int) primitive;
-    }
-
-    /**
-     * Returns the primitive boolean value this constant represents. The constant must have kind
-     * {@link Kind#Boolean}.
-     * 
-     * @return the constant value
-     */
-    public boolean asBoolean() {
-        assert getKind() == Kind.Boolean;
-        return primitive != 0L;
-    }
-
-    /**
-     * Returns the primitive long value this constant represents. The constant must have kind
-     * {@link Kind#Long}, a {@link Kind#getStackKind()} of {@link Kind#Int}.
-     * 
-     * @return the constant value
-     */
-    public long asLong() {
-        assert getKind().isNumericInteger();
-        return primitive;
-    }
-
-    /**
-     * Returns the primitive float value this constant represents. The constant must have kind
-     * {@link Kind#Float}.
-     * 
-     * @return the constant value
-     */
-    public float asFloat() {
-        assert getKind() == Kind.Float;
-        return Float.intBitsToFloat((int) primitive);
-    }
-
-    /**
-     * Returns the primitive double value this constant represents. The constant must have kind
-     * {@link Kind#Double}.
-     * 
-     * @return the constant value
-     */
-    public double asDouble() {
-        assert getKind() == Kind.Double;
-        return Double.longBitsToDouble(primitive);
-    }
-
-    /**
-     * Returns the object reference this constant represents. The constant must have kind
-     * {@link Kind#Object}.
-     * 
-     * @return the constant value
-     */
-    public Object asObject() {
-        assert getKind() == Kind.Object;
-        return object;
-    }
-
-    /**
-     * Gets the annotation (if any) associated with this constant.
-     * 
-     * @return null if this constant is not primitive or has no annotation
-     */
-    public Object getPrimitiveAnnotation() {
-        return getKind() == Kind.Object ? null : object;
-    }
-
-    /**
-     * Computes the hashcode of this constant.
-     * 
-     * @return a suitable hashcode for this constant
-     */
-    @Override
-    public int hashCode() {
-        if (getKind() == Kind.Object) {
-            return System.identityHashCode(object);
-        }
-        return (int) primitive * getKind().ordinal();
-    }
-
-    /**
-     * Checks whether this constant equals another object. This is only true if the other object is
-     * a constant that has the same {@linkplain #getKind() kind}, value and
-     * {@link #getPrimitiveAnnotation() annotation}.
-     * 
-     * @param o the object to compare equality
-     * @return {@code true} if this constant is equivalent to the specified object
-     */
-    @Override
-    public boolean equals(Object o) {
-        return o == this || o instanceof Constant && valueEqual((Constant) o, false);
-    }
-
-    /**
      * Creates a boxed double constant.
-     * 
+     *
      * @param d the double value to box
      * @return a boxed copy of {@code value}
      */
@@ -291,12 +163,12 @@
         if (Double.compare(d, 1.0D) == 0) {
             return DOUBLE_1;
         }
-        return new Constant(Kind.Double, null, Double.doubleToRawLongBits(d));
+        return new PrimitiveConstant(Kind.Double, Double.doubleToRawLongBits(d));
     }
 
     /**
      * Creates a boxed float constant.
-     * 
+     *
      * @param f the float value to box
      * @return a boxed copy of {@code value}
      */
@@ -310,22 +182,22 @@
         if (Float.compare(f, 2.0F) == 0) {
             return FLOAT_2;
         }
-        return new Constant(Kind.Float, null, Float.floatToRawIntBits(f));
+        return new PrimitiveConstant(Kind.Float, Float.floatToRawIntBits(f));
     }
 
     /**
      * Creates a boxed long constant.
-     * 
+     *
      * @param i the long value to box
      * @return a boxed copy of {@code value}
      */
     public static Constant forLong(long i) {
-        return i == 0 ? LONG_0 : i == 1 ? LONG_1 : new Constant(Kind.Long, null, i);
+        return i == 0 ? LONG_0 : i == 1 ? LONG_1 : new PrimitiveConstant(Kind.Long, i);
     }
 
     /**
      * Creates a boxed integer constant.
-     * 
+     *
      * @param i the integer value to box
      * @return a boxed copy of {@code value}
      */
@@ -336,22 +208,22 @@
         if (i >= 0 && i < INT_CONSTANT_CACHE.length) {
             return INT_CONSTANT_CACHE[i];
         }
-        return new Constant(Kind.Int, null, i);
+        return new PrimitiveConstant(Kind.Int, i);
     }
 
     /**
      * Creates a boxed byte constant.
-     * 
+     *
      * @param i the byte value to box
      * @return a boxed copy of {@code value}
      */
     public static Constant forByte(byte i) {
-        return new Constant(Kind.Byte, null, i);
+        return new PrimitiveConstant(Kind.Byte, i);
     }
 
     /**
      * Creates a boxed boolean constant.
-     * 
+     *
      * @param i the boolean value to box
      * @return a boxed copy of {@code value}
      */
@@ -361,52 +233,33 @@
 
     /**
      * Creates a boxed char constant.
-     * 
+     *
      * @param i the char value to box
      * @return a boxed copy of {@code value}
      */
     public static Constant forChar(char i) {
-        return new Constant(Kind.Char, null, i);
+        return new PrimitiveConstant(Kind.Char, i);
     }
 
     /**
      * Creates a boxed short constant.
-     * 
+     *
      * @param i the short value to box
      * @return a boxed copy of {@code value}
      */
     public static Constant forShort(short i) {
-        return new Constant(Kind.Short, null, i);
+        return new PrimitiveConstant(Kind.Short, i);
     }
 
     /**
-     * Creates a boxed object constant.
-     * 
-     * @param o the object value to box
-     * @return a boxed copy of {@code value}
+     * Creates a {@link Constant} from a primitive integer of a certain kind.
      */
-    public static Constant forObject(Object o) {
-        if (o == null) {
-            return NULL_OBJECT;
-        }
-        return new Constant(Kind.Object, o, 0L);
-    }
-
-    /**
-     * Creates an annotated int or long constant. An annotation enables a client to associate some
-     * extra semantic or debugging information with a primitive. An annotated primitive constant is
-     * never {@linkplain #equals(Object) equal} to a non-annotated constant.
-     * 
-     * @param kind the type of this constant
-     * @param i the value of this constant
-     * @param annotation an arbitrary non-null object
-     */
-    public static Constant forIntegerKind(Kind kind, long i, Object annotation) {
+    public static Constant forIntegerKind(Kind kind, long i) {
         switch (kind) {
             case Int:
-                return new Constant(kind, annotation, (int) i);
+                return new PrimitiveConstant(kind, (int) i);
             case Long:
-                return new Constant(kind, annotation, i);
+                return new PrimitiveConstant(kind, i);
             default:
                 throw new IllegalArgumentException("not an integer kind: " + kind);
         }
@@ -418,47 +271,42 @@
     public static Constant forPrimitiveInt(int bits, long i) {
         assert bits <= 64;
         if (bits > 32) {
-            return new Constant(Kind.Long, null, i);
+            return new PrimitiveConstant(Kind.Long, i);
         } else {
-            return new Constant(Kind.Int, null, (int) i);
+            return new PrimitiveConstant(Kind.Int, (int) i);
         }
     }
 
     /**
-     * Creates a boxed constant for the given kind from an Object. The object needs to be of the
-     * Java boxed type corresponding to the kind.
-     * 
-     * @param kind the kind of the constant to create
-     * @param value the Java boxed value: a {@link Byte} instance for {@link Kind#Byte}, etc.
-     * @return the boxed copy of {@code value}
+     * Creates a boxed constant for the given boxed primitive value.
+     *
+     * @param value the Java boxed value
+     * @return the primitive constant holding the {@code value}
      */
-    public static Constant forBoxed(Kind kind, Object value) {
-        switch (kind) {
-            case Boolean:
-                return forBoolean((Boolean) value);
-            case Byte:
-                return forByte((Byte) value);
-            case Char:
-                return forChar((Character) value);
-            case Short:
-                return forShort((Short) value);
-            case Int:
-                return forInt((Integer) value);
-            case Long:
-                return forLong((Long) value);
-            case Float:
-                return forFloat((Float) value);
-            case Double:
-                return forDouble((Double) value);
-            case Object:
-                return forObject(value);
-            default:
-                throw new RuntimeException("cannot create Constant for boxed " + kind + " value");
+    public static Constant forBoxedPrimitive(Object value) {
+        if (value instanceof Boolean) {
+            return forBoolean((Boolean) value);
+        } else if (value instanceof Byte) {
+            return forByte((Byte) value);
+        } else if (value instanceof Character) {
+            return forChar((Character) value);
+        } else if (value instanceof Short) {
+            return forShort((Short) value);
+        } else if (value instanceof Integer) {
+            return forInt((Integer) value);
+        } else if (value instanceof Long) {
+            return forLong((Long) value);
+        } else if (value instanceof Float) {
+            return forFloat((Float) value);
+        } else if (value instanceof Double) {
+            return forDouble((Double) value);
+        } else {
+            return null;
         }
     }
 
     public static Constant forIllegal() {
-        return new Constant(Kind.Illegal, null, 0);
+        return new PrimitiveConstant(Kind.Illegal, 0);
     }
 
     /**
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantPool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantPool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -117,5 +117,5 @@
      *            {@code -1}
      * @return the appendix if it exists and is resolved or {@code null}
      */
-    Object lookupAppendix(int cpi, int opcode);
+    Constant lookupAppendix(int cpi, int opcode);
 }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantReflectionProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -23,34 +23,78 @@
 package com.oracle.graal.api.meta;
 
 /**
- * Reflection operations on values represented as {@linkplain Constant constants}.
+ * Reflection operations on values represented as {@linkplain Constant constants}. All methods in
+ * this interface require the VM to access the actual object encapsulated in {@link Kind#Object
+ * object} constants. This access is not always possible, depending on kind of VM and the state that
+ * the VM is in. Therefore, all methods can return {@code null} at any time, to indicate that the
+ * result is not available at this point. The caller is responsible to check for {@code null}
+ * results and handle them properly, e.g., not perform an optimization.
  */
 public interface ConstantReflectionProvider {
 
     /**
-     * Compares two constants for equality. The equality relationship is symmetric. If the constants
-     * cannot be compared at this point, the return value is {@code null};
-     * 
-     * @return {@code true} if the two parameters represent the same runtime object, {@code false}
-     *         if they are different, or {@code null} if the parameters cannot be compared.
+     * Compares two constants for equality. The equality relationship is symmetric. Returns
+     * {@link Boolean#TRUE true} if the two constants represent the same run time value,
+     * {@link Boolean#FALSE false} if they are different. Returns {@code null} if the constants
+     * cannot be compared at this point.
      */
     Boolean constantEquals(Constant x, Constant y);
 
     /**
-     * Returns the length of an array that is wrapped in a {@link Constant} object. If {@code array}
-     * is not an array, or the array length is not available at this point, the return value is
-     * {@code null}.
+     * Returns the length of the array constant. Returns {@code null} if the constant is not an
+     * array, or if the array length is not available at this point.
      */
-    Integer lookupArrayLength(Constant array);
+    Integer readArrayLength(Constant array);
 
     /**
-     * Reads a value of this kind using a base address and a displacement.
-     * 
-     * @param base the base address from which the value is read
+     * Reads a value from the given array at the given index. Returns {@code null} if the constant
+     * is not an array, if the index is out of bounds, or if the value is not available at this
+     * point.
+     */
+    Constant readArrayElement(Constant array, int index);
+
+    /**
+     * Reads a value of this kind using a base address and a displacement. No bounds checking or
+     * type checking is performed. Returns {@code null} if the value is not available at this point.
+     *
+     * @param base the base address from which the value is read.
      * @param displacement the displacement within the object in bytes
-     * @param compressible whether this is a read of a compressed or an uncompressed pointer
      * @return the read value encapsulated in a {@link Constant} object, or {@code null} if the
      *         value cannot be read.
      */
-    Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressible);
+    Constant readUnsafeConstant(Kind kind, Constant base, long displacement);
+
+    /**
+     * Reads a primitive value using a base address and a displacement.
+     *
+     * @param kind the {@link Kind} of the returned {@link Constant} object
+     * @param base the base address from which the value is read
+     * @param displacement the displacement within the object in bytes
+     * @param bits the number of bits to read from memory
+     * @return the read value encapsulated in a {@link Constant} object of {@link Kind} kind
+     */
+    Constant readRawConstant(Kind kind, Constant base, long displacement, int bits);
+
+    /**
+     * Converts the given {@link Kind#isPrimitive() primitive} constant to a boxed
+     * {@link Kind#Object object} constant, according to the Java boxing rules. Returns {@code null}
+     * if the source is is not a primitive constant, or the boxed value is not available at this
+     * point.
+     */
+    Constant boxPrimitive(Constant source);
+
+    /**
+     * Converts the given {@link Kind#Object object} constant to a {@link Kind#isPrimitive()
+     * primitive} constant, according to the Java unboxing rules. Returns {@code null} if the source
+     * is is not an object constant that can be unboxed, or the unboxed value is not available at
+     * this point.
+     */
+    Constant unboxPrimitive(Constant source);
+
+    /**
+     * Returns the {@link ResolvedJavaType} for a {@link Class} object (or any other object regarded
+     * as a class by the VM) encapsulated in the given constant. Returns {@code null} if the
+     * constant does not encapsulate a class, or if the type is not available at this point.
+     */
+    ResolvedJavaType asJavaType(Constant constant);
 }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ForeignCallDescriptor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ForeignCallDescriptor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,10 +41,10 @@
 public class ForeignCallDescriptor {
 
     private final String name;
-    private final Class resultType;
-    private final Class[] argumentTypes;
+    private final Class<?> resultType;
+    private final Class<?>[] argumentTypes;
 
-    public ForeignCallDescriptor(String name, Class resultType, Class... argumentTypes) {
+    public ForeignCallDescriptor(String name, Class<?> resultType, Class<?>... argumentTypes) {
         this.name = name;
         this.resultType = resultType;
         this.argumentTypes = argumentTypes;
@@ -89,7 +89,7 @@
     public String toString() {
         StringBuilder sb = new StringBuilder(name).append('(');
         String sep = "";
-        for (Class arg : argumentTypes) {
+        for (Class<?> arg : argumentTypes) {
             sb.append(sep).append(arg.getSimpleName());
             sep = ",";
         }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Wed Apr 16 14:02:52 2014 +0200
@@ -66,10 +66,10 @@
     private final char typeChar;
     private final String javaName;
     private final boolean isStackInt;
-    private final Class primitiveJavaClass;
-    private final Class boxedJavaClass;
+    private final Class<?> primitiveJavaClass;
+    private final Class<?> boxedJavaClass;
 
-    private Kind(char typeChar, String javaName, boolean isStackInt, Class primitiveJavaClass, Class boxedJavaClass) {
+    private Kind(char typeChar, String javaName, boolean isStackInt, Class<?> primitiveJavaClass, Class<?> boxedJavaClass) {
         this.typeChar = typeChar;
         this.javaName = javaName;
         this.isStackInt = isStackInt;
@@ -95,7 +95,7 @@
 
     /**
      * Checks whether this type is a Java primitive type.
-     * 
+     *
      * @return {@code true} if this is {@link #Boolean}, {@link #Byte}, {@link #Char},
      *         {@link #Short}, {@link #Int}, {@link #Long}, {@link #Float}, {@link #Double}, or
      *         {@link #Void}.
@@ -106,7 +106,7 @@
 
     /**
      * Returns the kind that represents this kind when on the Java operand stack.
-     * 
+     *
      * @return the kind used on the operand stack
      */
     public Kind getStackKind() {
@@ -118,7 +118,7 @@
 
     /**
      * Checks whether this type is a Java primitive type representing an integer number.
-     * 
+     *
      * @return {@code true} if the stack kind is {@link #Int} or {@link #Long}.
      */
     public boolean isNumericInteger() {
@@ -127,7 +127,7 @@
 
     /**
      * Checks whether this type is a Java primitive type representing an unsigned number.
-     * 
+     *
      * @return {@code true} if the kind is {@link #Boolean} or {@link #Char}.
      */
     public boolean isUnsigned() {
@@ -136,7 +136,7 @@
 
     /**
      * Checks whether this type is a Java primitive type representing a floating point number.
-     * 
+     *
      * @return {@code true} if this is {@link #Float} or {@link #Double}.
      */
     public boolean isNumericFloat() {
@@ -145,7 +145,7 @@
 
     /**
      * Checks whether this represent an Object of some sort.
-     * 
+     *
      * @return {@code true} if this is {@link #Object}.
      */
     public boolean isObject() {
@@ -154,7 +154,7 @@
 
     /**
      * Returns the kind corresponding to the Java type string.
-     * 
+     *
      * @param typeString the Java type string
      * @return the kind
      */
@@ -169,7 +169,7 @@
 
     /**
      * Returns the kind of a word given the size of a word in bytes.
-     * 
+     *
      * @param wordSizeInBytes the size of a word in bytes
      * @return the kind representing a word value
      */
@@ -184,7 +184,7 @@
 
     /**
      * Returns the kind from the character describing a primitive or void.
-     * 
+     *
      * @param ch the character
      * @return the kind
      */
@@ -214,7 +214,7 @@
 
     /**
      * Returns the Kind representing the given Java class.
-     * 
+     *
      * @param klass the class
      * @return the kind
      */
@@ -244,7 +244,7 @@
 
     /**
      * Returns the Java class representing this kind.
-     * 
+     *
      * @return the Java class
      */
     public Class<?> toJavaClass() {
@@ -253,7 +253,7 @@
 
     /**
      * Returns the Java class for instances of boxed values of this kind.
-     * 
+     *
      * @return the Java class
      */
     public Class<?> toBoxedJavaClass() {
@@ -279,13 +279,13 @@
     /**
      * Classes for which invoking {@link Object#toString()} does not run user code.
      */
-    private static boolean isToStringSafe(Class c) {
+    private static boolean isToStringSafe(Class<?> c) {
         return c == Boolean.class || c == Byte.class || c == Character.class || c == Short.class || c == Integer.class || c == Float.class || c == Long.class || c == Double.class;
     }
 
     /**
      * Gets a formatted string for a given value of this kind.
-     * 
+     *
      * @param value a value of this kind
      * @return a formatted string for {@code value} based on this kind
      */
@@ -307,7 +307,7 @@
                 } else if (value instanceof JavaType) {
                     return "JavaType:" + MetaUtil.toJavaName((JavaType) value);
                 } else if (value instanceof Enum) {
-                    return MetaUtil.getSimpleName(value.getClass(), true) + ":" + ((Enum) value).name();
+                    return MetaUtil.getSimpleName(value.getClass(), true) + ":" + ((Enum<?>) value).name();
                 } else if (value instanceof FormatWithToString) {
                     return MetaUtil.getSimpleName(value.getClass(), true) + ":" + String.valueOf(value);
                 } else if (value instanceof Class<?>) {
@@ -351,7 +351,7 @@
 
     /**
      * The minimum value that can be represented as a value of this kind.
-     * 
+     *
      * @return the minimum value
      */
     public long getMinValue() {
@@ -375,7 +375,7 @@
 
     /**
      * The maximum value that can be represented as a value of this kind.
-     * 
+     *
      * @return the maximum value
      */
     public long getMaxValue() {
@@ -399,7 +399,7 @@
 
     /**
      * Number of bytes that are necessary to represent a value of this kind.
-     * 
+     *
      * @return the number of bytes
      */
     public int getByteCount() {
@@ -412,7 +412,7 @@
 
     /**
      * Number of bits that are necessary to represent a value of this kind.
-     * 
+     *
      * @return the number of bits
      */
     public int getBitCount() {
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -45,7 +45,7 @@
     /**
      * Provides the {@link ResolvedJavaMethod} for a {@link Constructor} obtained via reflection.
      */
-    ResolvedJavaMethod lookupJavaConstructor(Constructor reflectionConstructor);
+    ResolvedJavaMethod lookupJavaConstructor(Constructor<?> reflectionConstructor);
 
     /**
      * Provides the {@link ResolvedJavaField} for a {@link Field} obtained via reflection.
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 import java.lang.reflect.*;
 import java.util.*;
 
-import com.oracle.graal.api.meta.ProfilingInfo.*;
+import com.oracle.graal.api.meta.ProfilingInfo.TriState;
 
 /**
  * Miscellaneous collection of utility methods used by {@code com.oracle.graal.api.meta} and its
@@ -50,18 +50,18 @@
     /**
      * Returns the number of bytes occupied by this constant value or constant object and
      * recursively all values reachable from this value.
-     * 
+     *
      * @param constant the constant whose bytes should be measured
      * @param printTopN print total size and instance count of the top n classes is desired
      * @return the number of bytes occupied by this constant
      */
-    public static long getMemorySizeRecursive(MetaAccessProvider access, Constant constant, PrintStream out, int printTopN) {
-        IdentityHashMap<Object, Boolean> marked = new IdentityHashMap<>();
+    public static long getMemorySizeRecursive(MetaAccessProvider access, ConstantReflectionProvider constantReflection, Constant constant, PrintStream out, int printTopN) {
+        Set<Constant> marked = new HashSet<>();
         Stack<Constant> stack = new Stack<>();
         if (constant.getKind() == Kind.Object && constant.isNonNull()) {
-            marked.put(constant.asObject(), Boolean.TRUE);
+            marked.add(constant);
         }
-        final HashMap<Class, ClassInfo> histogram = new HashMap<>();
+        final HashMap<ResolvedJavaType, ClassInfo> histogram = new HashMap<>();
         stack.push(constant);
         long sum = 0;
         while (!stack.isEmpty()) {
@@ -69,7 +69,7 @@
             long memorySize = access.getMemorySize(constant);
             sum += memorySize;
             if (c.getKind() == Kind.Object && c.isNonNull()) {
-                Class<?> clazz = c.asObject().getClass();
+                ResolvedJavaType clazz = access.lookupJavaType(c);
                 if (!histogram.containsKey(clazz)) {
                     histogram.put(clazz, new ClassInfo());
                 }
@@ -79,10 +79,10 @@
                 ResolvedJavaType type = access.lookupJavaType(c);
                 if (type.isArray()) {
                     if (!type.getComponentType().isPrimitive()) {
-                        Object[] array = (Object[]) c.asObject();
-                        for (Object value : array) {
-                            Constant forObject = Constant.forObject(value);
-                            pushConstant(marked, stack, forObject);
+                        int length = constantReflection.readArrayLength(c);
+                        for (int i = 0; i < length; i++) {
+                            Constant value = constantReflection.readArrayElement(c, i);
+                            pushConstant(marked, stack, value);
                         }
                     }
                 } else {
@@ -96,12 +96,12 @@
                 }
             }
         }
-        ArrayList<Class> clazzes = new ArrayList<>();
+        ArrayList<ResolvedJavaType> clazzes = new ArrayList<>();
         clazzes.addAll(histogram.keySet());
-        Collections.sort(clazzes, new Comparator<Class>() {
+        Collections.sort(clazzes, new Comparator<ResolvedJavaType>() {
 
             @Override
-            public int compare(Class o1, Class o2) {
+            public int compare(ResolvedJavaType o1, ResolvedJavaType o2) {
                 long l1 = histogram.get(o1).totalSize;
                 long l2 = histogram.get(o2).totalSize;
                 if (l1 > l2) {
@@ -115,7 +115,7 @@
         });
 
         int z = 0;
-        for (Class c : clazzes) {
+        for (ResolvedJavaType c : clazzes) {
             if (z > printTopN) {
                 break;
             }
@@ -126,10 +126,10 @@
         return sum;
     }
 
-    private static void pushConstant(IdentityHashMap<Object, Boolean> marked, Stack<Constant> stack, Constant value) {
+    private static void pushConstant(Set<Constant> marked, Stack<Constant> stack, Constant value) {
         if (value.isNonNull()) {
-            if (!marked.containsKey(value.asObject())) {
-                marked.put(value.asObject(), Boolean.TRUE);
+            if (!marked.contains(value)) {
+                marked.add(value);
                 stack.push(value);
             }
         }
@@ -158,7 +158,7 @@
     /**
      * Calls {@link MetaAccessProvider#lookupJavaType(Class)} on an array of classes.
      */
-    public static ResolvedJavaType[] lookupJavaTypes(MetaAccessProvider metaAccess, Class[] classes) {
+    public static ResolvedJavaType[] lookupJavaTypes(MetaAccessProvider metaAccess, Class<?>[] classes) {
         ResolvedJavaType[] result = new ResolvedJavaType[classes.length];
         for (int i = 0; i < result.length; i++) {
             result[i] = metaAccess.lookupJavaType(classes[i]);
@@ -182,7 +182,7 @@
     /**
      * Extends the functionality of {@link Class#getSimpleName()} to include a non-empty string for
      * anonymous and local classes.
-     * 
+     *
      * @param clazz the class for which the simple name is being requested
      * @param withEnclosingClass specifies if the returned name should be qualified with the name(s)
      *            of the enclosing class/classes of {@code clazz} (if any). This option is ignored
@@ -218,7 +218,7 @@
     /**
      * Converts a given type to its Java programming language name. The following are examples of
      * strings returned by this method:
-     * 
+     *
      * <pre>
      *     qualified == true:
      *         java.lang.Object
@@ -229,7 +229,7 @@
      *         int
      *         boolean[][]
      * </pre>
-     * 
+     *
      * @param type the type to be converted to a Java name
      * @param qualified specifies if the package prefix of the type should be included in the
      *            returned name
@@ -246,13 +246,13 @@
     /**
      * Converts a given type to its Java programming language name. The following are examples of
      * strings returned by this method:
-     * 
+     *
      * <pre>
      *      java.lang.Object
      *      int
      *      boolean[][]
      * </pre>
-     * 
+     *
      * @param type the type to be converted to a Java name
      * @return the Java name corresponding to {@code type}
      */
@@ -308,7 +308,7 @@
      * and specifiers that denote an attribute of the method that is to be copied to the result. A
      * specifier is a single character preceded by a '%' character. The accepted specifiers and the
      * method attributes they denote are described below:
-     * 
+     *
      * <pre>
      *     Specifier | Description                                          | Example(s)
      *     ----------+------------------------------------------------------------------------------------------
@@ -322,7 +322,7 @@
      *     'f'       | Indicator if method is unresolved, static or virtual | "unresolved" "static" "virtual"
      *     '%'       | A '%' character                                      | "%"
      * </pre>
-     * 
+     *
      * @param format a format specification
      * @param method the method to be formatted
      * @return the result of formatting this method according to {@code format}
@@ -402,7 +402,7 @@
      * specifiers that denote an attribute of the field that is to be copied to the result. A
      * specifier is a single character preceded by a '%' character. The accepted specifiers and the
      * field attributes they denote are described below:
-     * 
+     *
      * <pre>
      *     Specifier | Description                                          | Example(s)
      *     ----------+------------------------------------------------------------------------------------------
@@ -414,7 +414,7 @@
      *     'f'       | Indicator if field is unresolved, static or instance | "unresolved" "static" "instance"
      *     '%'       | A '%' character                                      | "%"
      * </pre>
-     * 
+     *
      * @param format a format specification
      * @param field the field to be formatted
      * @return the result of formatting this field according to {@code format}
@@ -472,7 +472,7 @@
 
     /**
      * Gets the annotations of a particular type for the formal parameters of a given method.
-     * 
+     *
      * @param annotationClass the Class object corresponding to the annotation type
      * @param method the method for which a parameter annotations are being requested
      * @return the annotation of type {@code annotationClass} (if any) for each formal parameter
@@ -494,7 +494,7 @@
 
     /**
      * Gets the annotation of a particular type for a formal parameter of a given method.
-     * 
+     *
      * @param annotationClass the Class object corresponding to the annotation type
      * @param parameterIndex the index of a formal parameter of {@code method}
      * @param method the method for which a parameter annotation is being requested
@@ -530,18 +530,18 @@
      * line number is {@linkplain ResolvedJavaMethod#asStackTraceElement(int) available} for the
      * given method, then the string returned is the {@link StackTraceElement#toString()} value of
      * the stack trace element, suffixed by the bci location. For example:
-     * 
+     *
      * <pre>
      *     java.lang.String.valueOf(String.java:2930) [bci: 12]
      * </pre>
-     * 
+     *
      * Otherwise, the string returned is the value of applying {@link #format(String, JavaMethod)}
      * with the format string {@code "%H.%n(%p)"}, suffixed by the bci location. For example:
-     * 
+     *
      * <pre>
      *     java.lang.String.valueOf(int) [bci: 12]
      * </pre>
-     * 
+     *
      * @param sb
      * @param method
      * @param bci
@@ -586,13 +586,13 @@
      * Gets the <a
      * href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.3">method
      * descriptor</a> corresponding to this signature. For example:
-     * 
+     *
      * <pre>
      * (ILjava/lang/String;D)V
      * </pre>
-     * 
+     *
      * .
-     * 
+     *
      * @param sig the {@link Signature} to be converted.
      * @return the signature as a string
      */
@@ -607,7 +607,7 @@
 
     /**
      * Formats some profiling information associated as a string.
-     * 
+     *
      * @param info the profiling info to format
      * @param method an optional method that augments the profile string returned
      * @param sep the separator to use for each separate profile record
@@ -669,13 +669,13 @@
         return s.substring(0, s.length() - sep.length());
     }
 
-    private static void appendProfile(StringBuilder buf, AbstractJavaProfile profile, int bci, String type, String sep) {
+    private static void appendProfile(StringBuilder buf, AbstractJavaProfile<?, ?> profile, int bci, String type, String sep) {
         if (profile != null) {
-            AbstractProfiledItem[] pitems = profile.getItems();
+            AbstractProfiledItem<?>[] pitems = profile.getItems();
             if (pitems != null) {
                 buf.append(String.format("%s@%d:", type, bci));
                 for (int j = 0; j < pitems.length; j++) {
-                    AbstractProfiledItem pitem = pitems[j];
+                    AbstractProfiledItem<?> pitem = pitems[j];
                     buf.append(String.format(" %.6f (%s)%s", pitem.getProbability(), pitem.getItem(), sep));
                 }
                 if (profile.getNotRecordedProbability() != 0) {
@@ -689,7 +689,7 @@
 
     /**
      * Converts a Java source-language class name into the internal form.
-     * 
+     *
      * @param className the class name
      * @return the internal name form of the class name
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.meta;
+
+/**
+ * The implementation type of the {@link Constant#NULL_OBJECT null constant}.
+ */
+final class NullConstant extends Constant {
+
+    private static final long serialVersionUID = 8906209595800783961L;
+
+    protected NullConstant() {
+        super(Kind.Object);
+    }
+
+    @Override
+    public boolean isNull() {
+        return true;
+    }
+
+    @Override
+    public boolean isDefaultForKind() {
+        return true;
+    }
+
+    @Override
+    public Object asBoxedPrimitive() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public int asInt() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public boolean asBoolean() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public long asLong() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public float asFloat() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public double asDouble() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public String toValueString() {
+        return "null";
+    }
+
+    @Override
+    public int hashCode() {
+        return System.identityHashCode(this);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        assert o == this || !(o instanceof NullConstant) : "null constant is a singleton";
+        return o == this;
+    }
+}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ObjectLocationIdentity.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.api.meta;
-
-import java.util.*;
-
-/**
- * A {@link LocationIdentity} wrapping an object.
- */
-public final class ObjectLocationIdentity implements LocationIdentity {
-
-    private static IdentityHashMap<Object, LocationIdentity> map = new IdentityHashMap<>();
-
-    private Object object;
-
-    public static LocationIdentity create(Object object) {
-        synchronized (map) {
-            if (map.containsKey(object)) {
-                return map.get(object);
-            } else {
-                ObjectLocationIdentity locationIdentity = new ObjectLocationIdentity(object);
-                map.put(object, locationIdentity);
-                return locationIdentity;
-            }
-        }
-    }
-
-    private ObjectLocationIdentity(Object object) {
-        this.object = object;
-    }
-
-    @Override
-    public String toString() {
-        return "Identity(" + object + ")";
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PrimitiveConstant.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,129 @@
+/*
+ * 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.api.meta;
+
+/**
+ * Represents a primitive constant value, such as an integer or floating point number, within the
+ * compiler and across the compiler/runtime interface.
+ */
+public class PrimitiveConstant extends Constant {
+
+    private static final long serialVersionUID = 8787949721295655376L;
+
+    /**
+     * The boxed primitive value as a {@code long}. For {@code float} and {@code double} values,
+     * this value is the result of {@link Float#floatToRawIntBits(float)} and
+     * {@link Double#doubleToRawLongBits(double)} respectively.
+     */
+    private final long primitive;
+
+    protected PrimitiveConstant(Kind kind, long primitive) {
+        super(kind);
+        this.primitive = primitive;
+
+        assert kind.isPrimitive() || kind == Kind.Illegal;
+    }
+
+    @Override
+    public boolean isNull() {
+        return false;
+    }
+
+    @Override
+    public boolean isDefaultForKind() {
+        return primitive == 0;
+    }
+
+    @Override
+    public boolean asBoolean() {
+        assert getKind() == Kind.Boolean;
+        return primitive != 0L;
+    }
+
+    @Override
+    public int asInt() {
+        assert getKind().getStackKind() == Kind.Int;
+        return (int) primitive;
+    }
+
+    @Override
+    public long asLong() {
+        assert getKind().isNumericInteger();
+        return primitive;
+    }
+
+    @Override
+    public float asFloat() {
+        assert getKind() == Kind.Float;
+        return Float.intBitsToFloat((int) primitive);
+    }
+
+    @Override
+    public double asDouble() {
+        assert getKind() == Kind.Double;
+        return Double.longBitsToDouble(primitive);
+    }
+
+    @Override
+    public Object asBoxedPrimitive() {
+        switch (getKind()) {
+            case Byte:
+                return Byte.valueOf((byte) primitive);
+            case Boolean:
+                return Boolean.valueOf(asBoolean());
+            case Short:
+                return Short.valueOf((short) primitive);
+            case Char:
+                return Character.valueOf((char) primitive);
+            case Int:
+                return Integer.valueOf(asInt());
+            case Long:
+                return Long.valueOf(asLong());
+            case Float:
+                return Float.valueOf(asFloat());
+            case Double:
+                return Double.valueOf(asDouble());
+            default:
+                throw new IllegalArgumentException();
+        }
+    }
+
+    @Override
+    public int hashCode() {
+        return (int) (primitive ^ (primitive >>> 32)) * (getKind().ordinal() + 31);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return o == this || (o instanceof PrimitiveConstant && super.equals(o) && primitive == ((PrimitiveConstant) o).primitive);
+    }
+
+    @Override
+    public String toString() {
+        if (getKind() == Kind.Illegal) {
+            return "illegal";
+        } else {
+            return getKind().getJavaName() + "[" + getKind().format(asBoxedPrimitive()) + "|0x" + Long.toHexString(primitive) + "]";
+        }
+    }
+}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java	Wed Apr 16 14:02:52 2014 +0200
@@ -35,10 +35,10 @@
      * Returns the bytecode of this method, if the method has code. The returned byte array does not
      * contain breakpoints or non-Java bytecodes. This may return null if the
      * {@link #getDeclaringClass() holder} is not {@link ResolvedJavaType#isLinked() linked}.
-     * 
+     *
      * The contained constant pool indices may not be the ones found in the original class file but
      * they can be used with the Graal API (e.g. methods in {@link ConstantPool}).
-     * 
+     *
      * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} or if the
      *         code is not ready.
      */
@@ -47,7 +47,7 @@
     /**
      * Returns the size of the bytecode of this method, if the method has code. This is equivalent
      * to {@link #getCode()}. {@code length} if the method has code.
-     * 
+     *
      * @return the size of the bytecode in bytes, or 0 if no bytecode is available
      */
     int getCodeSize();
@@ -84,10 +84,10 @@
 
     /**
      * Returns {@code true} if this method is a default method; returns {@code false} otherwise.
-     * 
+     *
      * A default method is a public non-abstract instance method, that is, a non-static method with
      * a body, declared in an interface type.
-     * 
+     *
      * @return true if and only if this method is a default method as defined by the Java Language
      *         Specification.
      */
@@ -95,22 +95,22 @@
 
     /**
      * Checks whether this method is a class initializer.
-     * 
+     *
      * @return {@code true} if the method is a class initializer
      */
     boolean isClassInitializer();
 
     /**
      * Checks whether this method is a constructor.
-     * 
+     *
      * @return {@code true} if the method is a constructor
      */
     boolean isConstructor();
 
     /**
      * Checks whether this method can be statically bound (usually, that means it is final or
-     * private or static, but not abstract).
-     * 
+     * private or static, but not abstract, or the declaring class is final)
+     *
      * @return {@code true} if this method can be statically bound
      */
     boolean canBeStaticallyBound();
@@ -143,7 +143,7 @@
     /**
      * Returns the annotation for the specified type of this method, if such an annotation is
      * present.
-     * 
+     *
      * @param annotationClass the Class object corresponding to the annotation type
      * @return this element's annotation for the specified annotation type if present on this
      *         method, else {@code null}
@@ -153,7 +153,7 @@
     /**
      * Returns an array of arrays that represent the annotations on the formal parameters, in
      * declaration order, of this method.
-     * 
+     *
      * @see Method#getParameterAnnotations()
      */
     Annotation[][] getParameterAnnotations();
@@ -161,7 +161,7 @@
     /**
      * Returns an array of {@link Type} objects that represent the formal parameter types, in
      * declaration order, of this method.
-     * 
+     *
      * @see Method#getGenericParameterTypes()
      */
     Type[] getGenericParameterTypes();
@@ -192,7 +192,7 @@
      * Invokes the underlying method represented by this object, on the specified object with the
      * specified parameters. This method is similar to a reflective method invocation by
      * {@link Method#invoke}.
-     * 
+     *
      * @param receiver The receiver for the invocation, or {@code null} if it is a static method.
      * @param arguments The arguments for the invocation.
      * @return The value returned by the method invocation, or {@code null} if the return type is
@@ -204,7 +204,7 @@
      * Uses the constructor represented by this object to create and initialize a new instance of
      * the constructor's declaring class, with the specified initialization parameters. This method
      * is similar to a reflective instantiation by {@link Constructor#newInstance}.
-     * 
+     *
      * @param arguments The arguments for the constructor.
      * @return The newly created and initialized object.
      */
@@ -212,14 +212,14 @@
 
     /**
      * Gets the encoding of (that is, a constant representing the value of) this method.
-     * 
+     *
      * @return a constant representing a reference to this method
      */
     Constant getEncoding();
 
     /**
      * Checks if this method is present in the virtual table.
-     * 
+     *
      * @return true is this method is present in the virtual table
      */
     boolean isInVirtualMethodTable();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.api.replacements;
+
+import com.oracle.graal.api.meta.*;
+
+/**
+ * Reflection operations on values represented as {@linkplain Constant constants} for the processing
+ * of snippets. Snippets need a direct access to the value of object constants, which is not allowed
+ * in other parts of Graal to enforce compiler-VM separation.
+ * <p>
+ * This interface must not be used in Graal code that is not related to snippet processing.
+ */
+public interface SnippetReflectionProvider {
+
+    /**
+     * Creates a boxed {@link Kind#Object object} constant.
+     *
+     * @param object the object value to box
+     * @return a constant containing {@code object}
+     */
+    Constant forObject(Object object);
+
+    /**
+     * Returns the object reference the given constant represents. The constant must have kind
+     * {@link Kind#Object}.
+     *
+     * @param constant the to access
+     * @return the object value of the constant
+     */
+    Object asObject(Constant constant);
+
+    /**
+     * Creates a boxed constant for the given kind from an Object. The object needs to be of the
+     * Java boxed type corresponding to the kind.
+     *
+     * @param kind the kind of the constant to create
+     * @param value the Java boxed value: a {@link Byte} instance for {@link Kind#Byte}, etc.
+     * @return the boxed copy of {@code value}
+     */
+    Constant forBoxed(Kind kind, Object value);
+
+    /**
+     * Returns the value of this constant as a boxed Java value.
+     *
+     * @param constant the constant to box
+     * @return the value of the constant
+     */
+    Object asBoxedValue(Constant constant);
+}
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
     public static GraalRuntime getRuntime() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            Class cc = Reflection.getCallerClass();
+            Class<?> cc = Reflection.getCallerClass();
             if (cc.getClassLoader() != null) {
                 sm.checkPermission(ACCESS_PERMISSION);
             }
@@ -60,7 +60,7 @@
     public static <T> T getRequiredCapability(Class<T> clazz) {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            Class cc = Reflection.getCallerClass();
+            Class<?> cc = Reflection.getCallerClass();
             if (cc.getClassLoader() != null) {
                 sm.checkPermission(ACCESS_PERMISSION);
             }
--- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64Assembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,7 @@
 import static com.oracle.graal.asm.amd64.AMD64AsmOptions.*;
 
 import com.oracle.graal.amd64.*;
+import com.oracle.graal.amd64.AMD64.CPUFeature;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.asm.*;
 
@@ -163,7 +164,7 @@
 
     /**
      * Constructs an assembler for the AMD64 architecture.
-     * 
+     *
      * @param registerConfig the register configuration used to bind {@link Register#Frame} and
      *            {@link Register#CallerFrame} to physical registers. This value can be null if this
      *            assembler instance will not be used to assemble instructions using these logical
@@ -183,44 +184,90 @@
         return r.encoding & 0x7;
     }
 
-    private void emitArith(int op1, int op2, Register dst, int imm32) {
-        emitArith(op1, op2, dst, imm32, false);
+    private void emitArithImm8(int op, Register dst, int imm8) {
+        int encode = prefixAndEncode(op, dst.encoding, true);
+        emitByte(0x80);
+        emitByte(0xC0 | encode);
+        emitByte(imm8);
+    }
+
+    private void emitArithImm16(int op, Register dst, int imm16) {
+        emitByte(0x66);
+        int encode = prefixAndEncode(op, dst.encoding);
+        if (isByte(imm16)) {
+            emitByte(0x83); // imm8 sign extend
+            emitByte(0xC0 | encode);
+            emitByte(imm16 & 0xFF);
+        } else {
+            emitByte(0x81);
+            emitByte(0xC0 | encode);
+            emitShort(imm16);
+        }
     }
 
-    private void emitArith(int op1, int op2, Register dst, int imm32, boolean force32Imm) {
-        assert isUByte(op1) && isUByte(op2) : "wrong opcode";
-        assert (op1 & 0x01) == 1 : "should be 32bit operation";
-        assert (op1 & 0x02) == 0 : "sign-extension bit should not be set";
-        if (isByte(imm32) && !force32Imm) {
-            emitByte(op1 | 0x02); // set sign bit
-            emitByte(op2 | encode(dst));
+    private void emitArithImm32(int op, Register dst, int imm32) {
+        int encode = prefixAndEncode(op, dst.encoding);
+        if (isByte(imm32)) {
+            emitByte(0x83); // imm8 sign extend
+            emitByte(0xC0 | encode);
             emitByte(imm32 & 0xFF);
         } else {
-            emitByte(op1);
-            emitByte(op2 | encode(dst));
+            emitByte(0x81);
+            emitByte(0xC0 | encode);
+            emitInt(imm32);
+        }
+    }
+
+    private void emitArithImm32q(int op, Register dst, int imm32) {
+        emitArithImm32q(op, dst, imm32, false);
+    }
+
+    private void emitArithImm32q(int op, Register dst, int imm32, boolean force32Imm) {
+        int encode = prefixqAndEncode(op, dst.encoding);
+        if (isByte(imm32) && !force32Imm) {
+            emitByte(0x83); // imm8 sign extend
+            emitByte(0xC0 | encode);
+            emitByte(imm32 & 0xFF);
+        } else {
+            emitByte(0x81);
+            emitByte(0xC0 | encode);
             emitInt(imm32);
         }
     }
 
     // immediate-to-memory forms
-    private void emitArithOperand(int op1, int op2, AMD64Address adr, int imm32) {
-        assert (op1 & 0x01) == 1 : "should be 32bit operation";
-        assert (op1 & 0x02) == 0 : "sign-extension bit should not be set";
-        if (isByte(imm32)) {
-            emitByte(op1 | 0x02); // set sign bit
-            emitOperandHelper(op2, adr);
-            emitByte(imm32 & 0xFF);
+    private void emitArithImm8(int op, AMD64Address adr, int imm8) {
+        prefix(adr);
+        emitByte(0x80);
+        emitOperandHelper(op, adr);
+        emitByte(imm8);
+    }
+
+    private void emitArithImm16(int op, AMD64Address adr, int imm16) {
+        emitByte(0x66);
+        prefix(adr);
+        if (isByte(imm16)) {
+            emitByte(0x83); // imm8 sign extend
+            emitOperandHelper(op, adr);
+            emitByte(imm16 & 0xFF);
         } else {
-            emitByte(op1);
-            emitOperandHelper(op2, adr);
-            emitInt(imm32);
+            emitByte(0x81);
+            emitOperandHelper(op, adr);
+            emitShort(imm16);
         }
     }
 
-    private void emitArith(int op1, int op2, Register dst, Register src) {
-        assert isUByte(op1) && isUByte(op2) : "wrong opcode";
-        emitByte(op1);
-        emitByte(op2 | encode(dst) << 3 | encode(src));
+    private void emitArithImm32(int op, AMD64Address adr, int imm32) {
+        prefix(adr);
+        if (isByte(imm32)) {
+            emitByte(0x83); // imm8 sign extend
+            emitOperandHelper(op, adr);
+            emitByte(imm32 & 0xFF);
+        } else {
+            emitByte(0x81);
+            emitOperandHelper(op, adr);
+            emitInt(imm32);
+        }
     }
 
     protected void emitOperandHelper(Register reg, AMD64Address addr) {
@@ -333,13 +380,11 @@
     }
 
     public final void addl(AMD64Address dst, int imm32) {
-        prefix(dst);
-        emitArithOperand(0x81, 0, dst, imm32);
+        emitArithImm32(0, dst, imm32);
     }
 
     public final void addl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xC0, dst, imm32);
+        emitArithImm32(0, dst, imm32);
     }
 
     public final void addl(Register dst, AMD64Address src) {
@@ -349,8 +394,9 @@
     }
 
     public final void addl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x03, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x03);
+        emitByte(0xC0 | encode);
     }
 
     private void addrNop4() {
@@ -424,8 +470,7 @@
     }
 
     public final void andl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xE0, dst, imm32);
+        emitArithImm32(4, dst, imm32);
     }
 
     public final void andl(Register dst, AMD64Address src) {
@@ -435,8 +480,9 @@
     }
 
     public final void andl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x23, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x23);
+        emitByte(0xC0 | encode);
     }
 
     public final void bsfq(Register dst, Register src) {
@@ -509,14 +555,56 @@
         emitOperandHelper(dst, src);
     }
 
+    public final void cmpb(Register dst, int imm8) {
+        emitArithImm8(7, dst, imm8);
+    }
+
+    public final void cmpb(Register dst, Register src) {
+        int encode = prefixAndEncode(dst.encoding, src.encoding, true);
+        emitByte(0x3A);
+        emitByte(0xC0 | encode);
+    }
+
+    public final void cmpb(Register dst, AMD64Address src) {
+        prefix(src, dst, true);
+        emitByte(0x3A);
+        emitOperandHelper(dst, src);
+    }
+
+    public final void cmpb(AMD64Address dst, int imm8) {
+        emitArithImm8(7, dst, imm8);
+    }
+
+    public final void cmpw(Register dst, int imm16) {
+        emitArithImm16(7, dst, imm16);
+    }
+
+    public final void cmpw(Register dst, Register src) {
+        emitByte(0x66);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x3B);
+        emitByte(0xC0 | encode);
+    }
+
+    public final void cmpw(Register dst, AMD64Address src) {
+        emitByte(0x66);
+        prefix(src, dst);
+        emitByte(0x3B);
+        emitOperandHelper(dst, src);
+    }
+
+    public final void cmpw(AMD64Address dst, int imm16) {
+        emitArithImm16(7, dst, imm16);
+    }
+
     public final void cmpl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xF8, dst, imm32);
+        emitArithImm32(7, dst, imm32);
     }
 
     public final void cmpl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x3B, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x3B);
+        emitByte(0xC0 | encode);
     }
 
     public final void cmpl(Register dst, AMD64Address src) {
@@ -526,10 +614,7 @@
     }
 
     public final void cmpl(AMD64Address dst, int imm32) {
-        prefix(dst);
-        emitByte(0x81);
-        emitOperandHelper(7, dst);
-        emitInt(imm32);
+        emitArithImm32(7, dst, imm32);
     }
 
     // The 32-bit cmpxchg compares the value at adr with the contents of X86.rax,
@@ -1425,8 +1510,7 @@
     }
 
     public final void orl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xC8, dst, imm32);
+        emitArithImm32(1, dst, imm32);
     }
 
     public final void orl(Register dst, AMD64Address src) {
@@ -1436,8 +1520,9 @@
     }
 
     public final void orl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x0B, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x0B);
+        emitByte(0xC0 | encode);
     }
 
     public final void popcntl(Register dst, AMD64Address src) {
@@ -1595,13 +1680,11 @@
     }
 
     public final void subl(AMD64Address dst, int imm32) {
-        prefix(dst);
-        emitArithOperand(0x81, 5, dst, imm32);
+        emitArithImm32(5, dst, imm32);
     }
 
     public final void subl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xE8, dst, imm32);
+        emitArithImm32(5, dst, imm32);
     }
 
     public final void subl(Register dst, AMD64Address src) {
@@ -1611,8 +1694,9 @@
     }
 
     public final void subl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x2B, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x2B);
+        emitByte(0xC0 | encode);
     }
 
     public final void subsd(Register dst, Register src) {
@@ -1678,8 +1762,9 @@
     }
 
     public final void testl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x85, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x85);
+        emitByte(0xC0 | encode);
     }
 
     public final void testl(Register dst, AMD64Address src) {
@@ -1720,8 +1805,7 @@
     }
 
     public final void xorl(Register dst, int imm32) {
-        prefix(dst);
-        emitArith(0x81, 0xF0, dst, imm32);
+        emitArithImm32(6, dst, imm32);
     }
 
     public final void xorl(Register dst, AMD64Address src) {
@@ -1731,8 +1815,9 @@
     }
 
     public final void xorl(Register dst, Register src) {
-        prefixAndEncode(dst.encoding, src.encoding);
-        emitArith(0x33, 0xC0, dst, src);
+        int encode = prefixAndEncode(dst.encoding, src.encoding);
+        emitByte(0x33);
+        emitByte(0xC0 | encode);
     }
 
     public final void andpd(Register dst, Register src) {
@@ -1880,7 +1965,7 @@
     /**
      * Creates prefix and the encoding of the lower 6 bits of the ModRM-Byte. It emits an operand
      * prefix. If the given operands exceed 3 bits, the 4th bit is encoded in the prefix.
-     * 
+     *
      * @param regEncoding the encoding of the register part of the ModRM-Byte
      * @param rmEncoding the encoding of the r/m part of the ModRM-Byte
      * @return the lower 6 bits of the ModRM-Byte that should be emitted
@@ -1907,12 +1992,6 @@
         return regEnc << 3 | rmEnc;
     }
 
-    private void prefix(Register reg) {
-        if (reg.encoding >= 8) {
-            emitByte(Prefix.REXB);
-        }
-    }
-
     private static boolean needsRex(Register reg) {
         return reg.encoding >= MinEncodingNeedsRex;
     }
@@ -2016,8 +2095,7 @@
     }
 
     public final void addq(Register dst, int imm32) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xC0, dst, imm32);
+        emitArithImm32q(0, dst, imm32);
     }
 
     public final void addq(Register dst, AMD64Address src) {
@@ -2027,13 +2105,13 @@
     }
 
     public final void addq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x03, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x03);
+        emitByte(0xC0 | encode);
     }
 
     public final void andq(Register dst, int imm32) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xE0, dst, imm32);
+        emitArithImm32q(4, dst, imm32);
     }
 
     public final void andq(Register dst, AMD64Address src) {
@@ -2043,8 +2121,9 @@
     }
 
     public final void andq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x23, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x23);
+        emitByte(0xC0 | encode);
     }
 
     public final void bswapq(Register reg) {
@@ -2080,13 +2159,13 @@
     }
 
     public final void cmpq(Register dst, int imm32) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xF8, dst, imm32);
+        emitArithImm32q(7, dst, imm32);
     }
 
     public final void cmpq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x3B, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x3B);
+        emitByte(0xC0 | encode);
     }
 
     public final void cmpq(Register dst, AMD64Address src) {
@@ -2307,8 +2386,7 @@
     }
 
     public final void orq(Register dst, int imm32) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xC8, dst, imm32);
+        emitArithImm32q(1, dst, imm32);
     }
 
     public final void orq(Register dst, AMD64Address src) {
@@ -2318,8 +2396,9 @@
     }
 
     public final void orq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x0B, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x0B);
+        emitByte(0xC0 | encode);
     }
 
     public final void sarq(Register dst, int imm8) {
@@ -2383,8 +2462,7 @@
     }
 
     private void subq(Register dst, int imm32, boolean force32Imm) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xE8, dst, imm32, force32Imm);
+        emitArithImm32q(5, dst, imm32, force32Imm);
     }
 
     public final void subq(Register dst, AMD64Address src) {
@@ -2394,8 +2472,9 @@
     }
 
     public final void subq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x2B, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x2B);
+        emitByte(0xC0 | encode);
     }
 
     public final void testq(Register dst, int imm32) {
@@ -2415,8 +2494,9 @@
     }
 
     public final void testq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x85, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x85);
+        emitByte(0xC0 | encode);
     }
 
     public final void testq(Register dst, AMD64Address src) {
@@ -2433,13 +2513,13 @@
     }
 
     public final void xorq(Register dst, int imm32) {
-        prefixqAndEncode(dst.encoding);
-        emitArith(0x81, 0xF0, dst, imm32);
+        emitArithImm32q(6, dst, imm32);
     }
 
     public final void xorq(Register dst, Register src) {
-        prefixqAndEncode(dst.encoding, src.encoding);
-        emitArith(0x33, 0xC0, dst, src);
+        int encode = prefixqAndEncode(dst.encoding, src.encoding);
+        emitByte(0x33);
+        emitByte(0xC0 | encode);
     }
 
     public final void xorq(Register dst, AMD64Address src) {
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAddress.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAddress.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.asm.hsail;
 
 import com.oracle.graal.api.code.*;
-
 import com.oracle.graal.api.meta.*;
 
 /**
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,15 +27,13 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hsail.*;
-import com.oracle.graal.graph.GraalInternalError;
-import com.amd.okra.OkraUtil;
-import java.lang.reflect.Array;
 
 /**
  * This class contains routines to emit HSAIL assembly code.
  */
-public class HSAILAssembler extends AbstractHSAILAssembler {
+public abstract class HSAILAssembler extends AbstractHSAILAssembler {
 
     /**
      * Stack size in bytes (used to keep track of spilling).
@@ -86,35 +84,13 @@
      * references get updated by the GC whenever the GC moves an Object.
      *
      * @param a the destination register
-     * @param obj the Object being moved
+     * @param src the Object Constant being moved
      */
-    public final void mov(Register a, Object obj) {
-        String regName = "$d" + a.encoding();
-        // For a null object simply move 0x0 into the destination register.
-        if (obj == null) {
-            emitString("mov_b64 " + regName + ", 0x0;  // null object");
-        } else {
-            // Get a JNI reference handle to the object.
-            long refHandle = OkraUtil.getRefHandle(obj);
-            // Get the clasname of the object for emitting a comment.
-            Class<?> clazz = obj.getClass();
-            String className = clazz.getName();
-            String comment = "// handle for object of type " + className;
-            // If the object is an array note the array length in the comment.
-            if (className.startsWith("[")) {
-                comment += ", length " + Array.getLength(obj);
-            }
-            // First move the reference handle into a register.
-            emitString("mov_b64 " + regName + ", 0x" + Long.toHexString(refHandle) + ";    " + comment);
-            // Next load the Object addressed by this reference handle into the destination reg.
-            emitString("ld_global_u64 " + regName + ", [" + regName + "];");
-        }
-
-    }
+    public abstract void mov(Register a, Constant src);
 
     public final void emitMov(Kind kind, Value dst, Value src) {
         if (isRegister(dst) && isConstant(src) && kind.getStackKind() == Kind.Object) {
-            mov(asRegister(dst), (asConstant(src)).asObject());
+            mov(asRegister(dst), asConstant(src));
         } else {
             String argtype = getArgTypeFromKind(kind).substring(1);
             emitString("mov_b" + argtype + " " + mapRegOrConstToString(dst) + ", " + mapRegOrConstToString(src) + ";");
@@ -126,7 +102,7 @@
         if (reg instanceof RegisterValue) {
             storeValue = HSAIL.mapRegister(reg);
         } else if (reg instanceof Constant) {
-            storeValue = ((Constant) reg).asBoxedValue().toString();
+            storeValue = ((Constant) reg).toValueString();
         }
         emitString(instr + " " + storeValue + ", " + mapAddress(addr) + ";");
     }
@@ -312,14 +288,14 @@
      *            float compares.
      * @param isUnsignedCompare - flag specifying if this is a compare of unsigned values.
      */
-    public void emitCompare(Value src0, Value src1, String condition, boolean unordered, boolean isUnsignedCompare) {
+    public void emitCompare(Kind compareKind, Value src0, Value src1, String condition, boolean unordered, boolean isUnsignedCompare) {
         // Formulate the prefix of the instruction.
         // if unordered is true, it should be ignored unless the src type is f32 or f64
-        String argType = getArgTypeFromKind(src1.getKind().getStackKind());
+        String argType = getArgTypeFromKind(compareKind);
         String unorderedPrefix = (argType.startsWith("f") && unordered ? "u" : "");
         String prefix = "cmp_" + condition + unorderedPrefix + "_b1_" + (isUnsignedCompare ? getArgTypeForceUnsigned(src1) : argType);
         // Generate a comment for debugging purposes
-        String comment = (isConstant(src1) && (src1.getKind() == Kind.Object) && (asConstant(src1).asObject() == null) ? " // null test " : "");
+        String comment = (isConstant(src1) && (src1.getKind() == Kind.Object) && (asConstant(src1).isNull()) ? " // null test " : "");
         // Emit the instruction.
         emitString(prefix + " $c0, " + mapRegOrConstToString(src0) + ", " + mapRegOrConstToString(src1) + ";" + comment);
     }
@@ -366,8 +342,7 @@
                 case Long:
                     return "0x" + Long.toHexString(consrc.asLong());
                 case Object:
-                    Object obj = consrc.asObject();
-                    if (obj == null) {
+                    if (consrc.isNull()) {
                         return "0";
                     } else {
                         throw GraalInternalError.shouldNotReachHere("unknown type: " + src);
@@ -532,7 +507,7 @@
      */
     private void emitWithOptionalTestForNull(boolean testForNull, String mnemonic, Value result, Value... sources) {
         if (testForNull) {
-            emitCompare(result, Constant.forLong(0), "eq", false, true);
+            emitCompare(Kind.Long, result, Constant.forLong(0), "eq", false, true);
         }
         emitForceUnsigned(mnemonic, result, sources);
         if (testForNull) {
@@ -549,8 +524,8 @@
      * @param newValue the new value that will be written to the memory location if the cmpValue
      *            comparison matches
      */
-    public void emitAtomicCas(AllocatableValue result, HSAILAddress address, Value cmpValue, Value newValue) {
-        emitString(String.format("atomic_cas_global_b%d   %s, %s, %s, %s;", getArgSize(cmpValue), HSAIL.mapRegister(result), mapAddress(address), mapRegOrConstToString(cmpValue),
+    public void emitAtomicCas(Kind accessKind, AllocatableValue result, HSAILAddress address, Value cmpValue, Value newValue) {
+        emitString(String.format("atomic_cas_global_b%d   %s, %s, %s, %s;", getArgSizeFromKind(accessKind), HSAIL.mapRegister(result), mapAddress(address), mapRegOrConstToString(cmpValue),
                         mapRegOrConstToString(newValue)));
     }
 
@@ -559,10 +534,17 @@
      *
      * @param result result operand that gets the original contents of the memory location
      * @param address the memory location
-     * @param deltaValue the amount to add
+     * @param delta the amount to add
      */
-    public void emitAtomicAdd(AllocatableValue result, HSAILAddress address, Value deltaValue) {
-        emitString(String.format("atomic_add_global_u%d   %s, %s, %s;", getArgSize(result), HSAIL.mapRegister(result), mapAddress(address), mapRegOrConstToString(deltaValue)));
+    public void emitAtomicAdd(AllocatableValue result, HSAILAddress address, Value delta) {
+        // ensure result and delta agree (this should probably be at some higher level)
+        Value mydelta = delta;
+        if (!isConstant(delta) && (getArgSize(result) != getArgSize(delta))) {
+            emitConvert(result, delta, result.getKind(), delta.getKind());
+            mydelta = result;
+        }
+        String prefix = getArgTypeForceUnsigned(result);
+        emitString(String.format("atomic_add_global_%s   %s, %s, %s;", prefix, HSAIL.mapRegister(result), mapAddress(address), mapRegOrConstToString(mydelta)));
     }
 
     /**
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAddress.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAddress.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.asm.ptx;
 
-import com.oracle.graal.lir.Variable;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.lir.*;
 
 /**
  * Represents an address in target machine memory, specified via some combination of a base register
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,17 +24,12 @@
 
 import static com.oracle.graal.api.code.ValueUtil.*;
 
-import com.oracle.graal.asm.Label;
-import com.oracle.graal.api.code.Register;
-import com.oracle.graal.api.code.RegisterConfig;
-import com.oracle.graal.api.code.TargetDescription;
-import com.oracle.graal.api.meta.Constant;
-import com.oracle.graal.api.meta.Kind;
-import com.oracle.graal.api.meta.Value;
-import com.oracle.graal.nodes.calc.Condition;
-import com.oracle.graal.graph.GraalInternalError;
-import com.oracle.graal.lir.LabelRef;
-import com.oracle.graal.lir.Variable;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.nodes.calc.*;
 
 public class PTXAssembler extends AbstractPTXAssembler {
 
@@ -375,7 +370,7 @@
             assert var instanceof Variable;
             assert val instanceof Constant;
             Constant constant = (Constant) val;
-            return ("[" + ((space == PTXStateSpace.Parameter) ? emitParameter((Variable) var) : emitRegister((Variable) var, false)) + " + " + constant.asBoxedValue() + "]");
+            return ("[" + ((space == PTXStateSpace.Parameter) ? emitParameter((Variable) var) : emitRegister((Variable) var, false)) + " + " + constant.toValueString() + "]");
         }
 
         @Override
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXMacroAssembler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXMacroAssembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,9 +25,9 @@
 import sun.misc.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.GraalInternalError;
 
 public class PTXMacroAssembler extends PTXAssembler {
 
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,7 +40,9 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
+import com.oracle.graal.java.BciBlockMapping.LocalLiveness;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert;
 import com.oracle.graal.nodes.cfg.*;
@@ -51,6 +53,25 @@
     protected LIRGenerator gen;
     private LIRGenerationResult lirGenRes;
     private BytecodeLIRBuilder lirBuilder;
+    @SuppressWarnings("unused") private BciBlock[] loopHeaders;
+    private LocalLiveness liveness;
+    private BciBlockBitMap blockVisited;
+
+    private class BciBlockBitMap {
+        BitSet bitSet;
+
+        public BciBlockBitMap(BciBlockMapping blockMap) {
+            bitSet = new BitSet(blockMap.blocks.size());
+        }
+
+        public boolean get(BciBlock block) {
+            return bitSet.get(block.getId());
+        }
+
+        public void set(BciBlock block) {
+            bitSet.set(block.getId());
+        }
+    }
 
     public BaselineBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
                     LIRFrameStateBuilder frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI, Backend backend) {
@@ -74,6 +95,9 @@
 
             // compute the block map, setup exception handlers and get the entrypoint(s)
             BciBlockMapping blockMap = BciBlockMapping.create(method);
+            loopHeaders = blockMap.loopHeaders;
+            liveness = blockMap.liveness;
+            blockVisited = new BciBlockBitMap(blockMap);
             // add predecessors
             for (BciBlock block : blockMap.blocks) {
                 for (BciBlock successor : block.getSuccessors()) {
@@ -85,9 +109,11 @@
                 throw GraalInternalError.unimplemented("Handle synchronized methods");
             }
 
-            // TODO: clear non live locals
+            frameState = new LIRFrameStateBuilder(method);
+            frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
 
             currentBlock = blockMap.startBlock;
+            blockMap.startBlock.entryState = frameState;
             if (blockMap.startBlock.isLoopHeader) {
                 throw GraalInternalError.unimplemented("Handle start block as loop header");
             }
@@ -95,7 +121,7 @@
             // add loops ? how do we add looks when we haven't parsed the bytecode?
 
             // create the control flow graph
-            LIRControlFlowGraph cfg = new LIRControlFlowGraph(blockMap.blocks.toArray(new BciBlock[0]), new Loop[0]);
+            LIRControlFlowGraph cfg = new LIRControlFlowGraph(blockMap);
 
             BlocksToDoubles blockProbabilities = new BlocksToDoubles(blockMap.blocks.size());
             for (BciBlock b : blockMap.blocks) {
@@ -107,7 +133,7 @@
             List<? extends AbstractBlock<?>> codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blockMap.blocks.size(), blockMap.startBlock, blockProbabilities);
             LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder);
 
-            FrameMap frameMap = backend.newFrameMap();
+            FrameMap frameMap = backend.newFrameMap(null);
             TargetDescription target = backend.getTarget();
             CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
             this.lirGenRes = backend.newLIRGenerationResult(lir, frameMap, null);
@@ -235,8 +261,7 @@
 
     @Override
     protected Value genIntegerMul(Kind kind, Value x, Value y) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+        return gen.emitMul(x, y);
     }
 
     @Override
@@ -371,7 +396,7 @@
         BciBlock trueBlock = currentBlock.getSuccessors().get(0);
         BciBlock falseBlock = currentBlock.getSuccessors().get(1);
         if (trueBlock == falseBlock) {
-            appendGoto(createTarget(trueBlock, frameState));
+            genGoto();
             return;
         }
 
@@ -390,21 +415,10 @@
             }
         }
 
-        // the mirroring and negation operations get the condition into canonical form
-        boolean mirror = cond.canonicalMirror();
-        boolean negate = cond.canonicalNegate();
-
-        Value a = mirror ? y : x;
-        Value b = mirror ? x : y;
+        LabelRef trueDestination = getSuccessor(0);
+        LabelRef falseDestination = getSuccessor(1);
 
-        LabelRef trueDestination = LabelRef.forSuccessor(lirGenRes.getLIR(), trueBlock, 0);
-        LabelRef falseDestination = LabelRef.forSuccessor(lirGenRes.getLIR(), falseBlock, 1);
-
-        if (negate) {
-            gen.emitCompareBranch(a, b, cond, false, falseDestination, trueDestination, 1 - probability);
-        } else {
-            gen.emitCompareBranch(a, b, cond, false, trueDestination, falseDestination, probability);
-        }
+        gen.emitCompareBranch(x.getKind(), x, y, cond, false, trueDestination, falseDestination, probability);
     }
 
     @Override
@@ -551,13 +565,7 @@
     }
 
     @Override
-    protected void setBlockSuccessor(Value switchNode, int i, Value createBlockTarget) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    @Override
-    protected Value genIntegerSwitch(Value value, int size, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
+    protected void genIntegerSwitch(Value value, ArrayList<BciBlock> actualSuccessors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
         // TODO Auto-generated method stub
         throw GraalInternalError.unimplemented("Auto-generated method stub");
     }
@@ -575,33 +583,126 @@
         return v;
     }
 
-    @Override
-    protected Value genDeoptimization() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+    private void createTarget(BciBlock block) {
+        assert block != null && frameState != null;
+        assert !block.isExceptionEntry || frameState.stackSize() == 1;
+
+        if (!blockVisited.get(block)) {
+            /*
+             * This is the first time we see this block as a branch target. Create and return a
+             * placeholder that later can be replaced with a MergeNode when we see this block again.
+             */
+            blockVisited.set(block);
+            if (block.getPredecessorCount() > 1) {
+                /*
+                 * If there are more than one predecessors we have to ensure that we are not passing
+                 * constants to the new framestate otherwise we will get interfacing problems.
+                 */
+                moveConstantsToVariables();
+            }
+            block.entryState = frameState.copy();
+            block.entryState.clearNonLiveLocals(block, liveness, true);
+
+            Debug.log("createTarget %s: first visit", block);
+            return;
+        }
+
+        // We already saw this block before, so we have to merge states.
+        if (!((LIRFrameStateBuilder) block.entryState).isCompatibleWith(frameState)) {
+            throw new BailoutException("stacks do not match; bytecodes would not verify");
+        }
+
+        if (block.isLoopHeader) {
+            assert currentBlock == null || currentBlock.getId() >= block.getId() : "must be backward branch";
+            if (currentBlock != null && currentBlock.numNormalSuccessors() == 1) {
+                // this is the only successor of the current block so we can adjust
+                adaptFramestate((LIRFrameStateBuilder) block.entryState);
+                return;
+            }
+            GraalInternalError.unimplemented("Loops not yet supported");
+        }
+        assert currentBlock == null || currentBlock.getId() < block.getId() : "must not be backward branch";
+
+        /*
+         * This is the second time we see this block. Create the actual MergeNode and the End Node
+         * for the already existing edge. For simplicity, we leave the placeholder in the graph and
+         * just append the new nodes after the placeholder.
+         */
+        if (currentBlock != null && currentBlock.numNormalSuccessors() == 1) {
+            // this is the only successor of the current block so we can adjust
+            adaptFramestate((LIRFrameStateBuilder) block.entryState);
+            return;
+        }
+        GraalInternalError.unimplemented("second block visit not yet implemented");
+
+        // merge frame states e.g. block.entryState.merge(mergeNode, target.state);
+
+        Debug.log("createTarget %s: merging state", block);
     }
 
-    @Override
-    protected Value createTarget(BciBlock trueBlock, AbstractFrameStateBuilder<Value> state) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+    private void moveConstantsToVariables() {
+        Debug.log("moveConstantsToVariables: framestate before: %s", frameState);
+        for (int i = 0; i < frameState.stackSize(); i++) {
+            Value src = frameState.stackAt(i);
+            if (src instanceof Constant) {
+                AllocatableValue dst = gen.newVariable(src.getPlatformKind());
+                gen.emitMove(dst, src);
+                frameState.storeStack(i, dst);
+                Debug.log("introduce new variabe %s for stackslot %d (end of block %s", dst, i, currentBlock);
+            }
+        }
+        for (int i = 0; i < frameState.localsSize(); i++) {
+            Value src = frameState.localAt(i);
+            if (src instanceof Constant) {
+                AllocatableValue dst = gen.newVariable(src.getPlatformKind());
+                gen.emitMove(dst, src);
+                frameState.storeLocal(i, dst);
+                Debug.log("introduce new variabe %s for local %d (end of block %s", dst, i, currentBlock);
+            }
+        }
+        Debug.log("moveConstantsToVariables: framestate after: %s", frameState);
     }
 
-    @Override
-    protected Value createBlockTarget(double probability, BciBlock bciBlock, AbstractFrameStateBuilder<Value> stateAfter) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+    private void adaptValues(Value dst, Value src) {
+        if (dst == null) {
+            return;
+        }
+        assert src != null : "Source is null but Destination is not!";
+
+        if (!dst.equals(src)) {
+            assert dst instanceof AllocatableValue : "Not an AllocatableValue: " + dst;
+            gen.emitMove((AllocatableValue) dst, src);
+        }
+    }
+
+    private void adaptFramestate(LIRFrameStateBuilder other) {
+        assert frameState.isCompatibleWith(other) : "framestates not compatible!";
+        for (int i = 0; i < frameState.stackSize(); i++) {
+            Value src = frameState.stackAt(i);
+            Value dst = other.stackAt(i);
+            adaptValues(dst, src);
+        }
+        for (int i = 0; i < frameState.localsSize(); i++) {
+            Value src = frameState.localAt(i);
+            Value dst = other.localAt(i);
+            adaptValues(dst, src);
+        }
     }
 
     @Override
     protected void processBlock(BciBlock block) {
+        frameState = (LIRFrameStateBuilder) block.entryState;
+        setCurrentFrameState(frameState);
+        currentBlock = block;
         iterateBytecodesForBlock(block);
     }
 
-    @Override
-    protected void appendGoto(Value target) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+    private boolean isBlockEnd() {
+        List<LIRInstruction> l = gen.getResult().getLIR().getLIRforBlock(currentBlock);
+        if (l.isEmpty()) {
+            return false;
+        }
+        return l.get(l.size() - 1) instanceof BlockEndOp;
     }
 
     @Override
@@ -633,13 +734,16 @@
             stream.next();
             bci = stream.currentBCI();
 
+            if (isBlockEnd()) {
+                break;
+            }
+
             if (bci < endBCI) {
                 if (bci > block.endBci) {
                     if (block.numNormalSuccessors() == 1) {
                         assert !block.getSuccessor(0).isExceptionEntry;
                         // we fell through to the next block, add a goto and break
-                        LabelRef label = LabelRef.forSuccessor(lirGenRes.getLIR(), block.getSuccessor(0), 0);
-                        gen.emitJump(label);
+                        genGoto();
                     }
                     break;
                 }
@@ -654,4 +758,14 @@
         frameState.storeLocal(i, x);
     }
 
+    LabelRef getSuccessor(int index) {
+        createTarget(currentBlock.getSuccessor(index));
+        return LabelRef.forSuccessor(lirGenRes.getLIR(), currentBlock, index);
+    }
+
+    @Override
+    protected void genGoto() {
+        gen.emitJump(getSuccessor(0));
+    }
+
 }
\ No newline at end of file
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,25 +23,15 @@
 package com.oracle.graal.baseline;
 
 import static com.oracle.graal.phases.GraalOptions.*;
-import static java.lang.reflect.Modifier.*;
 
-import java.lang.reflect.*;
-import java.util.*;
-
-import com.oracle.graal.alloc.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.bytecode.*;
 import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.alloc.*;
-import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.java.*;
-import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.phases.*;
 
 /**
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRBlock.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRBlock.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
         successors = Collections.emptyList();
     }
 
-    public Loop getLoop() {
+    public Loop<LIRBlock> getLoop() {
         // TODO Auto-generated method stub
         return null;
     }
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRControlFlowGraph.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRControlFlowGraph.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,24 +22,30 @@
  */
 package com.oracle.graal.baseline;
 
+import java.util.*;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.java.*;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
 import com.oracle.graal.nodes.cfg.*;
 
 public class LIRControlFlowGraph implements AbstractControlFlowGraph<BciBlock> {
 
     private BciBlock[] blocks;
-    private Loop[] loops;
+    private Collection<Loop<BciBlock>> loops;
+    private BitSet visited;
 
-    public LIRControlFlowGraph(BciBlock[] blocks, Loop[] loops) {
-        this.blocks = blocks;
-        this.loops = loops;
+    public LIRControlFlowGraph(BciBlockMapping blockMap) {
+        blocks = blockMap.blocks.toArray(new BciBlock[0]);
+        loops = new ArrayList<>();
+        computeLoopInformation();
     }
 
     public BciBlock[] getBlocks() {
         return blocks;
     }
 
-    public Loop[] getLoops() {
+    public Collection<Loop<BciBlock>> getLoops() {
         return loops;
     }
 
@@ -50,4 +56,44 @@
         return null;
     }
 
+    private void computeLoopInformation() {
+        visited = new BitSet(blocks.length);
+        Deque<LIRLoop> stack = new ArrayDeque<>();
+        for (int i = blocks.length - 1; i >= 0; i--) {
+            BciBlock block = blocks[i];
+            calcLoop(block, stack);
+        }
+    }
+
+    private void calcLoop(BciBlock block, Deque<LIRLoop> stack) {
+        if (visited.get(block.getId())) {
+            return;
+        }
+        visited.set(block.getId());
+        if (block.isLoopEnd()) {
+            BciBlock loopHeader = getLoopHeader(block);
+            LIRLoop l = new LIRLoop(stack.peek(), loops.size(), loopHeader);
+            loops.add(l);
+            stack.push(l);
+        }
+        block.loop = stack.peek();
+        if (block.isLoopHeader()) {
+            assert block.loop.header.equals(block);
+            stack.pop();
+        }
+        for (BciBlock pred : block.getPredecessors()) {
+            calcLoop(pred, stack);
+        }
+    }
+
+    private static BciBlock getLoopHeader(BciBlock block) {
+        assert block.isLoopEnd();
+        for (BciBlock sux : block.getSuccessors()) {
+            if (sux.isLoopHeader() && sux.getId() <= block.getId() && block.loops == sux.loops) {
+                return sux;
+            }
+        }
+        throw GraalInternalError.shouldNotReachHere("No loop header found for " + block);
+    }
+
 }
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRFrameStateBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRFrameStateBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,224 +26,78 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.java.*;
 
-public class LIRFrameStateBuilder extends AbstractFrameStateBuilder<Value> {
+public class LIRFrameStateBuilder extends AbstractFrameStateBuilder<Value, LIRFrameStateBuilder> {
 
-    private final Value[] locals;
-    private final Value[] stack;
-    private Value[] lockedObjects;
+    private static final Value[] EMPTY_ARRAY = new Value[0];
 
     public LIRFrameStateBuilder(ResolvedJavaMethod method) {
-        super(method);
-
-        this.locals = new Value[method.getMaxLocals()];
         // we always need at least one stack slot (for exceptions)
-        this.stack = new Value[Math.max(1, method.getMaxStackSize())];
+        super(method, new Value[method.getMaxLocals()], new Value[Math.max(1, method.getMaxStackSize())], EMPTY_ARRAY);
     }
 
     protected LIRFrameStateBuilder(LIRFrameStateBuilder other) {
         super(other);
-        // TODO Auto-generated constructor stub
-        locals = other.locals;
-        stack = other.stack;
-        lockedObjects = other.lockedObjects;
-    }
-
-    @Override
-    public int localsSize() {
-        return locals.length;
     }
 
     @Override
-    public Value localAt(int i) {
-        return locals[i];
-    }
-
-    @Override
-    public Value stackAt(int i) {
-        return stack[i];
-    }
-
-    @Override
-    public Value loadLocal(int i) {
-        Value x = locals[i];
-        assert !isTwoSlot(x.getKind()) || locals[i + 1] == null;
-        assert i == 0 || locals[i - 1] == null || !isTwoSlot(locals[i - 1].getKind());
-        return x;
+    protected Value[] getEmtpyArray() {
+        return EMPTY_ARRAY;
     }
 
     @Override
-    public void storeLocal(int i, Value x) {
-        assert x == null || x.getKind() != Kind.Void && x.getKind() != Kind.Illegal : "unexpected value: " + x;
-        locals[i] = x;
-        if (x != null && isTwoSlot(x.getKind())) {
-            // if this is a double word, then kill i+1
-            locals[i + 1] = null;
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[locals: [");
+        for (int i = 0; i < locals.length; i++) {
+            sb.append(i == 0 ? "" : ",").append(locals[i] == null ? "_" : locals[i].toString());
+        }
+        sb.append("] stack: [");
+        for (int i = 0; i < stackSize; i++) {
+            sb.append(i == 0 ? "" : ",").append(stack[i] == null ? "_" : stack[i].toString());
         }
-        if (x != null && i > 0) {
-            Value p = locals[i - 1];
-            if (p != null && isTwoSlot(p.getKind())) {
-                // if there was a double word at i - 1, then kill it
-                locals[i - 1] = null;
-            }
+        sb.append("] locks: [");
+        for (int i = 0; i < lockedObjects.length; i++) {
+            sb.append(i == 0 ? "" : ",").append(lockedObjects[i].toString());
         }
-    }
-
-    @Override
-    public void storeStack(int i, Value x) {
-        assert x == null || (stack[i] == null || x.getKind() == stack[i].getKind()) : "Method does not handle changes from one-slot to two-slot values or non-alive values";
-        stack[i] = x;
+        sb.append("]");
+        if (rethrowException) {
+            sb.append(" rethrowException");
+        }
+        sb.append("]");
+        return sb.toString();
     }
 
     @Override
-    public void push(Kind kind, Value x) {
-        assert x.getKind() != Kind.Void && x.getKind() != Kind.Illegal;
-        xpush(assertKind(kind, x));
-        if (isTwoSlot(kind)) {
-            xpush(null);
-        }
-    }
-
-    @Override
-    public void xpush(Value x) {
-        assert x == null || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal);
-        stack[stackSize++] = x;
-    }
-
-    @Override
-    public void ipush(Value x) {
-        xpush(assertInt(x));
+    public LIRFrameStateBuilder copy() {
+        return new LIRFrameStateBuilder(this);
     }
 
-    @Override
-    public void fpush(Value x) {
-        xpush(assertFloat(x));
-    }
-
-    @Override
-    public void apush(Value x) {
-        xpush(assertObject(x));
-    }
-
-    @Override
-    public void lpush(Value x) {
-        xpush(assertLong(x));
-    }
-
-    @Override
-    public void dpush(Value x) {
-        xpush(assertDouble(x));
+    private static boolean isCompatible(Value x, Value y) {
+        if (x == null && y == null) {
+            return true;
+        }
+        if ((x == null || y == null) || (x.getKind() != y.getKind())) {
+            return false;
+        }
+        return true;
 
     }
 
     @Override
-    public void pushReturn(Kind kind, Value x) {
-        if (kind != Kind.Void) {
-            push(kind.getStackKind(), x);
-        }
-    }
-
-    @Override
-    public Value pop(Kind kind) {
-        assert kind != Kind.Void;
-        if (isTwoSlot(kind)) {
-            xpop();
-        }
-        return assertKind(kind, xpop());
-    }
-
-    @Override
-    public Value xpop() {
-        Value result = stack[--stackSize];
-        return result;
-    }
-
-    @Override
-    public Value ipop() {
-        return assertInt(xpop());
-    }
-
-    @Override
-    public Value fpop() {
-        return assertFloat(xpop());
-    }
-
-    @Override
-    public Value apop() {
-        return assertObject(xpop());
-    }
-
-    @Override
-    public Value lpop() {
-        assertHigh(xpop());
-        return assertLong(xpop());
-    }
-
-    @Override
-    public Value dpop() {
-        assertHigh(xpop());
-        return assertDouble(xpop());
-    }
+    public boolean isCompatibleWith(LIRFrameStateBuilder other) {
+        assert method.equals(other.method) && localsSize() == other.localsSize() : "Can only compare frame states of the same method";
 
-    @Override
-    public Value[] popArguments(int slotSize, int argSize) {
-        int base = stackSize - slotSize;
-        Value[] r = new Value[argSize];
-        int argIndex = 0;
-        int stackindex = 0;
-        while (stackindex < slotSize) {
-            Value element = stack[base + stackindex];
-            assert element != null;
-            r[argIndex++] = element;
-            stackindex += stackSlots(element.getKind());
-        }
-        stackSize = base;
-        return r;
-    }
-
-    @Override
-    public Value peek(int argumentNumber) {
-        int idx = stackSize() - 1;
-        for (int i = 0; i < argumentNumber; i++) {
-            if (stackAt(idx) == null) {
-                idx--;
-                assert isTwoSlot(stackAt(idx).getKind());
-            }
-            idx--;
+        if (stackSize() != other.stackSize()) {
+            return false;
         }
-        return stackAt(idx);
-    }
-
-    private static Value assertKind(Kind kind, Value x) {
-        assert x != null && x.getKind() == kind : "kind=" + kind + ", value=" + x + ((x == null) ? "" : ", value.kind=" + x.getKind());
-        return x;
-    }
-
-    private static Value assertLong(Value x) {
-        assert x != null && (x.getKind() == Kind.Long);
-        return x;
-    }
-
-    private static Value assertInt(Value x) {
-        assert x != null && (x.getKind() == Kind.Int);
-        return x;
-    }
-
-    private static Value assertFloat(Value x) {
-        assert x != null && (x.getKind() == Kind.Float);
-        return x;
-    }
-
-    private static Value assertObject(Value x) {
-        assert x != null && (x.getKind() == Kind.Object);
-        return x;
-    }
-
-    private static Value assertDouble(Value x) {
-        assert x != null && (x.getKind() == Kind.Double);
-        return x;
-    }
-
-    private static void assertHigh(Value x) {
-        assert x == null;
+        for (int i = 0; i < stackSize(); i++) {
+            if (!isCompatible(stackAt(i), other.stackAt(i))) {
+                return false;
+            }
+        }
+        if (lockedObjects.length != other.lockedObjects.length) {
+            return false;
+        }
+        return true;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRLoop.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, 2014, 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.baseline;
+
+import com.oracle.graal.java.BciBlockMapping.BciBlock;
+import com.oracle.graal.nodes.cfg.*;
+
+public class LIRLoop extends Loop<BciBlock> {
+
+    protected LIRLoop(Loop<BciBlock> parent, int index, BciBlock header) {
+        super(parent, index, header);
+    }
+
+    @Override
+    public long numBackedges() {
+        // currently only loops with one backedge are supported
+        return 1;
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -246,8 +246,8 @@
     }
 
     @Override
-    public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) {
-        boolean mirrored = emitCompare(left, right);
+    public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) {
+        boolean mirrored = emitCompare(cmpKind, left, right);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
         switch (left.getKind().getStackKind()) {
             case Int:
@@ -276,8 +276,8 @@
     }
 
     @Override
-    public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
-        boolean mirrored = emitCompare(left, right);
+    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
+        boolean mirrored = emitCompare(cmpKind, left, right);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
 
         Variable result = newVariable(trueValue.getKind());
@@ -314,8 +314,16 @@
         }
     }
 
-    protected void emitCompareOp(Variable left, Value right) {
-        switch (left.getKind().getStackKind()) {
+    protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) {
+        switch ((Kind) cmpKind) {
+            case Byte:
+            case Boolean:
+                append(new CompareOp(BCMP, left, right));
+                break;
+            case Short:
+            case Char:
+                append(new CompareOp(SCMP, left, right));
+                break;
             case Int:
                 append(new CompareOp(ICMP, left, right));
                 break;
@@ -337,8 +345,16 @@
     }
 
     protected void emitCompareMemoryConOp(Kind kind, AMD64AddressValue address, Value value, LIRFrameState state) {
-        assert kind == value.getKind();
+        assert kind.getStackKind() == value.getKind().getStackKind();
         switch (kind) {
+            case Byte:
+            case Boolean:
+                append(new CompareMemoryOp(BCMP, kind, address, value, state));
+                break;
+            case Short:
+            case Char:
+                append(new CompareMemoryOp(SCMP, kind, address, value, state));
+                break;
             case Int:
                 append(new CompareMemoryOp(ICMP, kind, address, value, state));
                 break;
@@ -353,6 +369,14 @@
     protected void emitCompareRegMemoryOp(Kind kind, Value value, AMD64AddressValue address, LIRFrameState state) {
         AMD64Compare opcode = null;
         switch (kind) {
+            case Byte:
+            case Boolean:
+                opcode = BCMP;
+                break;
+            case Short:
+            case Char:
+                opcode = SCMP;
+                break;
             case Int:
                 opcode = ICMP;
                 break;
@@ -382,7 +406,7 @@
      * @param b the right operand of the comparison
      * @return true if the left and right operands were switched, false otherwise
      */
-    private boolean emitCompare(Value a, Value b) {
+    private boolean emitCompare(PlatformKind cmpKind, Value a, Value b) {
         Variable left;
         Value right;
         boolean mirrored;
@@ -395,7 +419,7 @@
             right = loadNonConst(b);
             mirrored = false;
         }
-        emitCompareOp(left, right);
+        emitCompareOp(cmpKind, left, right);
         return mirrored;
     }
 
@@ -876,7 +900,7 @@
             append(new BinaryRegConst(AMD64Arithmetic.LAND, result, asAllocatable(inputVal), Constant.forLong(mask)));
             return result;
         } else {
-            assert inputVal.getKind() == Kind.Int;
+            assert inputVal.getKind().getStackKind() == Kind.Int;
             Variable result = newVariable(Kind.Int);
             int mask = (int) IntegerStamp.defaultMask(fromBits);
             append(new BinaryRegConst(AMD64Arithmetic.IAND, result, asAllocatable(inputVal), Constant.forInt(mask)));
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64MemoryPeephole.java	Wed Apr 16 14:02:52 2014 +0200
@@ -76,8 +76,12 @@
         return null;
     }
 
+    protected Kind getMemoryKind(Access access) {
+        return (Kind) gen.getLIRGenerator().getPlatformKind(access.asNode().stamp());
+    }
+
     protected AMD64AddressValue makeAddress(Access access) {
-        return (AMD64AddressValue) access.nullCheckLocation().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(access.object()));
+        return (AMD64AddressValue) access.accessLocation().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(access.object()));
     }
 
     protected Value emitBinaryMemory(AMD64Arithmetic op, boolean commutative, ValueNode x, ValueNode y, Access access) {
@@ -90,7 +94,7 @@
             }
         }
         ensureEvaluated(other);
-        return gen.getLIRGenerator().emitBinaryMemory(op, access.nullCheckLocation().getValueKind(), gen.getLIRGeneratorTool().asAllocatable(gen.operand(other)), makeAddress(access), getState(access));
+        return gen.getLIRGenerator().emitBinaryMemory(op, getMemoryKind(access), gen.getLIRGeneratorTool().asAllocatable(gen.operand(other)), makeAddress(access), getState(access));
     }
 
     /**
@@ -129,7 +133,7 @@
 
     @Override
     public Value emitAddMemory(ValueNode x, ValueNode y, Access access) {
-        switch (access.nullCheckLocation().getValueKind()) {
+        switch (getMemoryKind(access)) {
             case Int:
                 return emitBinaryMemory(IADD, true, x, y, access);
             case Long:
@@ -145,7 +149,7 @@
 
     @Override
     public Value emitSubMemory(ValueNode x, ValueNode y, Access access) {
-        switch (access.nullCheckLocation().getValueKind()) {
+        switch (getMemoryKind(access)) {
             case Int:
                 return emitBinaryMemory(ISUB, false, x, y, access);
             case Long:
@@ -161,7 +165,7 @@
 
     @Override
     public Value emitMulMemory(ValueNode x, ValueNode y, Access access) {
-        switch (access.nullCheckLocation().getValueKind()) {
+        switch (getMemoryKind(access)) {
             case Int:
                 return emitBinaryMemory(IMUL, true, x, y, access);
             case Long:
@@ -187,7 +191,7 @@
 
     @Override
     public Value emitAndMemory(ValueNode x, ValueNode y, Access access) {
-        Kind kind = access.nullCheckLocation().getValueKind();
+        Kind kind = getMemoryKind(access);
         switch (kind) {
             case Int:
                 return emitBinaryMemory(IAND, true, x, y, access);
@@ -224,7 +228,7 @@
 
     @Override
     public Value emitOrMemory(ValueNode x, ValueNode y, Access access) {
-        switch (access.nullCheckLocation().getValueKind()) {
+        switch (getMemoryKind(access)) {
             case Int:
                 return emitBinaryMemory(IOR, true, x, y, access);
             case Long:
@@ -236,7 +240,7 @@
 
     @Override
     public Value emitXorMemory(ValueNode x, ValueNode y, Access access) {
-        switch (access.nullCheckLocation().getValueKind()) {
+        switch (getMemoryKind(access)) {
             case Int:
                 return emitBinaryMemory(IXOR, true, x, y, access);
             case Long:
@@ -249,7 +253,7 @@
     @Override
     public Value emitReinterpretMemory(Stamp stamp, Access access) {
         PlatformKind to = gen.getLIRGenerator().getPlatformKind(stamp);
-        Kind from = access.nullCheckLocation().getValueKind();
+        Kind from = getMemoryKind(access);
         assert to != from : "should have been eliminated";
 
         /*
@@ -353,10 +357,10 @@
     }
 
     @Override
-    public Value emitZeroExtendMemory(int inputBits, int resultBits, Access access) {
-        assert resultBits == 32 || resultBits == 64;
-        Kind memoryKind = access.nullCheckLocation().getValueKind();
-        if (memoryKind.getBitCount() != inputBits && !memoryKind.isUnsigned()) {
+    public Value emitZeroExtendMemory(int fromBits, int toBits, Access access) {
+        assert fromBits != toBits;
+        Kind memoryKind = getMemoryKind(access);
+        if (memoryKind.getBitCount() != fromBits && !memoryKind.isUnsigned()) {
             // The memory being read from is signed and smaller than the result size so
             // this is a sign extension to inputBits followed by a zero extension to resultBits
             // which can't be expressed in a memory operation.
@@ -366,7 +370,7 @@
             memoryKind = Kind.Char;
         }
         evaluateDeferred();
-        return gen.getLIRGenerator().emitZeroExtendMemory(memoryKind, resultBits, makeAddress(access), getState(access));
+        return gen.getLIRGenerator().emitZeroExtendMemory(memoryKind, toBits, makeAddress(access), getState(access));
     }
 
     public boolean emitIfMemory(IfNode x, Access access) {
@@ -399,7 +403,7 @@
 
     private boolean emitIntegerTestBranchMemory(ValueNode left, ValueNode right, Access access, LabelRef trueLabel, LabelRef falseLabel, double trueLabelProbability) {
         ValueNode other = selectOtherInput(left, right, access);
-        Kind kind = access.nullCheckLocation().getValueKind();
+        Kind kind = getMemoryKind(access);
         if (other.isConstant()) {
             if (kind != kind.getStackKind()) {
                 return false;
@@ -431,7 +435,7 @@
     protected ValueNode uncast(ValueNode value) {
         if (value instanceof UnsafeCastNode) {
             UnsafeCastNode cast = (UnsafeCastNode) value;
-            return cast.getOriginalValue();
+            return cast.getOriginalNode();
         }
         return value;
     }
@@ -439,7 +443,7 @@
     protected boolean emitCompareBranchMemory(ValueNode left, ValueNode right, Access access, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel,
                     double trueLabelProbability) {
         ValueNode other = selectOtherInput(left, right, access);
-        Kind kind = access.nullCheckLocation().getValueKind();
+        Kind kind = getMemoryKind(access);
         boolean mirrored = false;
 
         if (other.isConstant()) {
@@ -458,19 +462,11 @@
                     return false;
                 }
             }
-            if (kind != kind.getStackKind()) {
-                Debug.log("Skipping constant compares for stack kinds");
-                return false;
-            }
             ensureEvaluated(other);
             gen.getLIRGenerator().emitCompareMemoryConOp(kind, makeAddress(access), constant, getState(access));
             mirrored = uncast(right) == access;
         } else {
-            if (kind != kind.getStackKind()) {
-                // Register compares only work for stack kinds
-                Debug.log("Register compares only work for stack kinds");
-                return false;
-            } else if (kind == Kind.Object) {
+            if (kind == Kind.Object) {
                 // Can't compare against objects since they require encode/decode
                 Debug.log("Skipping compares for Object kinds");
                 return false;
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64NodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -72,7 +72,7 @@
                 FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) node;
                 if (((fixedWithNextNode instanceof IntegerDivNode) || (fixedWithNextNode instanceof IntegerRemNode)) && fixedWithNextNode.getClass() != divRem.getClass()) {
                     FixedBinaryNode otherDivRem = (FixedBinaryNode) fixedWithNextNode;
-                    if (otherDivRem.x() == divRem.x() && otherDivRem.y() == divRem.y() && operand(otherDivRem) == null) {
+                    if (otherDivRem.x() == divRem.x() && otherDivRem.y() == divRem.y() && !hasOperand(otherDivRem)) {
                         Value[] results = ((AMD64LIRGenerator) gen).emitIntegerDivRem(operand(divRem.x()), operand(divRem.y()), (DeoptimizingNode) valueNode);
                         if (divRem instanceof IntegerDivNode) {
                             setResult(divRem, results[0]);
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,6 +29,7 @@
  */
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.phases.GraalOptions.*;
+import static org.junit.Assume.*;
 
 import java.io.*;
 import java.lang.reflect.*;
@@ -54,7 +55,7 @@
         super(getHSAILBackend().isDeviceInitialized());
     }
 
-    private static HSAILHotSpotBackend getHSAILBackend() {
+    protected static HSAILHotSpotBackend getHSAILBackend() {
         Backend backend = runtime().getBackend(HSAIL.class);
         Assume.assumeTrue(backend instanceof HSAILHotSpotBackend);
         return (HSAILHotSpotBackend) backend;
@@ -102,6 +103,47 @@
         return (canGenerateCalls && canExecuteCalls);
     }
 
+    private static boolean supportsObjectAllocation() {
+        return true;
+    }
+
+    /**
+     * Determines if the runtime supports object allocation in HSAIL code.
+     */
+    public boolean canHandleObjectAllocation() {
+        return supportsObjectAllocation() && canDeoptimize();
+    }
+
+    /**
+     * Determines if the runtime supports deoptimization in HSAIL code.
+     */
+    public boolean canDeoptimize() {
+        return getHSAILBackend().getRuntime().getConfig().useHSAILDeoptimization;
+    }
+
+    /**
+     * Determines if the runtime supports {@link VirtualObject}s in {@link DebugInfo} associated
+     * with HSAIL code.
+     */
+    public boolean canHandleDeoptVirtualObjects() {
+        return false;
+    }
+
+    /**
+     * Determines if the runtime supports {@link StackSlot}s in {@link DebugInfo} associated with
+     * HSAIL code.
+     */
+    public boolean canHandleDeoptStackSlots() {
+        return false;
+    }
+
+    /**
+     * Determines if the runtime has the capabilities required by this test.
+     */
+    protected boolean supportsRequiredCapabilities() {
+        return true;
+    }
+
     @Override
     protected void dispatchKernelOkra(int range, Object... args) {
         HSAILHotSpotBackend backend = getHSAILBackend();
@@ -118,7 +160,7 @@
         }
     }
 
-    public static OptionValue<?> getOptionFromField(Class declaringClass, String fieldName) {
+    public static OptionValue<?> getOptionFromField(Class<?> declaringClass, String fieldName) {
         try {
             Field f = declaringClass.getDeclaredField(fieldName);
             f.setAccessible(true);
@@ -140,6 +182,7 @@
     @Override
     public void testGeneratedHsail() {
         try (OverrideScope s = getOverrideScope()) {
+            assumeTrue(supportsRequiredCapabilities());
             super.testGeneratedHsail();
         }
     }
@@ -147,8 +190,8 @@
     @Override
     public void testGeneratedHsailUsingLambdaMethod() {
         try (OverrideScope s = getOverrideScope()) {
+            assumeTrue(supportsRequiredCapabilities());
             super.testGeneratedHsailUsingLambdaMethod();
         }
     }
-
 }
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Wed Apr 16 14:02:52 2014 +0200
@@ -416,9 +416,9 @@
     }
 
     /**
-     * The dispatchLambdaKernel dispatches the lambda version of a kernel where the "kernel" is for
-     * the xxx$$Lambda.accept method in the wrapper for the lambda. Note that the useLambdaMethod
-     * boolean provides a way of actually invoking dispatchLambdaMethodKernel from this API.
+     * Dispatches the lambda version of a kernel where the "kernel" is for the xxx$$Lambda.accept
+     * method in the wrapper for the lambda. Note that the useLambdaMethod boolean provides a way of
+     * actually invoking dispatchLambdaMethodKernel from this API.
      */
     public void dispatchLambdaKernel(int range, MyIntConsumer consumer) {
         if (useLambdaMethod) {
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
+
 import java.lang.reflect.*;
 
 import org.junit.*;
@@ -343,12 +345,14 @@
     }
 
     private void test(final String snippet) {
-        try (Scope s = Debug.scope("HSAILCodeGen")) {
-            Method method = getMethod(snippet);
-            ExternalCompilationResult hsailCode = getBackend().compileKernel(getMetaAccess().lookupJavaMethod(method), false);
-            Debug.log("HSAIL code generated for %s:%n%s", snippet, hsailCode.getCodeString());
-        } catch (Throwable e) {
-            throw Debug.handle(e);
+        try (DebugConfigScope dcs = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
+            try (Scope s = Debug.scope("HSAILCodeGen")) {
+                Method method = getMethod(snippet);
+                ExternalCompilationResult hsailCode = getBackend().compileKernel(getMetaAccess().lookupJavaMethod(method), false);
+                Debug.log("HSAIL code generated for %s:%n%s", snippet, hsailCode.getCodeString());
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
         }
     }
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchBase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchBase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Base Class for tests that deopt but then catch the exception in the run routine itself.
@@ -55,6 +55,11 @@
     }
 
     @Override
+    protected boolean supportsRequiredCapabilities() {
+        return canDeoptimize();
+    }
+
+    @Override
     public void runTest() {
         setupArrays();
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany16384Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany16384Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 16384, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany20000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany20000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 20000, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany5000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany5000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 5000, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany8192Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany8192Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 8192, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654HighTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654HighTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 987654, deopt on many gids but then catch the exception in the run routine itself
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 987654, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany99999Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany99999Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 99999, deopt on many gids but then catch the exception in the run routine itself.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost1000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost1000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 1000, deopt on almost all gids but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 20000, deopt on almost all gids but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle16384Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle16384Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 16384, deopt on a single gid but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle20000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle20000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 20000, deopt on a single gid but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle5000Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle5000Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 5000, deopt on a single gid but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle8192Test.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle8192Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * For globalsize 8192, deopt on a single gid but then catch the exception in the run routine
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckDoubleNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckDoubleNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFailsInMiddleTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFailsInMiddleTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFloatNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFloatNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckInlineTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckInlineTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckLongNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckLongNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciInstanceTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CallTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,7 +24,7 @@
 
 import org.junit.*;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests direct method calls.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes a ClassCastException to test throwing the exception back to the
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test deliberately causes a ClassCastException to test throwing the exception back to the
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleAbsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleAbsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleCeilTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleCeilTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleFloorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleFloorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests double to long conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleNegTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleNegTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- /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/EscapingNewBase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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 java.util.Arrays;
+
+/**
+ * Base Class for tests that allocate escaping objects.
+ */
+
+public class EscapingNewBase extends GraalKernelTester {
+
+    final int NUM = getRange();
+
+    int getRange() {
+        return 24;
+    }
+
+    @Result public Object[] outArray = new Object[NUM];
+    public Object[] savedOutArray;
+    @Result public boolean savedOutArrayMatch1;
+    @Result public boolean savedOutArrayMatch2;
+    @Result public boolean savedOutArrayMatch3;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = null;
+        }
+    }
+
+    int getDispatches() {
+        return 1;
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        return canHandleObjectAllocation();
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchMethodKernel(NUM);
+        // use System.gc() to ensure new objects are in form that gc likes
+        System.gc();
+        savedOutArray = Arrays.copyOf(outArray, NUM);
+        savedOutArrayMatch1 = Arrays.equals(outArray, savedOutArray);
+        if (getDispatches() > 1) {
+            // redispatch kernel without gc
+            dispatchMethodKernel(NUM);
+            savedOutArrayMatch2 = Arrays.equals(outArray, savedOutArray);
+            // and one more time with gc
+            dispatchMethodKernel(NUM);
+            savedOutArrayMatch3 = Arrays.equals(outArray, savedOutArray);
+            System.gc();
+        }
+    }
+
+}
--- /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/EscapingNewFloatStringTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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;
+
+/**
+ * Tests creating a new String from a float.
+ */
+
+public class EscapingNewFloatStringTest extends EscapingNewBase {
+
+    @Result public String[] myOutArray = new String[NUM];
+
+    public void run(int gid) {
+        outArray[gid] = Float.toString(gid * 1.11f);
+        myOutArray[gid] = Float.toString(gid * 2.22f);
+    }
+
+    // problems runs out of memory space while inlining
+    // @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/EscapingNewFloatTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014, 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;
+
+public class EscapingNewFloatTest extends EscapingNewBase {
+    @Result Float[] myOutArray = new Float[NUM];
+
+    public void run(int gid) {
+        outArray[gid] = (gid + 1) * 1.11f;
+        myOutArray[gid] = (gid + 1) * 2.22f;
+    }
+
+    @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/EscapingNewIntArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, 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 allocation of an integer array per workitem.
+ */
+
+public class EscapingNewIntArrayTest extends EscapingNewBase {
+
+    public void run(int gid) {
+        int size = gid + 1;
+        int[] ary = new int[size];
+        for (int i = 0; i < ary.length; i++) {
+            ary[i] = i * 3;
+        }
+        outArray[gid] = ary;
+    }
+
+    private static final boolean DEBUG = Boolean.getBoolean("hsail.debug");
+
+    @Override
+    public void runTest() {
+        super.runTest();
+        if (DEBUG) {
+            for (int i = 0; i < NUM; i++) {
+                int[] ary = (int[]) outArray[i];
+                System.out.print("ary len " + ary.length + ":  ");
+                for (int val : ary) {
+                    System.out.print(val + ",");
+                }
+                System.out.println();
+            }
+        }
+    }
+
+    @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/EscapingNewIntegerTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a java.lang.Integer per workitem.
+ */
+
+public class EscapingNewIntegerTest extends EscapingNewBase {
+    @Result Integer[] myOutArray = new Integer[NUM];
+
+    public void run(int gid) {
+        outArray[gid] = (gid + 1) * 111;
+        myOutArray[gid] = (gid + 1) * 222;
+    }
+
+    @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/EscapingNewStoreFieldTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a Vec3 object stored in a field by workitem #1.
+ */
+
+public class EscapingNewStoreFieldTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    public float[] inArray = new float[NUM];
+    @Result public Vec3 outField;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+        }
+    }
+
+    public void run(int gid) {
+        if (gid == 1) {
+            float inval = inArray[gid];
+            outField = new Vec3(inval + 1, inval + 2, inval + 3);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchMethodKernel(NUM);
+
+        // see what happens if we do it again
+        dispatchMethodKernel(NUM);
+        System.gc();
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        return canHandleObjectAllocation();
+    }
+
+    @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/EscapingNewStringConcatTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014, 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 com.oracle.graal.debug.Debug.*;
+
+import org.junit.Test;
+
+import com.oracle.graal.debug.*;
+
+/**
+ * Tests allocation of a new String based on string concatenation.
+ */
+
+public class EscapingNewStringConcatTest extends EscapingNewBase {
+
+    @Result public String[] myOutArray = new String[NUM];
+    public String[] inArray = new String[NUM];
+
+    @Override
+    void setupArrays() {
+        super.setupArrays();
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = Integer.toString(i + 100);
+        }
+    }
+
+    public void run(int gid) {
+        outArray[gid] = inArray[gid] + inArray[(gid + NUM / 2) % NUM];
+        myOutArray[gid] = inArray[(gid + NUM / 2) % NUM] + inArray[gid];
+    }
+
+    // Node implementing Lowerable not handled in HSAIL Backend: 6274|MonitorEnter
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            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/EscapingNewStringInternTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, 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 com.oracle.graal.debug.Debug.*;
+
+import org.junit.Test;
+
+import com.oracle.graal.debug.*;
+
+/**
+ * Tests allocation of a new String based on string interning.
+ */
+
+public class EscapingNewStringInternTest extends EscapingNewBase {
+
+    public void run(int gid) {
+        outArray[gid] = Integer.toString(gid * 111).intern();
+    }
+
+    // at node: 12|Invoke#Direct#intern
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            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/EscapingNewStringLargeRangeTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new String from integer with a large range of workitems.
+ */
+
+public class EscapingNewStringLargeRangeTest extends EscapingNewStringTest {
+
+    @Override
+    int getRange() {
+        return 125000;
+    }
+
+    @Override
+    @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/EscapingNewStringTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new String from an integer per workitem.
+ */
+
+public class EscapingNewStringTest extends EscapingNewBase {
+
+    @Result public String[] myOutArray = new String[NUM];
+
+    public void run(int gid) {
+        outArray[gid] = Integer.toString(gid * 111);
+        myOutArray[gid] = Integer.toString(gid * 222);
+    }
+
+    @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/EscapingNewVec3ArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, 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 allocation of an array of Vec3 objects per workitem.
+ */
+
+public class EscapingNewVec3ArrayTest extends EscapingNewBase {
+
+    public void run(int gid) {
+        int size = gid + 1;
+        Vec3[] vec3ary = new Vec3[size];
+        for (int i = 0; i < vec3ary.length; i++) {
+            vec3ary[i] = new Vec3(size + i + 1.1f, size + i + 2.2f, size + i + 3.3f);
+        }
+        outArray[gid] = vec3ary;
+    }
+
+    private static final boolean DEBUG = Boolean.getBoolean("hsail.debug");
+
+    @Override
+    public void runTest() {
+        super.runTest();
+        if (DEBUG) {
+            System.out.println("dumping results");
+            for (int i = 0; i < NUM; i++) {
+                Vec3[] ary = (Vec3[]) outArray[i];
+                System.out.print("ary len " + ary.length + ":  ");
+                for (Vec3 val : ary) {
+                    System.out.print(val + ", ");
+                }
+                System.out.println();
+            }
+        }
+    }
+
+    @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/EscapingNewVec3Base.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, 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;
+
+/**
+ * Base class for Vec3 object allocation tests.
+ */
+
+public class EscapingNewVec3Base extends EscapingNewBase {
+
+    float[] inArray = new float[NUM];
+    @Result Vec3[] myOutArray = new Vec3[NUM];
+
+    @Override
+    void setupArrays() {
+        super.setupArrays();
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            myOutArray[i] = null;
+        }
+    }
+
+    public void run(int gid) {
+        float inval = inArray[gid];
+        // allocate and store in Object array
+        outArray[gid] = new Vec3(inval + 1.1f, inval + 2.1f, inval + 3.1f);
+        // allocate and store in Vec3 array
+        myOutArray[gid] = new Vec3(inval + 4.1f, inval + 5.1f, inval + 6.1f);
+    }
+}
--- /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/EscapingNewVec3LargeRangeDisp3Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object with a large range of workitems with 3 dispatches.
+ */
+
+public class EscapingNewVec3LargeRangeDisp3Test extends EscapingNewVec3Test {
+
+    @Override
+    int getRange() {
+        return 250000;
+    }
+
+    @Override
+    int getDispatches() {
+        return 3;
+    }
+
+    @Override
+    @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/EscapingNewVec3LargeRangeTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object with a large range of workitems.
+ */
+
+public class EscapingNewVec3LargeRangeTest extends EscapingNewVec3Test {
+
+    @Override
+    int getRange() {
+        return 250000;
+    }
+
+    @Override
+    @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/EscapingNewVec3MediumRangeTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object with a medium range of workitems.
+ */
+
+public class EscapingNewVec3MediumRangeTest extends EscapingNewVec3Test {
+
+    @Override
+    int getRange() {
+        return 100000;
+    }
+
+    @Override
+    @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/EscapingNewVec3Partial2Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object but skipping one workitem.
+ */
+
+public class EscapingNewVec3Partial2Test extends EscapingNewVec3Base {
+
+    int testGid = NUM / 2;
+
+    @Override
+    public void run(int gid) {
+        float inval = inArray[gid];
+        if (gid != testGid) {
+            outArray[gid] = new Vec3(inval + 1.1f, inval + 2.1f, inval + 3.1f);
+            myOutArray[gid] = new Vec3(inval + 4.1f, inval + 5.1f, inval + 6.1f);
+        }
+    }
+
+    @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/EscapingNewVec3PartialTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object but only for half of the workitems.
+ */
+
+public class EscapingNewVec3PartialTest extends EscapingNewVec3Base {
+
+    @Override
+    public void run(int gid) {
+        float inval = inArray[gid];
+        outArray[gid] = (gid % 2 == 0 ? new Vec3(inval + 1.1f, inval + 2.1f, inval + 3.1f) : null);
+        myOutArray[gid] = (gid % 2 != 0 ? new Vec3(inval + 4.1f, inval + 5.1f, inval + 6.1f) : null);
+    }
+
+    @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/EscapingNewVec3Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, 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 allocation of a new Vec3 object per workitem.
+ */
+
+public class EscapingNewVec3Test extends EscapingNewVec3Base {
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixBase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixBase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Base class used by other Float2DMatrix tests.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests 2D array access for Matrix Multiplication.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatAbsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatAbsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests floating point comparison.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDivPrecisionTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDivPrecisionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * This test (originally derived from a discrepancy seen in Mandel) showed a difference in the
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests float to long conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatNegTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatNegTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- /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/FloatSqrtTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
+
+/**
+ * Tests floating point square root.
+ */
+public class FloatSqrtTest extends GraalKernelTester {
+
+    static final int size = 64;
+    float[] input = new float[size];
+    @Result float[] output = new float[size];
+    {
+        for (int i = 0; i < size; i++) {
+            input[i] = i;
+            output[i] = -1.0f;
+        }
+
+    }
+
+    public static void run(float[] input1, float[] output1, int gid) {
+        output1[gid] = (float) Math.sqrt(input1[gid]);
+    }
+
+    @Override
+    public void runTest() {
+        dispatchMethodKernel(size, input, output);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/InstanceOfTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/InstanceOfTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests instanceof operator. Requires correct support for decompression of klass ptrs.
--- /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/InstanceOfTwoLevelTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,118 @@
+/*
+ * 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;
+
+public class InstanceOfTwoLevelTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    static abstract class Shape {
+        abstract public float getArea();
+    }
+
+    static class Ellipse extends Shape {
+        private float major;
+        private float minor;
+
+        Ellipse(float major, float minor) {
+            this.major = major;
+            this.minor = minor;
+        }
+
+        public float getEccentricity() {
+            float a = major / 2;
+            float b = minor / 2;
+            return (float) Math.sqrt(1 - (b / a) * (b / a));
+        }
+
+        @Override
+        public float getArea() {
+            float a = major / 2;
+            float b = minor / 2;
+            return (float) (Math.PI * a * b);
+        }
+    }
+
+    static class Circle extends Ellipse {
+        Circle(float r) {
+            super(2 * r, 2 * r);
+        }
+    }
+
+    static class Square extends Shape {
+        private float len;
+
+        Square(float _len) {
+            len = _len;
+        }
+
+        @Override
+        public float getArea() {
+            return len * len;
+        }
+    }
+
+    @Result public float[] outArray = new float[NUM];
+    public Object[] inShapeArray = new Object[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            switch (i % 4) {
+                case 0:
+                    inShapeArray[i] = new Circle(i + 1);
+                    break;
+                case 1:
+                    inShapeArray[i] = new Square(i + 1);
+                    break;
+                case 2:
+                    inShapeArray[i] = new Ellipse(i + 1, i + 2);
+                    break;
+                case 3:
+                    inShapeArray[i] = new Object();
+                    break;
+            }
+            outArray[i] = -i;
+        }
+    }
+
+    public void run(int gid) {
+        outArray[gid] = (inShapeArray[gid] instanceof Shape ? 1.0f : 2.0f);
+    }
+
+    @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/IntAbsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAbsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddIndexTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddIndexTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests array element addition.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests integer addition.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseNotTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseNotTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftLeftTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftLeftTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightUnsignedTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightUnsignedTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests integer to byte conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests integer to char conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDivTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDivTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests integer division.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubledTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubledTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests doubling an integer value.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests integer to long conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLookupSwitchTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLookupSwitchTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntModTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntModTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests modulo operation.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntMulTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntMulTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests array multiplication.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntNegTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntNegTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,10 @@
 package com.oracle.graal.compiler.hsail.test;
 
 import java.util.*;
+
 import org.junit.*;
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests integer to short conversion.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSqrAddTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSqrAddTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests array addition and multiplication.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredGidCmpTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredGidCmpTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests comparison operation and array multiplication.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTernaryTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTernaryTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests conditionals, modulo arithmetic, and addition and multiplications.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests squaring an array element.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCatchNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCatchNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckNonZeroBciTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckNonZeroBciTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullNonArrayParamCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullNonArrayParamCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests one of the kernel parameters being null.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullParamCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullParamCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests one of the kernel parameters being null.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSubTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSubTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests subtracting one array element from another.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSumArrayTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSumArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
 
 /**
  * Tests iteratively summing the elements of an array.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTableSwitchTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTableSwitchTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- /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/IntTestBranchTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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 code generation for IntegerTestNode for HSAIL backend.
+ */
+public class IntTestBranchTest extends StaticMethodTwoIntArrays {
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     * @param out
+     * @param in
+     * @param gid
+     */
+    public static void run(int[] out, int[] in, int gid) {
+        if ((in[gid] & 3) != 0) {
+            out[gid] = in[gid] * 2;
+        } else {
+            out[gid] = in[gid] * 3;
+        }
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongAbsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongAbsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseNotTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseNotTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftLeftTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftLeftTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightUnsignedTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightUnsignedTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongModTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongModTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests the remainder operation (%) on two longs. Generates a rem_s64 instruction.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongNegTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongNegTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
+import org.junit.*;
+
 import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
--- /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/NestedStaticCallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,85 @@
+/*
+ * 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.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests direct method calls.
+ */
+public class NestedStaticCallTest extends GraalKernelTester {
+
+    static final int width = 768;
+    static final int height = width;
+    private int iterations = 100;
+    static final int range = width * height;
+    @Result public float[] outArray = new float[range];
+
+    public static int a(int i) {
+        if (i < 2) {
+            return b(i);
+        } else {
+            return i;
+        }
+    }
+
+    public static int b(int i) {
+        if (i < 90) {
+            return c(i) + i;
+        } else {
+            return d(i) - i;
+        }
+    }
+
+    public static int c(int i) {
+
+        return d(i) + 5;
+    }
+
+    public static int d(int i) {
+
+        return e(i) + 10;
+    }
+
+    public static int e(int i) {
+        return 52 + i;
+    }
+
+    public void run(int gid) {
+        for (int i = 0; i < iterations; i++) {
+            outArray[gid] = a(gid) + i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        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/NestedVirtualCallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,85 @@
+/*
+ * 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.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests direct method calls.
+ */
+public class NestedVirtualCallTest extends GraalKernelTester {
+
+    static final int width = 768;
+    static final int height = width;
+    private int iterations = 100;
+    static final int range = width * height;
+    @Result public float[] outArray = new float[range];
+
+    public int a(int i) {
+        if (i < 2) {
+            return b(i);
+        } else {
+            return i;
+        }
+    }
+
+    public int b(int i) {
+        if (i < 90) {
+            return c(i) + i;
+        } else {
+            return d(i) - i;
+        }
+    }
+
+    public int c(int i) {
+
+        return d(i) + 5;
+    }
+
+    public int d(int i) {
+
+        return e(i) + 10;
+    }
+
+    public int e(int i) {
+        return 52 + i;
+    }
+
+    public void run(int gid) {
+        for (int i = 0; i < iterations; i++) {
+            outArray[gid] = a(gid) + i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        dispatchMethodKernel(range);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests the storing of objects into an array.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/SingleExceptionTestBase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/SingleExceptionTestBase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,10 +23,10 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
- * 
+ *
  * @author ecaspole
  */
 public abstract class SingleExceptionTestBase extends GraalKernelTester {
@@ -35,6 +35,11 @@
     @Result String exceptionString;
     @Result StackTraceElement firstStackTraceElement;
 
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        return canDeoptimize();
+    }
+
     void recordException(Exception e) {
         // for now we just test that the class the of the exception
         // matches for the java and gpu side
--- /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/StaticCallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests direct method calls.
+ */
+public class StaticCallTest extends GraalKernelTester {
+
+    static final int width = 768;
+    static final int height = width;
+    private int iterations = 100;
+    static final int range = width * height;
+    @Result public float[] outArray = new float[range];
+
+    public static int foo(int gid, int i) {
+        if (gid < 2) {
+            return bar(gid, i);
+        } else {
+            return gid + i;
+        }
+    }
+
+    public static int bar(int gid, int i) {
+        if (gid < 90) {
+            return gid + i;
+        } else {
+            return gid - i;
+        }
+    }
+
+    public void run(int gid) {
+        for (int i = 0; i < iterations; i++) {
+            outArray[gid] = bar(gid, i);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        dispatchMethodKernel(range);
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,9 +24,9 @@
 
 import java.util.*;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests the spilling of double variables into memory.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticIntSpillTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticIntSpillTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,9 +24,9 @@
 
 import java.util.*;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests the spilling of integers into memory.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelBoundsCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelBoundsCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
-import static org.junit.Assume.*;
+import org.junit.*;
 
 /**
  * Unit test that simulates the Mandelbrot application. The run method here is a static method
@@ -83,7 +82,6 @@
 
     @Test
     public void test() {
-        assumeTrue(runningOnSimulator());
         testGeneratedHsail();
     }
 }
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,9 +23,8 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
-import static org.junit.Assume.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Unit test that simulates the Mandelbrot application. The run method here is a static method
@@ -80,7 +79,6 @@
 
     @Test
     public void test() {
-        assumeTrue(runningOnSimulator());
         testGeneratedHsail();
     }
 }
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,10 +23,11 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
+
 import org.junit.*;
 
 import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.internal.*;
 
 /**
  * Tests the addition of elements from sixteen input arrays.
@@ -64,15 +65,7 @@
     @Test(expected = java.lang.ClassCastException.class)
     @Ignore("until GPU backends can co-exist")
     public void test() {
-        DebugConfig debugConfig = DebugScope.getConfig();
-        DebugConfig noInterceptConfig = new DelegatingDebugConfig(debugConfig) {
-            @Override
-            public RuntimeException interceptException(Throwable e) {
-                return null;
-            }
-        };
-
-        try (DebugConfigScope s = Debug.setConfig(noInterceptConfig)) {
+        try (DebugConfigScope s = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
             testGeneratedHsail();
         }
     }
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethodTwoIntArrays.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethodTwoIntArrays.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Superclass that initializes one input array and one output array. Derived by some of the other
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyCallTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyCallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,6 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import static org.junit.Assume.*;
-
 import org.junit.*;
 
 /**
@@ -39,7 +37,6 @@
 
     @Override
     public void runTest() {
-        assumeTrue(aggressiveInliningEnabled() || canHandleHSAILMethodCalls());
         super.runTest();
     }
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,9 +23,7 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import org.junit.Test;
-
-import static org.junit.Assume.*;
+import org.junit.*;
 
 /**
  * Tests codegen for String.contains() but with a wrapper method such as one would get in the
@@ -42,7 +40,6 @@
 
     @Override
     public void runTest() {
-        assumeTrue(aggressiveInliningEnabled() || canHandleHSAILMethodCalls());
         setupArrays();
 
         dispatchMethodKernel(NUM);
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for String.contains().
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringEqualsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringEqualsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 public class StringEqualsTest extends GraalKernelTester {
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for String.indexOf().
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringSwitchTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringSwitchTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,10 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import static org.junit.Assume.*;
+import org.junit.*;
 
-import org.junit.Test;
-import com.oracle.graal.compiler.hsail.test.infra.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
 
 /**
  * Tests switch statement with String literal keys.
@@ -120,14 +119,8 @@
         }
     }
 
-    /**
-     * Tests the HSAIL code generated for this unit test by comparing the result of executing this
-     * code with the result of executing a sequential Java version of this unit test.
-     */
     @Test
     public void test() {
-        // This test is only run if inlining is enabled since it requires method call support.
-        assumeTrue(aggressiveInliningEnabled() || canHandleHSAILMethodCalls());
         super.testGeneratedHsail();
     }
 
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamFloatCaptureTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamFloatCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for a java 7 style object array stream kernel, one float capture.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntCaptureTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for a java 7 style object array stream kernel, one int capture.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntFloatCaptureTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntFloatCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for a java 7 style object array stream kernel, with one int and one float capture.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjCaptureTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for a java 7 style object array stream kernel, one object capture.
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjFieldTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjFieldTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.compiler.hsail.test;
 
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-import org.junit.Test;
+import org.junit.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.*;
 
 /**
  * Tests codegen for a java 7 style object array stream kernel, no captures. Instance method which
--- /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/VolatileIntTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+/**
+ * 
+ * @author ecaspole
+ */
+public class VolatileIntTest extends GraalKernelTester {
+
+    static final int num = 20;
+    @Result protected int[] outArray = new int[num];
+
+    volatile int theVolatileInt = 42;
+
+    /**
+     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
+     * 
+     */
+    public void run(int[] out, int[] ina, int[] inb, int gid) {
+
+        // Note these array ops are not really part of the test results
+        int x = theVolatileInt;
+
+        out[gid] = ina[gid] + inb[gid];
+
+        theVolatileInt = x;
+    }
+
+    @Test
+    public void test() {
+        super.testGeneratedHsail();
+    }
+
+    void setupArrays(int[] in, int[] in2) {
+        for (int i = 0; i < num; i++) {
+            in[i] = 1;
+            in2[i] = 2;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        int[] inArray = new int[num];
+        int[] inArray2 = new int[num];
+        setupArrays(inArray, inArray2);
+
+        dispatchMethodKernel(num, outArray, inArray, inArray2);
+    }
+
+}
--- /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/lambda/ArrayFieldAccessTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests accessing a field which is an array.
+ */
+public class ArrayFieldAccessTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * 3;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ArrayListGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+/**
+ * Tests calling ArrayList.get().
+ */
+public class ArrayListGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public ArrayList<Integer> inList = new ArrayList<>();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inList.add(i);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            int val = inList.get(gid);
+            outArray[gid] = val * val + 1;
+        });
+    }
+
+    // NYI emitForeignCall charAlignedDisjointArraycopy
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- /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/lambda/ArrayListStreamTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,190 @@
+/*
+ * 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.lambda;
+
+import java.util.ArrayList;
+import java.util.stream.Stream;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+/**
+ * Tests using ArrayLists as streams.
+ */
+public class ArrayListStreamTest {
+
+    // Static and instance fields to test codegen for
+    // each type of variable
+    static int staticSize = 16;
+    final int size = staticSize;
+
+    static int staticFactor = 3;
+    final int factor = staticFactor;
+
+    class MyPoint {
+
+        int x;
+        int y;
+
+        public MyPoint(int _x, int _y) {
+            x = _x;
+            y = _y;
+        }
+    }
+
+    public ArrayList<MyPoint> buildMyPointInputArray() {
+        ArrayList<MyPoint> inputs = new ArrayList<>(size);
+
+        for (int i = 0; i < size; i++) {
+            inputs.add(new MyPoint(i, i + 1));
+        }
+        return inputs;
+    }
+
+    public int[] buildIntInputArray() {
+        int[] inputs = new int[size];
+
+        for (int i = 0; i < size; i++) {
+            inputs[i] = i * 4;
+        }
+        return inputs;
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCaptures() {
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            // Swap the values
+            int tmp = p.x;
+            p.x = p.y + factor;
+            p.y = tmp;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + factor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCapturesUseStatic() {
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            // Swap the values
+            int tmp = p.x;
+            p.x = p.y + staticFactor;
+            p.y = tmp;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + staticFactor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCapture() {
+        int[] data = buildIntInputArray();
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCaptureUseStatic() {
+        int[] data = buildIntInputArray();
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == (data[p.x] + +staticFactor));
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCaptures() {
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + data2[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCapturesUseStatic() {
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+        ArrayList<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + data2[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x] + staticFactor);
+        }
+
+    }
+}
--- /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/lambda/AtomicIntAddAndGetGidTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,84 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#addAndGet(int)} with a variable delta.
+ */
+public class AtomicIntAddAndGetGidTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    public int[] outArray = new int[NUM];
+    @Result public int[] gaps = new int[NUM];
+    AtomicInteger atomicInt;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+        atomicInt = new AtomicInteger(0);
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.addAndGet(gid);
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+        // System.out.print("outArray: ");
+        // for (int val : outArray) {
+        // System.out.print(val + ", ");
+        // }
+        // System.out.println();
+        // create array of gaps
+        gaps[0] = outArray[0] - 0;
+        for (int i = 1; i < NUM; i++) {
+            gaps[i] = outArray[i] - outArray[i - 1];
+        }
+        Arrays.sort(gaps);
+
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntAddAndGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#addAndGet(int)} with the delta being a constant.
+ */
+public class AtomicIntAddAndGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.addAndGet(0x7);
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntDecAndGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#decrementAndGet()}.
+ */
+public class AtomicIntDecAndGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.decrementAndGet();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntGetAndAddTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#getAndAdd(int)} with the delta being a constant.
+ */
+public class AtomicIntGetAndAddTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.getAndAdd(0x7);
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntGetAndDecTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#getAndDecrement()}.
+ */
+public class AtomicIntGetAndDecTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.getAndDecrement();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntGetAndIncTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#getAndIncrement()}.
+ */
+public class AtomicIntGetAndIncTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.getAndIncrement();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicIntIncAndGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicInteger#incrementAndGet()}.
+ */
+public class AtomicIntIncAndGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    AtomicInteger atomicInt = new AtomicInteger();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicInt.incrementAndGet();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicLongAddAndGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+import org.junit.Test;
+
+import java.util.concurrent.atomic.*;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicLong#addAndGet(long)} with the delta being a constant.
+ */
+public class AtomicLongAddAndGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    AtomicLong atomicLong = new AtomicLong();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicLong.addAndGet(0x7);
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicLongGetAndAddTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicLong#getAndAdd(long)} with the delta being a constant.
+ */
+public class AtomicLongGetAndAddTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    AtomicLong atomicLong = new AtomicLong();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicLong.getAndAdd(0x7);
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicLongGetAndIncTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicLong#getAndIncrement()}.
+ */
+public class AtomicLongGetAndIncTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    AtomicLong atomicLong = new AtomicLong();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicLong.getAndIncrement();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/AtomicLongIncAndGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.Arrays;
+
+/**
+ * Tests {@link AtomicLong#incrementAndGet()}.
+ */
+public class AtomicLongIncAndGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    AtomicLong atomicLong = new AtomicLong();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = atomicLong.incrementAndGet();
+        });
+
+        // note: the actual order of entries in outArray is not predictable
+        // thus we sort before we compare results
+        Arrays.sort(outArray);
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/BigIntegerSquaredTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import java.math.BigInteger;
+
+/**
+ * Tests squaring a BigInteger.
+ */
+public class BigIntegerSquaredTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public BigInteger[] inArray = new BigInteger[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new BigInteger(Integer.toString(i));
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid].multiply(inArray[gid]).intValue();
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        // recursive calls
+        return (canHandleHSAILMethodCalls());
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Body.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,113 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * A Body object derived from Vec3 used in NBody tests.
+ */
+public class Body extends Vec3 {
+
+    public Body(float _x, float _y, float _z, float _m) {
+        super(_x, _y, _z);
+        m = _m;
+        v = new Vec3(0, 0, 0);
+    }
+
+    float m;
+    Vec3 v;
+
+    public float getX() {
+        return x;
+    }
+
+    public float getY() {
+        return y;
+    }
+
+    public float getZ() {
+        return z;
+    }
+
+    public float getVx() {
+        return v.x;
+    }
+
+    public float getVy() {
+        return v.y;
+    }
+
+    public float getVz() {
+        return v.z;
+    }
+
+    public float getM() {
+        return m;
+    }
+
+    public void setM(float _m) {
+        m = _m;
+    }
+
+    public void setX(float _x) {
+        x = _x;
+    }
+
+    public void setY(float _y) {
+        y = _y;
+    }
+
+    public void setZ(float _z) {
+        z = _z;
+    }
+
+    public void setVx(float _vx) {
+        v.x = _vx;
+    }
+
+    public void setVy(float _vy) {
+        v.y = _vy;
+    }
+
+    public void setVz(float _vz) {
+        v.z = _vz;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof Body)) {
+            return false;
+        }
+        Body oth = (Body) other;
+        return (oth.x == x && oth.y == y && oth.z == z && oth.m == m && v.equals(oth.v));
+    }
+
+    @Override
+    public int hashCode() {
+        // TODO Auto-generated method stub
+        return super.hashCode();
+    }
+
+}
--- /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/lambda/ByteArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests reading from a byte array.
+ */
+public class ByteArrayTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public byte[] inArray = new byte[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = (byte) ((i + 1) * (i % 3 == 0 ? 1 : -1));
+            outArray[i] = 99;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/CountMatchesBase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,47 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Base class for tests that use Apache StringUtils.countMatches().
+ */
+public abstract class CountMatchesBase extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public String[] inArray = new String[NUM];
+
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + (i % 10));
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, i, 40);
+        }
+    }
+
+}
--- /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/lambda/DoubleFieldAccessTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests accessing a double field.
+ */
+public class DoubleFieldAccessTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public double[] outArray = new double[NUM];
+    public double[] inArray = new double[NUM];
+
+    double doubleField = 7.0;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        double[] out = outArray;
+        double[] in = inArray;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            out[gid] = in[gid] + doubleField;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/FibRecursionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,74 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests a recursive method invocation.
+ */
+public class FibRecursionTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    int fib(int n) {
+        return (n <= 2 ? 1 : fib(n - 2) + fib(n - 1));
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = fib(inArray[gid]);
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        // recursive calls
+        return (canHandleHSAILMethodCalls());
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Float2DMatrixBase.java	Wed Apr 16 14:02:52 2014 +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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Base class for 2D float matrix 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/lambda/Float2DMatrixMultiplyRangeFinalTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,60 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests 2D float matrix multiply with range being final.
+ */
+public class Float2DMatrixMultiplyRangeFinalTest extends Float2DMatrixBase {
+
+    static final int range = 6;
+
+    @Override
+    public void runTest() {
+        setupArrays(range);
+
+        dispatchLambdaKernel(range, (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;
+            }
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Float2DMatrixMultiplySingleOutTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests 2D float matrix multiply with each workitem outputting one entry of the result matrix.
+ */
+public class Float2DMatrixMultiplySingleOutTest extends Float2DMatrixBase {
+
+    @Override
+    public void runTest() {
+        int range = 20;
+        setupArrays(range);
+
+        dispatchLambdaKernel(range * range, (gid) -> {
+            int i = gid % range;
+            int j = gid / range;
+            float sum = 0;
+            for (int k = 0; k < range; k++) {
+                sum += (matrixA[i][k] * matrixB[k][j]);
+            }
+            outMatrix[i][j] = sum;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Float2DMatrixMultiplyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests 2D float matrix multiply with each workitem outputting one row of the result matrix.
+ */
+public class Float2DMatrixMultiplyTest extends Float2DMatrixBase {
+
+    @Override
+    public void runTest() {
+        int range = 20;
+        setupArrays(range);
+
+        dispatchLambdaKernel(range, (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;
+            }
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/FloatCondMoveTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests conditional move of a float value.
+ */
+public class FloatCondMoveTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+    public float[] inArray = new float[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = (gid > 9 ? 2.0f : 3.0f);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/FloatFieldAccessTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests accessing a float field.
+ */
+public class FloatFieldAccessTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+    public int[] inArray = new int[NUM];
+
+    float floatField = 7f;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        float[] out = outArray;
+        int[] in = inArray;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            out[gid] = in[gid] + floatField;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/FloatFieldWriteTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests writing a float field.
+ */
+public class FloatFieldWriteTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Body[] bodyArray = new Body[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            Body b = new Body(i, i + 1, -i, 0);
+            bodyArray[i] = b;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            Body b = bodyArray[gid];
+            b.z = b.x * b.y;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ForEachToGraalTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,311 @@
+/*
+ * 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.lambda;
+
+import java.util.stream.IntStream;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+import java.util.Arrays;
+import java.util.ArrayList;
+
+/**
+ * Several tests for the Sumatra APIs.
+ */
+public class ForEachToGraalTest {
+
+    // Static and instance fields to test codegen for
+    // each type of variable
+    static int staticSize = 16;
+    final int size = staticSize;
+
+    static int printSize = 4;
+
+    static int staticFactor = 3;
+    final int factor = staticFactor;
+
+    class MyPoint {
+
+        int x;
+        int y;
+
+        public MyPoint(int _x, int _y) {
+            x = _x;
+            y = _y;
+        }
+
+        public int getX() {
+            return x;
+        }
+
+        public int getY() {
+            return y;
+        }
+    }
+
+    public MyPoint[] buildMyPointInputArray() {
+        MyPoint[] inputs = new MyPoint[size];
+
+        for (int i = 0; i < size; i++) {
+            inputs[i] = new MyPoint(i, i + 1);
+        }
+        return inputs;
+    }
+
+    public int[] buildIntInputArray() {
+        int[] inputs = new int[size];
+
+        for (int i = 0; i < size; i++) {
+            inputs[i] = i * 4;
+        }
+        return inputs;
+    }
+
+    @Test
+    public void testForEachIntRangeNoCaptures() {
+        int[] dest = new int[size];
+        IntStream range = IntStream.range(0, dest.length).parallel();
+
+        // System.out.println("testForEachIntRangeNoCaptures");
+
+        range.forEach(p -> {
+            dest[p] = p * factor;
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            if (k < printSize) {
+                // System.out.println(k + " ... " + dest[k]);
+            }
+            assertTrue(dest[k] == k * factor);
+        }
+    }
+
+    @Test
+    public void testForEachIntRangeNoCapturesUseStatic() {
+        int[] dest = new int[size];
+        IntStream range = IntStream.range(0, dest.length).parallel();
+
+        // System.out.println("testForEachIntRangeNoCapturesUseStatic");
+
+        range.forEach(p -> {
+            dest[p] = p * staticFactor;
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            if (k < printSize) {
+                // System.out.println(k + " ... " + dest[k]);
+            }
+            assertTrue(dest[k] == k * staticFactor);
+        }
+    }
+
+    @Test
+    public void testForEachIntRangeOneCapture() {
+        int[] dest = new int[size];
+        IntStream range = IntStream.range(0, dest.length).parallel();
+        int[] data = buildIntInputArray();
+
+        range.forEach(p -> {
+            dest[p] = p * factor + data[p];
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            if (k < printSize) {
+                // System.out.println(k + " ... " + dest[k]);
+            }
+            assertTrue(dest[k] == k * 3 + data[k]);
+        }
+
+    }
+
+    @Test
+    public void testForEachIntRangeOneCaptureUseStatic() {
+        int[] dest = new int[size];
+        IntStream range = IntStream.range(0, dest.length).parallel();
+        int[] data = buildIntInputArray();
+
+        range.forEach(p -> {
+            dest[p] = p * staticFactor + data[p];
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            // System.out.println( k + " ... " + dest[k] );
+            assertTrue(dest[k] == k * staticFactor + data[k]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCaptures() {
+        MyPoint[] inputs = buildMyPointInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            // Swap the values
+                        int tmp = p.x;
+                        p.x = p.y + factor;
+                        p.y = tmp;
+                    });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + factor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCapturesUseStatic() {
+        MyPoint[] inputs = buildMyPointInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            // Swap the values
+                        int tmp = p.x;
+                        p.x = p.y + staticFactor;
+                        p.y = tmp;
+                    });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + staticFactor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCapture() {
+        MyPoint[] inputs = buildMyPointInputArray();
+        int[] data = buildIntInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            p.y = data[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCaptureUseStatic() {
+        MyPoint[] inputs = buildMyPointInputArray();
+        int[] data = buildIntInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            p.y = data[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == (data[p.x] + +staticFactor));
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCaptures() {
+        MyPoint[] inputs = buildMyPointInputArray();
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            p.y = data[p.x] + data2[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCapturesUseStatic() {
+        MyPoint[] inputs = buildMyPointInputArray();
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+
+        Arrays.stream(inputs).parallel().forEach(p -> {
+            p.y = data[p.x] + data2[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs[k];
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x] + staticFactor);
+        }
+
+    }
+
+    // This test should fall back to the regular Java path if
+    // Graal throws NYI
+    @Test
+    public void testForEachIntRangeNoCapturesUseEscapingNew() {
+        MyPoint[] dest = new MyPoint[size];
+        IntStream range = IntStream.range(0, dest.length).parallel();
+
+        range.forEach(p -> {
+            dest[p] = new MyPoint(p + p, p);
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            if (k < printSize) {
+                // System.out.println(k + " ... " + dest[k]);
+            }
+            assertTrue(dest[k].getX() == (k + k));
+        }
+    }
+
+    // This test should fall back to the regular Java path if
+    // Graal throws NYI
+    @Test
+    public void testForEachIntRangeNoCapturesUseCall() {
+        MyPoint[] dest = new MyPoint[size];
+        ArrayList<MyPoint> list = new ArrayList<>(size);
+        IntStream range = IntStream.range(0, dest.length).parallel();
+
+        for (int i = 0; i < dest.length; i++) {
+            list.add(new MyPoint(i + i, i));
+        }
+
+        range.forEach(p -> {
+            dest[p] = list.get(p);
+        });
+
+        for (int k = 0; k < dest.length; k++) {
+            if (k < printSize) {
+                // System.out.println(k + " ... " + dest[k]);
+            }
+            assertTrue(dest[k].getX() == (k + k));
+        }
+    }
+    // public static void main(String args[]) {
+    // (new ForEachToGraalTest()).testForEachIntRange();
+    // }
+
+}
--- /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/lambda/HashMapGetTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,108 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import java.util.HashMap;
+
+import org.junit.Test;
+
+/**
+ * Tests calling HashMap.get().
+ */
+public class HashMapGetTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    static class MyObj {
+        public MyObj(int id) {
+            this.id = id;
+        }
+
+        int id;
+
+        public int getId() {
+            return id;
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof MyObj)) {
+                return false;
+            }
+            MyObj othobj = (MyObj) other;
+            return (othobj.id == this.id);
+        }
+
+        @Override
+        public int hashCode() {
+            return 43 * (id % 7);
+        }
+
+    }
+
+    @Result public MyObj[] outArray = new MyObj[NUM];
+    MyObj[] inArray = new MyObj[NUM];
+    public HashMap<MyObj, MyObj> inMap = new HashMap<>();
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            MyObj myobj = new MyObj(i);
+            inMap.put(myobj, new MyObj(i * 3));
+            inArray[NUM - 1 - i] = myobj;
+            outArray[i] = null;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inMap.get(inArray[gid]);
+        });
+    }
+
+    // ForeignCall to Invoke#Direct#get
+    // not inlining HashMapGetTest.lambda$38@15: java.util.HashMap.get(Object):Object (20 bytes): no
+    // type profile exists
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsail();
+        }
+    }
+
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- /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/lambda/InstanceNBodyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,112 @@
+/*
+ * 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.lambda;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Test intstream lambda version of nbody.
+ */
+public class InstanceNBodyTest extends GraalKernelTester {
+
+    static final int bodies = 1024;
+    static final float delT = .005f;
+    static final float espSqr = 1.0f;
+    static final float mass = 5f;
+    static final int width = 768;
+    static final int height = 768;
+
+    @Result float[] in_xyz = new float[bodies * 3]; // positions xy and z of bodies
+
+    @Result float[] out_xyz = new float[bodies * 3]; // positions xy and z of bodies
+
+    @Result float[] in_vxyz = new float[bodies * 3]; // velocity component of x,y and z of
+    // bodies
+
+    @Result float[] out_vxyz = new float[bodies * 3];
+
+    static float[] seed_xyz = new float[bodies * 3];
+    static {
+        final float maxDist = width / 4;
+        for (int body = 0; body < (bodies * 3); body += 3) {
+            final float theta = (float) (Math.random() * Math.PI * 2);
+            final float phi = (float) (Math.random() * Math.PI * 2);
+            final float radius = (float) (Math.random() * maxDist);
+            seed_xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
+            seed_xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
+            seed_xyz[body + 2] = (float) (radius * Math.cos(phi));
+        }
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seed_xyz, 0, in_xyz, 0, seed_xyz.length);
+        Arrays.fill(out_xyz, 0f);
+        Arrays.fill(out_vxyz, 0f);
+        Arrays.fill(in_vxyz, 0f);
+
+        // no local copies to make it an instance lambda
+
+        dispatchLambdaKernel(bodies, (gid) -> {
+            final int count = bodies * 3;
+            final int globalId = gid * 3;
+
+            float accx = 0.f;
+            float accy = 0.f;
+            float accz = 0.f;
+            for (int i = 0; i < count; i += 3) {
+                final float dx = in_xyz[i + 0] - in_xyz[globalId + 0];
+                final float dy = in_xyz[i + 1] - in_xyz[globalId + 1];
+                final float dz = in_xyz[i + 2] - in_xyz[globalId + 2];
+                final float invDist = (float) (1.0 / (Math.sqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr)));
+                accx += mass * invDist * invDist * invDist * dx;
+                accy += mass * invDist * invDist * invDist * dy;
+                accz += mass * invDist * invDist * invDist * dz;
+            }
+            accx *= delT;
+            accy *= delT;
+            accz *= delT;
+            out_xyz[globalId + 0] = in_xyz[globalId + 0] + (in_vxyz[globalId + 0] * delT) + (accx * .5f * delT);
+            out_xyz[globalId + 1] = in_xyz[globalId + 1] + (in_vxyz[globalId + 1] * delT) + (accy * .5f * delT);
+            out_xyz[globalId + 2] = in_xyz[globalId + 2] + (in_vxyz[globalId + 2] * delT) + (accz * .5f * delT);
+
+            out_vxyz[globalId + 0] = in_vxyz[globalId + 0] + accx;
+            out_vxyz[globalId + 1] = in_vxyz[globalId + 1] + accy;
+            out_vxyz[globalId + 2] = in_vxyz[globalId + 2] + accz;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/InstanceOfNullTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests instanceof operator on a null object.
+ */
+public class InstanceOfNullTest extends VirtualCallTest {
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        // change some of the inShapes to null
+        for (int i = 0; i < NUM; i++) {
+            if (i % 3 == 0)
+                inShapeArray[i] = null;
+        }
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = (inShapeArray[gid] instanceof Circle ? 1.0f : 2.0f);
+        });
+    }
+
+    @Override
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Override
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/InstanceOfTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,54 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests instanceof operator.
+ */
+public class InstanceOfTest extends VirtualCallTest {
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = (inShapeArray[gid] instanceof Circle ? 1.0f : 2.0f);
+        });
+    }
+
+    @Override
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Override
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/InstanceOopNBodyAccTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,125 @@
+/*
+ * 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.lambda;
+
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests Oop NBody calling a method that returns acceleration.
+ */
+public class InstanceOopNBodyAccTest extends GraalKernelTester {
+
+    static final int bodies = 1024;
+    static final float delT = .005f;
+    static final float espSqr = 1.0f;
+    static final float mass = 5f;
+    static final int width = 768;
+    static final int height = 768;
+
+    static class Body extends com.oracle.graal.compiler.hsail.test.lambda.Body {
+
+        public Body(float x, float y, float z, float m) {
+            super(x, y, z, m);
+        }
+
+        public Vec3 computeAcc(Body[] in_bodies, float espSqr1, float delT1) {
+            float accx = 0.f;
+            float accy = 0.f;
+            float accz = 0.f;
+            float myPosx = x;
+            float myPosy = y;
+            float myPosz = z;
+
+            for (int b = 0; b < in_bodies.length; b++) {
+                float dx = in_bodies[b].getX() - myPosx;
+                float dy = in_bodies[b].getY() - myPosy;
+                float dz = in_bodies[b].getZ() - myPosz;
+                float invDist = 1.0f / (float) Math.sqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr1);
+                float s = in_bodies[b].getM() * invDist * invDist * invDist;
+                accx = accx + (s * dx);
+                accy = accy + (s * dy);
+                accz = accz + (s * dz);
+            }
+
+            // now return acc as a Vec3
+            return new Vec3(accx * delT1, accy * delT1, accz * delT1);
+        }
+    }
+
+    @Result Body[] in_bodies = new Body[bodies];
+    @Result Body[] out_bodies = new Body[bodies];
+
+    static Body[] seed_bodies = new Body[bodies];
+    static {
+        final float maxDist = width / 4;
+        for (int body = 0; body < bodies; body++) {
+            final float theta = (float) (Math.random() * Math.PI * 2);
+            final float phi = (float) (Math.random() * Math.PI * 2);
+            final float radius = (float) (Math.random() * maxDist);
+            float x = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
+            float y = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
+            float z = (float) (radius * Math.cos(phi));
+            seed_bodies[body] = new Body(x, y, z, mass);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seed_bodies, 0, in_bodies, 0, seed_bodies.length);
+        for (int b = 0; b < bodies; b++) {
+            out_bodies[b] = new Body(0, 0, 0, mass);
+        }
+        // no local copies of arrays so we make it an instance lambda
+
+        dispatchLambdaKernel(bodies, (gid) -> {
+            Body bin = in_bodies[gid];
+            Body bout = out_bodies[gid];
+            Vec3 acc = bin.computeAcc(in_bodies, espSqr, delT);
+
+            float myPosx = bin.getX();
+            float myPosy = bin.getY();
+            float myPosz = bin.getZ();
+            bout.setX(myPosx + (bin.getVx() * delT) + (acc.x * .5f * delT));
+            bout.setY(myPosy + (bin.getVy() * delT) + (acc.y * .5f * delT));
+            bout.setZ(myPosz + (bin.getVz() * delT) + (acc.z * .5f * delT));
+
+            bout.setVx(bin.getVx() + acc.x);
+            bout.setVy(bin.getVy() + acc.y);
+            bout.setVz(bin.getVz() + acc.z);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/InstanceOopNBodyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,111 @@
+/*
+ * 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.lambda;
+
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests OopStream NBody as an instance lambda.
+ */
+public class InstanceOopNBodyTest extends GraalKernelTester {
+
+    static final int bodies = 1024;
+    static final float delT = .005f;
+    static final float espSqr = 1.0f;
+    static final float mass = 5f;
+    static final int width = 768;
+    static final int height = 768;
+
+    @Result Body[] in_bodies = new Body[bodies];
+
+    @Result Body[] out_bodies = new Body[bodies];
+
+    static Body[] seed_bodies = new Body[bodies];
+    static {
+        final float maxDist = width / 4;
+        for (int body = 0; body < bodies; body++) {
+            final float theta = (float) (Math.random() * Math.PI * 2);
+            final float phi = (float) (Math.random() * Math.PI * 2);
+            final float radius = (float) (Math.random() * maxDist);
+            float x = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
+            float y = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
+            float z = (float) (radius * Math.cos(phi));
+            seed_bodies[body] = new Body(x, y, z, mass);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seed_bodies, 0, in_bodies, 0, seed_bodies.length);
+        for (int b = 0; b < bodies; b++) {
+            out_bodies[b] = new Body(0, 0, 0, mass);
+        }
+        // no local copies of arrays so we make it an instance lambda
+
+        dispatchLambdaKernel(bodies, (gid) -> {
+            float accx = 0.f;
+            float accy = 0.f;
+            float accz = 0.f;
+            Body inb = in_bodies[gid];
+            Body outb = out_bodies[gid];
+            float myPosx = inb.getX();
+            float myPosy = inb.getY();
+            float myPosz = inb.getZ();
+
+            for (Body b : in_bodies) {
+                final float dx = b.getX() - myPosx;
+                final float dy = b.getY() - myPosy;
+                final float dz = b.getZ() - myPosz;
+                final float invDist = 1.0f / (float) Math.sqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr);
+                final float s = b.getM() * invDist * invDist * invDist;
+                accx = accx + (s * dx);
+                accy = accy + (s * dy);
+                accz = accz + (s * dz);
+            }
+
+            accx = accx * delT;
+            accy = accy * delT;
+            accz = accz * delT;
+            outb.setX(myPosx + (inb.getVx() * delT) + (accx * .5f * delT));
+            outb.setY(myPosy + (inb.getVy() * delT) + (accy * .5f * delT));
+            outb.setZ(myPosz + (inb.getVz() * delT) + (accz * .5f * delT));
+
+            outb.setVx(inb.getVx() + accx);
+            outb.setVy(inb.getVy() + accy);
+            outb.setVz(inb.getVz() + accz);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntCondMoveTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests conditional move of an int value.
+ */
+public class IntCondMoveTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * (gid > 9 ? 2 : 3);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntFieldAccessTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests accessing an integer field.
+ */
+public class IntFieldAccessTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    int intField = 7;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        int[] out = outArray;
+        int[] in = inArray;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            out[gid] = in[gid] + intField;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntNegateInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests integer negation.
+ */
+public class IntNegateInstanceTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = -inArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntSquaredInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests squaring an integer as an instance lambda.
+ */
+public class IntSquaredInstanceTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * inArray[gid] + 1;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntSquaredStaticTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,61 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests squaring an integer as a static lambda.
+ */
+public class IntSquaredStaticTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        int[] out = outArray;
+        int[] in = inArray;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            out[gid] = in[gid] * in[gid] + 1;
+        });
+    }
+
+    @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/lambda/IntToLongTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests conversion an int to a long.
+ */
+public class IntToLongTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = ((i + 1) * (i % 3 == 0 ? 1 : -1));
+            outArray[i] = 99;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/IntegerObjectCreateTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests allocation of an Integer object.
+ */
+public class IntegerObjectCreateTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public Integer[] outArray = new Integer[NUM];
+    public Integer[] inArray = new Integer[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            int val = inArray[gid];
+            outArray[gid] = val * val + 1;
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        return canHandleObjectAllocation();
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/IntegerObjectReadTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests reading and unboxing of an Integer object.
+ */
+public class IntegerObjectReadTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public Integer[] inArray = new Integer[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            int val = inArray[gid];
+            outArray[gid] = val * val + 1;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/LongAdderTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+import java.util.concurrent.atomic.LongAdder;
+
+import org.junit.Test;
+
+/**
+ * Tests calling LongAdder.add().
+ */
+public class LongAdderTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long finalSum;
+    LongAdder adder = new LongAdder();
+
+    void setupArrays() {
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            adder.add(gid);
+        });
+
+        finalSum = adder.sum();
+    }
+
+    // cannot handle node: CurrentJavaThread
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
+            testGeneratedHsail();
+        }
+    }
+
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+}
--- /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/lambda/LongCmpTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests comparing a long to a constant.
+ */
+public class LongCmpTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    public long[] inArray = new long[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            long val = inArray[gid];
+            long result = val * val;
+            if (val > 9)
+                result++;
+            outArray[gid] = result;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/LongCondMoveTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests conditional move of a long value.
+ */
+public class LongCondMoveTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    public long[] inArray = new long[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * (gid > 9 ? 0x123456789L : 0x123456780L);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/LongNegateInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests negation of a long.
+ */
+public class LongNegateInstanceTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    public long[] inArray = new long[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = 0;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = -inArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/LongSquaredInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests squaring of a long as an instance lambda.
+ */
+public class LongSquaredInstanceTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public long[] outArray = new long[NUM];
+    public long[] inArray = new long[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * inArray[gid] + 1;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Main.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,35 @@
+/*
+ * 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.lambda;
+
+/**
+ * a place to put a direct call to a test if you don't want to go thru junit.
+ */
+
+public class Main {
+
+    public static void main(String[] args) {
+        // new StaticIntFieldAccessTest().test();
+    }
+}
--- /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/lambda/MandelInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,91 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests mandel as an instance lambda.
+ */
+
+public class MandelInstanceTest extends GraalKernelTester {
+
+    static final int WIDTH = 768;
+    static final int HEIGHT = WIDTH;
+    static final int maxIterations = 64;
+
+    static final int RANGE = WIDTH * HEIGHT;
+    @Result public int[] rgb = new int[RANGE];
+    int[] palette = new int[256];
+
+    void setupPalette(int[] in) {
+        for (int i = 0; i < in.length; i++) {
+            in[i] = i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupPalette(palette);
+
+        float x_offset = -1f;
+        float y_offset = 0f;
+        float scale = 3f;
+
+        // call it for a range, specifying the lambda
+        dispatchLambdaKernel(RANGE, (gid) -> {
+            final int width = WIDTH;
+            final int height = HEIGHT;
+            float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + x_offset;
+            float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + y_offset;
+
+            int count = 0;
+            float zx = lx;
+            float zy = ly;
+            float new_zx = 0f;
+
+            // Iterate until the algorithm converges or until maxIterations are reached.
+                        while (count < maxIterations && zx * zx + zy * zy < 8) {
+                            new_zx = zx * zx - zy * zy + lx;
+                            zy = 2 * zx * zy + ly;
+                            zx = new_zx;
+                            count++;
+                        }
+
+                        rgb[gid] = palette[count];
+                    });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/MandelStaticTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,93 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests static lambda version of Mandel.
+ */
+public class MandelStaticTest extends GraalKernelTester {
+
+    static final int WIDTH = 768;
+    static final int HEIGHT = WIDTH;
+    static final int maxIterations = 64;
+
+    static final int RANGE = WIDTH * HEIGHT;
+    @Result public int[] rgb = new int[RANGE];
+
+    void setupPalette(int[] in) {
+        for (int i = 0; i < in.length; i++) {
+            in[i] = i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        int[] palette = new int[256];
+        setupPalette(palette);
+
+        // since we want this to be a fully static lambda, make local copies
+        // of the arrays and values that will get captured by the lambda
+        int[] rgb1 = this.rgb;
+        float x_offset = -1f;
+        float y_offset = 0f;
+        float scale = 3f;
+
+        // call it for a range, specifying lambda
+        dispatchLambdaKernel(RANGE, (gid) -> {
+            final int width = WIDTH;
+            final int height = HEIGHT;
+            float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + x_offset;
+            float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + y_offset;
+
+            int count = 0;
+            float zx = lx;
+            float zy = ly;
+            float new_zx = 0f;
+
+            // Iterate until the algorithm converges or until maxIterations are reached.
+                        while (count < maxIterations && zx * zx + zy * zy < 8) {
+                            new_zx = zx * zx - zy * zy + lx;
+                            zy = 2 * zx * zy + ly;
+                            zx = new_zx;
+                            count++;
+                        }
+
+                        rgb1[gid] = palette[count];
+                    });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/NewStringEqualsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,81 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import org.junit.Test;
+
+/**
+ * Tests creating a String and calling .equals() on it.
+ */
+public class NewStringEqualsTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public boolean[] outArray = new boolean[NUM];
+    char[] chars = new char[100];
+
+    void setupArrays() {
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + i);
+        }
+        for (int i = 0; i < NUM; i++) {
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        String base = "ABCDEFGHIJ";
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = new String(chars, 0, 10 + (gid % 3)).equals(base);
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        // although not escaping, seems to require object allocation support
+        return (canHandleObjectAllocation());
+    }
+
+    // NYI emitForeignCall charAlignedDisjointArraycopy
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsail();
+        }
+    }
+
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- /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/lambda/NewStringLenTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,74 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests creating a String and calling .length() on it.
+ */
+public class NewStringLenTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+    char[] chars = new char[100];
+
+    void setupArrays() {
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = 'A';
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i + 10;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = Integer.toString(gid).length();
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        // although not escaping, seems to require object allocation support
+        return (canHandleObjectAllocation());
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/NonEscapingNewArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests creating a non-escaping array and using it.
+ */
+public class NonEscapingNewArrayTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            float[] ary = {gid, gid + 1, gid + 2};
+            outArray[gid] = ary[0] * ary[1] * ary[2];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/NonEscapingNewObjWithArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,95 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+/**
+ * Tests non-escaping object creation and calling a method on it.
+ */
+public class NonEscapingNewObjWithArrayTest extends GraalKernelTester {
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+
+    static class MyObj {
+        float a[];
+
+        public MyObj(float[] src, int ofst) {
+            a = Arrays.copyOfRange(src, ofst, ofst + 3);
+        }
+
+        public float productOf() {
+            return a[0] * a[1] * a[2];
+        }
+    }
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        float[] fsrc = new float[2 * NUM];
+        for (int i = 0; i < 2 * NUM; i++) {
+            fsrc[i] = i;
+        }
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = new MyObj(fsrc, gid).productOf();
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        // although not escaping, seems to require object allocation support
+        return (canHandleObjectAllocation());
+    }
+
+    // NYI emitForeignCall floatArraycopy
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsail();
+        }
+    }
+
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- /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/lambda/NonEscapingNewTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests creation of three non-escaping objects.
+ */
+public class NonEscapingNewTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+    public Vec3[] inArray = new Vec3[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, i + 2);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            Vec3 veca = inArray[gid];
+            Vec3 vecb = inArray[(gid + 1) % NUM];
+            Vec3 vecresult = Vec3.add(veca, vecb);
+            outArray[gid] = vecresult.z;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ObjectArrayInstanceDerivedTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,82 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests calling a method on an object when there are derived types of that object. Note: if you
+ * enable these tests, not only will these tests fail but other tests like ObjectArrayInstanceTest
+ * will also fail because they depend on there being no derived classes from Body.
+ */
+public class ObjectArrayInstanceDerivedTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    class DerivedBody extends Body {
+
+        DerivedBody(float x, float y, float z, float m) {
+            super(x, y, z, m);
+        }
+
+        @Override
+        public float getX() {
+            return 42.0f;
+        }
+    }
+
+    @Result public float[] outArray = new float[NUM];
+    public Body[] inBodyArray = new Body[NUM];
+    public Body[] unusedBodyArray = new Body[NUM];
+    public DerivedBody[] unusedDerivedBodyArray = new DerivedBody[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inBodyArray[i] = new Body(i, i + 1, i + 2, i + 3);
+            // unusedBodyArray[i] = new DerivedBody(i, i+1, i+2, i+3);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            Body b = inBodyArray[gid];
+            outArray[gid] = b.getX() * b.getY();
+        });
+    }
+
+    // @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    // @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ObjectArrayInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling a method on an object when there are no derived types of that object.
+ */
+public class ObjectArrayInstanceTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public float[] outArray = new float[NUM];
+    public Body[] inBodyArray = new Body[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inBodyArray[i] = new Body(i, i + 1, i + 2, i + 3);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            Body b = inBodyArray[gid];
+            outArray[gid] = b.getX() * b.getY();
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ObjectStoreNullTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,54 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests the storing of null in an Object array
+ */
+public class ObjectStoreNullTest extends ObjectStoreTest {
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outBodyArray[gid] = (gid % 3 == 1 ? null : inBodyArray[gid]);
+        });
+    }
+
+    @Override
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Override
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ObjectStoreTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests copying an object from one array to another.
+ */
+public class ObjectStoreTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Body[] outBodyArray = new Body[NUM];
+    public Body[] inBodyArray = new Body[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inBodyArray[i] = new Body(i, i + 1, i + 2, i + 3);
+            outBodyArray[i] = null;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outBodyArray[gid] = inBodyArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/OverloadMethodTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling methods with the same name but different signatures.
+ */
+public class OverloadMethodTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    int addArgs(int a, int b) {
+        return a + b;
+    }
+
+    int addArgs(int a, int b, int c) {
+        return a + b + c;
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = (gid > 9 ? addArgs(inArray[gid], gid + 1) : addArgs(inArray[gid], gid - 1, gid - 2));
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/ShortArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests accessing an array of shorts.
+ */
+public class ShortArrayTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public short[] inArray = new short[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = (short) ((i + 1) * (i % 3 == 0 ? 1 : -1));
+            outArray[i] = 99;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid];
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticFloatFieldReadTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests reading from a static float field.
+ */
+public class StaticFloatFieldReadTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+    public float[] inArray = new float[NUM];
+
+    static float floatField = 7.123f;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        float[] out = outArray;
+        float[] in = inArray;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            out[gid] = in[gid] + floatField;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticIntField2ReadTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,56 @@
+/*
+ * 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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests reading from a two static int fields in different classes.
+ */
+public class StaticIntField2ReadTest extends StaticIntFieldReadTest {
+
+    static int intField2 = 8;
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * intField1 + intField2;
+        });
+    }
+
+    @Override
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Override
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticIntFieldReadTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests reading from a static int field.
+ */
+public class StaticIntFieldReadTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    static int intField1 = 7;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] + intField1;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticIntFieldSameClassTest.java	Wed Apr 16 14:02:52 2014 +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.lambda;
+
+import org.junit.Test;
+
+/**
+ * Tests reading from a two static int fields in the same class.
+ */
+public class StaticIntFieldSameClassTest extends StaticIntFieldReadTest {
+
+    static int myField1 = 5;
+    static int myField2 = -99;
+    @Result int fieldResult;
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        myField2 = -99;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            int val = inArray[gid] * myField1;
+            outArray[gid] = val;
+            if (gid == 3)
+                myField2 = val + gid;
+        });
+        fieldResult = myField2;
+    }
+
+    @Override
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Override
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticIntFieldWriteTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,70 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests writing a static int field.
+ */
+public class StaticIntFieldWriteTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+    @Result int fieldResult;
+
+    static int intStaticField = -99;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        intStaticField = -99;
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid] * 2;
+            if (gid == 3)
+                intStaticField = outArray[gid];
+        });
+        fieldResult = intStaticField;   // save for kerneltester comparison
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StaticNBodyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,116 @@
+/*
+ * 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.lambda;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+
+/**
+ * Tests a static lambda version of nbody.
+ */
+public class StaticNBodyTest extends GraalKernelTester {
+
+    static final int bodies = 1024;
+    static final float delT = .005f;
+    static final float espSqr = 1.0f;
+    static final float mass = 5f;
+    static final int width = 768;
+    static final int height = 768;
+
+    @Result float[] in_xyz = new float[bodies * 3]; // positions xy and z of bodies
+
+    @Result float[] out_xyz = new float[bodies * 3]; // positions xy and z of bodies
+
+    @Result float[] in_vxyz = new float[bodies * 3]; // velocity component of x,y and z of
+    // bodies
+
+    @Result float[] out_vxyz = new float[bodies * 3];
+
+    static float[] seed_xyz = new float[bodies * 3];
+    static {
+        final float maxDist = width / 4;
+        for (int body = 0; body < (bodies * 3); body += 3) {
+            final float theta = (float) (Math.random() * Math.PI * 2);
+            final float phi = (float) (Math.random() * Math.PI * 2);
+            final float radius = (float) (Math.random() * maxDist);
+            seed_xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
+            seed_xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
+            seed_xyz[body + 2] = (float) (radius * Math.cos(phi));
+        }
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seed_xyz, 0, in_xyz, 0, seed_xyz.length);
+        Arrays.fill(out_xyz, 0f);
+        Arrays.fill(out_vxyz, 0f);
+        Arrays.fill(in_vxyz, 0f);
+
+        // local copies for a static lambda
+        float[] in_xyz1 = this.in_xyz;
+        float[] out_xyz1 = this.out_xyz;
+        float[] in_vxyz1 = this.in_vxyz;
+        float[] out_vxyz1 = this.out_vxyz;
+
+        dispatchLambdaKernel(bodies, (gid) -> {
+            final int count = bodies * 3;
+            final int globalId = gid * 3;
+
+            float accx = 0.f;
+            float accy = 0.f;
+            float accz = 0.f;
+            for (int i = 0; i < count; i += 3) {
+                final float dx = in_xyz1[i + 0] - in_xyz1[globalId + 0];
+                final float dy = in_xyz1[i + 1] - in_xyz1[globalId + 1];
+                final float dz = in_xyz1[i + 2] - in_xyz1[globalId + 2];
+                final float invDist = (float) (1.0 / (Math.sqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr)));
+                accx += mass * invDist * invDist * invDist * dx;
+                accy += mass * invDist * invDist * invDist * dy;
+                accz += mass * invDist * invDist * invDist * dz;
+            }
+            accx *= delT;
+            accy *= delT;
+            accz *= delT;
+            out_xyz1[globalId + 0] = in_xyz1[globalId + 0] + (in_vxyz1[globalId + 0] * delT) + (accx * .5f * delT);
+            out_xyz1[globalId + 1] = in_xyz1[globalId + 1] + (in_vxyz1[globalId + 1] * delT) + (accy * .5f * delT);
+            out_xyz1[globalId + 2] = in_xyz1[globalId + 2] + (in_vxyz1[globalId + 2] * delT) + (accz * .5f * delT);
+
+            out_vxyz1[globalId + 0] = in_vxyz1[globalId + 0] + accx;
+            out_vxyz1[globalId + 1] = in_vxyz1[globalId + 1] + accy;
+            out_vxyz1[globalId + 2] = in_vxyz1[globalId + 2] + accz;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringContainsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling String.contains().
+ */
+public class StringContainsTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public boolean[] outArray = new boolean[NUM];
+    public String[] inArray = new String[NUM];
+
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + i);
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, i, 10);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        String base = "CDE";
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid].contains(base);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringEqualsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling String.equals().
+ */
+public class StringEqualsTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public boolean[] outArray = new boolean[NUM];
+    public String[] inArray = new String[NUM];
+
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + i);
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, 0, 10 + (i % 3));
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        String base = "ABCDEFGHIJ";
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid].equals(base);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringHashTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling String.hashCode().
+ */
+public class StringHashTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public String[] inArray = new String[NUM];
+
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + i);
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, 0, i + 1);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid].hashCode();
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringLenTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling String.length().
+ */
+public class StringLenTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public String[] inArray = new String[NUM];
+
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = 'A';
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, 0, i + 10);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid].length();
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringUtilsCountMatches2Test.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.compiler.hsail.test.lambda.StringUtilsCountMatchesTest.*;
+
+import org.junit.*;
+
+/**
+ * Tests calling a method similar to {@code StringUtils.countMatches()} from the Apache commons-lang
+ * library. The second argument varies per workitem.
+ */
+public class StringUtilsCountMatches2Test extends CountMatchesBase {
+    @Override
+    void setupArrays() {
+        char[] chars = new char[100];
+        for (int i = 0; i < chars.length; i++) {
+            chars[i] = (char) ('A' + (i % 10));
+        }
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new String(chars, i, (i % 5 + 1));
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        String base = "ABCDE BCDEF CDEFG DEFGH EFGHI FGHIJ ABCDE BCDEF CDEFG DEFGH EFGHI FGHIJ ";
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = countMatches(base, inArray[gid]);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/StringUtilsCountMatchesTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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.lambda;
+
+import org.junit.*;
+
+/**
+ * Tests calling a method similar to {@code StringUtils.countMatches()} from the Apache commons-lang
+ * library. The first argument varies per workitem.
+ */
+public class StringUtilsCountMatchesTest extends CountMatchesBase {
+
+    public static int countMatches(String str, String sub) {
+        if (isEmpty(str) || isEmpty(sub)) {
+            return 0;
+        }
+        int count = 0;
+        int idx = 0;
+        while ((idx = str.indexOf(sub, idx)) != -1) {
+            count++;
+            idx += sub.length();
+        }
+        return count;
+    }
+
+    private static boolean isEmpty(String str) {
+        return str == null || str.length() == 0;
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        String base = "CDE";
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = countMatches(inArray[gid], base);
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/SynchronizedMethodTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,78 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import org.junit.Test;
+
+/**
+ * Tests calling a synchronized method.
+ */
+public class SynchronizedMethodTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    synchronized int syncSquare(int n) {
+        return n * n;
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = syncSquare(inArray[gid]);
+        });
+    }
+
+    // cannot handle the BeginLockScope node
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsail();
+        }
+    }
+
+    // cannot handle the BeginLockScope node
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- /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/lambda/TooSimpleNewTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,67 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests a very simple non-escaping object allocation.
+ */
+public class TooSimpleNewTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public float[] outArray = new float[NUM];
+    public float[] inArray = new float[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            float inval = inArray[gid];
+            Vec3 vec3 = new Vec3(inval + 1, inval + 2, inval + 3);
+            outArray[gid] = vec3.x;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/TwoDIntArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests reading from a 2-D int array.
+ */
+public class TwoDIntArrayTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[][] inArray = new int[NUM][NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            for (int j = 0; j < NUM; j++) {
+                inArray[i][j] = i * j;
+            }
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = inArray[gid][gid] + 100;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/VarArgsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+
+/**
+ * Tests calling a varargs method.
+ */
+public class VarArgsTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+    @Result public int[] outArray = new int[NUM];
+    public int[] inArray = new int[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = i;
+            outArray[i] = -i;
+        }
+    }
+
+    int addArgs(Object... args) {
+        int sum = 0;
+        for (Object n : args) {
+            sum += (Integer) n;
+        }
+        return sum;
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            outArray[gid] = (gid > 9 ? addArgs(gid, gid + 1, gid + 2) : addArgs(inArray[gid], gid - 1, gid - 2, gid - 3));
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/Vec3ObjStreamFloatCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 lambda style object array stream kernel, one float capture.
+ */
+public class Vec3ObjStreamFloatCaptureTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+    float baseAdjustment = 0.5f;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        float adjustment = baseAdjustment;
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = vec3.x + vec3.y - adjustment;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/Vec3ObjStreamIntCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 style object array stream kernel, one int capture.
+ */
+public class Vec3ObjStreamIntCaptureTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+    int baseAdjustment = 7;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        int adjustment = baseAdjustment;
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = vec3.x + vec3.y - adjustment;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/Vec3ObjStreamIntFloatCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 style object array stream kernel, one int and one float capture.
+ */
+public class Vec3ObjStreamIntFloatCaptureTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+    int baseAdjustment = 7;
+    float baseMultiplier = 0.5f;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        int adjustment = baseAdjustment;
+        float multiplier = baseMultiplier;
+
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = (vec3.x + vec3.y - adjustment) * multiplier;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/Vec3ObjStreamObjCaptureTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 lambda style object array stream kernel, one object capture.
+ */
+public class Vec3ObjStreamObjCaptureTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+    float baseAdjustment = 0.5f;
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        Vec3 basevec = new Vec3(1, 2, 3);
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = vec3.x + vec3.y - basevec.z;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/Vec3ObjStreamObjFieldTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,65 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 style object array stream kernel. Instance method which accesses an
+ * object field.
+ */
+public class Vec3ObjStreamObjFieldTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+    Vec3 basevec = new Vec3(1, 2, 3);
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = vec3.x + vec3.y - basevec.z;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/Vec3ObjStreamTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ * 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.lambda;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import org.junit.Test;
+import com.oracle.graal.compiler.hsail.test.Vec3;
+
+/**
+ * Tests codegen for a java 8 style object array stream kernel, no captures.
+ */
+public class Vec3ObjStreamTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    @Result public Vec3[] inArray = new Vec3[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            inArray[i] = new Vec3(i, i + 1, -1);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+        dispatchLambdaKernel(inArray, obj -> {
+            Vec3 vec3 = (Vec3) obj;
+            vec3.z = vec3.x + vec3.y;
+        });
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+}
--- /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/lambda/VecmathNBodyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,135 @@
+/*
+ * 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.lambda;
+
+import java.util.*;
+import org.junit.*;
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import javax.vecmath.*;
+
+/**
+ * Tests NBody algorithm using the javax.vecmath package (all objects non-escaping).
+ */
+public class VecmathNBodyTest extends GraalKernelTester {
+    static final int bodies = 1024;
+    static final float delT = .005f;
+    static final float espSqr = 1.0f;
+    static final float mass = 5f;
+    static final int width = 768;
+    static final int height = 768;
+
+    static class Body extends Vector3f {
+
+        /**
+         *
+         */
+        private static final long serialVersionUID = 1L;
+
+        public Body(float _x, float _y, float _z, float _m) {
+            super(_x, _y, _z);
+            m = _m;
+            v = new Vector3f(0, 0, 0);
+        }
+
+        float m;
+        Vector3f v;
+
+        public float getM() {
+            return m;
+        }
+
+        public Vector3f computeAcc(Body[] in_bodies, float espSqr1, float delT1) {
+            Vector3f acc = new Vector3f();
+
+            for (Body b : in_bodies) {
+                Vector3f d = new Vector3f();
+                d.sub(b, this);
+                float invDist = 1.0f / (float) Math.sqrt(d.lengthSquared() + espSqr1);
+                float s = b.getM() * invDist * invDist * invDist;
+                acc.scaleAdd(s, d, acc);
+            }
+
+            // now return acc scaled by delT
+            acc.scale(delT1);
+            return acc;
+        }
+    }
+
+    @Result Body[] in_bodies = new Body[bodies];
+    @Result Body[] out_bodies = new Body[bodies];
+
+    static Body[] seed_bodies = new Body[bodies];
+
+    static {
+        java.util.Random randgen = new Random(0);
+        final float maxDist = width / 4;
+        for (int body = 0; body < bodies; body++) {
+            final float theta = (float) (randgen.nextFloat() * Math.PI * 2);
+            final float phi = (float) (randgen.nextFloat() * Math.PI * 2);
+            final float radius = randgen.nextFloat() * maxDist;
+            float x = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
+            float y = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
+            float z = (float) (radius * Math.cos(phi));
+            seed_bodies[body] = new Body(x, y, z, mass);
+        }
+    }
+
+    @Override
+    public void runTest() {
+        System.arraycopy(seed_bodies, 0, in_bodies, 0, seed_bodies.length);
+        for (int b = 0; b < bodies; b++) {
+            out_bodies[b] = new Body(0, 0, 0, mass);
+        }
+        // no local copies of arrays so we make it an instance lambda
+
+        dispatchLambdaKernel(bodies, (gid) -> {
+            Body inb = in_bodies[gid];
+            Body outb = out_bodies[gid];
+            Vector3f acc = inb.computeAcc(in_bodies, espSqr, delT);
+
+            Vector3f tmpPos = new Vector3f();
+            tmpPos.scaleAdd(delT, inb.v, inb);
+            tmpPos.scaleAdd(0.5f * delT, acc, tmpPos);
+            outb.set(tmpPos);
+
+            outb.v.add(inb.v, acc);
+        });
+    }
+
+    @Override
+    protected boolean supportsRequiredCapabilities() {
+        return (canHandleDeoptVirtualObjects());
+    }
+
+    @Test
+    public void test() {
+        testGeneratedHsail();
+    }
+
+    @Test
+    public void testUsingLambdaMethod() {
+        testGeneratedHsailUsingLambdaMethod();
+    }
+
+}
--- /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/lambda/VectorStreamTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,190 @@
+/*
+ * 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.lambda;
+
+import java.util.Vector;
+import java.util.stream.Stream;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+/**
+ * Sumatra API tests which use a Stream derived from a Vector.
+ */
+public class VectorStreamTest {
+
+    // Static and instance fields to test codegen for
+    // each type of variable
+    static int staticSize = 16;
+    final int size = staticSize;
+
+    static int staticFactor = 3;
+    final int factor = staticFactor;
+
+    class MyPoint {
+
+        int x;
+        int y;
+
+        public MyPoint(int _x, int _y) {
+            x = _x;
+            y = _y;
+        }
+    }
+
+    public Vector<MyPoint> buildMyPointInputArray() {
+        Vector<MyPoint> inputs = new Vector<>(size);
+
+        for (int i = 0; i < size; i++) {
+            inputs.add(new MyPoint(i, i + 1));
+        }
+        return inputs;
+    }
+
+    public int[] buildIntInputArray() {
+        int[] inputs = new int[size];
+
+        for (int i = 0; i < size; i++) {
+            inputs[i] = i * 4;
+        }
+        return inputs;
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCaptures() {
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            // Swap the values
+            int tmp = p.x;
+            p.x = p.y + factor;
+            p.y = tmp;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + factor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamNoCapturesUseStatic() {
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            // Swap the values
+            int tmp = p.x;
+            p.x = p.y + staticFactor;
+            p.y = tmp;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.x == (p.y + 1 + staticFactor));
+        }
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCapture() {
+        int[] data = buildIntInputArray();
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamOneCaptureUseStatic() {
+        int[] data = buildIntInputArray();
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == (data[p.x] + +staticFactor));
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCaptures() {
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + data2[p.x];
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x]);
+        }
+
+    }
+
+    @Test
+    public void testForEachObjectStreamTwoCapturesUseStatic() {
+        int[] data = buildIntInputArray();
+        int[] data2 = buildIntInputArray();
+        Vector<MyPoint> inputs = buildMyPointInputArray();
+
+        Stream<MyPoint> s = inputs.stream();
+        s = s.parallel();
+        s.forEach(p -> {
+            p.y = data[p.x] + data2[p.x] + staticFactor;
+        });
+
+        for (int k = 0; k < size; k++) {
+            MyPoint p = inputs.get(k);
+            // System.out.println( k + " ... p.x=" + p.x );
+            assertTrue(p.y == data[p.x] + data2[p.x] + staticFactor);
+        }
+
+    }
+}
--- /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/lambda/VirtualCallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,111 @@
+/*
+ * 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.lambda;
+
+import static com.oracle.graal.debug.Debug.*;
+
+import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
+import com.oracle.graal.debug.*;
+
+import org.junit.Test;
+
+/**
+ * Tests a true virtual method call.
+ */
+public class VirtualCallTest extends GraalKernelTester {
+
+    static final int NUM = 20;
+
+    static abstract class Shape {
+
+        abstract public float getArea();
+    }
+
+    static class Circle extends Shape {
+
+        private float radius;
+
+        Circle(float r) {
+            radius = r;
+        }
+
+        @Override
+        public float getArea() {
+            return (float) (Math.PI * radius * radius);
+        }
+    }
+
+    static class Square extends Shape {
+
+        private float len;
+
+        Square(float _len) {
+            len = _len;
+        }
+
+        @Override
+        public float getArea() {
+            return len * len;
+        }
+    }
+
+    @Result public float[] outArray = new float[NUM];
+    public Shape[] inShapeArray = new Shape[NUM];
+
+    void setupArrays() {
+        for (int i = 0; i < NUM; i++) {
+            if (i % 2 == 0)
+                inShapeArray[i] = new Circle(i + 1);
+            else
+                inShapeArray[i] = new Square(i + 1);
+            outArray[i] = -i;
+        }
+    }
+
+    @Override
+    public void runTest() {
+        setupArrays();
+
+        dispatchLambdaKernel(NUM, (gid) -> {
+            Shape shape = inShapeArray[gid];
+            outArray[gid] = shape.getArea();
+        });
+    }
+
+    // graal says not inlining getArea():float (0 bytes): no type profile exists
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void test() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsail();
+        }
+    }
+
+    @Test(expected = com.oracle.graal.graph.GraalInternalError.class)
+    public void testUsingLambdaMethod() {
+        try (DebugConfigScope s = disableIntercept()) {
+            testGeneratedHsailUsingLambdaMethod();
+        }
+    }
+
+}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -93,7 +93,7 @@
 
     @Override
     public Variable emitMove(Value input) {
-        Variable result = newVariable(input.getKind());
+        Variable result = newVariable(input.getPlatformKind());
         emitMove(result, input);
         return result;
     }
@@ -193,7 +193,8 @@
     }
 
     @Override
-    public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
+    public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
+                    double trueDestinationProbability) {
         // We don't have to worry about mirroring the condition on HSAIL.
         Condition finalCondition = cond;
         Variable result = newVariable(left.getKind());
@@ -220,11 +221,13 @@
 
     @Override
     public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
-        throw GraalInternalError.unimplemented();
+        Variable result = emitAnd(left, right);
+        Variable dummyResult = newVariable(left.getKind());
+        append(new CompareBranchOp(mapKindToCompareOp(left.getKind()), Condition.EQ, result, Constant.forInt(0), dummyResult, dummyResult, trueDestination, falseDestination, false));
     }
 
     @Override
-    public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
+    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
         Condition finalCondition = cond;
         Variable result = newVariable(trueValue.getKind());
         Kind kind = left.getKind().getStackKind();
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -35,6 +35,7 @@
         test("testIfElse2I", 19, 64);
     }
 
+    @Ignore("PTXHotSpotLIRGenerator.emitCompress is unimplemented")
     @Test
     public void testControl2() {
         compileKernel("testStatic");
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,10 @@
  */
 package com.oracle.graal.compiler.ptx.test;
 
-import org.junit.*;
+import java.io.*;
+import java.lang.reflect.*;
 
-import java.io.*;
-import java.lang.reflect.Method;
+import org.junit.*;
 
 public class IntegerPTXTest extends PTXTest {
 
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ObjectPTXTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ObjectPTXTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -151,7 +151,7 @@
     @Ignore("Object return values not yet supported")
     @Test
     public void test9() {
-        for (Object o : new Object[]{null, "object", new Object(), new HashMap()}) {
+        for (Object o : new Object[]{null, "object", new Object(), new HashMap<>()}) {
             A a = new A();
             a.o = o;
             test("testObject", a);
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -265,7 +265,8 @@
     }
 
     @Override
-    public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
+    public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
+                    double trueDestinationProbability) {
         switch (left.getKind().getStackKind()) {
             case Int:
                 append(new CompareOp(ICMP, cond, left, right, nextPredRegNum));
@@ -305,7 +306,7 @@
     }
 
     @Override
-    public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
+    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
 
         Condition finalCondition = LIRValueUtil.isVariable(right) ? cond.mirror() : cond;
 
@@ -837,7 +838,7 @@
             // Store result in global memory whose location is loadVar
             emitStoreReturnValue(operand.getKind(), loadVar, operand, null);
         }
-        append(new ReturnOp(operand));
+        emitReturnNoVal();
     }
 
     void emitReturnNoVal() {
@@ -907,4 +908,7 @@
         return (new Variable(kind, 0));
     }
 
+    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
+        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitCompareAndSwap()");
+    }
 }
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,6 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.ptx.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
 
 /**
  * This class implements the PTX specific portion of the LIR generator.
@@ -122,11 +121,6 @@
     }
 
     @Override
-    public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.visitCompareAndSwap()");
-    }
-
-    @Override
     public void visitBreakpointNode(BreakpointNode node) {
         throw GraalInternalError.unimplemented("PTXLIRGenerator.visitBreakpointNode()");
     }
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -233,7 +233,8 @@
     }
 
     @Override
-    public void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
+    public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
+                    double trueDestinationProbability) {
         boolean mirrored = emitCompare(left, right);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
         Kind kind = left.getKind().getStackKind();
@@ -278,7 +279,7 @@
     }
 
     @Override
-    public Variable emitConditionalMove(Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
+    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
         boolean mirrored = emitCompare(left, right);
         Condition finalCondition = mirrored ? cond.mirror() : cond;
 
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCNodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCNodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,6 @@
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.lir.sparc.SPARCMove.NullCheckOp;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
 
 /**
  * This class implements the SPARC specific portion of the LIR generator.
@@ -47,11 +46,6 @@
     }
 
     @Override
-    public void visitCompareAndSwap(LoweredCompareAndSwapNode i, Value address) {
-        throw new InternalError("NYI");
-    }
-
-    @Override
     public void visitBreakpointNode(BreakpointNode node) {
         JavaType[] sig = new JavaType[node.arguments().size()];
         for (int i = 0; i < sig.length; i++) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.compiler.test;
 
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
+
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
@@ -33,7 +35,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
@@ -106,14 +107,7 @@
                         String methodName = className + "." + m.getName();
                         if (matches(filters, methodName)) {
                             StructuredGraph graph = new StructuredGraph(metaAccess.lookupJavaMethod(m));
-                            DebugConfig debugConfig = DebugScope.getConfig();
-                            DebugConfig noInterceptConfig = new DelegatingDebugConfig(debugConfig) {
-                                @Override
-                                public RuntimeException interceptException(Throwable e) {
-                                    return null;
-                                }
-                            };
-                            try (DebugConfigScope s = Debug.setConfig(noInterceptConfig)) {
+                            try (DebugConfigScope s = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
                                 graphBuilderSuite.apply(graph, context);
                                 checkGraph(context, graph);
                             } catch (VerificationError e) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,6 @@
 
 import org.junit.*;
 
-import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.java.*;
@@ -304,7 +303,6 @@
         new FloatingReadPhase().apply(graph);
         new ConditionalEliminationPhase(getMetaAccess()).apply(graph);
         canonicalizer.apply(graph, context);
-        DebugScope.forceDump(graph, "dup guards");
 
         assertEquals(1, graph.getNodes().filter(GuardNode.class).count());
     }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,7 +59,7 @@
         }
     }
 
-    private StructuredGraph parseAndProcess(Class cl, Assumptions assumptions) {
+    private StructuredGraph parseAndProcess(Class<?> cl, Assumptions assumptions) {
         Constructor<?>[] constructors = cl.getConstructors();
         Assert.assertTrue(constructors.length == 1);
         final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaConstructor(constructors[0]);
@@ -73,7 +73,7 @@
         return graph;
     }
 
-    private void checkForRegisterFinalizeNode(Class cl, boolean shouldContainFinalizer, boolean optimistic) {
+    private void checkForRegisterFinalizeNode(Class<?> cl, boolean shouldContainFinalizer, boolean optimistic) {
         Assumptions assumptions = new Assumptions(optimistic);
         StructuredGraph graph = parseAndProcess(cl, assumptions);
         Assert.assertTrue(graph.getNodes().filter(RegisterFinalizerNode.class).count() == (shouldContainFinalizer ? 1 : 0));
@@ -109,7 +109,7 @@
         private static int loaderInstance = 0;
 
         private final String replaceTo;
-        private HashMap<String, Class> cache = new HashMap<>();
+        private HashMap<String, Class<?>> cache = new HashMap<>();
 
         public ClassTemplateLoader() {
             loaderInstance++;
@@ -149,7 +149,7 @@
             }
             dumpStringsInByteArray(classData);
 
-            Class c = defineClass(null, classData, 0, classData.length);
+            Class<?> c = defineClass(null, classData, 0, classData.length);
             cache.put(nameReplaced, c);
             return c;
         }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,6 +38,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CallingConvention.Type;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.baseline.*;
 import com.oracle.graal.compiler.target.*;
@@ -240,6 +241,10 @@
         return providers;
     }
 
+    protected SnippetReflectionProvider getSnippetReflection() {
+        return Graal.getRequiredCapability(SnippetReflectionProvider.class);
+    }
+
     protected TargetDescription getTarget() {
         return getProviders().getCodeCache().getTarget();
     }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -148,10 +148,10 @@
         Debug.dump(graph, "Graph");
         ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
 
-        Assert.assertTrue(cfg.getLoops().length == 3);
-        Loop rootLoop = cfg.getLoops()[0];
-        Loop nestedLoop = cfg.getLoops()[1];
-        Loop innerMostLoop = cfg.getLoops()[2];
+        Assert.assertTrue(cfg.getLoops().size() == 3);
+        Loop<Block> rootLoop = cfg.getLoops().get(0);
+        Loop<Block> nestedLoop = cfg.getLoops().get(1);
+        Loop<Block> innerMostLoop = cfg.getLoops().get(2);
         Invoke a = getInvoke("a", graph);
         Invoke b = getInvoke("b", graph);
         Invoke c = getInvoke("c", graph);
@@ -168,14 +168,14 @@
         Debug.dump(graph, "Graph");
     }
 
-    private static boolean contains(Loop loop, Invoke node, ControlFlowGraph cfg) {
+    private static boolean contains(Loop<Block> loop, Invoke node, ControlFlowGraph cfg) {
         Block block = cfg.blockFor((Node) node);
         Assert.assertNotNull(block);
         return loop.blocks.contains(block);
     }
 
-    private static boolean containsDirect(Loop loop, Invoke node, ControlFlowGraph cfg) {
-        for (Loop child : loop.children) {
+    private static boolean containsDirect(Loop<Block> loop, Invoke node, ControlFlowGraph cfg) {
+        for (Loop<Block> child : loop.children) {
             if (contains(child, node, cfg)) {
                 return false;
             }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,7 +41,7 @@
     @Test
     public void test1() {
         StructuredGraph graph = parse("test1Snippet");
-        Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext());
+        Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
     }
 
     public static int test1Snippet(int a) {
@@ -54,7 +54,7 @@
     @Test
     public void test2() {
         StructuredGraph graph = parse("test2Snippet");
-        Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext());
+        Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
     }
 
     public static int test2Snippet(int a) {
@@ -68,7 +68,7 @@
     public void test3() {
         StructuredGraph graph = parse("test3Snippet");
         Debug.dump(graph, "Graph");
-        Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext());
+        Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
     }
 
     public static int test3Snippet(int a) {
@@ -84,7 +84,7 @@
     public void test4() {
         StructuredGraph graph = parse("test4Snippet");
         Debug.dump(graph, "Graph");
-        Assert.assertFalse(graph.getNodes().filter(PhiNode.class).iterator().hasNext());
+        Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
     }
 
     public static int test4Snippet(int a) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -113,14 +113,14 @@
 
         SchedulePhase schedule = null;
         try (Scope s = Debug.scope("FrontEnd")) {
-            schedule = GraalCompiler.emitHIR(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
-                            graph.method().getProfilingInfo(), new SpeculationLog(), getSuites());
+            schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
+                            graph.method().getProfilingInfo(), null, getSuites());
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
 
         CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
-        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc);
+        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null);
         return new RegisterStats(lirGen.getLIR());
     }
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,15 +59,15 @@
         new DeadCodeEliminationPhase().apply(graph);
 
         for (ConstantNode node : ConstantNode.getConstantNodes(graph)) {
-            if (node.getKind() == Kind.Object && " ".equals(node.getValue().asObject())) {
-                node.replace(graph, ConstantNode.forObject("-", getMetaAccess(), graph));
+            if (node.getKind() == Kind.Object && " ".equals(getSnippetReflection().asObject(node.getValue()))) {
+                node.replace(graph, ConstantNode.forConstant(getSnippetReflection().forObject("-"), getMetaAccess(), graph));
             }
         }
 
         final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method);
         InstalledCode compiledMethod = getCode(javaMethod, graph);
         try {
-            Object result = compiledMethod.execute("1", "2", "3");
+            Object result = compiledMethod.executeVarargs("1", "2", "3");
             Assert.assertEquals("1-2-3", result);
         } catch (InvalidInstalledCodeException t) {
             Assert.fail("method invalidated");
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EAMergingTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
     public void testSimpleMerge() {
         testEscapeAnalysis("simpleMergeSnippet", null, false);
         assertEquals(1, returnNodes.size());
-        assertTrue(returnNodes.get(0).result() instanceof PhiNode);
+        assertTrue(returnNodes.get(0).result() instanceof ValuePhiNode);
         PhiNode phi = (PhiNode) returnNodes.get(0).result();
         assertTrue(phi.valueAt(0) instanceof ParameterNode);
         assertTrue(phi.valueAt(1) instanceof ParameterNode);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -62,7 +62,7 @@
 
     @Test
     public void test3() {
-        testEscapeAnalysis("test3Snippet", Constant.forObject(null), false);
+        testEscapeAnalysis("test3Snippet", Constant.NULL_OBJECT, false);
     }
 
     public static Object test3Snippet() {
@@ -257,7 +257,7 @@
 
     @Test
     public void testCheckCast() {
-        testEscapeAnalysis("testCheckCastSnippet", Constant.forObject(TestClassObject.class), false);
+        testEscapeAnalysis("testCheckCastSnippet", getSnippetReflection().forObject(TestClassObject.class), false);
     }
 
     public Object testCheckCastSnippet() {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -164,7 +164,7 @@
         ValueNode result = getReturn("testBadLoopSnippet").result();
         assertEquals(0, graph.getNodes().filter(LoadFieldNode.class).count());
         assertTrue(result instanceof ProxyNode);
-        assertTrue(((ProxyNode) result).value() instanceof PhiNode);
+        assertTrue(((ProxyNode) result).value() instanceof ValuePhiNode);
     }
 
     @SuppressWarnings("all")
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/UnsafeEATest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/UnsafeEATest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -87,7 +87,7 @@
     public void testMergedDouble() {
         testEscapeAnalysis("testMergedDoubleSnippet", null, false);
         Assert.assertEquals(1, returnNodes.size());
-        Assert.assertTrue(returnNodes.get(0).result() instanceof PhiNode);
+        Assert.assertTrue(returnNodes.get(0).result() instanceof ValuePhiNode);
         PhiNode phi = (PhiNode) returnNodes.get(0).result();
         Assert.assertTrue(phi.valueAt(0) instanceof LoadFieldNode);
         Assert.assertTrue(phi.valueAt(1) instanceof LoadFieldNode);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/nfi/NativeFunctionInterfaceTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/nfi/NativeFunctionInterfaceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,6 +38,7 @@
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.runtime.*;
 
+@Ignore
 public class NativeFunctionInterfaceTest {
 
     public final NativeFunctionInterface nfi;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/CompilerThread.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/CompilerThread.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.compiler;
 
-import com.oracle.graal.compiler.CompilerThreadFactory.*;
+import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess;
 import com.oracle.graal.debug.*;
 
 /**
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -138,23 +138,8 @@
         assert !graph.isFrozen();
         try (Scope s0 = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) {
             Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
-            SchedulePhase schedule = null;
-            try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
-                schedule = emitHIR(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites);
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-            try (TimerCloseable a = BackEnd.start()) {
-                LIRGenerationResult lirGenRes = null;
-                lirGenRes = emitLIR(backend, target, schedule, graph, stub, cc);
-                try (Scope s = Debug.scope("CodeGen", lirGenRes)) {
-                    emitCode(backend, assumptions, lirGenRes, compilationResult, installedCodeOwner, factory);
-                } catch (Throwable e) {
-                    throw Debug.handle(e);
-                }
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
+            SchedulePhase schedule = emitFrontEnd(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites);
+            emitBackEnd(graph, stub, cc, installedCodeOwner, backend, target, compilationResult, factory, assumptions, schedule, null);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
@@ -172,37 +157,54 @@
     /**
      * Builds the graph, optimizes it.
      */
-    public static SchedulePhase emitHIR(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache,
+    public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache,
                     PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) {
-
-        if (speculationLog != null) {
-            speculationLog.collectFailedSpeculations();
-        }
+        try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
+            if (speculationLog != null) {
+                speculationLog.collectFailedSpeculations();
+            }
 
-        HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
-        if (graph.start().next() == null) {
-            graphBuilderSuite.apply(graph, highTierContext);
-            new DeadCodeEliminationPhase().apply(graph);
-        } else {
-            Debug.dump(graph, "initial state");
-        }
+            HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
+            if (graph.start().next() == null) {
+                graphBuilderSuite.apply(graph, highTierContext);
+                new DeadCodeEliminationPhase().apply(graph);
+            } else {
+                Debug.dump(graph, "initial state");
+            }
+
+            suites.getHighTier().apply(graph, highTierContext);
+            graph.maybeCompress();
+
+            MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
+            suites.getMidTier().apply(graph, midTierContext);
+            graph.maybeCompress();
 
-        suites.getHighTier().apply(graph, highTierContext);
-        graph.maybeCompress();
+            LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
+            suites.getLowTier().apply(graph, lowTierContext);
+            graph.maybeCompress();
 
-        MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
-        suites.getMidTier().apply(graph, midTierContext);
-        graph.maybeCompress();
+            SchedulePhase schedule = new SchedulePhase();
+            schedule.apply(graph);
+            Debug.dump(schedule, "Final HIR schedule");
+            return schedule;
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
+    }
 
-        LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
-        suites.getLowTier().apply(graph, lowTierContext);
-        graph.maybeCompress();
-
-        SchedulePhase schedule = new SchedulePhase();
-        schedule.apply(graph);
-        Debug.dump(schedule, "Final HIR schedule");
-        return schedule;
-
+    public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend,
+                    TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, Assumptions assumptions, SchedulePhase schedule, RegisterConfig registerConfig) {
+        try (TimerCloseable a = BackEnd.start()) {
+            LIRGenerationResult lirGen = null;
+            lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig);
+            try (Scope s = Debug.scope("CodeGen", lirGen)) {
+                emitCode(backend, assumptions, lirGen, compilationResult, installedCodeOwner, factory);
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
     }
 
     private static void emitBlock(NodeLIRBuilder nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
@@ -216,7 +218,7 @@
         }
     }
 
-    public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc) {
+    public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc, RegisterConfig registerConfig) {
         Block[] blocks = schedule.getCFG().getBlocks();
         Block startBlock = schedule.getCFG().getStartBlock();
         assert startBlock != null;
@@ -241,7 +243,7 @@
             throw Debug.handle(e);
         }
         try (Scope ds = Debug.scope("BackEnd", lir)) {
-            FrameMap frameMap = backend.newFrameMap();
+            FrameMap frameMap = backend.newFrameMap(registerConfig);
             LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMap, stub);
             LIRGenerator lirGen = backend.newLIRGenerator(cc, lirGenRes);
             NodeLIRBuilder nodeLirGen = backend.newNodeLIRGenerator(graph, lirGen);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java	Wed Apr 16 14:02:52 2014 +0200
@@ -335,7 +335,7 @@
     }
 
     int numLoops() {
-        return ir.getControlFlowGraph().getLoops().length;
+        return ir.getControlFlowGraph().getLoops().size();
     }
 
     boolean isIntervalInLoop(int interval, int loop) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.compiler.alloc;
 
 import static com.oracle.graal.api.code.ValueUtil.*;
+
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,9 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.*;
+import com.oracle.graal.lir.LIRInstruction.OperandFlag;
+import com.oracle.graal.lir.LIRInstruction.OperandMode;
+import com.oracle.graal.lir.LIRInstruction.ValueProcedure;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.phases.util.*;
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -315,11 +315,6 @@
 
     public void append(LIRInstruction op) {
         if (printIRWithLIR && !TTY.isSuppressed()) {
-            // if (currentInstruction != null && lastInstructionPrinted != currentInstruction) {
-            // lastInstructionPrinted = currentInstruction;
-            // InstructionPrinter ip = new InstructionPrinter(TTY.out());
-            // ip.printInstructionListing(currentInstruction);
-            // }
             TTY.println(op.toStringWithIdPrefix());
             TTY.println();
         }
@@ -327,6 +322,14 @@
         res.getLIR().getLIRforBlock(currentBlock).add(op);
     }
 
+    public boolean hasBlockEnd(AbstractBlock<?> block) {
+        List<LIRInstruction> ops = getResult().getLIR().getLIRforBlock(block);
+        if (ops.size() == 0) {
+            return false;
+        }
+        return ops.get(ops.size() - 1) instanceof BlockEndOp;
+    }
+
     public final void doBlockStart(AbstractBlock<?> block) {
         if (printIRWithLIR) {
             TTY.print(block.toString());
@@ -364,13 +367,14 @@
 
     public abstract void emitJump(LabelRef label);
 
-    public abstract void emitCompareBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability);
+    public abstract void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination,
+                    double trueDestinationProbability);
 
     public abstract void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, double overflowProbability);
 
     public abstract void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueSuccessorProbability);
 
-    public abstract Variable emitConditionalMove(Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue);
+    public abstract Variable emitConditionalMove(PlatformKind cmpKind, Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue);
 
     public abstract Variable emitIntegerTestMove(Value leftVal, Value right, Value trueValue, Value falseValue);
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,10 +37,8 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.BlockEndOp;
 import com.oracle.graal.lir.StandardOp.JumpOp;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.extended.*;
@@ -227,7 +225,7 @@
             }
         }
 
-        if (!hasBlockEnd(block)) {
+        if (!gen.hasBlockEnd(block)) {
             NodeClassIterable successors = block.getEndNode().successors();
             assert successors.count() == block.getSuccessorCount();
             if (block.getSuccessorCount() != 1) {
@@ -338,7 +336,7 @@
                                 continue;
                             } else if (node instanceof UnsafeCastNode) {
                                 UnsafeCastNode cast = (UnsafeCastNode) node;
-                                if (cast.getOriginalValue() == access) {
+                                if (cast.getOriginalNode() == access) {
                                     continue;
                                 }
                             }
@@ -392,14 +390,6 @@
 
     protected abstract boolean peephole(ValueNode valueNode);
 
-    private boolean hasBlockEnd(Block block) {
-        List<LIRInstruction> ops = gen.getResult().getLIR().getLIRforBlock(block);
-        if (ops.size() == 0) {
-            return false;
-        }
-        return ops.get(ops.size() - 1) instanceof BlockEndOp;
-    }
-
     private void doRoot(ValueNode instr) {
         if (gen.traceLevel >= 2) {
             TTY.println("Emitting LIR for instruction " + instr);
@@ -473,9 +463,9 @@
         }
         PhiResolver resolver = new PhiResolver(gen);
         for (PhiNode phi : merge.phis()) {
-            if (phi.type() == PhiType.Value) {
+            if (phi instanceof ValuePhiNode) {
                 ValueNode curVal = phi.valueAt(pred);
-                resolver.move(operandForPhi(phi), operand(curVal));
+                resolver.move(operandForPhi((ValuePhiNode) phi), operand(curVal));
             }
         }
         resolver.dispose();
@@ -487,8 +477,7 @@
         return gen.getPlatformKind(phi.stamp());
     }
 
-    private Value operandForPhi(PhiNode phi) {
-        assert phi.type() == PhiType.Value : "wrong phi type: " + phi;
+    private Value operandForPhi(ValuePhiNode phi) {
         Value result = getOperand(phi);
         if (result == null) {
             // allocate a variable for this phi
@@ -520,11 +509,13 @@
     }
 
     private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) {
-        gen.emitCompareBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability);
+        PlatformKind kind = gen.getPlatformKind(node.object().stamp());
+        gen.emitCompareBranch(kind, operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability);
     }
 
     public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) {
-        gen.emitCompareBranch(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueSuccessor, falseSuccessor, trueSuccessorProbability);
+        PlatformKind kind = gen.getPlatformKind(compare.x().stamp());
+        gen.emitCompareBranch(kind, operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueSuccessor, falseSuccessor, trueSuccessorProbability);
     }
 
     public void emitIntegerTestBranch(IntegerTestNode test, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) {
@@ -546,10 +537,12 @@
     public Variable emitConditional(LogicNode node, Value trueValue, Value falseValue) {
         if (node instanceof IsNullNode) {
             IsNullNode isNullNode = (IsNullNode) node;
-            return gen.emitConditionalMove(operand(isNullNode.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueValue, falseValue);
+            PlatformKind kind = gen.getPlatformKind(isNullNode.object().stamp());
+            return gen.emitConditionalMove(kind, operand(isNullNode.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueValue, falseValue);
         } else if (node instanceof CompareNode) {
             CompareNode compare = (CompareNode) node;
-            return gen.emitConditionalMove(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueValue, falseValue);
+            PlatformKind kind = gen.getPlatformKind(compare.x().stamp());
+            return gen.emitConditionalMove(kind, operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueValue, falseValue);
         } else if (node instanceof LogicConstantNode) {
             return gen.emitMove(((LogicConstantNode) node).getValue() ? trueValue : falseValue);
         } else if (node instanceof IntegerTestNode) {
@@ -635,7 +628,8 @@
             if (keyCount == 1) {
                 assert defaultTarget != null;
                 double probability = x.probability(x.keySuccessor(0));
-                gen.emitCompareBranch(gen.load(operand(x.value())), x.keyAt(0), Condition.EQ, false, getLIRBlock(x.keySuccessor(0)), defaultTarget, probability);
+                PlatformKind kind = gen.getPlatformKind(x.value().stamp());
+                gen.emitCompareBranch(kind, gen.load(operand(x.value())), x.keyAt(0), Condition.EQ, false, getLIRBlock(x.keySuccessor(0)), defaultTarget, probability);
             } else {
                 LabelRef[] keyTargets = new LabelRef[keyCount];
                 Constant[] keyConstants = new Constant[keyCount];
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
 import com.oracle.graal.nodes.*;
 
 /**
- * Converts {@link PhiNode} instructions into moves.
+ * Converts {@link ValuePhiNode} instructions into moves.
  * 
  * Resolves cycles:
  * 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.compiler.target;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.stack.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.compiler.gen.*;
@@ -64,7 +65,11 @@
         return providers.getCodeCache().getTarget();
     }
 
-    public abstract FrameMap newFrameMap();
+    /**
+     * The given registerConfig is optional, in case null is passed the default RegisterConfig from
+     * the CodeCacheProvider will be used.
+     */
+    public abstract FrameMap newFrameMap(RegisterConfig registerConfig);
 
     public abstract LIRGenerator newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes);
 
@@ -92,6 +97,8 @@
 
     public abstract boolean shouldAllocateRegisters();
 
+    public abstract StackIntrospection getStackIntrospection();
+
     /**
      * Emits the code for a given graph.
      *
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.debug;
 
 import static com.oracle.graal.debug.Debug.Initialization.*;
+import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
 import static java.util.FormattableFlags.*;
 
 import java.io.*;
@@ -259,17 +260,25 @@
     }
 
     public static Scope forceLog() {
-        return Debug.sandbox("forceLog", new DelegatingDebugConfig(DebugScope.getConfig()) {
-            @Override
-            public boolean isLogEnabled() {
-                return true;
-            }
+        return Debug.sandbox("forceLog", new DelegatingDebugConfig().enable(LOG).enable(LOG_METHOD));
+    }
 
-            @Override
-            public boolean isLogEnabledForMethod() {
-                return true;
-            }
-        });
+    /**
+     * Opens a scope in which exception {@linkplain DebugConfig#interceptException(Throwable)
+     * interception} is disabled. It is recommended to use the try-with-resource statement for
+     * managing entering and leaving such scopes:
+     *
+     * <pre>
+     * try (DebugConfigScope s = Debug.disableIntercept()) {
+     *     ...
+     * }
+     * </pre>
+     *
+     * This is particularly useful to suppress extraneous output in JUnit tests that are expected to
+     * throw an exception.
+     */
+    public static DebugConfigScope disableIntercept() {
+        return Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT));
     }
 
     /**
@@ -853,7 +862,7 @@
 
     public static Object convertFormatArg(Object arg) {
         if (arg instanceof Class) {
-            return ((Class) arg).getSimpleName();
+            return ((Class<?>) arg).getSimpleName();
         }
         return arg;
     }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DelegatingDebugConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,45 +25,139 @@
 import java.io.*;
 import java.util.*;
 
+import com.oracle.graal.debug.internal.*;
+
 public class DelegatingDebugConfig implements DebugConfig {
 
     protected final DebugConfig delegate;
 
+    /**
+     * The features of a {@link DelegatingDebugConfig} that can be force
+     * {@linkplain DelegatingDebugConfig#enable(Feature) enabled}/
+     * {@linkplain DelegatingDebugConfig#disable(Feature) disabled} or
+     * {@linkplain DelegatingDebugConfig#delegate(Feature) delegated}.
+     */
+    public enum Feature {
+        /**
+         * @see Debug#isLogEnabled()
+         */
+        LOG,
+        /**
+         * @see Debug#isLogEnabledForMethod()
+         */
+        LOG_METHOD,
+        /**
+         * @see Debug#isDumpEnabled()
+         */
+        DUMP,
+        /**
+         * @see Debug#isDumpEnabledForMethod()
+         */
+        DUMP_METHOD,
+        /**
+         * @see Debug#isMeterEnabled()
+         */
+        METER,
+        /**
+         * @see Debug#isTimeEnabled()
+         */
+        TIME,
+        /**
+         * @see DebugConfig#interceptException(Throwable)
+         */
+        INTERCEPT
+    }
+
+    private final Map<Feature, Boolean> featureState = new EnumMap<>(Feature.class);
+
+    /**
+     * Creates a config that delegates to the {@link DebugScope#getConfig() current config}.
+     */
+    public DelegatingDebugConfig() {
+        this(DebugScope.getConfig());
+    }
+
+    /**
+     * Creates a config that delegates to a given config.
+     */
     public DelegatingDebugConfig(DebugConfig delegate) {
         this.delegate = delegate;
     }
 
+    public DelegatingDebugConfig enable(Feature feature) {
+        featureState.put(feature, Boolean.TRUE);
+        return this;
+    }
+
+    public DelegatingDebugConfig disable(Feature feature) {
+        featureState.put(feature, Boolean.FALSE);
+        return this;
+    }
+
+    public DelegatingDebugConfig delegate(Feature feature) {
+        featureState.put(feature, null);
+        return this;
+    }
+
     @Override
     public boolean isLogEnabled() {
-        return delegate.isLogEnabled();
+        Boolean fs = featureState.get(Feature.LOG);
+        if (fs == null) {
+            return delegate.isLogEnabled();
+        }
+        return fs.booleanValue();
     }
 
     public boolean isLogEnabledForMethod() {
-        return delegate.isLogEnabledForMethod();
+        Boolean fs = featureState.get(Feature.LOG_METHOD);
+        if (fs == null) {
+            return delegate.isLogEnabledForMethod();
+        }
+        return fs.booleanValue();
     }
 
     @Override
     public boolean isMeterEnabled() {
-        return delegate.isMeterEnabled();
+        Boolean fs = featureState.get(Feature.METER);
+        if (fs == null) {
+            return delegate.isMeterEnabled();
+        }
+        return fs.booleanValue();
     }
 
     @Override
     public boolean isDumpEnabled() {
-        return delegate.isDumpEnabled();
+        Boolean fs = featureState.get(Feature.DUMP);
+        if (fs == null) {
+            return delegate.isDumpEnabled();
+        }
+        return fs.booleanValue();
     }
 
     public boolean isDumpEnabledForMethod() {
-        return delegate.isDumpEnabledForMethod();
+        Boolean fs = featureState.get(Feature.DUMP_METHOD);
+        if (fs == null) {
+            return delegate.isDumpEnabledForMethod();
+        }
+        return fs.booleanValue();
     }
 
     @Override
     public boolean isTimeEnabled() {
-        return delegate.isTimeEnabled();
+        Boolean fs = featureState.get(Feature.TIME);
+        if (fs == null) {
+            return delegate.isTimeEnabled();
+        }
+        return fs.booleanValue();
     }
 
     @Override
     public RuntimeException interceptException(Throwable e) {
-        return delegate.interceptException(e);
+        Boolean fs = featureState.get(Feature.INTERCEPT);
+        if (fs == null || fs) {
+            return delegate.interceptException(e);
+        }
+        return null;
     }
 
     @Override
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,8 @@
 import java.util.*;
 
 import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.DebugHistogram.*;
+import com.oracle.graal.debug.DebugHistogram.CountedValue;
+import com.oracle.graal.debug.DebugHistogram.Printer;
 
 /**
  * Renders a textual representation of a histogram to a given print stream.
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.GraphEvent.NodeEvent;
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.ValueNumberable;
 import com.oracle.graal.graph.iterators.*;
 
 /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/InputType.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, 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.graph;
+
+public enum InputType {
+    /**
+     * Inputs that consume an actual value generated by the referenced node.
+     */
+    Value,
+    /**
+     * Inputs that consume the memory state of the referenced node.
+     */
+    Memory,
+    /**
+     * Inputs that reference a condition.
+     */
+    Condition,
+    /**
+     * Inputs that reference a frame state.
+     */
+    State,
+    /**
+     * Inputs that reference a guard (guards, begin nodes).
+     */
+    Guard,
+    /**
+     * Inputs that reference an anchor (begin nodes, value anchors).
+     */
+    Anchor,
+    /**
+     * Inputs that represent an association between nodes, e.g., a phi and the merge or a loop begin
+     * and loop exits and ends.
+     */
+    Association,
+    /**
+     * Inputs that connect tightly coupled nodes, e.g., an InvokeNode and its CallTargetNode.
+     */
+    Extension,
+    /**
+     * Inputs of this type are temporarily exempt from type checking. This should only be used in
+     * exceptional cases and should never survive to later stages of compilation.
+     */
+    Unchecked
+}
\ No newline at end of file
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Wed Apr 16 14:02:52 2014 +0200
@@ -44,9 +44,9 @@
  * this field points to.
  * <p>
  * Nodes which are be value numberable should implement the {@link ValueNumberable} interface.
- * 
+ *
  * <h1>Assertions and Verification</h1>
- * 
+ *
  * The Node class supplies the {@link #assertTrue(boolean, String, Object...)} and
  * {@link #assertFalse(boolean, String, Object...)} methods, which will check the supplied boolean
  * and throw a VerificationError if it has the wrong value. Both methods will always either throw an
@@ -67,8 +67,7 @@
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ElementType.FIELD)
     public static @interface Input {
-
-        boolean notDataflow() default false;
+        InputType value() default InputType.Value;
     }
 
     @Retention(RetentionPolicy.RUNTIME)
@@ -112,7 +111,7 @@
          * method. If not specified, then the class in which the annotated method is declared is
          * used (and is assumed to be a {@link Node} subclass).
          */
-        Class value() default NodeIntrinsic.class;
+        Class<?> value() default NodeIntrinsic.class;
 
         /**
          * Determines if the stamp of the instantiated intrinsic node has its stamp set from the
@@ -166,7 +165,7 @@
     /**
      * Returns an {@link NodeClassIterable iterable} which can be used to traverse all non-null
      * input edges of this node.
-     * 
+     *
      * @return an {@link NodeClassIterable iterable} for all non-null input edges.
      */
     public NodeClassIterable inputs() {
@@ -176,7 +175,7 @@
     /**
      * Returns an {@link NodeClassIterable iterable} which can be used to traverse all non-null
      * successor edges of this node.
-     * 
+     *
      * @return an {@link NodeClassIterable iterable} for all non-null successor edges.
      */
     public NodeClassIterable successors() {
@@ -288,7 +287,7 @@
     /**
      * Finds the index of the last non-null entry in a node array. The search assumes that all
      * non-null entries precede the first null entry in the array.
-     * 
+     *
      * @param nodes the array to search
      * @return the index of the last non-null entry in {@code nodes} if it exists, else -1
      */
@@ -321,7 +320,7 @@
 
     /**
      * Adds a given node to this node's {@linkplain #usages() usages}.
-     * 
+     *
      * @param node the node to add
      */
     private void addUsage(Node node) {
@@ -352,7 +351,7 @@
 
     /**
      * Removes a given node from this node's {@linkplain #usages() usages}.
-     * 
+     *
      * @param node the node to remove
      * @return whether or not {@code usage} was in the usage list
      */
@@ -477,6 +476,10 @@
         }
     }
 
+    protected void updateUsagesInterface(NodeInterface oldInput, NodeInterface newInput) {
+        updateUsages(oldInput == null ? null : oldInput.asNode(), newInput == null ? null : newInput.asNode());
+    }
+
     /**
      * Updates the predecessor of the given nodes after a successor slot is changed from
      * oldSuccessor to newSuccessor: removes this node from oldSuccessor's predecessors and adds
@@ -513,6 +516,10 @@
         return NodeClass.get(getClass());
     }
 
+    public boolean isAllowedUsageType(InputType type) {
+        return getNodeClass().getAllowedUsageTypes().contains(type);
+    }
+
     private boolean checkReplaceWith(Node other) {
         assert assertTrue(graph == null || !graph.isFrozen(), "cannot modify frozen graph");
         assert assertFalse(other == this, "cannot replace a node with itself");
@@ -536,6 +543,19 @@
         clearUsages();
     }
 
+    public void replaceAtUsages(InputType type, Node other) {
+        assert checkReplaceWith(other);
+        for (Node usage : usages().snapshot()) {
+            NodeClassIterator iter = usage.inputs().iterator();
+            while (iter.hasNext()) {
+                Position pos = iter.nextPosition();
+                if (pos.getInputType(usage) == type) {
+                    pos.set(usage, other);
+                }
+            }
+        }
+    }
+
     private void maybeNotifyChanged(Node usage) {
         if (graph != null) {
             assert !graph.isFrozen();
@@ -656,7 +676,7 @@
      * Must be overridden by subclasses that implement {@link Canonicalizable}. The implementation
      * in {@link Node} exists to obviate the need to cast a node before invoking
      * {@link Canonicalizable#canonical(CanonicalizerTool)}.
-     * 
+     *
      * @param tool
      */
     public Node canonical(CanonicalizerTool tool) {
@@ -667,7 +687,7 @@
      * Must be overridden by subclasses that implement {@link Simplifiable}. The implementation in
      * {@link Node} exists to obviate the need to cast a node before invoking
      * {@link Simplifiable#simplify(SimplifierTool)}.
-     * 
+     *
      * @param tool
      */
     public void simplify(SimplifierTool tool) {
@@ -726,6 +746,14 @@
             for (Node usage : usages()) {
                 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage);
                 assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage);
+                NodeClassIterator iterator = usage.inputs().iterator();
+                while (iterator.hasNext()) {
+                    Position pos = iterator.nextPosition();
+                    if (pos.get(usage) == this && pos.getInputType(usage) != InputType.Unchecked) {
+                        assert isAllowedUsageType(pos.getInputType(usage)) : "invalid input of type " + pos.getInputType(usage) + " from " + usage + " to " + this + " (" + pos.getInputName(usage) +
+                                        ")";
+                    }
+                }
             }
         }
         if (predecessor != null) {
@@ -797,7 +825,7 @@
      * Fills a {@link Map} with properties of this node for use in debugging (e.g., to view in the
      * ideal graph visualizer). Subclasses overriding this method should also fill the map using
      * their superclass.
-     * 
+     *
      * @param map
      */
     public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
@@ -879,7 +907,8 @@
         if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) {
             formatter.format("%s", toString(Verbosity.Id));
         } else if ((flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE) {
-            formatter.format("%s", toString(Verbosity.Long));
+            // Use All here since Long is only slightly longer than Short.
+            formatter.format("%s", toString(Verbosity.All));
         } else {
             formatter.format("%s", toString(Verbosity.Short));
         }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,15 +26,16 @@
 
 import java.lang.reflect.*;
 import java.util.*;
-import java.util.concurrent.*;
 
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.Graph.DuplicationReplacement;
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.Input;
+import com.oracle.graal.graph.Node.Successor;
+import com.oracle.graal.graph.Node.Verbosity;
 import com.oracle.graal.graph.spi.*;
 
 /**
- * Lazily associated metadata for every {@link Node} type. The metadata includes:
+ * Metadata for every {@link Node} type. The metadata includes:
  * <ul>
  * <li>The offsets of fields annotated with {@link Input} and {@link Successor} as well as methods
  * for iterating over such fields.</li>
@@ -43,72 +44,7 @@
  */
 public final class NodeClass extends FieldIntrospection {
 
-    /**
-     * Maps {@link Class} values (for {@link Node} types) to {@link NodeClass} values.
-     * 
-     * Only a single Registry instance can be created. If a runtime creates a specialized registry,
-     * it must do so before the class initializer of {@link NodeClass} is executed.
-     */
-    public static class Registry {
-
-        private static Registry instance;
-
-        /**
-         * Gets the singleton {@link Registry} instance, creating it first if necessary.
-         */
-        static synchronized Registry instance() {
-            if (instance == null) {
-                return new Registry();
-            }
-            return instance;
-        }
-
-        protected Registry() {
-            assert instance == null : "exactly one registry can be created";
-            instance = this;
-        }
-
-        /**
-         * @return the {@link NodeClass} value for {@code key} or {@code null} if no such mapping
-         *         exists
-         */
-        protected NodeClass get(Class<? extends Node> key) {
-            return (NodeClass) allClasses.get(key);
-        }
-
-        /**
-         * Same as {@link #get(Class)} except that a {@link NodeClass} is created if no such mapping
-         * exists. The creation of a {@link NodeClass} must be serialized as
-         * {@link NodeClass#NodeClass(Class)} accesses both {@link FieldIntrospection#allClasses}
-         * and {@link NodeClass#nextIterableId}.
-         * <p>
-         * The fact that {@link ConcurrentHashMap#put} {@link ConcurrentHashMap#get} are used should
-         * make the double-checked locking idiom work in the way {@link NodeClass#get(Class)} uses
-         * this method and {@link #get(Class)}.
-         */
-        final synchronized NodeClass make(Class<? extends Node> key) {
-            NodeClass value = (NodeClass) allClasses.get(key);
-            if (value == null) {
-                value = new NodeClass(key);
-                Object old = allClasses.putIfAbsent(key, value);
-                assert old == null;
-                registered(key, value);
-            }
-            return value;
-        }
-
-        /**
-         * Hook for a subclass to be notified of a new mapping added to the registry.
-         * 
-         * @param key
-         * @param value
-         */
-        protected void registered(Class<? extends Node> key, NodeClass value) {
-
-        }
-    }
-
-    private static final Registry registry = Registry.instance();
+    private static final Object GetNodeClassLock = new Object();
 
     /**
      * Gets the {@link NodeClass} associated with a given {@link Class}.
@@ -116,11 +52,22 @@
     @SuppressWarnings("unchecked")
     public static NodeClass get(Class<?> c) {
         Class<? extends Node> key = (Class<? extends Node>) c;
-        NodeClass value = registry.get(key);
-        if (value != null) {
-            return value;
+        NodeClass value = (NodeClass) allClasses.get(key);
+        // The fact that {@link ConcurrentHashMap#put} and {@link ConcurrentHashMap#get}
+        // are used makes the double-checked locking idiom work.
+        if (value == null) {
+            // The creation of a NodeClass must be serialized as the NodeClass constructor accesses
+            // both FieldIntrospection.allClasses and NodeClass.nextIterableId.
+            synchronized (GetNodeClassLock) {
+                value = (NodeClass) allClasses.get(key);
+                if (value == null) {
+                    value = new NodeClass(key);
+                    Object old = allClasses.putIfAbsent(key, value);
+                    assert old == null : old + "   " + key;
+                }
+            }
         }
-        return registry.make(key);
+        return value;
     }
 
     public static final int NOT_ITERABLE = -1;
@@ -134,8 +81,11 @@
 
     private final int directInputCount;
     private final long[] inputOffsets;
+    private final InputType[] inputTypes;
+    private final String[] inputNames;
     private final int directSuccessorCount;
     private final long[] successorOffsets;
+    private final String[] successorNames;
     private final Class<?>[] dataTypes;
     private final boolean canGVN;
     private final boolean isLeafNode;
@@ -143,6 +93,7 @@
     private final String shortName;
     private final String nameTemplate;
     private final int iterableId;
+    private final EnumSet<InputType> allowedUsageTypes;
     private int[] iterableIds;
 
     private static final DebugMetric ITERABLE_NODE_TYPES = Debug.metric("IterableNodeTypes");
@@ -173,8 +124,21 @@
 
         directInputCount = scanner.inputOffsets.size();
         inputOffsets = sortedLongCopy(scanner.inputOffsets, scanner.inputListOffsets);
+        inputTypes = new InputType[inputOffsets.length];
+        inputNames = new String[inputOffsets.length];
+        for (int i = 0; i < inputOffsets.length; i++) {
+            inputTypes[i] = scanner.types.get(inputOffsets[i]);
+            inputNames[i] = scanner.names.get(inputOffsets[i]);
+            assert inputTypes[i] != null;
+            assert inputNames[i] != null;
+        }
         directSuccessorCount = scanner.successorOffsets.size();
         successorOffsets = sortedLongCopy(scanner.successorOffsets, scanner.successorListOffsets);
+        successorNames = new String[successorOffsets.length];
+        for (int i = 0; i < successorOffsets.length; i++) {
+            successorNames[i] = scanner.names.get(successorOffsets[i]);
+            assert successorNames[i] != null;
+        }
 
         dataOffsets = sortedLongCopy(scanner.dataOffsets);
         dataTypes = new Class[dataOffsets.length];
@@ -202,7 +166,19 @@
                 newNameTemplate = info.nameTemplate();
             }
         }
+        EnumSet<InputType> newAllowedUsageTypes = EnumSet.noneOf(InputType.class);
+        Class<?> current = clazz;
+        do {
+            NodeInfo currentInfo = current.getAnnotation(NodeInfo.class);
+            if (currentInfo != null) {
+                if (currentInfo.allowedUsageTypes().length > 0) {
+                    newAllowedUsageTypes.addAll(Arrays.asList(currentInfo.allowedUsageTypes()));
+                }
+            }
+            current = current.getSuperclass();
+        } while (current != Node.class);
         this.nameTemplate = newNameTemplate == null ? newShortName : newNameTemplate;
+        this.allowedUsageTypes = newAllowedUsageTypes;
         this.shortName = newShortName;
         if (presetIterableIds != null) {
             this.iterableIds = presetIterableIds;
@@ -296,12 +272,18 @@
         return nextIterableId;
     }
 
+    public EnumSet<InputType> getAllowedUsageTypes() {
+        return allowedUsageTypes;
+    }
+
     protected static class FieldScanner extends BaseFieldScanner {
 
         public final ArrayList<Long> inputOffsets = new ArrayList<>();
         public final ArrayList<Long> inputListOffsets = new ArrayList<>();
         public final ArrayList<Long> successorOffsets = new ArrayList<>();
         public final ArrayList<Long> successorListOffsets = new ArrayList<>();
+        public final HashMap<Long, InputType> types = new HashMap<>();
+        public final HashMap<Long, String> names = new HashMap<>();
 
         protected FieldScanner(CalcOffset calc) {
             super(calc);
@@ -311,6 +293,7 @@
         protected void scanField(Field field, Class<?> type, long offset) {
             if (field.isAnnotationPresent(Node.Input.class)) {
                 assert !field.isAnnotationPresent(Node.Successor.class) : "field cannot be both input and successor";
+                Input inputAnnotation = field.getAnnotation(Node.Input.class);
                 if (INPUT_LIST_CLASS.isAssignableFrom(type)) {
                     GraalInternalError.guarantee(Modifier.isFinal(field.getModifiers()), "NodeInputList input field %s should be final", field);
                     GraalInternalError.guarantee(!Modifier.isPublic(field.getModifiers()), "NodeInputList input field %s should not be public", field);
@@ -321,7 +304,9 @@
                     GraalInternalError.guarantee(Modifier.isPrivate(field.getModifiers()), "Node input field %s should be private", field);
                     inputOffsets.add(offset);
                 }
-                if (field.getAnnotation(Node.Input.class).notDataflow()) {
+                types.put(offset, inputAnnotation.value());
+                names.put(offset, field.getName());
+                if (inputAnnotation.value() != InputType.Value) {
                     fieldNames.put(offset, field.getName() + "#NDF");
                 }
             } else if (field.isAnnotationPresent(Node.Successor.class)) {
@@ -335,6 +320,7 @@
                     GraalInternalError.guarantee(Modifier.isPrivate(field.getModifiers()), "Node successor field %s should be private", field);
                     successorOffsets.add(offset);
                 }
+                names.put(offset, field.getName());
             } else {
                 GraalInternalError.guarantee(!NODE_CLASS.isAssignableFrom(type) || field.getName().equals("Null"), "suspicious node field: %s", field);
                 GraalInternalError.guarantee(!INPUT_LIST_CLASS.isAssignableFrom(type), "suspicious node input list field: %s", field);
@@ -365,7 +351,7 @@
 
     /**
      * Describes an edge slot for a {@link NodeClass}.
-     * 
+     *
      * @see NodeClass#get(Node, Position)
      * @see NodeClass#getName(Position)
      */
@@ -390,6 +376,14 @@
             return node.getNodeClass().get(node, this);
         }
 
+        public InputType getInputType(Node node) {
+            return node.getNodeClass().getInputType(this);
+        }
+
+        public String getInputName(Node node) {
+            return node.getNodeClass().getEdgeName(this);
+        }
+
         public void set(Node node, Node value) {
             node.getNodeClass().set(node, this, value);
         }
@@ -446,7 +440,7 @@
         unsafe.putObject(node, offset, value);
     }
 
-    private static void putNodeList(Node node, long offset, NodeList value) {
+    private static void putNodeList(Node node, long offset, NodeList<?> value) {
         unsafe.putObject(node, offset, value);
     }
 
@@ -456,7 +450,7 @@
      * of the fields are treated as {@link NodeList}s. All elements of these NodeLists will be
      * visited by the iterator as well. This iterator can be used to iterate over the inputs or
      * successors of a node.
-     * 
+     *
      * An iterator of this type will not return null values, unless the field values are modified
      * concurrently. Concurrent modifications are detected by an assertion on a best-effort basis.
      */
@@ -467,7 +461,7 @@
 
         /**
          * Creates an iterator that will iterate over fields in the given node.
-         * 
+         *
          * @param node the node which contains the fields.
          */
         NodeClassIterator(Node node) {
@@ -759,7 +753,7 @@
 
     /**
      * Populates a given map with the names and values of all data fields.
-     * 
+     *
      * @param node the node from which to take the values.
      * @param properties a map that will be populated.
      */
@@ -920,6 +914,15 @@
         }
     }
 
+    public InputType getInputType(Position pos) {
+        assert pos.input;
+        return inputTypes[pos.index];
+    }
+
+    public String getEdgeName(Position pos) {
+        return pos.input ? inputNames[pos.index] : successorNames[pos.index];
+    }
+
     public NodeList<?> getNodeList(Node node, Position pos) {
         long offset = pos.input ? inputOffsets[pos.index] : successorOffsets[pos.index];
         assert pos.subIndex == NODE_LIST;
@@ -1126,7 +1129,7 @@
      * Clear all inputs in the given node. This is accomplished by setting input fields to null and
      * replacing input lists with new lists. (which is important so that this method can be used to
      * clear the inputs of cloned nodes.)
-     * 
+     *
      * @param node the node to be cleared
      */
     public void clearInputs(Node node) {
@@ -1146,7 +1149,7 @@
      * Clear all successors in the given node. This is accomplished by setting successor fields to
      * null and replacing successor lists with new lists. (which is important so that this method
      * can be used to clear the successors of cloned nodes.)
-     * 
+     *
      * @param node the node to be cleared
      */
     public void clearSuccessors(Node node) {
@@ -1165,7 +1168,7 @@
     /**
      * Copies the inputs from node to newNode. The nodes are expected to be of the exact same
      * NodeClass type.
-     * 
+     *
      * @param node the node from which the inputs should be copied.
      * @param newNode the node to which the inputs should be copied.
      */
@@ -1187,7 +1190,7 @@
     /**
      * Copies the successors from node to newNode. The nodes are expected to be of the exact same
      * NodeClass type.
-     * 
+     *
      * @param node the node from which the successors should be copied.
      * @param newNode the node to which the successors should be copied.
      */
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeFlood.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeFlood.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,7 @@
  */
 package com.oracle.graal.graph;
 
-import java.util.ArrayDeque;
-import java.util.Iterator;
-import java.util.Queue;
+import java.util.*;
 
 public class NodeFlood implements Iterable<Node> {
 
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInfo.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInfo.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,12 +22,9 @@
  */
 package com.oracle.graal.graph;
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.Verbosity;
 
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
@@ -40,4 +37,6 @@
      * using &#123;i#inputName&#125; or &#123;p#propertyName&#125;.
      */
     String nameTemplate() default "";
+
+    InputType[] allowedUsageTypes() default {};
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInterface.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.graph;
+
+public interface NodeInterface {
+    Node asNode();
+}
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeWorkList.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeWorkList.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,7 @@
  */
 package com.oracle.graal.graph;
 
-import java.util.ArrayDeque;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Queue;
+import java.util.*;
 
 public class NodeWorkList implements Iterable<Node> {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizationStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.amd64.AMD64.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.stubs.*;
+
+final class AMD64DeoptimizationStub extends DeoptimizationStub {
+
+    private RegisterConfig registerConfig;
+
+    public AMD64DeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) {
+        super(providers, target, linkage);
+        registerConfig = new AMD64HotSpotRegisterConfig(target.arch, HotSpotGraalRuntime.runtime().getConfig(), new Register[]{rax, rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r13, r14});
+    }
+
+    @Override
+    public RegisterConfig getRegisterConfig() {
+        return registerConfig;
+    }
+}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.lir.StandardOp.BlockEndOp;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 
@@ -41,6 +41,6 @@
 
     @Override
     public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
-        AMD64Call.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info);
+        AMD64Call.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER), null, false, info);
     }
 }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,8 +41,8 @@
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.nfi.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
@@ -67,8 +67,8 @@
     }
 
     @Override
-    public FrameMap newFrameMap() {
-        return new AMD64FrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new AMD64FrameMap(getCodeCache(), registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.amd64.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
@@ -108,10 +109,11 @@
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
         Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null);
-        Replacements replacements = createReplacements(runtime, assumptions, p);
+        HotSpotSnippetReflectionProvider snippetReflection = createSnippetReflection();
+        Replacements replacements = createReplacements(runtime, assumptions, p, snippetReflection);
         HotSpotDisassemblerProvider disassembler = createDisassembler(runtime);
         HotSpotSuitesProvider suites = createSuites(runtime);
-        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers);
+        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection);
 
         return createBackend(runtime, providers);
     }
@@ -128,8 +130,8 @@
         return new HotSpotDisassemblerProvider(runtime);
     }
 
-    protected Replacements createReplacements(HotSpotGraalRuntime runtime, Assumptions assumptions, Providers p) {
-        return new HotSpotReplacementsImpl(p, runtime.getConfig(), assumptions, p.getCodeCache().getTarget());
+    protected Replacements createReplacements(HotSpotGraalRuntime runtime, Assumptions assumptions, Providers p, SnippetReflectionProvider snippetReflection) {
+        return new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, p.getCodeCache().getTarget());
     }
 
     protected AMD64HotSpotForeignCallsProvider createForeignCalls(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache,
@@ -153,6 +155,10 @@
         return new HotSpotSuitesProvider(runtime);
     }
 
+    protected HotSpotSnippetReflectionProvider createSnippetReflection() {
+        return new HotSpotSnippetReflectionProvider();
+    }
+
     protected AMD64HotSpotLoweringProvider createLowerer(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) {
         return new AMD64HotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers);
     }
@@ -183,15 +189,15 @@
         } else {
             /*
              * System V Application Binary Interface, AMD64 Architecture Processor Supplement
-             * 
+             *
              * Draft Version 0.96
-             * 
+             *
              * http://www.uclibc.org/docs/psABI-x86_64.pdf
-             * 
+             *
              * 3.2.1
-             * 
+             *
              * ...
-             * 
+             *
              * This subsection discusses usage of each register. Registers %rbp, %rbx and %r12
              * through %r15 "belong" to the calling function and the called function is required to
              * preserve their values. In other words, a called function must preserve these
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -26,6 +26,7 @@
 
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 
@@ -33,11 +34,11 @@
  * Removes the current frame and tail calls the uncommon trap routine.
  */
 @Opcode("DEOPT_CALLER")
-final class AMD64HotSpotDeoptimizeCallerOp extends AMD64HotSpotEpilogueOp {
+final class AMD64HotSpotDeoptimizeCallerOp extends AMD64HotSpotEpilogueOp implements BlockEndOp {
 
     @Override
     public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
         leaveFrameAndRestoreRbp(crb, masm);
-        AMD64Call.directJmp(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP));
+        AMD64Call.directJmp(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER));
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEnterUnpackFramesStackFrameOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.amd64.AMD64.*;
+import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.amd64.*;
+import com.oracle.graal.lir.asm.*;
+
+/**
+ * Emits code that enters a stack frame which is tailored to call the C++ method
+ * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}.
+ */
+@Opcode("ENTER_UNPACK_FRAMES_STACK_FRAME")
+final class AMD64HotSpotEnterUnpackFramesStackFrameOp extends AMD64LIRInstruction {
+
+    private final Register thread;
+    private final int threadLastJavaSpOffset;
+    private final int threadLastJavaPcOffset;
+    private final int threadLastJavaFpOffset;
+    @Alive(REG) AllocatableValue framePc;
+    @Alive(REG) AllocatableValue senderSp;
+    @Alive(REG) AllocatableValue senderFp;
+
+    AMD64HotSpotEnterUnpackFramesStackFrameOp(Register thread, int threadLastJavaSpOffset, int threadLastJavaPcOffset, int threadLastJavaFpOffset, AllocatableValue framePc, AllocatableValue senderSp,
+                    AllocatableValue senderFp) {
+        this.thread = thread;
+        this.threadLastJavaSpOffset = threadLastJavaSpOffset;
+        this.threadLastJavaPcOffset = threadLastJavaPcOffset;
+        this.threadLastJavaFpOffset = threadLastJavaFpOffset;
+        this.framePc = framePc;
+        this.senderSp = senderSp;
+        this.senderFp = senderFp;
+    }
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+        final int totalFrameSize = crb.frameMap.totalFrameSize();
+        masm.push(asRegister(framePc));
+        masm.push(asRegister(senderFp));
+        masm.movq(rbp, rsp);
+
+        /*
+         * Allocate a full sized frame. Since return address and base pointer are already in place
+         * (see above) we allocate two words less.
+         */
+        masm.decrementq(rsp, totalFrameSize - 2 * crb.target.wordSize);
+
+        // Set up last Java values.
+        masm.movq(new AMD64Address(thread, threadLastJavaSpOffset), rsp);
+
+        /*
+         * Save the PC since it cannot easily be retrieved using the last Java SP after we aligned
+         * SP. Don't need the precise return PC here, just precise enough to point into this code
+         * blob.
+         */
+        masm.leaq(rax, new AMD64Address(rip, 0));
+        masm.movq(new AMD64Address(thread, threadLastJavaPcOffset), rax);
+
+        // Use BP because the frames look interpreted now.
+        masm.movq(new AMD64Address(thread, threadLastJavaFpOffset), rbp);
+
+        // Align the stack for the following unpackFrames call.
+        masm.andq(rsp, -(crb.target.stackAlignment));
+    }
+}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,14 +30,13 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 
 /**
  * Superclass for operations that use the value of RBP saved in a method's prologue.
  */
-abstract class AMD64HotSpotEpilogueOp extends AMD64LIRInstruction implements BlockEndOp {
+abstract class AMD64HotSpotEpilogueOp extends AMD64LIRInstruction {
 
     /**
      * The type of location (i.e., stack or register) in which RBP is saved is not known until
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -51,7 +51,8 @@
 
     @Override
     public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-        Kind word = providers.getCodeCache().getTarget().wordKind;
+        TargetDescription target = providers.getCodeCache().getTarget();
+        Kind word = target.wordKind;
 
         // The calling convention for the exception handler stub is (only?) defined in
         // TemplateInterpreterGenerator::generate_throw_exception()
@@ -62,6 +63,8 @@
         register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, null, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION));
         register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, ANY_LOCATION));
 
+        link(new AMD64DeoptimizationStub(providers, target, registerStubCall(UNCOMMON_TRAP_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS)));
+
         // When the java.ext.dirs property is modified then the crypto classes might not be found.
         // If that's the case we ignore the ClassNotFoundException and continue since we cannot
         // replace a non-existing method anyway.
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -31,6 +31,7 @@
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.asm.*;
 
 /**
@@ -38,7 +39,7 @@
  * and jumps to the handler.
  */
 @Opcode("JUMP_TO_EXCEPTION_HANDLER_IN_CALLER")
-final class AMD64HotSpotJumpToExceptionHandlerInCallerOp extends AMD64HotSpotEpilogueOp {
+final class AMD64HotSpotJumpToExceptionHandlerInCallerOp extends AMD64HotSpotEpilogueOp implements BlockEndOp {
 
     @Use(REG) AllocatableValue handlerInCallerPc;
     @Use(REG) AllocatableValue exception;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.amd64.AMD64.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*;
 
 import java.util.*;
 
@@ -43,8 +44,11 @@
 import com.oracle.graal.hotspot.nodes.type.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.NoOp;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.amd64.*;
+import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
+import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
 import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp;
 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
@@ -52,6 +56,7 @@
 import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp;
 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 
 /**
@@ -173,12 +178,65 @@
         super.emitForeignCall(linkage, result, arguments, temps, info);
     }
 
-    protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations) {
-        AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations, true);
+    public void emitLeaveCurrentStackFrame() {
+        append(new AMD64HotSpotLeaveCurrentStackFrameOp());
+    }
+
+    public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
+        Variable frameSizeVariable = load(frameSize);
+        Variable initialInfoVariable = load(initialInfo);
+        append(new AMD64HotSpotLeaveDeoptimizedStackFrameOp(frameSizeVariable, initialInfoVariable));
+    }
+
+    public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp) {
+        Register thread = getProviders().getRegisters().getThreadRegister();
+        Variable framePcVariable = load(framePc);
+        Variable senderSpVariable = load(senderSp);
+        Variable senderFpVariable = load(senderFp);
+        append(new AMD64HotSpotEnterUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), framePcVariable,
+                        senderSpVariable, senderFpVariable));
+    }
+
+    public void emitLeaveUnpackFramesStackFrame() {
+        Register thread = getProviders().getRegisters().getThreadRegister();
+        append(new AMD64HotSpotLeaveUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset()));
+    }
+
+    /**
+     * @param savedRegisters the registers saved by this operation which may be subject to pruning
+     * @param savedRegisterLocations the slots to which the registers are saved
+     * @param supportsRemove determines if registers can be pruned
+     */
+    protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations, boolean supportsRemove) {
+        AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations, supportsRemove);
         append(save);
         return save;
     }
 
+    /**
+     * Adds a node to the graph that saves all allocatable registers to the stack.
+     *
+     * @param supportsRemove determines if registers can be pruned
+     * @return the register save node
+     */
+    private AMD64SaveRegistersOp emitSaveAllRegisters(Register[] savedRegisters, boolean supportsRemove) {
+        StackSlot[] savedRegisterLocations = new StackSlot[savedRegisters.length];
+        for (int i = 0; i < savedRegisters.length; i++) {
+            PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory());
+            assert kind != Kind.Illegal;
+            StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(kind);
+            savedRegisterLocations[i] = spillSlot;
+        }
+        return emitSaveRegisters(savedRegisters, savedRegisterLocations, supportsRemove);
+    }
+
+    @Override
+    public SaveRegistersOp emitSaveAllRegisters() {
+        // We are saving all registers.
+        // TODO Save upper half of YMM registers.
+        return emitSaveAllRegisters(cpuxmmRegisters, false);
+    }
+
     protected void emitRestoreRegisters(AMD64SaveRegistersOp save) {
         append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save));
     }
@@ -189,44 +247,42 @@
 
     @Override
     public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) {
-        boolean destroysRegisters = linkage.destroysRegisters();
+        HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
+        boolean destroysRegisters = hotspotLinkage.destroysRegisters();
 
         AMD64SaveRegistersOp save = null;
-        StackSlot[] savedRegisterLocations = null;
         if (destroysRegisters) {
             if (getStub() != null) {
                 if (getStub().preservesRegisters()) {
                     Register[] savedRegisters = getResult().getFrameMap().registerConfig.getAllocatableRegisters();
-                    savedRegisterLocations = new StackSlot[savedRegisters.length];
-                    for (int i = 0; i < savedRegisters.length; i++) {
-                        PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory());
-                        assert kind != Kind.Illegal;
-                        StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(kind);
-                        savedRegisterLocations[i] = spillSlot;
-                    }
-                    save = emitSaveRegisters(savedRegisters, savedRegisterLocations);
+                    save = emitSaveAllRegisters(savedRegisters, true);
                 }
             }
         }
 
         Variable result;
+        DeoptimizingNode deoptInfo = null;
+        if (hotspotLinkage.canDeoptimize()) {
+            deoptInfo = info;
+            assert deoptInfo != null || getStub() != null;
+            assert hotspotLinkage.needsJavaFrameAnchor();
+        }
 
-        if (linkage.canDeoptimize()) {
-            assert info != null || ((AMD64HotSpotLIRGenerationResult) getResult()).getStub() != null;
+        if (hotspotLinkage.needsJavaFrameAnchor()) {
             Register thread = getProviders().getRegisters().getThreadRegister();
             append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
-            result = super.emitForeignCall(linkage, info, args);
+            result = super.emitForeignCall(hotspotLinkage, deoptInfo, args);
             append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
         } else {
-            result = super.emitForeignCall(linkage, info, args);
+            result = super.emitForeignCall(hotspotLinkage, deoptInfo, args);
         }
 
         if (destroysRegisters) {
             if (getStub() != null) {
                 if (getStub().preservesRegisters()) {
-                    assert !((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo().containsKey(currentRuntimeCallInfo);
-                    ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo().put(currentRuntimeCallInfo, save);
-
+                    AMD64HotSpotLIRGenerationResult generationResult = (AMD64HotSpotLIRGenerationResult) getResult();
+                    assert !generationResult.getCalleeSaveInfo().containsKey(currentRuntimeCallInfo);
+                    generationResult.getCalleeSaveInfo().put(currentRuntimeCallInfo, save);
                     emitRestoreRegisters(save);
                 } else {
                     assert zapRegisters();
@@ -237,6 +293,21 @@
         return result;
     }
 
+    public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
+        ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(UNCOMMON_TRAP);
+
+        Register thread = getProviders().getRegisters().getThreadRegister();
+        append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
+        Variable result = super.emitForeignCall(linkage, null, thread.asValue(Kind.Long), trapRequest);
+        append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
+
+        Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo();
+        assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo);
+        calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp);
+
+        return result;
+    }
+
     protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
         AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
         append(zap);
@@ -338,7 +409,12 @@
      */
     protected static Constant compress(Constant c, CompressEncoding encoding) {
         if (c.getKind() == Kind.Long) {
-            return Constant.forIntegerKind(Kind.Int, (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL), c.getPrimitiveAnnotation());
+            int compressedValue = (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL);
+            if (c instanceof HotSpotMetaspaceConstant) {
+                return HotSpotMetaspaceConstant.forMetaspaceObject(Kind.Int, compressedValue, HotSpotMetaspaceConstant.getMetaspaceObject(c));
+            } else {
+                return Constant.forIntegerKind(Kind.Int, compressedValue);
+            }
         } else {
             throw GraalInternalError.shouldNotReachHere();
         }
@@ -360,6 +436,14 @@
         }
     }
 
+    public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
+        Variable frameSizeVariable = load(frameSize);
+        Variable framePcVariable = load(framePc);
+        Variable senderSpVariable = load(senderSp);
+        Variable initialInfoVariable = load(initialInfo);
+        append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable));
+    }
+
     @Override
     public Variable emitLoad(PlatformKind kind, Value address, Access access) {
         AMD64AddressValue loadAddress = asAddressValue(address);
@@ -443,17 +527,41 @@
     }
 
     @Override
-    public Value emitCompress(Value pointer, CompressEncoding encoding) {
-        Variable result = newVariable(NarrowOopStamp.NarrowOop);
-        append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding));
-        return result;
+    public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
+        if (pointer.getPlatformKind() == Kind.Object) {
+            Variable result = newVariable(NarrowOopStamp.NarrowOop);
+            append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
+            return result;
+        } else {
+            assert pointer.getPlatformKind() == Kind.Long;
+            Variable result = newVariable(Kind.Int);
+            AllocatableValue base = Value.ILLEGAL;
+            if (encoding.base != 0) {
+                base = newVariable(Kind.Long);
+                append(new AMD64Move.MoveToRegOp(Kind.Long, base, Constant.forLong(encoding.base)));
+            }
+            append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
+            return result;
+        }
     }
 
     @Override
-    public Value emitUncompress(Value pointer, CompressEncoding encoding) {
-        Variable result = newVariable(Kind.Object);
-        append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding));
-        return result;
+    public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
+        if (pointer.getPlatformKind() == NarrowOopStamp.NarrowOop) {
+            Variable result = newVariable(Kind.Object);
+            append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
+            return result;
+        } else {
+            assert pointer.getPlatformKind() == Kind.Int;
+            Variable result = newVariable(Kind.Long);
+            AllocatableValue base = Value.ILLEGAL;
+            if (encoding.base != 0) {
+                base = newVariable(Kind.Long);
+                append(new AMD64Move.MoveToRegOp(Kind.Long, base, Constant.forLong(encoding.base)));
+            }
+            append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
+            return result;
+        }
     }
 
     @Override
@@ -469,4 +577,20 @@
         }
     }
 
+    @Override
+    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
+        PlatformKind kind = newValue.getPlatformKind();
+        assert kind == expectedValue.getPlatformKind();
+        Kind memKind = getMemoryKind(kind);
+
+        AMD64AddressValue addressValue = asAddressValue(address);
+        RegisterValue raxRes = AMD64.rax.asValue(kind);
+        emitMove(raxRes, expectedValue);
+        append(new CompareAndSwapOp(memKind, raxRes, addressValue, raxRes, asAllocatable(newValue)));
+
+        assert trueValue.getPlatformKind() == falseValue.getPlatformKind();
+        Variable result = newVariable(trueValue.getPlatformKind());
+        append(new CondMoveOp(result, Condition.EQ, asAllocatable(trueValue), falseValue));
+        return result;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveCurrentStackFrameOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.amd64.AMD64.*;
+
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
+
+/**
+ * Pops the current frame off the stack including the return address.
+ */
+@Opcode("LEAVE_CURRENT_STACK_FRAME")
+final class AMD64HotSpotLeaveCurrentStackFrameOp extends AMD64HotSpotEpilogueOp {
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+        leaveFrameAndRestoreRbp(crb, masm);
+        masm.addq(rsp, crb.target.arch.getReturnAddressSize());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveDeoptimizedStackFrameOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.amd64.AMD64.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
+
+/**
+ * Pops the current frame off the stack including the return address.
+ */
+@Opcode("LEAVE_DEOPTIMIZED_STACK_FRAME")
+final class AMD64HotSpotLeaveDeoptimizedStackFrameOp extends AMD64HotSpotEpilogueOp {
+
+    @Use(REG) AllocatableValue frameSize;
+    @Use(REG) AllocatableValue framePointer;
+
+    public AMD64HotSpotLeaveDeoptimizedStackFrameOp(AllocatableValue frameSize, AllocatableValue initialInfo) {
+        this.frameSize = frameSize;
+        this.framePointer = initialInfo;
+    }
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+        masm.addq(rsp, asRegister(frameSize));
+        // Restore the frame pointer before stack bang because if a stack overflow is thrown it
+        // needs to be pushed (and preserved).
+        masm.movq(rbp, asRegister(framePointer));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLeaveUnpackFramesStackFrameOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.amd64.AMD64.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.amd64.*;
+import com.oracle.graal.lir.asm.*;
+
+/**
+ * Emits code that leaves a stack frame which is tailored to call the C++ method
+ * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}.
+ */
+@Opcode("LEAVE_UNPACK_FRAMES_STACK_FRAME")
+final class AMD64HotSpotLeaveUnpackFramesStackFrameOp extends AMD64LIRInstruction {
+
+    private final Register thread;
+    private final int threadLastJavaSpOffset;
+    private final int threadLastJavaPcOffset;
+    private final int threadLastJavaFpOffset;
+
+    AMD64HotSpotLeaveUnpackFramesStackFrameOp(Register thread, int threadLastJavaSpOffset, int threadLastJavaPcOffset, int threadLastJavaFpOffset) {
+        this.thread = thread;
+        this.threadLastJavaSpOffset = threadLastJavaSpOffset;
+        this.threadLastJavaPcOffset = threadLastJavaPcOffset;
+        this.threadLastJavaFpOffset = threadLastJavaFpOffset;
+    }
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+        // Restore stack pointer.
+        masm.movq(rsp, new AMD64Address(thread, threadLastJavaSpOffset));
+
+        // Clear last Java frame values.
+        masm.movslq(new AMD64Address(thread, threadLastJavaSpOffset), 0);
+        masm.movslq(new AMD64Address(thread, threadLastJavaPcOffset), 0);
+        masm.movslq(new AMD64Address(thread, threadLastJavaFpOffset), 0);
+    }
+}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,7 +41,7 @@
 
     @Override
     public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-        convertSnippets = new AMD64ConvertSnippets.Templates(providers, providers.getCodeCache().getTarget());
+        convertSnippets = new AMD64ConvertSnippets.Templates(providers, providers.getSnippetReflection(), providers.getCodeCache().getTarget());
         super.initialize(providers, config);
     }
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMemoryPeephole.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,6 +31,8 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.data.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.type.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp;
@@ -63,9 +65,9 @@
                 masm.cmpl(x.toAddress(), 0);
             } else {
                 if (y.getKind() == Kind.Object) {
-                    crb.recordInlineDataInCode(new OopData(0, constant.asObject(), true));
+                    crb.recordInlineDataInCode(new OopData(0, HotSpotObjectConstant.asObject(constant), true));
                 } else if (y.getKind() == Kind.Long) {
-                    crb.recordInlineDataInCode(new MetaspaceData(0, constant.asLong(), constant.getPrimitiveAnnotation(), true));
+                    crb.recordInlineDataInCode(new MetaspaceData(0, constant.asLong(), HotSpotMetaspaceConstant.getMetaspaceObject(constant), true));
                 } else {
                     throw GraalInternalError.shouldNotReachHere();
                 }
@@ -82,11 +84,21 @@
     }
 
     @Override
+    protected Kind getMemoryKind(Access access) {
+        PlatformKind kind = gen.getLIRGenerator().getPlatformKind(access.asNode().stamp());
+        if (kind == NarrowOopStamp.NarrowOop) {
+            return Kind.Int;
+        } else {
+            return (Kind) kind;
+        }
+    }
+
+    @Override
     protected boolean emitCompareBranchMemory(ValueNode left, ValueNode right, Access access, Condition cond, boolean unorderedIsTrue, LabelRef trueLabel, LabelRef falseLabel,
                     double trueLabelProbability) {
         if (HotSpotGraalRuntime.runtime().getConfig().useCompressedOops) {
             ValueNode other = selectOtherInput(left, right, access);
-            Kind kind = access.nullCheckLocation().getValueKind();
+            Kind kind = getMemoryKind(access);
 
             if (other.isConstant() && kind == Kind.Object && access.isCompressible()) {
                 ensureEvaluated(other);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 import com.oracle.graal.hotspot.data.*;
-import com.oracle.graal.hotspot.nodes.type.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
@@ -53,8 +53,8 @@
         public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
             if (kind == Kind.Long) {
                 if (NumUtil.isInt(input.asLong())) {
-                    if (input.getPrimitiveAnnotation() != null) {
-                        crb.recordInlineDataInCode(new MetaspaceData(0, input.asLong(), input.getPrimitiveAnnotation(), true));
+                    if (input instanceof HotSpotMetaspaceConstant) {
+                        crb.recordInlineDataInCode(new MetaspaceData(0, input.asLong(), HotSpotMetaspaceConstant.getMetaspaceObject(input), true));
                     }
                     masm.movl(address.toAddress(), (int) input.asLong());
                 } else {
@@ -64,7 +64,7 @@
                 if (input.isNull()) {
                     masm.movl(address.toAddress(), 0);
                 } else if (crb.target.inlineObjects) {
-                    crb.recordInlineDataInCode(new OopData(0, input.asObject(), true));
+                    crb.recordInlineDataInCode(new OopData(0, HotSpotObjectConstant.asObject(input), true));
                     masm.movl(address.toAddress(), 0xDEADDEAD);
                 } else {
                     throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory");
@@ -78,25 +78,36 @@
     public static class CompressPointer extends AMD64LIRInstruction {
 
         private final CompressEncoding encoding;
+        private final boolean nonNull;
 
         @Def({REG, HINT}) protected AllocatableValue result;
         @Use({REG}) protected AllocatableValue input;
-        @Temp({REG, ILLEGAL}) protected AllocatableValue baseRegister;
+        @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 
-        public CompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding) {
+        public CompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
             this.result = result;
             this.input = input;
             this.baseRegister = baseRegister;
             this.encoding = encoding;
+            this.nonNull = nonNull;
         }
 
         @Override
         public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
-            if (result.getPlatformKind() == NarrowOopStamp.NarrowOop) {
-                AMD64Move.move(Kind.Long, crb, masm, result, input);
-                encodePointer(masm, asRegister(result), asRegister(baseRegister), encoding);
-            } else {
-                throw GraalInternalError.unimplemented();
+            AMD64Move.move(Kind.Long, crb, masm, result, input);
+
+            Register resReg = asRegister(result);
+            if (encoding.base != 0) {
+                Register baseReg = asRegister(baseRegister);
+                if (!nonNull) {
+                    masm.testq(resReg, resReg);
+                    masm.cmovq(ConditionFlag.Equal, resReg, baseReg);
+                }
+                masm.subq(resReg, baseReg);
+            }
+
+            if (encoding.shift != 0) {
+                masm.shrq(resReg, encoding.shift);
             }
         }
     }
@@ -104,25 +115,43 @@
     public static class UncompressPointer extends AMD64LIRInstruction {
 
         private final CompressEncoding encoding;
+        private final boolean nonNull;
 
         @Def({REG, HINT}) protected AllocatableValue result;
         @Use({REG}) protected AllocatableValue input;
-        @Temp({REG, ILLEGAL}) protected AllocatableValue baseRegister;
+        @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
 
-        public UncompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding) {
+        public UncompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
             this.result = result;
             this.input = input;
             this.baseRegister = baseRegister;
             this.encoding = encoding;
+            this.nonNull = nonNull;
         }
 
         @Override
         public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
-            if (result.getKind() == Kind.Object) {
-                AMD64Move.move(Kind.Int, crb, masm, result, input);
-                decodePointer(masm, asRegister(result), asRegister(baseRegister), encoding);
-            } else {
-                throw GraalInternalError.unimplemented();
+            AMD64Move.move(Kind.Int, crb, masm, result, input);
+
+            Register resReg = asRegister(result);
+            if (encoding.shift != 0) {
+                masm.shlq(resReg, encoding.shift);
+            }
+
+            if (encoding.base != 0) {
+                if (nonNull) {
+                    masm.addq(resReg, asRegister(baseRegister));
+                } else {
+                    if (encoding.shift == 0) {
+                        // if encoding.shift != 0, the flags are already set by the shlq
+                        masm.testq(resReg, resReg);
+                    }
+
+                    Label done = new Label();
+                    masm.jccb(ConditionFlag.Equal, done);
+                    masm.addq(resReg, asRegister(baseRegister));
+                    masm.bind(done);
+                }
             }
         }
     }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -39,17 +39,13 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.SaveRbp;
-import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.CompareAndSwapCompressedOp;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.NoOp;
 import com.oracle.graal.lir.amd64.*;
-import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 
 /**
@@ -124,8 +120,7 @@
             assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
             HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target();
             assert !Modifier.isAbstract(resolvedMethod.getModifiers()) : "Cannot make direct call to abstract method.";
-            Constant metaspaceMethod = resolvedMethod.getMetaspaceMethodConstant();
-            append(new AMD64HotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind, metaspaceMethod));
+            append(new AMD64HotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
         }
     }
 
@@ -198,32 +193,10 @@
 
         RegisterValue raxLocal = AMD64.rax.asValue(kind);
         gen.emitMove(raxLocal, expected);
-        append(new CompareAndSwapOp(raxLocal, address, raxLocal, newVal));
+        append(new CompareAndSwapOp(kind, raxLocal, address, raxLocal, newVal));
 
         Variable result = newVariable(x.getKind());
         gen.emitMove(result, raxLocal);
         setResult(x, result);
     }
-
-    @Override
-    public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) {
-        Kind kind = node.getNewValue().getKind();
-        assert kind == node.getExpectedValue().getKind();
-        Value expected = gen.loadNonConst(operand(node.getExpectedValue()));
-        Variable newValue = gen.load(operand(node.getNewValue()));
-        AMD64AddressValue addressValue = getGen().asAddressValue(address);
-        RegisterValue raxRes = AMD64.rax.asValue(kind);
-        gen.emitMove(raxRes, expected);
-        if (getGen().config.useCompressedOops && node.isCompressible()) {
-            Variable scratch = newVariable(Kind.Long);
-            Register heapBaseReg = getGen().getProviders().getRegisters().getHeapBaseRegister();
-            append(new CompareAndSwapCompressedOp(raxRes, addressValue, raxRes, newValue, scratch, getGen().config.getOopEncoding(), heapBaseReg));
-        } else {
-            append(new CompareAndSwapOp(raxRes, addressValue, raxRes, newValue));
-        }
-        Variable result = newVariable(node.getKind());
-        append(new CondMoveOp(result, Condition.EQ, gen.load(Constant.TRUE), Constant.FALSE));
-        setResult(node, result);
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPushInterpreterFrameOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.amd64;
+
+import static com.oracle.graal.amd64.AMD64.*;
+import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.amd64.*;
+import com.oracle.graal.lir.asm.*;
+
+/**
+ * Pushes an interpreter frame to the stack.
+ */
+@Opcode("PUSH_INTERPRETER_FRAME")
+final class AMD64HotSpotPushInterpreterFrameOp extends AMD64LIRInstruction {
+
+    @Alive(REG) AllocatableValue frameSize;
+    @Alive(REG) AllocatableValue framePc;
+    @Alive(REG) AllocatableValue senderSp;
+    @Alive(REG) AllocatableValue initialInfo;
+
+    AMD64HotSpotPushInterpreterFrameOp(AllocatableValue frameSize, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue initialInfo) {
+        this.frameSize = frameSize;
+        this.framePc = framePc;
+        this.senderSp = senderSp;
+        this.initialInfo = initialInfo;
+    }
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+        final Register frameSizeRegister = asRegister(frameSize);
+        final Register framePcRegister = asRegister(framePc);
+        final Register senderSpRegister = asRegister(senderSp);
+        final Register initialInfoRegister = asRegister(initialInfo);
+        final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
+        final int wordSize = HotSpotGraalRuntime.runtime().getTarget().wordSize;
+
+        // We'll push PC and BP by hand.
+        masm.subq(frameSizeRegister, 2 * wordSize);
+
+        // Push return address.
+        masm.push(framePcRegister);
+
+        // Prolog
+        masm.push(initialInfoRegister);
+        masm.movq(initialInfoRegister, rsp);
+        masm.subq(rsp, frameSizeRegister);
+
+        // This value is corrected by layout_activation_impl.
+        masm.movptr(new AMD64Address(initialInfoRegister, config.frameInterpreterFrameLastSpOffset * wordSize), 0);
+
+        // Make the frame walkable.
+        masm.movq(new AMD64Address(initialInfoRegister, config.frameInterpreterFrameSenderSpOffset * wordSize), senderSpRegister);
+    }
+}
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -42,6 +42,8 @@
 
     private final Register[] allocatable;
 
+    private final int maxFrameSize;
+
     /**
      * The same as {@link #allocatable}, except if parameter registers are removed with the
      * {@link GraalOptions#RegisterPressure} option. The caller saved registers always include all
@@ -55,6 +57,10 @@
 
     private final RegisterAttributes[] attributesMap;
 
+    public int getMaximumFrameSize() {
+        return maxFrameSize;
+    }
+
     @Override
     public Register[] getAllocatableRegisters() {
         return allocatable.clone();
@@ -135,7 +141,13 @@
     }
 
     public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) {
+        this(architecture, config, initAllocatable(config.useCompressedOops));
+        assert callerSaved.length == allocatable.length || RegisterPressure.getValue() != null;
+    }
+
+    public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) {
         this.architecture = architecture;
+        this.maxFrameSize = config.maxFrameSize;
 
         if (config.windowsOs) {
             javaGeneralParameterRegisters = new Register[]{rdx, r8, r9, rdi, rsi, rcx};
@@ -146,14 +158,13 @@
         }
 
         csl = null;
-        allocatable = initAllocatable(config.useCompressedOops);
+        this.allocatable = allocatable.clone();
         Set<Register> callerSaveSet = new HashSet<>();
         Collections.addAll(callerSaveSet, allocatable);
         Collections.addAll(callerSaveSet, xmmParameterRegisters);
         Collections.addAll(callerSaveSet, javaGeneralParameterRegisters);
         Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters);
         callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]);
-        assert callerSaved.length == allocatable.length || RegisterPressure.getValue() != null;
 
         allAllocatableAreCallerSaved = true;
         attributesMap = RegisterAttributes.createMap(this, AMD64.allRegisters);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -29,13 +29,14 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.asm.*;
 
 /**
  * Returns from a function.
  */
 @Opcode("RETURN")
-final class AMD64HotSpotReturnOp extends AMD64HotSpotEpilogueOp {
+final class AMD64HotSpotReturnOp extends AMD64HotSpotEpilogueOp implements BlockEndOp {
 
     @Use({REG, ILLEGAL}) protected Value value;
     private final boolean isStub;
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
@@ -77,7 +77,7 @@
         if (ImmutableCode.getValue()) {
             Kind hostWordKind = HotSpotGraalRuntime.getHostWordKind();
             int alignment = hostWordKind.getBitCount() / Byte.SIZE;
-            Constant pollingPageAddress = Constant.forIntegerKind(hostWordKind, config.safepointPollingAddress, null);
+            Constant pollingPageAddress = Constant.forIntegerKind(hostWordKind, config.safepointPollingAddress);
             // This move will be patched to load the safepoint page from a data segment
             // co-located with the immutable code.
             asm.movq(scratch, (AMD64Address) crb.recordDataReferenceInCode(pollingPageAddress, alignment));
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -31,6 +31,7 @@
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
 
@@ -38,7 +39,7 @@
  * Removes the current frame and jumps to the {@link UnwindExceptionToCallerStub}.
  */
 @Opcode("UNWIND")
-final class AMD64HotSpotUnwindOp extends AMD64HotSpotEpilogueOp {
+final class AMD64HotSpotUnwindOp extends AMD64HotSpotEpilogueOp implements BlockEndOp {
 
     @Use({REG}) protected RegisterValue exception;
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,42 +22,32 @@
  */
 package com.oracle.graal.hotspot.amd64;
 
-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.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 
 /**
- * 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.
+ * A direct call that complies with the conventions for such calls in HotSpot. It doesn't use an
+ * inline cache so it's just a patchable call site.
  */
 @Opcode("CALL_DIRECT")
 final class AMD64HotspotDirectStaticCallOp extends DirectCallOp {
 
-    private final Constant metaspaceMethod;
     private final InvokeKind invokeKind;
 
-    AMD64HotspotDirectStaticCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind, Constant metaspaceMethod) {
+    AMD64HotspotDirectStaticCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind) {
         super(target, result, parameters, temps, state);
         assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
-        this.metaspaceMethod = metaspaceMethod;
         this.invokeKind = invokeKind;
     }
 
     @Override
     public void emitCode(CompilationResultBuilder crb, 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.
-        AMD64Move.move(crb, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod);
         MarkId.recordMark(crb, invokeKind == InvokeKind.Static ? MarkId.INVOKESTATIC : MarkId.INVOKESPECIAL);
-        // This must be emitted exactly like this to ensure it's patchable
-        masm.movq(AMD64.rax, HotSpotGraalRuntime.runtime().getConfig().nonOopBits);
         super.emitCode(crb, masm);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/DonorThreadPool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.hsail;
+
+import static com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options.*;
+
+import java.util.concurrent.*;
+
+import com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options;
+
+/**
+ * Thread pool for HSAIL allocation support.
+ */
+public class DonorThreadPool {
+
+    private final Thread[] threads;
+
+    void waitAt(CyclicBarrier barrier) {
+        try {
+            barrier.await();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Creates a pool of threads whose size is given by {@link Options#HsailDonorThreads}.
+     */
+    DonorThreadPool() {
+        int size = HsailDonorThreads.getValue();
+        this.threads = new Thread[size];
+        CyclicBarrier barrier = new CyclicBarrier(size + 1);
+
+        // fill in threads
+        for (int i = 0; i < size; i++) {
+            threads[i] = new Thread(new Runnable() {
+                @Override
+                public void run() {
+                    while (true) {
+                        waitAt(barrier);
+                    }
+                }
+            }, "HsailDonorThread-" + i);
+            threads[i].setDaemon(true);
+            threads[i].start();
+        }
+        // creating thread waits at barrier to make sure others have started
+        waitAt(barrier);
+    }
+
+    public Thread[] getThreads() {
+        return threads;
+    }
+}
\ No newline at end of file
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,6 +33,7 @@
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.internal.*;
+import com.oracle.graal.gpu.*;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hsail.*;
@@ -42,7 +43,6 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.printer.*;
-import com.oracle.graal.gpu.*;
 
 /**
  * Implements compile and dispatch of Java code containing lambda constructs. Currently only used by
@@ -62,7 +62,7 @@
      * @param intConsumerClass a class implementing {@code java.util.function.IntConsumer}
      * @return a {@link HotSpotNmethod} handle to the compiled and installed kernel
      */
-    private static HotSpotNmethod getCompiledLambda(Class intConsumerClass) {
+    private static HotSpotNmethod getCompiledLambda(Class<?> intConsumerClass) {
         Method acceptMethod = null;
         for (Method m : intConsumerClass.getMethods()) {
             if (m.getName().equals("accept")) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotAssembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,66 @@
+/*
+ * 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.hotspot.hsail;
+
+import java.lang.reflect.*;
+
+import com.amd.okra.*;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.hsail.*;
+import com.oracle.graal.hotspot.meta.*;
+
+/**
+ * This class contains routines to emit HSAIL assembly code.
+ */
+public class HSAILHotSpotAssembler extends HSAILAssembler {
+
+    public HSAILHotSpotAssembler(TargetDescription target) {
+        super(target);
+    }
+
+    @Override
+    public final void mov(Register a, Constant src) {
+        String regName = "$d" + a.encoding();
+        // For a null object simply move 0x0 into the destination register.
+        if (src.isNull()) {
+            emitString("mov_b64 " + regName + ", 0x0;  // null object");
+        } else {
+            Object obj = HotSpotObjectConstant.asObject(src);
+            // Get a JNI reference handle to the object.
+            long refHandle = OkraUtil.getRefHandle(obj);
+            // Get the clasname of the object for emitting a comment.
+            Class<?> clazz = obj.getClass();
+            String className = clazz.getName();
+            String comment = "// handle for object of type " + className;
+            // If the object is an array note the array length in the comment.
+            if (className.startsWith("[")) {
+                comment += ", length " + Array.getLength(obj);
+            }
+            // First move the reference handle into a register.
+            emitString("mov_b64 " + regName + ", 0x" + Long.toHexString(refHandle) + ";    " + comment);
+            // Next load the Object addressed by this reference handle into the destination reg.
+            emitString("ld_global_u64 " + regName + ", [" + regName + "];");
+        }
+    }
+}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,8 @@
 import static com.oracle.graal.api.code.CallingConvention.Type.*;
 import static com.oracle.graal.api.code.CodeUtil.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.api.meta.LocationIdentity.*;
 import static com.oracle.graal.compiler.GraalCompiler.*;
-import static com.oracle.graal.api.meta.LocationIdentity.*;
 
 import java.lang.reflect.*;
 import java.util.*;
@@ -58,21 +58,35 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.hsail.*;
+import com.oracle.graal.lir.hsail.HSAILMove.AtomicGetAndAddOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizeOp;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.tiers.*;
 
+import static com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options.*;
+import static com.oracle.graal.hotspot.hsail.replacements.HSAILNewObjectSnippets.Options.*;
+
 /**
  * HSAIL specific backend.
  */
 public class HSAILHotSpotBackend extends HotSpotBackend {
 
+    public static class Options {
+
+        // @formatter:off
+        @Option(help = "Number of donor threads for HSAIL kernel dispatch")
+        static public final OptionValue<Integer> HsailDonorThreads = new OptionValue<>(4);
+        // @formatter:on
+    }
+
     private Map<String, String> paramTypeMap = new HashMap<>();
     private final boolean deviceInitialized;
     // TODO: get maximum Concurrency from okra
@@ -103,18 +117,6 @@
     private static native boolean initialize();
 
     /**
-     * Control how many threads run on simulator (used only from junit tests).
-     */
-    public void setSimulatorSingleThreaded() {
-        String simThrEnv = System.getenv("SIMTHREADS");
-        if (simThrEnv == null || !simThrEnv.equals("1")) {
-            setSimulatorSingleThreaded0();
-        }
-    }
-
-    private static native void setSimulatorSingleThreaded0();
-
-    /**
      * Determines if the GPU device (or simulator) is available and initialized.
      */
     public boolean isDeviceInitialized() {
@@ -257,7 +259,7 @@
                 Debug.log("Param count: %d", parameterTypes.length);
                 for (int i = 0; i < parameterTypes.length; i++) {
                     ParameterNode parameter = hostGraph.getParameter(i);
-                    Debug.log("Param [%d]=%d", i, parameter);
+                    Debug.log("Param [%d]=%s", i, parameter);
                     parameterTypes[i] = parameter.stamp().javaType(hostBackend.getProviders().getMetaAccess());
                     Debug.log(" %s", parameterTypes[i]);
                 }
@@ -347,22 +349,30 @@
         return result;
     }
 
+    private static final ThreadLocal<DonorThreadPool> donorThreadPool = new ThreadLocal<DonorThreadPool>() {
+        @Override
+        protected DonorThreadPool initialValue() {
+            return new DonorThreadPool();
+        }
+    };
+
     public boolean executeKernel(HotSpotInstalledCode kernel, int jobSize, Object[] args) throws InvalidInstalledCodeException {
         if (!deviceInitialized) {
             throw new GraalInternalError("Cannot execute GPU kernel if device is not initialized");
         }
         Object[] oopsSaveArea = new Object[maxDeoptIndex * 16];
-        return executeKernel0(kernel, jobSize, args, oopsSaveArea);
+        return executeKernel0(kernel, jobSize, args, oopsSaveArea, donorThreadPool.get().getThreads(), HsailAllocBytesPerWorkitem.getValue());
     }
 
-    private static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args, Object[] oopsSave) throws InvalidInstalledCodeException;
+    private static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args, Object[] oopsSave, Thread[] donorThreads, int allocBytesPerWorkitem)
+                    throws InvalidInstalledCodeException;
 
     /**
      * Use the HSAIL register set when the compilation target is HSAIL.
      */
     @Override
-    public FrameMap newFrameMap() {
-        return new HSAILFrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new HSAILFrameMap(getCodeCache(), registerConfig);
     }
 
     @Override
@@ -412,7 +422,7 @@
 
     @Override
     protected Assembler createAssembler(FrameMap frameMap) {
-        return new HSAILAssembler(getTarget());
+        return new HSAILHotSpotAssembler(getTarget());
     }
 
     @Override
@@ -430,8 +440,24 @@
     @Override
     public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod method) {
         assert method != null : lir + " is not associated with a method";
+        Kind wordKind = getProviders().getCodeCache().getTarget().wordKind;
 
-        boolean usesDeoptInfo = true;     // TODO: make this conditional on something?
+        HotSpotVMConfig config = getRuntime().getConfig();
+        boolean useHSAILDeoptimization = config.useHSAILDeoptimization;
+
+        // see what graph nodes we have to see if we are using the thread register
+        // if not, we don't have to emit the code that sets that up
+        // maybe there is a better way to do this?
+        boolean usesThreadRegister = false;
+        search: for (AbstractBlock<?> b : lir.linearScanOrder()) {
+            for (LIRInstruction op : lir.getLIRforBlock(b)) {
+                if (op instanceof AtomicGetAndAddOp && ((AtomicGetAndAddOp) op).getAddress().toAddress().getBase().equals(HSAIL.threadRegister)) {
+                    usesThreadRegister = true;
+                    assert useHSAILDeoptimization : "cannot use thread register if HSAIL deopt support is disabled";
+                    break search;
+                }
+            }
+        }
 
         // Emit the prologue.
         HSAILAssembler asm = (HSAILAssembler) crb.asm;
@@ -513,13 +539,13 @@
         for (int i = 0; i < totalParamCount; i++) {
             String str = "align 8 kernarg_" + paramHsailSizes[i] + " " + paramNames[i];
 
-            if (usesDeoptInfo || (i != totalParamCount - 1)) {
+            if (useHSAILDeoptimization || (i != totalParamCount - 1)) {
                 str += ",";
             }
             asm.emitString(str);
         }
 
-        if (usesDeoptInfo) {
+        if (useHSAILDeoptimization) {
             // add in the deoptInfo parameter
             asm.emitString("kernarg_u64 " + asm.getDeoptInfoName());
         }
@@ -542,22 +568,41 @@
         String workItemReg = "$s" + Integer.toString(asRegister(cc.getArgument(nonConstantParamCount)).encoding());
         asm.emitString("workitemabsid_u32 " + workItemReg + ", 0;");
 
-        final int offsetToDeoptSaveStates = getRuntime().getConfig().hsailSaveStatesOffset0;
-        final int sizeofKernelDeopt = getRuntime().getConfig().hsailSaveStatesOffset1 - getRuntime().getConfig().hsailSaveStatesOffset0;
-        final int offsetToDeopt = getRuntime().getConfig().hsailDeoptOffset;
-        final int offsetToNeverRanArray = getRuntime().getConfig().hsailNeverRanArrayOffset;
-        final int offsetToDeoptNextIndex = getRuntime().getConfig().hsailDeoptNextIndexOffset;
         final String deoptInProgressLabel = "@LHandleDeoptInProgress";
 
-        if (usesDeoptInfo) {
-            AllocatableValue scratch64 = HSAIL.d16.asValue(Kind.Object);
-            AllocatableValue scratch32 = HSAIL.s34.asValue(Kind.Int);
-            HSAILAddress deoptInfoAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToDeopt).toAddress();
-            asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64");
+        if (useHSAILDeoptimization) {
+            // Aliases for d16
+            RegisterValue d16_deoptInfo = HSAIL.d16.asValue(wordKind);
+            RegisterValue d16_donorThreads = d16_deoptInfo;
+
+            // Aliases for d17
+            RegisterValue d17_donorThreadIndex = HSAIL.d17.asValue(wordKind);
+
+            // Aliases for s34
+            RegisterValue s34_deoptOccurred = HSAIL.s34.asValue(Kind.Int);
+            RegisterValue s34_donorThreadIndex = s34_deoptOccurred;
+
+            asm.emitLoadKernelArg(d16_deoptInfo, asm.getDeoptInfoName(), "u64");
             asm.emitComment("// Check if a deopt has occurred and abort if true before doing any work");
-            asm.emitLoadAcquire(scratch32, deoptInfoAddr);
-            asm.emitCompare(scratch32, Constant.forInt(0), "ne", false, false);
+            asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(Kind.Int, d16_deoptInfo, config.hsailDeoptOccurredOffset).toAddress());
+            asm.emitCompare(Kind.Int, s34_deoptOccurred, Constant.forInt(0), "ne", false, false);
             asm.cbr(deoptInProgressLabel);
+            // load thread register if needed
+            if (usesThreadRegister) {
+                assert HsailDonorThreads.getValue() > 0;
+                asm.emitLoad(wordKind, d16_donorThreads, new HSAILAddressValue(wordKind, d16_deoptInfo, config.hsailDonorThreadsOffset).toAddress());
+                if (HsailDonorThreads.getValue() != 1) {
+                    asm.emitComment("// map workitem to a donor thread");
+                    asm.emitString(String.format("rem_u32  $%s, %s, %d;", s34_donorThreadIndex.getRegister(), workItemReg, HsailDonorThreads.getValue()));
+                    asm.emitConvert(d17_donorThreadIndex, s34_donorThreadIndex, wordKind, Kind.Int);
+                    asm.emit("mad", d16_donorThreads, d17_donorThreadIndex, Constant.forInt(8), d16_donorThreads);
+                } else {
+                    // workitem is already mapped to solitary donor thread
+                }
+                AllocatableValue threadRegValue = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
+                asm.emitComment("// $" + getProviders().getRegisters().getThreadRegister() + " will point to a donor thread for this workitem");
+                asm.emitLoad(wordKind, threadRegValue, new HSAILAddressValue(wordKind, d16_donorThreads).toAddress());
+            }
         }
 
         /*
@@ -570,8 +615,8 @@
         asm.emitString(spillsegTemplate);
         // Emit object array load prologue here.
         if (isObjectLambda) {
-            boolean useCompressedOops = getRuntime().getConfig().useCompressedOops;
-            final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(Kind.Object);
+            boolean useCompressedOops = config.useCompressedOops;
+            final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(wordKind);
             String iterationObjArgReg = HSAIL.mapRegister(cc.getArgument(nonConstantParamCount - 1));
             // iterationObjArgReg will be the highest $d register in use (it is the last parameter)
             // so tempReg can be the next higher $d register
@@ -590,8 +635,8 @@
                 // Load u32 into the d 64 reg since it will become an object address
                 asm.emitString("ld_global_u32 " + tmpReg + ", " + "[" + tmpReg + "]" + "; // Load compressed ptr from array");
 
-                long narrowOopBase = getRuntime().getConfig().narrowOopBase;
-                long narrowOopShift = getRuntime().getConfig().narrowOopShift;
+                long narrowOopBase = config.narrowOopBase;
+                long narrowOopShift = config.narrowOopShift;
 
                 if (narrowOopBase == 0 && narrowOopShift == 0) {
                     // No more calculation to do, mov to target register
@@ -631,19 +676,23 @@
         asm.emitString(spillsegStringFinal, spillsegDeclarationPosition);
         // Emit the epilogue.
 
-        final int offsetToDeoptimizationWorkItem = getRuntime().getConfig().hsailDeoptimizationWorkItem;
-        final int offsetToDeoptimizationReason = getRuntime().getConfig().hsailDeoptimizationReason;
-        final int offsetToDeoptimizationFrame = getRuntime().getConfig().hsailDeoptimizationFrame;
-        final int offsetToFramePc = getRuntime().getConfig().hsailFramePcOffset;
-        final int offsetToNumSaves = getRuntime().getConfig().hsailFrameNumSRegOffset;
-        final int offsetToSaveArea = getRuntime().getConfig().hsailFrameSaveAreaOffset;
+        // TODO: keep track of whether we need it
+        if (useHSAILDeoptimization) {
+            final int offsetToDeoptSaveStates = config.hsailSaveStatesOffset0;
+            final int sizeofKernelDeopt = config.hsailSaveStatesOffset1 - config.hsailSaveStatesOffset0;
+            final int offsetToNeverRanArray = config.hsailNeverRanArrayOffset;
+            final int offsetToDeoptNextIndex = config.hsailDeoptNextIndexOffset;
+            final int offsetToDeoptimizationWorkItem = config.hsailDeoptimizationWorkItem;
+            final int offsetToDeoptimizationReason = config.hsailDeoptimizationReason;
+            final int offsetToDeoptimizationFrame = config.hsailDeoptimizationFrame;
+            final int offsetToFramePc = config.hsailFramePcOffset;
+            final int offsetToNumSaves = config.hsailFrameNumSRegOffset;
+            final int offsetToSaveArea = config.hsailFrameSaveAreaOffset;
 
-        // TODO: keep track of whether we need it
-        if (usesDeoptInfo) {
-            AllocatableValue scratch64 = HSAIL.d16.asValue(Kind.Object);
-            AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(Kind.Object);
-            AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(Kind.Object);
-            AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(Kind.Object);
+            AllocatableValue scratch64 = HSAIL.d16.asValue(wordKind);
+            AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(wordKind);
+            AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(wordKind);
+            AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordKind);
 
             AllocatableValue actionAndReasonReg = HSAIL.s32.asValue(Kind.Int);
             AllocatableValue codeBufferOffsetReg = HSAIL.s33.asValue(Kind.Int);
@@ -656,9 +705,9 @@
 
             // The just-started lanes that see the deopt flag will jump here
             asm.emitString0(deoptInProgressLabel + ":\n");
-            asm.emitLoad(Kind.Object, waveMathScratch1, neverRanArrayAddr);
+            asm.emitLoad(wordKind, waveMathScratch1, neverRanArrayAddr);
             asm.emitWorkItemAbsId(workidreg);
-            asm.emitConvert(waveMathScratch2, workidreg, Kind.Object, Kind.Int);
+            asm.emitConvert(waveMathScratch2, workidreg, wordKind, Kind.Int);
             asm.emit("add", waveMathScratch1, waveMathScratch1, waveMathScratch2);
             HSAILAddress neverRanStoreAddr = new HSAILAddressValue(Kind.Byte, waveMathScratch1, 0).toAddress();
             asm.emitStore(Kind.Byte, Constant.forInt(1), neverRanStoreAddr);
@@ -668,7 +717,7 @@
             asm.emitString0(asm.getDeoptLabelName() + ":\n");
             String labelExit = asm.getDeoptLabelName() + "_Exit";
 
-            HSAILAddress deoptInfoAddr = new HSAILAddressValue(Kind.Int, scratch64, offsetToDeopt).toAddress();
+            HSAILAddress deoptInfoAddr = new HSAILAddressValue(Kind.Int, scratch64, config.hsailDeoptOccurredOffset).toAddress();
             asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64");
 
             // Set deopt occurred flag
@@ -680,7 +729,7 @@
             // scratch32 now holds next index to use
             // set error condition if no room in save area
             asm.emitComment("// assert room to save deopt");
-            asm.emitCompare(scratch32, Constant.forInt(maxDeoptIndex), "lt", false, false);
+            asm.emitCompare(Kind.Int, scratch32, Constant.forInt(maxDeoptIndex), "lt", false, false);
             asm.cbr("@L_StoreDeopt");
             // if assert fails, store a guaranteed negative workitemid in top level deopt occurred
             // flag
@@ -694,7 +743,7 @@
             // Store deopt for this workitem into its slot in the HSAILComputeUnitSaveStates array
 
             asm.emitComment("// Convert id's for ptr math");
-            asm.emitConvert(cuSaveAreaPtr, scratch32, Kind.Object, Kind.Int);
+            asm.emitConvert(cuSaveAreaPtr, scratch32, wordKind, Kind.Int);
             asm.emitComment("// multiply by sizeof KernelDeoptArea");
             asm.emit("mul", cuSaveAreaPtr, cuSaveAreaPtr, Constant.forInt(sizeofKernelDeopt));
             asm.emitComment("// Add computed offset to deoptInfoPtr base");
@@ -725,9 +774,7 @@
             asm.emitStore(Kind.Short, dregOopMapReg, dregOopMapAddr);
 
             // get the union of registers needed to be saved at the infopoints
-            // usedRegs array assumes d15 has the highest register number we wish to save
-            // and initially has all registers as false
-            boolean[] infoUsedRegs = new boolean[HSAIL.d15.number + 1];
+            boolean[] infoUsedRegs = new boolean[HSAIL.threadRegister.number + 1];
             List<Infopoint> infoList = crb.compilationResult.getInfopoints();
             for (Infopoint info : infoList) {
                 BytecodeFrame frame = info.debugInfo.frame();
@@ -773,13 +820,18 @@
             // and emit the return
             crb.frameContext.leave(crb);
             asm.exit();
+        } else {
+            // Deoptimization is explicitly off, so emit simple return
+            asm.emitString0(asm.getDeoptLabelName() + ":\n");
+            asm.emitComment("// No deoptimization");
+            asm.emitString("ret;");
         }
 
         asm.emitString0("}; \n");
 
         ExternalCompilationResult compilationResult = (ExternalCompilationResult) crb.compilationResult;
         HSAILHotSpotLIRGenerationResult lirGenRes = ((HSAILCompilationResultBuilder) crb).lirGenRes;
-        compilationResult.setHostGraph(prepareHostGraph(method, lirGenRes.getDeopts(), getProviders(), getRuntime().getConfig()));
+        compilationResult.setHostGraph(prepareHostGraph(method, lirGenRes.getDeopts(), getProviders(), config));
     }
 
     private static StructuredGraph prepareHostGraph(ResolvedJavaMethod method, List<DeoptimizeOp> deopts, HotSpotProviders providers, HotSpotVMConfig config) {
@@ -863,7 +915,7 @@
         return frameState;
     }
 
-    @SuppressWarnings({"unused"})
+    @SuppressWarnings("unused")
     private static MonitorIdNode getMonitorIdForHotSpotMonitorValueFromFrame(HotSpotMonitorValue lockValue, ParameterNode hsailFrame, StructuredGraph hsailGraph) {
         if (lockValue.isEliminated()) {
             return null;
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,10 +28,10 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hsail.*;
-import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
+import com.oracle.graal.hotspot.hsail.replacements.*;
 
 @ServiceProvider(HotSpotBackendFactory.class)
 public class HSAILHotSpotBackendFactory implements HotSpotBackendFactory {
@@ -40,7 +40,7 @@
     public HSAILHotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotBackend hostBackend) {
         HotSpotProviders host = hostBackend.getProviders();
 
-        HotSpotRegisters registers = new HotSpotRegisters(Register.None, Register.None, Register.None);
+        HotSpotRegisters registers = new HotSpotRegisters(HSAIL.threadRegister, Register.None, Register.None);
         HotSpotMetaAccessProvider metaAccess = host.getMetaAccess();
         HSAILHotSpotCodeCacheProvider codeCache = new HSAILHotSpotCodeCacheProvider(runtime, createTarget());
         ConstantReflectionProvider constantReflection = host.getConstantReflection();
@@ -50,10 +50,13 @@
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
         Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null);
-        Replacements replacements = new HSAILHotSpotReplacementsImpl(p, assumptions, codeCache.getTarget(), host.getReplacements());
+        Replacements replacements = new HSAILHotSpotReplacementsImpl(p, host.getSnippetReflection(), assumptions, codeCache.getTarget(), host.getReplacements());
         HotSpotDisassemblerProvider disassembler = host.getDisassembler();
-        SuitesProvider suites = new DefaultSuitesProvider();
-        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers);
+        SuitesProvider suites = new HotSpotSuitesProvider(runtime);
+        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, host.getSnippetReflection());
+
+        // pass registers info down to ReplacementsUtil (maybe a better way to do this?)
+        HSAILHotSpotReplacementsUtil.initialize(providers.getRegisters());
 
         return new HSAILHotSpotBackend(runtime, providers);
     }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -35,11 +35,14 @@
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.type.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 import com.oracle.graal.lir.hsail.*;
+import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizeOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall1ArgOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCall2ArgOp;
 import com.oracle.graal.lir.hsail.HSAILControlFlow.ForeignCallNoArgOp;
+import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp;
 import com.oracle.graal.lir.hsail.HSAILMove.LoadCompressedPointer;
 import com.oracle.graal.lir.hsail.HSAILMove.LoadOp;
 import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp;
@@ -48,6 +51,7 @@
 import com.oracle.graal.lir.hsail.HSAILMove.StoreConstantOp;
 import com.oracle.graal.lir.hsail.HSAILMove.StoreOp;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.phases.util.*;
 
@@ -151,8 +155,11 @@
             if (canStoreConstant(c, isCompressed)) {
                 if (isCompressed) {
                     if ((c.getKind() == Kind.Object) && c.isNull()) {
+                        // Constant value = c.isNull() ? c : compress(c, config.getOopEncoding());
                         append(new StoreConstantOp(Kind.Int, storeAddress, Constant.forInt(0), state));
                     } else if (c.getKind() == Kind.Long) {
+                        // It's always a good idea to directly store compressed constants since they
+                        // have to be materialized as 64 bits encoded otherwise.
                         Constant value = compress(c, config.getKlassEncoding());
                         append(new StoreConstantOp(Kind.Int, storeAddress, value, state));
                     } else {
@@ -179,6 +186,22 @@
         }
     }
 
+    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
+        PlatformKind kind = newValue.getPlatformKind();
+        assert kind == expectedValue.getPlatformKind();
+        Kind memKind = getMemoryKind(kind);
+
+        HSAILAddressValue addressValue = asAddressValue(address);
+        Variable expected = emitMove(expectedValue);
+        Variable casResult = newVariable(kind);
+        append(new CompareAndSwapOp(memKind, casResult, addressValue, expected, asAllocatable(newValue)));
+
+        assert trueValue.getPlatformKind() == falseValue.getPlatformKind();
+        Variable nodeResult = newVariable(trueValue.getPlatformKind());
+        append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(memKind), casResult, expected, nodeResult, Condition.EQ, trueValue, falseValue));
+        return nodeResult;
+    }
+
     @Override
     public void emitDeoptimize(Value actionAndReason, Value failedSpeculation, DeoptimizingNode deopting) {
         emitDeoptimizeInner(actionAndReason, state(deopting), "emitDeoptimize");
@@ -252,33 +275,68 @@
      */
     protected static Constant compress(Constant c, CompressEncoding encoding) {
         if (c.getKind() == Kind.Long) {
-            return Constant.forIntegerKind(Kind.Int, (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL), c.getPrimitiveAnnotation());
+            int compressedValue = (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL);
+            if (c instanceof HotSpotMetaspaceConstant) {
+                return HotSpotMetaspaceConstant.forMetaspaceObject(Kind.Int, compressedValue, HotSpotMetaspaceConstant.getMetaspaceObject(c));
+            } else {
+                return Constant.forIntegerKind(Kind.Int, compressedValue);
+            }
         } else {
             throw GraalInternalError.shouldNotReachHere();
         }
     }
 
     public void emitTailcall(Value[] args, Value address) {
-        throw GraalInternalError.shouldNotReachHere("NYI");
+        throw GraalInternalError.unimplemented();
     }
 
     public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
-        throw GraalInternalError.shouldNotReachHere("NYI");
+        throw GraalInternalError.unimplemented();
     }
 
     public StackSlot getLockSlot(int lockDepth) {
-        throw GraalInternalError.shouldNotReachHere("NYI");
+        throw GraalInternalError.unimplemented();
     }
 
-    public Value emitCompress(Value pointer, CompressEncoding encoding) {
+    @Override
+    public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
         Variable result = newVariable(NarrowOopStamp.NarrowOop);
-        append(new HSAILMove.CompressPointer(result, newVariable(pointer.getPlatformKind()), asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment));
+        append(new HSAILMove.CompressPointer(result, newVariable(pointer.getPlatformKind()), asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull));
+        return result;
+    }
+
+    @Override
+    public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
+        Variable result = newVariable(Kind.Object);
+        append(new HSAILMove.UncompressPointer(result, asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull));
         return result;
     }
 
-    public Value emitUncompress(Value pointer, CompressEncoding encoding) {
-        Variable result = newVariable(Kind.Object);
-        append(new HSAILMove.UncompressPointer(result, asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment));
-        return result;
+    public void emitLeaveCurrentStackFrame() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveUnpackFramesStackFrame() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public SaveRegistersOp emitSaveAllRegisters() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
+        throw GraalInternalError.unimplemented();
     }
 }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,30 +32,48 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.hotspot.hsail.nodes.*;
+import com.oracle.graal.hotspot.hsail.replacements.*;
 import java.util.HashMap;
 
 public class HSAILHotSpotLoweringProvider extends HotSpotLoweringProvider {
 
-    abstract static class LoweringStrategy {
+    private HSAILNewObjectSnippets.Templates hsailNewObjectSnippets;
+
+    abstract class LoweringStrategy {
         abstract void lower(Node n, LoweringTool tool);
     }
 
-    static LoweringStrategy PassThruStrategy = new LoweringStrategy() {
+    LoweringStrategy PassThruStrategy = new LoweringStrategy() {
         @Override
         void lower(Node n, LoweringTool tool) {
             return;
         }
     };
 
-    static LoweringStrategy RejectStrategy = new LoweringStrategy() {
+    LoweringStrategy RejectStrategy = new LoweringStrategy() {
         @Override
         void lower(Node n, LoweringTool tool) {
             throw new GraalInternalError("Node implementing Lowerable not handled in HSAIL Backend: " + n);
         }
     };
 
+    LoweringStrategy NewObjectStrategy = new LoweringStrategy() {
+        @Override
+        void lower(Node n, LoweringTool tool) {
+            StructuredGraph graph = (StructuredGraph) n.graph();
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+                if (n instanceof NewInstanceNode) {
+                    hsailNewObjectSnippets.lower((NewInstanceNode) n, tool);
+                } else if (n instanceof NewArrayNode) {
+                    hsailNewObjectSnippets.lower((NewArrayNode) n, tool);
+                }
+            }
+        }
+    };
+
     // strategy to replace an UnwindNode with a DeoptNode
-    static LoweringStrategy UnwindNodeStrategy = new LoweringStrategy() {
+    LoweringStrategy UnwindNodeStrategy = new LoweringStrategy() {
         @Override
         void lower(Node n, LoweringTool tool) {
             StructuredGraph graph = (StructuredGraph) n.graph();
@@ -84,25 +102,58 @@
         }
     };
 
-    private static HashMap<Class<?>, LoweringStrategy> strategyMap = new HashMap<>();
-    static {
+    LoweringStrategy AtomicGetAndAddStrategy = new LoweringStrategy() {
+        @Override
+        void lower(Node n, LoweringTool tool) {
+            StructuredGraph graph = (StructuredGraph) n.graph();
+
+            // Note: this code adapted from CompareAndSwapNode
+            // lowering but since we are not dealing with an object
+            // but a word (thread passed in), I wasn't sure what
+            // should be done with the Location stuff so leaving it
+            // out for now
+
+            AtomicGetAndAddNode getAdd = (AtomicGetAndAddNode) n;
+            // LocationNode location = IndexedLocationNode.create(ANY_LOCATION, Kind.Long, 0,
+            // getAdd.offset(), graph, 1);
+            LocationNode location = IndexedLocationNode.create(getAdd.getLocationIdentity(), Kind.Long, 0, getAdd.offset(), graph, 1);
+            // note: getAdd.base() used to be getAdd.object()
+            LoweredAtomicGetAndAddNode loweredAtomicGetAdd = graph.add(new LoweredAtomicGetAndAddNode(getAdd.base(), location, getAdd.delta(), HeapAccess.BarrierType.NONE,
+                            getAdd.getKind() == Kind.Object));
+            loweredAtomicGetAdd.setStateAfter(getAdd.stateAfter());
+            graph.replaceFixedWithFixed(getAdd, loweredAtomicGetAdd);
+        }
+    };
+
+    private HashMap<Class<?>, LoweringStrategy> strategyMap = new HashMap<>();
+
+    void initStrategyMap() {
         strategyMap.put(ConvertNode.class, PassThruStrategy);
         strategyMap.put(FloatConvertNode.class, PassThruStrategy);
-        strategyMap.put(NewInstanceNode.class, RejectStrategy);
-        strategyMap.put(NewArrayNode.class, RejectStrategy);
+        strategyMap.put(NewInstanceNode.class, NewObjectStrategy);
+        strategyMap.put(NewArrayNode.class, NewObjectStrategy);
         strategyMap.put(NewMultiArrayNode.class, RejectStrategy);
         strategyMap.put(DynamicNewArrayNode.class, RejectStrategy);
         strategyMap.put(MonitorEnterNode.class, RejectStrategy);
         strategyMap.put(MonitorExitNode.class, RejectStrategy);
         strategyMap.put(UnwindNode.class, UnwindNodeStrategy);
+        strategyMap.put(AtomicGetAndAddNode.class, AtomicGetAndAddStrategy);
     }
 
-    private static LoweringStrategy getStrategy(Node n) {
+    private LoweringStrategy getStrategy(Node n) {
         return strategyMap.get(n.getClass());
     }
 
     public HSAILHotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) {
         super(runtime, metaAccess, foreignCalls, registers);
+        initStrategyMap();
+    }
+
+    @Override
+    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
+        super.initialize(providers, config);
+        TargetDescription target = providers.getCodeCache().getTarget();
+        hsailNewObjectSnippets = new HSAILNewObjectSnippets.Templates(providers, target);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,71 +23,32 @@
 
 package com.oracle.graal.hotspot.hsail;
 
-import sun.misc.*;
-
+import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.hsail.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
+import com.oracle.graal.hotspot.hsail.nodes.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp;
-import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapCompressedOp;
+import com.oracle.graal.lir.hsail.HSAILMove.AtomicGetAndAddOp;
 import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
 
 /**
  * The HotSpot specific portion of the HSAIL LIR generator.
  */
-public class HSAILHotSpotNodeLIRBuilder extends HSAILNodeLIRBuilder {
+public class HSAILHotSpotNodeLIRBuilder extends HSAILNodeLIRBuilder implements HotSpotNodeLIRBuilder {
 
     public HSAILHotSpotNodeLIRBuilder(StructuredGraph graph, LIRGenerator lirGen) {
         super(graph, lirGen);
     }
 
-    private HSAILHotSpotLIRGenerator getGen() {
-        return (HSAILHotSpotLIRGenerator) gen;
-    }
-
-    /**
-     * Appends either a {@link CompareAndSwapOp} or a {@link CompareAndSwapCompressedOp} depending
-     * on whether the memory location of a given {@link LoweredCompareAndSwapNode} contains a
-     * compressed oop. For the {@link CompareAndSwapCompressedOp} case, allocates a number of
-     * scratch registers. The result {@link #operand(ValueNode) operand} for {@code node} complies
-     * with the API for {@link Unsafe#compareAndSwapInt(Object, long, int, int)}.
-     *
-     * @param address the memory location targeted by the operation
-     */
-    @Override
-    public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) {
-        Kind kind = node.getNewValue().getKind();
-        assert kind == node.getExpectedValue().getKind();
-        Variable expected = gen.load(operand(node.getExpectedValue()));
-        Variable newValue = gen.load(operand(node.getNewValue()));
-        HSAILAddressValue addressValue = getGen().asAddressValue(address);
-        Variable casResult = newVariable(kind);
-        if (getGen().config.useCompressedOops && node.isCompressible()) {
-            // make 64-bit scratch variables for expected and new
-            Variable scratchExpected64 = newVariable(Kind.Long);
-            Variable scratchNewValue64 = newVariable(Kind.Long);
-            // make 32-bit scratch variables for expected and new and result
-            Variable scratchExpected32 = newVariable(Kind.Int);
-            Variable scratchNewValue32 = newVariable(Kind.Int);
-            Variable scratchCasResult32 = newVariable(Kind.Int);
-            append(new CompareAndSwapCompressedOp(casResult, addressValue, expected, newValue, scratchExpected64, scratchNewValue64, scratchExpected32, scratchNewValue32, scratchCasResult32,
-                            getGen().getNarrowOopBase(), getGen().getNarrowOopShift(), getGen().getLogMinObjectAlignment()));
-        } else {
-            append(new CompareAndSwapOp(casResult, addressValue, expected, newValue));
-        }
-        Variable nodeResult = newVariable(node.getKind());
-        append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(kind), casResult, expected, nodeResult, Condition.EQ, Constant.INT_1, Constant.INT_0));
-        setResult(node, nodeResult);
-    }
-
     @Override
     protected void emitNode(ValueNode node) {
         if (node instanceof CurrentJavaThreadNode) {
@@ -97,14 +58,70 @@
         }
     }
 
+    private HSAILHotSpotLIRGenerator getGen() {
+        return (HSAILHotSpotLIRGenerator) gen;
+    }
+
     /**
      * @return a compressed version of the incoming constant lifted from AMD64HotSpotLIRGenerator
      */
     protected static Constant compress(Constant c, CompressEncoding encoding) {
         if (c.getKind() == Kind.Long) {
-            return Constant.forIntegerKind(Kind.Int, (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL), c.getPrimitiveAnnotation());
+            int compressedValue = (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL);
+            if (c instanceof HotSpotMetaspaceConstant) {
+                return HotSpotMetaspaceConstant.forMetaspaceObject(Kind.Int, compressedValue, HotSpotMetaspaceConstant.getMetaspaceObject(c));
+            } else {
+                return Constant.forIntegerKind(Kind.Int, compressedValue);
+            }
         } else {
             throw GraalInternalError.shouldNotReachHere();
         }
     }
+
+    public void visitAtomicGetAndAdd(LoweredAtomicGetAndAddNode node, Value address) {
+        Variable nodeResult = newVariable(node.getKind());
+        Value delta = getGen().loadNonConst(operand(node.getDelta()));
+        HSAILAddressValue addressValue = getGen().asAddressValue(address);
+        append(new AtomicGetAndAddOp(nodeResult, addressValue, delta));
+        setResult(node, nodeResult);
+    }
+
+    public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
+        Kind kind = x.newValue().getKind();
+        assert kind == x.expectedValue().getKind();
+
+        Variable expected = getGen().load(operand(x.expectedValue()));
+        Variable newVal = getGen().load(operand(x.newValue()));
+
+        int disp = 0;
+        HSAILAddressValue address;
+        Value index = operand(x.offset());
+        if (ValueUtil.isConstant(index) && NumUtil.isInt(ValueUtil.asConstant(index).asLong() + disp)) {
+            assert !getGen().getCodeCache().needsDataPatch(ValueUtil.asConstant(index));
+            disp += (int) ValueUtil.asConstant(index).asLong();
+            address = new HSAILAddressValue(kind, getGen().load(operand(x.object())), disp);
+        } else {
+            throw GraalInternalError.shouldNotReachHere("NYI");
+        }
+
+        Variable casResult = newVariable(kind);
+        append(new CompareAndSwapOp(kind, casResult, address, expected, newVal));
+
+        setResult(x, casResult);
+    }
+
+    @Override
+    public void emitPrefetchAllocate(ValueNode address, ValueNode distance) {
+        // nop
+    }
+
+    @Override
+    public void emitPatchReturnAddress(ValueNode address) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) {
+        throw GraalInternalError.unimplemented();
+    }
 }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotReplacementsImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotReplacementsImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,15 +23,16 @@
 package com.oracle.graal.hotspot.hsail;
 
 import java.lang.reflect.*;
+import java.util.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.hsail.*;
-import java.util.HashSet;
 
 /**
  * The substitutions and snippets supported by HSAIL.
@@ -41,8 +42,8 @@
     private final Replacements host;
     private HashSet<ResolvedJavaMethod> ignoredResolvedMethods = new HashSet<>();
 
-    public HSAILHotSpotReplacementsImpl(Providers providers, Assumptions assumptions, TargetDescription target, Replacements host) {
-        super(providers, assumptions, target);
+    public HSAILHotSpotReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target, Replacements host) {
+        super(providers, snippetReflection, assumptions, target);
         this.host = host;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/nodes/AtomicGetAndAddNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.hsail.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Represents an atomic get-and-add operation. The result is the get value (before the delta is
+ * added)
+ */
+public class AtomicGetAndAddNode extends AbstractStateSplit implements Lowerable, MemoryCheckpoint.Single {
+
+    @Input private ValueNode base;
+    @Input private ValueNode offset;
+    @Input private ValueNode delta;
+    @Input private LocationIdentity locationIdentity;
+
+    public ValueNode base() {
+        return base;
+    }
+
+    public ValueNode offset() {
+        return offset;
+    }
+
+    public ValueNode delta() {
+        return delta;
+    }
+
+    @SuppressWarnings("unused")
+    public AtomicGetAndAddNode(ValueNode base, ValueNode offset, ValueNode location /* ignored */, ValueNode delta) {
+        super(StampFactory.forKind(Kind.Long.getStackKind()));
+        this.base = base;
+        this.offset = offset;
+        this.delta = delta;
+    }
+
+    @Override
+    public LocationIdentity getLocationIdentity() {
+        return locationIdentity;
+    }
+
+    @Override
+    public void lower(LoweringTool tool) {
+        tool.getLowerer().lower(this, tool);
+    }
+
+    @NodeIntrinsic
+    public native static long atomicGetAndAdd(long base, int offset, LocationIdentity locationIdentity, int delta);
+
+    public MemoryCheckpoint asMemoryCheckpoint() {
+        return this;
+    }
+
+    public MemoryPhiNode asMemoryPhi() {
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/nodes/LoweredAtomicGetAndAddNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.hsail.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.hotspot.hsail.*;
+
+/**
+ * Represents the lowered version of an atomic get-and-add operation{@code AtomicGetAndAddNode}.
+ */
+public class LoweredAtomicGetAndAddNode extends FixedAccessNode implements StateSplit, LIRLowerable, MemoryCheckpoint.Single {
+
+    @Input private ValueNode delta;
+    @Input(InputType.State) private FrameState stateAfter;
+
+    public FrameState stateAfter() {
+        return stateAfter;
+    }
+
+    public void setStateAfter(FrameState x) {
+        assert x == null || x.isAlive() : "frame state must be in a graph";
+        updateUsages(stateAfter, x);
+        stateAfter = x;
+    }
+
+    public boolean hasSideEffect() {
+        return true;
+    }
+
+    public ValueNode getDelta() {
+        return delta;
+    }
+
+    public LoweredAtomicGetAndAddNode(ValueNode object, LocationNode location, ValueNode delta, BarrierType barrierType, boolean compressible) {
+        super(object, location, StampFactory.forKind(Kind.Long.getStackKind()), barrierType, compressible);
+        this.delta = delta;
+    }
+
+    @Override
+    public LocationIdentity getLocationIdentity() {
+        return location().getLocationIdentity();
+    }
+
+    @Override
+    public boolean canNullCheck() {
+        return false;
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        HSAILHotSpotNodeLIRBuilder hsailGen = (HSAILHotSpotNodeLIRBuilder) gen;
+        hsailGen.visitAtomicGetAndAdd(this, location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object())));
+    }
+
+    @Override
+    public MemoryCheckpoint asMemoryCheckpoint() {
+        return this;
+    }
+
+    @Override
+    public MemoryPhiNode asMemoryPhi() {
+        return null;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILHotSpotReplacementsUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.hsail.replacements;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.replacements.Snippet.Fold;
+import com.oracle.graal.word.*;
+import com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.hsail.nodes.*;
+
+//JaCoCo Exclude
+
+/**
+ * A collection of methods used in HSAIL-specific snippets and substitutions.
+ */
+public class HSAILHotSpotReplacementsUtil extends HotSpotReplacementsUtil {
+
+    private static HotSpotRegistersProvider hsailRegisters;
+
+    public static void initialize(HotSpotRegistersProvider registers) {
+        hsailRegisters = registers;
+    }
+
+    /**
+     * Gets the value of the thread register as a Word.
+     */
+    public static Word thread() {
+        return registerAsWord(threadRegister(), true, false);
+    }
+
+    @Fold
+    public static Register threadRegister() {
+        return hsailRegisters.getThreadRegister();
+    }
+
+    public static Word atomicGetAndAddTlabTop(Word thread, int size) {
+        return Word.unsigned(AtomicGetAndAddNode.atomicGetAndAdd(thread.rawValue(), threadTlabTopOffset(), TLAB_TOP_LOCATION, size));
+    }
+
+    public static final LocationIdentity TLAB_PFTOP_LOCATION = new NamedLocationIdentity("TlabPfTop");
+
+    @Fold
+    public static int threadTlabPfTopOffset() {
+        return config().threadTlabPfTopOffset();
+    }
+
+    public static void writeTlabPfTop(Word thread, Word val) {
+        thread.writeWord(threadTlabPfTopOffset(), val, TLAB_PFTOP_LOCATION);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.hsail.replacements;
+
+import static com.oracle.graal.api.code.UnsignedMath.*;
+import static com.oracle.graal.hotspot.hsail.replacements.HSAILHotSpotReplacementsUtil.*;
+import static com.oracle.graal.hotspot.hsail.replacements.HSAILNewObjectSnippets.Options.*;
+import static com.oracle.graal.nodes.PiArrayNode.*;
+import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
+import static com.oracle.graal.phases.GraalOptions.*;
+import static com.oracle.graal.replacements.SnippetTemplate.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.options.*;
+import com.oracle.graal.replacements.*;
+import com.oracle.graal.replacements.Snippet.ConstantParameter;
+import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
+import com.oracle.graal.replacements.SnippetTemplate.Arguments;
+import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
+import com.oracle.graal.word.*;
+
+/**
+ * HSAIL-specific Snippets used for implementing NEW and NEWARRAY.
+ */
+public class HSAILNewObjectSnippets extends NewObjectSnippets {
+
+    static public class Options {
+
+        // @formatter:off
+        @Option(help = "In HSAIL allocation, allow allocation from eden as fallback if TLAB is full")
+        static final OptionValue<Boolean> HsailUseEdenAllocate = new OptionValue<>(false);
+
+        @Option(help = "Estimate of number of bytes allocated by each HSAIL workitem, used to size TLABs")
+        static public final OptionValue<Integer> HsailAllocBytesPerWorkitem = new OptionValue<>(64);
+
+        // @formatter:on
+    }
+
+    private static final boolean hsailUseEdenAllocate = HsailUseEdenAllocate.getValue();
+
+    @Snippet
+    public static Object allocateInstanceAtomic(@ConstantParameter int size, Word hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) {
+        Word thread = thread();
+        boolean haveResult = false;
+        if (useTLAB()) {
+            Word top = atomicGetAndAddTlabTop(thread, size);
+            Word end = readTlabEnd(thread);
+            Word newTop = top.add(size);
+            if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
+                // writeTlabTop(thread, newTop) was done by the atomicGetAndAdd
+                Object result = formatObject(hub, size, top, prototypeMarkWord, fillContents, true, false, true);
+                profileAllocation("instance", size, typeContext);
+                return piCast(verifyOop(result), StampFactory.forNodeIntrinsic());
+            } else {
+                // only one overflower will be the first overflower, detectable because
+                // oldtop was still below end
+                if (top.belowOrEqual(end)) {
+                    // hack alert: store the last good top before overflow into pf_top
+                    // we will move it back into top later when back in the VM
+                    writeTlabPfTop(thread, top);
+                }
+                // useless logic but see notes on deopt path below
+                haveResult = newTop.belowOrEqual(end);
+            }
+        }
+        if (hsailUseEdenAllocate) {
+            // originally:
+            // result = NewInstanceStubCall.call(hub);
+
+            // we could not allocate from tlab, try allocating directly from eden
+            // false for no logging
+            Word memory = NewInstanceStub.edenAllocate(Word.unsigned(size), false);
+            if (memory.notEqual(0)) {
+                new_eden.inc();
+                Object result = formatObject(hub, size, memory, prototypeMarkWord, fillContents, true, false, true);
+                profileAllocation("instance", size, typeContext);
+                return piCast(verifyOop(result), StampFactory.forNodeIntrinsic());
+            }
+        }
+        // haveResult test here helps avoid dropping earlier stores were seen to be dropped without
+        // this.
+        if (!haveResult) {
+            DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
+        }
+        // will never get here but this keeps the compiler happy
+        return Word.zero().toObject();
+    }
+
+    @Snippet
+    public static Object allocateArrayAtomic(Word hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize,
+                    @ConstantParameter boolean fillContents, @ConstantParameter boolean maybeUnroll, @ConstantParameter String typeContext) {
+        if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) {
+            // This handles both negative array sizes and very large array sizes
+            DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
+        }
+        return allocateArrayAtomicImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, maybeUnroll, typeContext);
+    }
+
+    private static Object allocateArrayAtomicImpl(Word hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, boolean maybeUnroll, String typeContext) {
+        int alignment = wordSize();
+        int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize);
+        Word thread = thread();
+        boolean haveResult = false;
+        if (useTLAB()) {
+            Word top = atomicGetAndAddTlabTop(thread, allocationSize);
+            Word end = readTlabEnd(thread);
+            Word newTop = top.add(allocationSize);
+            if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
+                // writeTlabTop(thread, newTop) was done by the atomicGetAndAdd
+                newarray_loopInit.inc();
+                // we are not in a stub so we can set useSnippetCounters to true
+                Object result = formatArray(hub, allocationSize, length, headerSize, top, prototypeMarkWord, fillContents, maybeUnroll, true);
+                profileAllocation("array", allocationSize, typeContext);
+                return piArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic());
+            } else {
+                // only one overflower will be the first overflower, detectable because
+                // oldtop was still below end
+                if (top.belowOrEqual(end)) {
+                    // hack alert: store the last good top before overflow into pf_top
+                    // we will move it back into top later when back in the VM
+                    writeTlabPfTop(thread, top);
+                }
+                // useless logic but see notes on deopt path below
+                haveResult = newTop.belowOrEqual(end);
+            }
+        }
+        // we could not allocate from tlab, try allocating directly from eden
+        if (hsailUseEdenAllocate) {
+            // false for no logging
+            Word memory = NewInstanceStub.edenAllocate(Word.unsigned(allocationSize), false);
+            if (memory.notEqual(0)) {
+                newarray_eden.inc();
+                // we are not in a stub so we can set useSnippetCounters to true
+                Object result = formatArray(hub, allocationSize, length, headerSize, memory, prototypeMarkWord, fillContents, maybeUnroll, true);
+                profileAllocation("array", allocationSize, typeContext);
+                return piArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic());
+            }
+        }
+        if (!haveResult) {
+            DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
+        }
+        // will never get here but this keeps the compiler happy
+        return Word.zero().toObject();
+    }
+
+    public static class Templates extends AbstractTemplates {
+
+        private final SnippetInfo allocateInstance = snippet(HSAILNewObjectSnippets.class, "allocateInstanceAtomic");
+        private final SnippetInfo allocateArray = snippet(HSAILNewObjectSnippets.class, "allocateArrayAtomic");
+
+        // private final SnippetInfo allocateArrayDynamic = snippet(NewObjectSnippets.class,
+        // "allocateArrayDynamic");
+        // private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class,
+        // "newmultiarray");
+
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
+        }
+
+        /**
+         * Lowers a {@link NewInstanceNode}.
+         */
+        public void lower(NewInstanceNode newInstanceNode, LoweringTool tool) {
+            StructuredGraph graph = newInstanceNode.graph();
+            HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass();
+            assert !type.isArray();
+            ConstantNode hub = ConstantNode.forConstant(type.klass(), providers.getMetaAccess(), graph);
+            int size = instanceSize(type);
+
+            Arguments args = new Arguments(allocateInstance, graph.getGuardsStage(), tool.getLoweringStage());
+            args.addConst("size", size);
+            args.add("hub", hub);
+            args.add("prototypeMarkWord", type.prototypeMarkWord());
+            args.addConst("fillContents", newInstanceNode.fillContents());
+            args.addConst("typeContext", MetaUtil.toJavaName(type, false));
+
+            SnippetTemplate template = template(args);
+            Debug.log("Lowering allocateInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, args);
+            template.instantiate(providers.getMetaAccess(), newInstanceNode, DEFAULT_REPLACER, args);
+        }
+
+        /**
+         * Lowers a {@link NewArrayNode}.
+         */
+        public void lower(NewArrayNode newArrayNode, LoweringTool tool) {
+            StructuredGraph graph = newArrayNode.graph();
+            ResolvedJavaType elementType = newArrayNode.elementType();
+            HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass();
+            Kind elementKind = elementType.getKind();
+            ConstantNode hub = ConstantNode.forConstant(arrayType.klass(), providers.getMetaAccess(), graph);
+            final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
+            // lowerer extends HotSpotLoweringProvider so we can just use that
+            HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
+            int log2ElementSize = CodeUtil.log2(lowerer.getScalingFactor(elementKind));
+
+            Arguments args = new Arguments(allocateArray, graph.getGuardsStage(), tool.getLoweringStage());
+            args.add("hub", hub);
+            args.add("length", newArrayNode.length());
+            args.add("prototypeMarkWord", arrayType.prototypeMarkWord());
+            args.addConst("headerSize", headerSize);
+            args.addConst("log2ElementSize", log2ElementSize);
+            args.addConst("fillContents", newArrayNode.fillContents());
+            args.addConst("maybeUnroll", newArrayNode.length().isConstant());
+            args.addConst("typeContext", MetaUtil.toJavaName(arrayType, false));
+
+            SnippetTemplate template = template(args);
+            Debug.log("Lowering allocateArray in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args);
+            template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
+        }
+
+        private static int instanceSize(HotSpotResolvedObjectType type) {
+            int size = type.instanceSize();
+            assert (size % wordSize()) == 0;
+            assert size >= 0;
+            return size;
+        }
+    }
+
+    private static final SnippetCounter.Group countersNew = SnippetCounters.getValue() ? new SnippetCounter.Group("NewInstance") : null;
+    private static final SnippetCounter new_eden = new SnippetCounter(countersNew, "eden", "used edenAllocate");
+
+    private static final SnippetCounter.Group countersNewArray = SnippetCounters.getValue() ? new SnippetCounter.Group("NewArray") : null;
+    private static final SnippetCounter newarray_loopInit = new SnippetCounter(countersNewArray, "tlabLoopInit", "TLAB alloc with zeroing in a loop");
+    private static final SnippetCounter newarray_eden = new SnippetCounter(countersNewArray, "eden", "used edenAllocate");
+}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -95,6 +95,7 @@
                     long.class, // objectParameterOffsets
                     long.class, // pinnedObjects
                     int.class); // encodedReturnTypeSize
+
     // @formatter:on
 
     public PTXHotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
@@ -154,8 +155,8 @@
     private static native long getLaunchKernelAddress();
 
     @Override
-    public FrameMap newFrameMap() {
-        return new PTXFrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new PTXFrameMap(getCodeCache(), registerConfig);
     }
 
     /**
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -47,7 +47,7 @@
         HotSpotDisassemblerProvider disassembler = host.getDisassembler();
         SuitesProvider suites = new DefaultSuitesProvider();
         HotSpotRegistersProvider registers = new HotSpotRegisters(PTX.tid, Register.None, Register.None);
-        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers);
+        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, host.getSnippetReflection());
         return new PTXHotSpotBackend(runtime, providers);
     }
 
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotCodeCacheProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotCodeCacheProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,11 @@
  */
 package com.oracle.graal.hotspot.ptx;
 
+import java.util.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
-import java.util.Arrays;
 
 public class PTXHotSpotCodeCacheProvider extends HotSpotCodeCacheProvider {
 
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,6 +31,7 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 
 /**
  * LIR generator specialized for PTX HotSpot.
@@ -59,13 +60,43 @@
         throw GraalInternalError.unimplemented();
     }
 
-    public Value emitCompress(Value pointer, CompressEncoding encoding) {
+    @Override
+    public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
+        // TODO
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
         // TODO
         throw GraalInternalError.unimplemented();
     }
 
-    public Value emitUncompress(Value pointer, CompressEncoding encoding) {
-        // TODO
+    public void emitLeaveCurrentStackFrame() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveUnpackFramesStackFrame() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public SaveRegistersOp emitSaveAllRegisters() {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
+        throw GraalInternalError.unimplemented();
+    }
+
+    public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
         throw GraalInternalError.unimplemented();
     }
 }
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,8 +29,8 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CallingConvention.Type;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.lir.Variable;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.*;
 
 public class PTXHotSpotRegisterConfig implements RegisterConfig {
 
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXWrapperBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXWrapperBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -192,7 +192,7 @@
             }
         }
 
-        InvokeNode kernelStart = createInvoke(getClass(), "getKernelStart", ConstantNode.forObject(kernel, providers.getMetaAccess(), getGraph()));
+        InvokeNode kernelStart = createInvoke(getClass(), "getKernelStart", ConstantNode.forConstant(HotSpotObjectConstant.forObject(kernel), providers.getMetaAccess(), getGraph()));
 
         AllocaNode buf = append(new AllocaNode(bufSize / wordSize, new BitSet()));
         ValueNode objectParametersOffsets;
@@ -290,8 +290,8 @@
             Debug.dump(getGraph(), "Initial kernel launch graph");
         }
 
-        rewriteWordTypes();
-        inlineInvokes();
+        rewriteWordTypes(providers.getSnippetReflection());
+        inlineInvokes(providers.getSnippetReflection());
 
         if (Debug.isDumpEnabled()) {
             Debug.dump(getGraph(), "Kernel launch graph before compilation");
--- a/graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.server/src/com/oracle/graal/hotspot/server/ReplacingStreams.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.hotspot.logging.*;
+import com.oracle.graal.hotspot.meta.*;
 
 public class ReplacingStreams {
 
@@ -172,7 +173,7 @@
                 if (constant.getKind() != Kind.Object) {
                     return obj;
                 }
-                Object contents = constant.asObject();
+                Object contents = HotSpotObjectConstant.asObject(constant);
                 if (contents == null) {
                     return obj;
                 }
@@ -182,12 +183,12 @@
                 }
                 placeholder = objectMap.get(contents);
                 if (placeholder != null) {
-                    return Constant.forObject(placeholder);
+                    return HotSpotObjectConstant.forObject(placeholder);
                 }
                 if (contents instanceof Remote) {
-                    return Constant.forObject(createRemoteCallPlaceholder(contents));
+                    return HotSpotObjectConstant.forObject(createRemoteCallPlaceholder(contents));
                 }
-                return Constant.forObject(createDummyPlaceholder(contents));
+                return HotSpotObjectConstant.forObject(createDummyPlaceholder(contents));
             }
             return obj;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizationStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.sparc;
+
+import static com.oracle.graal.sparc.SPARC.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.stubs.*;
+
+final class SPARCDeoptimizationStub extends DeoptimizationStub {
+
+    private RegisterConfig registerConfig;
+
+    public SPARCDeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) {
+        super(providers, target, linkage);
+        registerConfig = new SPARCHotSpotRegisterConfig(target, new Register[]{o0, o1, o2, o3, o4, o5, o7, l0, l1, l2, l3, l4, l5, l6, l7, i0, i1, i2, i3, i4, i5, f0, f1, f2, f3, f4, f5, f6, f7});
+    }
+
+    @Override
+    public RegisterConfig getRegisterConfig() {
+        return registerConfig;
+    }
+}
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.lir.StandardOp.BlockEndOp;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
 
@@ -49,6 +49,6 @@
         // [Deopt Handler Code]
         // 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call}
         // 0xffffffff749bb610: nop
-        SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info);
+        SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER), null, false, info);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,8 +48,8 @@
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
@@ -74,8 +74,8 @@
     }
 
     @Override
-    public FrameMap newFrameMap() {
-        return new SPARCFrameMap(getProviders().getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new SPARCFrameMap(getProviders().getCodeCache(), registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -60,10 +60,11 @@
         // to be valid for the entire run of the VM.
         Assumptions assumptions = new Assumptions(false);
         Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null);
-        HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, runtime.getConfig(), assumptions, target);
+        HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider();
+        HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, target);
         HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime);
         HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime);
-        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers);
+        HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection);
 
         return new SPARCHotSpotBackend(runtime, providers);
     }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -47,7 +47,7 @@
         // HotSpotFrameContext frameContext = backend.new HotSpotFrameContext(isStub);
         // frameContext.enter(crb);
         Register scratch = g3;
-        SPARCCall.indirectJmp(crb, masm, scratch, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP));
+        SPARCCall.indirectJmp(crb, masm, scratch, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP_HANDLER));
 
         // frameContext.leave(crb);
     }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
+import com.oracle.graal.lir.StandardOp.BlockEndOp;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
-import com.oracle.graal.lir.StandardOp.*;
-import com.oracle.graal.lir.asm.*;
 
 /**
  * Superclass for operations that leave a method's frame.
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -46,7 +46,8 @@
 
     @Override
     public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-        Kind word = providers.getCodeCache().getTarget().wordKind;
+        TargetDescription target = providers.getCodeCache().getTarget();
+        Kind word = target.wordKind;
 
         // The calling convention for the exception handler stub is (only?) defined in
         // TemplateInterpreterGenerator::generate_throw_exception()
@@ -60,6 +61,8 @@
         register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, ANY_LOCATION));
         register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, ANY_LOCATION));
 
+        link(new SPARCDeoptimizationStub(providers, target, registerStubCall(UNCOMMON_TRAP_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS)));
+
         super.initialize(providers, config);
     }
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,10 +31,11 @@
 import com.oracle.graal.compiler.sparc.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.HotSpotVMConfig.*;
+import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.lir.sparc.SPARCMove.LoadOp;
 import com.oracle.graal.lir.sparc.SPARCMove.StoreConstantOp;
@@ -80,18 +81,23 @@
 
     @Override
     public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) {
+        HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
         Variable result;
+        DeoptimizingNode deoptInfo = null;
+        if (hotspotLinkage.canDeoptimize()) {
+            deoptInfo = info;
+            assert deoptInfo != null || getStub() != null;
+        }
 
-        if (linkage.canDeoptimize()) {
-            assert info != null || getStub() != null;
+        if (hotspotLinkage.needsJavaFrameAnchor()) {
             HotSpotRegistersProvider registers = getProviders().getRegisters();
             Register thread = registers.getThreadRegister();
             Register stackPointer = registers.getStackPointerRegister();
             append(new SPARCHotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread, stackPointer));
-            result = super.emitForeignCall(linkage, info, args);
+            result = super.emitForeignCall(hotspotLinkage, deoptInfo, args);
             append(new SPARCHotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadJavaFrameAnchorFlagsOffset(), thread));
         } else {
-            result = super.emitForeignCall(linkage, null, args);
+            result = super.emitForeignCall(hotspotLinkage, deoptInfo, args);
         }
 
         return result;
@@ -228,6 +234,10 @@
         }
     }
 
+    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
+        throw new InternalError("NYI");
+    }
+
     @Override
     public Value emitNot(Value input) {
         GraalInternalError.shouldNotReachHere("binary negation not implemented");
@@ -238,13 +248,50 @@
         return deoptimizationRescueSlot;
     }
 
-    public Value emitCompress(Value pointer, CompressEncoding encoding) {
+    @Override
+    public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
+        // TODO
+        throw GraalInternalError.unimplemented();
+    }
+
+    @Override
+    public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
         // TODO
         throw GraalInternalError.unimplemented();
     }
 
-    public Value emitUncompress(Value pointer, CompressEncoding encoding) {
-        // TODO
+    public SaveRegistersOp emitSaveAllRegisters() {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveCurrentStackFrame() {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp) {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitLeaveUnpackFramesStackFrame() {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
+        // TODO Auto-generated method stub
+        throw GraalInternalError.unimplemented();
+    }
+
+    public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
+        // TODO Auto-generated method stub
         throw GraalInternalError.unimplemented();
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -101,8 +101,7 @@
             assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
             HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target();
             assert !Modifier.isAbstract(resolvedMethod.getModifiers()) : "Cannot make direct call to abstract method.";
-            Constant metaspaceMethod = resolvedMethod.getMetaspaceMethodConstant();
-            append(new SPARCHotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind, metaspaceMethod));
+            append(new SPARCHotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
         }
     }
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,15 +22,15 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 import static com.oracle.graal.sparc.SPARC.*;
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Ldx;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
-import com.oracle.graal.lir.asm.*;
 
 /**
  * Patch the return address of the current frame.
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,18 +22,18 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
+import static com.oracle.graal.phases.GraalOptions.*;
 import static com.oracle.graal.sparc.SPARC.*;
-import static com.oracle.graal.phases.GraalOptions.*;
 
 import java.util.*;
 
-import com.oracle.graal.sparc.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CallingConvention.Type;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.sparc.*;
 
 public class SPARCHotSpotRegisterConfig implements RegisterConfig {
 
@@ -131,10 +131,14 @@
     }
 
     public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) {
+        this(target, initAllocatable(config.useCompressedOops));
+    }
+
+    public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) {
         this.architecture = target.arch;
 
         csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters);
-        allocatable = initAllocatable(config.useCompressedOops);
+        this.allocatable = allocatable.clone();
         attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
     }
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,17 +22,18 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Ldx;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
-import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.spi.*;
 
 /**
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,18 +22,18 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
-import static com.oracle.graal.sparc.SPARC.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.hotspot.HotSpotBackend.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Mov;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
-import com.oracle.graal.lir.asm.*;
 
 /**
  * Removes the current frame and jumps to the {@link UnwindExceptionToCallerStub}.
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,44 +22,32 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
-import static com.oracle.graal.sparc.SPARC.*;
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp;
-import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 
 /**
- * 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.
+ * A direct call that complies with the conventions for such calls in HotSpot. It doesn't use an
+ * inline cache so it's just a patchable call site.
  */
 @Opcode("CALL_DIRECT")
 final class SPARCHotspotDirectStaticCallOp extends DirectCallOp {
 
-    private final Constant metaspaceMethod;
     private final InvokeKind invokeKind;
 
-    SPARCHotspotDirectStaticCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind, Constant metaspaceMethod) {
+    SPARCHotspotDirectStaticCallOp(ResolvedJavaMethod target, Value result, Value[] parameters, Value[] temps, LIRFrameState state, InvokeKind invokeKind) {
         super(target, result, parameters, temps, state);
         assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
-        this.metaspaceMethod = metaspaceMethod;
         this.invokeKind = invokeKind;
     }
 
     @Override
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler 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.
-        SPARCMove.move(crb, masm, g5.asValue(Kind.Long), metaspaceMethod);
         MarkId.recordMark(crb, invokeKind == InvokeKind.Static ? MarkId.INVOKESTATIC : MarkId.INVOKESPECIAL);
-        // SPARCMove.move(crb, masm, g3.asValue(Kind.Long), Constant.LONG_0);
-        new Setx(HotSpotGraalRuntime.runtime().getConfig().nonOopBits, g3, true).emit(masm);
         super.emitCode(crb, masm);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,12 +27,12 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Setx;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp;
-import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 
 /**
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,9 +31,9 @@
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.lir.sparc.SPARCCall.IndirectCallOp;
-import com.oracle.graal.lir.asm.*;
 
 /**
  * A register indirect call that complies with the extra conventions for such calls in HotSpot. In
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCPrefetchOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCPrefetchOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,9 +23,9 @@
 
 package com.oracle.graal.hotspot.sparc;
 
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
+import com.oracle.graal.asm.sparc.SPARCAssembler.Prefetch;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.*;
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -81,7 +81,7 @@
         assertEquals(0, result.getNodes().filter(ReadNode.class).count());
     }
 
-    public static Class getClassObject() {
+    public static Class<AheadOfTimeCompilationTest> getClassObject() {
         return AheadOfTimeCompilationTest.class;
     }
 
@@ -104,7 +104,7 @@
 
         NodeIterable<ConstantNode> filter = getConstantNodes(result);
         assertEquals(1, filter.count());
-        Object mirror = filter.first().asConstant().asObject();
+        Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant());
         assertEquals(Class.class, mirror.getClass());
         assertEquals(AheadOfTimeCompilationTest.class, mirror);
 
@@ -112,7 +112,7 @@
         assertEquals(0, result.getNodes().filter(ReadNode.class).count());
     }
 
-    public static Class getPrimitiveClassObject() {
+    public static Class<Integer> getPrimitiveClassObject() {
         return int.class;
     }
 
@@ -132,7 +132,7 @@
         StructuredGraph result = compile("getPrimitiveClassObject", false);
         NodeIterable<ConstantNode> filter = getConstantNodes(result);
         assertEquals(1, filter.count());
-        Object mirror = filter.first().asConstant().asObject();
+        Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant());
         assertEquals(Class.class, mirror.getClass());
         assertEquals(Integer.TYPE, mirror);
 
@@ -160,7 +160,7 @@
 
         NodeIterable<ConstantNode> filter = getConstantNodes(result);
         assertEquals(1, filter.count());
-        Object mirror = filter.first().asConstant().asObject();
+        Object mirror = HotSpotObjectConstant.asObject(filter.first().asConstant());
         assertEquals(String.class, mirror.getClass());
         assertEquals("test string", mirror);
 
@@ -193,7 +193,7 @@
         assertEquals(1, getConstantNodes(result).count());
         ConstantNode constant = getConstantNodes(result).first();
         assertEquals(Kind.Object, constant.getKind());
-        assertEquals(Boolean.TRUE, constant.asConstant().asObject());
+        assertEquals(Boolean.TRUE, HotSpotObjectConstant.asObject(constant.asConstant()));
     }
 
     private StructuredGraph compile(String test, boolean compileAOT) {
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -47,8 +47,8 @@
         this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
     }
 
-    private HotSpotInstalledCode getInstalledCode(String name) throws Exception {
-        final Method method = CompressedOopTest.class.getMethod(name, Object.class, Object.class, Object.class);
+    private HotSpotInstalledCode getInstalledCode(String name, Class<?>... parameterTypes) throws Exception {
+        final Method method = CompressedOopTest.class.getMethod(name, parameterTypes);
         final HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
         final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(javaMethod, parse(method));
         return installedBenchmarkCode;
@@ -56,19 +56,19 @@
 
     @Test
     public void test() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("fieldTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("fieldTest", Object.class);
         Container c1 = new Container();
-        Assert.assertEquals(c1.b, installedBenchmarkCode.executeVarargs(c1, c1, c1));
+        Assert.assertEquals(c1.b, installedBenchmarkCode.executeVarargs(c1));
     }
 
-    public static Object fieldTest(Object c1, @SuppressWarnings("unused") Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Object fieldTest(Object c1) {
         ((Container) c1).a = ((Container) c1).b;
         return ((Container) c1).a;
     }
 
     @Test
     public void test1() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("arrayTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("arrayTest", Object.class, Object.class, Object.class);
         ArrayContainer ac = new ArrayContainer();
         Assert.assertEquals(ac.a[9], installedBenchmarkCode.executeVarargs(ac.a, 0, 9));
         Assert.assertEquals(ac.a[8], installedBenchmarkCode.executeVarargs(ac.a, 1, 8));
@@ -92,16 +92,16 @@
 
     @Test
     public void test2() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("arrayCopyTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("arrayCopyTest", Object.class, Object.class);
         ArrayContainer source = new ArrayContainer();
         ArrayContainer destination = new ArrayContainer();
         Assert.assertEquals(source.a.length, destination.a.length);
         Assert.assertFalse(Arrays.equals(source.a, destination.a));
-        installedBenchmarkCode.execute(source.a, destination.a, source.a);
+        installedBenchmarkCode.executeVarargs(source.a, destination.a);
         Assert.assertArrayEquals(source.a, destination.a);
     }
 
-    public static void arrayCopyTest(Object c1, Object c2, @SuppressWarnings("unused") Object c3) {
+    public static void arrayCopyTest(Object c1, Object c2) {
         Object[] source = (Object[]) c1;
         Object[] destination = (Object[]) c2;
         System.arraycopy(source, 0, destination, 0, source.length);
@@ -109,14 +109,14 @@
 
     @Test
     public void test3() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("compareAndSwapTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("compareAndSwapTest", Object.class, Object.class, Object.class);
         Object initial = new Object();
         Object replacement = new Object();
         AtomicReference<Object> cas = new AtomicReference<>();
         Assert.assertEquals(cas.get(), null);
-        installedBenchmarkCode.execute(cas, null, initial);
+        installedBenchmarkCode.executeVarargs(cas, null, initial);
         Assert.assertEquals(cas.get(), initial);
-        installedBenchmarkCode.execute(cas, initial, replacement);
+        installedBenchmarkCode.executeVarargs(cas, initial, replacement);
         Assert.assertEquals(cas.get(), replacement);
     }
 
@@ -128,11 +128,11 @@
 
     @Test
     public void test4() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("charArrayCopyTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("charArrayCopyTest", Object.class, Object.class, Object.class);
         StringContainer1 source1 = new StringContainer1();
         StringContainer2 source2 = new StringContainer2();
         char[] result = new char[source1.value.length + source2.value.length];
-        installedBenchmarkCode.execute(source1.value, source2.value, result);
+        installedBenchmarkCode.executeVarargs(source1.value, source2.value, result);
         Assert.assertArrayEquals(new char[]{'T', 'e', 's', 't', ' ', 'S', 't', 'r', 'i', 'n', 'g'}, result);
     }
 
@@ -152,11 +152,11 @@
 
     @Test
     public void test5() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("charContainerArrayCopyTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("charContainerArrayCopyTest", Object.class, Object.class, Object.class);
         StringContainer1 source1 = new StringContainer1();
         StringContainer2 source2 = new StringContainer2();
         char[] result = new char[source1.value.length + source2.value.length];
-        installedBenchmarkCode.execute(source1, source2, result);
+        installedBenchmarkCode.executeVarargs(source1, source2, result);
         Assert.assertArrayEquals(new char[]{'T', 'e', 's', 't', ' ', 'S', 't', 'r', 'i', 'n', 'g'}, result);
     }
 
@@ -175,14 +175,14 @@
 
     @Test
     public void test6() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringCopyTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringCopyTest", Object.class, Object.class);
         String a = new String("Test ");
         String b = new String("String");
-        String c = (String) installedBenchmarkCode.execute(a, b, null);
+        String c = (String) installedBenchmarkCode.executeVarargs(a, b);
         Assert.assertTrue(c.equals("Test String"));
     }
 
-    public static String stringCopyTest(Object c1, Object c2, @SuppressWarnings("unused") Object c3) {
+    public static String stringCopyTest(Object c1, Object c2) {
         String source = (String) c1;
         String destination = (String) c2;
         return source + destination;
@@ -190,7 +190,7 @@
 
     @Test
     public void test7() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("queueTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("queueTest", Object.class, Object.class);
         ArrayDeque<Object> q = new ArrayDeque<>();
         Object[] objects = new Object[512];
         for (int i = 0; i < objects.length; i++) {
@@ -202,7 +202,7 @@
                 // This can get invalidated due to lack of MDO update
                 installedBenchmarkCode = getInstalledCode("queueTest");
             }
-            installedBenchmarkCode.execute(q, objects[j], null);
+            installedBenchmarkCode.executeVarargs(q, objects[j]);
             j++;
         }
 
@@ -220,19 +220,19 @@
     }
 
     @SuppressWarnings("unchecked")
-    public static void queueTest(Object c1, Object c2, @SuppressWarnings("unused") Object c3) {
+    public static void queueTest(Object c1, Object c2) {
         ArrayDeque<Object> queue = (ArrayDeque<Object>) c1;
         queue.add(c2);
     }
 
     @Test
     public void test8() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest", Object.class);
         List<Object> list = new ArrayList<>();
         for (int i = 0; i < 512; i++) {
             list.add(new Object());
         }
-        Object[] array = (Object[]) installedBenchmarkCode.execute(list, null, null);
+        Object[] array = (Object[]) installedBenchmarkCode.executeVarargs(list);
         Assert.assertTrue(list.size() == array.length);
         int i = 0;
         for (Object obj : list) {
@@ -242,7 +242,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    public static Object[] unmodListTest(Object c1, @SuppressWarnings("unused") Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Object[] unmodListTest(Object c1) {
         List<Object> queue = (ArrayList<Object>) c1;
         Object[] result = Collections.unmodifiableCollection(queue).toArray(new Object[queue.size()]);
         return result;
@@ -250,50 +250,50 @@
 
     @Test
     public void test9() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTest", Object.class);
         List<Object> list = new ArrayList<>();
-        Object[] array = (Object[]) installedBenchmarkCode.execute(list, null, null);
+        Object[] array = (Object[]) installedBenchmarkCode.executeVarargs(list);
         Assert.assertTrue(list.size() == array.length);
     }
 
     public void test10() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("constantTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("constantTest", Object.class);
         Container c = new Container();
-        Assert.assertFalse((boolean) installedBenchmarkCode.execute(c, null, null));
+        Assert.assertFalse((boolean) installedBenchmarkCode.executeVarargs(c));
     }
 
-    public static Boolean constantTest(Object c1, @SuppressWarnings("unused") Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Boolean constantTest(Object c1) {
         ConstantContainer container = (ConstantContainer) c1;
         return container.a.equals(container.b);
     }
 
     @Test
     public void test11() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringEqualsTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringEqualsTest", Object.class, Object.class);
         String s1 = new String("Test");
         String s2 = new String("Test");
-        boolean result = ((Boolean) (installedBenchmarkCode.execute(s1, s2, null))).booleanValue();
+        boolean result = ((Boolean) (installedBenchmarkCode.executeVarargs(s1, s2))).booleanValue();
         Assert.assertTrue(result);
     }
 
-    public static Boolean stringEqualsTest(Object c1, Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Boolean stringEqualsTest(Object c1, Object c2) {
         return ((String) c1).equals(c2);
     }
 
     @Test
     public void test12() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringConstantEqualsTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringConstantEqualsTest", Object.class);
         String s1 = new String("Test");
-        boolean result = ((Boolean) (installedBenchmarkCode.execute(s1, null, null))).booleanValue();
+        boolean result = ((Boolean) (installedBenchmarkCode.executeVarargs(s1))).booleanValue();
         Assert.assertTrue(result);
     }
 
-    public static Boolean stringConstantEqualsTest(Object c1, @SuppressWarnings("unused") Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Boolean stringConstantEqualsTest(Object c1) {
         return "Test".equals(c1);
     }
 
     @SuppressWarnings("unchecked")
-    public static Object[] unmodListTestByte(Object c1, @SuppressWarnings("unused") Object c2, @SuppressWarnings("unused") Object c3) {
+    public static Object[] unmodListTestByte(Object c1) {
         List<Byte> queue = (ArrayList<Byte>) c1;
         Byte[] result = Collections.unmodifiableCollection(queue).toArray(new Byte[queue.size()]);
         return result;
@@ -301,24 +301,24 @@
 
     @Test
     public void test13() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTestByte");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("unmodListTestByte", Object.class);
         List<Byte> list = new ArrayList<>();
-        Byte[] array = (Byte[]) installedBenchmarkCode.execute(list, null, null);
+        Byte[] array = (Byte[]) installedBenchmarkCode.executeVarargs(list);
         Assert.assertTrue(list.size() == array.length);
     }
 
     @Test
     public void test14() throws Exception {
-        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBufferTest");
+        HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBufferTest", Object.class, Object.class);
         StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest");
         Assert.assertTrue(buffer.length() == 28);
         String a = new String("TestTestTestTestTestTestTest");
-        installedBenchmarkCode.execute(buffer, a.toCharArray(), null);
+        installedBenchmarkCode.executeVarargs(buffer, a.toCharArray());
         Assert.assertTrue(buffer.length() == 56);
         Assert.assertTrue(buffer.toString().equals("TestTestTestTestTestTestTestTestTestTestTestTestTestTest"));
     }
 
-    public static void stringBufferTest(Object c1, Object c2, @SuppressWarnings("unused") Object c3) {
+    public static void stringBufferTest(Object c1, Object c2) {
         StringBuffer source = (StringBuffer) c1;
         char[] add = (char[]) c2;
         for (int i = 0; i < add.length; i++) {
@@ -329,11 +329,10 @@
     @Test
     public void test15() throws Exception {
         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBufferTestIn");
-        installedBenchmarkCode.execute(null, null, null);
+        installedBenchmarkCode.executeVarargs();
     }
 
-    @SuppressWarnings("unused")
-    public static void stringBufferTestIn(Object c1, Object c2, Object c3) {
+    public static void stringBufferTestIn() {
         StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest");
         Assert.assertTrue(buffer.length() == 28);
         String a = new String("TestTestTestTestTestTestTest");
@@ -348,11 +347,10 @@
     @Test
     public void test16() throws Exception {
         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBufferArrayCopy");
-        installedBenchmarkCode.execute(null, null, null);
+        installedBenchmarkCode.executeVarargs();
     }
 
-    @SuppressWarnings("unused")
-    public static void stringBufferArrayCopy(Object c1, Object c2, Object c3) {
+    public static void stringBufferArrayCopy() {
         StringBuffer buffer = new StringBuffer("TestTestTestTestTestTestTest");
         Assert.assertTrue(buffer.length() == 28);
         String a = new String("TestTestTestTestTestTestTest");
@@ -366,11 +364,10 @@
     @Test
     public void test17() throws Exception {
         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringFormat");
-        installedBenchmarkCode.execute(null, null, null);
+        installedBenchmarkCode.executeVarargs();
     }
 
-    @SuppressWarnings("unused")
-    public static void stringFormat(Object c1, Object c2, Object c3) {
+    public static void stringFormat() {
         String.format("Hello %d", 0);
         String.format("Hello %d", -11);
         String.format("Hello %d", -2147483648);
@@ -379,13 +376,12 @@
     @Test
     public void test18() throws Exception {
         HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilder");
-        StringBuilder b = (StringBuilder) installedBenchmarkCode.execute(null, null, null);
+        StringBuilder b = (StringBuilder) installedBenchmarkCode.executeVarargs();
         Assert.assertTrue(b.capacity() == 16);
         Assert.assertTrue(b.length() == 0);
     }
 
-    @SuppressWarnings("unused")
-    public static Object stringBuilder(Object c1, Object c2, Object c3) {
+    public static Object stringBuilder() {
         return new StringBuilder();
     }
 
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -127,7 +127,7 @@
     }
 
     private static Method lookup(String className, String methodName) {
-        Class c;
+        Class<?> c;
         try {
             c = Class.forName(className);
             for (Method m : c.getDeclaredMethods()) {
@@ -180,7 +180,7 @@
         return result;
     }
 
-    private static byte[] readClassfile16(Class c) throws IOException {
+    private static byte[] readClassfile16(Class<? extends HotSpotCryptoSubstitutionTest> c) throws IOException {
         String classFilePath = "/" + c.getName().replace('.', '/') + ".class";
         InputStream stream = c.getResourceAsStream(classFilePath);
         int bytesToRead = stream.available();
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMethodSubstitutionTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotMethodSubstitutionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -74,7 +74,7 @@
         test("getSuperClass");
         test("getComponentType");
 
-        for (Class c : new Class[]{getClass(), Cloneable.class, int[].class, String[][].class}) {
+        for (Class<?> c : new Class[]{getClass(), Cloneable.class, int[].class, String[][].class}) {
             assertEquals(c.getModifiers(), ClassSubstitutions.getModifiers(c));
             assertEquals(c.isInterface(), ClassSubstitutions.isInterface(c));
             assertEquals(c.isArray(), ClassSubstitutions.isArray(c));
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -42,7 +42,7 @@
         Assert.assertTrue(nmethod.isValid());
         Object result;
         try {
-            result = nmethod.execute(null, "b", "c");
+            result = nmethod.executeVarargs(null, "b", "c");
             assertEquals(43, result);
         } catch (InvalidInstalledCodeException e) {
             Assert.fail("Code was invalidated");
@@ -51,7 +51,7 @@
         nmethod.invalidate();
         Assert.assertFalse(nmethod.isValid());
         try {
-            result = nmethod.execute(null, null, null);
+            result = nmethod.executeVarargs(null, null, null);
             Assert.fail("Code was not invalidated");
         } catch (InvalidInstalledCodeException e) {
         }
@@ -65,7 +65,7 @@
         final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, graph);
         Object result;
         try {
-            result = nmethod.execute(nmethod, null, null);
+            result = nmethod.executeVarargs(nmethod, null, null);
             assertEquals(43, result);
         } catch (InvalidInstalledCodeException e) {
             Assert.fail("Code was invalidated");
@@ -81,7 +81,7 @@
         Assert.assertTrue(nmethod.isValid());
         try {
             for (int i = 0; i < ITERATION_COUNT; ++i) {
-                nmethod.execute(null, "b", "c");
+                nmethod.executeVarargs(null, "b", "c");
             }
         } catch (InvalidInstalledCodeException e) {
             Assert.fail("Code was invalidated");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNodeClassSubstitutionsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.test;
+
+import org.junit.*;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.replacements.test.*;
+
+/**
+ * Tests HotSpot specific substitutions for {@link NodeClass}.
+ */
+public class HotSpotNodeClassSubstitutionsTest extends MethodSubstitutionTest {
+
+    @Test
+    public void test() {
+        test("get", ValueNode.class);
+    }
+
+    public static NodeClass get(Class<?> c) {
+        return NodeClass.get(c);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNodeSubstitutionsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.test;
+
+import org.junit.*;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.replacements.test.*;
+
+/**
+ * Tests HotSpot specific substitutions for {@link Node}.
+ */
+public class HotSpotNodeSubstitutionsTest extends MethodSubstitutionTest {
+
+    @Test
+    public void test() {
+        StructuredGraph graph = new StructuredGraph();
+        test("getNodeClass", ConstantNode.forInt(42, graph));
+    }
+
+    public static NodeClass getNodeClass(Node n) {
+        return n.getNodeClass();
+    }
+}
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedJavaFieldTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotResolvedJavaFieldTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
  */
 public class HotSpotResolvedJavaFieldTest {
 
-    private static final Class[] classesWithInternalFields = {Class.class, ClassLoader.class};
+    private static final Class<?>[] classesWithInternalFields = {Class.class, ClassLoader.class};
 
     /**
      * Tests that {@link HotSpotResolvedJavaField#getModifiers()} only includes the modifiers
@@ -47,7 +47,7 @@
      */
     @Test
     public void testModifiersForInternal() {
-        for (Class c : classesWithInternalFields) {
+        for (Class<?> c : classesWithInternalFields) {
             ResolvedJavaType type = HotSpotResolvedObjectType.fromClass(c);
             for (ResolvedJavaField field : type.getInstanceFields(false)) {
                 if (field.isInternal()) {
@@ -63,7 +63,7 @@
      */
     @Test
     public void testCachingForInternalFields() {
-        for (Class c : classesWithInternalFields) {
+        for (Class<?> c : classesWithInternalFields) {
             HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(c);
             for (ResolvedJavaField field : type.getInstanceFields(false)) {
                 if (field.isInternal()) {
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -49,7 +49,7 @@
 
     @Test
     public void test1() throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException {
-        final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class);
+        final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo");
         final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(fooMethod);
         final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod));
 
@@ -69,13 +69,13 @@
         int val = 0;
         for (int j = 0; j < 100; j++) {
             for (int i = 0; i < ITERATIONS; i++) {
-                val = (Integer) code.execute(null, null, null);
+                val = (Integer) code.executeVarargs();
             }
         }
         return val;
     }
 
-    public static Integer foo(@SuppressWarnings("unused") Object a1, @SuppressWarnings("unused") Object a2, @SuppressWarnings("unused") Object a3) {
+    public static Integer foo() {
         return 42;
     }
 
@@ -89,7 +89,7 @@
             assert parameterTypes.length == args.length;
             for (int i = 0; i < argsToBind.length; i++) {
                 ParameterNode param = graph.getParameter(i);
-                Constant c = Constant.forBoxed(parameterTypes[i].getKind(), argsToBind[i]);
+                Constant c = HotSpotObjectConstant.forBoxedValue(parameterTypes[i].getKind(), argsToBind[i]);
                 ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
                 param.replaceAtUsages(replacement);
             }
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -187,7 +187,7 @@
      */
     @Test
     public void test8() throws Exception {
-        test2("testUnsafeLoad", wr, new Long(32), null);
+        test2("testUnsafeLoad", wr, new Long(useCompressedOops() ? 20 : 32), null);
     }
 
     /**
@@ -207,7 +207,7 @@
      */
     @Test
     public void test9() throws Exception {
-        test2("testUnsafeLoad", wr, new Long(16), new Integer(16));
+        test2("testUnsafeLoad", wr, new Long(useCompressedOops() ? 10 : 16), new Integer(useCompressedOops() ? 10 : 16));
     }
 
     static Object[] src = new Object[1];
@@ -296,6 +296,6 @@
 
     private void test2(final String snippet, Object a, Object b, Object c) throws Exception {
         HotSpotInstalledCode code = getInstalledCode(snippet);
-        code.execute(a, b, c);
+        code.executeVarargs(a, b, c);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.hotspot;
 
-import static com.oracle.graal.graph.UnsafeAccess.*;
 import static java.lang.Thread.*;
 
 import java.io.*;
@@ -32,9 +31,6 @@
 import java.util.*;
 import java.util.concurrent.*;
 
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.sun.management.ThreadMXBean;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,11 +55,9 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.tiers.*;
 
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import edu.umd.cs.findbugs.annotations.*;
 
-public class CompilationTask implements Runnable, Comparable {
-
-    private static final long TIMESTAMP_START = System.currentTimeMillis();
+public class CompilationTask implements Runnable, Comparable<Object> {
 
     // Keep static finals in a group with withinEnqueue as the last one. CompilationTask can be
     // called from within it's own clinit so it needs to be careful about accessing state. Once
@@ -372,18 +370,18 @@
         }
         HotSpotVMConfig config = backend.getRuntime().getConfig();
         int compLevel = config.compilationLevelFullOptimization;
-        char compLevelChar;
+        String compLevelString;
         if (config.tieredCompilation) {
-            compLevelChar = '-';
+            compLevelString = "- ";
             if (compLevel != -1) {
-                compLevelChar = (char) ('0' + compLevel);
+                compLevelString = (char) ('0' + compLevel) + " ";
             }
         } else {
-            compLevelChar = ' ';
+            compLevelString = "";
         }
         boolean hasExceptionHandlers = method.getExceptionHandlers().length > 0;
-        TTY.println(String.format("%s%7d %4d %c%c%c%c%c%c      %s %s(%d bytes)", compilerName, (System.currentTimeMillis() - TIMESTAMP_START), id, isOSR ? '%' : ' ',
-                        Modifier.isSynchronized(mod) ? 's' : ' ', hasExceptionHandlers ? '!' : ' ', blocking ? 'b' : ' ', Modifier.isNative(mod) ? 'n' : ' ', compLevelChar,
+        TTY.println(String.format("%s%7d %4d %c%c%c%c%c %s      %s %s(%d bytes)", compilerName, backend.getRuntime().compilerToVm.getTimeStamp(), id, isOSR ? '%' : ' ',
+                        Modifier.isSynchronized(mod) ? 's' : ' ', hasExceptionHandlers ? '!' : ' ', blocking ? 'b' : ' ', Modifier.isNative(mod) ? 'n' : ' ', compLevelString,
                         MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + " " : "", method.getCodeSize()));
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java	Wed Apr 16 14:02:52 2014 +0200
@@ -311,7 +311,7 @@
         }
 
         println();
-        TTY.println("CompileTheWorld : Done (%d classes, %d methods, %d ms)", classFileCounter, compiledMethodsCounter, compileTime);
+        println("CompileTheWorld : Done (%d classes, %d methods, %d ms)", classFileCounter, compiledMethodsCounter, compileTime);
     }
 
     class CTWCompilationTask extends CompilationTask {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerObject.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerObject.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,7 +24,7 @@
 
 import java.io.*;
 
-import com.oracle.graal.api.meta.Kind.*;
+import com.oracle.graal.api.meta.Kind.FormatWithToString;
 
 /**
  * Parent class for all HotSpot types that need to be serialized.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.stack.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.hotspot.meta.*;
@@ -44,9 +45,9 @@
 public abstract class HotSpotBackend extends Backend {
 
     /**
-     * Descriptor for SharedRuntime::deopt_blob()-&gt;uncommon_trap().
+     * Descriptor for {@link DeoptimizationStub}.
      */
-    public static final ForeignCallDescriptor UNCOMMON_TRAP = new ForeignCallDescriptor("deoptimize", void.class);
+    public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
 
     /**
      * Descriptor for {@link ExceptionHandlerStub}. This stub is called by the
@@ -96,7 +97,7 @@
 
     /**
      * Finds all the registers that are defined by some given LIR.
-     * 
+     *
      * @param lir the LIR to examine
      * @return the registers that are defined by or used as temps for any instruction in {@code lir}
      */
@@ -134,7 +135,7 @@
      * {@linkplain SaveRegistersOp#remove(Set) removed} as these registers are declared as
      * temporaries in the stub's {@linkplain ForeignCallLinkage linkage} (and thus will be saved by
      * the stub's caller).
-     * 
+     *
      * @param stub the stub to update
      * @param destroyedRegisters the registers destroyed by the stub
      * @param calleeSaveInfo a map from debug infos to the operations that provide their
@@ -158,6 +159,11 @@
     }
 
     @Override
+    public StackIntrospection getStackIntrospection() {
+        return runtime;
+    }
+
+    @Override
     public HotSpotProviders getProviders() {
         return (HotSpotProviders) super.getProviders();
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,11 +22,14 @@
  */
 package com.oracle.graal.hotspot;
 
+import static com.oracle.graal.hotspot.HotSpotBackend.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CompilationResult.Call;
 import com.oracle.graal.api.code.CompilationResult.DataPatch;
 import com.oracle.graal.api.code.CompilationResult.Infopoint;
 import com.oracle.graal.hotspot.data.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
 
 /**
@@ -40,8 +43,8 @@
 
     public HotSpotCompiledRuntimeStub(TargetDescription target, Stub stub, CompilationResult compResult) {
         super(target, compResult);
+        this.stubName = stub.toString();
         assert checkStubInvariants(compResult);
-        this.stubName = stub.toString();
     }
 
     /**
@@ -50,6 +53,15 @@
     private boolean checkStubInvariants(CompilationResult compResult) {
         assert compResult.getExceptionHandlers().isEmpty();
         for (DataPatch data : compResult.getDataReferences()) {
+            if (data.data instanceof MetaspaceData) {
+                MetaspaceData meta = (MetaspaceData) data.data;
+                if (meta.annotation instanceof HotSpotResolvedObjectType && ((HotSpotResolvedObjectType) meta.annotation).getName().equals("[I")) {
+                    // special handling for NewArrayStub
+                    // embedding the type '[I' is safe, since it is never unloaded
+                    continue;
+                }
+            }
+
             assert !(data.data instanceof PatchedData) : this + " cannot have embedded object or metadata constant: " + data.data;
         }
         for (Infopoint infopoint : compResult.getInfopoints()) {
@@ -57,8 +69,13 @@
             Call call = (Call) infopoint;
             assert call.target instanceof HotSpotForeignCallLinkage : this + " cannot have non runtime call: " + call.target;
             HotSpotForeignCallLinkage linkage = (HotSpotForeignCallLinkage) call.target;
-            assert !linkage.isCompiledStub() : this + " cannot call compiled stub " + linkage;
+            assert !linkage.isCompiledStub() || linkage.getDescriptor() == UNCOMMON_TRAP_HANDLER : this + " cannot call compiled stub " + linkage;
         }
         return true;
     }
+
+    @Override
+    public String toString() {
+        return stubName != null ? stubName : super.toString();
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java	Wed Apr 16 14:02:52 2014 +0200
@@ -58,6 +58,7 @@
     public enum Transition {
         LEAF_NOFP,
         LEAF,
+        LEAF_SP,
         NOT_LEAF;
     }
 
@@ -110,7 +111,7 @@
 
     /**
      * Creates a {@link HotSpotForeignCallLinkage}.
-     * 
+     *
      * @param descriptor the descriptor of the call
      * @param address the address of the code to call
      * @param effect specifies if the call destroys or preserves all registers (apart from
@@ -150,7 +151,7 @@
         return regConfig.getCallingConvention(ccType, returnType, parameterTypes, target, false);
     }
 
-    private static JavaType asJavaType(Class type, MetaAccessProvider metaAccess, CodeCacheProvider codeCache) {
+    private static JavaType asJavaType(Class<?> type, MetaAccessProvider metaAccess, CodeCacheProvider codeCache) {
         if (WordBase.class.isAssignableFrom(type)) {
             return metaAccess.lookupJavaType(codeCache.getTarget().wordKind.toJavaClass());
         } else {
@@ -264,4 +265,8 @@
     public boolean mayContainFP() {
         return transition != Transition.LEAF_NOFP;
     }
+
+    public boolean needsJavaFrameAnchor() {
+        return canDeoptimize() || transition == Transition.LEAF_SP;
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,9 @@
 import sun.reflect.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.stack.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.graph.*;
@@ -48,7 +50,7 @@
 /**
  * Singleton class holding the instance of the {@link GraalRuntime}.
  */
-public final class HotSpotGraalRuntime implements GraalRuntime, RuntimeProvider {
+public final class HotSpotGraalRuntime implements GraalRuntime, RuntimeProvider, StackIntrospection {
 
     private static final HotSpotGraalRuntime instance = new HotSpotGraalRuntime();
     static {
@@ -62,7 +64,7 @@
     public static HotSpotGraalRuntime runtime() {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            Class cc = Reflection.getCallerClass();
+            Class<?> cc = Reflection.getCallerClass();
             if (cc != null && cc.getClassLoader() != null) {
                 sm.checkPermission(Graal.ACCESS_PERMISSION);
             }
@@ -153,7 +155,7 @@
      * Checks that a factory overriding is valid. A factory B can only override/replace a factory A
      * if the B.getClass() is a subclass of A.getClass(). This models the assumption that B is
      * extends the behavior of A and has therefore understood the behavior expected of A.
-     * 
+     *
      * @param baseFactory
      * @param overridingFactory
      */
@@ -265,15 +267,13 @@
 
     /**
      * Gets the Graal mirror for a {@link Class} object.
-     * 
+     *
      * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass}
      */
     public ResolvedJavaType fromClass(Class<?> javaClass) {
         return graalMirrors.get(javaClass);
     }
 
-    public static final String GRAAL_GPU_ISALIST_PROPERTY_NAME = "graal.gpu.isalist";
-
     /**
      * Gets the names of the supported GPU architectures for the purpose of finding the
      * corresponding {@linkplain HotSpotBackendFactory backend} objects.
@@ -320,7 +320,7 @@
 
     /**
      * Converts a name to a Java type.
-     * 
+     *
      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
      * @param accessingType the context of resolution (may be null)
      * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will
@@ -364,6 +364,10 @@
     public <T> T getCapability(Class<T> clazz) {
         if (clazz == RuntimeProvider.class) {
             return (T) this;
+        } else if (clazz == StackIntrospection.class) {
+            return (T) this;
+        } else if (clazz == SnippetReflectionProvider.class) {
+            return (T) getHostProviders().getSnippetReflection();
         }
         return null;
     }
@@ -383,7 +387,7 @@
 
     /**
      * The offset from the origin of an array to the first element.
-     * 
+     *
      * @return the offset in bytes
      */
     public static int getArrayBaseOffset(Kind kind) {
@@ -413,7 +417,7 @@
 
     /**
      * The scale used for the index when accessing elements of an array of this kind.
-     * 
+     *
      * @return the scale in order to convert the index into a byte offset
      */
     public static int getArrayIndexScale(Kind kind) {
@@ -440,4 +444,50 @@
                 throw GraalInternalError.shouldNotReachHere();
         }
     }
+
+    public Iterable<InspectedFrame> getStackTrace(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip) {
+        final long[] initialMetaMethods = toMeta(initialMethods);
+        final long[] matchingMetaMethods = toMeta(matchingMethods);
+        class StackFrameIterator implements Iterator<InspectedFrame> {
+
+            private HotSpotStackFrameReference current = compilerToVm.getNextStackFrame(null, initialMetaMethods, initialSkip);
+            // we don't want to read ahead if hasNext isn't called
+            private boolean advanced = true;
+
+            public boolean hasNext() {
+                update();
+                return current != null;
+            }
+
+            public InspectedFrame next() {
+                update();
+                advanced = false;
+                return current;
+            }
+
+            private void update() {
+                if (!advanced) {
+                    current = compilerToVm.getNextStackFrame(current, matchingMetaMethods, 0);
+                    advanced = true;
+                }
+            }
+        }
+        return new Iterable<InspectedFrame>() {
+            public Iterator<InspectedFrame> iterator() {
+                return new StackFrameIterator();
+            }
+        };
+    }
+
+    private static long[] toMeta(ResolvedJavaMethod[] methods) {
+        if (methods == null) {
+            return null;
+        } else {
+            long[] result = new long[methods.length];
+            for (int i = 0; i < result.length; i++) {
+                result[i] = ((HotSpotResolvedJavaMethod) methods[i]).getMetaspaceMethod();
+            }
+            return result;
+        }
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,26 +25,41 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
-import com.oracle.graal.hotspot.HotSpotVMConfig.*;
+import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 import com.oracle.graal.nodes.spi.*;
 
 /**
  * This interface defines the contract a HotSpot backend LIR generator needs to fulfill in addition
- * to abstract methods from {@link LIRGenerator} and {@link NodeLIRBuilderTool}.
+ * to abstract methods from {@link LIRGenerator} and {@link LIRGeneratorTool}.
  */
-public interface HotSpotLIRGenerator {
+public interface HotSpotLIRGenerator extends LIRGeneratorTool {
 
     /**
      * Emits an operation to make a tail call.
-     * 
+     *
      * @param args the arguments of the call
      * @param address the target address of the call
      */
     void emitTailcall(Value[] args, Value address);
 
+    void emitLeaveCurrentStackFrame();
+
+    void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo);
+
+    void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp);
+
+    void emitLeaveUnpackFramesStackFrame();
+
+    SaveRegistersOp emitSaveAllRegisters();
+
     void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason);
 
+    void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo);
+
+    Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp);
+
     /**
      * Gets a stack slot for a lock at a given lock nesting depth.
      */
@@ -52,7 +67,7 @@
 
     HotSpotProviders getProviders();
 
-    Value emitCompress(Value pointer, CompressEncoding encoding);
+    Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 
-    Value emitUncompress(Value pointer, CompressEncoding encoding);
+    Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -217,7 +217,7 @@
      * @param c the class in which the field is declared
      * @param name the name of the field
      */
-    private static void unconditionallyEnableTimerOrMetric(Class c, String name) {
+    private static void unconditionallyEnableTimerOrMetric(Class<?> c, String name) {
         try {
             Field field = c.getDeclaredField(name);
             String propertyName;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,6 +26,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
@@ -41,8 +42,8 @@
 
     private final HotSpotVMConfig config;
 
-    public HotSpotReplacementsImpl(Providers providers, HotSpotVMConfig config, Assumptions assumptions, TargetDescription target) {
-        super(providers, assumptions, target);
+    public HotSpotReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, HotSpotVMConfig config, Assumptions assumptions, TargetDescription target) {
+        super(providers, snippetReflection, assumptions, target);
         this.config = config;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotStackFrameReference.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.stack.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.*;
+
+public class HotSpotStackFrameReference implements InspectedFrame {
+
+    private CompilerToVM compilerToVM;
+
+    // information used to find the stack frame
+    private long stackPointer;
+    private int frameNumber;
+
+    // information about the stack frame's contents
+    private int bci;
+    private long metaspaceMethod;
+    private Object[] locals;
+    private boolean[] localIsVirtual;
+
+    public long getStackPointer() {
+        return stackPointer;
+    }
+
+    public int getFrameNumber() {
+        return frameNumber;
+    }
+
+    public Object getLocal(int index) {
+        return locals[index];
+    }
+
+    public boolean isVirtual(int index) {
+        return localIsVirtual == null ? false : localIsVirtual[index];
+    }
+
+    public void materializeVirtualObjects(boolean invalidateCode) {
+        compilerToVM.materializeVirtualObjects(this, invalidateCode);
+    }
+
+    public int getBytecodeIndex() {
+        return bci;
+    }
+
+    public ResolvedJavaMethod getMethod() {
+        return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
+    }
+
+    public boolean hasVirtualObjects() {
+        return localIsVirtual != null;
+    }
+
+    @Override
+    public String toString() {
+        return "HotSpotStackFrameReference [stackPointer=" + stackPointer + ", frameNumber=" + frameNumber + ", bci=" + bci + ", method=" + getMethod() + ", locals=" + Arrays.toString(locals) +
+                        ", localIsVirtual=" + Arrays.toString(localIsVirtual) + "]";
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -59,6 +59,11 @@
         return false;
     }
 
+    /**
+     * Maximum allowed size of allocated area for a frame.
+     */
+    public final int maxFrameSize = 16 * 1024;
+
     HotSpotVMConfig(CompilerToVM compilerToVm) {
         /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */
         gHotSpotVMStructs = 0;
@@ -611,10 +616,9 @@
             nameOffset = vmStructs.get("Flag::_name").getOffset();
             addrOffset = vmStructs.get("Flag::_addr").getOffset();
 
-            // TODO use the following after we switched to JDK 8
-            assert vmTypes.get("bool").getSize() == Byte.SIZE / Byte.SIZE; // TODO Byte.BYTES;
-            assert vmTypes.get("intx").getSize() == Long.SIZE / Byte.SIZE; // TODO Long.BYTES;
-            assert vmTypes.get("uintx").getSize() == Long.SIZE / Byte.SIZE; // TODO Long.BYTES;
+            assert vmTypes.get("bool").getSize() == Byte.BYTES;
+            assert vmTypes.get("intx").getSize() == Long.BYTES;
+            assert vmTypes.get("uintx").getSize() == Long.BYTES;
         }
 
         public Iterator<Flags.Flag> iterator() {
@@ -853,6 +857,7 @@
     @HotSpotVMField(name = "Array<Klass*>::_length", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayLengthOffset;
     @HotSpotVMField(name = "Array<Klass*>::_data[0]", type = "Klass*", get = HotSpotVMField.Type.OFFSET) @Stable public int metaspaceArrayBaseOffset;
 
+    @HotSpotVMField(name = "InstanceKlass::_graal_node_class", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNodeClassOffset;
     @HotSpotVMField(name = "InstanceKlass::_source_file_name_index", type = "u2", get = HotSpotVMField.Type.OFFSET) @Stable public int klassSourceFileNameIndexOffset;
     @HotSpotVMField(name = "InstanceKlass::_init_state", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int klassStateOffset;
     @HotSpotVMField(name = "InstanceKlass::_constants", type = "ConstantPool*", get = HotSpotVMField.Type.OFFSET) @Stable public int instanceKlassConstantsOffset;
@@ -957,7 +962,10 @@
         return javaThreadAnchorOffset + javaFrameAnchorFlagsOffset;
     }
 
+    // These are only valid on AMD64.
     @HotSpotVMConstant(name = "frame::arg_reg_save_area_bytes", archs = {"amd64"}) @Stable public int runtimeCallStackSize;
+    @HotSpotVMConstant(name = "frame::interpreter_frame_sender_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameSenderSpOffset;
+    @HotSpotVMConstant(name = "frame::interpreter_frame_last_sp_offset", archs = {"amd64"}) @Stable public int frameInterpreterFrameLastSpOffset;
 
     @HotSpotVMField(name = "PtrQueue::_active", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueActiveOffset;
     @HotSpotVMField(name = "PtrQueue::_buf", type = "void**", get = HotSpotVMField.Type.OFFSET) @Stable public int ptrQueueBufferOffset;
@@ -1004,15 +1012,18 @@
     @HotSpotVMField(name = "ThreadShadow::_pending_deoptimization", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingDeoptimizationOffset;
     @HotSpotVMField(name = "ThreadShadow::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset;
 
+    @HotSpotVMFlag(name = "UseHSAILDeoptimization") @Stable public boolean useHSAILDeoptimization;
+
     /**
      * Offsets of Hsail deoptimization fields (defined in gpu_hsail.hpp). Used to propagate
      * exceptions from Hsail back to C++ runtime.
      */
     @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_deopt_save_states[0]", type = "Hsail::HSAILKernelDeoptimization", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailSaveStatesOffset0;
     @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_deopt_save_states[1]", type = "Hsail::HSAILKernelDeoptimization", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailSaveStatesOffset1;
-    @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_deopt_occurred", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDeoptOffset;
+    @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_deopt_occurred", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDeoptOccurredOffset;
     @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_never_ran_array", type = "jboolean *", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailNeverRanArrayOffset;
     @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_deopt_next_index", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDeoptNextIndexOffset;
+    @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_donor_threads", type = "JavaThread**", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDonorThreadsOffset;
 
     @HotSpotVMField(name = "Hsail::HSAILKernelDeoptimization::_workitemid", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDeoptimizationWorkItem;
     @HotSpotVMField(name = "Hsail::HSAILKernelDeoptimization::_actionAndReason", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailDeoptimizationReason;
@@ -1048,6 +1059,7 @@
     @HotSpotVMConstant(name = "Method::_force_inline") @Stable public int methodFlagsForceInline;
     @HotSpotVMConstant(name = "Method::_dont_inline") @Stable public int methodFlagsDontInline;
     @HotSpotVMConstant(name = "Method::_hidden") @Stable public int methodFlagsHidden;
+    @HotSpotVMConstant(name = "Method::nonvirtual_vtable_index") @Stable public int nonvirtualVtableIndex;
 
     @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch;
     @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes;
@@ -1107,6 +1119,7 @@
     @HotSpotVMConstant(name = "JVM_CONSTANT_MethodHandleInError") @Stable public int jvmConstantMethodHandleInError;
     @HotSpotVMConstant(name = "JVM_CONSTANT_MethodType") @Stable public int jvmConstantMethodType;
     @HotSpotVMConstant(name = "JVM_CONSTANT_MethodTypeInError") @Stable public int jvmConstantMethodTypeInError;
+    @HotSpotVMConstant(name = "JVM_CONSTANT_InvokeDynamic") @Stable public int jvmConstantInvokeDynamic;
 
     @HotSpotVMConstant(name = "HeapWordSize") @Stable public int heapWordSize;
 
@@ -1237,6 +1250,7 @@
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferStartOffset;
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferEndOffset;
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferTopOffset;
+    @HotSpotVMField(name = "ThreadLocalAllocBuffer::_pf_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferPfTopOffset;
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_slow_allocations", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferSlowAllocationsOffset;
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_fast_refill_waste", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferFastRefillWasteOffset;
     @HotSpotVMField(name = "ThreadLocalAllocBuffer::_number_of_refills", type = "unsigned", get = HotSpotVMField.Type.OFFSET) @Stable private int threadLocalAllocBufferNumberOfRefillsOffset;
@@ -1275,6 +1289,10 @@
         return threadTlabOffset + threadLocalAllocBufferTopOffset;
     }
 
+    public int threadTlabPfTopOffset() {
+        return threadTlabOffset + threadLocalAllocBufferPfTopOffset;
+    }
+
     @HotSpotVMFlag(name = "TLABStats") @Stable public boolean tlabStats;
     @Stable public boolean inlineContiguousAllocationSupported;
 
@@ -1333,7 +1351,6 @@
     }
 
     @Stable public long handleDeoptStub;
-    @Stable public long uncommonTrapStub;
 
     @HotSpotVMField(name = "StubRoutines::_aescrypt_encryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptEncryptBlockStub;
     @HotSpotVMField(name = "StubRoutines::_aescrypt_decryptBlock", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long aescryptDecryptBlockStub;
@@ -1403,6 +1420,10 @@
 
     @Stable public int graalCountersSize;
 
+    @Stable public long deoptimizationFetchUnrollInfo;
+    @Stable public long deoptimizationUncommonTrap;
+    @Stable public long deoptimizationUnpackFrames;
+
     @HotSpotVMConstant(name = "Deoptimization::Reason_none") @Stable public int deoptReasonNone;
     @HotSpotVMConstant(name = "Deoptimization::Reason_null_check") @Stable public int deoptReasonNullCheck;
     @HotSpotVMConstant(name = "Deoptimization::Reason_range_check") @Stable public int deoptReasonRangeCheck;
@@ -1433,6 +1454,19 @@
     @HotSpotVMConstant(name = "Deoptimization::_reason_shift") @Stable public int deoptimizationReasonShift;
     @HotSpotVMConstant(name = "Deoptimization::_debug_id_shift") @Stable public int deoptimizationDebugIdShift;
 
+    @HotSpotVMConstant(name = "Deoptimization::Unpack_deopt") @Stable public int deoptimizationUnpackDeopt;
+    @HotSpotVMConstant(name = "Deoptimization::Unpack_exception") @Stable public int deoptimizationUnpackException;
+    @HotSpotVMConstant(name = "Deoptimization::Unpack_uncommon_trap") @Stable public int deoptimizationUnpackUncommonTrap;
+    @HotSpotVMConstant(name = "Deoptimization::Unpack_reexecute") @Stable public int deoptimizationUnpackReexecute;
+
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_size_of_deoptimized_frame", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_caller_adjustment", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockCallerAdjustmentOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_number_of_frames", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockNumberOfFramesOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_total_frame_sizes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockTotalFrameSizesOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_sizes", type = "intptr_t*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFrameSizesOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_frame_pcs", type = "address*", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockFramePcsOffset;
+    @HotSpotVMField(name = "Deoptimization::UnrollBlock::_initial_info", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int deoptimizationUnrollBlockInitialInfoOffset;
+
     @HotSpotVMConstant(name = "vmIntrinsics::_invokeBasic") @Stable public int vmIntrinsicInvokeBasic;
     @HotSpotVMConstant(name = "vmIntrinsics::_linkToVirtual") @Stable public int vmIntrinsicLinkToVirtual;
     @HotSpotVMConstant(name = "vmIntrinsics::_linkToStatic") @Stable public int vmIntrinsicLinkToStatic;
@@ -1492,6 +1526,22 @@
             this.alignment = alignment;
         }
 
+        public int compress(long ptr) {
+            if (ptr == 0L) {
+                return 0;
+            } else {
+                return (int) ((ptr - base) >>> shift);
+            }
+        }
+
+        public long uncompress(int ptr) {
+            if (ptr == 0) {
+                return 0L;
+            } else {
+                return ((ptr & 0xFFFFFFFFL) << shift) + base;
+            }
+        }
+
         @Override
         public String toString() {
             return "base: " + base + " shift: " + shift + " alignment: " + alignment;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 
     /**
      * Copies the original bytecode of a given method into a given byte array.
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object
      * @param code the array into which to copy the original bytecode
      * @return the value of {@code code}
@@ -49,7 +49,7 @@
 
     /**
      * Determines if a given metaspace Method object has balanced monitors.
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object to query
      * @return true if the method has balanced monitors
      */
@@ -63,7 +63,7 @@
      * <li>the method may have a bytecode breakpoint set</li>
      * <li>the method may have other bytecode features that require special handling by the VM</li>
      * </ul>
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object to query
      * @return true if the method can be inlined
      */
@@ -75,7 +75,7 @@
      * <li>a CompileOracle directive may forces inlining of this methods</li>
      * <li>an annotation forces inlining of this method</li>
      * </ul>
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object to query
      * @return true if the method should be inlined
      */
@@ -83,7 +83,7 @@
 
     /**
      * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}.
-     * 
+     *
      * @param metaspaceMethod the metaspace Method on which to based the search
      * @return the metaspace Method result or 0 is there is no unique concrete method for
      *         {@code metaspaceMethod}
@@ -92,7 +92,7 @@
 
     /**
      * Returns the implementor for the given interface class.
-     * 
+     *
      * @param metaspaceKlass the metaspace klass to get the implementor for
      * @return the implementor as metaspace klass pointer or null if there is no implementor
      */
@@ -100,7 +100,7 @@
 
     /**
      * Determines if a given metaspace method is ignored by security stack walks.
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object
      * @return true if the method is ignored
      */
@@ -108,7 +108,7 @@
 
     /**
      * Converts a name to a metaspace klass.
-     * 
+     *
      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
      * @param accessingClass the context of resolution (may be null)
      * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will
@@ -134,7 +134,7 @@
 
     /**
      * Looks up a class entry in a constant pool.
-     * 
+     *
      * @param metaspaceConstantPool metaspace constant pool pointer
      * @param cpi constant pool index
      * @return a metaspace Klass for a resolved method entry, a metaspace Symbol otherwise (with
@@ -144,7 +144,7 @@
 
     /**
      * Looks up a method entry in a constant pool.
-     * 
+     *
      * @param metaspaceConstantPool metaspace constant pool pointer
      * @param cpi constant pool index
      * @return a metaspace Method for a resolved method entry, 0 otherwise
@@ -154,12 +154,12 @@
     /**
      * Looks up a field entry in a constant pool and attempts to resolve it. The values returned in
      * {@code info} are:
-     * 
+     *
      * <pre>
      *     [(int) flags,   // only valid if field is resolved
      *      (int) offset]  // only valid if field is resolved
      * </pre>
-     * 
+     *
      * @param metaspaceConstantPool metaspace constant pool pointer
      * @param cpi constant pool index
      * @param info an array in which the details of the field are returned
@@ -221,7 +221,7 @@
 
     /**
      * Installs the result of a compilation into the code cache.
-     * 
+     *
      * @param compiledCode the result of a compilation
      * @param code the details of the installed CodeBlob are written to this object
      * @return the outcome of the installation as a {@link CodeInstallResult}.
@@ -230,7 +230,7 @@
 
     /**
      * Notifies the VM of statistics for a completed compilation.
-     * 
+     *
      * @param id the identifier of the compilation
      * @param method the method compiled
      * @param osr specifies if the compilation was for on-stack-replacement
@@ -257,7 +257,7 @@
     /**
      * Gets the metaspace Method object corresponding to a given {@link Class} object and slot
      * number.
-     * 
+     *
      * @param holder method holder
      * @param slot slot number of the method
      * @return the metaspace Method
@@ -282,7 +282,7 @@
 
     String getFileName(HotSpotResolvedJavaType method);
 
-    Object readUnsafeUncompressedPointer(Object o, long displacement);
+    Class<?> getJavaMirror(long metaspaceKlass);
 
     long readUnsafeKlassPointer(Object o);
 
@@ -290,7 +290,7 @@
 
     /**
      * Invalidates the profiling information and restarts profiling upon the next invocation.
-     * 
+     *
      * @param metaspaceMethod the metaspace Method object
      */
     void reprofile(long metaspaceMethod);
@@ -311,17 +311,44 @@
 
     /**
      * Gets the names of the supported GPU architectures.
-     * 
+     *
      * @return a comma separated list of names
      */
     String getGPUs();
 
     /**
-     * 
+     *
      * @param metaspaceMethod the method to check
      * @param entryBCI
      * @param level the compilation level
      * @return true if the {@code metaspaceMethod} has code for {@code level}
      */
     boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level);
+
+    /**
+     * Fetch the time stamp used for printing inside hotspot. It's relative to VM start to that all
+     * events can be ordered.
+     *
+     * @return milliseconds since VM start
+     */
+    long getTimeStamp();
+
+    /**
+     * Looks for the next Java stack frame with the given method.
+     *
+     * @param frame the starting point of the search, where {@code null} refers to the topmost frame
+     * @param methods the metaspace methods to look for, where {@code null} means that any frame is
+     *            returned
+     * @return the frame, or {@code null} if the end of the stack was reached during the search
+     */
+    HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip);
+
+    /**
+     * Materialized all virtual objects within the given stack frame and update the locals within
+     * the given stackFrame object.
+     *
+     * @param invalidate if {@code true}, the compiled method for the stack frame will be
+     *            invalidated.
+     */
+    void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -141,7 +141,7 @@
     public native void invalidateInstalledCode(HotSpotInstalledCode hotspotInstalledCode);
 
     @Override
-    public native Object readUnsafeUncompressedPointer(Object o, long displacement);
+    public native Class<?> getJavaMirror(long metaspaceKlass);
 
     @Override
     public native long readUnsafeKlassPointer(Object o);
@@ -151,7 +151,7 @@
 
     @Override
     public Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException {
-        return executeCompiledMethodIntrinsic(arg1, arg2, arg3, hotspotInstalledCode);
+        return executeCompiledMethodVarargs(new Object[]{arg1, arg2, arg3}, hotspotInstalledCode);
     }
 
     public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond,
@@ -161,15 +161,6 @@
 
     public native void resetCompilationStatistics();
 
-    /**
-     * Direct call to the given nmethod with three object arguments and an object return value. This
-     * method does not have an implementation on the C++ side, but its entry points (from
-     * interpreter and from compiled code) are directly pointing to a manually generated assembly
-     * stub that does the necessary argument shuffling and a tail call via an indirect jump to the
-     * verified entry point of the given native method.
-     */
-    public static native Object executeCompiledMethodIntrinsic(Object arg1, Object arg2, Object arg3, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException;
-
     public native long[] collectCounters();
 
     public native boolean isMature(long method);
@@ -184,4 +175,9 @@
 
     public native boolean hasCompiledCodeForOSR(long metaspaceMethod, int entryBCI, int level);
 
+    public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, long[] methods, int initialSkip);
+
+    public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
+
+    public native long getTimeStamp();
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/FastNodeClassRegistry.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +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.hotspot.bridge;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.meta.*;
-
-/**
- * A fast-path for {@link NodeClass} retrieval using {@link HotSpotResolvedObjectType}.
- */
-class FastNodeClassRegistry extends NodeClass.Registry {
-
-    @SuppressWarnings("unused")
-    static void initialize() {
-        new FastNodeClassRegistry();
-    }
-
-    private static HotSpotResolvedObjectType type(Class<? extends Node> key) {
-        return (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(key);
-    }
-
-    @Override
-    public NodeClass get(Class<? extends Node> key) {
-        return type(key).getNodeClass();
-    }
-
-    @Override
-    protected void registered(Class<? extends Node> key, NodeClass value) {
-        type(key).setNodeClass(value);
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -144,8 +144,6 @@
 
     public void startCompiler(boolean bootstrapEnabled) throws Throwable {
 
-        FastNodeClassRegistry.initialize();
-
         bootstrapRunning = bootstrapEnabled;
 
         if (LogFile.getValue() != null) {
@@ -250,7 +248,7 @@
 
     /**
      * Take action related to entering a new execution phase.
-     * 
+     *
      * @param phase the execution phase being entered
      */
     protected void phaseTransition(String phase) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -79,7 +79,7 @@
         return interf.cast(obj);
     }
 
-    private static ArrayList<CountingProxy> proxies = new ArrayList<>();
+    private static ArrayList<CountingProxy<?>> proxies = new ArrayList<>();
 
     static {
         if (ENABLED) {
@@ -87,7 +87,7 @@
 
                 @Override
                 public void run() {
-                    for (CountingProxy proxy : proxies) {
+                    for (CountingProxy<?> proxy : proxies) {
                         proxy.print();
                     }
                 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -251,14 +251,16 @@
     }
 
     public boolean needsDataPatch(Constant constant) {
-        return constant.getPrimitiveAnnotation() != null;
+        return constant instanceof HotSpotMetaspaceConstant;
     }
 
     public Data createDataItem(Constant constant, int alignment) {
-        if (constant.getPrimitiveAnnotation() != null) {
-            return new MetaspaceData(alignment, constant.asLong(), constant.getPrimitiveAnnotation(), false);
+        if (constant instanceof HotSpotMetaspaceConstant) {
+            // constant.getKind() == target.wordKind for uncompressed pointers
+            // otherwise, it's a compressed pointer
+            return new MetaspaceData(alignment, constant.asLong(), HotSpotMetaspaceConstant.getMetaspaceObject(constant), constant.getKind() != target.wordKind);
         } else if (constant.getKind().isObject()) {
-            return new OopData(alignment, constant.asObject(), false);
+            return new OopData(alignment, HotSpotObjectConstant.asObject(constant), false);
         } else {
             return new PrimitiveData(constant, alignment);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -61,7 +61,8 @@
         MethodHandle(config().jvmConstantMethodHandle),
         MethodHandleInError(config().jvmConstantMethodHandleInError),
         MethodType(config().jvmConstantMethodType),
-        MethodTypeInError(config().jvmConstantMethodTypeInError);
+        MethodTypeInError(config().jvmConstantMethodTypeInError),
+        InvokeDynamic(config().jvmConstantInvokeDynamic);
         // @formatter:on
 
         private final int value;
@@ -95,7 +96,7 @@
 
     /**
      * Gets the holder for this constant pool as {@link HotSpotResolvedObjectType}.
-     * 
+     *
      * @return holder for this constant pool
      */
     private HotSpotResolvedObjectType getHolder() {
@@ -106,7 +107,7 @@
     /**
      * Converts a raw index from the bytecodes to a constant pool index by adding a
      * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
-     * 
+     *
      * @param rawIndex index from the bytecode
      * @param opcode bytecode to convert the index for
      * @return constant pool index
@@ -126,8 +127,39 @@
     }
 
     /**
+     * Decode a constant pool cache index to a constant pool index.
+     *
+     * See {@code ConstantPool::decode_cpcache_index}.
+     *
+     * @param index constant pool cache index
+     * @return decoded index
+     */
+    private static int decodeConstantPoolCacheIndex(int index) {
+        if (isInvokedynamicIndex(index)) {
+            return decodeInvokedynamicIndex(index);
+        } else {
+            return index - runtime().getConfig().constantPoolCpCacheIndexTag;
+        }
+    }
+
+    /**
+     * See {@code ConstantPool::is_invokedynamic_index}.
+     */
+    private static boolean isInvokedynamicIndex(int index) {
+        return index < 0;
+    }
+
+    /**
+     * See {@code ConstantPool::decode_invokedynamic_index}.
+     */
+    private static int decodeInvokedynamicIndex(int i) {
+        assert isInvokedynamicIndex(i) : i;
+        return ~i;
+    }
+
+    /**
      * Gets the constant pool tag at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return constant pool tag
      */
@@ -141,7 +173,7 @@
 
     /**
      * Gets the constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return constant pool entry
      */
@@ -152,7 +184,7 @@
 
     /**
      * Gets the integer constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return integer constant pool entry at index
      */
@@ -163,7 +195,7 @@
 
     /**
      * Gets the long constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return long constant pool entry
      */
@@ -174,7 +206,7 @@
 
     /**
      * Gets the float constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return float constant pool entry
      */
@@ -185,7 +217,7 @@
 
     /**
      * Gets the double constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return float constant pool entry
      */
@@ -196,7 +228,7 @@
 
     /**
      * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return {@code JVM_CONSTANT_NameAndType} constant pool entry
      */
@@ -208,7 +240,7 @@
     /**
      * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index
      * {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry
      */
@@ -219,7 +251,7 @@
     /**
      * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
      * {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return name as {@link String}
      */
@@ -232,7 +264,7 @@
     /**
      * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at
      * index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return name reference index
      */
@@ -245,7 +277,7 @@
     /**
      * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
      * {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return signature as {@link String}
      */
@@ -258,7 +290,7 @@
     /**
      * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry
      * at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return signature reference index
      */
@@ -270,7 +302,7 @@
 
     /**
      * Gets the klass reference index constant pool entry at index {@code index}.
-     * 
+     *
      * @param index constant pool index
      * @return klass reference index
      */
@@ -281,7 +313,7 @@
     /**
      * Gets the uncached klass reference index constant pool entry at index {@code index}. See:
      * {@code ConstantPool::uncached_klass_ref_index_at}.
-     * 
+     *
      * @param index constant pool index
      * @return klass reference index
      */
@@ -294,7 +326,7 @@
 
     /**
      * Asserts that the constant pool index {@code index} is in the bounds of the constant pool.
-     * 
+     *
      * @param index constant pool index
      */
     private void assertBounds(int index) {
@@ -303,7 +335,7 @@
 
     /**
      * Asserts that the constant pool tag at index {@code index} is equal to {@code tag}.
-     * 
+     *
      * @param index constant pool index
      * @param tag expected tag
      */
@@ -336,13 +368,13 @@
                 return lookupType(cpi, opcode);
             case String:
                 Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi);
-                return Constant.forObject(string);
+                return HotSpotObjectConstant.forObject(string);
             case MethodHandle:
             case MethodHandleInError:
             case MethodType:
             case MethodTypeInError:
                 Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi);
-                return Constant.forObject(obj);
+                return HotSpotObjectConstant.forObject(obj);
             default:
                 throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + tag);
         }
@@ -362,16 +394,21 @@
     }
 
     @Override
-    public Object lookupAppendix(int cpi, int opcode) {
+    public Constant lookupAppendix(int cpi, int opcode) {
         assert Bytecodes.isInvoke(opcode);
         final int index = toConstantPoolIndex(cpi, opcode);
-        return runtime().getCompilerToVM().lookupAppendixInPool(metaspaceConstantPool, index);
+        Object result = runtime().getCompilerToVM().lookupAppendixInPool(metaspaceConstantPool, index);
+        if (result == null) {
+            return null;
+        } else {
+            return HotSpotObjectConstant.forObject(result);
+        }
     }
 
     /**
      * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending
      * on the {@link HotSpotVMConfig#compilerToVMKlassTag tag}.
-     * 
+     *
      * @param metaspacePointer either a metaspace Klass or a metaspace Symbol
      */
     private static JavaType getJavaType(final long metaspacePointer) {
@@ -462,6 +499,11 @@
             case Bytecodes.LDC2_W:
                 index = cpi;
                 break;
+            case Bytecodes.INVOKEDYNAMIC:
+                // invokedynamic instructions point to a constant pool cache entry.
+                index = decodeConstantPoolCacheIndex(cpi);
+                index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
+                break;
             default:
                 index = toConstantPoolIndex(cpi, opcode);
                 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,15 +48,34 @@
     }
 
     @Override
-    public Integer lookupArrayLength(Constant array) {
-        if (array.getKind() != Kind.Object || array.isNull() || !array.asObject().getClass().isArray()) {
+    public Integer readArrayLength(Constant array) {
+        if (array.getKind() != Kind.Object || array.isNull() || !HotSpotObjectConstant.asObject(array).getClass().isArray()) {
             return null;
         }
-        return Array.getLength(array.asObject());
+        return Array.getLength(HotSpotObjectConstant.asObject(array));
     }
 
     @Override
-    public Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressible) {
+    public Constant readUnsafeConstant(Kind kind, Constant baseConstant, long initialDisplacement) {
+        Object base;
+        long displacement;
+        if (baseConstant.getKind() == Kind.Object) {
+            base = HotSpotObjectConstant.asObject(baseConstant);
+            displacement = initialDisplacement;
+            if (base == null) {
+                return null;
+            }
+        } else if (baseConstant.getKind().isNumericInteger()) {
+            long baseLong = baseConstant.asLong();
+            if (baseLong == 0L) {
+                return null;
+            }
+            displacement = initialDisplacement + baseLong;
+            base = null;
+        } else {
+            throw GraalInternalError.shouldNotReachHere();
+        }
+
         switch (kind) {
             case Boolean:
                 return Constant.forBoolean(base == null ? unsafe.getByte(displacement) != 0 : unsafe.getBoolean(base, displacement));
@@ -84,15 +103,132 @@
                 return Constant.forDouble(base == null ? unsafe.getDouble(displacement) : unsafe.getDouble(base, displacement));
             case Object: {
                 Object o = null;
-                if (compressible) {
+                if (baseConstant.getKind() == Kind.Object) {
                     o = unsafe.getObject(base, displacement);
+                } else if (baseConstant instanceof HotSpotMetaspaceConstant) {
+                    Object metaspaceObject = HotSpotMetaspaceConstant.getMetaspaceObject(baseConstant);
+                    if (metaspaceObject instanceof HotSpotResolvedObjectType && initialDisplacement == runtime.getConfig().classMirrorOffset) {
+                        o = ((HotSpotResolvedObjectType) metaspaceObject).mirror();
+                    } else {
+                        throw GraalInternalError.shouldNotReachHere();
+                    }
                 } else {
-                    o = runtime.getCompilerToVM().readUnsafeUncompressedPointer(base, displacement);
+                    throw GraalInternalError.shouldNotReachHere();
                 }
-                return Constant.forObject(o);
+                return HotSpotObjectConstant.forObject(o);
             }
             default:
                 throw GraalInternalError.shouldNotReachHere();
         }
     }
+
+    @Override
+    public Constant readRawConstant(Kind kind, Constant baseConstant, long initialDisplacement, int bits) {
+        Object base;
+        long displacement;
+        if (baseConstant.getKind() == Kind.Object) {
+            base = HotSpotObjectConstant.asObject(baseConstant);
+            displacement = initialDisplacement;
+            if (base == null) {
+                return null;
+            }
+        } else if (baseConstant.getKind().isNumericInteger()) {
+            long baseLong = baseConstant.asLong();
+            if (baseLong == 0L) {
+                return null;
+            }
+            displacement = initialDisplacement + baseLong;
+            base = null;
+        } else {
+            throw GraalInternalError.shouldNotReachHere();
+        }
+
+        long rawValue;
+        switch (bits) {
+            case 8:
+                rawValue = base == null ? unsafe.getByte(displacement) : unsafe.getByte(base, displacement);
+                break;
+            case 16:
+                rawValue = base == null ? unsafe.getShort(displacement) : unsafe.getShort(base, displacement);
+                break;
+            case 32:
+                rawValue = base == null ? unsafe.getInt(displacement) : unsafe.getInt(base, displacement);
+                break;
+            case 64:
+                rawValue = base == null ? unsafe.getLong(displacement) : unsafe.getLong(base, displacement);
+                break;
+            default:
+                throw GraalInternalError.shouldNotReachHere();
+        }
+
+        if (base != null && displacement == config().hubOffset) {
+            if (config().useCompressedClassPointers) {
+                assert bits == 32 && kind == Kind.Int;
+                long klassPointer = config().getKlassEncoding().uncompress((int) rawValue);
+                assert klassPointer == runtime.getCompilerToVM().readUnsafeKlassPointer(base);
+                return HotSpotMetaspaceConstant.forMetaspaceObject(kind, rawValue, HotSpotResolvedObjectType.fromMetaspaceKlass(klassPointer));
+            } else {
+                assert bits == 64 && kind == Kind.Long;
+                return HotSpotMetaspaceConstant.forMetaspaceObject(kind, rawValue, HotSpotResolvedObjectType.fromMetaspaceKlass(rawValue));
+            }
+        } else {
+            switch (kind) {
+                case Int:
+                    return Constant.forInt((int) rawValue);
+                case Long:
+                    return Constant.forLong(rawValue);
+                case Float:
+                    return Constant.forFloat(Float.intBitsToFloat((int) rawValue));
+                case Double:
+                    return Constant.forDouble(Double.longBitsToDouble(rawValue));
+                default:
+                    throw GraalInternalError.shouldNotReachHere();
+            }
+        }
+    }
+
+    @Override
+    public Constant readArrayElement(Constant array, int index) {
+        if (array.getKind() != Kind.Object || array.isNull()) {
+            return null;
+        }
+        Object a = HotSpotObjectConstant.asObject(array);
+
+        if (index < 0 || index >= Array.getLength(a)) {
+            return null;
+        }
+
+        if (a instanceof Object[]) {
+            return HotSpotObjectConstant.forObject(((Object[]) a)[index]);
+        } else {
+            return Constant.forBoxedPrimitive(Array.get(a, index));
+        }
+    }
+
+    @Override
+    public Constant boxPrimitive(Constant source) {
+        if (!source.getKind().isPrimitive()) {
+            return null;
+        }
+        return HotSpotObjectConstant.forObject(source.asBoxedPrimitive());
+    }
+
+    @Override
+    public Constant unboxPrimitive(Constant source) {
+        if (!source.getKind().isObject()) {
+            return null;
+        }
+        return Constant.forBoxedPrimitive(HotSpotObjectConstant.asObject(source));
+    }
+
+    @Override
+    public ResolvedJavaType asJavaType(Constant constant) {
+        if (constant.getKind() == Kind.Object) {
+            Object obj = HotSpotObjectConstant.asObject(constant);
+            if (obj instanceof Class) {
+                return runtime.getHostProviders().getMetaAccess().lookupJavaType((Class<?>) obj);
+            }
+        }
+        return null;
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,10 +27,10 @@
 import static com.oracle.graal.hotspot.HotSpotBackend.*;
 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*;
 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*;
-import static com.oracle.graal.hotspot.nodes.MonitorExitStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*;
 import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*;
+import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*;
 import static com.oracle.graal.hotspot.nodes.VMErrorNode.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 import static com.oracle.graal.hotspot.replacements.MonitorSnippets.*;
@@ -38,12 +38,13 @@
 import static com.oracle.graal.hotspot.replacements.SystemSubstitutions.*;
 import static com.oracle.graal.hotspot.replacements.ThreadSubstitutions.*;
 import static com.oracle.graal.hotspot.replacements.WriteBarrierSnippets.*;
+import static com.oracle.graal.hotspot.stubs.DeoptimizationStub.*;
 import static com.oracle.graal.hotspot.stubs.ExceptionHandlerStub.*;
 import static com.oracle.graal.hotspot.stubs.NewArrayStub.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
 import static com.oracle.graal.hotspot.stubs.StubUtil.*;
 import static com.oracle.graal.hotspot.stubs.UnwindExceptionToCallerStub.*;
-import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*;
+import static com.oracle.graal.hotspot.meta.HotSpotLoweringProvider.RuntimeCalls.*;
 import static com.oracle.graal.nodes.java.RegisterFinalizerNode.*;
 import static com.oracle.graal.replacements.Log.*;
 import static com.oracle.graal.replacements.MathSubstitutionsX86.*;
@@ -65,26 +66,25 @@
         super(runtime, metaAccess, codeCache);
     }
 
-    private static void link(Stub stub) {
+    protected static void link(Stub stub) {
         stub.getLinkage().setCompiledStub(stub);
     }
 
     public static ForeignCallDescriptor lookupArraycopyDescriptor(Kind kind, boolean aligned, boolean disjoint) {
-        return (ForeignCallDescriptor) arraycopyDescriptors[aligned ? 1 : 0][disjoint ? 1 : 0].get(kind);
+        return arraycopyDescriptors[aligned ? 1 : 0][disjoint ? 1 : 0].get(kind);
     }
 
-    private static final EnumMap[][] arraycopyDescriptors = new EnumMap[2][2];
+    @SuppressWarnings("unchecked") private static final EnumMap<Kind, ForeignCallDescriptor>[][] arraycopyDescriptors = new EnumMap[2][2];
 
     static {
         // Populate the EnumMap instances
         for (int i = 0; i < arraycopyDescriptors.length; i++) {
             for (int j = 0; j < arraycopyDescriptors[i].length; j++) {
-                arraycopyDescriptors[i][j] = new EnumMap<Kind, ForeignCallDescriptor>(Kind.class);
+                arraycopyDescriptors[i][j] = new EnumMap<>(Kind.class);
             }
         }
     }
 
-    @SuppressWarnings("unchecked")
     private static ForeignCallDescriptor registerArraycopyDescriptor(Kind kind, boolean aligned, boolean disjoint) {
         String name = kind + (aligned ? "Aligned" : "") + (disjoint ? "Disjoint" : "") + "Arraycopy";
         ForeignCallDescriptor desc = new ForeignCallDescriptor(name, void.class, Word.class, Word.class, Word.class);
@@ -103,7 +103,6 @@
     public void initialize(HotSpotProviders providers, HotSpotVMConfig c) {
         TargetDescription target = providers.getCodeCache().getTarget();
 
-        registerForeignCall(UNCOMMON_TRAP, c.uncommonTrapStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(DEOPT_HANDLER, c.handleDeoptStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, REEXECUTABLE, NO_LOCATIONS);
         registerForeignCall(IC_MISS_HANDLER, c.inlineCacheMissStub(), NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, REEXECUTABLE, NO_LOCATIONS);
 
@@ -116,8 +115,11 @@
 
         registerForeignCall(EXCEPTION_HANDLER_FOR_PC, c.exceptionHandlerForPcAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         registerForeignCall(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, c.exceptionHandlerForReturnAddressAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
+        registerForeignCall(FETCH_UNROLL_INFO, c.deoptimizationFetchUnrollInfo, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         registerForeignCall(NEW_ARRAY_C, c.newArrayAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         registerForeignCall(NEW_INSTANCE_C, c.newInstanceAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
+        registerForeignCall(UNCOMMON_TRAP, c.deoptimizationUncommonTrap, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
+        registerForeignCall(UNPACK_FRAMES, c.deoptimizationUnpackFrames, NativeCall, DESTROYS_REGISTERS, LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
         registerForeignCall(VM_MESSAGE_C, c.vmMessageAddress, NativeCall, DESTROYS_REGISTERS, NOT_LEAF, REEXECUTABLE, NO_LOCATIONS);
 
         link(new NewInstanceStub(providers, target, registerStubCall(NEW_INSTANCE, REEXECUTABLE, NOT_LEAF, ANY_LOCATION)));
@@ -131,7 +133,7 @@
         linkForeignCall(providers, CREATE_NULL_POINTER_EXCEPTION, c.createNullPointerExceptionAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(providers, CREATE_OUT_OF_BOUNDS_EXCEPTION, c.createOutOfBoundsExceptionAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(providers, MONITORENTER, c.monitorenterAddress, PREPEND_THREAD, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
-        linkForeignCall(providers, MONITOREXIT, c.monitorexitAddress, PREPEND_THREAD, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
+        linkForeignCall(providers, MONITOREXIT, c.monitorexitAddress, PREPEND_THREAD, LEAF_SP, NOT_REEXECUTABLE, ANY_LOCATION);
         linkForeignCall(providers, NEW_MULTI_ARRAY, c.newMultiArrayAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION);
         linkForeignCall(providers, DYNAMIC_NEW_ARRAY, c.dynamicNewArrayAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION);
         linkForeignCall(providers, DYNAMIC_NEW_INSTANCE, c.dynamicNewInstanceAddress, PREPEND_THREAD, NOT_LEAF, REEXECUTABLE, INIT_LOCATION);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,12 +23,11 @@
 package com.oracle.graal.hotspot.meta;
 
 import static com.oracle.graal.graph.UnsafeAccess.*;
+import sun.misc.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.hotspot.*;
 
-import sun.misc.*;
-
 /**
  * Implementation of {@link InstalledCode} for HotSpot.
  */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -90,7 +90,7 @@
         newObjectSnippets = new NewObjectSnippets.Templates(providers, target);
         monitorSnippets = new MonitorSnippets.Templates(providers, target, config.useFastLocking);
         writeBarrierSnippets = new WriteBarrierSnippets.Templates(providers, target, config.useCompressedOops ? config.getOopEncoding() : null);
-        boxingSnippets = new BoxingSnippets.Templates(providers, target);
+        boxingSnippets = new BoxingSnippets.Templates(providers, providers.getSnippetReflection(), target);
         exceptionObjectSnippets = new LoadExceptionObjectSnippets.Templates(providers, target);
         unsafeLoadSnippets = new UnsafeLoadSnippets.Templates(providers, target);
         providers.getReplacements().registerSnippetTemplateCache(new UnsafeArrayCopySnippets.Templates(providers, target));
@@ -134,8 +134,8 @@
             lowerOSRStartNode((OSRStartNode) n);
         } else if (n instanceof DynamicCounterNode) {
             lowerDynamicCounterNode((DynamicCounterNode) n);
-        } else if (n instanceof DeferredForeignCallNode) {
-            lowerDeferredForeignCallNode((DeferredForeignCallNode) n);
+        } else if (n instanceof BytecodeExceptionNode) {
+            lowerBytecodeExceptionNode((BytecodeExceptionNode) n);
         } else if (n instanceof CheckCastDynamicNode) {
             checkcastDynamicSnippets.lower((CheckCastDynamicNode) n, tool);
         } else if (n instanceof InstanceOfNode) {
@@ -234,7 +234,7 @@
                         int vtableEntryOffset = hsMethod.vtableEntryOffset();
                         assert vtableEntryOffset > 0;
                         Kind wordKind = runtime.getTarget().wordKind;
-                        FloatingReadNode hub = createReadHub(graph, wordKind, receiver, receiverNullCheck);
+                        ValueNode hub = createReadHub(graph, wordKind, receiver, receiverNullCheck);
 
                         ReadNode metaspaceMethod = createReadVirtualMethod(graph, wordKind, hub, hsMethod);
                         // We use LocationNode.ANY_LOCATION for the reads that access the
@@ -307,7 +307,7 @@
     private void lowerLoadFieldNode(LoadFieldNode loadField, LoweringTool tool) {
         StructuredGraph graph = loadField.graph();
         HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) loadField.field();
-        ValueNode object = loadField.isStatic() ? ConstantNode.forObject(field.getDeclaringClass().mirror(), metaAccess, graph) : loadField.object();
+        ValueNode object = loadField.isStatic() ? ConstantNode.forConstant(HotSpotObjectConstant.forObject(field.getDeclaringClass().mirror()), metaAccess, graph) : loadField.object();
         assert loadField.getKind() != Kind.Illegal;
         BarrierType barrierType = getFieldLoadBarrierType(field);
 
@@ -351,7 +351,7 @@
     private void lowerStoreFieldNode(StoreFieldNode storeField, LoweringTool tool) {
         StructuredGraph graph = storeField.graph();
         HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) storeField.field();
-        ValueNode object = storeField.isStatic() ? ConstantNode.forObject(field.getDeclaringClass().mirror(), metaAccess, graph) : storeField.object();
+        ValueNode object = storeField.isStatic() ? ConstantNode.forConstant(HotSpotObjectConstant.forObject(field.getDeclaringClass().mirror()), metaAccess, graph) : storeField.object();
         BarrierType barrierType = getFieldStoreBarrierType(storeField);
 
         ValueNode value = implicitStoreConvert(graph, storeField.field().getKind(), storeField.value());
@@ -370,12 +370,15 @@
         }
     }
 
-    private static void lowerCompareAndSwapNode(CompareAndSwapNode cas) {
-        // Separate out GC barrier semantics
+    private void lowerCompareAndSwapNode(CompareAndSwapNode cas) {
         StructuredGraph graph = cas.graph();
-        LocationNode location = IndexedLocationNode.create(cas.getLocationIdentity(), cas.expected().getKind(), cas.displacement(), cas.offset(), graph, 1);
-        LoweredCompareAndSwapNode atomicNode = graph.add(new LoweredCompareAndSwapNode(cas.object(), location, cas.expected(), cas.newValue(), getCompareAndSwapBarrier(cas),
-                        cas.expected().getKind() == Kind.Object));
+        Kind valueKind = cas.getValueKind();
+        LocationNode location = IndexedLocationNode.create(cas.getLocationIdentity(), valueKind, cas.displacement(), cas.offset(), graph, 1);
+
+        ValueNode expectedValue = implicitStoreConvert(graph, valueKind, cas.expected(), true);
+        ValueNode newValue = implicitStoreConvert(graph, valueKind, cas.newValue(), true);
+
+        LoweredCompareAndSwapNode atomicNode = graph.add(new LoweredCompareAndSwapNode(cas.object(), location, expectedValue, newValue, getCompareAndSwapBarrierType(cas), false));
         atomicNode.setStateAfter(cas.stateAfter());
         graph.replaceFixedWithFixed(cas, atomicNode);
     }
@@ -418,7 +421,7 @@
                 }
             } else {
                 Kind wordKind = runtime.getTarget().wordKind;
-                FloatingReadNode arrayClass = createReadHub(graph, wordKind, array, boundsCheck);
+                ValueNode arrayClass = createReadHub(graph, wordKind, array, boundsCheck);
                 LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, wordKind, runtime.getConfig().arrayClassElementOffset, graph);
                 /*
                  * Anchor the read of the element klass to the cfg, because it is only valid when
@@ -524,7 +527,7 @@
             assert loadHub.getKind() == wordKind;
             ValueNode object = loadHub.object();
             GuardingNode guard = loadHub.getGuard();
-            FloatingReadNode hub = createReadHub(graph, wordKind, object, guard);
+            ValueNode hub = createReadHub(graph, wordKind, object, guard);
             graph.replaceFloating(loadHub, hub);
         }
     }
@@ -661,11 +664,51 @@
         }
     }
 
-    private void lowerDeferredForeignCallNode(DeferredForeignCallNode deferred) {
-        StructuredGraph graph = deferred.graph();
+    static final class Exceptions {
+        protected static final ArrayIndexOutOfBoundsException cachedArrayIndexOutOfBoundsException;
+        protected static final NullPointerException cachedNullPointerException;
+
+        static {
+            cachedArrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException();
+            cachedArrayIndexOutOfBoundsException.setStackTrace(new StackTraceElement[0]);
+            cachedNullPointerException = new NullPointerException();
+            cachedNullPointerException.setStackTrace(new StackTraceElement[0]);
+        }
+    }
+
+    public static final class RuntimeCalls {
+        public static final ForeignCallDescriptor CREATE_NULL_POINTER_EXCEPTION = new ForeignCallDescriptor("createNullPointerException", NullPointerException.class);
+        public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", ArrayIndexOutOfBoundsException.class, int.class);
+    }
+
+    private void lowerBytecodeExceptionNode(BytecodeExceptionNode node) {
+        StructuredGraph graph = node.graph();
         if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
-            ForeignCallNode foreignCallNode = graph.add(new ForeignCallNode(foreignCalls, deferred.getDescriptor(), deferred.stamp(), deferred.getArguments()));
-            graph.replaceFixedWithFixed(deferred, foreignCallNode);
+            if (OmitHotExceptionStacktrace.getValue()) {
+                Throwable exception;
+                if (node.getExceptionClass() == NullPointerException.class) {
+                    exception = Exceptions.cachedNullPointerException;
+                } else if (node.getExceptionClass() == ArrayIndexOutOfBoundsException.class) {
+                    exception = Exceptions.cachedArrayIndexOutOfBoundsException;
+                } else {
+                    throw GraalInternalError.shouldNotReachHere();
+                }
+                FloatingNode exceptionNode = ConstantNode.forConstant(HotSpotObjectConstant.forObject(exception), metaAccess, graph);
+                graph.replaceFixedWithFloating(node, exceptionNode);
+
+            } else {
+                ForeignCallDescriptor descriptor;
+                if (node.getExceptionClass() == NullPointerException.class) {
+                    descriptor = RuntimeCalls.CREATE_NULL_POINTER_EXCEPTION;
+                } else if (node.getExceptionClass() == ArrayIndexOutOfBoundsException.class) {
+                    descriptor = RuntimeCalls.CREATE_OUT_OF_BOUNDS_EXCEPTION;
+                } else {
+                    throw GraalInternalError.shouldNotReachHere();
+                }
+
+                ForeignCallNode foreignCallNode = graph.add(new ForeignCallNode(foreignCalls, descriptor, node.stamp(), node.getArguments()));
+                graph.replaceFixedWithFixed(node, foreignCallNode);
+            }
         }
     }
 
@@ -703,6 +746,14 @@
 
         long displacement = 0;
         int indexScaling = 1;
+        boolean signExtend = false;
+        if (offset instanceof SignExtendNode) {
+            SignExtendNode extend = (SignExtendNode) offset;
+            if (extend.getResultBits() == 64) {
+                signExtend = true;
+                offset = extend.getInput();
+            }
+        }
         if (offset instanceof IntegerAddNode) {
             IntegerAddNode integerAddNode = (IntegerAddNode) offset;
             if (integerAddNode.y() instanceof ConstantNode) {
@@ -727,7 +778,10 @@
                 }
             }
         }
-
+        if (signExtend) {
+            // If we were using sign extended values before restore the sign extension.
+            offset = offset.graph().addOrUnique(new SignExtendNode(offset, 64));
+        }
         return IndexedLocationNode.create(locationIdentity, accessKind, displacement, offset, offset.graph(), indexScaling);
     }
 
@@ -755,18 +809,37 @@
         return metaspaceMethod;
     }
 
-    private FloatingReadNode createReadHub(StructuredGraph graph, Kind wordKind, ValueNode object, GuardingNode guard) {
+    private ValueNode createReadHub(StructuredGraph graph, Kind wordKind, ValueNode object, GuardingNode guard) {
         HotSpotVMConfig config = runtime.getConfig();
         LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, wordKind, config.hubOffset, graph);
         assert !object.isConstant() || object.asConstant().isNull();
-        return graph.unique(new FloatingReadNode(object, location, null, StampFactory.forKind(wordKind), guard, BarrierType.NONE, config.useCompressedClassPointers));
+
+        Stamp hubStamp;
+        if (config.useCompressedClassPointers) {
+            hubStamp = StampFactory.forInteger(32);
+        } else {
+            hubStamp = StampFactory.forKind(wordKind);
+        }
+
+        FloatingReadNode memoryRead = graph.unique(new FloatingReadNode(object, location, null, hubStamp, guard, BarrierType.NONE, false));
+        if (config.useCompressedClassPointers) {
+            return CompressionNode.uncompress(memoryRead, config.getKlassEncoding());
+        } else {
+            return memoryRead;
+        }
     }
 
     private WriteNode createWriteHub(StructuredGraph graph, Kind wordKind, ValueNode object, ValueNode value) {
         HotSpotVMConfig config = runtime.getConfig();
         LocationNode location = ConstantLocationNode.create(HUB_LOCATION, wordKind, config.hubOffset, graph);
         assert !object.isConstant() || object.asConstant().isNull();
-        return graph.add(new WriteNode(object, value, location, BarrierType.NONE, config.useCompressedClassPointers));
+
+        ValueNode writeValue = value;
+        if (config.useCompressedClassPointers) {
+            writeValue = CompressionNode.compress(value, config.getKlassEncoding());
+        }
+
+        return graph.add(new WriteNode(object, writeValue, location, BarrierType.NONE, false));
     }
 
     private static BarrierType getFieldLoadBarrierType(HotSpotResolvedJavaField loadField) {
@@ -778,45 +851,41 @@
     }
 
     private static BarrierType getFieldStoreBarrierType(StoreFieldNode storeField) {
-        BarrierType barrierType = BarrierType.NONE;
         if (storeField.field().getKind() == Kind.Object) {
-            barrierType = BarrierType.IMPRECISE;
+            return BarrierType.IMPRECISE;
         }
-        return barrierType;
+        return BarrierType.NONE;
     }
 
     private static BarrierType getArrayStoreBarrierType(StoreIndexedNode store) {
-        BarrierType barrierType = BarrierType.NONE;
         if (store.elementKind() == Kind.Object) {
-            barrierType = BarrierType.PRECISE;
+            return BarrierType.PRECISE;
         }
-        return barrierType;
+        return BarrierType.NONE;
     }
 
     private static BarrierType getUnsafeStoreBarrierType(UnsafeStoreNode store) {
-        BarrierType barrierType = BarrierType.NONE;
         if (store.value().getKind() == Kind.Object) {
             ResolvedJavaType type = ObjectStamp.typeOrNull(store.object());
             if (type != null && !type.isArray()) {
-                barrierType = BarrierType.IMPRECISE;
+                return BarrierType.IMPRECISE;
             } else {
-                barrierType = BarrierType.PRECISE;
+                return BarrierType.PRECISE;
             }
         }
-        return barrierType;
+        return BarrierType.NONE;
     }
 
-    private static BarrierType getCompareAndSwapBarrier(CompareAndSwapNode cas) {
-        BarrierType barrierType = BarrierType.NONE;
+    private static BarrierType getCompareAndSwapBarrierType(CompareAndSwapNode cas) {
         if (cas.expected().getKind() == Kind.Object) {
             ResolvedJavaType type = ObjectStamp.typeOrNull(cas.object());
             if (type != null && !type.isArray()) {
-                barrierType = BarrierType.IMPRECISE;
+                return BarrierType.IMPRECISE;
             } else {
-                barrierType = BarrierType.PRECISE;
+                return BarrierType.PRECISE;
             }
         }
-        return barrierType;
+        return BarrierType.NONE;
     }
 
     protected static ConstantLocationNode createFieldLocation(StructuredGraph graph, HotSpotResolvedJavaField field, boolean initialization) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
         if (constant.getKind() != Kind.Object || constant.isNull()) {
             return null;
         }
-        Object o = constant.asObject();
+        Object o = HotSpotObjectConstant.asObject(constant);
         return HotSpotResolvedObjectType.fromClass(o.getClass());
     }
 
@@ -93,7 +93,7 @@
         }
     }
 
-    public ResolvedJavaMethod lookupJavaConstructor(Constructor reflectionConstructor) {
+    public ResolvedJavaMethod lookupJavaConstructor(Constructor<?> reflectionConstructor) {
         try {
             Class<?> holder = reflectionConstructor.getDeclaringClass();
             final int slot = reflectionConstructorSlot.getInt(reflectionConstructor);
@@ -295,7 +295,7 @@
             } else {
                 if (lookupJavaType.isArray()) {
                     // TODO(tw): Add compressed pointer support.
-                    int length = Array.getLength(constant.asObject());
+                    int length = Array.getLength(HotSpotObjectConstant.asObject(constant));
                     ResolvedJavaType elementType = lookupJavaType.getComponentType();
                     Kind elementKind = elementType.getKind();
                     final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstant.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.meta;
+
+import java.util.*;
+
+import com.oracle.graal.api.meta.*;
+
+public final class HotSpotMetaspaceConstant extends PrimitiveConstant {
+
+    private static final long serialVersionUID = 1003463314013122983L;
+
+    public static Constant forMetaspaceObject(Kind kind, long primitive, Object metaspaceObject) {
+        return new HotSpotMetaspaceConstant(kind, primitive, metaspaceObject);
+    }
+
+    public static Object getMetaspaceObject(Constant constant) {
+        return ((HotSpotMetaspaceConstant) constant).metaspaceObject;
+    }
+
+    private final Object metaspaceObject;
+
+    private HotSpotMetaspaceConstant(Kind kind, long primitive, Object metaspaceObject) {
+        super(kind, primitive);
+        this.metaspaceObject = metaspaceObject;
+    }
+
+    @Override
+    public int hashCode() {
+        return super.hashCode() ^ System.identityHashCode(metaspaceObject);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return o == this || (o instanceof HotSpotMetaspaceConstant && super.equals(o) && Objects.equals(metaspaceObject, ((HotSpotMetaspaceConstant) o).metaspaceObject));
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + "{" + metaspaceObject + "}";
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,6 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.bridge.*;
 
 /**
  * Implementation of {@link InstalledCode} for code installed as an nmethod. The nmethod stores a
@@ -92,12 +91,6 @@
         return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getCodeBlob(), isDefault, name);
     }
 
-    @Override
-    public Object execute(Object arg1, Object arg2, Object arg3) throws InvalidInstalledCodeException {
-        assert checkThreeObjectArgs();
-        return CompilerToVMImpl.executeCompiledMethodIntrinsic(arg1, arg2, arg3, this);
-    }
-
     protected boolean checkThreeObjectArgs() {
         assert method.getSignature().getParameterCount(!Modifier.isStatic(method.getModifiers())) == 3;
         assert method.getSignature().getParameterKind(0) == Kind.Object;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstant.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,140 @@
+/*
+ * 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.hotspot.meta;
+
+import com.oracle.graal.api.meta.*;
+
+/**
+ * Represents a constant non-{@code null} object reference, within the compiler and across the
+ * compiler/runtime interface.
+ */
+public final class HotSpotObjectConstant extends Constant {
+
+    private static final long serialVersionUID = 3592151693708093496L;
+
+    public static Constant forObject(Object object) {
+        if (object == null) {
+            return Constant.NULL_OBJECT;
+        } else {
+            return new HotSpotObjectConstant(object);
+        }
+    }
+
+    public static Constant forBoxedValue(Kind kind, Object value) {
+        if (kind == Kind.Object) {
+            return HotSpotObjectConstant.forObject(value);
+        } else {
+            return Constant.forBoxedPrimitive(value);
+        }
+    }
+
+    public static Object asObject(Constant constant) {
+        if (constant.isNull()) {
+            return null;
+        } else {
+            return ((HotSpotObjectConstant) constant).object;
+        }
+    }
+
+    public static Object asBoxedValue(Constant constant) {
+        if (constant.isNull()) {
+            return null;
+        } else if (constant.getKind() == Kind.Object) {
+            return ((HotSpotObjectConstant) constant).object;
+        } else {
+            return constant.asBoxedPrimitive();
+        }
+    }
+
+    private final Object object;
+
+    private HotSpotObjectConstant(Object object) {
+        super(Kind.Object);
+        this.object = object;
+        assert object != null;
+    }
+
+    @Override
+    public boolean isNull() {
+        return false;
+    }
+
+    @Override
+    public boolean isDefaultForKind() {
+        return false;
+    }
+
+    @Override
+    public Object asBoxedPrimitive() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public int asInt() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public boolean asBoolean() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public long asLong() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public float asFloat() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public double asDouble() {
+        throw new IllegalArgumentException();
+    }
+
+    @Override
+    public int hashCode() {
+        return System.identityHashCode(object);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        return o == this || (o instanceof HotSpotObjectConstant && super.equals(o) && object == ((HotSpotObjectConstant) o).object);
+    }
+
+    @Override
+    public String toValueString() {
+        if (object instanceof String) {
+            return (String) object;
+        } else {
+            return Kind.Object.format(object);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return getKind().getJavaName() + "[" + Kind.Object.format(object) + "]";
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.meta;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
@@ -36,13 +37,16 @@
     private final HotSpotDisassemblerProvider disassembler;
     private final SuitesProvider suites;
     private final HotSpotRegistersProvider registers;
+    private final SnippetReflectionProvider snippetReflection;
 
     public HotSpotProviders(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, HotSpotForeignCallsProvider foreignCalls,
-                    LoweringProvider lowerer, Replacements replacements, HotSpotDisassemblerProvider disassembler, SuitesProvider suites, HotSpotRegistersProvider registers) {
+                    LoweringProvider lowerer, Replacements replacements, HotSpotDisassemblerProvider disassembler, SuitesProvider suites, HotSpotRegistersProvider registers,
+                    SnippetReflectionProvider snippetReflection) {
         super(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements);
         this.disassembler = disassembler;
         this.suites = suites;
         this.registers = registers;
+        this.snippetReflection = snippetReflection;
     }
 
     @Override
@@ -72,4 +76,7 @@
         return registers;
     }
 
+    public SnippetReflectionProvider getSnippetReflection() {
+        return snippetReflection;
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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
@@ -204,7 +204,6 @@
             if (Modifier.isFinal(getModifiers())) {
                 if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && isEmbeddable()) {
                     return readValue(receiver);
-
                 }
             }
         } else {
@@ -213,7 +212,7 @@
              * have a non-default value.
              */
             assert !isStatic(modifiers);
-            Object object = receiver.asObject();
+            Object object = HotSpotObjectConstant.asObject(receiver);
 
             // Canonicalization may attempt to process an unsafe read before
             // processing a guard (e.g. a null check or a type check) for this read
@@ -234,7 +233,7 @@
                     if (StableOptionValue.class.isAssignableFrom(clazz)) {
                         assert getName().equals("value") : "Unexpected field in " + StableOptionValue.class.getName() + " hierarchy:" + this;
                         StableOptionValue<?> option = (StableOptionValue<?>) object;
-                        return Constant.forObject(option.getValue());
+                        return HotSpotObjectConstant.forObject(option.getValue());
                     }
                 }
             }
@@ -244,7 +243,7 @@
 
     /**
      * Determines if a given object contains this field.
-     * 
+     *
      * @return true iff this is a non-static field and its declaring class is assignable from
      *         {@code object}'s class
      */
@@ -260,14 +259,13 @@
         if (receiver == null) {
             assert isStatic(modifiers);
             if (holder.isInitialized()) {
-                return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), holder.mirror(), offset, getKind() == Kind.Object);
+                return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), HotSpotObjectConstant.forObject(holder.mirror()), offset);
             }
             return null;
         } else {
             assert !isStatic(modifiers);
-            Object object = receiver.asObject();
-            assert object != null && isInObject(object);
-            return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), object, offset, getKind() == Kind.Object);
+            assert receiver.isNonNull() && isInObject(HotSpotObjectConstant.asObject(receiver));
+            return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), receiver, offset);
         }
     }
 
@@ -332,7 +330,7 @@
 
     /**
      * Checks if this field has the {@link Stable} annotation.
-     * 
+     *
      * @return true if field has {@link Stable} annotation, false otherwise
      */
     public boolean isStable() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,7 +59,7 @@
 
     /**
      * Gets the holder of a HotSpot metaspace method native object.
-     * 
+     *
      * @param metaspaceMethod a metaspace Method object
      * @return the {@link ResolvedJavaType} corresponding to the holder of the
      *         {@code metaspaceMethod}
@@ -74,7 +74,7 @@
 
     /**
      * Gets the {@link ResolvedJavaMethod} for a HotSpot metaspace method native object.
-     * 
+     *
      * @param metaspaceMethod a metaspace Method object
      * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod}
      */
@@ -110,7 +110,7 @@
     /**
      * Returns a pointer to this method's constant method data structure (
      * {@code Method::_constMethod}).
-     * 
+     *
      * @return pointer to this method's ConstMethod
      */
     private long getConstMethod() {
@@ -134,7 +134,7 @@
 
     /**
      * Returns this method's flags ({@code Method::_flags}).
-     * 
+     *
      * @return flags of this method
      */
     private int getFlags() {
@@ -143,7 +143,7 @@
 
     /**
      * Returns this method's constant method flags ({@code ConstMethod::_flags}).
-     * 
+     *
      * @return flags of this method's ConstMethod
      */
     private int getConstMethodFlags() {
@@ -159,7 +159,11 @@
      * Gets the address of the C++ Method object for this method.
      */
     public Constant getMetaspaceMethodConstant() {
-        return Constant.forIntegerKind(getHostWordKind(), metaspaceMethod, this);
+        return HotSpotMetaspaceConstant.forMetaspaceObject(getHostWordKind(), metaspaceMethod, this);
+    }
+
+    public long getMetaspaceMethod() {
+        return metaspaceMethod;
     }
 
     @Override
@@ -183,7 +187,7 @@
     @Override
     public boolean canBeStaticallyBound() {
         int modifiers = getModifiers();
-        return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers)) && !Modifier.isAbstract(modifiers);
+        return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(holder.getModifiers())) && !Modifier.isAbstract(modifiers);
     }
 
     @Override
@@ -248,7 +252,7 @@
 
     /**
      * Returns true if this method has a {@code CallerSensitive} annotation.
-     * 
+     *
      * @return true if CallerSensitive annotation present, false otherwise
      */
     public boolean isCallerSensitive() {
@@ -257,7 +261,7 @@
 
     /**
      * Returns true if this method has a {@code ForceInline} annotation.
-     * 
+     *
      * @return true if ForceInline annotation present, false otherwise
      */
     public boolean isForceInline() {
@@ -266,7 +270,7 @@
 
     /**
      * Returns true if this method has a {@code DontInline} annotation.
-     * 
+     *
      * @return true if DontInline annotation present, false otherwise
      */
     public boolean isDontInline() {
@@ -283,7 +287,7 @@
     /**
      * Returns true if this method is one of the special methods that is ignored by security stack
      * walks.
-     * 
+     *
      * @return true if special method ignored by security stack walks, false otherwise
      */
     public boolean ignoredBySecurityStackWalk() {
@@ -374,7 +378,7 @@
 
     /**
      * Gets the value of {@code Method::_code}.
-     * 
+     *
      * @return the value of {@code Method::_code}
      */
     private long getCompiledCode() {
@@ -384,7 +388,7 @@
 
     /**
      * Returns whether this method has compiled code.
-     * 
+     *
      * @return true if this method has compiled code, false otherwise
      */
     public boolean hasCompiledCode() {
@@ -451,7 +455,7 @@
     @Override
     public Annotation[][] getParameterAnnotations() {
         if (isConstructor()) {
-            Constructor javaConstructor = toJavaConstructor();
+            Constructor<?> javaConstructor = toJavaConstructor();
             return javaConstructor == null ? null : javaConstructor.getParameterAnnotations();
         }
         Method javaMethod = toJava();
@@ -486,7 +490,7 @@
     @Override
     public Type[] getGenericParameterTypes() {
         if (isConstructor()) {
-            Constructor javaConstructor = toJavaConstructor();
+            Constructor<?> javaConstructor = toJavaConstructor();
             return javaConstructor == null ? null : javaConstructor.getGenericParameterTypes();
         }
         Method javaMethod = toJava();
@@ -511,7 +515,7 @@
         }
     }
 
-    private Constructor toJavaConstructor() {
+    private Constructor<?> toJavaConstructor() {
         try {
             return holder.mirror().getDeclaredConstructor(signatureToTypes());
         } catch (NoSuchMethodException e) {
@@ -589,7 +593,7 @@
     /**
      * Returns the offset of this method into the v-table. The method must have a v-table entry as
      * indicated by {@link #isInVirtualMethodTable()}, otherwise an exception is thrown.
-     * 
+     *
      * @return the offset of this method into the v-table
      */
     public int vtableEntryOffset() {
@@ -608,17 +612,20 @@
 
     /**
      * Returns this method's virtual table index.
-     * 
+     *
      * @return virtual table index
      */
     private int getVtableIndex() {
+        assert !Modifier.isInterface(holder.getModifiers());
         HotSpotVMConfig config = runtime().getConfig();
-        return unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset);
+        int result = unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset);
+        assert result >= config.nonvirtualVtableIndex : "must be linked";
+        return result;
     }
 
     public SpeculationLog getSpeculationLog() {
         if (speculationLog == null) {
-            speculationLog = new SpeculationLog();
+            speculationLog = new HotSpotSpeculationLog();
         }
         return speculationLog;
     }
@@ -636,13 +643,13 @@
 
         Object[] objArguments = new Object[arguments.length];
         for (int i = 0; i < arguments.length; i++) {
-            objArguments[i] = arguments[i].asBoxedValue();
+            objArguments[i] = HotSpotObjectConstant.asBoxedValue(arguments[i]);
         }
-        Object objReceiver = receiver != null ? receiver.asObject() : null;
+        Object objReceiver = receiver != null ? HotSpotObjectConstant.asObject(receiver) : null;
 
         try {
             Object objResult = javaMethod.invoke(objReceiver, objArguments);
-            return javaMethod.getReturnType() == void.class ? null : Constant.forBoxed(getSignature().getReturnKind(), objResult);
+            return javaMethod.getReturnType() == void.class ? null : HotSpotObjectConstant.forBoxedValue(getSignature().getReturnKind(), objResult);
 
         } catch (IllegalAccessException | InvocationTargetException ex) {
             throw new IllegalArgumentException(ex);
@@ -652,18 +659,18 @@
     @Override
     public Constant newInstance(Constant[] arguments) {
         assert isConstructor();
-        Constructor javaConstructor = toJavaConstructor();
+        Constructor<?> javaConstructor = toJavaConstructor();
         javaConstructor.setAccessible(true);
 
         Object[] objArguments = new Object[arguments.length];
         for (int i = 0; i < arguments.length; i++) {
-            objArguments[i] = arguments[i].asBoxedValue();
+            objArguments[i] = HotSpotObjectConstant.asBoxedValue(arguments[i]);
         }
 
         try {
             Object objResult = javaConstructor.newInstance(objArguments);
             assert objResult != null;
-            return Constant.forObject(objResult);
+            return HotSpotObjectConstant.forObject(objResult);
 
         } catch (IllegalAccessException | InvocationTargetException | InstantiationException ex) {
             throw new IllegalArgumentException(ex);
@@ -672,7 +679,7 @@
 
     /**
      * Allocates a compile id for this method by asking the VM for one.
-     * 
+     *
      * @param entryBCI entry bci
      * @return compile id
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,11 +48,6 @@
      */
     private final Class<?> javaClass;
 
-    /**
-     * Used for implemented a lazy binding from a {@link Node} type to a {@link NodeClass} value.
-     */
-    private NodeClass nodeClass;
-
     private HashMap<Long, HotSpotResolvedJavaField> fieldCache;
     private HashMap<Long, HotSpotResolvedJavaMethod> methodCache;
     private HotSpotResolvedJavaField[] instanceFields;
@@ -62,7 +57,7 @@
 
     /**
      * Gets the Graal mirror from a HotSpot metaspace Klass native object.
-     * 
+     *
      * @param metaspaceKlass a metaspace Klass object boxed in a {@link Constant}
      * @return the {@link ResolvedJavaType} corresponding to {@code klassConstant}
      */
@@ -73,26 +68,26 @@
 
     /**
      * Gets the Graal mirror from a HotSpot metaspace Klass native object.
-     * 
+     *
      * @param metaspaceKlass a metaspace Klass object
      * @return the {@link ResolvedJavaType} corresponding to {@code metaspaceKlass}
      */
     public static ResolvedJavaType fromMetaspaceKlass(long metaspaceKlass) {
         assert metaspaceKlass != 0;
-        Class javaClass = (Class) runtime().getCompilerToVM().readUnsafeUncompressedPointer(null, metaspaceKlass + runtime().getConfig().classMirrorOffset);
+        Class<?> javaClass = runtime().getCompilerToVM().getJavaMirror(metaspaceKlass);
         assert javaClass != null;
         return fromClass(javaClass);
     }
 
     /**
      * Creates the Graal mirror for a {@link Class} object.
-     * 
+     *
      * <p>
      * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the
      * {@link Class} type. Use {@link #fromClass(Class)}, {@link #fromMetaspaceKlass(Constant)} or
      * {@link #fromMetaspaceKlass(long)} instead.
      * </p>
-     * 
+     *
      * @param javaClass the Class to create the mirror for
      */
     public HotSpotResolvedObjectType(Class<?> javaClass) {
@@ -138,7 +133,7 @@
 
     @Override
     public ResolvedJavaType getComponentType() {
-        Class javaComponentType = mirror().getComponentType();
+        Class<?> javaComponentType = mirror().getComponentType();
         return javaComponentType == null ? null : fromClass(javaComponentType);
     }
 
@@ -185,7 +180,7 @@
     /**
      * Returns if type {@code type} is a leaf class. This is the case if the
      * {@code Klass::_subklass} field of the underlying class is zero.
-     * 
+     *
      * @return true if the type is a leaf class
      */
     private boolean isLeafClass() {
@@ -195,7 +190,7 @@
     /**
      * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given
      * type {@code type}.
-     * 
+     *
      * @return value of the subklass field as metaspace klass pointer
      */
     private long getSubklass() {
@@ -204,14 +199,14 @@
 
     @Override
     public HotSpotResolvedObjectType getSuperclass() {
-        Class javaSuperclass = mirror().getSuperclass();
+        Class<?> javaSuperclass = mirror().getSuperclass();
         return javaSuperclass == null ? null : (HotSpotResolvedObjectType) fromClass(javaSuperclass);
     }
 
     @Override
     public ResolvedJavaType[] getInterfaces() {
         if (interfaces == null) {
-            Class[] javaInterfaces = mirror().getInterfaces();
+            Class<?>[] javaInterfaces = mirror().getInterfaces();
             ResolvedJavaType[] result = new ResolvedJavaType[javaInterfaces.length];
             for (int i = 0; i < javaInterfaces.length; i++) {
                 result[i] = fromClass(javaInterfaces[i]);
@@ -267,7 +262,7 @@
     public Constant getEncoding(Representation r) {
         switch (r) {
             case JavaClass:
-                return Constant.forObject(mirror());
+                return HotSpotObjectConstant.forObject(mirror());
             case ObjectHub:
                 return klass();
             default:
@@ -312,7 +307,7 @@
     /**
      * Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace
      * klass.
-     * 
+     *
      * @return state field value of this type
      */
     private int getState() {
@@ -330,7 +325,7 @@
     @Override
     public boolean isInstance(Constant obj) {
         if (obj.getKind() == Kind.Object && !obj.isNull()) {
-            return mirror().isInstance(obj.asObject());
+            return mirror().isInstance(HotSpotObjectConstant.asObject(obj));
         }
         return false;
     }
@@ -476,7 +471,7 @@
 
         /**
          * Creates a field info for the field in the fields array at index {@code index}.
-         * 
+         *
          * @param index index to the fields array
          */
         public FieldInfo(int index) {
@@ -484,8 +479,7 @@
             // Get Klass::_fields
             final long metaspaceFields = unsafe.getAddress(metaspaceKlass() + config.instanceKlassFieldsOffset);
             assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code";
-            metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * 2 * index;  // TODO
-            // Short.BYTES
+            metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * Short.BYTES * index;
         }
 
         private int getAccessFlags() {
@@ -513,7 +507,7 @@
          * on top an array of Java shorts.
          */
         private int readFieldSlot(int index) {
-            return unsafe.getChar(metaspaceData + 2 * index);  // TODO Short.BYTES
+            return unsafe.getChar(metaspaceData + Short.BYTES * index);
         }
 
         /**
@@ -578,8 +572,7 @@
                     }
                 }
 
-                // TODO use in 1.8: fieldsArray.sort(new OffsetComparator());
-                Collections.sort(fieldsArray, new OffsetComparator());
+                fieldsArray.sort(new OffsetComparator());
 
                 HotSpotResolvedJavaField[] myFields = fieldsArray.toArray(new HotSpotResolvedJavaField[0]);
 
@@ -614,7 +607,7 @@
     /**
      * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array
      * by walking the array and discounting the generic signature slots at the end of the array.
-     * 
+     *
      * <p>
      * See {@code FieldStreamBase::init_generic_signature_start_slot}
      */
@@ -663,7 +656,7 @@
      * Gets the metaspace Klass boxed in a {@link Constant}.
      */
     public Constant klass() {
-        return Constant.forIntegerKind(runtime().getTarget().wordKind, metaspaceKlass(), this);
+        return HotSpotMetaspaceConstant.forMetaspaceObject(runtime().getTarget().wordKind, metaspaceKlass(), this);
     }
 
     public boolean isPrimaryType() {
@@ -719,7 +712,7 @@
 
     @Override
     public ResolvedJavaMethod[] getDeclaredConstructors() {
-        Constructor[] constructors = mirror().getDeclaredConstructors();
+        Constructor<?>[] constructors = mirror().getDeclaredConstructors();
         ResolvedJavaMethod[] result = new ResolvedJavaMethod[constructors.length];
         for (int i = 0; i < constructors.length; i++) {
             result[i] = runtime().getHostProviders().getMetaAccess().lookupJavaConstructor(constructors[i]);
@@ -749,21 +742,7 @@
 
     @Override
     public Constant newArray(int length) {
-        return Constant.forObject(Array.newInstance(mirror(), length));
-    }
-
-    /**
-     * @return the {@link NodeClass} value (which may be {@code null}) associated with this type
-     */
-    public NodeClass getNodeClass() {
-        return nodeClass;
-    }
-
-    /**
-     * Sets the {@link NodeClass} value associated with this type.
-     */
-    public void setNodeClass(NodeClass nodeClass) {
-        this.nodeClass = nodeClass;
+        return HotSpotObjectConstant.forObject(Array.newInstance(mirror(), length));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Wed Apr 16 14:02:52 2014 +0200
@@ -253,6 +253,6 @@
 
     @Override
     public Constant newArray(int length) {
-        return Constant.forObject(Array.newInstance(mirror(), length));
+        return HotSpotObjectConstant.forObject(Array.newInstance(mirror(), length));
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntimeStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -56,10 +56,6 @@
         return String.format("InstalledRuntimeStub[stub=%s, codeBlob=0x%x]", stub, getCodeBlob());
     }
 
-    public Object execute(Object arg1, Object arg2, Object arg3) throws InvalidInstalledCodeException {
-        throw new GraalInternalError("Cannot call stub %s", stub);
-    }
-
     public Object executeVarargs(Object... args) throws InvalidInstalledCodeException {
         throw new GraalInternalError("Cannot call stub %s", stub);
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Wed Apr 16 14:02:52 2014 +0200
@@ -127,13 +127,30 @@
         return argSlots + (withReceiver ? 1 : 0);
     }
 
+    private static boolean checkValidCache(JavaType type, ResolvedJavaType accessingClass) {
+        if (!(type instanceof ResolvedJavaType)) {
+            return false;
+        }
+
+        if (type instanceof HotSpotResolvedObjectType) {
+            HotSpotResolvedObjectType resolved = (HotSpotResolvedObjectType) type;
+            if (accessingClass == null) {
+                return resolved.mirror().getClassLoader() == null;
+            } else {
+                return resolved.mirror().getClassLoader() == ((HotSpotResolvedObjectType) accessingClass).mirror().getClassLoader();
+            }
+        }
+
+        return true;
+    }
+
     @Override
     public JavaType getParameterType(int index, ResolvedJavaType accessingClass) {
         if (parameterTypes == null) {
             parameterTypes = new JavaType[parameters.size()];
         }
         JavaType type = parameterTypes[index];
-        if (type == null || !(type instanceof ResolvedJavaType)) {
+        if (!checkValidCache(type, accessingClass)) {
             type = runtime().lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false);
             parameterTypes[index] = type;
         }
@@ -152,7 +169,7 @@
 
     @Override
     public JavaType getReturnType(ResolvedJavaType accessingClass) {
-        if (returnTypeCache == null || !(returnTypeCache instanceof ResolvedJavaType)) {
+        if (!checkValidCache(returnTypeCache, accessingClass)) {
             returnTypeCache = runtime().lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false);
         }
         return returnTypeCache;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.meta;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+
+public class HotSpotSnippetReflectionProvider implements SnippetReflectionProvider {
+
+    @Override
+    public Constant forObject(Object object) {
+        return HotSpotObjectConstant.forObject(object);
+    }
+
+    @Override
+    public Object asObject(Constant constant) {
+        return HotSpotObjectConstant.asObject(constant);
+    }
+
+    @Override
+    public Constant forBoxed(Kind kind, Object value) {
+        return HotSpotObjectConstant.forBoxedValue(kind, value);
+    }
+
+    @Override
+    public Object asBoxedValue(Constant constant) {
+        return HotSpotObjectConstant.asBoxedValue(constant);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSpeculationLog.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.meta;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+
+public class HotSpotSpeculationLog extends SpeculationLog {
+
+    @Override
+    public Constant speculate(Object reason) {
+        addSpeculation(reason);
+        return HotSpotObjectConstant.forObject(reason);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.meta;
 
 import static com.oracle.graal.phases.GraalOptions.*;
+
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.phases.*;
 import com.oracle.graal.java.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionHandle.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionHandle.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,9 +34,9 @@
 
     private final InstalledCode code;
     private final String name;
-    private final Class[] argumentTypes;
+    private final Class<?>[] argumentTypes;
 
-    public HotSpotNativeFunctionHandle(InstalledCode code, String name, Class... argumentTypes) {
+    public HotSpotNativeFunctionHandle(InstalledCode code, String name, Class<?>... argumentTypes) {
         this.argumentTypes = argumentTypes;
         this.name = name;
         this.code = code;
@@ -63,7 +63,7 @@
         assert checkArgs(args);
         try {
             traceCall(args);
-            Object res = code.execute(args, null, null);
+            Object res = code.executeVarargs(args);
             traceResult(res);
             return res;
         } catch (InvalidInstalledCodeException e) {
@@ -76,7 +76,7 @@
         for (int i = 0; i < argumentTypes.length; i++) {
             Object arg = args[i];
             assert arg != null;
-            Class expectedType = argumentTypes[i];
+            Class<?> expectedType = argumentTypes[i];
             if (expectedType.isPrimitive()) {
                 Kind kind = Kind.fromJavaClass(expectedType);
                 expectedType = kind.toBoxedJavaClass();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java	Wed Apr 16 14:02:52 2014 +0200
@@ -86,13 +86,13 @@
     }
 
     @Override
-    public HotSpotNativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, String name, Class returnType, Class... argumentTypes) {
+    public HotSpotNativeFunctionHandle getFunctionHandle(NativeLibraryHandle library, String name, Class<?> returnType, Class<?>... argumentTypes) {
         HotSpotNativeFunctionPointer functionPointer = lookupFunctionPointer(name, library, true);
         return createHandle(functionPointer, returnType, argumentTypes);
     }
 
     @Override
-    public HotSpotNativeFunctionHandle getFunctionHandle(NativeLibraryHandle[] libraries, String name, Class returnType, Class... argumentTypes) {
+    public HotSpotNativeFunctionHandle getFunctionHandle(NativeLibraryHandle[] libraries, String name, Class<?> returnType, Class<?>... argumentTypes) {
         HotSpotNativeFunctionPointer functionPointer = null;
         for (NativeLibraryHandle libraryHandle : libraries) {
             functionPointer = lookupFunctionPointer(name, libraryHandle, false);
@@ -105,7 +105,7 @@
     }
 
     @Override
-    public HotSpotNativeFunctionHandle getFunctionHandle(String name, Class returnType, Class... argumentTypes) {
+    public HotSpotNativeFunctionHandle getFunctionHandle(String name, Class<?> returnType, Class<?>... argumentTypes) {
         if (rtldDefault == null) {
             throw new UnsatisfiedLinkError(name);
         }
@@ -136,14 +136,14 @@
     }
 
     @Override
-    public HotSpotNativeFunctionHandle getFunctionHandle(NativeFunctionPointer functionPointer, Class returnType, Class... argumentTypes) {
+    public HotSpotNativeFunctionHandle getFunctionHandle(NativeFunctionPointer functionPointer, Class<?> returnType, Class<?>... argumentTypes) {
         if (!(functionPointer instanceof HotSpotNativeFunctionPointer)) {
             throw new UnsatisfiedLinkError(functionPointer.getName());
         }
         return createHandle(functionPointer, returnType, argumentTypes);
     }
 
-    private HotSpotNativeFunctionHandle createHandle(NativeFunctionPointer functionPointer, Class returnType, Class... argumentTypes) {
+    private HotSpotNativeFunctionHandle createHandle(NativeFunctionPointer functionPointer, Class<?> returnType, Class<?>... argumentTypes) {
         HotSpotNativeFunctionPointer hs = (HotSpotNativeFunctionPointer) functionPointer;
         InstalledCode code = installNativeFunctionStub(hs.value, returnType, argumentTypes);
         return new HotSpotNativeFunctionHandle(code, hs.name, argumentTypes);
@@ -152,7 +152,7 @@
     /**
      * Creates and installs a stub for calling a native function.
      */
-    private InstalledCode installNativeFunctionStub(long functionPointer, Class returnType, Class... argumentTypes) {
+    private InstalledCode installNativeFunctionStub(long functionPointer, Class<?> returnType, Class<?>... argumentTypes) {
         StructuredGraph g = getGraph(providers, factory, functionPointer, returnType, argumentTypes);
         Suites suites = providers.getSuites().createSuites();
         PhaseSuite<HighTierContext> phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,13 +43,13 @@
 
     /**
      * Creates a graph for a stub used to call a native function.
-     * 
+     *
      * @param functionPointer a native function pointer
      * @param returnType the type of the return value
      * @param argumentTypes the types of the arguments
      * @return the graph that represents the call stub
      */
-    public static StructuredGraph getGraph(HotSpotProviders providers, RawNativeCallNodeFactory factory, long functionPointer, Class returnType, Class... argumentTypes) {
+    public static StructuredGraph getGraph(HotSpotProviders providers, RawNativeCallNodeFactory factory, long functionPointer, Class<?> returnType, Class<?>... argumentTypes) {
         try {
             ResolvedJavaMethod method = providers.getMetaAccess().lookupJavaMethod(NativeCallStubGraphBuilder.class.getMethod("libCall", Object.class, Object.class, Object.class));
             StructuredGraph g = new StructuredGraph(method);
@@ -91,14 +91,14 @@
 
             ReturnNode returnNode = g.add(new ReturnNode(boxedResult));
             callNode.setNext(returnNode);
-            (new WordTypeRewriterPhase(providers.getMetaAccess(), Kind.Long)).apply(g);
+            (new WordTypeRewriterPhase(providers.getMetaAccess(), providers.getSnippetReflection(), Kind.Long)).apply(g);
             return g;
         } catch (NoSuchMethodException e) {
             throw GraalInternalError.shouldNotReachHere("Call Stub method not found");
         }
     }
 
-    private static FixedWithNextNode getParameters(StructuredGraph g, ParameterNode argumentsArray, int numArgs, Class[] argumentTypes, List<ValueNode> args, HotSpotProviders providers) {
+    private static FixedWithNextNode getParameters(StructuredGraph g, ParameterNode argumentsArray, int numArgs, Class<?>[] argumentTypes, List<ValueNode> args, HotSpotProviders providers) {
         assert numArgs == argumentTypes.length;
         FixedWithNextNode last = null;
         for (int i = 0; i < numArgs; i++) {
@@ -111,7 +111,7 @@
                 last.setNext(boxedElement);
                 last = boxedElement;
             }
-            Class type = argumentTypes[i];
+            Class<?> type = argumentTypes[i];
             Kind kind = getKind(type);
             if (kind == Kind.Object) {
                 // array value
@@ -140,8 +140,8 @@
         return last;
     }
 
-    public static Kind getElementKind(Class clazz) {
-        Class componentType = clazz.getComponentType();
+    public static Kind getElementKind(Class<?> clazz) {
+        Class<?> componentType = clazz.getComponentType();
         if (componentType == null) {
             throw new IllegalArgumentException("Parameter type not supported: " + clazz);
         }
@@ -151,7 +151,7 @@
         throw new IllegalArgumentException("Parameter type not supported: " + clazz);
     }
 
-    private static Kind getKind(Class clazz) {
+    private static Kind getKind(Class<?> clazz) {
         if (clazz == int.class || clazz == Integer.class) {
             return Kind.Int;
         } else if (clazz == long.class || clazz == Long.class) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,6 +26,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
@@ -37,6 +38,7 @@
  * is locked (ensuring the GC sees and updates the object) so it must come after any null pointer
  * check on the object.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public final class BeginLockScopeNode extends AbstractMemoryCheckpoint implements LIRGenLowerable, MonitorEnter, MemoryCheckpoint.Single {
 
     private int lockDepth;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -53,7 +53,7 @@
 
     /**
      * Converts a string to a null terminated byte array of ASCII characters.
-     * 
+     *
      * @param s a String that must only contain ASCII characters
      */
     public static byte[] toCString(String s) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassCastNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassCastNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
             ValueNode object = getObject();
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null && !c.isPrimitive()) {
                 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(c);
                 CheckCastNode checkcast = graph().add(new CheckCastNode(type, object, null, false));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetComponentTypeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetComponentTypeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
 
 /**
  * {@link MacroNode Macro node} for {@link Class#getComponentType()}.
- * 
+ *
  * @see ClassSubstitutions#getComponentType(Class)
  */
 public class ClassGetComponentTypeNode extends MacroNode implements Canonicalizable {
@@ -47,10 +48,10 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
-                Class componentType = c.getComponentType();
-                return ConstantNode.forObject(componentType, tool.getMetaAccess(), graph());
+                Class<?> componentType = c.getComponentType();
+                return ConstantNode.forConstant(HotSpotObjectConstant.forObject(componentType), tool.getMetaAccess(), graph());
             }
         }
         return this;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetModifiersNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetModifiersNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -47,7 +48,7 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
                 return ConstantNode.forInt(c.getModifiers(), graph());
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetSuperclassNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetSuperclassNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
 
 /**
  * {@link MacroNode Macro node} for {@link Class#getSuperclass()}.
- * 
+ *
  * @see ClassSubstitutions#getSuperclass(Class)
  */
 public class ClassGetSuperclassNode extends MacroNode implements Canonicalizable {
@@ -47,10 +48,10 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
-                Class superclass = c.getSuperclass();
-                return ConstantNode.forObject(superclass, tool.getMetaAccess(), graph());
+                Class<?> superclass = c.getSuperclass();
+                return ConstantNode.forConstant(HotSpotObjectConstant.forObject(superclass), tool.getMetaAccess(), graph());
             }
         }
         return this;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsArrayNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsArrayNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -47,7 +48,7 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
                 return ConstantNode.forBoolean(c.isArray(), graph());
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInstanceNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInstanceNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,13 +55,13 @@
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
             ValueNode object = getObject();
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
                 if (c.isPrimitive()) {
                     return ConstantNode.forBoolean(false, graph());
                 }
                 if (object.isConstant()) {
-                    Object o = object.asConstant().asObject();
+                    Object o = HotSpotObjectConstant.asObject(object.asConstant());
                     return ConstantNode.forBoolean(o != null && c.isInstance(o), graph());
                 }
                 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(c);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInterfaceNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInterfaceNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -47,7 +48,7 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
                 return ConstantNode.forBoolean(c.isInterface(), graph());
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsPrimitiveNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsPrimitiveNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -47,7 +48,7 @@
     public Node canonical(CanonicalizerTool tool) {
         ValueNode javaClass = getJavaClass();
         if (javaClass.isConstant()) {
-            Class c = (Class) javaClass.asConstant().asObject();
+            Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(javaClass.asConstant());
             if (c != null) {
                 return ConstantNode.forBoolean(c.isPrimitive(), graph());
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -105,13 +105,21 @@
     @Override
     public void generate(NodeLIRBuilderTool gen) {
         HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen.getLIRGeneratorTool();
+        boolean nonNull;
+        if (input.stamp() instanceof ObjectStamp) {
+            nonNull = ObjectStamp.isObjectNonNull(input.stamp());
+        } else {
+            // metaspace pointers are never null
+            nonNull = true;
+        }
+
         Value result;
         switch (op) {
             case Compress:
-                result = hsGen.emitCompress(gen.operand(input), encoding);
+                result = hsGen.emitCompress(gen.operand(input), encoding, nonNull);
                 break;
             case Uncompress:
-                result = hsGen.emitUncompress(gen.operand(input), encoding);
+                result = hsGen.emitUncompress(gen.operand(input), encoding, nonNull);
                 break;
             default:
                 throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,10 +25,12 @@
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.word.*;
 
 /**
@@ -36,8 +38,8 @@
  */
 public final class CurrentJavaThreadNode extends FloatingNode implements LIRLowerable {
 
-    private CurrentJavaThreadNode() {
-        super(null);
+    private CurrentJavaThreadNode(Kind kind) {
+        super(StampFactory.forKind(kind));
     }
 
     @Override
@@ -55,7 +57,7 @@
     }
 
     @NodeIntrinsic(setStampFromReturnType = true)
-    public static Word get() {
+    public static Word get(@SuppressWarnings("unused") @ConstantNodeParameter Kind kind) {
         return Word.unsigned(unsafeReadWord(Thread.currentThread(), eetopOffset()));
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectCompareAndSwapNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectCompareAndSwapNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
@@ -37,6 +38,7 @@
  * {@linkplain #compareAndSwap(Object, long, Word, Word, LocationIdentity)} returns either the
  * expected value or the compared against value instead of a boolean.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class DirectCompareAndSwapNode extends FixedWithNextNode implements LIRGenLowerable, MemoryCheckpoint.Single {
 
     @Input private ValueNode object;
@@ -86,7 +88,7 @@
      * given offset. Iff they are same, {@code newValue} is placed into the location and the
      * {@code expectedValue} is returned. Otherwise, the actual value is returned. All of the above
      * is performed in one atomic hardware transaction.
-     * 
+     *
      * @param object the object containing a field to be atomically tested and updated
      * @param offset offset from {@code object} of the field
      * @param expectedValue if this value is currently in the field, perform the swap
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EndLockScopeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EndLockScopeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.hotspot.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
@@ -32,6 +33,7 @@
  * Intrinsic for closing a {@linkplain BeginLockScopeNode scope} binding a stack-based lock with an
  * object.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public final class EndLockScopeNode extends AbstractMemoryCheckpoint implements LIRLowerable, MonitorExit, MemoryCheckpoint.Single {
 
     public EndLockScopeNode() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/EnterUnpackFramesStackFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.*;
+
+/**
+ * Emits code to enter a low-level stack frame specifically to call out to the C++ method
+ * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}.
+ */
+public class EnterUnpackFramesStackFrameNode extends FixedWithNextNode implements LIRLowerable {
+
+    @Input private ValueNode framePc;
+    @Input private ValueNode senderSp;
+    @Input private ValueNode senderFp;
+
+    public EnterUnpackFramesStackFrameNode(ValueNode framePc, ValueNode senderSp, ValueNode senderFp) {
+        super(StampFactory.forVoid());
+        this.framePc = framePc;
+        this.senderSp = senderSp;
+        this.senderFp = senderFp;
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        Value operandValue = gen.operand(framePc);
+        Value senderSpValue = gen.operand(senderSp);
+        Value senderFpValue = gen.operand(senderFp);
+        ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitEnterUnpackFramesStackFrame(operandValue, senderSpValue, senderFpValue);
+    }
+
+    @NodeIntrinsic
+    public static native void enterUnpackFramesStackFrame(Word framePc, Word senderSp, Word senderFp);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1PreWriteBarrier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1PreWriteBarrier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,12 +22,13 @@
  */
 package com.oracle.graal.hotspot.nodes;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 
 public class G1PreWriteBarrier extends WriteBarrier implements DeoptimizingNode.DeoptBefore {
 
-    @Input private FrameState stateBefore;
+    @Input(InputType.State) private FrameState stateBefore;
     private final boolean nullCheck;
     private final boolean doLoad;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveCurrentStackFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Emits code to leave (pop) the current low-level stack frame. This operation also removes the
+ * return address if its location is on the stack.
+ */
+public class LeaveCurrentStackFrameNode extends FixedWithNextNode implements LIRLowerable {
+
+    public LeaveCurrentStackFrameNode() {
+        super(StampFactory.forVoid());
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitLeaveCurrentStackFrame();
+    }
+
+    @NodeIntrinsic
+    public static native void leaveCurrentStackFrame();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveDeoptimizedStackFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.*;
+
+/**
+ * Emits code to leave (pop) the current low-level stack frame which is being deoptimized. This node
+ * is only used in {@link DeoptimizationStub}.
+ */
+public class LeaveDeoptimizedStackFrameNode extends FixedWithNextNode implements LIRLowerable {
+
+    @Input private ValueNode frameSize;
+    @Input private ValueNode initialInfo;
+
+    public LeaveDeoptimizedStackFrameNode(ValueNode frameSize, ValueNode initialInfo) {
+        super(StampFactory.forVoid());
+        this.frameSize = frameSize;
+        this.initialInfo = initialInfo;
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        Value frameSizeValue = gen.operand(frameSize);
+        Value initialInfoValue = gen.operand(initialInfo);
+        ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitLeaveDeoptimizedStackFrame(frameSizeValue, initialInfoValue);
+    }
+
+    @NodeIntrinsic
+    public static native void leaveDeoptimizedStackFrame(int frameSize, Word initialInfo);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LeaveUnpackFramesStackFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Emits code to leave a low-level stack frame specifically to call out to the C++ method
+ * {@link DeoptimizationStub#UNPACK_FRAMES Deoptimization::unpack_frames}.
+ */
+public class LeaveUnpackFramesStackFrameNode extends FixedWithNextNode implements LIRLowerable {
+
+    public LeaveUnpackFramesStackFrameNode() {
+        super(StampFactory.forVoid());
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitLeaveUnpackFramesStackFrame();
+    }
+
+    @NodeIntrinsic
+    public static native void leaveUnpackFramesStackFrame();
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.hotspot.nodes;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.gen.*;
-import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.word.*;
-
-/**
- * Node implementing a call to {@code GraalRuntime::monitorexit}.
- */
-public class MonitorExitStubCall extends DeoptimizingStubCall implements LIRGenLowerable {
-
-    @Input private ValueNode object;
-    private int lockDepth;
-    public static final ForeignCallDescriptor MONITOREXIT = new ForeignCallDescriptor("monitorexit", void.class, Object.class, Word.class);
-
-    public MonitorExitStubCall(ValueNode object, int lockDepth) {
-        super(StampFactory.forVoid());
-        this.object = object;
-        this.lockDepth = lockDepth;
-    }
-
-    @Override
-    public void generate(NodeLIRBuilder gen) {
-        assert lockDepth != -1;
-        HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen.getLIRGeneratorTool();
-        StackSlot slot = hsGen.getLockSlot(lockDepth);
-        ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(MonitorExitStubCall.MONITOREXIT);
-        gen.getLIRGeneratorTool().emitForeignCall(linkage, this, gen.operand(object), gen.getLIRGeneratorTool().emitAddress(slot));
-    }
-
-    @NodeIntrinsic
-    public static native void call(Object object, @ConstantNodeParameter int lockDepth);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/PushInterpreterFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.*;
+
+/**
+ * A call to the runtime code implementing the uncommon trap logic.
+ */
+public class PushInterpreterFrameNode extends FixedWithNextNode implements LIRLowerable {
+
+    @Input private ValueNode framePc;
+    @Input private ValueNode frameSize;
+    @Input private ValueNode senderSp;
+    @Input private ValueNode initialInfo;
+
+    public PushInterpreterFrameNode(ValueNode frameSize, ValueNode framePc, ValueNode senderSp, ValueNode initialInfo) {
+        super(StampFactory.forVoid());
+        this.frameSize = frameSize;
+        this.framePc = framePc;
+        this.senderSp = senderSp;
+        this.initialInfo = initialInfo;
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        Value frameSizeValue = gen.operand(frameSize);
+        Value framePcValue = gen.operand(framePc);
+        Value senderSpValue = gen.operand(senderSp);
+        Value initialInfoValue = gen.operand(initialInfo);
+        ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitPushInterpreterFrame(frameSizeValue, framePcValue, senderSpValue, initialInfoValue);
+    }
+
+    @NodeIntrinsic
+    public static native void pushInterpreterFrame(Word frameSize, Word framePc, Word senderSp, Word initialInfo);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SaveAllRegistersNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Saves all allocatable registers.
+ */
+public class SaveAllRegistersNode extends FixedWithNextNode implements LIRLowerable {
+
+    private SaveRegistersOp saveRegistersOp;
+
+    public SaveAllRegistersNode() {
+        super(StampFactory.forKind(Kind.Long));
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        saveRegistersOp = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitSaveAllRegisters();
+    }
+
+    /**
+     * @return the map from registers to the stack locations in they are saved
+     */
+    public SaveRegistersOp getSaveRegistersOp() {
+        assert saveRegistersOp != null : "saved registers op has not yet been created";
+        return saveRegistersOp;
+    }
+
+    /**
+     * @return a token that couples this node to an {@link UncommonTrapCallNode} so that the latter
+     *         has access to the {@linkplain SaveRegistersOp#getMap register save map}
+     */
+    @NodeIntrinsic
+    public static native long saveAllRegisters();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetAnchorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Value, InputType.Anchor, InputType.Guard})
+public final class SnippetAnchorNode extends FixedWithNextNode implements Simplifiable, GuardingNode {
+
+    public SnippetAnchorNode() {
+        super(StampFactory.object());
+    }
+
+    @Override
+    public void simplify(SimplifierTool tool) {
+        AbstractBeginNode prevBegin = BeginNode.prevBegin(this);
+        replaceAtUsages(InputType.Anchor, prevBegin);
+        replaceAtUsages(InputType.Guard, prevBegin);
+        if (usages().isEmpty()) {
+            graph().removeFixed(this);
+        }
+    }
+
+    @NodeIntrinsic
+    public static native GuardingNode anchor();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetLocationProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Association, InputType.Value})
+public final class SnippetLocationProxyNode extends FloatingNode implements Canonicalizable {
+
+    @Input(InputType.Unchecked) private ValueNode location;
+
+    public SnippetLocationProxyNode(ValueNode location) {
+        super(StampFactory.object());
+        this.location = location;
+    }
+
+    @Override
+    public Node canonical(CanonicalizerTool tool) {
+        return location.isAllowedUsageType(InputType.Association) ? location : this;
+    }
+
+    @NodeIntrinsic
+    public static native GuardingNode location(Object location);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/StubForeignCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/StubForeignCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,7 @@
 /**
  * Node for a {@linkplain ForeignCallDescriptor foreign} call from within a stub.
  */
-@NodeInfo(nameTemplate = "StubForeignCall#{p#descriptor/s}")
+@NodeInfo(nameTemplate = "StubForeignCall#{p#descriptor/s}", allowedUsageTypes = {InputType.Memory})
 public class StubForeignCallNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Multi {
 
     @Input private final NodeInputList<ValueNode> arguments;
@@ -68,7 +68,7 @@
     @Override
     public void generate(NodeLIRBuilderTool gen) {
         assert graph().start() instanceof StubStartNode;
-        ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(descriptor);
+        ForeignCallLinkage linkage = foreignCalls.lookupForeignCall(descriptor);
         Value[] operands = operands(gen);
         Value result = gen.getLIRGeneratorTool().emitForeignCall(linkage, null, operands);
         if (result != null) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,6 +31,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
@@ -43,12 +44,12 @@
  */
 public class TailcallNode extends FixedWithNextNode implements LIRGenResLowerable {
 
-    @Input private FrameState frameState;
+    @Input(InputType.State) private FrameState frameState;
     @Input private ValueNode target;
 
     /**
      * Creates a TailcallNode.
-     * 
+     *
      * @param target points to the start of an nmethod
      * @param frameState the parameters will be taken from this FrameState
      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/UncommonTrapCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.word.*;
+
+/**
+ * A call to the runtime code implementing the uncommon trap logic.
+ */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
+public class UncommonTrapCallNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Multi {
+
+    @Input private ValueNode trapRequest;
+    @Input private SaveAllRegistersNode registerSaver;
+    private final ForeignCallsProvider foreignCalls;
+    public static final ForeignCallDescriptor UNCOMMON_TRAP = new ForeignCallDescriptor("uncommonTrap", Word.class, Word.class, int.class);
+
+    public UncommonTrapCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ValueNode registerSaver, ValueNode trapRequest) {
+        super(StampFactory.forKind(Kind.fromJavaClass(UNCOMMON_TRAP.getResultType())));
+        this.trapRequest = trapRequest;
+        this.registerSaver = (SaveAllRegistersNode) registerSaver;
+        this.foreignCalls = foreignCalls;
+    }
+
+    @Override
+    public LocationIdentity[] getLocationIdentities() {
+        return foreignCalls.getKilledLocations(UNCOMMON_TRAP);
+    }
+
+    public SaveRegistersOp getSaveRegistersOp() {
+        return registerSaver.getSaveRegistersOp();
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        Value trapRequestValue = gen.operand(trapRequest);
+        Value result = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitUncommonTrapCall(trapRequestValue, getSaveRegistersOp());
+        gen.setResult(this, result);
+    }
+
+    @NodeIntrinsic
+    public static native Word uncommonTrap(long registerSaver, int trapRequest);
+
+    public MemoryCheckpoint asMemoryCheckpoint() {
+        return null;
+    }
+
+    public MemoryPhiNode asMemoryPhi() {
+        return null;
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.nodes;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
@@ -31,7 +32,7 @@
 
     @Input private ValueNode object;
     @Input private ValueNode value;
-    @Input private LocationNode location;
+    @Input(InputType.Association) private LocationNode location;
     private final boolean precise;
 
     public WriteBarrier(ValueNode object, ValueNode value, LocationNode location, boolean precise) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -66,6 +66,11 @@
     }
 
     @Override
+    public Stamp illegal() {
+        return new NarrowOopStamp((ObjectStamp) super.illegal(), encoding);
+    }
+
+    @Override
     public Kind getStackKind() {
         return Kind.Object;
     }
@@ -88,11 +93,8 @@
         if (this == otherStamp) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.meet(this);
-        }
         if (!isCompatible(otherStamp)) {
-            return StampFactory.illegal(Kind.Illegal);
+            return StampFactory.illegal();
         }
         return new NarrowOopStamp((ObjectStamp) super.meet(otherStamp), encoding);
     }
@@ -102,9 +104,6 @@
         if (this == otherStamp) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.join(this);
-        }
         if (!isCompatible(otherStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.nodes.ConstantNode.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.tiers.*;
@@ -57,7 +58,7 @@
     }
 
     private static boolean isNullReference(ConstantNode node) {
-        return isObject(node) && node.asConstant().asObject() == null;
+        return isObject(node) && node.asConstant().isNull();
     }
 
     @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "reference equality is what we want")
@@ -66,7 +67,7 @@
             return false;
         }
 
-        Object o = node.asConstant().asObject();
+        Object o = HotSpotObjectConstant.asObject(node.asConstant());
         if (!(o instanceof String)) {
             return false;
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/LoadJavaMirrorWithKlassPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,9 +54,9 @@
     }
 
     private FloatingReadNode getClassConstantReplacement(StructuredGraph graph, PhaseContext context, Constant constant) {
-        if (constant.getKind() == Kind.Object && constant.asObject() instanceof Class<?>) {
+        if (constant.getKind() == Kind.Object && HotSpotObjectConstant.asObject(constant) instanceof Class<?>) {
             MetaAccessProvider metaAccess = context.getMetaAccess();
-            ResolvedJavaType type = metaAccess.lookupJavaType((Class<?>) constant.asObject());
+            ResolvedJavaType type = metaAccess.lookupJavaType((Class<?>) HotSpotObjectConstant.asObject(constant));
             assert type instanceof HotSpotResolvedObjectType;
 
             Constant klass = ((HotSpotResolvedObjectType) type).klass();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AbstractMethodHandleNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AbstractMethodHandleNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -162,7 +162,7 @@
         Constant vmtarget = memberNameVmtargetField.readValue(memberName);
 
         // Create a method from the vmtarget pointer
-        Class<?> c = (Class<?>) clazz.asObject();
+        Class<?> c = (Class<?>) HotSpotObjectConstant.asObject(clazz);
         HotSpotResolvedObjectType holderClass = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(c);
         HotSpotResolvedJavaMethod targetMethod = HotSpotResolvedJavaMethod.fromMetaspace(vmtarget.asLong());
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.*;
@@ -38,6 +39,7 @@
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
 import com.oracle.graal.runtime.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public final class ArrayCopyCallNode extends ArrayRangeWriteNode implements Lowerable, MemoryCheckpoint.Single {
 
     @Input private ValueNode src;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopySnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,34 +26,20 @@
 import static com.oracle.graal.nodes.GuardingPiNode.*;
 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
 import static com.oracle.graal.phases.GraalOptions.*;
-import static com.oracle.graal.replacements.SnippetTemplate.*;
 
 import java.lang.reflect.*;
 import java.util.*;
 
-import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
-import com.oracle.graal.loop.phases.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.Snippet.Fold;
-import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
-import com.oracle.graal.replacements.SnippetTemplate.Arguments;
-import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo;
 import com.oracle.graal.word.*;
 
-@SuppressWarnings("unused")
 public class ArrayCopySnippets implements Snippets {
 
     private static final EnumMap<Kind, Method> arraycopyMethods = new EnumMap<>(Kind.class);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CRC32Substitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CRC32Substitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,8 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.Snippet.Fold;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -44,7 +45,7 @@
 
     private ConstantNode getConstantCallTarget(MetaAccessProvider metaAccess, Assumptions assumptions) {
         if (getCallSite().isConstant() && !getCallSite().isNullConstant()) {
-            CallSite callSite = (CallSite) getCallSite().asConstant().asObject();
+            CallSite callSite = (CallSite) HotSpotObjectConstant.asObject(getCallSite().asConstant());
             MethodHandle target = callSite.getTarget();
             if (!(callSite instanceof ConstantCallSite)) {
                 if (assumptions == null || !assumptions.useOptimisticAssumptions()) {
@@ -52,7 +53,7 @@
                 }
                 assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target));
             }
-            return ConstantNode.forObject(target, metaAccess, graph());
+            return ConstantNode.forConstant(HotSpotObjectConstant.forObject(target), metaAccess, graph());
         }
         return null;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CheckCastDynamicSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,11 +32,13 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
@@ -53,13 +55,13 @@
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
         } else {
-            BeginNode anchorNode = BeginNode.anchor();
+            GuardingNode anchorNode = SnippetAnchorNode.anchor();
             Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
             if (!checkUnknownSubType(hub, objectHub)) {
                 DeoptimizeNode.deopt(InvalidateReprofile, ClassCastException);
             }
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         return piCast(verifyOop(object), StampFactory.forNodeIntrinsic(), anchorNode);
     }
 
@@ -67,8 +69,8 @@
 
         private final SnippetInfo dynamic = snippet(CheckCastDynamicSnippets.class, "checkcastDynamic");
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
         }
 
         public void lower(CheckCastDynamicNode checkcast, LoweringTool tool) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -63,35 +63,12 @@
     }
 
     @Fold
-    private static Class getAESCryptClass() {
+    private static Class<?> getAESCryptClass() {
         return AESCryptSubstitutions.AESCryptClass;
     }
 
-    @MethodSubstitution(isStatic = false, optional = true)
-    static void encrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
-        Object embeddedCipher = UnsafeLoadNode.load(rcvr, embeddedCipherOffset, Kind.Object, LocationIdentity.ANY_LOCATION);
-        if (getAESCryptClass().isInstance(embeddedCipher)) {
-            Object aesCipher = PiNode.piCastNonNull(embeddedCipher, AESCryptSubstitutions.AESCryptClass);
-            crypt(rcvr, in, inOffset, inLength, out, outOffset, aesCipher, true);
-        } else {
-            encrypt(rcvr, in, inOffset, inLength, out, outOffset);
-        }
-    }
-
-    @MethodSubstitution(isStatic = false, optional = true)
-    static void decrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
-        Object realReceiver = PiNode.piCastNonNull(rcvr, cipherBlockChainingClass);
-        Object embeddedCipher = UnsafeLoadNode.load(realReceiver, embeddedCipherOffset, Kind.Object, LocationIdentity.ANY_LOCATION);
-        if (in != out && getAESCryptClass().isInstance(embeddedCipher)) {
-            Object aesCipher = PiNode.piCastNonNull(embeddedCipher, AESCryptSubstitutions.AESCryptClass);
-            crypt(realReceiver, in, inOffset, inLength, out, outOffset, aesCipher, false);
-        } else {
-            decrypt(realReceiver, in, inOffset, inLength, out, outOffset);
-        }
-    }
-
-    @MethodSubstitution(value = "encrypt", isStatic = false, optional = true)
-    static int encryptInt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
+    @MethodSubstitution(isStatic = false)
+    static int encrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
         Object realReceiver = PiNode.piCastNonNull(rcvr, cipherBlockChainingClass);
         Object embeddedCipher = UnsafeLoadNode.load(realReceiver, embeddedCipherOffset, Kind.Object, LocationIdentity.ANY_LOCATION);
         if (getAESCryptClass().isInstance(embeddedCipher)) {
@@ -99,12 +76,12 @@
             crypt(realReceiver, in, inOffset, inLength, out, outOffset, aesCipher, true);
             return inLength;
         } else {
-            return encryptInt(realReceiver, in, inOffset, inLength, out, outOffset);
+            return encrypt(realReceiver, in, inOffset, inLength, out, outOffset);
         }
     }
 
-    @MethodSubstitution(value = "decrypt", isStatic = false, optional = true)
-    static int decryptInt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
+    @MethodSubstitution(isStatic = false)
+    static int decrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) {
         Object realReceiver = PiNode.piCastNonNull(rcvr, cipherBlockChainingClass);
         Object embeddedCipher = UnsafeLoadNode.load(realReceiver, embeddedCipherOffset, Kind.Object, LocationIdentity.ANY_LOCATION);
         if (in != out && getAESCryptClass().isInstance(embeddedCipher)) {
@@ -112,7 +89,7 @@
             crypt(realReceiver, in, inOffset, inLength, out, outOffset, aesCipher, false);
             return inLength;
         } else {
-            return decryptInt(realReceiver, in, inOffset, inLength, out, outOffset);
+            return decrypt(realReceiver, in, inOffset, inLength, out, outOffset);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompositeValueClassSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.replacements;
+
+import static com.oracle.graal.phases.GraalOptions.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.nodes.*;
+
+/**
+ * Substitutions for improving the performance of {@link CompositeValueClass#getClass()}.
+ */
+@ClassSubstitution(CompositeValueClass.class)
+public class CompositeValueClassSubstitutions {
+
+    /**
+     * A macro node for calls to {@link CompositeValueClass#get(Class)}. It can use the compiler's
+     * knowledge about node classes to replace itself with a constant value for a constant
+     * {@link Class} parameter.
+     */
+    public static class CompositeValueClassGetNode extends PureFunctionMacroNode {
+
+        public CompositeValueClassGetNode(Invoke invoke) {
+            super(invoke);
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
+            if (param.isNull() || ImmutableCode.getValue()) {
+                return null;
+            }
+            return HotSpotObjectConstant.forObject(CompositeValueClass.get((Class<? extends CompositeValue>) HotSpotObjectConstant.asObject(param)));
+        }
+    }
+
+    @MacroSubstitution(isStatic = true, forced = true, macro = CompositeValueClassGetNode.class)
+    private static native CompositeValueClass get(Class<?> c);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeClassSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.replacements;
+
+import static com.oracle.graal.phases.GraalOptions.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.nodes.*;
+
+/**
+ * Substitutions for improving the performance of {@link NodeClass#get}.
+ */
+@ClassSubstitution(NodeClass.class)
+public class HotSpotNodeClassSubstitutions {
+
+    /**
+     * A macro node for calls to {@link NodeClass#get(Class)}. It can use the compiler's knowledge
+     * about node classes to replace itself with a constant value for a constant {@link Class}
+     * parameter.
+     */
+    public static class NodeClassGetNode extends PureFunctionMacroNode {
+
+        public NodeClassGetNode(Invoke invoke) {
+            super(invoke);
+        }
+
+        @Override
+        protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
+            if (param.isNull() || ImmutableCode.getValue()) {
+                return null;
+            }
+            return HotSpotObjectConstant.forObject(NodeClass.get((Class<?>) HotSpotObjectConstant.asObject(param)));
+        }
+    }
+
+    /**
+     * NOTE: A {@link MethodSubstitution} similar to
+     * {@link HotSpotNodeSubstitutions#getNodeClass(Node)} is not possible here because there is no
+     * guarantee that {@code c} is initialized (accessing a Class literal in Java is not a class
+     * initialization barrier).
+     */
+    @MacroSubstitution(isStatic = true, forced = true, macro = NodeClassGetNode.class)
+    public static native NodeClass get(Class<?> c);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotNodeSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.replacements;
+
+import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
+import static com.oracle.graal.nodes.PiNode.*;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.word.*;
+
+@ClassSubstitution(Node.class)
+public class HotSpotNodeSubstitutions {
+
+    /**
+     * Gets the value of the {@code InstanceKlass::_graal_node_class} field from the InstanceKlass
+     * pointed to by {@code node}'s header.
+     */
+    @MethodSubstitution(isStatic = false)
+    public static NodeClass getNodeClass(final Node node) {
+        // HotSpot creates the NodeClass for each Node subclass while initializing it
+        // so we are guaranteed to read a non-null value here. As long as NodeClass
+        // is final, the stamp of the PiNode below will automatically be exact.
+        Word klass = loadHub(node);
+        return piCastNonNull(klass.readObject(Word.signed(klassNodeClassOffset()), KLASS_NODE_CLASS), NodeClass.class);
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -80,6 +80,20 @@
         return config().threadExceptionPcOffset;
     }
 
+    public static final LocationIdentity LAST_JAVA_PC_LOCATION = new NamedLocationIdentity("LastJavaPc");
+
+    @Fold
+    public static int threadLastJavaPcOffset() {
+        return config().threadLastJavaPcOffset();
+    }
+
+    public static final LocationIdentity LAST_JAVA_FP_LOCATION = new NamedLocationIdentity("LastJavaFp");
+
+    @Fold
+    public static int threadLastJavaFpOffset() {
+        return config().threadLastJavaFpOffset();
+    }
+
     public static final LocationIdentity TLAB_TOP_LOCATION = new NamedLocationIdentity("TlabTop");
 
     @Fold
@@ -111,6 +125,16 @@
         return config().pendingExceptionOffset;
     }
 
+    public static final LocationIdentity PENDING_DEOPTIMIZATION_LOCATION = new NamedLocationIdentity("PendingDeoptimization");
+
+    /**
+     * @see HotSpotVMConfig#pendingDeoptimizationOffset
+     */
+    @Fold
+    private static int threadPendingDeoptimizationOffset() {
+        return config().pendingDeoptimizationOffset;
+    }
+
     public static final LocationIdentity OBJECT_RESULT_LOCATION = new NamedLocationIdentity("ObjectResult");
 
     @Fold
@@ -140,6 +164,14 @@
         thread.writeWord(threadExceptionPcOffset(), value, EXCEPTION_PC_LOCATION);
     }
 
+    public static void writeLastJavaPc(Word thread, Word value) {
+        thread.writeWord(threadLastJavaPcOffset(), value, LAST_JAVA_PC_LOCATION);
+    }
+
+    public static void writeLastJavaFp(Word thread, Word value) {
+        thread.writeWord(threadLastJavaFpOffset(), value, LAST_JAVA_FP_LOCATION);
+    }
+
     public static Word readTlabTop(Word thread) {
         return thread.readWord(threadTlabTopOffset(), TLAB_TOP_LOCATION);
     }
@@ -164,7 +196,7 @@
 
     /**
      * Clears the pending exception for the given thread.
-     * 
+     *
      * @return {@code true} if there was a pending exception
      */
     public static boolean clearPendingException(Word thread) {
@@ -174,8 +206,24 @@
     }
 
     /**
+     * Reads the pending deoptimization value for the given thread.
+     * 
+     * @return {@code true} if there was a pending deoptimization
+     */
+    public static int readPendingDeoptimization(Word thread) {
+        return thread.readInt(threadPendingDeoptimizationOffset(), PENDING_DEOPTIMIZATION_LOCATION);
+    }
+
+    /**
+     * Writes the pending deoptimization value for the given thread.
+     */
+    public static void writePendingDeoptimization(Word thread, int value) {
+        thread.writeInt(threadPendingDeoptimizationOffset(), value, PENDING_DEOPTIMIZATION_LOCATION);
+    }
+
+    /**
      * Gets and clears the object result from a runtime call stored in a thread local.
-     * 
+     *
      * @return the object that was in the thread local
      */
     public static Object getAndClearObjectResult(Word thread) {
@@ -247,9 +295,9 @@
 
     /**
      * Checks if class {@code klass} is an array.
-     * 
+     *
      * See: Klass::layout_helper_is_array
-     * 
+     *
      * @param klass the class to be checked
      * @return true if klass is an array, false otherwise
      */
@@ -299,13 +347,13 @@
 
     /**
      * Mask for a biasable, locked or unlocked mark word.
-     * 
+     *
      * <pre>
      * +----------------------------------+-+-+
      * |                                 1|1|1|
      * +----------------------------------+-+-+
      * </pre>
-     * 
+     *
      */
     @Fold
     public static int biasedLockMaskInPlace() {
@@ -319,13 +367,13 @@
 
     /**
      * Pattern for a biasable, unlocked mark word.
-     * 
+     *
      * <pre>
      * +----------------------------------+-+-+
      * |                                 1|0|1|
      * +----------------------------------+-+-+
      * </pre>
-     * 
+     *
      */
     @Fold
     public static int biasedLockPattern() {
@@ -467,7 +515,7 @@
      * Loads the hub of an object (without null checking it first).
      */
     public static Word loadHub(Object object) {
-        return loadHubIntrinsic(object, getWordKind(), null);
+        return loadHubIntrinsic(object, getWordKind());
     }
 
     public static Object verifyOop(Object object) {
@@ -487,7 +535,7 @@
 
     /**
      * Reads the value of a given register.
-     * 
+     *
      * @param register a register which must not be available to the register allocator
      * @return the value of {@code register} as a word
      */
@@ -498,6 +546,9 @@
     @NodeIntrinsic(value = ReadRegisterNode.class, setStampFromReturnType = true)
     public static native Word registerAsWord(@ConstantNodeParameter Register register, @ConstantNodeParameter boolean directUse, @ConstantNodeParameter boolean incoming);
 
+    @NodeIntrinsic(value = WriteRegisterNode.class, setStampFromReturnType = true)
+    public static native void writeRegisterAsWord(@ConstantNodeParameter Register register, Word value);
+
     @SuppressWarnings("unused")
     @NodeIntrinsic(value = UnsafeLoadNode.class, setStampFromReturnType = true)
     private static Word loadWordFromObjectIntrinsic(Object object, long offset, @ConstantNodeParameter Kind wordKind, @ConstantNodeParameter LocationIdentity locationIdentity) {
@@ -510,6 +561,12 @@
         return Word.unsigned(unsafeReadKlassPointer(object));
     }
 
+    @SuppressWarnings("unused")
+    @NodeIntrinsic(value = LoadHubNode.class, setStampFromReturnType = true)
+    public static Word loadHubIntrinsic(Object object, @ConstantNodeParameter Kind word) {
+        return Word.unsigned(unsafeReadKlassPointer(object));
+    }
+
     @Fold
     public static int log2WordSize() {
         return CodeUtil.log2(wordSize());
@@ -550,6 +607,13 @@
         return config().arrayKlassOffset;
     }
 
+    public static final LocationIdentity KLASS_NODE_CLASS = new NamedLocationIdentity("KlassNodeClass");
+
+    @Fold
+    public static int klassNodeClassOffset() {
+        return config().klassNodeClassOffset;
+    }
+
     @Fold
     public static int classMirrorOffset() {
         return config().classMirrorOffset;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -42,5 +42,8 @@
         replacements.registerSubstitutions(CipherBlockChainingSubstitutions.class);
         replacements.registerSubstitutions(CRC32Substitutions.class);
         replacements.registerSubstitutions(ReflectionSubstitutions.class);
+        replacements.registerSubstitutions(HotSpotNodeClassSubstitutions.class);
+        replacements.registerSubstitutions(HotSpotNodeSubstitutions.class);
+        replacements.registerSubstitutions(CompositeValueClassSubstitutions.class);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,13 +34,14 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.Hints;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.options.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.ConstantParameter;
 import com.oracle.graal.replacements.Snippet.VarargsParameter;
@@ -52,7 +53,7 @@
 /**
  * Snippets used for implementing the type test of an instanceof instruction. Since instanceof is a
  * floating node, it is lowered separately for each of its usages.
- * 
+ *
  * The type tests implemented are described in the paper <a
  * href="http://dl.acm.org/citation.cfm?id=583821"> Fast subtype checking in the HotSpot JVM</a> by
  * Cliff Click and John Rose.
@@ -75,7 +76,7 @@
     /**
      * A test against a set of hints derived from a profile with very close to 100% precise coverage
      * of seen types. This snippet deoptimizes on hint miss paths.
-     * 
+     *
      * @see #hintHitProbabilityThresholdForDeoptimizingSnippet()
      */
     @Snippet
@@ -90,7 +91,7 @@
             }
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
@@ -119,7 +120,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (probability(LIKELY_PROBABILITY, objectHub.notEqual(exactHub))) {
             exactMiss.inc();
@@ -138,7 +139,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (probability(NOT_LIKELY_PROBABILITY, objectHub.readWord(superCheckOffset, LocationIdentity.FINAL_LOCATION).notEqual(hub))) {
             displayMiss.inc();
@@ -157,7 +158,7 @@
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         // if we get an exact match: succeed immediately
         ExplodeLoopNode.explodeLoop();
@@ -179,12 +180,12 @@
      * Type test used when the type being tested against is not known at compile time.
      */
     @Snippet
-    public static Object instanceofDynamic(Class mirror, Object object, Object trueValue, Object falseValue) {
+    public static Object instanceofDynamic(Class<?> mirror, Object object, Object trueValue, Object falseValue) {
         if (probability(NOT_FREQUENT_PROBABILITY, object == null)) {
             isNull.inc();
             return falseValue;
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
         Word hub = loadWordFromObject(mirror, klassOffset());
         Word objectHub = loadHubIntrinsic(object, getWordKind(), anchorNode);
         if (hub.equal(0) || !checkUnknownSubType(hub, objectHub)) {
@@ -214,8 +215,8 @@
         private final SnippetInfo instanceofSecondary = snippet(InstanceOfSnippets.class, "instanceofSecondary");
         private final SnippetInfo instanceofDynamic = snippet(InstanceOfSnippets.class, "instanceofDynamic");
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
         }
 
         @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -66,7 +66,7 @@
         private final SnippetInfo loadException = snippet(LoadExceptionObjectSnippets.class, "loadException");
 
         public Templates(HotSpotProviders providers, TargetDescription target) {
-            super(providers, target);
+            super(providers, providers.getSnippetReflection(), target);
         }
 
         public void lower(LoadExceptionObjectNode loadExceptionObject, HotSpotRegistersProvider registers, LoweringTool tool) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleInvokeBasicNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleInvokeBasicNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import java.lang.invoke.MethodHandle;
+import java.lang.invoke.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToInterfaceNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToInterfaceNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import java.lang.invoke.MethodHandle;
+import java.lang.invoke.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToSpecialNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToSpecialNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import java.lang.invoke.MethodHandle;
+import java.lang.invoke.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToStaticNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToStaticNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import java.lang.invoke.MethodHandle;
+import java.lang.invoke.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToVirtualNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleLinkToVirtualNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
-import java.lang.invoke.MethodHandle;
+import java.lang.invoke.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,7 +48,6 @@
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.ConstantParameter;
 import com.oracle.graal.replacements.Snippet.Fold;
@@ -59,7 +58,7 @@
 
 /**
  * Snippets used for implementing the monitorenter and monitorexit instructions.
- * 
+ *
  * The locking algorithm used is described in the paper <a
  * href="http://dl.acm.org/citation.cfm?id=1167515.1167496"> Eliminating synchronization-related
  * atomic operations with biased locking and bulk rebiasing</a> by Kenneth Russell and David
@@ -103,7 +102,7 @@
         if (object == null) {
             DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException);
         }
-        BeginNode anchorNode = BeginNode.anchor();
+        GuardingNode anchorNode = SnippetAnchorNode.anchor();
 
         // Load the mark word - this includes a null-check on object
         final Word mark = loadWordFromObject(object, markOffset());
@@ -325,7 +324,7 @@
                 // The object's mark word was not pointing to the displaced header,
                 // we do unlocking via runtime call.
                 traceObject(trace, "-lock{stub}", object, false);
-                MonitorExitStubCall.call(object, lockDepth);
+                monitorexitStub(MONITOREXIT, object, lock);
             } else {
                 traceObject(trace, "-lock{cas}", object, false);
             }
@@ -341,7 +340,8 @@
     public static void monitorexitStub(Object object, @ConstantParameter int lockDepth, @ConstantParameter boolean trace) {
         verifyOop(object);
         traceObject(trace, "-lock{stub}", object, false);
-        MonitorExitStubCall.call(object, lockDepth);
+        final Word lock = CurrentLockNode.currentLock(lockDepth);
+        monitorexitStub(MONITOREXIT, object, lock);
         endLockScope();
         decCounter();
     }
@@ -416,8 +416,8 @@
 
         private final boolean useFastLocking;
 
-        public Templates(Providers providers, TargetDescription target, boolean useFastLocking) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target, boolean useFastLocking) {
+            super(providers, providers.getSnippetReflection(), target);
             this.useFastLocking = useFastLocking;
         }
 
@@ -507,7 +507,7 @@
                     for (ReturnNode ret : rets) {
                         returnType = checkCounter.getMethod().getSignature().getReturnType(checkCounter.getMethod().getDeclaringClass());
                         String msg = "unbalanced monitors in " + MetaUtil.format("%H.%n(%p)", graph.method()) + ", count = %d";
-                        ConstantNode errMsg = ConstantNode.forObject(msg, providers.getMetaAccess(), graph);
+                        ConstantNode errMsg = ConstantNode.forConstant(HotSpotObjectConstant.forObject(msg), providers.getMetaAccess(), graph);
                         callTarget = graph.add(new MethodCallTargetNode(InvokeKind.Static, checkCounter.getMethod(), new ValueNode[]{errMsg}, returnType));
                         invoke = graph.add(new InvokeNode(callTarget, 0));
                         List<ValueNode> stack = Collections.emptyList();
@@ -528,8 +528,12 @@
     }
 
     public static final ForeignCallDescriptor MONITORENTER = new ForeignCallDescriptor("monitorenter", void.class, Object.class, Word.class);
+    public static final ForeignCallDescriptor MONITOREXIT = new ForeignCallDescriptor("monitorexit", void.class, Object.class, Word.class);
 
     @NodeIntrinsic(ForeignCallNode.class)
     private static native void monitorenterStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock);
 
+    @NodeIntrinsic(ForeignCallNode.class)
+    private static native void monitorexitStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock);
+
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,7 +48,6 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.options.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.ConstantParameter;
 import com.oracle.graal.replacements.Snippet.Fold;
@@ -106,7 +105,7 @@
         return ProfileAllocations.getValue();
     }
 
-    private static void profileAllocation(String path, long size, String typeContext) {
+    protected static void profileAllocation(String path, long size, String typeContext) {
         if (doProfile()) {
             String name = createName(path, typeContext);
 
@@ -348,7 +347,7 @@
     /**
      * Formats some allocated memory with an object header and zeroes out the rest.
      */
-    private static Object formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean noAsserts, boolean useSnippetCounters) {
+    protected static Object formatObject(Word hub, int size, Word memory, Word compileTimePrototypeMarkWord, boolean fillContents, boolean constantSize, boolean noAsserts, boolean useSnippetCounters) {
         Word prototypeMarkWord = useBiasedLocking() ? hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION) : compileTimePrototypeMarkWord;
         initializeObjectHeader(memory, prototypeMarkWord, hub);
         if (fillContents) {
@@ -382,8 +381,8 @@
         private final SnippetInfo allocateInstanceDynamic = snippet(NewObjectSnippets.class, "allocateInstanceDynamic");
         private final SnippetInfo newmultiarray = snippet(NewObjectSnippets.class, "newmultiarray");
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
         }
 
         /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionGetCallerClassNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -93,7 +93,7 @@
                     if (!method.ignoredBySecurityStackWalk()) {
                         // We have reached the desired frame; return the holder class.
                         HotSpotResolvedObjectType callerClass = method.getDeclaringClass();
-                        return ConstantNode.forObject(callerClass.mirror(), metaAccess, graph());
+                        return ConstantNode.forConstant(HotSpotObjectConstant.forObject(callerClass.mirror()), metaAccess, graph());
                     }
                     break;
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ReflectionSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 package com.oracle.graal.hotspot.replacements;
 
 import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.nodes.spi.MacroSubstitution;
+import com.oracle.graal.nodes.spi.*;
 
 /**
  * Substitutions for {@link sun.reflect.Reflection} methods.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemIdentityHashCodeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.phases.GraalOptions.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
 
@@ -36,6 +37,6 @@
 
     @Override
     protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
-        return ImmutableCode.getValue() || param.isNull() ? null : Constant.forInt(System.identityHashCode(param.asObject()));
+        return ImmutableCode.getValue() || param.isNull() ? null : Constant.forInt(System.identityHashCode(HotSpotObjectConstant.asObject(param)));
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -45,12 +45,12 @@
 
     @MethodSubstitution
     public static Thread currentThread() {
-        return PiNode.piCastNonNull(CurrentJavaThreadNode.get().readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION), Thread.class);
+        return PiNode.piCastNonNull(CurrentJavaThreadNode.get(getWordKind()).readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION), Thread.class);
     }
 
     @MethodSubstitution(isStatic = false)
     public static boolean isInterrupted(final Thread thisObject, boolean clearInterrupted) {
-        Word javaThread = CurrentJavaThreadNode.get();
+        Word javaThread = CurrentJavaThreadNode.get(getWordKind());
         Object thread = javaThread.readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION);
         if (thisObject == thread) {
             Word osThread = javaThread.readWord(osThreadOffset(), LocationIdentity.FINAL_LOCATION);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,12 +25,14 @@
 import static com.oracle.graal.api.meta.LocationIdentity.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
 
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public final class UnsafeArrayCopyNode extends ArrayRangeWriteNode implements Lowerable, MemoryCheckpoint.Single {
 
     @Input private ValueNode src;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopySnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopySnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,10 +31,10 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.phases.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
@@ -249,8 +249,8 @@
         private final SnippetInfo[] arraycopySnippets;
         private final SnippetInfo genericPrimitiveSnippet;
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
 
             arraycopySnippets = new SnippetInfo[Kind.values().length];
             arraycopySnippets[Kind.Boolean.ordinal()] = snippet(UnsafeArrayCopySnippets.class, "arraycopyBoolean");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeLoadSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeLoadSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,10 +26,10 @@
 import static com.oracle.graal.replacements.SnippetTemplate.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
@@ -52,8 +52,8 @@
 
         private final SnippetInfo unsafeLoad = snippet(UnsafeLoadSnippets.class, "lowerUnsafeLoad");
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target) {
+            super(providers, providers.getSnippetReflection(), target);
         }
 
         public void lower(UnsafeLoadNode load, LoweringTool tool) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
-import com.oracle.graal.hotspot.HotSpotVMConfig.*;
+import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.hotspot.nodes.type.*;
@@ -40,7 +40,6 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.ConstantParameter;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
@@ -72,7 +71,7 @@
         Object fixedObject = FixedValueAnchorNode.getObject(object);
         Pointer oop;
         if (usePrecise) {
-            oop = Word.fromArray(fixedObject, location);
+            oop = Word.fromArray(fixedObject, SnippetLocationProxyNode.location(location));
         } else {
             oop = Word.fromObject(fixedObject);
         }
@@ -117,7 +116,7 @@
         Object fixedObject = FixedValueAnchorNode.getObject(object);
         verifyOop(fixedObject);
         Object fixedExpectedObject = FixedValueAnchorNode.getObject(expectedObject);
-        Word field = (Word) Word.fromArray(fixedObject, location);
+        Word field = (Word) Word.fromArray(fixedObject, SnippetLocationProxyNode.location(location));
         Word previousOop = (Word) Word.fromObject(fixedExpectedObject);
         byte markingValue = thread.readByte(g1SATBQueueMarkingOffset());
         Word bufferAddress = thread.readWord(g1SATBQueueBufferOffset());
@@ -174,7 +173,7 @@
         validateObject(fixedObject, fixedValue);
         Word oop;
         if (usePrecise) {
-            oop = (Word) Word.fromArray(fixedObject, location);
+            oop = (Word) Word.fromArray(fixedObject, SnippetLocationProxyNode.location(location));
         } else {
             oop = (Word) Word.fromObject(fixedObject);
         }
@@ -334,8 +333,8 @@
 
         private final CompressEncoding oopEncoding;
 
-        public Templates(Providers providers, TargetDescription target, CompressEncoding oopEncoding) {
-            super(providers, target);
+        public Templates(HotSpotProviders providers, TargetDescription target, CompressEncoding oopEncoding) {
+            super(providers, providers.getSnippetReflection(), target);
             this.oopEncoding = oopEncoding;
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.stubs;
+
+import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
+import static com.oracle.graal.hotspot.stubs.StubUtil.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.nodes.*;
+import com.oracle.graal.replacements.*;
+import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.word.*;
+
+/**
+ * Deoptimization stub.
+ *
+ * This is the entry point for code which is returning to a de-optimized frame.
+ *
+ * The steps taken by this frame are as follows:
+ *
+ * - push a dummy "register_save" and save the return values (O0, O1, F0/F1, G1) and all potentially
+ * live registers (at a pollpoint many registers can be live).
+ *
+ * - call the C routine: Deoptimization::fetch_unroll_info (this function returns information about
+ * the number and size of interpreter frames which are equivalent to the frame which is being
+ * deoptimized)
+ *
+ * - deallocate the unpack frame, restoring only results values. Other volatile registers will now
+ * be captured in the vframeArray as needed.
+ *
+ * - deallocate the deoptimization frame
+ *
+ * - in a loop using the information returned in the previous step push new interpreter frames (take
+ * care to propagate the return values through each new frame pushed)
+ *
+ * - create a dummy "unpack_frame" and save the return values (O0, O1, F0)
+ *
+ * - call the C routine: Deoptimization::unpack_frames (this function lays out values on the
+ * interpreter frame which was just created)
+ *
+ * - deallocate the dummy unpack_frame
+ *
+ * - ensure that all the return values are correctly set and then do a return to the interpreter
+ * entry point
+ */
+public class DeoptimizationStub extends SnippetStub {
+
+    private final TargetDescription target;
+
+    public DeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) {
+        super(providers, target, linkage);
+        this.target = target;
+    }
+
+    @Override
+    public boolean preservesRegisters() {
+        return false;
+    }
+
+    @Override
+    protected Object getConstantParameterValue(int index, String name) {
+        switch (index) {
+            case 0:
+                return providers.getRegisters().getThreadRegister();
+            case 1:
+                return providers.getRegisters().getStackPointerRegister();
+            default:
+                throw GraalInternalError.shouldNotReachHere("unknown parameter " + name + " at index " + index);
+        }
+    }
+
+    /**
+     * Uncommon trap.
+     *
+     * We save the argument return registers. We call the first C routine, fetch_unroll_info(). This
+     * routine captures the return values and returns a structure which describes the current frame
+     * size and the sizes of all replacement frames. The current frame is compiled code and may
+     * contain many inlined functions, each with their own JVM state. We pop the current frame, then
+     * push all the new frames. Then we call the C routine unpack_frames() to populate these frames.
+     * Finally unpack_frames() returns us the new target address. Notice that callee-save registers
+     * are BLOWN here; they have already been captured in the vframeArray at the time the return PC
+     * was patched.
+     *
+     * <p>
+     * <b>ATTENTION: We cannot do any complicated operations e.g. logging via printf in this snippet
+     * because we change the current stack layout and so the code is very sensitive to register
+     * allocation.</b>
+     */
+    @Snippet
+    private static void uncommonTrapHandler(@ConstantParameter Register threadRegister, @ConstantParameter Register stackPointerRegister) {
+        final Word thread = registerAsWord(threadRegister);
+        long registerSaver = SaveAllRegistersNode.saveAllRegisters();
+
+        final int actionAndReason = readPendingDeoptimization(thread);
+        writePendingDeoptimization(thread, -1);
+
+        final Word unrollBlock = UncommonTrapCallNode.uncommonTrap(registerSaver, actionAndReason);
+
+        // Pop all the frames we must move/replace.
+        //
+        // Frame picture (youngest to oldest)
+        // 1: self-frame (no frame link)
+        // 2: deoptimizing frame (no frame link)
+        // 3: caller of deoptimizing frame (could be compiled/interpreted).
+
+        // Pop self-frame.
+        LeaveCurrentStackFrameNode.leaveCurrentStackFrame();
+
+        // Load the initial info we should save (e.g. frame pointer).
+        final Word initialInfo = unrollBlock.readWord(deoptimizationUnrollBlockInitialInfoOffset());
+
+        // Pop deoptimized frame
+        final int sizeOfDeoptimizedFrame = unrollBlock.readInt(deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset());
+        LeaveDeoptimizedStackFrameNode.leaveDeoptimizedStackFrame(sizeOfDeoptimizedFrame, initialInfo);
+
+        /*
+         * Stack bang to make sure there's enough room for the interpreter frames. Bang stack for
+         * total size of the interpreter frames plus shadow page size. Bang one page at a time
+         * because large sizes can bang beyond yellow and red zones.
+         */
+        final int totalFrameSizes = unrollBlock.readInt(deoptimizationUnrollBlockTotalFrameSizesOffset());
+        final int bangPages = NumUtil.roundUp(totalFrameSizes, pageSize()) / pageSize() + stackShadowPages();
+        Word stackPointer = readRegister(stackPointerRegister);
+
+        for (int i = 1; i < bangPages; i++) {
+            stackPointer.writeInt(-(i * pageSize()), i);
+        }
+
+        // Load number of interpreter frames.
+        final int numberOfFrames = unrollBlock.readInt(deoptimizationUnrollBlockNumberOfFramesOffset());
+
+        // Load address of array of frame sizes.
+        final Word frameSizes = unrollBlock.readWord(deoptimizationUnrollBlockFrameSizesOffset());
+
+        // Load address of array of frame PCs.
+        final Word framePcs = unrollBlock.readWord(deoptimizationUnrollBlockFramePcsOffset());
+
+        /*
+         * Get the current stack pointer (sender's original SP) before adjustment so that we can
+         * save it in the skeletal interpreter frame.
+         */
+        Word senderSp = readRegister(stackPointerRegister);
+
+        // Adjust old interpreter frame to make space for new frame's extra Java locals.
+        final int callerAdjustment = unrollBlock.readInt(deoptimizationUnrollBlockCallerAdjustmentOffset());
+        writeRegister(stackPointerRegister, readRegister(stackPointerRegister).subtract(callerAdjustment));
+
+        for (int i = 0; i < numberOfFrames; i++) {
+            final Word frameSize = frameSizes.readWord(i * wordSize());
+            final Word framePc = framePcs.readWord(i * wordSize());
+
+            // Push an interpreter frame onto the stack.
+            PushInterpreterFrameNode.pushInterpreterFrame(frameSize, framePc, senderSp, initialInfo);
+
+            // Get the current stack pointer (sender SP) and pass it to next frame.
+            senderSp = readRegister(stackPointerRegister);
+        }
+
+        // Get final return address.
+        final Word framePc = framePcs.readWord(numberOfFrames * wordSize());
+
+        /*
+         * Enter a frame to call out to unpack frames. Since we changed the stack pointer to an
+         * unknown alignment we need to align it here before calling C++ code.
+         */
+        final Word senderFp = initialInfo;
+        EnterUnpackFramesStackFrameNode.enterUnpackFramesStackFrame(framePc, senderSp, senderFp);
+
+        // Pass uncommon trap mode to unpack frames.
+        final int mode = deoptimizationUnpackUncommonTrap();
+        unpackFrames(UNPACK_FRAMES, thread, mode);
+
+        LeaveUnpackFramesStackFrameNode.leaveUnpackFramesStackFrame();
+    }
+
+    /**
+     * Reads the value of the passed register as a Word.
+     */
+    private static Word readRegister(Register register) {
+        return registerAsWord(register, false, false);
+    }
+
+    /**
+     * Writes the value of the passed register.
+     *
+     * @param value value the register should be set to
+     */
+    private static void writeRegister(Register register, Word value) {
+        writeRegisterAsWord(register, value);
+    }
+
+    @Fold
+    private static int stackShadowPages() {
+        return config().useStackBanging ? config().stackShadowPages : 0;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset() {
+        return config().deoptimizationUnrollBlockSizeOfDeoptimizedFrameOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockCallerAdjustmentOffset() {
+        return config().deoptimizationUnrollBlockCallerAdjustmentOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockNumberOfFramesOffset() {
+        return config().deoptimizationUnrollBlockNumberOfFramesOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockTotalFrameSizesOffset() {
+        return config().deoptimizationUnrollBlockTotalFrameSizesOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockFrameSizesOffset() {
+        return config().deoptimizationUnrollBlockFrameSizesOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockFramePcsOffset() {
+        return config().deoptimizationUnrollBlockFramePcsOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnrollBlockInitialInfoOffset() {
+        return config().deoptimizationUnrollBlockInitialInfoOffset;
+    }
+
+    @Fold
+    private static int deoptimizationUnpackDeopt() {
+        return config().deoptimizationUnpackDeopt;
+    }
+
+    @Fold
+    private static int deoptimizationUnpackUncommonTrap() {
+        return config().deoptimizationUnpackUncommonTrap;
+    }
+
+    public static final ForeignCallDescriptor FETCH_UNROLL_INFO = descriptorFor(DeoptimizationStub.class, "fetchUnrollInfo");
+    public static final ForeignCallDescriptor UNPACK_FRAMES = descriptorFor(DeoptimizationStub.class, "unpackFrames");
+
+    @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true)
+    public static native Word fetchUnrollInfo(@ConstantNodeParameter ForeignCallDescriptor fetchUnrollInfo, Word thread);
+
+    @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true)
+    public static native int unpackFrames(@ConstantNodeParameter ForeignCallDescriptor unpackFrames, Word thread, int mode);
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,11 +31,12 @@
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.ConstantParameter;
+import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -63,7 +63,7 @@
 
     /**
      * Creates a stub for a call to code at a given address.
-     * 
+     *
      * @param address the address of the code to call
      * @param descriptor the signature of the call to this stub
      * @param prependThread true if the JavaThread value for the current thread is to be prepended
@@ -78,7 +78,7 @@
         super(providers, HotSpotForeignCallLinkage.create(providers.getMetaAccess(), providers.getCodeCache(), providers.getForeignCalls(), descriptor, 0L, PRESERVES_REGISTERS, JavaCall, JavaCallee,
                         transition, reexecutable, killedLocations));
         this.prependThread = prependThread;
-        Class[] targetParameterTypes = createTargetParameters(descriptor);
+        Class<?>[] targetParameterTypes = createTargetParameters(descriptor);
         ForeignCallDescriptor targetSig = new ForeignCallDescriptor(descriptor.getName() + ":C", descriptor.getResultType(), targetParameterTypes);
         target = HotSpotForeignCallLinkage.create(providers.getMetaAccess(), providers.getCodeCache(), providers.getForeignCalls(), targetSig, address, DESTROYS_REGISTERS, NativeCall, NativeCall,
                         transition, reexecutable, killedLocations);
@@ -91,10 +91,10 @@
         return target;
     }
 
-    private Class[] createTargetParameters(ForeignCallDescriptor descriptor) {
-        Class[] parameters = descriptor.getArgumentTypes();
+    private Class<?>[] createTargetParameters(ForeignCallDescriptor descriptor) {
+        Class<?>[] parameters = descriptor.getArgumentTypes();
         if (prependThread) {
-            Class[] newParameters = new Class[parameters.length + 1];
+            Class<?>[] newParameters = new Class[parameters.length + 1];
             System.arraycopy(parameters, 0, newParameters, 1, parameters.length);
             newParameters[0] = Word.class;
             return newParameters;
@@ -141,7 +141,7 @@
      * Creates a graph for this stub.
      * <p>
      * If the stub returns an object, the graph created corresponds to this pseudo code:
-     * 
+     *
      * <pre>
      *     Object foreignFunctionStub(args...) {
      *         foreignFunction(currentThread,  args);
@@ -152,10 +152,10 @@
      *         return verifyObject(getAndClearObjectResult(thread()));
      *     }
      * </pre>
-     * 
+     *
      * If the stub returns a primitive or word, the graph created corresponds to this pseudo code
      * (using {@code int} as the primitive return type):
-     * 
+     *
      * <pre>
      *     int foreignFunctionStub(args...) {
      *         int result = foreignFunction(currentThread,  args);
@@ -165,9 +165,9 @@
      *         return result;
      *     }
      * </pre>
-     * 
+     *
      * If the stub is void, the graph created corresponds to this pseudo code:
-     * 
+     *
      * <pre>
      *     void foreignFunctionStub(args...) {
      *         foreignFunction(currentThread,  args);
@@ -176,7 +176,7 @@
      *         }
      *     }
      * </pre>
-     * 
+     *
      * In each example above, the {@code currentThread} argument is the C++ JavaThread value (i.e.,
      * %r15 on AMD64) and is only prepended if {@link #prependThread} is true.
      */
@@ -203,8 +203,8 @@
             Debug.dump(graph, "Initial stub graph");
         }
 
-        kit.rewriteWordTypes();
-        kit.inlineInvokes();
+        kit.rewriteWordTypes(providers.getSnippetReflection());
+        kit.inlineInvokes(providers.getSnippetReflection());
 
         if (Debug.isDumpEnabled()) {
             Debug.dump(graph, "Stub graph before compilation");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.hotspot.stubs;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 import static com.oracle.graal.hotspot.replacements.NewObjectSnippets.*;
 import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*;
@@ -61,16 +60,10 @@
     protected Arguments makeArguments(SnippetInfo stub) {
         HotSpotResolvedObjectType intArrayType = (HotSpotResolvedObjectType) providers.getMetaAccess().lookupJavaType(int[].class);
 
-        // RuntimeStub cannot (currently) support oops or metadata embedded in the code so we
-        // convert the hub (i.e., Klass*) for int[] to be a naked word. This should be safe since
-        // the int[] class will never be unloaded.
-        Constant intArrayHub = intArrayType.klass();
-        intArrayHub = Constant.forIntegerKind(runtime().getTarget().wordKind, intArrayHub.asLong(), null);
-
         Arguments args = new Arguments(stub, GuardsStage.FLOATING_GUARDS, LoweringTool.StandardLoweringStage.HIGH_TIER);
         args.add("hub", null);
         args.add("length", null);
-        args.addConst("intArrayHub", intArrayHub);
+        args.addConst("intArrayHub", intArrayType.klass());
         args.addConst("threadRegister", providers.getRegisters().getThreadRegister());
         return args;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -65,7 +65,7 @@
         // convert the hub (i.e., Klass*) for int[] to be a naked word. This should be safe since
         // the int[] class will never be unloaded.
         Constant intArrayHub = intArrayType.klass();
-        intArrayHub = Constant.forIntegerKind(runtime().getTarget().wordKind, intArrayHub.asLong(), null);
+        intArrayHub = Constant.forIntegerKind(runtime().getTarget().wordKind, intArrayHub.asLong());
 
         Arguments args = new Arguments(stub, GuardsStage.FLOATING_GUARDS, LoweringTool.StandardLoweringStage.HIGH_TIER);
         args.add("hub", null);
@@ -231,7 +231,7 @@
      * @param log specifies if logging is enabled
      * @return the allocated chunk or {@link Word#zero()} if allocation fails
      */
-    static Word edenAllocate(Word sizeInBytes, boolean log) {
+    public static Word edenAllocate(Word sizeInBytes, boolean log) {
         Word heapTopAddress = Word.unsigned(heapTopAddress());
         Word heapEndAddress = Word.unsigned(heapEndAddress());
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,6 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates;
 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
@@ -45,8 +44,8 @@
 
     static class Template extends AbstractTemplates {
 
-        Template(Providers providers, TargetDescription target, Class<? extends Snippets> declaringClass) {
-            super(providers, target);
+        Template(HotSpotProviders providers, TargetDescription target, Class<? extends Snippets> declaringClass) {
+            super(providers, providers.getSnippetReflection(), target);
             this.info = snippet(declaringClass, null);
         }
 
@@ -65,7 +64,7 @@
 
     /**
      * Creates a new snippet stub.
-     * 
+     *
      * @param linkage linkage details for a call to the stub
      */
     public SnippetStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
 
 import static com.oracle.graal.compiler.GraalCompiler.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.phases.GraalOptions.*;
 
 import java.util.*;
 
@@ -41,6 +42,7 @@
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.schedule.*;
 
 //JaCoCo Exclude
 
@@ -108,6 +110,10 @@
         return linkage;
     }
 
+    public RegisterConfig getRegisterConfig() {
+        return null;
+    }
+
     /**
      * Gets the graph that from which the code for this stub will be compiled.
      */
@@ -145,9 +151,17 @@
                 CodeCacheProvider codeCache = providers.getCodeCache();
                 // The stub itself needs the incoming calling convention.
                 CallingConvention incomingCc = linkage.getIncomingCallingConvention();
-                final CompilationResult compResult = compileGraph(graph, Stub.this, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null,
-                                providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(),
-                                new CompilationResult(), CompilationResultBuilderFactory.Default);
+                TargetDescription target = codeCache.getTarget();
+
+                final CompilationResult compResult = new CompilationResult();
+                try (Scope s0 = Debug.scope("StubCompilation", graph, providers.getCodeCache())) {
+                    Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
+                    SchedulePhase schedule = emitFrontEnd(providers, target, graph, assumptions, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL,
+                                    getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites());
+                    emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, assumptions, schedule, getRegisterConfig());
+                } catch (Throwable e) {
+                    throw Debug.handle(e);
+                }
 
                 assert destroyedRegisters != null;
                 try (Scope s = Debug.scope("CodeInstall")) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.word.*;
@@ -69,7 +69,7 @@
         }
         assert found != null : "could not find foreign call named " + name + " in " + stubClass;
         List<Class<?>> paramList = Arrays.asList(found.getParameterTypes());
-        Class[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class[paramList.size() - 1]);
+        Class<?>[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class[paramList.size() - 1]);
         return new ForeignCallDescriptor(name, found.getReturnType(), cCallTypes);
     }
 
@@ -98,7 +98,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param message a message string
      */
     public static void printf(String message) {
@@ -110,7 +110,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param value the value associated with the first conversion specifier in {@code format}
      */
@@ -123,7 +123,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long)} to avoid an object
      * constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -137,7 +137,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -159,7 +159,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param message an error message
      */
     public static void fatal(String message) {
@@ -171,7 +171,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param value the value associated with the first conversion specifier in {@code format}
      */
@@ -184,7 +184,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -198,7 +198,7 @@
      * <p>
      * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
      * object constant in a RuntimeStub.</b>
-     * 
+     *
      * @param format a C style printf format value
      * @param v1 the value associated with the first conversion specifier in {@code format}
      * @param v2 the value associated with the second conversion specifier in {@code format}
@@ -218,7 +218,7 @@
 
             Pointer oop = Word.fromObject(object);
             if (object != null) {
-                BeginNode anchorNode = BeginNode.anchor();
+                GuardingNode anchorNode = SnippetAnchorNode.anchor();
                 // make sure object is 'reasonable'
                 if (!oop.and(unsigned(verifyOopMask())).equal(unsigned(verifyOopBits()))) {
                     fatal("oop not in heap: %p", oop.rawValue());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,8 @@
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.ConstantParameter;
+import com.oracle.graal.replacements.Snippet.Fold;
 import com.oracle.graal.word.*;
 
 /**
--- a/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java	Wed Apr 16 14:02:52 2014 +0200
@@ -131,6 +131,8 @@
     public static final Register d17 = new Register(81, 17, "d17", CPU);
     public static final Register d18 = new Register(82, 18, "d18", CPU);
     public static final Register d19 = new Register(83, 19, "d19", CPU);
+    public static final Register d20 = new Register(84, 20, "d20", CPU);
+    public static final Register threadRegister = d20;
 
     // @formatter:off
     public static final Register[] cRegisters = {
@@ -145,7 +147,7 @@
     };
 
     public static final Register[] dRegisters = {
-        d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15
+        d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, threadRegister
     };
 
     public static final Register[] qRegisters = {
@@ -156,7 +158,7 @@
         c0, c1, c2, c3, c4, c5, c6, c7, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15,
         d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13,
         d14, d15, q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11,
-        q12, q13, q14, q15
+        q12, q13, q14, q15, threadRegister
     };
 
     // @formatter:on
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerLoopSimplify.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerLoopSimplify.java	Wed Apr 16 14:02:52 2014 +0200
@@ -46,7 +46,7 @@
             cfgBlocks.remove(0);
             if (firstBlock.isLoopHeader()) {
                 DecompilerLoopBlock loopBlock = new DecompilerLoopBlock(firstBlock, decompiler, decompiler.getSchedule(), infoStream);
-                Loop loop = firstBlock.getLoop();
+                Loop<Block> loop = firstBlock.getLoop();
 
                 for (int i = 0; i < cfgBlocks.size(); i++) {
                     if (loop.blocks.contains(cfgBlocks.get(i)) && cfgBlocks.get(i) != firstBlock) {
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerSyntaxLine.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerSyntaxLine.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,7 +48,7 @@
 
     protected static String getStringRepresentation(Node node) {
         if (node instanceof ConstantNode) {
-            return String.valueOf(((ConstantNode) node).asConstant().asBoxedValue());
+            return ((ConstantNode) node).asConstant().toValueString();
         } else if (node instanceof ParameterNode) {
             return "param_" + ((ParameterNode) node).index();
         } else {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,7 +43,7 @@
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 
-public abstract class AbstractBytecodeParser<T extends KindProvider, F extends AbstractFrameStateBuilder<T>> {
+public abstract class AbstractBytecodeParser<T extends KindProvider, F extends AbstractFrameStateBuilder<T, F>> {
 
     static class Options {
         // @formatter:off
@@ -505,11 +505,7 @@
         frameState.storeLocal(index, append(genIntegerAdd(Kind.Int, x, y)));
     }
 
-    private void genGoto() {
-        appendGoto(createTarget(currentBlock.getSuccessors().get(0), frameState));
-        // assert currentBlock.numNormalSuccessors() == 1;
-        assert currentBlock.getSuccessors().size() == 1;
-    }
+    protected abstract void genGoto();
 
     protected abstract T genObjectEquals(T x, T y);
 
@@ -716,13 +712,6 @@
 
     protected abstract void emitNullCheck(T receiver);
 
-    protected static final ArrayIndexOutOfBoundsException cachedArrayIndexOutOfBoundsException = new ArrayIndexOutOfBoundsException();
-    protected static final NullPointerException cachedNullPointerException = new NullPointerException();
-    static {
-        cachedArrayIndexOutOfBoundsException.setStackTrace(new StackTraceElement[0]);
-        cachedNullPointerException.setStackTrace(new StackTraceElement[0]);
-    }
-
     protected abstract void emitBoundsCheck(T index, T length);
 
     private static final DebugMetric EXPLICIT_EXCEPTIONS = Debug.metric("ExplicitExceptions");
@@ -834,7 +823,7 @@
      *
      * @return an array of size successorCount with the accumulated probability for each successor.
      */
-    private static double[] successorProbabilites(int successorCount, int[] keySuccessors, double[] keyProbabilities) {
+    public static double[] successorProbabilites(int successorCount, int[] keySuccessors, double[] keyProbabilities) {
         double[] probability = new double[successorCount];
         for (int i = 0; i < keySuccessors.length; i++) {
             probability[keySuccessors[i]] += keyProbabilities[i];
@@ -884,17 +873,11 @@
             }
         }
 
-        double[] successorProbabilities = successorProbabilites(actualSuccessors.size(), keySuccessors, keyProbabilities);
-        T switchNode = append(genIntegerSwitch(value, actualSuccessors.size(), keys, keyProbabilities, keySuccessors));
-        for (int i = 0; i < actualSuccessors.size(); i++) {
-            setBlockSuccessor(switchNode, i, createBlockTarget(successorProbabilities[i], actualSuccessors.get(i), frameState));
-        }
+        genIntegerSwitch(value, actualSuccessors, keys, keyProbabilities, keySuccessors);
 
     }
 
-    protected abstract void setBlockSuccessor(T switchNode, int i, T createBlockTarget);
-
-    protected abstract T genIntegerSwitch(T value, int size, int[] keys, double[] keyProbabilities, int[] keySuccessors);
+    protected abstract void genIntegerSwitch(T value, ArrayList<BciBlock> actualSuccessors, int[] keys, double[] keyProbabilities, int[] keySuccessors);
 
     private static class SuccessorInfo {
 
@@ -911,34 +894,12 @@
 
     protected abstract T append(T v);
 
-    private boolean isNeverExecutedCode(double probability) {
+    protected boolean isNeverExecutedCode(double probability) {
         return probability == 0 && optimisticOpts.removeNeverExecutedCode() && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI;
     }
 
-    protected abstract T genDeoptimization();
-
-    protected T createTarget(double probability, BciBlock block, AbstractFrameStateBuilder<T> stateAfter) {
-        assert probability >= 0 && probability <= 1.01 : probability;
-        if (isNeverExecutedCode(probability)) {
-            return genDeoptimization();
-        } else {
-            assert block != null;
-            return createTarget(block, stateAfter);
-        }
-    }
-
-    protected abstract T createTarget(BciBlock trueBlock, AbstractFrameStateBuilder<T> state);
-
-    /**
-     * Returns a block begin node with the specified state. If the specified probability is 0, the
-     * block deoptimizes immediately.
-     */
-    protected abstract T createBlockTarget(double probability, BciBlock bciBlock, AbstractFrameStateBuilder<T> stateAfter);
-
     protected abstract void processBlock(BciBlock block);
 
-    protected abstract void appendGoto(T target);
-
     protected abstract void iterateBytecodesForBlock(BciBlock block);
 
     public void processBytecode(int bci, int opcode) {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,19 +23,82 @@
 
 package com.oracle.graal.java;
 
-import com.oracle.graal.api.meta.*;
+import java.util.*;
 
-public abstract class AbstractFrameStateBuilder<T extends KindProvider> {
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.java.BciBlockMapping.BciBlock;
+import com.oracle.graal.java.BciBlockMapping.LocalLiveness;
+
+public abstract class AbstractFrameStateBuilder<T extends KindProvider, S extends AbstractFrameStateBuilder<T, S>> {
 
     protected final ResolvedJavaMethod method;
     protected int stackSize;
+    protected final T[] locals;
+    protected final T[] stack;
+    protected T[] lockedObjects;
 
-    public AbstractFrameStateBuilder(ResolvedJavaMethod method) {
+    /**
+     * @see BytecodeFrame#rethrowException
+     */
+    protected boolean rethrowException;
+
+    public AbstractFrameStateBuilder(ResolvedJavaMethod method, T[] l, T[] s, T[] lo) {
         this.method = method;
+        this.locals = l;
+        this.stack = s;
+        this.lockedObjects = lo;
+    }
+
+    protected AbstractFrameStateBuilder(S other) {
+        this.method = other.method;
+        this.stackSize = other.stackSize;
+        this.locals = other.locals.clone();
+        this.stack = other.stack.clone();
+        this.lockedObjects = other.lockedObjects == getEmtpyArray() ? getEmtpyArray() : other.lockedObjects.clone();
+        this.rethrowException = other.rethrowException;
+
+        assert locals.length == method.getMaxLocals();
+        assert stack.length == Math.max(1, method.getMaxStackSize());
     }
 
-    protected AbstractFrameStateBuilder(AbstractFrameStateBuilder other) {
-        this.method = other.method;
+    public abstract S copy();
+
+    protected abstract T[] getEmtpyArray();
+
+    public abstract boolean isCompatibleWith(S other);
+
+    public void clearNonLiveLocals(BciBlock block, LocalLiveness liveness, boolean liveIn) {
+        if (liveness == null) {
+            return;
+        }
+        if (liveIn) {
+            for (int i = 0; i < locals.length; i++) {
+                if (!liveness.localIsLiveIn(block, i)) {
+                    locals[i] = null;
+                }
+            }
+        } else {
+            for (int i = 0; i < locals.length; i++) {
+                if (!liveness.localIsLiveOut(block, i)) {
+                    locals[i] = null;
+                }
+            }
+        }
+    }
+
+    /**
+     * @see BytecodeFrame#rethrowException
+     */
+    public boolean rethrowException() {
+        return rethrowException;
+    }
+
+    /**
+     * @see BytecodeFrame#rethrowException
+     */
+    public void setRethrowException(boolean b) {
+        rethrowException = b;
     }
 
     /**
@@ -43,7 +106,9 @@
      *
      * @return the size of the local variables
      */
-    public abstract int localsSize();
+    public int localsSize() {
+        return locals.length;
+    }
 
     /**
      * Gets the current size (height) of the stack.
@@ -58,7 +123,9 @@
      * @param i the index into the locals
      * @return the instruction that produced the value for the specified local
      */
-    public abstract T localAt(int i);
+    public T localAt(int i) {
+        return locals[i];
+    }
 
     /**
      * Get the value on the stack at the specified stack index.
@@ -66,7 +133,9 @@
      * @param i the index into the stack, with {@code 0} being the bottom of the stack
      * @return the instruction at the specified position in the stack
      */
-    public abstract T stackAt(int i);
+    public T stackAt(int i) {
+        return stack[i];
+    }
 
     /**
      * Loads the local variable at the specified index, checking that the returned value is non-null
@@ -75,7 +144,12 @@
      * @param i the index of the local variable to load
      * @return the instruction that produced the specified local
      */
-    public abstract T loadLocal(int i);
+    public T loadLocal(int i) {
+        T x = locals[i];
+        assert !isTwoSlot(x.getKind()) || locals[i + 1] == null;
+        assert i == 0 || locals[i - 1] == null || !isTwoSlot(locals[i - 1].getKind());
+        return x;
+    }
 
     /**
      * Stores a given local variable at the specified index. If the value occupies two slots, then
@@ -84,9 +158,26 @@
      * @param i the index at which to store
      * @param x the instruction which produces the value for the local
      */
-    public abstract void storeLocal(int i, T x);
+    public void storeLocal(int i, T x) {
+        assert x == null || x.getKind() != Kind.Void && x.getKind() != Kind.Illegal : "unexpected value: " + x;
+        locals[i] = x;
+        if (x != null && isTwoSlot(x.getKind())) {
+            // if this is a double word, then kill i+1
+            locals[i + 1] = null;
+        }
+        if (x != null && i > 0) {
+            T p = locals[i - 1];
+            if (p != null && isTwoSlot(p.getKind())) {
+                // if there was a double word at i - 1, then kill it
+                locals[i - 1] = null;
+            }
+        }
+    }
 
-    public abstract void storeStack(int i, T x);
+    public void storeStack(int i, T x) {
+        assert x == null || (stack[i] == null || x.getKind() == stack[i].getKind()) : "Method does not handle changes from one-slot to two-slot values or non-alive values";
+        stack[i] = x;
+    }
 
     /**
      * Pushes an instruction onto the stack with the expected type.
@@ -94,51 +185,76 @@
      * @param kind the type expected for this instruction
      * @param x the instruction to push onto the stack
      */
-    public abstract void push(Kind kind, T x);
+    public void push(Kind kind, T x) {
+        assert x.getKind() != Kind.Void && x.getKind() != Kind.Illegal;
+        xpush(assertKind(kind, x));
+        if (isTwoSlot(kind)) {
+            xpush(null);
+        }
+    }
 
     /**
      * Pushes a value onto the stack without checking the type.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void xpush(T x);
+    public void xpush(T x) {
+        assert x == null || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal);
+        stack[stackSize++] = x;
+    }
 
     /**
      * Pushes a value onto the stack and checks that it is an int.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void ipush(T x);
+    public void ipush(T x) {
+        xpush(assertInt(x));
+    }
 
     /**
      * Pushes a value onto the stack and checks that it is a float.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void fpush(T x);
+    public void fpush(T x) {
+        xpush(assertFloat(x));
+    }
 
     /**
      * Pushes a value onto the stack and checks that it is an object.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void apush(T x);
+    public void apush(T x) {
+        xpush(assertObject(x));
+    }
 
     /**
      * Pushes a value onto the stack and checks that it is a long.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void lpush(T x);
+    public void lpush(T x) {
+        xpush(assertLong(x));
+        xpush(null);
+    }
 
     /**
      * Pushes a value onto the stack and checks that it is a double.
      *
      * @param x the instruction to push onto the stack
      */
-    public abstract void dpush(T x);
+    public void dpush(T x) {
+        xpush(assertDouble(x));
+        xpush(null);
+    }
 
-    public abstract void pushReturn(Kind kind, T x);
+    public void pushReturn(Kind kind, T x) {
+        if (kind != Kind.Void) {
+            push(kind.getStackKind(), x);
+        }
+    }
 
     /**
      * Pops an instruction off the stack with the expected type.
@@ -146,49 +262,70 @@
      * @param kind the expected type
      * @return the instruction on the top of the stack
      */
-    public abstract T pop(Kind kind);
+    public T pop(Kind kind) {
+        assert kind != Kind.Void;
+        if (isTwoSlot(kind)) {
+            xpop();
+        }
+        return assertKind(kind, xpop());
+    }
 
     /**
      * Pops a value off of the stack without checking the type.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T xpop();
+    public T xpop() {
+        T result = stack[--stackSize];
+        return result;
+    }
 
     /**
      * Pops a value off of the stack and checks that it is an int.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T ipop();
+    public T ipop() {
+        return assertInt(xpop());
+    }
 
     /**
      * Pops a value off of the stack and checks that it is a float.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T fpop();
+    public T fpop() {
+        return assertFloat(xpop());
+    }
 
     /**
      * Pops a value off of the stack and checks that it is an object.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T apop();
+    public T apop() {
+        return assertObject(xpop());
+    }
 
     /**
      * Pops a value off of the stack and checks that it is a long.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T lpop();
+    public T lpop() {
+        assertHigh(xpop());
+        return assertLong(xpop());
+    }
 
     /**
      * Pops a value off of the stack and checks that it is a double.
      *
      * @return x the instruction popped off the stack
      */
-    public abstract T dpop();
+    public T dpop() {
+        assertHigh(xpop());
+        return assertDouble(xpop());
+    }
 
     /**
      * Pop the specified number of slots off of this stack and return them as an array of
@@ -196,7 +333,19 @@
      *
      * @return an array containing the arguments off of the stack
      */
-    public abstract T[] popArguments(int slotSize, int argSize);
+    public T[] popArguments(int slotSize, int argSize) {
+        int base = stackSize - slotSize;
+        List<T> r = new ArrayList<>(argSize);
+        int stackindex = 0;
+        while (stackindex < slotSize) {
+            T element = stack[base + stackindex];
+            assert element != null;
+            r.add(element);
+            stackindex += stackSlots(element.getKind());
+        }
+        stackSize = base;
+        return r.toArray(getEmtpyArray());
+    }
 
     /**
      * Peeks an element from the operand stack.
@@ -206,7 +355,17 @@
      *            ignored.
      * @return The peeked argument.
      */
-    public abstract T peek(int argumentNumber);
+    public T peek(int argumentNumber) {
+        int idx = stackSize() - 1;
+        for (int i = 0; i < argumentNumber; i++) {
+            if (stackAt(idx) == null) {
+                idx--;
+                assert isTwoSlot(stackAt(idx).getKind());
+            }
+            idx--;
+        }
+        return stackAt(idx);
+    }
 
     public static int stackSlots(Kind kind) {
         return isTwoSlot(kind) ? 2 : 1;
@@ -224,4 +383,38 @@
         return kind == Kind.Long || kind == Kind.Double;
     }
 
+    private T assertKind(Kind kind, T x) {
+        assert x != null && x.getKind() == kind : "kind=" + kind + ", value=" + x + ((x == null) ? "" : ", value.kind=" + x.getKind());
+        return x;
+    }
+
+    private T assertLong(T x) {
+        assert x != null && (x.getKind() == Kind.Long);
+        return x;
+    }
+
+    private T assertInt(T x) {
+        assert x != null && (x.getKind() == Kind.Int);
+        return x;
+    }
+
+    private T assertFloat(T x) {
+        assert x != null && (x.getKind() == Kind.Float);
+        return x;
+    }
+
+    private T assertObject(T x) {
+        assert x != null && (x.getKind() == Kind.Object);
+        return x;
+    }
+
+    private T assertDouble(T x) {
+        assert x != null && (x.getKind() == Kind.Double);
+        return x;
+    }
+
+    private void assertHigh(T x) {
+        assert x == null;
+    }
+
 }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java	Wed Apr 16 14:02:52 2014 +0200
@@ -82,12 +82,14 @@
         public boolean isLoopHeader;
         public int loopId;
 
-        public FixedWithNextNode firstInstruction;
-        public HIRFrameStateBuilder entryState;
+        /**
+         * XXX to be removed - currently only used by baseline compiler
+         */
+        public Loop<BciBlock> loop;
+        public boolean isLoopEnd;
 
-        // public ArrayList<BciBlock> successors = new ArrayList<>(2);
-        // public ArrayList<BciBlock> predecessors = new ArrayList<>(2); // only used in the
-        // baseline
+        public FixedWithNextNode firstInstruction;
+        public AbstractFrameStateBuilder<?, ?> entryState;
 
         public long exits;
 
@@ -148,14 +150,12 @@
             return sb.toString();
         }
 
-        public Loop getLoop() {
-            // TODO Auto-generated method stub
-            return null;
+        public Loop<BciBlock> getLoop() {
+            return loop;
         }
 
         public int getLoopDepth() {
-            // TODO Auto-generated method stub
-            return 0;
+            return Long.bitCount(loops);
         }
 
         public boolean isLoopHeader() {
@@ -163,13 +163,11 @@
         }
 
         public boolean isLoopEnd() {
-            // TODO Auto-generated method stub
-            return false;
+            return isLoopEnd;
         }
 
         public boolean isExceptionEntry() {
-            // TODO Auto-generated method stub
-            return false;
+            return isExceptionEntry;
         }
 
         public BciBlock getSuccessor(int index) {
@@ -720,6 +718,10 @@
         for (BciBlock successor : block.getSuccessors()) {
             // Recursively process successors.
             loops |= computeBlockOrder(successor);
+            if (block.visited && successor.active) {
+                // Reached block via backward branch.
+                block.isLoopEnd = true;
+            }
         }
 
         block.loops = loops;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeDisassembler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeDisassembler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -117,26 +117,7 @@
                         String desc = null;
                         if (constant instanceof Constant) {
                             Constant c = ((Constant) constant);
-                            switch (c.getKind()) {
-                                case Int :
-                                    desc = String.valueOf(c.asInt());
-                                    break;
-                                case Float:
-                                    desc = String.valueOf(c.asFloat());
-                                    break;
-                                case Object:
-                                    desc = Kind.Object.format(c.asObject());
-                                    break;
-                                case Double :
-                                    desc = String.valueOf(c.asDouble());
-                                    break;
-                                case Long :
-                                    desc = String.valueOf(c.asLong());
-                                    break;
-                                default:
-                                    desc = c.toString();
-                                    break;
-                            }
+                            desc = c.toValueString();
                         } else {
                             desc = constant.toString();
                         }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,7 +25,6 @@
 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
 import static com.oracle.graal.bytecode.Bytecodes.*;
-import static com.oracle.graal.java.GraphBuilderPhase.RuntimeCalls.*;
 import static com.oracle.graal.phases.GraalOptions.*;
 import static java.lang.reflect.Modifier.*;
 
@@ -59,12 +58,6 @@
  */
 public class GraphBuilderPhase extends BasePhase<HighTierContext> {
 
-    public static final class RuntimeCalls {
-
-        public static final ForeignCallDescriptor CREATE_NULL_POINTER_EXCEPTION = new ForeignCallDescriptor("createNullPointerException", NullPointerException.class);
-        public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", ArrayIndexOutOfBoundsException.class, int.class);
-    }
-
     private final GraphBuilderConfiguration graphBuilderConfig;
 
     public GraphBuilderPhase(GraphBuilderConfiguration graphBuilderConfig) {
@@ -122,13 +115,10 @@
             }
         }
 
-        private BciBlock[] loopHeaders;
-        private LocalLiveness liveness;
-
         /**
          * Gets the current frame state being processed by this builder.
          */
-        protected AbstractFrameStateBuilder<ValueNode> getCurrentFrameState() {
+        protected HIRFrameStateBuilder getCurrentFrameState() {
             return parser.getFrameState();
         }
 
@@ -200,6 +190,8 @@
 
         class BytecodeParser extends AbstractBytecodeParser<ValueNode, HIRFrameStateBuilder> {
 
+            private BciBlock[] loopHeaders;
+            private LocalLiveness liveness;
             /**
              * Head of placeholder list.
              */
@@ -569,6 +561,12 @@
             }
 
             @Override
+            protected void genGoto() {
+                appendGoto(createTarget(currentBlock.getSuccessors().get(0), frameState));
+                assert currentBlock.numNormalSuccessors() == 1;
+            }
+
+            @Override
             protected ValueNode genObjectEquals(ValueNode x, ValueNode y) {
                 return new ObjectEqualsNode(x, y);
             }
@@ -644,16 +642,10 @@
                 append(new IfNode(currentGraph.unique(new IsNullNode(receiver)), trueSucc, falseSucc, 0.01));
                 lastInstr = falseSucc;
 
-                if (OmitHotExceptionStacktrace.getValue()) {
-                    ValueNode exception = ConstantNode.forObject(cachedNullPointerException, metaAccess, currentGraph);
-                    trueSucc.setNext(handleException(exception, bci()));
-                } else {
-                    DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_NULL_POINTER_EXCEPTION));
-                    call.setStamp(StampFactory.exactNonNull(metaAccess.lookupJavaType(CREATE_NULL_POINTER_EXCEPTION.getResultType())));
-                    call.setStateAfter(frameState.create(bci()));
-                    trueSucc.setNext(call);
-                    call.setNext(handleException(call, bci()));
-                }
+                BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, NullPointerException.class));
+                exception.setStateAfter(frameState.create(bci()));
+                trueSucc.setNext(exception);
+                exception.setNext(handleException(exception, bci()));
             }
 
             @Override
@@ -663,16 +655,10 @@
                 append(new IfNode(currentGraph.unique(new IntegerBelowThanNode(index, length)), trueSucc, falseSucc, 0.99));
                 lastInstr = trueSucc;
 
-                if (OmitHotExceptionStacktrace.getValue()) {
-                    ValueNode exception = ConstantNode.forObject(cachedArrayIndexOutOfBoundsException, metaAccess, currentGraph);
-                    falseSucc.setNext(handleException(exception, bci()));
-                } else {
-                    DeferredForeignCallNode call = currentGraph.add(new DeferredForeignCallNode(CREATE_OUT_OF_BOUNDS_EXCEPTION, index));
-                    call.setStamp(StampFactory.exactNonNull(metaAccess.lookupJavaType(CREATE_OUT_OF_BOUNDS_EXCEPTION.getResultType())));
-                    call.setStateAfter(frameState.create(bci()));
-                    falseSucc.setNext(call);
-                    call.setNext(handleException(call, bci()));
-                }
+                BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, ArrayIndexOutOfBoundsException.class, index));
+                exception.setStateAfter(frameState.create(bci()));
+                falseSucc.setNext(exception);
+                exception.setNext(handleException(exception, bci()));
             }
 
             @Override
@@ -714,9 +700,9 @@
             @Override
             protected void genInvokeDynamic(JavaMethod target) {
                 if (target instanceof ResolvedJavaMethod) {
-                    Object appendix = constantPool.lookupAppendix(stream.readCPI4(), Bytecodes.INVOKEDYNAMIC);
+                    Constant appendix = constantPool.lookupAppendix(stream.readCPI4(), Bytecodes.INVOKEDYNAMIC);
                     if (appendix != null) {
-                        frameState.apush(ConstantNode.forObject(appendix, metaAccess, currentGraph));
+                        frameState.apush(ConstantNode.forConstant(appendix, metaAccess, currentGraph));
                     }
                     ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(false), target.getSignature().getParameterCount(false));
                     appendInvoke(InvokeKind.Static, (ResolvedJavaMethod) target, args);
@@ -736,9 +722,9 @@
                      * +and+invokedynamic
                      */
                     boolean hasReceiver = !isStatic(((ResolvedJavaMethod) target).getModifiers());
-                    Object appendix = constantPool.lookupAppendix(stream.readCPI(), Bytecodes.INVOKEVIRTUAL);
+                    Constant appendix = constantPool.lookupAppendix(stream.readCPI(), Bytecodes.INVOKEVIRTUAL);
                     if (appendix != null) {
-                        frameState.apush(ConstantNode.forObject(appendix, metaAccess, currentGraph));
+                        frameState.apush(ConstantNode.forConstant(appendix, metaAccess, currentGraph));
                     }
                     ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(hasReceiver), target.getSignature().getParameterCount(hasReceiver));
                     if (hasReceiver) {
@@ -884,13 +870,12 @@
             }
 
             @Override
-            protected void setBlockSuccessor(ValueNode switchNode, int i, ValueNode createBlockTarget) {
-                ((IntegerSwitchNode) switchNode).setBlockSuccessor(i, (AbstractBeginNode) createBlockTarget);
-            }
-
-            @Override
-            protected ValueNode genIntegerSwitch(ValueNode value, int size, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
-                return new IntegerSwitchNode(value, size, keys, keyProbabilities, keySuccessors);
+            protected void genIntegerSwitch(ValueNode value, ArrayList<BciBlock> actualSuccessors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
+                double[] successorProbabilities = successorProbabilites(actualSuccessors.size(), keySuccessors, keyProbabilities);
+                IntegerSwitchNode switchNode = append(new IntegerSwitchNode(value, actualSuccessors.size(), keys, keyProbabilities, keySuccessors));
+                for (int i = 0; i < actualSuccessors.size(); i++) {
+                    switchNode.setBlockSuccessor(i, createBlockTarget(successorProbabilities[i], actualSuccessors.get(i), frameState));
+                }
             }
 
             @Override
@@ -991,7 +976,7 @@
                             }
                             lastLoopExit = loopExit;
                             Debug.log("Target %s (%s) Exits %s, scanning framestates...", targetBlock, target, loop);
-                            newState.insertLoopProxies(loopExit, loop.entryState);
+                            newState.insertLoopProxies(loopExit, (HIRFrameStateBuilder) loop.entryState);
                             loopExit.setStateAfter(newState.create(bci));
                         }
 
@@ -1002,23 +987,17 @@
                 return new Target(target, state);
             }
 
-            @Override
-            protected ValueNode genDeoptimization() {
-                return currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
+            private FixedNode createTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
+                assert probability >= 0 && probability <= 1.01 : probability;
+                if (isNeverExecutedCode(probability)) {
+                    return currentGraph.add(new DeoptimizeNode(InvalidateReprofile, UnreachedCode));
+                } else {
+                    assert block != null;
+                    return createTarget(block, stateAfter);
+                }
             }
 
-            @Override
-            protected FixedNode createTarget(double probability, BciBlock block, AbstractFrameStateBuilder<ValueNode> stateAfter) {
-                ValueNode fixed = super.createTarget(probability, block, stateAfter);
-                assert fixed instanceof FixedNode;
-                return (FixedNode) fixed;
-
-            }
-
-            @Override
-            protected FixedNode createTarget(BciBlock block, AbstractFrameStateBuilder<ValueNode> abstractState) {
-                assert abstractState instanceof HIRFrameStateBuilder;
-                HIRFrameStateBuilder state = (HIRFrameStateBuilder) abstractState;
+            private FixedNode createTarget(BciBlock block, HIRFrameStateBuilder state) {
                 assert block != null && state != null;
                 assert !block.isExceptionEntry || state.stackSize() == 1;
 
@@ -1039,7 +1018,7 @@
                 }
 
                 // We already saw this block before, so we have to merge states.
-                if (!block.entryState.isCompatibleWith(state)) {
+                if (!((HIRFrameStateBuilder) block.entryState).isCompatibleWith(state)) {
                     throw new BailoutException("stacks do not match; bytecodes would not verify");
                 }
 
@@ -1052,7 +1031,7 @@
                     LoopBeginNode loopBegin = (LoopBeginNode) block.firstInstruction;
                     Target target = checkLoopExit(currentGraph.add(new LoopEndNode(loopBegin)), block, state);
                     FixedNode result = target.fixed;
-                    block.entryState.merge(loopBegin, target.state);
+                    ((HIRFrameStateBuilder) block.entryState).merge(loopBegin, target.state);
 
                     Debug.log("createTarget %s: merging backward branch to loop header %s, result: %s", block, loopBegin, result);
                     return result;
@@ -1087,7 +1066,7 @@
                 AbstractEndNode newEnd = currentGraph.add(new EndNode());
                 Target target = checkLoopExit(newEnd, block, state);
                 FixedNode result = target.fixed;
-                block.entryState.merge(mergeNode, target.state);
+                ((HIRFrameStateBuilder) block.entryState).merge(mergeNode, target.state);
                 mergeNode.addForwardEnd(newEnd);
 
                 Debug.log("createTarget %s: merging state, result: %s", block, result);
@@ -1098,8 +1077,7 @@
              * Returns a block begin node with the specified state. If the specified probability is
              * 0, the block deoptimizes immediately.
              */
-            @Override
-            protected AbstractBeginNode createBlockTarget(double probability, BciBlock block, AbstractFrameStateBuilder<ValueNode> stateAfter) {
+            private AbstractBeginNode createBlockTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
                 FixedNode target = createTarget(probability, block, stateAfter);
                 AbstractBeginNode begin = AbstractBeginNode.begin(target);
 
@@ -1126,7 +1104,7 @@
                 try (Indent indent = Debug.logAndIndent("Parsing block %s  firstInstruction: %s  loopHeader: %b", block, block.firstInstruction, block.isLoopHeader)) {
 
                     lastInstr = block.firstInstruction;
-                    frameState = block.entryState;
+                    frameState = (HIRFrameStateBuilder) block.entryState;
                     parser.setCurrentFrameState(frameState);
                     currentBlock = block;
 
@@ -1235,10 +1213,7 @@
                 }
             }
 
-            @Override
-            protected void appendGoto(ValueNode targetNode) {
-                assert targetNode instanceof FixedNode;
-                FixedNode target = (FixedNode) targetNode;
+            private void appendGoto(FixedNode target) {
                 if (lastInstr != null) {
                     lastInstr.setNext(target);
                 }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.java;
 
 import static com.oracle.graal.graph.iterators.NodePredicates.*;
-import static com.oracle.graal.nodes.ValueNodeUtil.*;
 import static java.lang.reflect.Modifier.*;
 
 import java.util.*;
@@ -32,39 +31,25 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.Node.Verbosity;
-import com.oracle.graal.java.BciBlockMapping.BciBlock;
-import com.oracle.graal.java.BciBlockMapping.LocalLiveness;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
 
-public class HIRFrameStateBuilder extends AbstractFrameStateBuilder<ValueNode> {
+public class HIRFrameStateBuilder extends AbstractFrameStateBuilder<ValueNode, HIRFrameStateBuilder> {
 
     private static final ValueNode[] EMPTY_ARRAY = new ValueNode[0];
     private static final MonitorIdNode[] EMPTY_MONITOR_ARRAY = new MonitorIdNode[0];
 
-    private final ValueNode[] locals;
-    private final ValueNode[] stack;
-    private ValueNode[] lockedObjects;
     private MonitorIdNode[] monitorIds;
     private final StructuredGraph graph;
 
-    /**
-     * @see BytecodeFrame#rethrowException
-     */
-    private boolean rethrowException;
-
     public HIRFrameStateBuilder(ResolvedJavaMethod method, StructuredGraph graph, boolean eagerResolve) {
-        super(method);
+        super(method, new ValueNode[method.getMaxLocals()], new ValueNode[Math.max(1, method.getMaxStackSize())], EMPTY_ARRAY);
 
         assert graph != null;
 
-        this.locals = new ValueNode[method.getMaxLocals()];
-        // we always need at least one stack slot (for exceptions)
-        this.stack = new ValueNode[Math.max(1, method.getMaxStackSize())];
-        this.lockedObjects = EMPTY_ARRAY;
         this.monitorIds = EMPTY_MONITOR_ARRAY;
         this.graph = graph;
 
@@ -85,7 +70,7 @@
             if (eagerResolve) {
                 type = type.resolve(accessingClass);
             }
-            Kind kind = type.getKind().getStackKind();
+            Kind kind = type.getKind();
             Stamp stamp;
             if (kind == Kind.Object && type instanceof ResolvedJavaType) {
                 stamp = StampFactory.declared((ResolvedJavaType) type);
@@ -103,12 +88,7 @@
         super(other);
         assert other.graph != null;
         graph = other.graph;
-        locals = other.locals.clone();
-        stack = other.stack.clone();
-        lockedObjects = other.lockedObjects == EMPTY_ARRAY ? EMPTY_ARRAY : other.lockedObjects.clone();
         monitorIds = other.monitorIds == EMPTY_MONITOR_ARRAY ? EMPTY_MONITOR_ARRAY : other.monitorIds.clone();
-        stackSize = other.stackSize;
-        rethrowException = other.rethrowException;
 
         assert locals.length == method.getMaxLocals();
         assert stack.length == Math.max(1, method.getMaxStackSize());
@@ -116,6 +96,11 @@
     }
 
     @Override
+    protected ValueNode[] getEmtpyArray() {
+        return EMPTY_ARRAY;
+    }
+
+    @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("[locals: [");
@@ -142,10 +127,12 @@
         return graph.add(new FrameState(method, bci, locals, Arrays.asList(stack).subList(0, stackSize), lockedObjects, monitorIds, rethrowException, false));
     }
 
+    @Override
     public HIRFrameStateBuilder copy() {
         return new HIRFrameStateBuilder(this);
     }
 
+    @Override
     public boolean isCompatibleWith(HIRFrameStateBuilder other) {
         assert method.equals(other.method) && graph == other.graph && localsSize() == other.localsSize() : "Can only compare frame states of the same method";
         assert lockedObjects.length == monitorIds.length && other.lockedObjects.length == other.monitorIds.length : "mismatch between lockedObjects and monitorIds";
@@ -192,7 +179,7 @@
 
         } else if (block.isPhiAtMerge(currentValue)) {
             if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) {
-                propagateDelete((PhiNode) currentValue);
+                propagateDelete((ValuePhiNode) currentValue);
                 return null;
             }
             ((PhiNode) currentValue).addInput(otherValue);
@@ -204,7 +191,7 @@
                 return null;
             }
 
-            PhiNode phi = graph.addWithoutUnique(new PhiNode(currentValue.stamp().unrestricted(), block));
+            ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(currentValue.stamp().unrestricted(), block));
             for (int i = 0; i < block.phiPredecessorCount(); i++) {
                 phi.addInput(currentValue);
             }
@@ -218,16 +205,16 @@
     }
 
     private void propagateDelete(FloatingNode node) {
-        assert node instanceof PhiNode || node instanceof ProxyNode;
+        assert node instanceof ValuePhiNode || node instanceof ProxyNode;
         if (node.isDeleted()) {
             return;
         }
         // Collect all phi functions that use this phi so that we can delete them recursively (after
         // we delete ourselves to avoid circles).
-        List<FloatingNode> propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(PhiNode.class).or(ProxyNode.class)).snapshot();
+        List<FloatingNode> propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(ValuePhiNode.class).or(ProxyNode.class)).snapshot();
 
         // Remove the phi function from all FrameStates where it is used and then delete it.
-        assert node.usages().filter(isNotA(FrameState.class).nor(PhiNode.class).nor(ProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states";
+        assert node.usages().filter(isNotA(FrameState.class).nor(ValuePhiNode.class).nor(ProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states";
         node.replaceAtUsages(null);
         node.safeDelete();
 
@@ -296,13 +283,13 @@
         }
     }
 
-    private PhiNode createLoopPhi(MergeNode block, ValueNode value) {
+    private ValuePhiNode createLoopPhi(MergeNode block, ValueNode value) {
         if (value == null) {
             return null;
         }
         assert !block.isPhiAtMerge(value) : "phi function for this block already created";
 
-        PhiNode phi = graph.addWithoutUnique(new PhiNode(value.stamp().unrestricted(), block));
+        ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(value.stamp().unrestricted(), block));
         phi.addInput(value);
         return phi;
     }
@@ -310,63 +297,15 @@
     public void cleanupDeletedPhis() {
         for (int i = 0; i < localsSize(); i++) {
             if (localAt(i) != null && localAt(i).isDeleted()) {
-                assert localAt(i) instanceof PhiNode || localAt(i) instanceof ProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i);
+                assert localAt(i) instanceof ValuePhiNode || localAt(i) instanceof ProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i);
                 storeLocal(i, null);
             }
         }
     }
 
-    public void clearNonLiveLocals(BciBlock block, LocalLiveness liveness, boolean liveIn) {
-        if (liveness == null) {
-            return;
-        }
-        if (liveIn) {
-            for (int i = 0; i < locals.length; i++) {
-                if (!liveness.localIsLiveIn(block, i)) {
-                    locals[i] = null;
-                }
-            }
-        } else {
-            for (int i = 0; i < locals.length; i++) {
-                if (!liveness.localIsLiveOut(block, i)) {
-                    locals[i] = null;
-                }
-            }
-        }
-    }
-
     /**
-     * @see BytecodeFrame#rethrowException
-     */
-    public boolean rethrowException() {
-        return rethrowException;
-    }
-
-    /**
-     * @see BytecodeFrame#rethrowException
-     */
-    public void setRethrowException(boolean b) {
-        rethrowException = b;
-    }
-
-    @Override
-    public int localsSize() {
-        return locals.length;
-    }
-
-    @Override
-    public ValueNode localAt(int i) {
-        return locals[i];
-    }
-
-    @Override
-    public ValueNode stackAt(int i) {
-        return stack[i];
-    }
-
-    /**
      * Adds a locked monitor to this frame state.
-     * 
+     *
      * @param object the object whose monitor will be locked.
      */
     public void pushLock(ValueNode object, MonitorIdNode monitorId) {
@@ -380,7 +319,7 @@
 
     /**
      * Removes a locked monitor from this frame state.
-     * 
+     *
      * @return the object whose monitor was removed from the locks list.
      */
     public ValueNode popLock() {
@@ -404,159 +343,6 @@
         return lockedObjects.length;
     }
 
-    @Override
-    public ValueNode loadLocal(int i) {
-        ValueNode x = locals[i];
-        assert !x.isDeleted();
-        assert !isTwoSlot(x.getKind()) || locals[i + 1] == null;
-        assert i == 0 || locals[i - 1] == null || !isTwoSlot(locals[i - 1].getKind());
-        return x;
-    }
-
-    @Override
-    public void storeLocal(int i, ValueNode x) {
-        assert x == null || x.isAlive() && x.getKind() != Kind.Void && x.getKind() != Kind.Illegal : "unexpected value: " + x;
-        locals[i] = x;
-        if (x != null && isTwoSlot(x.getKind())) {
-            // if this is a double word, then kill i+1
-            locals[i + 1] = null;
-        }
-        if (x != null && i > 0) {
-            ValueNode p = locals[i - 1];
-            if (p != null && isTwoSlot(p.getKind())) {
-                // if there was a double word at i - 1, then kill it
-                locals[i - 1] = null;
-            }
-        }
-    }
-
-    @Override
-    public void storeStack(int i, ValueNode x) {
-        assert x == null || x.isAlive() && (stack[i] == null || x.getKind() == stack[i].getKind()) : "Method does not handle changes from one-slot to two-slot values or non-alive values";
-        stack[i] = x;
-    }
-
-    @Override
-    public void push(Kind kind, ValueNode x) {
-        assert x.isAlive() && x.getKind() != Kind.Void && x.getKind() != Kind.Illegal;
-        xpush(assertKind(kind, x));
-        if (isTwoSlot(kind)) {
-            xpush(null);
-        }
-    }
-
-    @Override
-    public void xpush(ValueNode x) {
-        assert x == null || (x.isAlive() && x.getKind() != Kind.Void && x.getKind() != Kind.Illegal);
-        stack[stackSize++] = x;
-    }
-
-    @Override
-    public void ipush(ValueNode x) {
-        xpush(assertInt(x));
-    }
-
-    @Override
-    public void fpush(ValueNode x) {
-        xpush(assertFloat(x));
-    }
-
-    @Override
-    public void apush(ValueNode x) {
-        xpush(assertObject(x));
-    }
-
-    @Override
-    public void lpush(ValueNode x) {
-        xpush(assertLong(x));
-        xpush(null);
-    }
-
-    @Override
-    public void dpush(ValueNode x) {
-        xpush(assertDouble(x));
-        xpush(null);
-    }
-
-    @Override
-    public void pushReturn(Kind kind, ValueNode x) {
-        if (kind != Kind.Void) {
-            push(kind.getStackKind(), x);
-        }
-    }
-
-    @Override
-    public ValueNode pop(Kind kind) {
-        assert kind != Kind.Void;
-        if (isTwoSlot(kind)) {
-            xpop();
-        }
-        return assertKind(kind, xpop());
-    }
-
-    @Override
-    public ValueNode xpop() {
-        ValueNode result = stack[--stackSize];
-        assert result == null || !result.isDeleted();
-        return result;
-    }
-
-    @Override
-    public ValueNode ipop() {
-        return assertInt(xpop());
-    }
-
-    @Override
-    public ValueNode fpop() {
-        return assertFloat(xpop());
-    }
-
-    @Override
-    public ValueNode apop() {
-        return assertObject(xpop());
-    }
-
-    @Override
-    public ValueNode lpop() {
-        assertHigh(xpop());
-        return assertLong(xpop());
-    }
-
-    @Override
-    public ValueNode dpop() {
-        assertHigh(xpop());
-        return assertDouble(xpop());
-    }
-
-    @Override
-    public ValueNode[] popArguments(int slotSize, int argSize) {
-        int base = stackSize - slotSize;
-        ValueNode[] r = new ValueNode[argSize];
-        int argIndex = 0;
-        int stackindex = 0;
-        while (stackindex < slotSize) {
-            ValueNode element = stack[base + stackindex];
-            assert element != null;
-            r[argIndex++] = element;
-            stackindex += stackSlots(element.getKind());
-        }
-        stackSize = base;
-        return r;
-    }
-
-    @Override
-    public ValueNode peek(int argumentNumber) {
-        int idx = stackSize() - 1;
-        for (int i = 0; i < argumentNumber; i++) {
-            if (stackAt(idx) == null) {
-                idx--;
-                assert isTwoSlot(stackAt(idx).getKind());
-            }
-            idx--;
-        }
-        return stackAt(idx);
-    }
-
     public boolean contains(ValueNode value) {
         for (int i = 0; i < localsSize(); i++) {
             if (localAt(i) == value) {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -84,7 +84,7 @@
         this.optionValueType = metaAccess.lookupJavaType(OptionValue.class);
         this.option = option;
         this.boxingTypes = new HashSet<>();
-        for (Class c : new Class[]{Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Float.class, Long.class, Double.class}) {
+        for (Class<?> c : new Class[]{Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Float.class, Long.class, Double.class}) {
             this.boxingTypes.add(metaAccess.lookupJavaType(c));
         }
     }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -64,7 +64,7 @@
             assert parameterTypes.length == args.length;
             for (int i = 0; i < args.length; i++) {
                 ParameterNode param = graph.getParameter(i);
-                Constant c = Constant.forBoxed(parameterTypes[i].getKind(), args[i]);
+                Constant c = getSnippetReflection().forBoxed(parameterTypes[i].getKind(), args[i]);
                 ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
                 param.replaceAtUsages(replacement);
             }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aaload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aaload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aaload_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aaload_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_aload_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_anewarray.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_anewarray.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_areturn.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_areturn.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_arraylength.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_arraylength.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_athrow.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_athrow.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_baload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_baload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_bastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_bastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_caload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_caload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_castore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_castore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_checkcast01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_checkcast01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_checkcast02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_checkcast02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2f.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2f.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2i01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2i01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2i02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2i02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_d2l03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dadd.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dadd.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_daload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_daload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp08.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp08.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp09.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp09.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp10.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dcmp10.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ddiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ddiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dmul.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dmul.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dneg.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dneg.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dneg2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dneg2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_drem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_drem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_drem extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dreturn.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dreturn.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dsub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dsub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dsub2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_dsub2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2d.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2d.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2i01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2i01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2i02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2i02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2l01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2l01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2l02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_f2l02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fadd.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fadd.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_faload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_faload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp08.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp08.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp09.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp09.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp10.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fcmp10.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fdiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fdiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fload_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fload_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fmul.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fmul.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fneg.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fneg.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_frem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_frem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_frem extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_freturn.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_freturn.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fsub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_fsub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_b.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_b.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_b extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_c.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_c.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_c extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_d.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_d.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_d extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_f.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_f.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_f extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_i.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_i.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_i extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_l.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_l.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_l extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_o.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_o.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_o extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_s.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_s.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_s extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_z.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getfield_z.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield_z extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_b.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_b.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_c.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_c.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_d.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_d.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_f.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_f.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_i.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_i.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_l.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_l.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_s.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_s.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_z.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_getstatic_z.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2b.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2b.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2c.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2c.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2d.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2d.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2f.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2f.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2l.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2l.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2s.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_i2s.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iadd3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iaload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iaload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iand.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iand.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iconst.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iconst.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_idiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_idiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_idiv2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_idiv2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifeq_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifge_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifgt.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifgt.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmplt1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmplt1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmplt2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmplt2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmpne1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmpne1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmpne2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ificmpne2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifle.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifle.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iflt.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iflt.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifne.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifne.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnonnull_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ifnull_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iinc_4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_0_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_1_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_1_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iload_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_imul.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_imul.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ineg.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ineg.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_instanceof.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_instanceof.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokeinterface.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokeinterface.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokespecial.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokespecial.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokespecial2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokespecial2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokestatic.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokestatic.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokevirtual.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_invokevirtual.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ior.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ior.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_irem3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ireturn.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ireturn.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ishl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ishl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ishr.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ishr.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_isub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_isub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iushr.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_iushr.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ixor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ixor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2d.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2d.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2f.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2f.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2i.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2i.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_l2i extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2i_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_l2i_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ladd.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ladd.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ladd2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ladd2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_laload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_laload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_land.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_land.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lcmp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lcmp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldc_06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_ldiv3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lload_3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lmul.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lmul.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lneg.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lneg.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lookupswitch05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lrem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lrem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lrem2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lrem2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lreturn.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lreturn.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshr.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshr.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshr02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lshr02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lsub.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lsub.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lushr.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lushr.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lxor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_lxor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_monitorenter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_monitorenter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_monitorenter02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_monitorenter02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_multianewarray04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_new.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_new.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_newarray.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_newarray.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
-import com.oracle.graal.jtt.*;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putfield_04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putstatic.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_putstatic.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_saload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_saload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_sastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_sastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_tableswitch4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_wide01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_wide01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_wide02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/bytecode/BC_wide02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.bytecode;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aaload0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aaload0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_aaload0 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aaload1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aaload1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aastore0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aastore0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_aastore0 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aastore1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_aastore1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_anewarray.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_anewarray.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_arraylength.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_arraylength.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_arraylength extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_athrow0 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_athrow2 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_athrow3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_athrow3 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_baload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_baload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_baload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_bastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_bastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_bastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_caload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_caload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_caload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_castore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_castore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_castore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast3.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast3.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast5.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast5.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast6.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_checkcast6.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_daload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_daload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_daload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_dastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_dastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_dastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_faload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_faload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_faload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_fastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_fastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_fastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_getfield.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_getfield.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_getfield extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_getfield1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_getfield1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,9 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
-import com.oracle.graal.jtt.*;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.jtt.*;
 
 public class BC_getfield1 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_iaload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_iaload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_iaload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_iastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_iastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_iastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_idiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_idiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_idiv extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_idiv2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_idiv2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_idiv2 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokespecial01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokespecial01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokevirtual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokevirtual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokevirtual02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_invokevirtual02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_irem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_irem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_irem extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_laload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_laload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_laload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_lastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_lastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_lastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_ldiv.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_ldiv.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_ldiv extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_ldiv2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_ldiv2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_ldiv2 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_lrem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_lrem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_lrem extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_monitorenter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_monitorenter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_multianewarray.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_multianewarray.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_newarray.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_newarray.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,9 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
-import com.oracle.graal.jtt.*;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_putfield.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_putfield.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_putfield extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_saload.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_saload.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_saload extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_sastore.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/BC_sastore.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BC_sastore extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Loop03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NASE_1.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NASE_1.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NASE_2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NASE_2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_00.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_00.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,8 @@
 
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_08.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_08.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_09.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_09.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_10.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_10.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_11.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_NPE_11.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_StackOverflowError_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_StackOverflowError_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /**
  * Some basic checking of the stack trace produced after a StackOverflowError.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Two03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Catch_Unresolved03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Locals.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Locals.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Except_Locals extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Except_Synchronized02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Except_Synchronized04 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Except_Synchronized05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Except_Synchronized05 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Finally01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Finally01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Finally02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Finally02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_AIOOBE_00.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_AIOOBE_00.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_CCE_00.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_CCE_00.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_00.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_00.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/StackTrace_NPE_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_InCatch01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_InCatch02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InCatch03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_InCatch03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InNested.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_InNested.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Throw_InNested extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_NPE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_NPE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_NPE_01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Throw_Synchronized01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Throw_Synchronized02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.except;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Throw_Synchronized03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_Synchronized04 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/except/Throw_Synchronized05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.except;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Throw_Synchronized05 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_allocate04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_array04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_control01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_control01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_control02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_control02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_convert01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_convert01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_count.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_count.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Runs: 10 = 55; 20 = 210; 30 = 465; 40 = 820;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_dead01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_dead01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_demo01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_demo01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Runs: 10 = 55; 20 = 210; 30 = 465; 40 = 820;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,8 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_idea.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_idea.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.util.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class HP_idea extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_inline01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_inline01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_inline02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_inline02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_invoke01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_invoke01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 package com.oracle.graal.jtt.hotpath;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_life.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_life.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,8 @@
 
 import java.util.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_nest01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_nest01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_nest02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_nest02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,8 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_scope01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_scope01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_scope02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_scope02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_trees01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_trees01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6186134.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6186134.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.util.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 // @formatter:off
 public class Test6186134 extends JTTTest {
@@ -42,7 +43,7 @@
             return num-- > 0;
         }
 
-        public ArrayList test1() {
+        public ArrayList<?> test1() {
             ArrayList<Object> res = new ArrayList<>();
             int maxResults = Integer.MAX_VALUE;
             int n = 0;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6196102.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6196102.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.hotspot;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /**
  * @bug 6196102
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6753639.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6753639.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.hotspot;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /**
  * @test
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6823354.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6823354.java	Wed Apr 16 14:02:52 2014 +0200
@@ -198,10 +198,10 @@
     }
 
     static void loadandrunclass(String classname) throws Exception {
-        Class cl = Class.forName(classname);
+        Class<?> cl = Class.forName(classname);
         URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
         ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
-        Class c = loader.loadClass(classname);
+        Class<?> c = loader.loadClass(classname);
         Runnable r = (Runnable) c.newInstance();
         r.run();
     }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6850611.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotspot/Test6850611.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.hotspot;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 //@formatter:off
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CharacterBits.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CharacterBits.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class CharacterBits extends JTTTest {
     @SuppressWarnings("unused") private static char init = Character.reverseBytes((char) 42);
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Class_getName.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Class_getName.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/EnumMap01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/EnumMap01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.util.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/EnumMap02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/EnumMap02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.util.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/IntegerBits.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/IntegerBits.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class IntegerBits extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/LongBits.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/LongBits.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class LongBits extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/ShortBits.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/ShortBits.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class ShortBits extends JTTTest {
     @SuppressWarnings("unused") private static short init = Short.reverseBytes((short) 42);
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_currentTimeMillis02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_nanoTime01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_nanoTime01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_nanoTime02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_nanoTime02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_setOut.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/System_setOut.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.io.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Thread_setName.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Thread_setName.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAccess01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAccess01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,10 +24,10 @@
 
 import java.lang.reflect.*;
 
-import com.oracle.graal.test.*;
+import sun.misc.*;
+
 import com.oracle.graal.jtt.*;
-
-import sun.misc.*;
+import com.oracle.graal.test.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAllocateInstance01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAllocateInstance01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,7 +43,7 @@
         return newObject.field01;
     }
 
-    public static void testClassForException(Class clazz) throws SecurityException, InstantiationException {
+    public static void testClassForException(Class<?> clazz) throws SecurityException, InstantiationException {
         final Unsafe unsafe = getUnsafe();
         unsafe.allocateInstance(clazz);
     }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,9 +26,9 @@
 
 import org.junit.*;
 
-import com.oracle.graal.jtt.*;
+import sun.misc.*;
 
-import sun.misc.*;
+import com.oracle.graal.jtt.*;
 
 public class Unsafe_compareAndSwap extends JTTTest {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwapNullCheck.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.jtt.jdk;
+
+import org.junit.*;
+
+import sun.misc.*;
+
+import com.oracle.graal.jtt.*;
+
+public class Unsafe_compareAndSwapNullCheck extends JTTTest {
+
+    static final Unsafe unsafe = UnsafeAccess01.getUnsafe();
+    static final long valueOffset;
+    static {
+        try {
+            valueOffset = unsafe.objectFieldOffset(Unsafe_compareAndSwap.class.getDeclaredField("value"));
+        } catch (Exception ex) {
+            throw new Error(ex);
+        }
+    }
+
+    long value;
+    long lng;
+
+    public static void test(Unsafe_compareAndSwapNullCheck u, long expected, long newValue) {
+        @SuppressWarnings("unused")
+        long l = u.lng;
+        unsafe.compareAndSwapLong(u, valueOffset, expected, newValue);
+    }
+
+    @Test
+    public void run0() throws Throwable {
+        runTest(EMPTY, false, true, "test", null, 1L, 2L);
+    }
+}
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Boxed_TYPE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Boxed_TYPE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Bridge_method01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Bridge_method01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/ClassLoader_loadClass01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/ClassLoader_loadClass01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.net.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_Literal01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_Literal01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Class_Literal01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_asSubclass01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_asSubclass01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Class_asSubclass01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_cast01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_cast01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Class_cast01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_cast02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_cast02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_cast02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Class_forName01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,14 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Class_forName02 extends JTTTest {
 
     public static String test(int i) throws ClassNotFoundException {
         String clname = null;
-        Class cl = null;
+        Class<?> cl = null;
         if (i == 0) {
             clname = "java.lang.Object";
             cl = Object.class;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.net.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
@@ -33,7 +33,7 @@
 
     public static String test(int i) throws ClassNotFoundException {
         String clname = null;
-        Class cl = null;
+        Class<?> cl = null;
         if (i == 0) {
             clname = "java.lang.Object[]";
             cl = Object.class;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_forName05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.net.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getComponentType01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getComponentType01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getComponentType01 extends JTTTest {
 
     public static String test(int i) {
-        Class cl = Object.class;
+        Class<?> cl = Object.class;
         if (i == 0) {
             cl = int.class;
         } else if (i == 1) {
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getInterfaces01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getInterfaces01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getModifiers01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getModifiers01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.io.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getModifiers01 extends JTTTest {
 
@@ -38,7 +39,7 @@
     private static class Private {
     }
 
-    public static int test(Class c) {
+    public static int test(Class<?> c) {
         return c.getModifiers();
     }
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getName01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getName01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getName01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getName02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getName02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getName02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSimpleName01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSimpleName01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getSimpleName01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSimpleName02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSimpleName02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getSimpleName02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSuperClass01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_getSuperClass01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_getSuperClass01 extends JTTTest {
 
     public static String test(int i) {
-        Class cl = Object.class;
+        Class<?> cl = Object.class;
         if (i == 0) {
             cl = int.class;
         } else if (i == 1) {
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isArray01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isArray01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isArray01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isAssignableFrom01 extends JTTTest {
 
     public static boolean test(int i) {
-        Class source = Object.class;
+        Class<?> source = Object.class;
         if (i == 0) {
             source = int.class;
         }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isAssignableFrom02 extends JTTTest {
 
     public static boolean test(int i) {
-        Class source = Object.class;
+        Class<?> source = Object.class;
         if (i == 0) {
             source = int.class;
         }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isAssignableFrom03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,14 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isAssignableFrom03 extends JTTTest implements Cloneable {
 
     public static boolean test(int i) {
-        Class source = Object.class;
+        Class<?> source = Object.class;
         if (i == 0) {
             source = int.class;
         }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance04 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance05 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInstance06 extends JTTTest implements Cloneable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInstance07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,9 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
-import com.oracle.graal.jtt.*;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.jtt.*;
 
 public final class Class_isInstance07 extends JTTTest implements Cloneable {
 
@@ -35,7 +35,7 @@
     static final String[] sarray = {};
     static final Object thisObject = new Class_isInstance07();
 
-    public static boolean test(int i, Class c) {
+    public static boolean test(int i, Class<?> c) {
         Object object = null;
         if (i == 0) {
             object = obj;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInterface01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isInterface01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isInterface01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isPrimitive01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Class_isPrimitive01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_isPrimitive01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Double_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Double_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Double_toString.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Double_toString.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Float_01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Float_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greater01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greater02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greater03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greater03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greaterEqual01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greaterEqual02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_greaterEqual03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_greaterEqual03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_less01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_less02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_less03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_less03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_lessEqual01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_lessEqual02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Int_lessEqual03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Int_lessEqual03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/JDK_ClassLoaders01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/JDK_ClassLoaders01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/JDK_ClassLoaders02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/JDK_ClassLoaders02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -44,8 +44,9 @@
 
 import java.net.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_greater02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greater03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_greater03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_greaterEqual01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_greaterEqual02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_greaterEqual03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_greaterEqual03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_less01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_less02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_less03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_less03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_lessEqual01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_lessEqual02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_lessEqual03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Long_lessEqual03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_reverseBytes01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_reverseBytes01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_reverseBytes02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Long_reverseBytes02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_abs.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_abs.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_log.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_log.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_log10.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_log10.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_pow.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_pow.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_sin.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_sin.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_sqrt.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_sqrt.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_tan.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Math_tan.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_clone02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_clone02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Object_clone02 extends JTTTest implements Cloneable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_equals01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_equals01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_equals01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_getClass01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_getClass01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Object_getClass01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_hashCode01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_hashCode01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_hashCode01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_notify02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_notify02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_notify02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_notifyAll02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_notifyAll02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_notifyAll02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_toString01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_toString01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Object_toString01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_toString02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_toString02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Object_toString02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_wait02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_wait02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_wait02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_wait03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/Object_wait03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Object_wait03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/ProcessEnvironment_init.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/ProcessEnvironment_init.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.util.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class ProcessEnvironment_init extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/StringCoding_Scale.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/StringCoding_Scale.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class StringCoding_Scale extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_intern03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_valueOf01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/String_valueOf01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.lang;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/DegeneratedLoop.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/DegeneratedLoop.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop08.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop08.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop09.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop09.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop11.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop11.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop12.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop12.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop13.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop13.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop14.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop14.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop15.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop15.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Loop15 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests exiting 2 loops at the same time with escape-analysed values flowing out of loops
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop17.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/Loop17.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test around an object that escapes directly from inside a loop (no virtual phi on the loop)
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopEscape.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopEscape.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test around an object that escapes directly from inside a loop (no virtual phi on the loop)
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopInline.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopInline.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class LoopInline extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopLastIndexOf.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopLastIndexOf.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * see java.lang.String.lastIndexOf(char[], int, int, char[], int ,int, int)
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopParseLong.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopParseLong.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class LoopParseLong extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopPhi.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopPhi.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopSwitch01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopSwitch01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopUnroll.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopUnroll.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ArrayCompare01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ArrayCompare01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ArrayCompare02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ArrayCompare02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BC_invokevirtual2.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BC_invokevirtual2.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigByteParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigByteParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigDoubleParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigDoubleParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigFloatParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigFloatParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigFloatParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigFloatParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigIntParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigIntParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigIntParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigIntParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigInterfaceParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigInterfaceParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigLongParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigLongParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,9 @@
 
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigMixedParams03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,8 +25,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigObjectParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigObjectParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigObjectParams02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigObjectParams02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigParamsAlignment.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigParamsAlignment.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class BigParamsAlignment extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigShortParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigShortParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigVirtualParams01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/BigVirtualParams01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Bubblesort.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Bubblesort.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Bubblesort extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Fibonacci.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Fibonacci.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/InvokeVirtual_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/InvokeVirtual_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class InvokeVirtual_01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/InvokeVirtual_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/InvokeVirtual_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class InvokeVirtual_02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Matrix01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/Matrix01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ReferenceMap01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/ReferenceMap01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/StrangeFrames.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/StrangeFrames.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/String_format01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/String_format01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/String_format02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/String_format02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_String01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_String01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_boolean01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_boolean01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_byte01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_byte01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_char01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_char01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_double01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_double01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_float01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_float01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_int01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_int01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_long01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_long01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_short01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/micro/VarArgs_short01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.micro;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ABCE_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopy06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopyGeneric.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayCopyGeneric.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
-import com.oracle.graal.jtt.*;
+import org.junit.*;
 
-import org.junit.*;
+import com.oracle.graal.jtt.*;
 
 /*
  * Tests calls to the array copy method.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayLength01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ArrayLength01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of array length operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_idiv_16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_idiv_16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_idiv_4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_idiv_4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_imul_16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_imul_16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_imul_4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_imul_4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_ldiv_16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_ldiv_16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_ldiv_4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_ldiv_4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lmul_16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lmul_16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lmul_4.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lmul_4.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C16.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C16.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C24.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C24.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C32.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BC_lshr_C32.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BlockSkip01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/BlockSkip01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Cmov01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Cmov01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Cmov02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Cmov02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Conditional01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Conditional01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.util.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,14 +23,11 @@
 package com.oracle.graal.jtt.optimize;
 
 import java.lang.reflect.*;
-import java.util.*;
 
 import org.junit.*;
 
-import com.oracle.graal.test.*;
 import com.oracle.graal.jtt.*;
 
-@SuppressWarnings("unused")
 public class ConditionalElimination01 extends JTTTest {
 
     private static int x;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,16 +22,13 @@
  */
 package com.oracle.graal.jtt.optimize;
 
-import java.lang.reflect.*;
 import java.util.*;
 
 import org.junit.*;
 
-import com.oracle.graal.test.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.jtt.*;
 
-@SuppressWarnings("unused")
 public class ConditionalElimination02 extends JTTTest {
 
     private static Object o = null;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConvertCompare.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConvertCompare.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class ConvertCompare extends JTTTest {
     public static boolean test(int a, float d) {
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/DeadCode01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/DeadCode01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/DeadCode02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/DeadCode02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Cast01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Cast01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of float conversions
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Convert04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of float conversions
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer comparisons.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Double03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Float01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Float01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Float02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Float02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer comparisons.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_InstanceOf01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_InstanceOf01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Int01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Int01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Int02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Int02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer comparisons.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Long01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Long01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Long02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Long02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer comparisons.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Math01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Fold_Math01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/InferStamp01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/InferStamp01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /**
  * test some stamps in combination with full loop unrolling and shifts.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Inline01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Inline01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Inline02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Inline02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/LLE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/LLE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test case for local load elimination. It makes sure that the second field store is not eliminated, because
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/List_reorder_bug.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/List_reorder_bug.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Logic0.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Logic0.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test case for null check elimination.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test case for null check elimination.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test case for null check elimination.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Test case for null check elimination.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NCE_FlowSensitive05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.io.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_byte03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_char03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Narrow_short03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Phi03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Convert01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Convert01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization integer conversions.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Double01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Double01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of double operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Float01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Float01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Int04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_IntShift01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_IntShift01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_IntShift02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_IntShift02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_Long04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Reduce_LongShift02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of switches.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/Switch02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of switches.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/TypeCastElem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/TypeCastElem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Cast01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Cast01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Cast02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Cast02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Convert01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Convert01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization integer conversions.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Convert02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Convert02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization integer conversions.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Double01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Double01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Double02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Double02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Field01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Field01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Field02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Field02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests constant folding of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Float01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Float01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Float02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Float02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of float operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of instanceof operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  * Tests value numbering of instanceof operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_InstanceOf03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of instanceof operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Int03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of long operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests optimization of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Long03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of long operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Loop01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/VN_Loop01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.optimize;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  * Tests value numbering of integer operations.
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_get01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_get02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_get03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_get03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getBoolean01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getBoolean01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getBoolean01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getByte01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getByte01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getByte01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getChar01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getChar01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getChar01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getDouble01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getDouble01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getDouble01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getFloat01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getFloat01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getFloat01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getInt01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getInt01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getInt01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getLength01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getLength01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getLength01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getLong01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getLong01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getLong01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getShort01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_getShort01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_getShort01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance04 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance05 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_newInstance06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_newInstance06 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_set01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_set02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_set03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_set03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setBoolean01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setBoolean01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setBoolean01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setByte01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setByte01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setByte01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setChar01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setChar01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setChar01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setDouble01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setDouble01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setDouble01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setFloat01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setFloat01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setFloat01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setInt01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setInt01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setInt01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setLong01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setLong01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setLong01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setShort01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Array_setShort01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public class Array_setShort01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getDeclaredField01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getDeclaredField01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getDeclaredMethod01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getDeclaredMethod01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getField01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getField01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getField02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getField02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getMethod01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getMethod01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getMethod02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_getMethod02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_newInstance01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_newInstance02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Class_newInstance03 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance06.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance06.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_newInstance06 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance07.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Class_newInstance07.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Class_newInstance07 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.lang.reflect.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_get04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_getType01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_getType01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Field_set03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_except01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_except01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.lang.reflect.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.lang.reflect.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_main03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.lang.reflect.*;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_virtual01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Invoke_virtual01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
 
 import java.lang.reflect.*;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Method_getParameterTypes01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Method_getParameterTypes01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Method_getReturnType01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/reflect/Method_getReturnType01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.reflect;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitor_contended01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitor_contended01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Monitor_contended01 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitor_notowner01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitor_notowner01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Monitor_notowner01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitorenter01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitorenter01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Monitorenter01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitorenter02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Monitorenter02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Monitorenter02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Object_wait01 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Object_wait02 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Object_wait03 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Object_wait04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Object_wait04 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/ThreadLocal03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_currentThread01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_currentThread01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_currentThread01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_getState01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_getState01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_getState01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_getState02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_getState02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Thread_getState02 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_holdsLock01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_holdsLock01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_holdsLock01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isAlive01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isAlive01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_isAlive01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_isInterrupted01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,8 +26,8 @@
 
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 //Test all, mainly monitors
 public class Thread_isInterrupted02 extends JTTTest {
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted04.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted04.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted05.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_isInterrupted05.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 /*
  */
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Thread_join01 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Thread_join02 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join03.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_join03.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Thread_join03 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_new01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_new01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Thread_new01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_new02.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_new02.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public class Thread_new02 extends JTTTest implements Runnable {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_setPriority01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_setPriority01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_setPriority01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_sleep01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_sleep01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import com.oracle.graal.jtt.*;
 import com.oracle.graal.test.*;
-import com.oracle.graal.jtt.*;
 
 public final class Thread_sleep01 extends JTTTest {
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_yield01.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/threads/Thread_yield01.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,9 @@
  */
 package com.oracle.graal.jtt.threads;
 
+import org.junit.*;
+
 import com.oracle.graal.jtt.*;
-import org.junit.*;
 
 public final class Thread_yield01 extends JTTTest {
 
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,13 +29,13 @@
 import java.lang.reflect.*;
 
 import com.oracle.graal.amd64.*;
-import com.oracle.graal.amd64.AMD64.*;
+import com.oracle.graal.amd64.AMD64.CPUFeature;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.asm.amd64.AMD64Address.Scale;
-import com.oracle.graal.asm.amd64.AMD64Assembler.*;
+import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.spi.*;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,6 +34,8 @@
 import com.oracle.graal.lir.asm.*;
 
 public enum AMD64Compare {
+    BCMP,
+    SCMP,
     ICMP,
     LCMP,
     ACMP,
@@ -59,9 +61,12 @@
         @Override
         protected void verify() {
             super.verify();
-            assert (name().startsWith("I") && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) ||
-                            (name().startsWith("L") && x.getKind() == Kind.Long && y.getKind() == Kind.Long) || (name().startsWith("A") && x.getKind() == Kind.Object && y.getKind() == Kind.Object) ||
-                            (name().startsWith("F") && x.getKind() == Kind.Float && y.getKind() == Kind.Float) || (name().startsWith("D") && x.getKind() == Kind.Double && y.getKind() == Kind.Double);
+            assert (name().startsWith("B") && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) ||
+                            (name().startsWith("S") && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) ||
+                            (name().startsWith("I") && x.getKind() == Kind.Int && y.getKind() == Kind.Int) || (name().startsWith("L") && x.getKind() == Kind.Long && y.getKind() == Kind.Long) ||
+                            (name().startsWith("A") && x.getKind() == Kind.Object && y.getKind() == Kind.Object) ||
+                            (name().startsWith("F") && x.getKind() == Kind.Float && y.getKind() == Kind.Float) || (name().startsWith("D") && x.getKind() == Kind.Double && y.getKind() == Kind.Double) : String.format(
+                            "%s(%s, %s)", opcode, x, y);
         }
     }
 
@@ -82,6 +87,12 @@
         public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
             if (isRegister(y)) {
                 switch (opcode) {
+                    case BCMP:
+                        masm.cmpb(asIntReg(y), address.toAddress());
+                        break;
+                    case SCMP:
+                        masm.cmpw(asIntReg(y), address.toAddress());
+                        break;
                     case ICMP:
                         masm.cmpl(asIntReg(y), address.toAddress());
                         break;
@@ -102,6 +113,12 @@
                 }
             } else if (isConstant(y)) {
                 switch (opcode) {
+                    case BCMP:
+                        masm.cmpb(address.toAddress(), crb.asIntConst(y));
+                        break;
+                    case SCMP:
+                        masm.cmpw(address.toAddress(), crb.asIntConst(y));
+                        break;
                     case ICMP:
                         masm.cmpl(address.toAddress(), crb.asIntConst(y));
                         break;
@@ -128,6 +145,12 @@
     public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Compare opcode, Value x, Value y) {
         if (isRegister(x) && isRegister(y)) {
             switch (opcode) {
+                case BCMP:
+                    masm.cmpb(asIntReg(x), asIntReg(y));
+                    break;
+                case SCMP:
+                    masm.cmpw(asIntReg(x), asIntReg(y));
+                    break;
                 case ICMP:
                     masm.cmpl(asIntReg(x), asIntReg(y));
                     break;
@@ -149,6 +172,20 @@
         } else if (isRegister(x) && isConstant(y)) {
             boolean isZero = ((Constant) y).isDefaultForKind();
             switch (opcode) {
+                case BCMP:
+                    if (isZero) {
+                        masm.testl(asIntReg(x), asIntReg(x));
+                    } else {
+                        masm.cmpb(asIntReg(x), crb.asIntConst(y));
+                    }
+                    break;
+                case SCMP:
+                    if (isZero) {
+                        masm.testl(asIntReg(x), asIntReg(x));
+                    } else {
+                        masm.cmpw(asIntReg(x), crb.asIntConst(y));
+                    }
+                    break;
                 case ICMP:
                     if (isZero) {
                         masm.testl(asIntReg(x), asIntReg(x));
@@ -181,6 +218,12 @@
             }
         } else if (isRegister(x) && isStackSlot(y)) {
             switch (opcode) {
+                case BCMP:
+                    masm.cmpb(asIntReg(x), (AMD64Address) crb.asByteAddr(y));
+                    break;
+                case SCMP:
+                    masm.cmpw(asIntReg(x), (AMD64Address) crb.asShortAddr(y));
+                    break;
                 case ICMP:
                     masm.cmpl(asIntReg(x), (AMD64Address) crb.asIntAddr(y));
                     break;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.BlockEndOp;
-import com.oracle.graal.lir.SwitchStrategy.*;
+import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.calc.*;
 
@@ -261,7 +261,7 @@
         @Use({REG, STACK, CONST}) protected Value falseValue;
         private final ConditionFlag condition;
 
-        public CondMoveOp(Variable result, Condition condition, Variable trueValue, Value falseValue) {
+        public CondMoveOp(Variable result, Condition condition, AllocatableValue trueValue, Value falseValue) {
             this.result = result;
             this.condition = intCond(condition);
             this.trueValue = trueValue;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -24,6 +24,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
 import com.oracle.graal.lir.*;
 
 /**
@@ -33,7 +34,7 @@
  *
  * <pre>
  *   Base       Contents
- *
+ * 
  *            :                                :  -----
  *   caller   | incoming overflow argument n   |    ^
  *   frame    :     ...                        :    | positive
@@ -69,8 +70,8 @@
  */
 public class AMD64FrameMap extends FrameMap {
 
-    public AMD64FrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
         // (negative) offset relative to sp + total frame size
         initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
         spillSize = initialSpillSize;
@@ -88,8 +89,7 @@
 
     @Override
     protected int alignFrameSize(int size) {
-        int x = size + returnAddressSize() + (target.stackAlignment - 1);
-        return (x / target.stackAlignment) * target.stackAlignment - returnAddressSize();
+        return NumUtil.roundUp(size + returnAddressSize(), target.stackAlignment) - returnAddressSize();
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,8 +28,8 @@
 import static java.lang.Float.*;
 
 import com.oracle.graal.amd64.*;
+import com.oracle.graal.api.code.CompilationResult.RawData;
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.CompilationResult.RawData;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.amd64.*;
@@ -396,12 +396,15 @@
     @Opcode("CAS")
     public static class CompareAndSwapOp extends AMD64LIRInstruction {
 
+        private final Kind accessKind;
+
         @Def protected AllocatableValue result;
         @Use({COMPOSITE}) protected AMD64AddressValue address;
         @Use protected AllocatableValue cmpValue;
         @Use protected AllocatableValue newValue;
 
-        public CompareAndSwapOp(AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+        public CompareAndSwapOp(Kind accessKind, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+            this.accessKind = accessKind;
             this.result = result;
             this.address = address;
             this.cmpValue = cmpValue;
@@ -410,7 +413,22 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
-            compareAndSwap(crb, masm, result, address, cmpValue, newValue);
+            assert asRegister(cmpValue).equals(AMD64.rax) && asRegister(result).equals(AMD64.rax);
+
+            if (crb.target.isMP) {
+                masm.lock();
+            }
+            switch (accessKind) {
+                case Int:
+                    masm.cmpxchgl(asRegister(newValue), address.toAddress());
+                    break;
+                case Long:
+                case Object:
+                    masm.cmpxchgq(asRegister(newValue), address.toAddress());
+                    break;
+                default:
+                    throw GraalInternalError.shouldNotReachHere();
+            }
         }
     }
 
@@ -641,24 +659,4 @@
                 throw GraalInternalError.shouldNotReachHere();
         }
     }
-
-    protected static void compareAndSwap(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue,
-                    AllocatableValue newValue) {
-        assert asRegister(cmpValue).equals(AMD64.rax) && asRegister(result).equals(AMD64.rax);
-
-        if (crb.target.isMP) {
-            masm.lock();
-        }
-        switch (cmpValue.getKind()) {
-            case Int:
-                masm.cmpxchgl(asRegister(newValue), address.toAddress());
-                break;
-            case Long:
-            case Object:
-                masm.cmpxchgq(asRegister(newValue), address.toAddress());
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
 }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
 import com.oracle.graal.lir.asm.*;
 
 /**
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,10 +26,10 @@
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
-import com.oracle.graal.lir.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.hsail.*;
+import com.oracle.graal.lir.*;
 
 /**
  * Represents an address value used in HSAIL code.
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 import com.oracle.graal.asm.hsail.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.CompilationResultBuilder;
+import com.oracle.graal.lir.asm.*;
 
 /**
  * Defines arithmetic instruction nodes.
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,10 @@
  */
 package com.oracle.graal.lir.hsail;
 
-import com.oracle.graal.lir.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.hsail.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 
 /**
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,22 +23,29 @@
 package com.oracle.graal.lir.hsail;
 
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.hsail.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.lir.*;
 
 /**
  * Implementation of compare operations.
  */
 public enum HSAILCompare {
-    ICMP,
-    LCMP,
-    ACMP,
-    FCMP,
-    DCMP;
+    ICMP(Kind.Int),
+    LCMP(Kind.Long),
+    ACMP(Kind.Object),
+    FCMP(Kind.Float),
+    DCMP(Kind.Double);
+
+    public final Kind kind;
+
+    private HSAILCompare(Kind kind) {
+        this.kind = kind;
+    }
 
     public static class CompareOp extends HSAILLIRInstruction {
 
@@ -59,7 +66,7 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, condition, x, y, z, unordered);
+            emit(crb, masm, opcode, condition, x, y, z, unordered);
         }
 
         @Override
@@ -71,8 +78,8 @@
     }
 
     @SuppressWarnings("unused")
-    public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) {
-        emitCompare(masm, condition, x, y, unorderedIsTrue);
+    public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILCompare opcode, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) {
+        masm.emitCompare(opcode.kind, x, y, conditionToString(condition), unorderedIsTrue, isUnsignedCompare(condition));
     }
 
     public static String conditionToString(Condition condition) {
@@ -109,9 +116,4 @@
                 return false;
         }
     }
-
-    private static void emitCompare(HSAILAssembler masm, Condition condition, Value src0, Value src1, boolean unordered) {
-        masm.emitCompare(src0, src1, conditionToString(condition), unordered, isUnsignedCompare(condition));
-    }
-
 }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,23 +22,21 @@
  */
 package com.oracle.graal.lir.hsail;
 
+import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
+import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.*;
 import com.oracle.graal.asm.hsail.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hsail.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.BlockEndOp;
 import com.oracle.graal.lir.SwitchStrategy.BaseSwitchClosure;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.calc.*;
 
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.hsail.HSAIL;
-
 /**
  * Implementation of control flow instructions.
  */
@@ -103,7 +101,7 @@
                         case Int:
                         case Long:
                             // Generate cascading compare and branches for each case.
-                            masm.emitCompare(key, keyConstants[index], HSAILCompare.conditionToString(condition), false, false);
+                            masm.emitCompare(key.getKind(), key, keyConstants[index], HSAILCompare.conditionToString(condition), false, false);
                             masm.cbr(masm.nameOf(target));
                             break;
                         case Object:
@@ -288,10 +286,10 @@
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
             if (crb.isSuccessorEdge(trueDestination)) {
-                HSAILCompare.emit(crb, masm, condition.negate(), x, y, z, !unordered);
+                HSAILCompare.emit(crb, masm, opcode, condition.negate(), x, y, z, !unordered);
                 masm.cbr(masm.nameOf(falseDestination.label()));
             } else {
-                HSAILCompare.emit(crb, masm, condition, x, y, z, unordered);
+                HSAILCompare.emit(crb, masm, opcode, condition, x, y, z, unordered);
                 masm.cbr(masm.nameOf(trueDestination.label()));
                 if (!crb.isSuccessorEdge(falseDestination)) {
                     masm.jmp(falseDestination.label());
@@ -322,7 +320,7 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            HSAILCompare.emit(crb, masm, condition, left, right, right, false);
+            HSAILCompare.emit(crb, masm, opcode, condition, left, right, right, false);
             cmove(masm, result, trueValue, falseValue);
         }
     }
@@ -338,7 +336,7 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            HSAILCompare.emit(crb, masm, condition, left, right, right, unorderedIsTrue);
+            HSAILCompare.emit(crb, masm, opcode, condition, left, right, right, unorderedIsTrue);
             cmove(masm, result, trueValue, falseValue);
         }
     }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,8 +37,8 @@
  */
 public final class HSAILFrameMap extends FrameMap {
 
-    public HSAILFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public HSAILFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Wed Apr 16 14:02:52 2014 +0200
@@ -95,6 +95,13 @@
             super(moveKind);
             this.result = result;
             this.input = input;
+            checkForNullObjectInput();
+        }
+
+        private void checkForNullObjectInput() {
+            if (result.getKind() == Kind.Object && isConstant(input) && input.getKind() == Kind.Long && ((Constant) input).asLong() == 0) {
+                input = Constant.NULL_OBJECT;
+            }
         }
 
         @Override
@@ -311,24 +318,26 @@
         private final long base;
         private final int shift;
         private final int alignment;
+        private final boolean nonNull;
 
         @Def({REG}) protected AllocatableValue result;
         @Temp({REG, HINT}) protected AllocatableValue scratch;
         @Use({REG}) protected AllocatableValue input;
 
-        public CompressPointer(AllocatableValue result, AllocatableValue scratch, AllocatableValue input, long base, int shift, int alignment) {
+        public CompressPointer(AllocatableValue result, AllocatableValue scratch, AllocatableValue input, long base, int shift, int alignment, boolean nonNull) {
             this.result = result;
             this.scratch = scratch;
             this.input = input;
             this.base = base;
             this.shift = shift;
             this.alignment = alignment;
+            this.nonNull = nonNull;
         }
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
             masm.emitMov(Kind.Long, scratch, input);
-            boolean testForNull = (input.getKind() == Kind.Object);
+            boolean testForNull = !nonNull;
             encodePointer(masm, scratch, base, shift, alignment, testForNull);
             masm.emitConvert(result, scratch, "u32", "u64");
         }
@@ -339,22 +348,24 @@
         private final long base;
         private final int shift;
         private final int alignment;
+        private final boolean nonNull;
 
         @Def({REG, HINT}) protected AllocatableValue result;
         @Use({REG}) protected AllocatableValue input;
 
-        public UncompressPointer(AllocatableValue result, AllocatableValue input, long base, int shift, int alignment) {
+        public UncompressPointer(AllocatableValue result, AllocatableValue input, long base, int shift, int alignment, boolean nonNull) {
             this.result = result;
             this.input = input;
             this.base = base;
             this.shift = shift;
             this.alignment = alignment;
+            this.nonNull = nonNull;
         }
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
             masm.emitConvert(result, input, "u64", "u32");
-            boolean testForNull = (result.getKind() == Kind.Object);
+            boolean testForNull = !nonNull;
             decodePointer(masm, result, base, shift, alignment, testForNull);
         }
     }
@@ -414,12 +425,15 @@
     @Opcode("CAS")
     public static class CompareAndSwapOp extends HSAILLIRInstruction {
 
+        private final Kind accessKind;
+
         @Def protected AllocatableValue result;
         @Use({COMPOSITE}) protected HSAILAddressValue address;
         @Use protected AllocatableValue cmpValue;
         @Use protected AllocatableValue newValue;
 
-        public CompareAndSwapOp(AllocatableValue result, HSAILAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+        public CompareAndSwapOp(Kind accessKind, AllocatableValue result, HSAILAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
+            this.accessKind = accessKind;
             this.result = result;
             this.address = address;
             this.cmpValue = cmpValue;
@@ -428,54 +442,7 @@
 
         @Override
         public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitAtomicCas(result, address.toAddress(), cmpValue, newValue);
-        }
-    }
-
-    @Opcode("CAS")
-    public static class CompareAndSwapCompressedOp extends CompareAndSwapOp {
-
-        @Temp({REG}) private AllocatableValue scratchCmpValue64;
-        @Temp({REG}) private AllocatableValue scratchNewValue64;
-        @Temp({REG}) private AllocatableValue scratchCmpValue32;
-        @Temp({REG}) private AllocatableValue scratchNewValue32;
-        @Temp({REG}) private AllocatableValue scratchCasResult32;
-        private final long base;
-        private final int shift;
-        private final int alignment;
-
-        public CompareAndSwapCompressedOp(AllocatableValue result, HSAILAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue, AllocatableValue scratchCmpValue64,
-                        AllocatableValue scratchNewValue64, AllocatableValue scratchCmpValue32, AllocatableValue scratchNewValue32, AllocatableValue scratchCasResult32, long base, int shift,
-                        int alignment) {
-            super(result, address, cmpValue, newValue);
-            this.scratchCmpValue64 = scratchCmpValue64;
-            this.scratchNewValue64 = scratchNewValue64;
-            this.scratchCmpValue32 = scratchCmpValue32;
-            this.scratchNewValue32 = scratchNewValue32;
-            this.scratchCasResult32 = scratchCasResult32;
-            this.base = base;
-            this.shift = shift;
-            this.alignment = alignment;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            // assume any encoded or decoded value could be null
-            boolean testForNull = true;
-            // set up scratch registers to be encoded versions
-            masm.emitMov(Kind.Long, scratchCmpValue64, cmpValue);
-            encodePointer(masm, scratchCmpValue64, base, shift, alignment, testForNull);
-            masm.emitMov(Kind.Long, scratchNewValue64, newValue);
-            encodePointer(masm, scratchNewValue64, base, shift, alignment, testForNull);
-            // get encoded versions into 32-bit registers
-            masm.emitConvertForceUnsigned(scratchCmpValue32, scratchCmpValue64);
-            masm.emitConvertForceUnsigned(scratchNewValue32, scratchNewValue64);
-            // finally do the cas
-            masm.emitAtomicCas(scratchCasResult32, address.toAddress(), scratchCmpValue32, scratchNewValue32);
-            // and convert the 32-bit CasResult back to 64-bit
-            masm.emitConvertForceUnsigned(result, scratchCasResult32);
-            // and decode/uncompress the 64-bit cas result
-            decodePointer(masm, result, base, shift, alignment, testForNull);
+            masm.emitAtomicCas(accessKind, result, address.toAddress(), cmpValue, newValue);
         }
     }
 
@@ -521,4 +488,28 @@
             throw GraalInternalError.shouldNotReachHere();
         }
     }
+
+    @Opcode("ATOMICADD")
+    public static class AtomicGetAndAddOp extends HSAILLIRInstruction {
+
+        @Def protected AllocatableValue result;
+        @Use({COMPOSITE}) protected HSAILAddressValue address;
+        @Use({REG, CONST}) protected Value delta;
+
+        public AtomicGetAndAddOp(AllocatableValue result, HSAILAddressValue address, Value delta) {
+            this.result = result;
+            this.address = address;
+            this.delta = delta;
+        }
+
+        public HSAILAddressValue getAddress() {
+            return address;
+        }
+
+        @Override
+        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
+            masm.emitAtomicAdd(result, address.toAddress(), delta);
+        }
+    }
+
 }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,13 +22,26 @@
  */
 package com.oracle.graal.lir.ptx;
 
-import static com.oracle.graal.asm.ptx.PTXMacroAssembler.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 import static com.oracle.graal.lir.LIRValueUtil.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Add;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.And;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Cvt;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Div;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Mul;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Neg;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Not;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Or;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Rem;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Shl;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Shr;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Sub;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Ushr;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Xor;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,12 +22,12 @@
  */
 package com.oracle.graal.lir.ptx;
 
-import static com.oracle.graal.asm.ptx.PTXAssembler.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXAssembler.Setp;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,8 +37,8 @@
  */
 public final class PTXFrameMap extends FrameMap {
 
-    public PTXFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public PTXFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,12 +22,15 @@
  */
 package com.oracle.graal.lir.ptx;
 
-import static com.oracle.graal.asm.ptx.PTXMacroAssembler.*;
 import static com.oracle.graal.asm.ptx.PTXStateSpace.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Ld;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.LoadAddr;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.LoadParam;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.St;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,17 +22,18 @@
  */
 package com.oracle.graal.lir.ptx;
 
-import static com.oracle.graal.asm.ptx.PTXMacroAssembler.*;
 import static com.oracle.graal.api.code.ValueUtil.*;
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 import static com.oracle.graal.lir.LIRValueUtil.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Mov;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.lir.StandardOp.MoveOp;
+import com.oracle.graal.lir.StandardOp.NullCheck;
 import com.oracle.graal.lir.asm.*;
 
 public class PTXMove {
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,11 +23,11 @@
 
 package com.oracle.graal.lir.ptx;
 
-import static com.oracle.graal.asm.ptx.PTXMacroAssembler.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXMacroAssembler.Param;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,13 +23,13 @@
 package com.oracle.graal.lir.ptx;
 
 import static com.oracle.graal.asm.ptx.PTXAssembler.BooleanOperator.*;
-import static com.oracle.graal.asm.ptx.PTXAssembler.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.ptx.*;
+import com.oracle.graal.asm.ptx.PTXAssembler.Setp;
 import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.nodes.calc.Condition;
+import com.oracle.graal.nodes.calc.*;
 
 public class PTXTestOp extends PTXLIRInstruction {
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCAddressValue.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.*;
+import com.oracle.graal.lir.LIRInstruction.OperandFlag;
 
 public class SPARCAddressValue extends CompositeValue {
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,11 +23,39 @@
 package com.oracle.graal.lir.sparc;
 
 import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
+import static com.oracle.graal.asm.sparc.SPARCAssembler.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Add;
+import com.oracle.graal.asm.sparc.SPARCAssembler.And;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Faddd;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fadds;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fdivd;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fdivs;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fdtoi;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fmuld;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fmuls;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fnegd;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fnegs;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fstoi;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fsubd;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Fsubs;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Mulx;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Or;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sdivx;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sll;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sllx;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sra;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Srax;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Srl;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Srlx;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sub;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Xor;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Neg;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Not;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Signx;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,13 +24,19 @@
 
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.asm.sparc.SPARCAssembler.*;
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
 import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Andn;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Or;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Popc;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Srl;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Srlx;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Sub;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Mov;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,12 +24,16 @@
 
 import static com.oracle.graal.api.code.ValueUtil.*;
 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
-import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Call;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Jmpl;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Jmp;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Nop;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Sethix;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Cmp;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -69,8 +69,8 @@
  */
 public final class SPARCFrameMap extends FrameMap {
 
-    public SPARCFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public SPARCFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
         // offset relative to sp + total frame size
         initialSpillSize = 0;
         spillSize = initialSpillSize;
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,9 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.asm.sparc.SPARCAssembler.*;
-import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Ldsw;
+import com.oracle.graal.asm.sparc.SPARCAssembler.Ldx;
+import com.oracle.graal.asm.sparc.SPARCMacroAssembler.Cmp;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.asm.*;
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Wed Apr 16 14:02:52 2014 +0200
@@ -84,11 +84,12 @@
     private boolean accessesCallerFrame;
 
     /**
-     * Creates a new frame map for the specified method.
+     * Creates a new frame map for the specified method. The given registerConfig is optional, in
+     * case null is passed the default RegisterConfig from the CodeCacheProvider will be used.
      */
-    public FrameMap(CodeCacheProvider codeCache) {
+    public FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
         this.target = codeCache.getTarget();
-        this.registerConfig = codeCache.getRegisterConfig();
+        this.registerConfig = registerConfig == null ? codeCache.getRegisterConfig() : registerConfig;
         this.frameSize = -1;
         this.outgoingSize = codeCache.getMinimumOutgoingSize();
         this.objectStackSlots = new ArrayList<>();
@@ -114,7 +115,7 @@
     /**
      * Gets the frame size of the compiled frame, not including the size of the
      * {@link Architecture#getReturnAddressSize() return address slot}.
-     * 
+     *
      * @return The size of the frame (in bytes).
      */
     public int frameSize() {
@@ -138,7 +139,7 @@
     /**
      * Gets the total frame size of the compiled frame, including the size of the
      * {@link Architecture#getReturnAddressSize() return address slot}.
-     * 
+     *
      * @return The total size of the frame (in bytes).
      */
     public abstract int totalFrameSize();
@@ -151,7 +152,7 @@
 
     /**
      * Aligns the given frame size to the stack alignment size and return the aligned size.
-     * 
+     *
      * @param size the initial frame size to be aligned
      * @return the aligned frame size
      */
@@ -179,11 +180,14 @@
             freedSlots = null;
         }
         frameSize = currentFrameSize();
+        if (frameSize > registerConfig.getMaximumFrameSize()) {
+            throw new BailoutException(String.format("Frame size (%d) exceeded maximum allowed frame size (%d).", frameSize, registerConfig.getMaximumFrameSize()));
+        }
     }
 
     /**
      * Computes the offset of a stack slot relative to the frame register.
-     * 
+     *
      * @param slot a stack slot
      * @return the offset of the stack slot
      */
@@ -199,7 +203,7 @@
     /**
      * Computes the index of a stack slot relative to slot 0. This is also the bit index of stack
      * slots in the reference map.
-     * 
+     *
      * @param slot a stack slot
      * @return the index of the stack slot
      */
@@ -211,7 +215,7 @@
     /**
      * Gets the offset from the stack pointer to the stack area where callee-saved registers are
      * stored.
-     * 
+     *
      * @return The offset to the callee save area (in bytes).
      */
     public abstract int offsetToCalleeSaveArea();
@@ -219,7 +223,7 @@
     /**
      * Informs the frame map that the compiled code calls a particular method, which may need stack
      * space for outgoing arguments.
-     * 
+     *
      * @param cc The calling convention for the called method.
      */
     public void callsMethod(CallingConvention cc) {
@@ -228,7 +232,7 @@
 
     /**
      * Reserves space for stack-based outgoing arguments.
-     * 
+     *
      * @param argsSize The amount of space (in bytes) to reserve for stack-based outgoing arguments.
      */
     public void reserveOutgoing(int argsSize) {
@@ -241,7 +245,7 @@
      * Reserves a new spill slot in the frame of the method being compiled. The returned slot is
      * aligned on its natural alignment, i.e., an 8-byte spill slot is aligned at an 8-byte
      * boundary.
-     * 
+     *
      * @param kind The kind of the spill slot to be reserved.
      * @param additionalOffset
      * @return A spill slot denoting the reserved memory area.
@@ -251,7 +255,7 @@
     /**
      * Returns the spill slot size for the given {@link PlatformKind}. The default value is the size
      * in bytes for the target architecture.
-     * 
+     *
      * @param kind the {@link PlatformKind} to be stored in the spill slot.
      * @return the size in bytes
      */
@@ -263,7 +267,7 @@
      * Reserves a spill slot in the frame of the method being compiled. The returned slot is aligned
      * on its natural alignment, i.e., an 8-byte spill slot is aligned at an 8-byte boundary, unless
      * overridden by a subclass.
-     * 
+     *
      * @param kind The kind of the spill slot to be reserved.
      * @return A spill slot denoting the reserved memory area.
      */
@@ -302,7 +306,7 @@
     /**
      * Reserves a number of contiguous slots in the frame of the method being compiled. If the
      * requested number of slots is 0, this method returns {@code null}.
-     * 
+     *
      * @param slots the number of slots to reserve
      * @param objects specifies the indexes of the object pointer slots. The caller is responsible
      *            for guaranteeing that each such object pointer slot is initialized before any
@@ -359,7 +363,7 @@
      * Marks the specified location as a reference in the reference map of the debug information.
      * The tracked location can be a {@link RegisterValue} or a {@link StackSlot}. Note that a
      * {@link Constant} is automatically tracked.
-     * 
+     *
      * @param location The location to be added to the reference map.
      * @param refMap A reference map, as created by {@link #initReferenceMap(boolean)}.
      */
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,8 +29,10 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.lir.LIRInstruction.OperandFlag;
+import com.oracle.graal.lir.LIRInstruction.OperandMode;
+import com.oracle.graal.lir.LIRInstruction.ValueProcedure;
 import com.oracle.graal.lir.StandardOp.MoveOp;
-import com.oracle.graal.lir.LIRInstruction.*;
 import com.oracle.graal.nodes.cfg.*;
 
 /**
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,7 +37,7 @@
 
 /**
  * Fills in a {@link CompilationResult} as its code is being assembled.
- * 
+ *
  * @see CompilationResultBuilderFactory
  */
 public class CompilationResultBuilder {
@@ -264,13 +264,23 @@
         return recordDataReferenceInCode((Constant) value, 8);
     }
 
+    public AbstractAddress asByteAddr(Value value) {
+        assert value.getKind().getByteCount() >= Kind.Byte.getByteCount();
+        return asAddress(value);
+    }
+
+    public AbstractAddress asShortAddr(Value value) {
+        assert value.getKind().getByteCount() >= Kind.Short.getByteCount();
+        return asAddress(value);
+    }
+
     public AbstractAddress asIntAddr(Value value) {
-        assert value.getKind() == Kind.Int;
+        assert value.getKind().getByteCount() >= Kind.Int.getByteCount();
         return asAddress(value);
     }
 
     public AbstractAddress asLongAddr(Value value) {
-        assert value.getKind() == Kind.Long;
+        assert value.getKind().getByteCount() >= Kind.Long.getByteCount();
         return asAddress(value);
     }
 
@@ -280,12 +290,12 @@
     }
 
     public AbstractAddress asFloatAddr(Value value) {
-        assert value.getKind() == Kind.Float;
+        assert value.getKind().getByteCount() >= Kind.Float.getByteCount();
         return asAddress(value);
     }
 
     public AbstractAddress asDoubleAddr(Value value) {
-        assert value.getKind() == Kind.Double;
+        assert value.getKind().getByteCount() >= Kind.Double.getByteCount();
         return asAddress(value);
     }
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,12 +29,12 @@
 
 public class BasicInductionVariable extends InductionVariable {
 
-    private PhiNode phi;
+    private ValuePhiNode phi;
     private ValueNode init;
     private ValueNode rawStride;
     private IntegerArithmeticNode op;
 
-    public BasicInductionVariable(LoopEx loop, PhiNode phi, ValueNode init, ValueNode rawStride, IntegerArithmeticNode op) {
+    public BasicInductionVariable(LoopEx loop, ValuePhiNode phi, ValueNode init, ValueNode rawStride, IntegerArithmeticNode op) {
         super(loop);
         this.phi = phi;
         this.init = init;
@@ -71,7 +71,7 @@
     }
 
     @Override
-    public PhiNode valueNode() {
+    public ValuePhiNode valueNode() {
         return phi;
     }
 
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/InductionVariables.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
             }
             ValueNode stride = addSub(backValue, phi);
             if (stride != null) {
-                BasicInductionVariable biv = new BasicInductionVariable(loop, phi, phi.valueAt(forwardEnd), stride, (IntegerArithmeticNode) backValue);
+                BasicInductionVariable biv = new BasicInductionVariable(loop, (ValuePhiNode) phi, phi.valueAt(forwardEnd), stride, (IntegerArithmeticNode) backValue);
                 ivs.put(phi, biv);
                 bivs.add(biv);
             }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,19 +36,19 @@
 
 public class LoopEx {
 
-    private final Loop lirLoop;
+    private final Loop<Block> lirLoop;
     private LoopFragmentInside inside;
     private LoopFragmentWhole whole;
     private CountedLoopInfo counted; // TODO (gd) detect
     private LoopsData data;
     private InductionVariables ivs;
 
-    LoopEx(Loop lirLoop, LoopsData data) {
+    LoopEx(Loop<Block> lirLoop, LoopsData data) {
         this.lirLoop = lirLoop;
         this.data = data;
     }
 
-    public Loop lirLoop() {
+    public Loop<Block> lirLoop() {
         return lirLoop;
     }
 
@@ -88,7 +88,7 @@
     }
 
     public LoopBeginNode loopBegin() {
-        return lirLoop().loopBegin();
+        return (LoopBeginNode) lirLoop().header.getBeginNode();
     }
 
     public FixedNode predecessor() {
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,6 +31,7 @@
 import com.oracle.graal.nodes.VirtualState.VirtualClosure;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.nodes.virtual.*;
 
 public abstract class LoopFragment {
@@ -285,6 +286,7 @@
             if (newEarlyExit == null) {
                 continue;
             }
+            boolean newEarlyExitIsBegin = newEarlyExit instanceof BeginNode;
             MergeNode merge = graph.add(new MergeNode());
             AbstractEndNode originalEnd = graph.add(new EndNode());
             AbstractEndNode newEnd = graph.add(new EndNode());
@@ -330,21 +332,17 @@
                 ProxyNode newVpn = getDuplicatedNode(vpn);
                 if (newVpn != null) {
                     PhiNode phi;
-                    switch (vpn.type()) {
-                        case Value:
-                            phi = graph.addWithoutUnique(new PhiNode(vpn.stamp(), merge));
-                            break;
-                        case Guard:
-                            phi = graph.addWithoutUnique(new PhiNode(vpn.type(), merge));
-                            break;
-                        case Memory:
-                            phi = graph.addWithoutUnique(new MemoryPhiNode(merge, ((MemoryProxyNode) vpn).getLocationIdentity()));
-                            break;
-                        default:
-                            throw GraalInternalError.shouldNotReachHere();
+                    if (vpn instanceof ValueProxyNode) {
+                        phi = graph.addWithoutUnique(new ValuePhiNode(vpn.stamp(), merge));
+                    } else if (vpn instanceof GuardProxyNode) {
+                        phi = graph.addWithoutUnique(new GuardPhiNode(merge));
+                    } else if (vpn instanceof MemoryProxyNode) {
+                        phi = graph.addWithoutUnique(new MemoryPhiNode(merge, ((MemoryProxyNode) vpn).getLocationIdentity()));
+                    } else {
+                        throw GraalInternalError.shouldNotReachHere();
                     }
                     phi.addInput(vpn);
-                    phi.addInput(newVpn);
+                    phi.addInput(newEarlyExitIsBegin ? newVpn.value() : newVpn);
                     replaceWith = phi;
                 } else {
                     replaceWith = vpn.value();
@@ -361,6 +359,16 @@
                     }
                 }
             }
+            if (newEarlyExitIsBegin) {
+                FrameState stateAtNewEarlyExit = newEarlyExit.stateAfter();
+                if (stateAtNewEarlyExit != null) {
+                    newEarlyExit.setStateAfter(null);
+                    GraphUtil.killWithUnusedFloatingInputs(stateAtNewEarlyExit);
+                }
+                for (ProxyNode proxy : newEarlyExit.proxies().snapshot()) {
+                    GraphUtil.killWithUnusedFloatingInputs(proxy);
+                }
+            }
         }
     }
 }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,11 +24,10 @@
 
 import java.util.*;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Graph.DuplicationReplacement;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.VirtualState.NodeClosure;
 import com.oracle.graal.nodes.util.*;
 
@@ -41,7 +40,7 @@
      * peeling case. In the unrolling case they will be used as the value that replace the loop-phis
      * of the duplicated inside fragment
      */
-    private Map<PhiNode, ValueNode> mergedInitializers;
+    private Map<ValuePhiNode, ValueNode> mergedInitializers;
     private final DuplicationReplacement dataFixBefore = new DuplicationReplacement() {
 
         @Override
@@ -168,18 +167,14 @@
 
     private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, MergeNode merge) {
         PhiNode ret;
-        switch (phi.type()) {
-            case Value:
-                ret = new PhiNode(phi.stamp(), merge);
-                break;
-            case Guard:
-                ret = new PhiNode(PhiType.Guard, merge);
-                break;
-            case Memory:
-                ret = new MemoryPhiNode(merge, ((MemoryPhiNode) phi).getLocationIdentity());
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
+        if (phi instanceof ValuePhiNode) {
+            ret = new ValuePhiNode(phi.stamp(), merge);
+        } else if (phi instanceof GuardPhiNode) {
+            ret = new GuardPhiNode(merge);
+        } else if (phi instanceof MemoryPhiNode) {
+            ret = new MemoryPhiNode(merge, ((MemoryPhiNode) phi).getLocationIdentity());
+        } else {
+            throw GraalInternalError.shouldNotReachHere();
         }
         return graph.addWithoutUnique(ret);
     }
@@ -219,7 +214,7 @@
             for (int i = 0; i < phi.valueCount(); i++) {
                 ValueNode v = phi.valueAt(i);
                 if (loopBegin.isPhiAtMerge(v)) {
-                    PhiNode newV = peel.getDuplicatedNode((PhiNode) v);
+                    PhiNode newV = peel.getDuplicatedNode((ValuePhiNode) v);
                     if (newV != null) {
                         phi.setValueAt(i, newV);
                     }
@@ -230,7 +225,7 @@
 
     /**
      * Gets the corresponding value in this fragment.
-     * 
+     *
      * @param b original value
      * @return corresponding value in the peel
      */
@@ -308,7 +303,7 @@
                         }
                     });
                 }
-                mergedInitializers.put(phi, initializer);
+                mergedInitializers.put((ValuePhiNode) phi, initializer);
             }
         }
         return newExit;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentWhole.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentWhole.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,8 +22,8 @@
  */
 package com.oracle.graal.loop;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Graph.DuplicationReplacement;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.cfg.*;
@@ -56,7 +56,7 @@
     @Override
     public NodeIterable<Node> nodes() {
         if (nodes == null) {
-            Loop lirLoop = loop().lirLoop();
+            Loop<Block> lirLoop = loop().lirLoop();
             nodes = LoopFragment.computeNodes(graph(), LoopFragment.toHirBlocks(lirLoop.blocks), LoopFragment.toHirBlocks(lirLoop.exits));
         }
         return nodes;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopsData.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,7 @@
 
 public class LoopsData {
 
-    private Map<Loop, LoopEx> lirLoopToEx = new IdentityHashMap<>();
+    private Map<Loop<Block>, LoopEx> lirLoopToEx = new IdentityHashMap<>();
     private Map<LoopBeginNode, LoopEx> loopBeginToEx = new IdentityHashMap<>();
     private ControlFlowGraph cfg;
 
@@ -42,14 +42,14 @@
             throw Debug.handle(e);
         }
 
-        for (Loop lirLoop : cfg.getLoops()) {
+        for (Loop<Block> lirLoop : cfg.getLoops()) {
             LoopEx ex = new LoopEx(lirLoop, this);
             lirLoopToEx.put(lirLoop, ex);
             loopBeginToEx.put(ex.loopBegin(), ex);
         }
     }
 
-    public LoopEx loop(Loop lirLoop) {
+    public LoopEx loop(Loop<?> lirLoop) {
         return lirLoopToEx.get(lirLoop);
     }
 
--- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/ObjectStampJoinTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/ObjectStampJoinTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -103,8 +103,9 @@
     @Test
     public void testJoin6() {
         Stamp dExactNonNull = StampFactory.exactNonNull(getType(D.class));
-        Stamp allwaysNull = StampFactory.alwaysNull();
-        Stamp join = join(allwaysNull, dExactNonNull);
+        Stamp alwaysNull = StampFactory.alwaysNull();
+        Stamp join = join(alwaysNull, dExactNonNull);
+        Assert.assertFalse(join.isLegal());
         Assert.assertFalse(ObjectStamp.isObjectNonNull(join));
         Assert.assertFalse(ObjectStamp.isObjectAlwaysNull(join));
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,9 +33,10 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-public abstract class AbstractBeginNode extends FixedWithNextNode implements StateSplit, LIRLowerable, Simplifiable, GuardingNode, IterableNodeType {
+@NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor})
+public abstract class AbstractBeginNode extends FixedWithNextNode implements StateSplit, LIRLowerable, Simplifiable, GuardingNode, AnchoringNode, IterableNodeType {
 
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public FrameState stateAfter() {
         return stateAfter;
@@ -52,7 +53,7 @@
     }
 
     protected AbstractBeginNode() {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
     }
 
     protected AbstractBeginNode(Stamp stamp) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractDeoptimizeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractDeoptimizeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
  */
 public abstract class AbstractDeoptimizeNode extends ControlSinkNode implements IterableNodeType, DeoptimizingNode.DeoptBefore {
 
-    @Input private FrameState stateBefore;
+    @Input(InputType.State) private FrameState stateBefore;
 
     public AbstractDeoptimizeNode() {
         super(StampFactory.forVoid());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.type.*;
@@ -30,7 +31,7 @@
 
 public abstract class AbstractFixedGuardNode extends DeoptimizingFixedWithNextNode implements Simplifiable, GuardingNode {
 
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
     private final DeoptimizationReason reason;
     private final DeoptimizationAction action;
     private boolean negated;
@@ -45,7 +46,7 @@
     }
 
     protected AbstractFixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
         this.action = action;
         this.negated = negated;
         this.condition = condition;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractLocalNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractLocalNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 
     /**
      * Gets the index of this local in the array of parameters. This is NOT the JVM local index.
-     * 
+     *
      * @return the index
      */
     public int index() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractStateSplit.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractStateSplit.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
@@ -29,7 +30,7 @@
  */
 public abstract class AbstractStateSplit extends FixedWithNextNode implements StateSplit {
 
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public FrameState stateAfter() {
         return stateAfter;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,9 +27,6 @@
 public final class BeginNode extends AbstractBeginNode {
 
     public BeginNode() {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
     }
-
-    @NodeIntrinsic
-    public static native BeginNode anchor();
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/CallTargetNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/CallTargetNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,17 +28,18 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Extension})
 public abstract class CallTargetNode extends ValueNode implements LIRLowerable {
 
     @Input private final NodeInputList<ValueNode> arguments;
 
     public CallTargetNode(ValueNode[] arguments) {
-        super(StampFactory.extension());
+        super(StampFactory.forVoid());
         this.arguments = new NodeInputList<>(this, arguments);
     }
 
     public CallTargetNode(List<ValueNode> arguments) {
-        super(StampFactory.extension());
+        super(StampFactory.forVoid());
         this.arguments = new NodeInputList<>(this, arguments);
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConditionAnchorNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConditionAnchorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,10 +28,10 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-@NodeInfo(nameTemplate = "ConditionAnchor(!={p#negated})")
+@NodeInfo(nameTemplate = "ConditionAnchor(!={p#negated})", allowedUsageTypes = {InputType.Guard})
 public final class ConditionAnchorNode extends FixedWithNextNode implements Canonicalizable, Lowerable, GuardingNode {
 
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
     private boolean negated;
 
     public ConditionAnchorNode(LogicNode condition) {
@@ -39,7 +39,7 @@
     }
 
     public ConditionAnchorNode(LogicNode condition, boolean negated) {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
         this.negated = negated;
         this.condition = condition;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -175,7 +175,8 @@
     public static ConstantNode forPrimitive(Stamp stamp, Constant constant, StructuredGraph graph) {
         if (stamp instanceof IntegerStamp) {
             assert constant.getKind().isNumericInteger() && stamp.getStackKind() == constant.getKind().getStackKind();
-            return forIntegerStamp(stamp, constant.asLong(), graph);
+            IntegerStamp istamp = (IntegerStamp) stamp;
+            return forIntegerBits(istamp.getBits(), constant, graph);
         } else {
             assert constant.getKind().isNumericFloat() && stamp.getStackKind() == constant.getKind();
             return forPrimitive(constant, graph);
@@ -262,20 +263,14 @@
         return unique(graph, createPrimitive(Constant.forInt(i)));
     }
 
-    /**
-     * Returns a node for an object constant.
-     *
-     * @param o the object value for which to create the instruction
-     * @return a node representing the object
-     */
-    public static ConstantNode forObject(Object o, MetaAccessProvider metaAccess, StructuredGraph graph) {
-        assert !(o instanceof Constant) : "wrapping a Constant into a Constant";
-        Constant constant = Constant.forObject(o);
-        return unique(graph, new ConstantNode(constant, StampFactory.forConstant(constant, metaAccess)));
+    private static ConstantNode unique(StructuredGraph graph, ConstantNode node) {
+        return graph.unique(node);
     }
 
-    private static ConstantNode unique(StructuredGraph graph, ConstantNode node) {
-        return graph.unique(node);
+    private static ConstantNode forIntegerBits(int bits, Constant constant, StructuredGraph graph) {
+        long value = constant.asLong();
+        long bounds = SignExtendNode.signExtend(value, bits);
+        return unique(graph, new ConstantNode(constant, StampFactory.forInteger(bits, bounds, bounds)));
     }
 
     /**
@@ -283,9 +278,7 @@
      * (e.g. short).
      */
     public static ConstantNode forIntegerBits(int bits, long value, StructuredGraph graph) {
-        Constant constant = Constant.forPrimitiveInt(bits, value);
-        long bounds = SignExtendNode.signExtend(value, bits);
-        return unique(graph, new ConstantNode(constant, StampFactory.forInteger(bits, bounds, bounds)));
+        return forIntegerBits(bits, Constant.forPrimitiveInt(bits, value), graph);
     }
 
     /**
@@ -346,7 +339,7 @@
             case Long:
                 return ConstantNode.forLong(0L, graph);
             case Object:
-                return ConstantNode.forObject(null, null, graph);
+                return ConstantNode.forConstant(Constant.NULL_OBJECT, null, graph);
             default:
                 return null;
         }
@@ -355,14 +348,14 @@
     @Override
     public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
         Map<Object, Object> properties = super.getDebugProperties(map);
-        properties.put("rawvalue", value.getKind() == Kind.Object ? value.getKind().format(value.asBoxedValue()) : value.asBoxedValue());
+        properties.put("rawvalue", value.toValueString());
         return properties;
     }
 
     @Override
     public String toString(Verbosity verbosity) {
         if (verbosity == Verbosity.Name) {
-            return super.toString(Verbosity.Name) + "(" + value.getKind().format(value.asBoxedValue()) + ")";
+            return super.toString(Verbosity.Name) + "(" + value.toValueString() + ")";
         } else {
             return super.toString(verbosity);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizingFixedWithNextNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizingFixedWithNextNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,11 +22,12 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.type.*;
 
 public abstract class DeoptimizingFixedWithNextNode extends FixedWithNextNode implements DeoptimizingNode.DeoptBefore {
 
-    @Input(notDataflow = true) private FrameState stateBefore;
+    @Input(InputType.State) private FrameState stateBefore;
 
     public DeoptimizingFixedWithNextNode(Stamp stamp) {
         super(stamp);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EndNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EndNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,5 +22,8 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.graph.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public final class EndNode extends AbstractEndNode {
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EntryMarkerNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EntryMarkerNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,6 +30,7 @@
  * This node will be inserted at point specified by {@link StructuredGraph#getEntryBCI()}, usually
  * by the graph builder.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public class EntryMarkerNode extends AbstractBeginNode implements IterableNodeType, Simplifiable, LIRLowerable {
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 
-@NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}")
+@NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}", allowedUsageTypes = {InputType.Guard})
 public final class FixedGuardNode extends AbstractFixedGuardNode implements Lowerable, IterableNodeType {
 
     public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedWithNextNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedWithNextNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -44,9 +44,4 @@
     public FixedWithNextNode(Stamp stamp) {
         super(stamp);
     }
-
-    @Override
-    public FixedWithNextNode asNode() {
-        return this;
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingAnchoredNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+public abstract class FloatingAnchoredNode extends FloatingNode {
+
+    @Input(InputType.Anchor) private AnchoringNode anchor;
+
+    public FloatingAnchoredNode(Stamp stamp) {
+        super(stamp);
+    }
+
+    public FloatingAnchoredNode(Stamp stamp, AnchoringNode anchor) {
+        super(stamp);
+        this.anchor = anchor;
+    }
+
+    public AnchoringNode getAnchor() {
+        return anchor;
+    }
+
+    public void setAnchor(AnchoringNode x) {
+        updateUsagesInterface(this.anchor, x);
+        this.anchor = x;
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingGuardedNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FloatingGuardedNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,13 +22,14 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.type.*;
 
 public abstract class FloatingGuardedNode extends FloatingNode implements GuardedNode {
 
-    @Input private GuardingNode guard;
+    @Input(InputType.Guard) private GuardingNode guard;
 
     public FloatingGuardedNode(Stamp stamp) {
         super(stamp);
@@ -46,7 +47,7 @@
 
     @Override
     public void setGuard(GuardingNode guard) {
-        updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+        updateUsagesInterface(this.guard, guard);
         this.guard = guard;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
 /**
  * The {@code FrameState} class encapsulates the frame state (i.e. local variables and operand
  * stack) at a particular point in the abstract interpretation.
- * 
+ *
  * This can be used as debug or deoptimization information.
  */
 @NodeInfo(nameTemplate = "FrameState@{p#method/s}:{p#bci}")
@@ -80,16 +80,16 @@
      */
     public static final int INVALID_FRAMESTATE_BCI = -5;
 
-    @Input private FrameState outerFrameState;
+    @Input(InputType.State) private FrameState outerFrameState;
 
     /**
      * Contains the locals, the expressions and the locked objects, in this order.
      */
     @Input private final NodeInputList<ValueNode> values;
 
-    @Input private final NodeInputList<MonitorIdNode> monitorIds;
+    @Input(InputType.Association) private final NodeInputList<MonitorIdNode> monitorIds;
 
-    @Input private final NodeInputList<EscapeObjectState> virtualObjectMappings;
+    @Input(InputType.State) private final NodeInputList<EscapeObjectState> virtualObjectMappings;
 
     /**
      * The bytecode index to which this frame state applies.
@@ -100,7 +100,7 @@
 
     /**
      * Creates a {@code FrameState} with the given locals, stack expressions and locked monitors.
-     * 
+     *
      * @param method the method for this frame state
      * @param bci the bytecode index of the frame state
      * @param values the locals, stack expressions and locked objects, in this order
@@ -130,7 +130,7 @@
 
     /**
      * Simple constructor used to create marker FrameStates.
-     * 
+     *
      * @param bci marker bci, needs to be &lt; 0
      */
     public FrameState(int bci) {
@@ -306,7 +306,7 @@
 
     /**
      * Gets the value in the local variables at the specified index.
-     * 
+     *
      * @param i the index into the locals
      * @return the instruction that produced the value for the specified local
      */
@@ -317,7 +317,7 @@
 
     /**
      * Get the value on the stack at the specified stack index.
-     * 
+     *
      * @param i the index into the stack, with {@code 0} being the bottom of the stack
      * @return the instruction at the specified position in the stack
      */
@@ -328,7 +328,7 @@
 
     /**
      * Get the monitor owner at the specified index.
-     * 
+     *
      * @param i the index into the list of locked monitors.
      * @return the lock owner at the given index.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,17 +40,17 @@
  * maximum flexibility for the guard node and guarantees that deoptimization occurs only if the
  * control flow would have reached the guarded node (without taking exceptions into account).
  */
-@NodeInfo(nameTemplate = "Guard(!={p#negated}) {p#reason/s}")
-public class GuardNode extends FloatingGuardedNode implements Canonicalizable, IterableNodeType, GuardingNode, GuardedNode {
+@NodeInfo(nameTemplate = "Guard(!={p#negated}) {p#reason/s}", allowedUsageTypes = {InputType.Guard})
+public class GuardNode extends FloatingAnchoredNode implements Canonicalizable, IterableNodeType, GuardingNode {
 
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
     private final DeoptimizationReason reason;
     private Constant speculation;
     private DeoptimizationAction action;
     private boolean negated;
 
-    public GuardNode(LogicNode condition, GuardingNode anchor, DeoptimizationReason reason, DeoptimizationAction action, boolean negated, Constant speculation) {
-        super(StampFactory.dependency(), anchor);
+    public GuardNode(LogicNode condition, AnchoringNode anchor, DeoptimizationReason reason, DeoptimizationAction action, boolean negated, Constant speculation) {
+        super(StampFactory.forVoid(), anchor);
         this.condition = condition;
         this.reason = reason;
         this.action = action;
@@ -103,7 +103,7 @@
     public Node canonical(CanonicalizerTool tool) {
         if (condition() instanceof LogicNegationNode) {
             LogicNegationNode negation = (LogicNegationNode) condition();
-            return graph().unique(new GuardNode(negation.getInput(), getGuard(), reason, action, !negated, speculation));
+            return graph().unique(new GuardNode(negation.getInput(), getAnchor(), reason, action, !negated, speculation));
         } else if (condition() instanceof LogicConstantNode) {
             LogicConstantNode c = (LogicConstantNode) condition();
             if (c.getValue() != negated) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardPhiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(nameTemplate = "GuardPhi({i#values})", allowedUsageTypes = {InputType.Guard})
+public class GuardPhiNode extends PhiNode implements GuardingNode {
+
+    @Input(InputType.Guard) final NodeInputList<ValueNode> values = new NodeInputList<>(this);
+
+    public GuardPhiNode(MergeNode merge) {
+        super(StampFactory.forVoid(), merge);
+    }
+
+    @Override
+    public NodeInputList<ValueNode> values() {
+        return values;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Guard})
+public class GuardProxyNode extends ProxyNode implements GuardingNode, Proxy {
+
+    @Input(InputType.Guard) private GuardingNode value;
+
+    public GuardProxyNode(GuardingNode value, AbstractBeginNode proxyPoint) {
+        super(StampFactory.forVoid(), proxyPoint);
+        this.value = value;
+    }
+
+    @Override
+    public ValueNode value() {
+        return value.asNode();
+    }
+
+    public Node getOriginalNode() {
+        return value.asNode();
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardedValueNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,10 +32,10 @@
 /**
  * A node that changes the type of its input, usually narrowing it. For example, a GuardedValueNode
  * is used to keep the nodes depending on guards inside a loop during speculative guard movement.
- * 
+ *
  * A GuardedValueNode will only go away if its guard is null or {@link StructuredGraph#start()}.
  */
-public class GuardedValueNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, IterableNodeType, GuardingNode, Canonicalizable, ValueProxy {
+public class GuardedValueNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, IterableNodeType, Canonicalizable, ValueProxy {
 
     @Input private ValueNode object;
 
@@ -88,7 +88,7 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,10 +34,10 @@
  * A node that changes the stamp of its input based on some condition being true.
  */
 @NodeInfo(nameTemplate = "GuardingPi(!={p#negated}) {p#reason/s}")
-public class GuardingPiNode extends FixedWithNextNode implements Lowerable, Virtualizable, GuardingNode, Canonicalizable, ValueProxy {
+public class GuardingPiNode extends FixedWithNextNode implements Lowerable, Virtualizable, Canonicalizable, ValueProxy {
 
     @Input private ValueNode object;
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
     private final DeoptimizationReason reason;
     private final DeoptimizationAction action;
     private boolean negated;
@@ -59,7 +59,7 @@
 
     /**
      * Creates a guarding pi node.
-     * 
+     *
      * @param object the object whose type is refined if this guard succeeds
      * @param condition the condition to test
      * @param negateCondition the guard succeeds if {@code condition != negateCondition}
@@ -132,7 +132,7 @@
                     @ConstantNodeParameter DeoptimizationAction action, @ConstantNodeParameter Stamp stamp);
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -47,7 +46,7 @@
 
     @Successor private AbstractBeginNode trueSuccessor;
     @Successor private AbstractBeginNode falseSuccessor;
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
     private double trueSuccessorProbability;
 
     public LogicNode condition() {
@@ -74,7 +73,7 @@
 
     /**
      * Gets the true successor.
-     * 
+     *
      * @return the true successor
      */
     public AbstractBeginNode trueSuccessor() {
@@ -83,7 +82,7 @@
 
     /**
      * Gets the false successor.
-     * 
+     *
      * @return the false successor
      */
     public AbstractBeginNode falseSuccessor() {
@@ -102,7 +101,7 @@
 
     /**
      * Gets the node corresponding to the specified outcome of the branch.
-     * 
+     *
      * @param istrue {@code true} if the true successor is requested, {@code false} otherwise
      * @return the corresponding successor
      */
@@ -340,7 +339,7 @@
 
     /**
      * Tries to remove an empty if construct or replace an if construct with a materialization.
-     * 
+     *
      * @return true if a transformation was made, false otherwise
      */
     private boolean removeOrMaterializeIf(SimplifierTool tool) {
@@ -445,7 +444,7 @@
     /**
      * Tries to connect code that initializes a variable directly with the successors of an if
      * construct that switches on the variable. For example, the pseudo code below:
-     * 
+     *
      * <pre>
      * contains(list, e, yes, no) {
      *     if (list == null || e == null) {
@@ -466,9 +465,9 @@
      *     }
      * }
      * </pre>
-     * 
+     *
      * will be transformed into:
-     * 
+     *
      * <pre>
      * contains(list, e, yes, no) {
      *     if (list == null || e == null) {
@@ -484,7 +483,7 @@
      *     }
      * }
      * </pre>
-     * 
+     *
      * @return true if a transformation was made, false otherwise
      */
     private boolean removeIntermediateMaterialization(SimplifierTool tool) {
@@ -514,12 +513,12 @@
             return false;
         }
         Node singleUsage = mergeUsages.first();
-        if (!(singleUsage instanceof PhiNode) || (singleUsage != compare.x() && singleUsage != compare.y())) {
+        if (!(singleUsage instanceof ValuePhiNode) || (singleUsage != compare.x() && singleUsage != compare.y())) {
             return false;
         }
 
         // Ensure phi is used by at most the comparison and the merge's frame state (if any)
-        PhiNode phi = (PhiNode) singleUsage;
+        ValuePhiNode phi = (ValuePhiNode) singleUsage;
         NodeIterable<Node> phiUsages = phi.usages();
         if (phiUsages.count() > 2) {
             return false;
@@ -634,7 +633,7 @@
      * Connects a set of ends to a given successor, inserting a merge node if there is more than one
      * end. If {@code ends} is not empty, then {@code successor} is added to {@code tool}'s
      * {@linkplain SimplifierTool#addToWorkList(com.oracle.graal.graph.Node) work list}.
-     * 
+     *
      * @param oldMerge the merge being removed
      * @param phiValues the values of the phi at the merge, keyed by the merge ends
      */
@@ -650,7 +649,7 @@
                 // removed
                 MergeNode newMerge = graph().add(new MergeNode());
                 PhiNode oldPhi = (PhiNode) oldMerge.usages().first();
-                PhiNode newPhi = graph().addWithoutUnique(new PhiNode(oldPhi.stamp(), newMerge));
+                PhiNode newPhi = graph().addWithoutUnique(new ValuePhiNode(oldPhi.stamp(), newMerge));
 
                 for (AbstractEndNode end : ends) {
                     newPhi.addInput(phiValues.get(end));
@@ -674,7 +673,7 @@
      * Gets an array of constants derived from a node that is either a {@link ConstantNode} or a
      * {@link PhiNode} whose input values are all constants. The length of the returned array is
      * equal to the number of ends terminating in a given merge node.
-     * 
+     *
      * @return null if {@code node} is neither a {@link ConstantNode} nor a {@link PhiNode} whose
      *         input values are all constants
      */
@@ -687,7 +686,7 @@
 
         if (node instanceof PhiNode) {
             PhiNode phi = (PhiNode) node;
-            if (phi.merge() == merge && phi.type() == PhiType.Value && phi.valueCount() == merge.forwardEndCount()) {
+            if (phi.merge() == merge && phi instanceof ValuePhiNode && phi.valueCount() == merge.forwardEndCount()) {
                 Constant[] result = new Constant[merge.forwardEndCount()];
                 int i = 0;
                 for (ValueNode n : phi.values()) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
@@ -32,7 +33,7 @@
 public class InfopointNode extends FixedWithNextNode implements LIRLowerable, NodeWithState {
 
     public final InfopointReason reason;
-    @Input private FrameState state;
+    @Input(InputType.State) private FrameState state;
 
     public InfopointNode(InfopointReason reason, FrameState state) {
         super(StampFactory.forVoid());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
@@ -34,19 +35,19 @@
 /**
  * The {@code InvokeNode} represents all kinds of method calls.
  */
-@NodeInfo(nameTemplate = "Invoke#{p#targetMethod/s}")
+@NodeInfo(nameTemplate = "Invoke#{p#targetMethod/s}", allowedUsageTypes = {InputType.Memory})
 public final class InvokeNode extends AbstractMemoryCheckpoint implements Invoke, LIRLowerable, MemoryCheckpoint.Single {
 
-    @Input private CallTargetNode callTarget;
-    @Input private FrameState stateDuring;
-    @Input private GuardingNode guard;
+    @Input(InputType.Extension) private CallTargetNode callTarget;
+    @Input(InputType.State) private FrameState stateDuring;
+    @Input(InputType.Guard) private GuardingNode guard;
     private final int bci;
     private boolean polymorphic;
     private boolean useForInlining;
 
     /**
      * Constructs a new Invoke instruction.
-     * 
+     *
      * @param callTarget the target method being called
      * @param bci the bytecode index of the original invoke (used for debug infos)
      */
@@ -56,7 +57,7 @@
 
     /**
      * Constructs a new Invoke instruction.
-     * 
+     *
      * @param callTarget the target method being called
      * @param bci the bytecode index of the original invoke (used for debug infos)
      * @param stamp the stamp to be used for this value
@@ -94,6 +95,16 @@
     }
 
     @Override
+    public boolean isAllowedUsageType(InputType type) {
+        if (getKind() != Kind.Void) {
+            if (callTarget instanceof MethodCallTargetNode && ((MethodCallTargetNode) callTarget).targetMethod().getAnnotation(NodeIntrinsic.class) != null) {
+                return true;
+            }
+        }
+        return super.isAllowedUsageType(type);
+    }
+
+    @Override
     public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
         Map<Object, Object> debugProperties = super.getDebugProperties(map);
         if (callTarget != null) {
@@ -134,7 +145,7 @@
 
     @Override
     public void intrinsify(Node node) {
-        assert !(node instanceof ValueNode) || (((ValueNode) node).getKind() == Kind.Void) == (getKind() == Kind.Void);
+        assert !(node instanceof ValueNode) || node.isAllowedUsageType(InputType.Value) == isAllowedUsageType(InputType.Value) : "replacing " + this + " with " + node;
         CallTargetNode call = callTarget;
         FrameState stateAfter = stateAfter();
         if (node instanceof StateSplit) {
@@ -187,7 +198,7 @@
 
     @Override
     public void setGuard(GuardingNode guard) {
-        updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+        updateUsagesInterface(this.guard, guard);
         this.guard = guard;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,17 +31,17 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.util.*;
 
-@NodeInfo(nameTemplate = "Invoke!#{p#targetMethod/s}")
+@NodeInfo(nameTemplate = "Invoke!#{p#targetMethod/s}", allowedUsageTypes = {InputType.Memory})
 public class InvokeWithExceptionNode extends ControlSplitNode implements Invoke, MemoryCheckpoint.Single, LIRLowerable {
 
     private static final double EXCEPTION_PROBA = 1e-5;
 
     @Successor private AbstractBeginNode next;
     @Successor private DispatchBeginNode exceptionEdge;
-    @Input private CallTargetNode callTarget;
-    @Input private FrameState stateDuring;
-    @Input private FrameState stateAfter;
-    @Input private GuardingNode guard;
+    @Input(InputType.Extension) private CallTargetNode callTarget;
+    @Input(InputType.State) private FrameState stateDuring;
+    @Input(InputType.State) private FrameState stateAfter;
+    @Input(InputType.Guard) private GuardingNode guard;
     private final int bci;
     private boolean polymorphic;
     private boolean useForInlining;
@@ -236,7 +236,7 @@
 
     @Override
     public void setGuard(GuardingNode guard) {
-        updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+        updateUsagesInterface(this.guard, guard);
         this.guard = guard;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/KillingBeginNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/KillingBeginNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,8 +23,10 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class KillingBeginNode extends AbstractBeginNode implements MemoryCheckpoint.Single {
 
     private LocationIdentity locationIdentity;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNegationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNegationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,7 @@
  */
 public class LogicNegationNode extends LogicNode implements Canonicalizable {
 
-    @Input private LogicNode input;
+    @Input(InputType.Condition) private LogicNode input;
 
     public LogicNegationNode(LogicNode input) {
         this.input = input;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LogicNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,13 +22,17 @@
  */
 package com.oracle.graal.nodes;
 
+import static com.oracle.graal.graph.InputType.*;
+
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.type.*;
 
+@NodeInfo(allowedUsageTypes = {Condition})
 public abstract class LogicNode extends FloatingNode {
 
     public LogicNode() {
-        super(StampFactory.condition());
+        super(StampFactory.forVoid());
     }
 
     public static LogicNode and(LogicNode a, LogicNode b, double shortCircuitProbability) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
     private double loopFrequency;
     private int nextEndIndex;
     private int unswitches;
-    @Input private GuardingNode overflowGuard;
+    @Input(InputType.Guard) private GuardingNode overflowGuard;
 
     public LoopBeginNode() {
         loopFrequency = 1;
@@ -57,7 +57,7 @@
      * Returns the <b>unordered</b> set of {@link LoopEndNode} that correspond to back-edges for
      * this loop. The order of the back-edges is unspecified, if you need to get an ordering
      * compatible for {@link PhiNode} creation, use {@link #orderedLoopEnds()}.
-     * 
+     *
      * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop
      */
     public NodeIterable<LoopEndNode> loopEnds() {
@@ -77,7 +77,7 @@
      * Returns the set of {@link LoopEndNode} that correspond to back-edges for this loop, ordered
      * in increasing {@link #phiPredecessorIndex}. This method is suited to create new loop
      * {@link PhiNode}.
-     * 
+     *
      * @return the set of {@code LoopEndNode} that correspond to back-edges for this loop
      */
     public List<LoopEndNode> orderedLoopEnds() {
@@ -198,7 +198,7 @@
     }
 
     public void setOverflowGuard(GuardingNode overflowGuard) {
-        updateUsages(this.overflowGuard == null ? null : this.overflowGuard.asNode(), overflowGuard == null ? null : overflowGuard.asNode());
+        updateUsagesInterface(this.overflowGuard, overflowGuard);
         this.overflowGuard = overflowGuard;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 
 public final class LoopEndNode extends AbstractEndNode {
 
-    @Input(notDataflow = true) private LoopBeginNode loopBegin;
+    @Input(InputType.Association) private LoopBeginNode loopBegin;
     private boolean canSafepoint;
     private int endIndex;
 
@@ -80,7 +80,7 @@
      * Returns the 0-based index of this loop end. This is <b>not</b> the index into {@link PhiNode}
      * values at the loop begin. Use {@link MergeNode#phiPredecessorIndex(AbstractEndNode)} for this
      * purpose.
-     * 
+     *
      * @return The 0-based index of this loop end.
      */
     public int endIndex() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopExitNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopExitNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,9 +25,10 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public class LoopExitNode extends BeginStateSplitNode implements IterableNodeType {
 
-    @Input(notDataflow = true) private LoopBeginNode loopBegin;
+    @Input(InputType.Association) private LoopBeginNode loopBegin;
 
     public LoopExitNode(LoopBeginNode loop) {
         assert loop != null;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,10 +25,12 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.type.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Extension})
 public abstract class MemoryMapNode extends FloatingNode {
 
     public MemoryMapNode() {
@@ -38,4 +40,6 @@
     public abstract MemoryNode getLastLocationAccess(LocationIdentity locationIdentity);
 
     public abstract Set<LocationIdentity> getLocations();
+
+    public abstract void replaceLastLocationAccess(MemoryNode oldNode, MemoryNode newNode);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, 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
@@ -23,22 +23,26 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.type.*;
 
 /**
  * The {@code PhiNode} represents the merging of dataflow in the memory graph.
  */
+@NodeInfo(nameTemplate = "MemoryPhi({i#values}) {p#locationIdentity/s}", allowedUsageTypes = {InputType.Memory})
 public class MemoryPhiNode extends PhiNode implements MemoryNode {
 
-    private final LocationIdentity identity;
+    @Input(InputType.Memory) final NodeInputList<ValueNode> values = new NodeInputList<>(this);
+    private final LocationIdentity locationIdentity;
 
-    public MemoryPhiNode(MergeNode merge, LocationIdentity identity) {
-        super(PhiType.Memory, merge);
-        this.identity = identity;
+    public MemoryPhiNode(MergeNode merge, LocationIdentity locationIdentity) {
+        super(StampFactory.forVoid(), merge);
+        this.locationIdentity = locationIdentity;
     }
 
     public LocationIdentity getLocationIdentity() {
-        return identity;
+        return locationIdentity;
     }
 
     public MemoryCheckpoint asMemoryCheckpoint() {
@@ -48,4 +52,9 @@
     public MemoryPhiNode asMemoryPhi() {
         return this;
     }
+
+    @Override
+    public NodeInputList<ValueNode> values() {
+        return values;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, 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
@@ -23,20 +23,28 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
 
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class MemoryProxyNode extends ProxyNode implements MemoryProxy, LIRLowerable {
 
+    @Input(InputType.Memory) private MemoryNode value;
     private final LocationIdentity identity;
 
-    public MemoryProxyNode(ValueNode value, AbstractBeginNode exit, LocationIdentity identity) {
-        super(value, exit, PhiType.Memory);
-        assert value instanceof MemoryNode;
+    public MemoryProxyNode(MemoryNode value, AbstractBeginNode exit, LocationIdentity identity) {
+        super(StampFactory.forVoid(), exit);
+        this.value = value;
         this.identity = identity;
     }
 
+    @Override
+    public ValueNode value() {
+        return value.asNode();
+    }
+
     public LocationIdentity getLocationIdentity() {
         return identity;
     }
@@ -47,14 +55,10 @@
 
     @Override
     public boolean verify() {
-        assert value() instanceof MemoryNode;
+        assert value() instanceof MemoryNode : this + " " + value();
         return super.verify();
     }
 
-    public static MemoryProxyNode forMemory(MemoryNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) {
-        return graph.unique(new MemoryProxyNode(ValueNodeUtil.asNode(value), exit, location));
-    }
-
     public MemoryNode getOriginalMemoryNode() {
         return (MemoryNode) value();
     }
@@ -66,4 +70,8 @@
     public MemoryPhiNode asMemoryPhi() {
         return getOriginalMemoryNode().asMemoryPhi();
     }
+
+    public Node getOriginalNode() {
+        return value.asNode();
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,9 +36,10 @@
 /**
  * Denotes the merging of multiple control-flow paths.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public class MergeNode extends BeginStateSplitNode implements IterableNodeType, LIRLowerable {
 
-    @Input(notDataflow = true) private final NodeInputList<AbstractEndNode> ends = new NodeInputList<>(this);
+    @Input(InputType.Association) private final NodeInputList<AbstractEndNode> ends = new NodeInputList<>(this);
 
     @Override
     public void generate(NodeLIRBuilderTool gen) {
@@ -68,7 +69,7 @@
 
     /**
      * Determines if a given node is a phi whose {@linkplain PhiNode#merge() merge} is this node.
-     * 
+     *
      * @param value the instruction to test
      * @return {@code true} if {@code value} is a phi and its merge is {@code this}
      */
@@ -79,7 +80,7 @@
     /**
      * Removes the given end from the merge, along with the entries corresponding to this end in the
      * phis connected to the merge.
-     * 
+     *
      * @param pred the end to remove
      */
     public void removeEnd(AbstractEndNode pred) {
@@ -210,7 +211,7 @@
                 }
             }
 
-            PhiNode returnValuePhi = returnNode.result() == null || !isPhiAtMerge(returnNode.result()) ? null : (PhiNode) returnNode.result();
+            ValuePhiNode returnValuePhi = returnNode.result() == null || !isPhiAtMerge(returnNode.result()) ? null : (ValuePhiNode) returnNode.result();
             List<AbstractEndNode> endNodes = forwardEnds().snapshot();
             for (AbstractEndNode end : endNodes) {
                 ReturnNode newReturn = graph().add(new ReturnNode(returnValuePhi == null ? returnNode.result() : returnValuePhi.valueAt(end)));
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, 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
@@ -25,61 +25,18 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.type.*;
 
-/**
- * The {@code PhiNode} represents the merging of dataflow in the graph. It refers to a merge and a
- * variable.
- */
-@NodeInfo(nameTemplate = "{p#type/s}Phi({i#values})")
-public class PhiNode extends FloatingNode implements Canonicalizable, GuardingNode {
-
-    public static enum PhiType {
-        Value(null), // normal value phis
-        Guard(StampFactory.dependency()),
-        Memory(StampFactory.dependency());
-
-        public final Stamp stamp;
+public abstract class PhiNode extends FloatingNode {
 
-        PhiType(Stamp stamp) {
-            this.stamp = stamp;
-        }
-    }
-
-    @Input(notDataflow = true) private MergeNode merge;
-    @Input private final NodeInputList<ValueNode> values = new NodeInputList<>(this);
-    private final PhiType type;
+    @Input(InputType.Association) private MergeNode merge;
 
-    /**
-     * Create a value phi ({@link PhiType#Value}) with the specified stamp.
-     * 
-     * @param stamp the stamp of the value
-     * @param merge the merge that the new phi belongs to
-     */
-    public PhiNode(Stamp stamp, MergeNode merge) {
+    protected PhiNode(Stamp stamp, MergeNode merge) {
         super(stamp);
-        assert stamp != StampFactory.forVoid();
-        this.type = PhiType.Value;
         this.merge = merge;
     }
 
-    /**
-     * Create a non-value phi ({@link PhiType#Memory} with the specified kind.
-     * 
-     * @param type the type of the new phi
-     * @param merge the merge that the new phi belongs to
-     */
-    public PhiNode(PhiType type, MergeNode merge) {
-        super(type.stamp);
-        assert type.stamp != null : merge + " " + type;
-        this.type = type;
-        this.merge = merge;
-    }
-
-    public PhiType type() {
-        return type;
-    }
+    public abstract NodeInputList<ValueNode> values();
 
     public MergeNode merge() {
         return merge;
@@ -90,23 +47,6 @@
         merge = x;
     }
 
-    public NodeInputList<ValueNode> values() {
-        return values;
-    }
-
-    @Override
-    public boolean inferStamp() {
-        if (type == PhiType.Value) {
-            return inferPhiStamp();
-        } else {
-            return false;
-        }
-    }
-
-    public boolean inferPhiStamp() {
-        return updateStamp(StampTool.meet(values()));
-    }
-
     @Override
     public boolean verify() {
         assertTrue(merge() != null, "missing merge");
@@ -117,29 +57,29 @@
     /**
      * Get the instruction that produces the value associated with the i'th predecessor of the
      * merge.
-     * 
+     *
      * @param i the index of the predecessor
      * @return the instruction that produced the value in the i'th predecessor
      */
     public ValueNode valueAt(int i) {
-        return values.get(i);
+        return values().get(i);
     }
 
     /**
      * Sets the value at the given index and makes sure that the values list is large enough.
-     * 
+     *
      * @param i the index at which to set the value
      * @param x the new phi input value for the given location
      */
     public void initializeValueAt(int i, ValueNode x) {
         while (values().size() <= i) {
-            values.add(null);
+            values().add(null);
         }
-        values.set(i, x);
+        values().set(i, x);
     }
 
     public void setValueAt(int i, ValueNode x) {
-        values.set(i, x);
+        values().set(i, x);
     }
 
     public ValueNode valueAt(AbstractEndNode pred) {
@@ -148,15 +88,15 @@
 
     /**
      * Get the number of inputs to this phi (i.e. the number of predecessors to the merge).
-     * 
+     *
      * @return the number of inputs in this phi
      */
     public int valueCount() {
-        return values.size();
+        return values().size();
     }
 
     public void clearValues() {
-        values.clear();
+        values().clear();
     }
 
     @Override
@@ -169,24 +109,20 @@
                 }
                 str.append(valueAt(i) == null ? "-" : valueAt(i).toString(Verbosity.Id));
             }
-            if (type == PhiType.Value) {
-                return super.toString(Verbosity.Name) + "(" + str + ")";
-            } else {
-                return type + super.toString(Verbosity.Name) + "(" + str + ")";
-            }
+            return super.toString(Verbosity.Name) + "(" + str + ")";
         } else {
             return super.toString(verbosity);
         }
     }
 
     public void addInput(ValueNode x) {
-        assert !(x instanceof PhiNode) || ((PhiNode) x).merge() instanceof LoopBeginNode || ((PhiNode) x).merge() != this.merge();
-        assert x.stamp().isCompatible(stamp()) || type != PhiType.Value;
-        values.add(x);
+        assert !(x instanceof ValuePhiNode) || ((ValuePhiNode) x).merge() instanceof LoopBeginNode || ((ValuePhiNode) x).merge() != this.merge();
+        assert !(this instanceof ValuePhiNode) || x.stamp().isCompatible(stamp());
+        values().add(x);
     }
 
     public void removeInput(int index) {
-        values.remove(index);
+        values().remove(index);
     }
 
     public ValueNode singleValue() {
@@ -235,4 +171,5 @@
     public boolean isLoopPhi() {
         return merge() instanceof LoopBeginNode;
     }
-}
+
+}
\ No newline at end of file
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,12 +34,12 @@
 /**
  * A node that changes the type of its input, usually narrowing it. For example, a PiNode refines
  * the type of a receiver during type-guarded inlining to be the type tested by the guard.
- * 
+ *
  * In contrast to a {@link GuardedValueNode}, a PiNode is useless as soon as the type of its input
  * is as narrow or narrower than the PiNode's type. The PiNode, and therefore also the scheduling
  * restriction enforced by the anchor, will go away.
  */
-public class PiNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, IterableNodeType, GuardingNode, Canonicalizable, ValueProxy {
+public class PiNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, IterableNodeType, Canonicalizable, ValueProxy {
 
     @Input private ValueNode object;
 
@@ -94,7 +94,7 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 
@@ -108,6 +108,10 @@
         return piCast(object, toType, true, true);
     }
 
+    public static <T> T piCastExact(Object object, @ConstantNodeParameter Class<T> toType) {
+        return piCast(object, toType, true, false);
+    }
+
     public static <T> T piCast(Object object, @ConstantNodeParameter Class<T> toType) {
         return piCast(object, toType, false, false);
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,87 +22,50 @@
  */
 package com.oracle.graal.nodes;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Node.ValueNumberable;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
 
 /**
- * A value proxy that is inserted in the frame state of a loop exit for any value that is created
- * inside the loop (i.e. was not live on entry to the loop) and is (potentially) used after the
- * loop.
+ * A proxy is inserted at loop exits for any value that is created inside the loop (i.e. was not
+ * live on entry to the loop) and is (potentially) used after the loop.
  */
-@NodeInfo(nameTemplate = "{p#type/s}Proxy")
-public class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable, Canonicalizable, Virtualizable, ValueAndStampProxy, GuardingNode {
+public abstract class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable {
 
-    @Input(notDataflow = true) private AbstractBeginNode proxyPoint;
-    @Input private ValueNode value;
-    private final PhiType type;
+    @Input(InputType.Association) private AbstractBeginNode proxyPoint;
 
-    public ProxyNode(ValueNode value, AbstractBeginNode exit, PhiType type) {
-        super(type == PhiType.Value ? value.stamp() : type.stamp);
-        this.type = type;
-        assert exit != null;
-        this.proxyPoint = exit;
-        this.value = value;
+    public ProxyNode(Stamp stamp, AbstractBeginNode proxyPoint) {
+        super(stamp);
+        assert proxyPoint != null;
+        this.proxyPoint = proxyPoint;
     }
 
-    public ValueNode value() {
-        return value;
-    }
-
-    @Override
-    public boolean inferStamp() {
-        return updateStamp(value.stamp());
-    }
+    public abstract ValueNode value();
 
     public AbstractBeginNode proxyPoint() {
         return proxyPoint;
     }
 
-    public PhiType type() {
-        return type;
-    }
-
     @Override
     public boolean verify() {
-        assert value != null;
+        assert value() != null;
         assert proxyPoint != null;
-        assert !(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint != proxyPoint;
+        assert !(value() instanceof ProxyNode) || ((ProxyNode) value()).proxyPoint != proxyPoint;
         return super.verify();
     }
 
-    @Override
-    public Node canonical(CanonicalizerTool tool) {
-        if (type == PhiType.Value && value.isConstant()) {
-            return value;
-        }
-        return this;
+    public static MemoryProxyNode forMemory(MemoryNode value, AbstractBeginNode exit, LocationIdentity location, StructuredGraph graph) {
+        return graph.unique(new MemoryProxyNode(value, exit, location));
     }
 
-    @Override
-    public void virtualize(VirtualizerTool tool) {
-        if (type == PhiType.Value) {
-            State state = tool.getObjectState(value);
-            if (state != null && state.getState() == EscapeState.Virtual) {
-                tool.replaceWithVirtual(state.getVirtualObject());
-            }
-        }
+    public static ValueProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
+        return graph.unique(new ValueProxyNode(value, exit));
     }
 
-    public static ProxyNode forGuard(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
-        return graph.unique(new ProxyNode(value, exit, PhiType.Guard));
-    }
-
-    public static ProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
-        return graph.unique(new ProxyNode(value, exit, PhiType.Value));
-    }
-
-    @Override
-    public ValueNode getOriginalValue() {
-        return value;
+    public static GuardProxyNode forGuard(GuardingNode value, AbstractBeginNode exit, StructuredGraph graph) {
+        return graph.unique(new GuardProxyNode(value, exit));
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ReturnNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 public final class ReturnNode extends ControlSinkNode implements LIRLowerable, IterableNodeType {
 
     @Input private ValueNode result;
-    @Input private MemoryMapNode memoryMap;
+    @Input(InputType.Extension) private MemoryMapNode memoryMap;
 
     public ValueNode result() {
         return result;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ShortCircuitOrNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,8 +27,8 @@
 
 public class ShortCircuitOrNode extends LogicNode implements IterableNodeType, Canonicalizable {
 
-    @Input private LogicNode x;
-    @Input private LogicNode y;
+    @Input(InputType.Condition) private LogicNode x;
+    @Input(InputType.Condition) private LogicNode y;
     private boolean xNegated;
     private boolean yNegated;
     private double shortCircuitProbability;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StartNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StartNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,11 +23,13 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.extended.*;
 
 /**
  * The start node of a graph.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class StartNode extends BeginStateSplitNode implements MemoryCheckpoint.Single {
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,7 +41,7 @@
      * The different stages of the compilation of a {@link Graph} regarding the status of
      * {@link GuardNode guards}, {@link DeoptimizingNode deoptimizations} and {@link FrameState
      * framestates}. The stage of a graph progresses monotonously.
-     * 
+     *
      */
     public static enum GuardsStage {
         /**
@@ -137,7 +137,7 @@
 
     /**
      * Gets the method from which this graph was built.
-     * 
+     *
      * @return null if this method was not built from a method or the method is not available
      */
     public ResolvedJavaMethod method() {
@@ -250,7 +250,7 @@
     /**
      * Unlinks a node from all its control flow neighbors and then removes it from its graph. The
      * node must have no {@linkplain Node#usages() usages}.
-     * 
+     *
      * @param node the node to be unlinked and removed
      */
     public void removeFixed(FixedWithNextNode node) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -123,7 +123,7 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,7 +55,7 @@
      * Checks if the given stamp is different than the current one (
      * {@code newStamp.equals(oldStamp) == false}). If it is different then the new stamp will
      * become the current stamp for this node.
-     * 
+     *
      * @return true if the stamp has changed, false otherwise.
      */
     protected final boolean updateStamp(Stamp newStamp) {
@@ -72,7 +72,7 @@
      * their stamp if their inputs change. A typical implementation will compute the stamp and pass
      * it to {@link #updateStamp(Stamp)}, whose return value can be used as the result of this
      * method.
-     * 
+     *
      * @return true if the stamp has changed, false otherwise.
      */
     public boolean inferStamp() {
@@ -85,7 +85,7 @@
 
     /**
      * Checks whether this value is a constant (i.e. it is of type {@link ConstantNode}.
-     * 
+     *
      * @return {@code true} if this value is a constant
      */
     public final boolean isConstant() {
@@ -106,7 +106,7 @@
 
     /**
      * Checks whether this value represents the null constant.
-     * 
+     *
      * @return {@code true} if this value represents the null constant
      */
     public final boolean isNullConstant() {
@@ -115,7 +115,7 @@
 
     /**
      * Convert this value to a constant if it is a constant, otherwise return null.
-     * 
+     *
      * @return the {@link Constant} represented by this value if it is a constant; {@code null}
      *         otherwise
      */
@@ -129,4 +129,13 @@
     public ValueNode asNode() {
         return this;
     }
+
+    @Override
+    public boolean isAllowedUsageType(InputType type) {
+        if (getKind() != Kind.Void && type == InputType.Value) {
+            return true;
+        } else {
+            return super.isAllowedUsageType(type);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * The {@code PhiNode} represents the merging of dataflow in the graph. It refers to a merge and a
+ * variable.
+ */
+@NodeInfo(nameTemplate = "ValuePhi({i#values})")
+public class ValuePhiNode extends PhiNode implements Canonicalizable {
+
+    @Input final NodeInputList<ValueNode> values = new NodeInputList<>(this);
+
+    /**
+     * Create a value phi with the specified stamp.
+     *
+     * @param stamp the stamp of the value
+     * @param merge the merge that the new phi belongs to
+     */
+    public ValuePhiNode(Stamp stamp, MergeNode merge) {
+        super(stamp, merge);
+        assert stamp != StampFactory.forVoid();
+    }
+
+    @Override
+    public NodeInputList<ValueNode> values() {
+        return values;
+    }
+
+    @Override
+    public boolean inferStamp() {
+        return inferPhiStamp();
+    }
+
+    public boolean inferPhiStamp() {
+        return updateStamp(StampTool.meet(values()));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.spi.*;
+
+public class ValueProxyNode extends ProxyNode implements Canonicalizable, Virtualizable, ValueAndStampProxy {
+
+    @Input private ValueNode value;
+
+    public ValueProxyNode(ValueNode value, AbstractBeginNode proxyPoint) {
+        super(value.stamp(), proxyPoint);
+        this.value = value;
+    }
+
+    @Override
+    public ValueNode value() {
+        return value;
+    }
+
+    @Override
+    public boolean inferStamp() {
+        return updateStamp(value.stamp());
+    }
+
+    @Override
+    public Node canonical(CanonicalizerTool tool) {
+        if (value.isConstant()) {
+            return value;
+        }
+        return this;
+    }
+
+    @Override
+    public void virtualize(VirtualizerTool tool) {
+        State state = tool.getObjectState(value);
+        if (state != null && state.getState() == EscapeState.Virtual) {
+            tool.replaceWithVirtual(state.getVirtualObject());
+        }
+    }
+
+    @Override
+    public ValueNode getOriginalNode() {
+        return value();
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,7 @@
  * Base class for nodes that contain "virtual" state, like FrameState and VirtualObjectState.
  * Subclasses of this class will be treated in a special way by the scheduler.
  */
+@NodeInfo(allowedUsageTypes = {InputType.State})
 public abstract class VirtualState extends Node {
 
     public interface NodeClosure<T extends Node> {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -67,6 +67,13 @@
             if ((rawY & mask) == 0) {
                 return ConstantNode.forIntegerStamp(stamp(), 0, graph());
             }
+            if (x() instanceof SignExtendNode) {
+                SignExtendNode ext = (SignExtendNode) x();
+                if (rawY == ((1L << ext.getInputBits()) - 1)) {
+                    ValueNode result = graph().unique(new ZeroExtendNode(ext.getInput(), ext.getResultBits()));
+                    return result;
+                }
+            }
             if (x().stamp() instanceof IntegerStamp) {
                 IntegerStamp xStamp = (IntegerStamp) x().stamp();
                 if (((xStamp.upMask() | xStamp.downMask()) & ~rawY) == 0) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/BinaryNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -45,7 +45,7 @@
 
     /**
      * Creates a new BinaryNode instance.
-     * 
+     *
      * @param stamp the result type of this instruction
      * @param x the first input instruction
      * @param y the second input instruction
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
  */
 public final class ConditionalNode extends BinaryNode implements Canonicalizable, LIRLowerable {
 
-    @Input private LogicNode condition;
+    @Input(InputType.Condition) private LogicNode condition;
 
     public LogicNode condition() {
         return condition;
@@ -128,7 +128,7 @@
     public static native boolean materializeCondition(@ConstantNodeParameter Condition condition, long x, long y);
 
     @NodeIntrinsic
-    public static boolean materializeIsInstance(Class mirror, Object object) {
+    public static boolean materializeIsInstance(Class<?> mirror, Object object) {
         return mirror.isInstance(object);
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -206,12 +206,6 @@
     }
 
     public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) {
-        Kind kind = access.nullCheckLocation().getValueKind();
-        if (kind != kind.getStackKind()) {
-            // Doesn't work for subword operations
-            return false;
-        }
-
         Value result = gen.emitFloatConvertMemory(getOp(), access);
         if (result != null) {
             gen.setResult(this, result);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatingNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatingNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,9 +31,4 @@
     public FloatingNode(Stamp stamp) {
         super(stamp);
     }
-
-    @Override
-    public FloatingNode asNode() {
-        return this;
-    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -75,9 +75,9 @@
     private void virtualizeNonVirtualComparison(State state, ValueNode other, VirtualizerTool tool) {
         if (!state.getVirtualObject().hasIdentity() && state.getVirtualObject().entryKind(0) == Kind.Boolean) {
             if (other.isConstant()) {
-                Object otherValue = other.asConstant().asObject();
-                if (otherValue == Boolean.TRUE || otherValue == Boolean.FALSE) {
-                    int expectedValue = (otherValue == Boolean.TRUE) ? 1 : 0;
+                Constant otherUnboxed = tool.getConstantReflectionProvider().unboxPrimitive(other.asConstant());
+                if (otherUnboxed != null && otherUnboxed.getKind() == Kind.Boolean) {
+                    int expectedValue = otherUnboxed.asBoolean() ? 1 : 0;
                     IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph()));
                     tool.addNode(equals);
                     tool.replaceWithValue(equals);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -111,7 +111,7 @@
 
     @Override
     public boolean generate(MemoryArithmeticLIRLowerer gen, Access access) {
-        Value result = gen.emitSignExtendMemory(access, access.nullCheckLocation().getValueKind().getBitCount(), getResultBits());
+        Value result = gen.emitSignExtendMemory(access, getInputBits(), getResultBits());
         if (result != null) {
             gen.setResult(this, result);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -75,6 +75,19 @@
             ZeroExtendNode other = (ZeroExtendNode) getInput();
             return graph().unique(new ZeroExtendNode(other.getInput(), getResultBits()));
         }
+        if (getInput() instanceof NarrowNode) {
+            NarrowNode narrow = (NarrowNode) getInput();
+            Stamp inputStamp = narrow.getInput().stamp();
+            if (inputStamp instanceof IntegerStamp && inputStamp.isCompatible(stamp())) {
+                IntegerStamp istamp = (IntegerStamp) inputStamp;
+                long mask = IntegerStamp.defaultMask(PrimitiveStamp.getBits(narrow.stamp()));
+                if (((istamp.upMask() | istamp.downMask()) & ~mask) == 0) {
+                    // The original value is in the range of the masked zero extended result so
+                    // simply return the original input.
+                    return narrow.getInput();
+                }
+            }
+        }
 
         return this;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,11 +24,11 @@
 
 import java.util.*;
 
-public interface AbstractBlock<T extends AbstractBlock<?>> {
+public interface AbstractBlock<T extends AbstractBlock<T>> {
 
     int getId();
 
-    Loop getLoop();
+    Loop<T> getLoop();
 
     int getLoopDepth();
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractControlFlowGraph.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractControlFlowGraph.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,11 +22,13 @@
  */
 package com.oracle.graal.nodes.cfg;
 
+import java.util.*;
+
 public interface AbstractControlFlowGraph<T extends AbstractBlock<T>> {
 
     T[] getBlocks();
 
-    Loop[] getLoops();
+    Collection<Loop<T>> getLoops();
 
     T getStartBlock();
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
     protected final AbstractBeginNode beginNode;
 
     protected FixedNode endNode;
-    protected Loop loop;
+    protected Loop<Block> loop;
 
     protected List<Block> dominated;
     protected Block postdominator;
@@ -49,7 +49,7 @@
         return endNode;
     }
 
-    public Loop getLoop() {
+    public Loop<Block> getLoop() {
         return loop;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/CFGVerifier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/CFGVerifier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -84,13 +84,13 @@
         }
 
         if (cfg.getLoops() != null) {
-            for (Loop loop : cfg.getLoops()) {
+            for (Loop<Block> loop : cfg.getLoops()) {
                 assert loop.header.isLoopHeader();
 
                 for (Block block : loop.blocks) {
                     assert block.getId() >= loop.header.getId();
 
-                    Loop blockLoop = block.getLoop();
+                    Loop<?> blockLoop = block.getLoop();
                     while (blockLoop != loop) {
                         assert blockLoop != null;
                         blockLoop = blockLoop.parent;
@@ -109,7 +109,7 @@
                 for (Block block : loop.exits) {
                     assert block.getId() >= loop.header.getId();
 
-                    Loop blockLoop = block.getLoop();
+                    Loop<?> blockLoop = block.getLoop();
                     while (blockLoop != null) {
                         blockLoop = blockLoop.parent;
                         assert blockLoop != loop;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
 
     private final NodeMap<Block> nodeToBlock;
     private Block[] reversePostOrder;
-    private Loop[] loops;
+    private List<Loop<Block>> loops;
 
     public static ControlFlowGraph compute(StructuredGraph graph, boolean connectBlocks, boolean computeLoops, boolean computeDominators, boolean computePostdominators) {
         ControlFlowGraph cfg = new ControlFlowGraph(graph);
@@ -106,7 +106,7 @@
         return nodeToBlock.get(node);
     }
 
-    public Loop[] getLoops() {
+    public List<Loop<Block>> getLoops() {
         return loops;
     }
 
@@ -233,12 +233,12 @@
     }
 
     private void computeLoopInformation() {
-        ArrayList<Loop> loopsList = new ArrayList<>();
+        loops = new ArrayList<>();
         for (Block block : reversePostOrder) {
             Node beginNode = block.getBeginNode();
             if (beginNode instanceof LoopBeginNode) {
-                Loop loop = new Loop(block.getLoop(), loopsList.size(), block);
-                loopsList.add(loop);
+                Loop<Block> loop = new HIRLoop(block.getLoop(), loops.size(), block);
+                loops.add(loop);
 
                 LoopBeginNode loopBegin = (LoopBeginNode) beginNode;
                 for (LoopEndNode end : loopBegin.loopEnds()) {
@@ -269,10 +269,9 @@
                 }
             }
         }
-        loops = loopsList.toArray(new Loop[loopsList.size()]);
     }
 
-    private static void addBranchToLoop(Loop l, Block b) {
+    private static void addBranchToLoop(Loop<Block> l, Block b) {
         if (l.blocks.contains(b)) {
             return;
         }
@@ -283,7 +282,7 @@
         }
     }
 
-    private static void computeLoopBlocks(Block block, Loop loop) {
+    private static void computeLoopBlocks(Block block, Loop<Block> loop) {
         if (block.getLoop() == loop) {
             return;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/HIRLoop.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.cfg;
+
+import com.oracle.graal.nodes.*;
+
+public class HIRLoop extends Loop<Block> {
+
+    protected HIRLoop(Loop<Block> parent, int index, Block header) {
+        super(parent, index, header);
+    }
+
+    @Override
+    public long numBackedges() {
+        return ((LoopBeginNode) header.getBeginNode()).loopEnds().count();
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Loop.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Loop.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,20 +24,18 @@
 
 import java.util.*;
 
-import com.oracle.graal.nodes.*;
+public abstract class Loop<T extends AbstractBlock<T>> {
 
-public class Loop {
-
-    public final Loop parent;
-    public final List<Loop> children;
+    public final Loop<T> parent;
+    public final List<Loop<T>> children;
 
     public final int depth;
     public final int index;
-    public final Block header;
-    public final List<Block> blocks;
-    public final List<Block> exits;
+    public final T header;
+    public final List<T> blocks;
+    public final List<T> exits;
 
-    protected Loop(Loop parent, int index, Block header) {
+    protected Loop(Loop<T> parent, int index, T header) {
         this.parent = parent;
         if (parent != null) {
             this.depth = parent.depth + 1;
@@ -52,12 +50,10 @@
         this.exits = new ArrayList<>();
     }
 
+    public abstract long numBackedges();
+
     @Override
     public String toString() {
         return "loop " + index + " depth " + depth + (parent != null ? " outer " + parent.index : "");
     }
-
-    public LoopBeginNode loopBegin() {
-        return (LoopBeginNode) header.getBeginNode();
-    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AbstractWriteNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AbstractWriteNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,14 +27,15 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
-public abstract class AbstractWriteNode extends FixedAccessNode implements StateSplit, MemoryCheckpoint.Single, MemoryAccess {
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
+public abstract class AbstractWriteNode extends FixedAccessNode implements StateSplit, MemoryCheckpoint.Single, MemoryAccess, GuardingNode {
 
     @Input private ValueNode value;
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
+    @Input(InputType.Memory) private Node lastLocationAccess;
+
     private final boolean initialization;
 
-    @Input private Node lastLocationAccess;
-
     public FrameState stateAfter() {
         return stateAfter;
     }
@@ -73,6 +74,11 @@
     }
 
     @Override
+    public boolean isAllowedUsageType(InputType type) {
+        return (type == InputType.Guard && getNullCheck()) ? true : super.isAllowedUsageType(type);
+    }
+
+    @Override
     public LocationIdentity getLocationIdentity() {
         return location().getLocationIdentity();
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/Access.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/Access.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,8 @@
 
     ValueNode object();
 
-    LocationNode nullCheckLocation();
+    LocationNode accessLocation();
+
+    boolean canNullCheck();
 
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
     }
 
     private AddLocationNode(ValueNode x, ValueNode y) {
-        super(StampFactory.extension());
+        super(StampFactory.forVoid());
         this.x = x;
         this.y = y;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AnchoringNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.extended;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+
+public interface AnchoringNode extends NodeInterface {
+
+    ValueNode asNode();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BytecodeExceptionNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.extended;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * A node that represents an exception thrown implicitly by a Java bytecode. It can be lowered to
+ * either a {@linkplain ForeignCallDescriptor foreign} call or a pre-allocated exception object.
+ */
+public class BytecodeExceptionNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+
+    private final Class<? extends Throwable> exceptionClass;
+    @Input private final NodeInputList<ValueNode> arguments;
+    @Input private FrameState deoptState;
+
+    public BytecodeExceptionNode(MetaAccessProvider metaAccess, Class<? extends Throwable> exceptionClass, ValueNode... arguments) {
+        super(StampFactory.exactNonNull(metaAccess.lookupJavaType(exceptionClass)));
+        this.exceptionClass = exceptionClass;
+        this.arguments = new NodeInputList<>(this, arguments);
+    }
+
+    public Class<? extends Throwable> getExceptionClass() {
+        return exceptionClass;
+    }
+
+    @Override
+    public String toString(Verbosity verbosity) {
+        if (verbosity == Verbosity.Name) {
+            return super.toString(verbosity) + "#" + exceptionClass.getSimpleName();
+        }
+        return super.toString(verbosity);
+    }
+
+    public LocationIdentity getLocationIdentity() {
+        return LocationIdentity.ANY_LOCATION;
+    }
+
+    public void lower(LoweringTool tool) {
+        tool.getLowerer().lower(this, tool);
+    }
+
+    public NodeInputList<ValueNode> getArguments() {
+        return arguments;
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.extended;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
@@ -31,7 +32,7 @@
 public class ComputeAddressNode extends FloatingNode implements LIRLowerable {
 
     @Input private ValueNode object;
-    @Input private ValueNode location;
+    @Input(InputType.Association) private ValueNode location;
 
     public ValueNode getObject() {
         return object;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,7 +43,7 @@
     }
 
     private ConstantLocationNode(LocationIdentity identity, Kind kind, long displacement) {
-        super(StampFactory.extension());
+        super(StampFactory.forVoid());
         assert kind != Kind.Illegal && kind != Kind.Void;
         this.valueKind = kind;
         this.locationIdentity = identity;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/DeferredForeignCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.nodes.extended;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-
-/**
- * A node that will be lowered to a {@linkplain ForeignCallDescriptor foreign} call.
- */
-@NodeInfo(nameTemplate = "DeferredForeignCall#{p#descriptor/s}")
-public class DeferredForeignCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
-
-    @Input private final NodeInputList<ValueNode> arguments;
-    @Input private FrameState deoptState;
-
-    private final ForeignCallDescriptor descriptor;
-
-    public DeferredForeignCallNode(ForeignCallDescriptor descriptor, ValueNode... arguments) {
-        super(StampFactory.forKind(Kind.fromJavaClass(descriptor.getResultType())));
-        this.arguments = new NodeInputList<>(this, arguments);
-        this.descriptor = descriptor;
-    }
-
-    public ForeignCallDescriptor getDescriptor() {
-        return descriptor;
-    }
-
-    @Override
-    public String toString(Verbosity verbosity) {
-        if (verbosity == Verbosity.Name) {
-            return super.toString(verbosity) + "#" + descriptor;
-        }
-        return super.toString(verbosity);
-    }
-
-    public LocationIdentity getLocationIdentity() {
-        return LocationIdentity.ANY_LOCATION;
-    }
-
-    public void lower(LoweringTool tool) {
-        tool.getLowerer().lower(this, tool);
-    }
-
-    public NodeInputList<ValueNode> getArguments() {
-        return arguments;
-    }
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedAccessNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedAccessNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,19 +22,19 @@
  */
 package com.oracle.graal.nodes.extended;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
  * Accesses a value at an memory address specified by an {@linkplain #object object} and a
- * {@linkplain #nullCheckLocation() location}. The access does not include a null check on the
- * object.
+ * {@linkplain #accessLocation() location}. The access does not include a null check on the object.
  */
-public abstract class FixedAccessNode extends DeoptimizingFixedWithNextNode implements Access, GuardingNode {
+public abstract class FixedAccessNode extends DeoptimizingFixedWithNextNode implements Access {
 
-    @Input private GuardingNode guard;
+    @Input(InputType.Guard) private GuardingNode guard;
     @Input private ValueNode object;
-    @Input private ValueNode location;
+    @Input(InputType.Association) private ValueNode location;
     private boolean nullCheck;
     private BarrierType barrierType;
     private boolean compressible;
@@ -52,7 +52,7 @@
         return (LocationNode) location;
     }
 
-    public LocationNode nullCheckLocation() {
+    public LocationNode accessLocation() {
         return (LocationNode) location;
     }
 
@@ -93,7 +93,7 @@
 
     @Override
     public void setGuard(GuardingNode guard) {
-        updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+        updateUsagesInterface(this.guard, guard);
         this.guard = guard;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingAccessNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingAccessNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,13 +23,14 @@
 package com.oracle.graal.nodes.extended;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
 
 public abstract class FloatingAccessNode extends FloatingGuardedNode implements Access, MemoryAccess {
 
     @Input private ValueNode object;
-    @Input private LocationNode location;
+    @Input(InputType.Association) private LocationNode location;
     private BarrierType barrierType;
     private boolean compressible;
 
@@ -41,7 +42,7 @@
         return location;
     }
 
-    public LocationNode nullCheckLocation() {
+    public LocationNode accessLocation() {
         return location;
     }
 
@@ -73,5 +74,9 @@
         return compressible;
     }
 
+    public boolean canNullCheck() {
+        return true;
+    }
+
     public abstract FixedAccessNode asFixedNode();
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -35,7 +35,7 @@
  */
 public final class FloatingReadNode extends FloatingAccessNode implements IterableNodeType, LIRLowerable, Canonicalizable {
 
-    @Input private MemoryNode lastLocationAccess;
+    @Input(InputType.Memory) private MemoryNode lastLocationAccess;
 
     public FloatingReadNode(ValueNode object, LocationNode location, MemoryNode lastLocationAccess, Stamp stamp) {
         this(object, location, lastLocationAccess, stamp, null, BarrierType.NONE, false);
@@ -69,14 +69,14 @@
     @Override
     public Node canonical(CanonicalizerTool tool) {
         if (object() instanceof PiNode && ((PiNode) object()).getGuard() == getGuard()) {
-            return graph().unique(new FloatingReadNode(((PiNode) object()).getOriginalValue(), location(), getLastLocationAccess(), stamp(), getGuard(), getBarrierType(), isCompressible()));
+            return graph().unique(new FloatingReadNode(((PiNode) object()).getOriginalNode(), location(), getLastLocationAccess(), stamp(), getGuard(), getBarrierType(), isCompressible()));
         }
         return ReadNode.canonicalizeRead(this, location(), object(), tool, isCompressible());
     }
 
     @Override
     public FixedAccessNode asFixedNode() {
-        return graph().add(new ReadNode(object(), nullCheckLocation(), stamp(), getGuard(), getBarrierType(), isCompressible()));
+        return graph().add(new ReadNode(object(), accessLocation(), stamp(), getGuard(), getBarrierType(), isCompressible()));
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ForeignCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,12 +34,12 @@
 /**
  * Node for a {@linkplain ForeignCallDescriptor foreign} call.
  */
-@NodeInfo(nameTemplate = "ForeignCall#{p#descriptor/s}")
+@NodeInfo(nameTemplate = "ForeignCall#{p#descriptor/s}", allowedUsageTypes = {InputType.Memory})
 public class ForeignCallNode extends AbstractMemoryCheckpoint implements LIRLowerable, DeoptimizingNode.DeoptDuring, MemoryCheckpoint.Multi {
 
     @Input private final NodeInputList<ValueNode> arguments;
+    @Input(InputType.State) private FrameState stateDuring;
     private final ForeignCallsProvider foreignCalls;
-    @Input private FrameState stateDuring;
 
     private final ForeignCallDescriptor descriptor;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GuardingNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/GuardingNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,10 @@
  */
 package com.oracle.graal.nodes.extended;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 
-public interface GuardingNode {
+public interface GuardingNode extends NodeInterface {
 
     ValueNode asNode();
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -66,7 +66,7 @@
     }
 
     public IndexedLocationNode(LocationIdentity identity, Kind kind, long displacement, ValueNode index, int indexScaling) {
-        super(StampFactory.extension());
+        super(StampFactory.forVoid());
         assert kind != Kind.Illegal && kind != Kind.Void;
         this.valueKind = kind;
         this.locationIdentity = identity;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/JavaReadNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/JavaReadNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,7 @@
  * Read a raw memory location according to Java field or array read semantics. It will perform read
  * barriers, implicit conversions and optionally oop uncompression.
  */
-public final class JavaReadNode extends FixedAccessNode implements Lowerable {
+public final class JavaReadNode extends FixedAccessNode implements Lowerable, GuardingNode {
 
     public JavaReadNode(ValueNode object, LocationNode location, BarrierType barrierType, boolean compressible) {
         super(object, location, StampFactory.forKind(location.getValueKind()), barrierType, compressible);
@@ -39,4 +39,8 @@
     public void lower(LoweringTool tool) {
         tool.getLowerer().lower(this, tool);
     }
+
+    public boolean canNullCheck() {
+        return true;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/JavaWriteNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/JavaWriteNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,4 +38,8 @@
     public void lower(LoweringTool tool) {
         tool.getLowerer().lower(this, tool);
     }
+
+    public boolean canNullCheck() {
+        return true;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -42,9 +42,15 @@
         return object;
     }
 
+    public LoadHubNode(ValueNode object, Kind kind) {
+        super(getKind(kind), null);
+        this.object = object;
+    }
+
     public LoadHubNode(ValueNode object, Kind kind, ValueNode guard) {
-        super(getKind(kind), asGuard(guard));
+        super(getKind(kind), (GuardingNode) guard);
         assert object != guard;
+        assert guard != null;
         this.object = object;
     }
 
@@ -52,13 +58,6 @@
         return kind == Kind.Object ? StampFactory.objectNonNull() : StampFactory.forKind(kind);
     }
 
-    private static GuardingNode asGuard(ValueNode guard) {
-        if (guard instanceof GuardingNode) {
-            return (GuardingNode) guard;
-        }
-        return null;
-    }
-
     @Override
     public void lower(LoweringTool tool) {
         tool.getLowerer().lower(this, tool);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.extended;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Node.ValueNumberable;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
@@ -33,6 +34,7 @@
  * locations have the form [base + location], where base is a node and location is defined by
  * subclasses of the {@link LocationNode}.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public abstract class LocationNode extends FloatingNode implements LIRLowerable, ValueNumberable {
 
     /**
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/MembarNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,6 +38,7 @@
 /**
  * Creates a memory barrier.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class MembarNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Single {
 
     private final int barriers;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/NullCheckNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/NullCheckNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,12 +26,12 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-public class NullCheckNode extends DeoptimizingFixedWithNextNode implements LIRLowerable, GuardingNode {
+public class NullCheckNode extends DeoptimizingFixedWithNextNode implements LIRLowerable {
 
     @Input private ValueNode object;
 
     public NullCheckNode(ValueNode object) {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
         this.object = object;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,7 @@
 /**
  * Reads an {@linkplain FixedAccessNode accessed} value.
  */
-public final class ReadNode extends FloatableAccessNode implements LIRLowerable, Canonicalizable, PiPushable, Virtualizable {
+public final class ReadNode extends FloatableAccessNode implements LIRLowerable, Canonicalizable, PiPushable, Virtualizable, GuardingNode {
 
     public ReadNode(ValueNode object, ValueNode location, Stamp stamp, BarrierType barrierType, boolean compressible) {
         super(object, location, stamp, barrierType, compressible);
@@ -62,7 +62,10 @@
     @Override
     public Node canonical(CanonicalizerTool tool) {
         if (object() instanceof PiNode && ((PiNode) object()).getGuard() == getGuard()) {
-            return graph().add(new ReadNode(((PiNode) object()).getOriginalValue(), location(), stamp(), getGuard(), getBarrierType(), isCompressible()));
+            ReadNode readNode = graph().add(new ReadNode(((PiNode) object()).getOriginalNode(), location(), stamp(), getGuard(), getBarrierType(), isCompressible()));
+            readNode.setNullCheck(getNullCheck());
+            readNode.setStateBefore(stateBefore());
+            return readNode;
         }
         return canonicalizeRead(this, location(), object(), tool, isCompressible());
     }
@@ -72,6 +75,11 @@
         return graph().unique(new FloatingReadNode(object(), location(), lastLocationAccess, stamp(), getGuard(), getBarrierType(), isCompressible()));
     }
 
+    @Override
+    public boolean isAllowedUsageType(InputType type) {
+        return (getNullCheck() && type == InputType.Guard) ? true : super.isAllowedUsageType(type);
+    }
+
     public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool, boolean compressible) {
         MetaAccessProvider metaAccess = tool.getMetaAccess();
         if (read.usages().isEmpty()) {
@@ -85,26 +93,22 @@
             }
         }
         if (tool.canonicalizeReads()) {
-            if (metaAccess != null && object != null && object.isConstant()) {
+            if (metaAccess != null && object != null && object.isConstant() && !compressible) {
                 if ((location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION || location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION) &&
                                 location instanceof ConstantLocationNode) {
                     long displacement = ((ConstantLocationNode) location).getDisplacement();
-                    Kind kind = location.getValueKind();
-                    if (object.getKind() == Kind.Object) {
-                        Object base = object.asConstant().asObject();
-                        if (base != null) {
-                            Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, base, displacement, compressible);
-                            if (constant != null) {
-                                return ConstantNode.forConstant(constant, metaAccess, read.graph());
-                            }
+                    Constant base = object.asConstant();
+                    if (base != null) {
+                        Constant constant;
+                        if (read.stamp() instanceof PrimitiveStamp) {
+                            PrimitiveStamp stamp = (PrimitiveStamp) read.stamp();
+                            constant = tool.getConstantReflection().readRawConstant(stamp.getStackKind(), base, displacement, stamp.getBits());
+                        } else {
+                            assert read.stamp() instanceof ObjectStamp;
+                            constant = tool.getConstantReflection().readUnsafeConstant(Kind.Object, base, displacement);
                         }
-                    } else if (object.getKind().isNumericInteger()) {
-                        long base = object.asConstant().asLong();
-                        if (base != 0L) {
-                            Constant constant = tool.getConstantReflection().readUnsafeConstant(kind, null, base + displacement, compressible);
-                            if (constant != null) {
-                                return ConstantNode.forConstant(constant, metaAccess, read.graph());
-                            }
+                        if (constant != null) {
+                            return ConstantNode.forConstant(read.stamp(), constant, metaAccess, read.graph());
                         }
                     }
                 }
@@ -164,4 +168,8 @@
             }
         }
     }
+
+    public boolean canNullCheck() {
+        return true;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SnippetLocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.nodes.extended;
-
-import static com.oracle.graal.api.meta.LocationIdentity.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-
-/**
- * Location node that can be used inside a snippet without having the elements (including the
- * location identity and kind) as a snippet constant. Can represent locations in the form of [base +
- * index * scale + disp]. When the location is created, all elements (base, index, scale, disp) are
- * nodes. Both scale and disp must eventually canonicalize to {@link ConstantNode constants} so that
- * this node can be canonicalized to a {@link IndexedLocationNode} or {@link ConstantLocationNode}.
- */
-public final class SnippetLocationNode extends LocationNode implements Canonicalizable {
-
-    @Input private ValueNode valueKind;
-    @Input private ValueNode locationIdentity;
-    @Input private ValueNode displacement;
-    @Input private ValueNode index;
-    @Input private ValueNode indexScaling;
-
-    public static SnippetLocationNode create(ValueNode identity, ValueNode kind, ValueNode displacement, ValueNode index, ValueNode indexScaling, Graph graph) {
-        return graph.unique(new SnippetLocationNode(identity, kind, displacement, index, indexScaling));
-    }
-
-    private SnippetLocationNode(ValueNode locationIdentity, ValueNode kind, ValueNode displacement) {
-        this(locationIdentity, kind, displacement, null, null);
-    }
-
-    private SnippetLocationNode(ValueNode locationIdentity, ValueNode kind, ValueNode displacement, ValueNode index, ValueNode indexScaling) {
-        super(StampFactory.object());
-        this.valueKind = kind;
-        this.locationIdentity = locationIdentity;
-        this.displacement = displacement;
-        this.index = index;
-        this.indexScaling = indexScaling;
-    }
-
-    @Override
-    public Kind getValueKind() {
-        if (valueKind.isConstant()) {
-            return (Kind) valueKind.asConstant().asObject();
-        }
-        throw new GraalInternalError("Cannot access kind yet because it is not constant: " + valueKind);
-    }
-
-    @Override
-    public LocationIdentity getLocationIdentity() {
-        if (locationIdentity.isConstant()) {
-            return (LocationIdentity) locationIdentity.asConstant().asObject();
-        }
-        // We do not know our actual location identity yet, so be conservative.
-        return ANY_LOCATION;
-    }
-
-    @Override
-    public Node canonical(CanonicalizerTool tool) {
-        if (valueKind.isConstant() && locationIdentity.isConstant() && displacement.isConstant() && (indexScaling == null || indexScaling.isConstant())) {
-            Kind constKind = (Kind) valueKind.asConstant().asObject();
-            LocationIdentity constLocation = (LocationIdentity) locationIdentity.asConstant().asObject();
-            long constDisplacement = displacement.asConstant().asLong();
-            int constIndexScaling = indexScaling == null ? 0 : indexScaling.asConstant().asInt();
-
-            if (index == null || constIndexScaling == 0) {
-                return ConstantLocationNode.create(constLocation, constKind, constDisplacement, graph());
-            } else if (index.isConstant()) {
-                return ConstantLocationNode.create(constLocation, constKind, index.asConstant().asLong() * constIndexScaling + constDisplacement, graph());
-            } else {
-                return IndexedLocationNode.create(constLocation, constKind, constDisplacement, index, graph(), constIndexScaling);
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public Value generateAddress(NodeMappableLIRBuilder builder, LIRGeneratorTool gen, Value base) {
-        throw new GraalInternalError("locationIdentity must be a constant so that this node can be canonicalized: " + locationIdentity);
-    }
-
-    @NodeIntrinsic
-    public static native Location constantLocation(LocationIdentity identity, Kind kind, long displacement);
-
-    @NodeIntrinsic
-    public static native Location indexedLocation(LocationIdentity identity, Kind kind, long displacement, int index, int indexScaling);
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -70,28 +70,9 @@
     public Node canonical(CanonicalizerTool tool) {
         if (value.isConstant()) {
             Constant constant = value.asConstant();
-            Object o = constant.asObject();
-            if (o != null) {
-                switch (boxingKind) {
-                    case Boolean:
-                        return ConstantNode.forBoolean((Boolean) o, graph());
-                    case Byte:
-                        return ConstantNode.forByte((Byte) o, graph());
-                    case Char:
-                        return ConstantNode.forChar((Character) o, graph());
-                    case Short:
-                        return ConstantNode.forShort((Short) o, graph());
-                    case Int:
-                        return ConstantNode.forInt((Integer) o, graph());
-                    case Long:
-                        return ConstantNode.forLong((Long) o, graph());
-                    case Float:
-                        return ConstantNode.forFloat((Float) o, graph());
-                    case Double:
-                        return ConstantNode.forDouble((Double) o, graph());
-                    default:
-                        ValueNodeUtil.shouldNotReachHere();
-                }
+            Constant unboxed = tool.getConstantReflection().unboxPrimitive(constant);
+            if (unboxed != null && unboxed.getKind() == boxingKind) {
+                return ConstantNode.forConstant(unboxed, tool.getMetaAccess(), graph());
             }
         } else if (value instanceof BoxNode) {
             BoxNode box = (BoxNode) value;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -78,8 +78,20 @@
                 }
             }
         }
+        // Temporarily disable this as it appears to break truffle.
+        // ResolvedJavaType receiverType = ObjectStamp.typeOrNull(object());
+        // if (receiverType != null && receiverType.isArray()) {
+        // LocationIdentity identity =
+        // NamedLocationIdentity.getArrayLocation(receiverType.getComponentType().getKind());
+        // // Try to build a better location node
+        // ValueNode location = offset();
+        // return cloneAsArrayAccess(location, identity);
+        // }
+
         return this;
     }
 
     protected abstract ValueNode cloneAsFieldAccess(ResolvedJavaField field);
+
+    protected abstract ValueNode cloneAsArrayAccess(ValueNode location, LocationIdentity identity);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,35 +54,26 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 
     @Override
+    public boolean inferStamp() {
+        if (stamp() instanceof ObjectStamp && object.stamp() instanceof ObjectStamp) {
+            return updateStamp(((ObjectStamp) object.stamp()).castTo((ObjectStamp) stamp()));
+        }
+        return updateStamp(object.stamp().join(stamp()));
+    }
+
+    @Override
     public Node canonical(CanonicalizerTool tool) {
         assert getKind() == Kind.Object && object.getKind() == Kind.Object;
-
-        ObjectStamp my = (ObjectStamp) stamp();
-        ObjectStamp other = (ObjectStamp) object.stamp();
-
-        if (my.type() == null || other.type() == null) {
-            return this;
-        }
-        if (my.isExactType() && !other.isExactType()) {
+        if (stamp().equals(object.stamp())) {
+            return object;
+        } else {
             return this;
         }
-        if (my.nonNull() && !other.nonNull()) {
-            return this;
-        }
-        if (!my.type().isAssignableFrom(other.type())) {
-            return this;
-        }
-        /*
-         * The unsafe cast does not add any new type information, so it can be removed. Note that
-         * this means that the unsafe cast cannot be used to "drop" type information (in which case
-         * it must not be canonicalized in any case).
-         */
-        return object;
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.graph.UnsafeAccess.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
@@ -35,7 +36,7 @@
  * performed before the load.
  */
 public class UnsafeLoadNode extends UnsafeAccessNode implements Lowerable, Virtualizable {
-    @Input private LogicNode guardingCondition;
+    @Input(InputType.Condition) private LogicNode guardingCondition;
 
     public UnsafeLoadNode(ValueNode object, ValueNode offset, Kind accessKind, LocationIdentity locationIdentity) {
         this(object, offset, accessKind, locationIdentity, null);
@@ -78,6 +79,11 @@
         return this.graph().add(new LoadFieldNode(object(), field));
     }
 
+    @Override
+    protected ValueNode cloneAsArrayAccess(ValueNode location, LocationIdentity identity) {
+        return this.graph().add(new UnsafeLoadNode(object(), location, accessKind(), identity));
+    }
+
     @SuppressWarnings({"unchecked", "unused"})
     @NodeIntrinsic
     public static <T> T load(Object object, long offset, @ConstantNodeParameter Kind kind, @ConstantNodeParameter LocationIdentity locationIdentity) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.graph.UnsafeAccess.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
@@ -37,7 +38,7 @@
 public class UnsafeStoreNode extends UnsafeAccessNode implements StateSplit, Lowerable, Virtualizable, MemoryCheckpoint.Single {
 
     @Input private ValueNode value;
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public UnsafeStoreNode(ValueNode object, ValueNode offset, ValueNode value, Kind accessKind, LocationIdentity locationIdentity) {
         super(StampFactory.forVoid(), object, offset, accessKind, locationIdentity);
@@ -107,6 +108,11 @@
         return storeFieldNode;
     }
 
+    @Override
+    protected ValueNode cloneAsArrayAccess(ValueNode location, LocationIdentity identity) {
+        return this.graph().add(new UnsafeStoreNode(object(), location, value, accessKind(), identity));
+    }
+
     public FrameState getState() {
         return stateAfter;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.nodes.extended;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
@@ -32,12 +33,13 @@
 /**
  * The ValueAnchor instruction keeps non-CFG (floating) nodes above a certain point in the graph.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Anchor, InputType.Guard})
 public final class ValueAnchorNode extends FixedWithNextNode implements LIRLowerable, Simplifiable, Virtualizable, GuardingNode {
 
-    @Input private ValueNode anchored;
+    @Input(InputType.Guard) private ValueNode anchored;
 
     public ValueAnchorNode(ValueNode value) {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
         this.anchored = value;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -60,7 +60,7 @@
     @Override
     public void simplify(SimplifierTool tool) {
         if (object() instanceof PiNode && ((PiNode) object()).getGuard() == getGuard()) {
-            setObject(((PiNode) object()).getOriginalValue());
+            setObject(((PiNode) object()).getOriginalNode());
         }
     }
 
@@ -82,4 +82,8 @@
             }
         }
     }
+
+    public boolean canNullCheck() {
+        return true;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,7 +40,7 @@
 
     /**
      * Constructs a new AbstractNewObjectNode.
-     * 
+     *
      * @param stamp the stamp of the newly created object
      * @param fillContents determines if the object's contents should be initialized to zero/null.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessMonitorNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AccessMonitorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.java;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.type.*;
@@ -33,11 +34,12 @@
  * The Java bytecode specification allows non-balanced locking. Graal does not handle such cases and
  * throws a {@link BailoutException} instead during graph building.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public abstract class AccessMonitorNode extends AbstractMemoryCheckpoint implements MemoryCheckpoint, DeoptimizingNode.DeoptBefore, DeoptimizingNode.DeoptAfter {
 
-    @Input private FrameState stateBefore;
+    @Input(InputType.State) private FrameState stateBefore;
     @Input private ValueNode object;
-    @Input private MonitorIdNode monitorId;
+    @Input(InputType.Association) private MonitorIdNode monitorId;
 
     @Override
     public boolean canDeoptimize() {
@@ -64,7 +66,7 @@
 
     /**
      * Creates a new AccessMonitor instruction.
-     * 
+     *
      * @param object the instruction producing the object
      */
     public AccessMonitorNode(ValueNode object, MonitorIdNode monitorId) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -56,10 +56,10 @@
 
     /**
      * Gets the length of an array if possible.
-     * 
+     *
      * @param graph TODO
      * @param array an array
-     * 
+     *
      * @return a node representing the length of {@code array} or null if it is not available
      */
     public static ValueNode readArrayLength(StructuredGraph graph, ValueNode array, ConstantReflectionProvider constantReflection) {
@@ -72,7 +72,7 @@
         if (constantReflection != null && array.isConstant() && !array.isNullConstant()) {
             Constant constantValue = array.asConstant();
             if (constantValue != null && constantValue.isNonNull()) {
-                Integer constantLength = constantReflection.lookupArrayLength(constantValue);
+                Integer constantLength = constantReflection.readArrayLength(constantValue);
                 if (constantLength != null) {
                     return ConstantNode.forInt(constantLength, graph);
                 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -76,10 +76,11 @@
         if (ObjectStamp.isObjectAlwaysNull(object())) {
             return object();
         }
-        if (hub.isConstant() && hub.asConstant().getKind() == Kind.Object && hub.asConstant().asObject() instanceof Class) {
-            Class clazz = (Class) hub.asConstant().asObject();
-            ResolvedJavaType t = tool.getMetaAccess().lookupJavaType(clazz);
-            return graph().add(new CheckCastNode(t, object(), null, forStoreCheck));
+        if (hub.isConstant()) {
+            ResolvedJavaType t = tool.getConstantReflection().asJavaType(hub.asConstant());
+            if (t != null) {
+                return graph().add(new CheckCastNode(t, object(), null, forStoreCheck));
+            }
         }
         return this;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -52,7 +52,7 @@
 
     /**
      * Creates a new CheckCast instruction.
-     * 
+     *
      * @param type the type being cast to
      * @param object the instruction producing the object
      */
@@ -71,26 +71,26 @@
 
     /**
      * Lowers a {@link CheckCastNode} to a {@link GuardingPiNode}. That is:
-     * 
+     *
      * <pre>
      * 1: A a = ...
      * 2: B b = (B) a;
      * </pre>
-     * 
+     *
      * is lowered to:
-     * 
+     *
      * <pre>
      * 1: A a = ...
      * 2: B b = guardingPi(a == null || a instanceof B, a, stamp(B))
      * </pre>
-     * 
+     *
      * or if a is known to be non-null:
-     * 
+     *
      * <pre>
      * 1: A a = ...
      * 2: B b = guardingPi(a instanceof B, a, stamp(B, non-null))
      * </pre>
-     * 
+     *
      * Note: we use {@link Graph#addWithoutUnique} as opposed to {@link Graph#unique} for the new
      * {@link InstanceOfNode} to maintain the invariant checked by
      * {@code LoweringPhase.checkUsagesAreScheduled()}.
@@ -201,7 +201,7 @@
     }
 
     @Override
-    public ValueNode getOriginalValue() {
+    public ValueNode getOriginalNode() {
         return object;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.graph.UnsafeAccess.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
@@ -34,12 +35,15 @@
  * Represents an atomic compare-and-swap operation The result is a boolean that contains whether the
  * value matched the expected value.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
 public class CompareAndSwapNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     @Input private ValueNode object;
     @Input private ValueNode offset;
     @Input private ValueNode expected;
     @Input private ValueNode newValue;
+
+    private final Kind valueKind;
     private final int displacement;
 
     public ValueNode object() {
@@ -62,7 +66,11 @@
         return displacement;
     }
 
-    public CompareAndSwapNode(ValueNode object, int displacement, ValueNode offset, ValueNode expected, ValueNode newValue) {
+    public Kind getValueKind() {
+        return valueKind;
+    }
+
+    public CompareAndSwapNode(ValueNode object, int displacement, ValueNode offset, ValueNode expected, ValueNode newValue, Kind valueKind) {
         super(StampFactory.forKind(Kind.Boolean.getStackKind()));
         assert expected.stamp().isCompatible(newValue.stamp());
         this.object = object;
@@ -70,6 +78,7 @@
         this.expected = expected;
         this.newValue = newValue;
         this.displacement = displacement;
+        this.valueKind = valueKind;
     }
 
     @Override
@@ -84,17 +93,20 @@
 
     // specialized on value type until boxing/unboxing is sorted out in intrinsification
     @NodeIntrinsic
-    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, Object expected, Object newValue) {
+    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, Object expected, Object newValue,
+                    @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind) {
         return unsafe.compareAndSwapObject(object, displacement + offset, expected, newValue);
     }
 
     @NodeIntrinsic
-    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, long expected, long newValue) {
+    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, long expected, long newValue,
+                    @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind) {
         return unsafe.compareAndSwapLong(object, displacement + offset, expected, newValue);
     }
 
     @NodeIntrinsic
-    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, int expected, int newValue) {
+    public static boolean compareAndSwap(Object object, @ConstantNodeParameter int displacement, long offset, int expected, int newValue,
+                    @SuppressWarnings("unused") @ConstantNodeParameter Kind valueKind) {
         return unsafe.compareAndSwapInt(object, displacement + offset, expected, newValue);
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,9 +55,8 @@
     @Override
     public void simplify(SimplifierTool tool) {
         if (isAlive() && elementType.isConstant()) {
-            Class<?> elementClass = (Class<?>) elementType.asConstant().asObject();
-            if (elementClass != null && !(elementClass.equals(void.class))) {
-                ResolvedJavaType javaType = tool.getMetaAccess().lookupJavaType(elementClass);
+            ResolvedJavaType javaType = tool.getConstantReflection().asJavaType(elementType.asConstant());
+            if (javaType != null && !javaType.equals(tool.getMetaAccess().lookupJavaType(void.class))) {
                 NewArrayNode newArray = graph().add(new NewArrayNode(javaType, length(), fillContents()));
                 List<Node> snapshot = inputs().snapshot();
                 graph().replaceFixedWithFixed(this, newArray);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,13 +40,9 @@
     @Override
     public Node canonical(CanonicalizerTool tool) {
         if (clazz.isConstant()) {
-            Constant clazzConstant = clazz.asConstant();
-            if (clazzConstant.getKind() == Kind.Object && clazzConstant.asObject() instanceof Class) {
-                Class staticClass = (Class) clazzConstant.asObject();
-                ResolvedJavaType type = tool.getMetaAccess().lookupJavaType(staticClass);
-                if (type.isInitialized()) {
-                    return graph().add(new NewInstanceNode(type, fillContents()));
-                }
+            ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant());
+            if (type != null && type.isInitialized()) {
+                return graph().add(new NewInstanceNode(type, fillContents()));
             }
         }
         return this;
@@ -57,5 +53,5 @@
     }
 
     @NodeIntrinsic
-    public static native Object allocateInstance(Class clazz, @ConstantNodeParameter boolean fillContents);
+    public static native Object allocateInstance(Class<?> clazz, @ConstantNodeParameter boolean fillContents);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfDynamicNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -60,12 +60,13 @@
     public Node canonical(CanonicalizerTool tool) {
         assert object() != null : this;
         if (mirror().isConstant()) {
-            Class clazz = (Class) mirror().asConstant().asObject();
-            ResolvedJavaType t = tool.getMetaAccess().lookupJavaType(clazz);
-            if (t.isPrimitive()) {
-                return LogicConstantNode.contradiction(graph());
-            } else {
-                return graph().unique(new InstanceOfNode(t, object(), null));
+            ResolvedJavaType t = tool.getConstantReflection().asJavaType(mirror().asConstant());
+            if (t != null) {
+                if (t.isPrimitive()) {
+                    return LogicConstantNode.contradiction(graph());
+                } else {
+                    return graph().unique(new InstanceOfNode(t, object(), null));
+                }
             }
         }
         return this;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,7 +41,7 @@
 
     /**
      * Creates a new LoadFieldNode instance.
-     * 
+     *
      * @param object the receiver object
      * @param field the compiler interface field
      */
@@ -97,7 +97,7 @@
     }
 
     private PhiNode asPhi(MetaAccessProvider metaAccess) {
-        if (!isStatic() && Modifier.isFinal(field.getModifiers()) && object() instanceof PhiNode && ((PhiNode) object()).values().filter(NodePredicates.isNotA(ConstantNode.class)).isEmpty()) {
+        if (!isStatic() && Modifier.isFinal(field.getModifiers()) && object() instanceof ValuePhiNode && ((ValuePhiNode) object()).values().filter(NodePredicates.isNotA(ConstantNode.class)).isEmpty()) {
             PhiNode phi = (PhiNode) object();
             Constant[] constants = new Constant[phi.valueCount()];
             for (int i = 0; i < phi.valueCount(); i++) {
@@ -107,7 +107,7 @@
                 }
                 constants[i] = constantValue;
             }
-            PhiNode newPhi = graph().addWithoutUnique(new PhiNode(stamp(), phi.merge()));
+            PhiNode newPhi = graph().addWithoutUnique(new ValuePhiNode(stamp(), phi.merge()));
             for (int i = 0; i < phi.valueCount(); i++) {
                 newPhi.addInput(ConstantNode.forConstant(constants[i], metaAccess, graph()));
             }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadIndexedNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadIndexedNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,7 +34,7 @@
 
     /**
      * Creates a new LoadIndexedNode.
-     * 
+     *
      * @param array the instruction producing the array
      * @param index the instruction producing the index
      * @param elementKind the element type
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoweredCompareAndSwapNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.java;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
@@ -31,11 +32,12 @@
 /**
  * Represents the lowered version of an atomic compare-and-swap operation{@code CompareAndSwapNode}.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Value, InputType.Memory})
 public class LoweredCompareAndSwapNode extends FixedAccessNode implements StateSplit, LIRLowerable, MemoryCheckpoint.Single {
 
     @Input private ValueNode expectedValue;
     @Input private ValueNode newValue;
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public FrameState stateAfter() {
         return stateAfter;
@@ -71,9 +73,16 @@
         return location().getLocationIdentity();
     }
 
+    public boolean canNullCheck() {
+        return false;
+    }
+
     @Override
     public void generate(NodeLIRBuilderTool gen) {
-        gen.visitCompareAndSwap(this, location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object())));
+        assert getNewValue().stamp().isCompatible(getExpectedValue().stamp());
+        Value address = location().generateAddress(gen, gen.getLIRGeneratorTool(), gen.operand(object()));
+        Value result = gen.getLIRGeneratorTool().emitCompareAndSwap(address, gen.operand(getExpectedValue()), gen.operand(getNewValue()), Constant.INT_1, Constant.INT_0);
+        gen.setResult(this, result);
     }
 
     public MemoryCheckpoint asMemoryCheckpoint() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,7 +55,7 @@
 
     /**
      * Gets the target method for this invocation instruction.
-     * 
+     *
      * @return the target method
      */
     public ResolvedJavaMethod targetMethod() {
@@ -76,7 +76,7 @@
 
     /**
      * Gets the instruction that produces the receiver object for this invocation, if any.
-     * 
+     *
      * @return the instruction that produces the receiver object for this invocation if any,
      *         {@code null} if this invocation does not take a receiver object
      */
@@ -86,7 +86,7 @@
 
     /**
      * Checks whether this is an invocation of a static method.
-     * 
+     *
      * @return {@code true} if the invocation is a static invocation
      */
     public boolean isStatic() {
@@ -138,18 +138,17 @@
                 return this;
             }
 
-            // check if the exact type of the receiver can be determined
+            assert targetMethod.getDeclaringClass().asExactType() == null : "should have been handled by canBeStaticallyBound";
+
+            // check if the type of the receiver can narrow the result
             ValueNode receiver = receiver();
-            ResolvedJavaType exact = targetMethod.getDeclaringClass().asExactType();
-            if (exact == null && ObjectStamp.isExactType(receiver)) {
-                exact = ObjectStamp.typeOrNull(receiver);
-            }
-            if (exact != null) {
+            ResolvedJavaType type = ObjectStamp.typeOrNull(receiver);
+            if (type != null) {
                 // either the holder class is exact, or the receiver object has an exact type
-                ResolvedJavaMethod exactMethod = exact.resolveMethod(targetMethod);
-                if (exactMethod != null) {
+                ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod);
+                if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || ObjectStamp.isExactType(receiver))) {
                     invokeKind = InvokeKind.Special;
-                    targetMethod = exactMethod;
+                    targetMethod = resolvedMethod;
                     return this;
                 }
             }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorIdNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorIdNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,12 +32,13 @@
  * states together. It is thus referenced from the {@link MonitorEnterNode}, from the
  * {@link MonitorExitNode} and from the {@link FrameState}.
  */
+@NodeInfo(allowedUsageTypes = {InputType.Association})
 public class MonitorIdNode extends ValueNode implements IterableNodeType, LIRLowerable {
 
     private int lockDepth;
 
     public MonitorIdNode(int lockDepth) {
-        super(StampFactory.dependency());
+        super(StampFactory.forVoid());
         this.lockDepth = lockDepth;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -50,7 +50,7 @@
 
     /**
      * Constructs a new NewMultiArrayNode.
-     * 
+     *
      * @param type the element type of the array
      * @param dimensions the node which produce the dimensions for this array
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
 
     public static final ForeignCallDescriptor REGISTER_FINALIZER = new ForeignCallDescriptor("registerFinalizer", void.class, Object.class);
 
-    @Input private FrameState deoptState;
+    @Input(InputType.State) private FrameState deoptState;
     @Input private ValueNode object;
 
     public ValueNode object() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,16 +22,12 @@
  */
 package com.oracle.graal.nodes.java;
 
-import java.lang.reflect.Modifier;
+import java.lang.reflect.*;
 
-import com.oracle.graal.api.meta.JavaType;
-import com.oracle.graal.api.meta.ResolvedJavaMethod;
-import com.oracle.graal.graph.GraalInternalError;
-import com.oracle.graal.graph.NodeInputList;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.NodeLIRBuilderTool;
-import com.oracle.graal.nodes.spi.Lowerable;
-import com.oracle.graal.nodes.spi.LoweringTool;
+import com.oracle.graal.nodes.spi.*;
 
 /**
  * A SelfReplacingMethodCallTargetNode replaces itself in the graph when being lowered with a
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/StoreFieldNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/StoreFieldNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 public final class StoreFieldNode extends AccessFieldNode implements StateSplit, VirtualizableRoot {
 
     @Input private ValueNode value;
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public FrameState stateAfter() {
         return stateAfter;
@@ -58,7 +58,7 @@
 
     /**
      * Creates a new StoreFieldNode.
-     * 
+     *
      * @param object the receiver object
      * @param field the compiler interface field
      * @param value the node representing the value to store to the field
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/StoreIndexedNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/StoreIndexedNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.nodes.java;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
@@ -33,7 +34,7 @@
 public final class StoreIndexedNode extends AccessIndexedNode implements StateSplit, Lowerable, Virtualizable {
 
     @Input private ValueNode value;
-    @Input(notDataflow = true) private FrameState stateAfter;
+    @Input(InputType.State) private FrameState stateAfter;
 
     public FrameState stateAfter() {
         return stateAfter;
@@ -55,7 +56,7 @@
 
     /**
      * Creates a new StoreIndexedNode.
-     * 
+     *
      * @param array the node producing the array
      * @param index the node producing the index
      * @param elementKind the element type
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,7 +25,7 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.meta.ResolvedJavaType.*;
+import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,6 +41,8 @@
 
     void emitStore(PlatformKind kind, Value address, Value input, Access access);
 
+    Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue);
+
     void emitDeoptimize(Value actionAndReason, Value failedSpeculation, DeoptimizingNode deopting);
 
     Value emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -52,7 +52,7 @@
      */
     FixedWithNextNode lastFixedNode();
 
-    GuardingNode getCurrentGuardAnchor();
+    AnchoringNode getCurrentGuardAnchor();
 
     /**
      * Marker interface lowering stages.
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryProxy.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/MemoryProxy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,7 +25,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.extended.*;
 
-public interface MemoryProxy extends ValueProxy, MemoryNode {
+public interface MemoryProxy extends Proxy, MemoryNode {
 
     LocationIdentity getLocationIdentity();
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,6 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
 
 public interface NodeLIRBuilderTool extends NodeMappableLIRBuilder {
 
@@ -50,8 +49,6 @@
 
     void visitLoopEnd(LoopEndNode i);
 
-    void visitCompareAndSwap(LoweredCompareAndSwapNode i, Value address);
-
     // These methods define the contract a runtime specific backend must provide.
 
     void visitSafepointNode(SafepointNode i);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Proxy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.nodes.spi;
+
+import com.oracle.graal.graph.*;
+
+/**
+ * This interface marks nodes whose result is the same as one of their inputs. Such nodes are used
+ * to add type information, to introduce scheduling restrictions, etc.
+ *
+ * For some algorithms it is necessary or advantageous to see through these proxies.
+ */
+public interface Proxy extends NodeInterface {
+
+    Node getOriginalNode();
+
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ValueProxy.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/ValueProxy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,11 +27,11 @@
 /**
  * This interface marks nodes whose result is the same as one of their inputs. Such nodes are used
  * to add type information, to introduce scheduling restrictions, etc.
- * 
+ *
  * For some algorithms it is necessary or advantageous to see through these proxies.
  */
-public interface ValueProxy {
+public interface ValueProxy extends Proxy {
 
-    ValueNode getOriginalValue();
+    ValueNode getOriginalNode();
 
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,12 +41,17 @@
 public interface VirtualizerTool {
 
     /**
-     * @return the {@link MetaAccessProvider} associated with the current compilation, which might
-     *         be required for creating constants, etc.
+     * @return the {@link MetaAccessProvider} associated with the current compilation.
      */
     MetaAccessProvider getMetaAccessProvider();
 
     /**
+     * @return the {@link ConstantReflectionProvider} associated with the current compilation, which
+     *         can be used to access {@link Constant}s.
+     */
+    ConstantReflectionProvider getConstantReflectionProvider();
+
+    /**
      * @return the {@link Assumptions} associated with the current compilation, which can be used to
      *         make type assumptions during virtualization.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,6 @@
 
     protected FloatStamp(int bits, double lowerBound, double upperBound, boolean nonNaN) {
         super(bits);
-        assert (!nonNaN && Double.isNaN(lowerBound) && Double.isNaN(upperBound)) || lowerBound <= upperBound;
         this.lowerBound = lowerBound;
         this.upperBound = upperBound;
         this.nonNaN = nonNaN;
@@ -50,6 +49,16 @@
     }
 
     @Override
+    public Stamp illegal() {
+        return new FloatStamp(getBits(), Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, true);
+    }
+
+    @Override
+    public boolean isLegal() {
+        return lowerBound <= upperBound || !nonNaN;
+    }
+
+    @Override
     public Kind getStackKind() {
         if (getBits() > 32) {
             return Kind.Double;
@@ -124,9 +133,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.meet(this);
-        }
         if (!(otherStamp instanceof FloatStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
@@ -149,9 +155,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.join(this);
-        }
         if (!(otherStamp instanceof FloatStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
@@ -164,8 +167,6 @@
             return this;
         } else if (joinLowerBound == other.lowerBound && joinUpperBound == other.upperBound && joinNonNaN == other.nonNaN) {
             return other;
-        } else if (joinLowerBound > joinUpperBound) {
-            return illegal();
         } else {
             return new FloatStamp(getBits(), joinLowerBound, joinUpperBound, joinNonNaN);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/GenericStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.nodes.type;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.spi.*;
-
-public final class GenericStamp extends Stamp {
-
-    public enum GenericStampType {
-        Dependency,
-        Extension,
-        Condition
-    }
-
-    private final GenericStampType type;
-
-    protected GenericStamp(GenericStampType type) {
-        this.type = type;
-    }
-
-    public GenericStampType type() {
-        return type;
-    }
-
-    @Override
-    public Stamp unrestricted() {
-        return this;
-    }
-
-    @Override
-    public Kind getStackKind() {
-        return Kind.Illegal;
-    }
-
-    @Override
-    public PlatformKind getPlatformKind(LIRTypeTool tool) {
-        throw GraalInternalError.shouldNotReachHere(type + " stamp has no value");
-    }
-
-    @Override
-    public ResolvedJavaType javaType(MetaAccessProvider metaAccess) {
-        throw GraalInternalError.shouldNotReachHere(type + " stamp has not Java type");
-    }
-
-    @Override
-    public String toString() {
-        return type.toString();
-    }
-
-    @Override
-    public boolean alwaysDistinct(Stamp other) {
-        return false;
-    }
-
-    @Override
-    public Stamp meet(Stamp other) {
-        if (other instanceof IllegalStamp) {
-            return other.join(this);
-        }
-        if (!(other instanceof GenericStamp) || ((GenericStamp) other).type != type) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
-        return this;
-    }
-
-    @Override
-    public Stamp join(Stamp other) {
-        if (other instanceof IllegalStamp) {
-            return other.join(this);
-        }
-        if (!(other instanceof GenericStamp) || ((GenericStamp) other).type != type) {
-            return StampFactory.illegal(Kind.Illegal);
-        }
-        return this;
-    }
-
-    @Override
-    public boolean isCompatible(Stamp stamp) {
-        if (this == stamp) {
-            return true;
-        }
-        if (stamp instanceof GenericStamp) {
-            GenericStamp other = (GenericStamp) stamp;
-            return type == other.type;
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return 31 + ((type == null) ? 0 : type.hashCode());
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-        if (type != ((GenericStamp) obj).type) {
-            return false;
-        }
-        return true;
-    }
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IllegalStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IllegalStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,22 +29,14 @@
 /**
  * This stamp represents the illegal type. Values with this type can not exist at run time.
  */
-public final class IllegalStamp extends PrimitiveStamp {
-
-    private final Kind kind;
+public final class IllegalStamp extends Stamp {
 
-    public IllegalStamp(Kind kind) {
-        super(0);
-        this.kind = kind;
-    }
-
-    public Kind kind() {
-        return kind;
+    private IllegalStamp() {
     }
 
     @Override
     public Kind getStackKind() {
-        return kind;
+        return Kind.Illegal;
     }
 
     @Override
@@ -64,12 +56,12 @@
 
     @Override
     public ResolvedJavaType javaType(MetaAccessProvider metaAccess) {
-        return null;
+        throw GraalInternalError.shouldNotReachHere("illegal stamp has no Java type");
     }
 
     @Override
     public Stamp meet(Stamp other) {
-        return other;
+        return this;
     }
 
     @Override
@@ -79,19 +71,22 @@
 
     @Override
     public boolean isCompatible(Stamp stamp) {
-        if (this == stamp) {
-            return true;
-        }
-        if (stamp instanceof IllegalStamp) {
-            IllegalStamp other = (IllegalStamp) stamp;
-            return kind == other.kind;
-        } else {
-            return stamp.isCompatible(this);
-        }
+        return false;
     }
 
     @Override
     public String toString() {
         return "ILLEGAL";
     }
+
+    @Override
+    public boolean isLegal() {
+        return false;
+    }
+
+    private static IllegalStamp instance = new IllegalStamp();
+
+    static IllegalStamp getInstance() {
+        return instance;
+    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,13 +48,10 @@
         this.upperBound = upperBound;
         this.downMask = downMask;
         this.upMask = upMask;
-        assert lowerBound <= upperBound : this;
         assert lowerBound >= defaultMinValue(bits) : this;
         assert upperBound <= defaultMaxValue(bits) : this;
         assert (downMask & defaultMask(bits)) == downMask : this;
         assert (upMask & defaultMask(bits)) == upMask : this;
-        assert (lowerBound & downMask) == downMask : this;
-        assert (upperBound & downMask) == downMask : this;
     }
 
     @Override
@@ -63,6 +60,16 @@
     }
 
     @Override
+    public Stamp illegal() {
+        return new IntegerStamp(getBits(), defaultMaxValue(getBits()), defaultMinValue(getBits()), defaultMask(getBits()), 0);
+    }
+
+    @Override
+    public boolean isLegal() {
+        return lowerBound <= upperBound;
+    }
+
+    @Override
     public Kind getStackKind() {
         if (getBits() > 32) {
             return Kind.Long;
@@ -193,9 +200,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.meet(this);
-        }
         if (!(otherStamp instanceof IntegerStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
@@ -208,9 +212,6 @@
         if (otherStamp == this) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.join(this);
-        }
         if (!(otherStamp instanceof IntegerStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,7 +37,6 @@
     private final boolean alwaysNull;
 
     public ObjectStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) {
-        assert !exactType || (type != null && (isConcreteType(type)));
         this.type = type;
         this.exactType = exactType;
         this.nonNull = nonNull;
@@ -50,6 +49,16 @@
     }
 
     @Override
+    public Stamp illegal() {
+        return new ObjectStamp(null, true, true, false);
+    }
+
+    @Override
+    public boolean isLegal() {
+        return !exactType || (type != null && (isConcreteType(type)));
+    }
+
+    @Override
     public Kind getStackKind() {
         return Kind.Object;
     }
@@ -96,9 +105,6 @@
         if (this == otherStamp) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.meet(this);
-        }
         if (!(otherStamp instanceof ObjectStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
@@ -119,7 +125,11 @@
             meetAlwaysNull = other.alwaysNull;
         } else {
             meetType = meetTypes(type(), other.type());
-            meetExactType = Objects.equals(meetType, type) && Objects.equals(meetType, other.type) && exactType && other.exactType;
+            meetExactType = exactType && other.exactType;
+            if (meetExactType && type != null && other.type != null) {
+                // meeting two valid exact types may result in a non-exact type
+                meetExactType = Objects.equals(meetType, type) && Objects.equals(meetType, other.type);
+            }
             meetNonNull = nonNull && other.nonNull;
             meetAlwaysNull = false;
         }
@@ -146,9 +156,6 @@
         if (other instanceof ObjectStamp) {
             return true;
         }
-        if (other instanceof IllegalStamp) {
-            return ((IllegalStamp) other).kind() == Kind.Object;
-        }
         return false;
     }
 
@@ -158,12 +165,12 @@
      * where both types are not obviously related, the cast operation will prefer the type of the
      * {@code to} stamp. This is necessary as long as ObjectStamps are not able to accurately
      * represent intersection types.
-     * 
+     *
      * For example when joining the {@link RandomAccess} type with the {@link AbstractList} type,
      * without intersection types, this would result in the most generic type ({@link Object} ). For
      * this reason, in some cases a {@code castTo} operation is preferable in order to keep at least
      * the {@link AbstractList} type.
-     * 
+     *
      * @param to the stamp this stamp should be casted to
      * @return This stamp casted to the {@code to} stamp
      */
@@ -175,13 +182,16 @@
         if (this == otherStamp) {
             return this;
         }
-        if (otherStamp instanceof IllegalStamp) {
-            return otherStamp.join(this);
-        }
         if (!(otherStamp instanceof ObjectStamp)) {
             return StampFactory.illegal(Kind.Illegal);
         }
         ObjectStamp other = (ObjectStamp) otherStamp;
+        if (!isLegal()) {
+            return this;
+        } else if (!other.isLegal()) {
+            return other;
+        }
+
         ResolvedJavaType joinType;
         boolean joinAlwaysNull = alwaysNull || other.alwaysNull;
         boolean joinNonNull = nonNull || other.nonNull;
@@ -291,7 +301,7 @@
     }
 
     public static boolean isObjectAlwaysNull(Stamp stamp) {
-        return (stamp instanceof ObjectStamp && ((ObjectStamp) stamp).alwaysNull());
+        return (stamp instanceof ObjectStamp && ((ObjectStamp) stamp).isLegal() && ((ObjectStamp) stamp).alwaysNull());
     }
 
     public static boolean isObjectNonNull(ValueNode node) {
@@ -299,7 +309,7 @@
     }
 
     public static boolean isObjectNonNull(Stamp stamp) {
-        return (stamp instanceof ObjectStamp && ((ObjectStamp) stamp).nonNull());
+        return stamp instanceof ObjectStamp && ((ObjectStamp) stamp).isLegal() && ((ObjectStamp) stamp).nonNull();
     }
 
     public static ResolvedJavaType typeOrNull(ValueNode node) {
@@ -323,14 +333,4 @@
         }
         return false;
     }
-
-    public static boolean isObject(Stamp stamp) {
-        if (stamp instanceof ObjectStamp) {
-            return true;
-        } else if (stamp instanceof IllegalStamp) {
-            return ((IllegalStamp) stamp).kind() == Kind.Object;
-        } else {
-            return false;
-        }
-    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/Stamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -41,7 +41,7 @@
     public abstract ResolvedJavaType javaType(MetaAccessProvider metaAccess);
 
     public boolean alwaysDistinct(Stamp other) {
-        return join(other) instanceof IllegalStamp;
+        return !join(other).isLegal();
     }
 
     /**
@@ -52,15 +52,15 @@
     public abstract Kind getStackKind();
 
     /**
-     * Gets a platform dependend {@link PlatformKind} that can be used to store a value of this
+     * Gets a platform dependent {@link PlatformKind} that can be used to store a value of this
      * stamp.
      */
     public abstract PlatformKind getPlatformKind(LIRTypeTool tool);
 
     /**
      * Returns the union of this stamp and the given stamp. Typically used to create stamps for
-     * {@link PhiNode}s.
-     * 
+     * {@link ValuePhiNode}s.
+     *
      * @param other The stamp that will enlarge this stamp.
      * @return The union of this stamp and the given stamp.
      */
@@ -68,7 +68,7 @@
 
     /**
      * Returns the intersection of this stamp and the given stamp.
-     * 
+     *
      * @param other The stamp that will tighten this stamp.
      * @return The intersection of this stamp and the given stamp.
      */
@@ -76,15 +76,17 @@
 
     /**
      * Returns a stamp of the same kind, but allowing the full value range of the kind.
+     *
+     * {@link #unrestricted()} is the neutral element of the {@link #join(Stamp)} operation.
      */
     public abstract Stamp unrestricted();
 
     /**
-     * Returns an illegal stamp that has the same kind, but no valid values.
+     * Returns a stamp of the same kind, but with no allowed values.
+     *
+     * {@link #illegal()} is the neutral element of the {@link #meet(Stamp)} operation.
      */
-    public Stamp illegal() {
-        return StampFactory.illegal(getStackKind());
-    }
+    public abstract Stamp illegal();
 
     /**
      * Test whether two stamps have the same base type.
@@ -92,9 +94,14 @@
     public abstract boolean isCompatible(Stamp other);
 
     /**
+     * Test whether this stamp has legal values.
+     */
+    public abstract boolean isLegal();
+
+    /**
      * If this stamp represents a single value, the methods returns this single value. It returns
      * null otherwise.
-     * 
+     *
      * @return the constant corresponding to the single value of this stamp and null if this stamp
      *         can represent less or more than one value.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,7 +24,6 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.type.GenericStamp.GenericStampType;
 
 public class StampFactory {
 
@@ -35,9 +34,6 @@
     private static final Stamp objectStamp = new ObjectStamp(null, false, false, false);
     private static final Stamp objectNonNullStamp = new ObjectStamp(null, false, true, false);
     private static final Stamp objectAlwaysNullStamp = new ObjectStamp(null, false, false, true);
-    private static final Stamp dependencyStamp = new GenericStamp(GenericStampType.Dependency);
-    private static final Stamp extensionStamp = new GenericStamp(GenericStampType.Extension);
-    private static final Stamp conditionStamp = new GenericStamp(GenericStampType.Condition);
     private static final Stamp nodeIntrinsicStamp = new ObjectStamp(null, false, false, false);
     private static final Stamp positiveInt = forInteger(Kind.Int, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE);
 
@@ -73,8 +69,13 @@
 
         setCache(Kind.Object, objectStamp);
         setCache(Kind.Void, VoidStamp.getInstance());
+
         for (Kind k : Kind.values()) {
-            illegalStampCache[k.ordinal()] = new IllegalStamp(k);
+            if (stampCache[k.ordinal()] != null) {
+                illegalStampCache[k.ordinal()] = stampCache[k.ordinal()].illegal();
+            } else {
+                illegalStampCache[k.ordinal()] = IllegalStamp.getInstance();
+            }
         }
     }
 
@@ -106,20 +107,12 @@
         return forKind(Kind.Int);
     }
 
-    public static Stamp dependency() {
-        return dependencyStamp;
+    public static Stamp positiveInt() {
+        return positiveInt;
     }
 
-    public static Stamp extension() {
-        return extensionStamp;
-    }
-
-    public static Stamp condition() {
-        return conditionStamp;
-    }
-
-    public static Stamp positiveInt() {
-        return positiveInt;
+    public static Stamp illegal() {
+        return illegal(Kind.Illegal);
     }
 
     public static Stamp illegal(Kind kind) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,23 +32,6 @@
  */
 public class StampTool {
 
-    private static Kind joinKind(Kind a, Kind b) {
-        if (a == b) {
-            return a;
-        }
-        return Kind.Illegal;
-    }
-
-    /**
-     * Create an {@link IllegalStamp} from two incompatible input stamps, joining the kind of the
-     * input stamps if possible.
-     */
-    private static Stamp joinIllegal(Stamp a, Stamp b) {
-        IllegalStamp ia = (IllegalStamp) a.illegal();
-        IllegalStamp ib = (IllegalStamp) b.illegal();
-        return StampFactory.illegal(joinKind(ia.kind(), ib.kind()));
-    }
-
     public static Stamp negate(Stamp stamp) {
         if (stamp instanceof IntegerStamp) {
             IntegerStamp integerStamp = (IntegerStamp) stamp;
@@ -92,7 +75,7 @@
         if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) {
             return add((IntegerStamp) stamp1, (IntegerStamp) stamp2);
         }
-        return joinIllegal(stamp1, stamp2);
+        return StampFactory.illegal();
     }
 
     private static long carryBits(long x, long y) {
@@ -107,7 +90,7 @@
         if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) {
             return div((IntegerStamp) stamp1, (IntegerStamp) stamp2);
         }
-        return joinIllegal(stamp1, stamp2);
+        return StampFactory.illegal();
     }
 
     public static Stamp div(IntegerStamp stamp1, IntegerStamp stamp2) {
@@ -206,7 +189,7 @@
         if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) {
             return and((IntegerStamp) stamp1, (IntegerStamp) stamp2);
         }
-        return joinIllegal(stamp1, stamp2);
+        return StampFactory.illegal();
     }
 
     public static Stamp and(IntegerStamp stamp1, IntegerStamp stamp2) {
@@ -218,7 +201,7 @@
         if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) {
             return or((IntegerStamp) stamp1, (IntegerStamp) stamp2);
         }
-        return joinIllegal(stamp1, stamp2);
+        return StampFactory.illegal();
     }
 
     public static Stamp or(IntegerStamp stamp1, IntegerStamp stamp2) {
@@ -230,7 +213,7 @@
         if (stamp1 instanceof IntegerStamp && stamp2 instanceof IntegerStamp) {
             return xor((IntegerStamp) stamp1, (IntegerStamp) stamp2);
         }
-        return joinIllegal(stamp1, stamp2);
+        return StampFactory.illegal();
     }
 
     public static Stamp xor(IntegerStamp stamp1, IntegerStamp stamp2) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/VoidStamp.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/VoidStamp.java	Wed Apr 16 14:02:52 2014 +0200
@@ -91,6 +91,17 @@
         return this == stamp;
     }
 
+    @Override
+    public Stamp illegal() {
+        // there is no illegal void stamp
+        return this;
+    }
+
+    @Override
+    public boolean isLegal() {
+        return true;
+    }
+
     private static VoidStamp instance = new VoidStamp();
 
     static VoidStamp getInstance() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -168,7 +168,7 @@
         if (proxyPoint instanceof LoopExitNode) {
             LoopExitNode exit = (LoopExitNode) proxyPoint;
             LoopBeginNode loopBegin = exit.loopBegin();
-            ValueNode vpnValue = vpn.value();
+            Node vpnValue = vpn.value();
             for (ValueNode v : loopBegin.stateAfter().values()) {
                 ValueNode v2 = v;
                 if (loopBegin.isPhiAtMerge(v2)) {
@@ -205,7 +205,7 @@
 
     /**
      * Gets an approximate source code location for a node if possible.
-     * 
+     *
      * @return the StackTraceElements if an approximate source location is found, null otherwise
      */
     public static StackTraceElement[] approxSourceStackTraceElement(Node node) {
@@ -235,7 +235,7 @@
 
     /**
      * Gets an approximate source code location for a node, encoded as an exception, if possible.
-     * 
+     *
      * @return the exception with the location
      */
     public static RuntimeException approxSourceException(Node node, Throwable cause) {
@@ -254,7 +254,7 @@
 
     /**
      * Gets an approximate source code location for a node if possible.
-     * 
+     *
      * @return a file name and source line number in stack trace format (e.g. "String.java:32") if
      *         an approximate source location is found, null otherwise
      */
@@ -271,7 +271,7 @@
 
     /**
      * Returns a string representation of the given collection of objects.
-     * 
+     *
      * @param objects The {@link Iterable} that will be used to iterate over the objects.
      * @return A string of the format "[a, b, ...]".
      */
@@ -290,14 +290,14 @@
 
     /**
      * Gets the original value by iterating through all {@link ValueProxy ValueProxies}.
-     * 
+     *
      * @param value The start value.
      * @return The first non-proxy value encountered.
      */
     public static ValueNode unproxify(ValueNode value) {
         ValueNode result = value;
         while (result instanceof ValueProxy) {
-            result = ((ValueProxy) result).getOriginalValue();
+            result = ((ValueProxy) result).getOriginalNode();
         }
         return result;
     }
@@ -306,14 +306,14 @@
      * Tries to find an original value of the given node by traversing through proxies and
      * unambiguous phis. Note that this method will perform an exhaustive search through phis. It is
      * intended to be used during graph building, when phi nodes aren't yet canonicalized.
-     * 
+     *
      * @param proxy The node whose original value should be determined.
      */
     public static ValueNode originalValue(ValueNode proxy) {
         ValueNode v = proxy;
         do {
             if (v instanceof ValueProxy) {
-                v = ((ValueProxy) v).getOriginalValue();
+                v = ((ValueProxy) v).getOriginalNode();
             } else if (v instanceof PhiNode) {
                 v = ((PhiNode) v).singleValue();
             } else {
@@ -339,7 +339,7 @@
             worklist.add(proxy);
             for (Node node : worklist) {
                 if (node instanceof ValueProxy) {
-                    ValueNode originalValue = ((ValueProxy) node).getOriginalValue();
+                    ValueNode originalValue = ((ValueProxy) node).getOriginalNode();
                     if (!process(originalValue, worklist)) {
                         return;
                     }
@@ -359,7 +359,7 @@
 
         /**
          * Process a node as part of this search.
-         * 
+         *
          * @param node the next node encountered in the search
          * @param worklist if non-null, {@code node} will be added to this list. Otherwise,
          *            {@code node} is treated as a candidate result.
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.nodes.virtual;
 
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
@@ -34,7 +35,7 @@
 public class AllocatedObjectNode extends FloatingNode implements Virtualizable, ArrayLengthProvider {
 
     @Input private VirtualObjectNode virtualObject;
-    @Input private CommitAllocationNode commit;
+    @Input(InputType.Extension) private CommitAllocationNode commit;
 
     public AllocatedObjectNode(VirtualObjectNode virtualObject) {
         super(StampFactory.exactNonNull(virtualObject.type()));
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,12 +32,12 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
-@NodeInfo(nameTemplate = "Alloc {i#virtualObjects}")
+@NodeInfo(nameTemplate = "Alloc {i#virtualObjects}", allowedUsageTypes = {InputType.Extension})
 public final class CommitAllocationNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable, Simplifiable {
 
     @Input private final NodeInputList<VirtualObjectNode> virtualObjects = new NodeInputList<>(this);
     @Input private final NodeInputList<ValueNode> values = new NodeInputList<>(this);
-    @Input private final NodeInputList<MonitorIdNode> locks = new NodeInputList<>(this);
+    @Input(InputType.Association) private final NodeInputList<MonitorIdNode> locks = new NodeInputList<>(this);
     private ArrayList<Integer> lockIndexes = new ArrayList<>(Arrays.asList(0));
 
     public CommitAllocationNode() {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/EscapeObjectState.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/EscapeObjectState.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.nodes.virtual;
 
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.ValueNumberable;
 import com.oracle.graal.nodes.*;
 
 public abstract class EscapeObjectState extends VirtualState implements ValueNumberable {
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,13 +29,13 @@
 public class OptionDescriptor {
 
     protected final String name;
-    protected final Class type;
+    protected final Class<?> type;
     protected final String help;
     protected final OptionValue<?> option;
     protected final Class<?> declaringClass;
     protected final String fieldName;
 
-    public OptionDescriptor(String name, Class type, String help, Class<?> declaringClass, String fieldName, OptionValue<?> option) {
+    public OptionDescriptor(String name, Class<?> type, String help, Class<?> declaringClass, String fieldName, OptionValue<?> option) {
         this.name = name;
         this.type = type;
         this.help = help;
@@ -48,7 +48,7 @@
     /**
      * Gets the type of values stored in the option.
      */
-    public Class getType() {
+    public Class<?> getType() {
         return type;
     }
 
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,7 +37,7 @@
  * Processes static fields annotated with {@link Option}. An {@link Options} service is generated
  * for each top level class containing at least one such field. These service objects can be
  * retrieved as follows:
- * 
+ *
  * <pre>
  * ServiceLoader&lt;Options&gt; sl = ServiceLoader.loadInstalled(Options.class);
  * for (OptionDescriptor desc : sl) {
@@ -184,11 +184,11 @@
             out.println("        return options.iterator();");
             out.println("    }");
             if (needPrivateFieldAccessor) {
-                out.println("    private static " + OptionValue.class.getSimpleName() + " field(Class<?> declaringClass, String fieldName) {");
+                out.println("    private static " + OptionValue.class.getSimpleName() + "<?> field(Class<?> declaringClass, String fieldName) {");
                 out.println("        try {");
                 out.println("            java.lang.reflect.Field field = declaringClass.getDeclaredField(fieldName);");
                 out.println("            field.setAccessible(true);");
-                out.println("            return (" + OptionValue.class.getSimpleName() + ") field.get(null);");
+                out.println("            return (" + OptionValue.class.getSimpleName() + "<?>) field.get(null);");
                 out.println("        } catch (Exception e) {");
                 out.println("            throw (InternalError) new InternalError().initCause(e);");
                 out.println("        }");
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Wed Apr 16 14:02:52 2014 +0200
@@ -139,7 +139,7 @@
 
     private long reads;
     private OptionValue<?> next;
-    private static OptionValue head;
+    private static OptionValue<?> head;
 
     private static final boolean ShowReadsHistogram = Boolean.getBoolean("graal.showOptionValueReadsHistogram");
 
@@ -252,7 +252,7 @@
      * {@link OptionValue#override(OptionValue, Object)} or {@link OptionValue#override(Map)}.
      */
     public abstract static class OverrideScope implements AutoCloseable {
-        abstract void addToInherited(Map<OptionValue, Object> inherited);
+        abstract void addToInherited(Map<OptionValue<?>, Object> inherited);
 
         abstract <T> T getOverride(OptionValue<T> option);
 
@@ -276,7 +276,7 @@
         }
 
         @Override
-        void addToInherited(Map<OptionValue, Object> inherited) {
+        void addToInherited(Map<OptionValue<?>, Object> inherited) {
             inherited.put(option, value);
         }
 
@@ -304,7 +304,7 @@
 
     static class MultipleOverridesScope extends OverrideScope {
         final OverrideScope parent;
-        final Map<OptionValue, Object> overrides;
+        final Map<OptionValue<?>, Object> overrides;
 
         public MultipleOverridesScope(OverrideScope parent, OptionValue<?> option, Object value) {
             this.parent = parent;
@@ -348,7 +348,7 @@
         }
 
         @Override
-        void addToInherited(Map<OptionValue, Object> inherited) {
+        void addToInherited(Map<OptionValue<?>, Object> inherited) {
             if (parent != null) {
                 parent.addToInherited(inherited);
             }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,6 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -197,7 +196,7 @@
             // this piece of code handles phis
             if (!(merge instanceof LoopBeginNode)) {
                 for (PhiNode phi : merge.phis()) {
-                    if (phi.type() == PhiType.Value && phi.getKind() == Kind.Object) {
+                    if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) {
                         ValueNode firstValue = phi.valueAt(0);
                         ResolvedJavaType type = getNodeType(firstValue);
                         boolean nonNull = knownNonNull.contains(firstValue);
@@ -708,24 +707,16 @@
                     if (nonNull) {
                         replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type);
                     }
-                    ValueAnchorNode anchor = null;
-                    if (replacementAnchor == null) {
-                        anchor = graph.add(new ValueAnchorNode(null));
-                        replacementAnchor = anchor;
-                    }
+                    replacementAnchor = BeginNode.prevBegin(checkCast);
                     PiNode piNode;
                     if (isNull) {
-                        ConstantNode nullObject = ConstantNode.forObject(null, metaAccess, graph);
+                        ConstantNode nullObject = ConstantNode.defaultForKind(Kind.Object, graph);
                         piNode = graph.unique(new PiNode(nullObject, StampFactory.forConstant(nullObject.getValue(), metaAccess), replacementAnchor.asNode()));
                     } else {
                         piNode = graph.unique(new PiNode(object, StampFactory.declared(type, nonNull), replacementAnchor.asNode()));
                     }
                     checkCast.replaceAtUsages(piNode);
-                    if (anchor != null) {
-                        graph.replaceFixedWithFixed(checkCast, anchor);
-                    } else {
-                        graph.removeFixed(checkCast);
-                    }
+                    graph.removeFixed(checkCast);
                     metricCheckCastRemoved.increment();
                 }
             } else if (node instanceof ConditionAnchorNode) {
@@ -823,7 +814,7 @@
                         if (!Objects.equals(type, ObjectStamp.typeOrNull(receiver))) {
                             ResolvedJavaMethod method = type.resolveMethod(callTarget.targetMethod());
                             if (method != null) {
-                                if (Modifier.isFinal(method.getModifiers()) || Modifier.isFinal(type.getModifiers())) {
+                                if (method.canBeStaticallyBound() || Modifier.isFinal(type.getModifiers())) {
                                     callTarget.setInvokeKind(InvokeKind.Special);
                                     callTarget.setTargetMethod(method);
                                 }
@@ -854,7 +845,7 @@
             for (Node n : value.usages()) {
                 if (n instanceof ValueProxy) {
                     ValueProxy proxyNode = (ValueProxy) n;
-                    if (proxyNode.getOriginalValue() == value) {
+                    if (proxyNode.getOriginalNode() == value) {
                         GuardingNode result = searchAnchor((ValueNode) n, type);
                         if (result != null) {
                             return result;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -56,8 +56,8 @@
                     if (target instanceof AbstractDeoptimizeNode) {
                         merge = graph.add(new MergeNode());
                         EndNode firstEnd = graph.add(new EndNode());
-                        reasonActionPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Int), merge));
-                        speculationPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), merge));
+                        reasonActionPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Int), merge));
+                        speculationPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Object), merge));
                         merge.addForwardEnd(firstEnd);
                         reasonActionPhi.addInput(((AbstractDeoptimizeNode) target).getActionAndReason(context.getMetaAccess()));
                         speculationPhi.addInput(((AbstractDeoptimizeNode) target).getSpeculation(context.getMetaAccess()));
@@ -92,9 +92,9 @@
 
     private static void exitLoops(AbstractDeoptimizeNode deopt, EndNode end, ControlFlowGraph cfg) {
         Block block = cfg.blockFor(deopt);
-        Loop loop = block.getLoop();
+        Loop<Block> loop = block.getLoop();
         while (loop != null) {
-            end.graph().addBeforeFixed(end, end.graph().add(new LoopExitNode(loop.loopBegin())));
+            end.graph().addBeforeFixed(end, end.graph().add(new LoopExitNode((LoopBeginNode) loop.header.getBeginNode())));
             loop = loop.parent;
         }
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -90,6 +90,14 @@
             return lastMemorySnapshot.keySet();
         }
 
+        @Override
+        public void replaceLastLocationAccess(MemoryNode oldNode, MemoryNode newNode) {
+            for (Map.Entry<LocationIdentity, MemoryNode> entry : lastMemorySnapshot.entrySet()) {
+                if (entry.getValue() == oldNode) {
+                    entry.setValue(newNode);
+                }
+            }
+        }
     }
 
     private final ExecutionMode execmode;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -45,7 +45,7 @@
 /**
  * This phase lowers {@link GuardNode GuardNodes} into corresponding control-flow structure and
  * {@link DeoptimizeNode DeoptimizeNodes}.
- * 
+ *
  * This allow to enter the {@link GuardsStage#FIXED_DEOPTS FIXED_DEOPTS} stage of the graph where
  * all node that may cause deoptimization are fixed.
  * <p>
@@ -89,24 +89,26 @@
         }
 
         private void processAccess(Access access) {
-            GuardNode guard = nullGuarded.get(access.object());
-            if (guard != null && isImplicitNullCheck(access.nullCheckLocation())) {
-                metricImplicitNullCheck.increment();
-                access.setGuard(guard.getGuard());
-                FixedAccessNode fixedAccess;
-                if (access instanceof FloatingAccessNode) {
-                    fixedAccess = ((FloatingAccessNode) access).asFixedNode();
-                    replaceCurrent(fixedAccess.asNode());
-                } else {
-                    fixedAccess = (FixedAccessNode) access;
+            if (access.canNullCheck()) {
+                GuardNode guard = nullGuarded.get(access.object());
+                if (guard != null && isImplicitNullCheck(access.accessLocation())) {
+                    metricImplicitNullCheck.increment();
+                    access.setGuard(null);
+                    FixedAccessNode fixedAccess;
+                    if (access instanceof FloatingAccessNode) {
+                        fixedAccess = ((FloatingAccessNode) access).asFixedNode();
+                        replaceCurrent(fixedAccess);
+                    } else {
+                        fixedAccess = (FixedAccessNode) access;
+                    }
+                    fixedAccess.setNullCheck(true);
+                    LogicNode condition = guard.condition();
+                    guard.replaceAndDelete(fixedAccess);
+                    if (condition.usages().isEmpty()) {
+                        GraphUtil.killWithUnusedFloatingInputs(condition);
+                    }
+                    nullGuarded.remove(fixedAccess.object());
                 }
-                fixedAccess.setNullCheck(true);
-                LogicNode condition = guard.condition();
-                guard.replaceAndDelete(fixedAccess.asNode());
-                if (condition.usages().isEmpty()) {
-                    GraphUtil.killWithUnusedFloatingInputs(condition);
-                }
-                nullGuarded.remove(fixedAccess.object());
             }
         }
 
@@ -172,10 +174,10 @@
         }
 
         private void insertLoopExits(DeoptimizeNode deopt) {
-            Loop loop = block.getLoop();
+            Loop<Block> loop = block.getLoop();
             StructuredGraph graph = deopt.graph();
             while (loop != null) {
-                LoopExitNode exit = graph.add(new LoopExitNode(loop.loopBegin()));
+                LoopExitNode exit = graph.add(new LoopExitNode((LoopBeginNode) loop.header.getBeginNode()));
                 graph.addBeforeFixed(deopt, exit);
                 loop = loop.parent;
             }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -485,7 +485,7 @@
         private void createGuard(StructuredGraph graph, MetaAccessProvider metaAccess) {
             ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
             ConstantNode typeHub = ConstantNode.forConstant(type.getEncoding(Representation.ObjectHub), metaAccess, graph);
-            LoadHubNode receiverHub = graph.unique(new LoadHubNode(nonNullReceiver, typeHub.getKind(), null));
+            LoadHubNode receiverHub = graph.unique(new LoadHubNode(nonNullReceiver, typeHub.getKind()));
 
             CompareNode typeCheck = CompareNode.createCompareNode(graph, Condition.EQ, receiverHub, typeHub);
             FixedGuardNode guard = graph.add(new FixedGuardNode(typeCheck, DeoptimizationReason.TypeCheckedInliningViolated, DeoptimizationAction.InvalidateReprofile));
@@ -628,7 +628,7 @@
 
             PhiNode returnValuePhi = null;
             if (invoke.asNode().getKind() != Kind.Void) {
-                returnValuePhi = graph.addWithoutUnique(new PhiNode(invoke.asNode().stamp().unrestricted(), returnMerge));
+                returnValuePhi = graph.addWithoutUnique(new ValuePhiNode(invoke.asNode().stamp().unrestricted(), returnMerge));
             }
 
             MergeNode exceptionMerge = null;
@@ -641,7 +641,7 @@
 
                 FixedNode exceptionSux = exceptionEdge.next();
                 graph.addBeforeFixed(exceptionSux, exceptionMerge);
-                exceptionObjectPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), exceptionMerge));
+                exceptionObjectPhi = graph.addWithoutUnique(new ValuePhiNode(StampFactory.forKind(Kind.Object), exceptionMerge));
                 exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Object, exceptionObjectPhi));
             }
 
@@ -785,7 +785,7 @@
             assert ptypes.size() >= 1;
             ValueNode nonNullReceiver = nonNullReceiver(invoke);
             Kind hubKind = ((MethodCallTargetNode) invoke.callTarget()).targetMethod().getDeclaringClass().getEncoding(Representation.ObjectHub).getKind();
-            LoadHubNode hub = graph.unique(new LoadHubNode(nonNullReceiver, hubKind, null));
+            LoadHubNode hub = graph.unique(new LoadHubNode(nonNullReceiver, hubKind));
 
             if (!invokeIsOnlySuccessor && chooseMethodDispatch()) {
                 assert successors.length == concretes.size() + 1;
@@ -1489,7 +1489,7 @@
 
             if (returnNode.result() != null) {
                 if (returnValuePhi == null) {
-                    returnValuePhi = merge.graph().addWithoutUnique(new PhiNode(returnNode.result().stamp().unrestricted(), merge));
+                    returnValuePhi = merge.graph().addWithoutUnique(new ValuePhiNode(returnNode.result().stamp().unrestricted(), merge));
                 }
                 returnValuePhi.addInput(returnNode.result());
             }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -50,11 +50,11 @@
 
         private final PhaseContext context;
         private final NodeBitMap activeGuards;
-        private GuardingNode guardAnchor;
+        private AnchoringNode guardAnchor;
         private FixedWithNextNode lastFixedNode;
         private ControlFlowGraph cfg;
 
-        public LoweringToolImpl(PhaseContext context, GuardingNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode, ControlFlowGraph cfg) {
+        public LoweringToolImpl(PhaseContext context, AnchoringNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode, ControlFlowGraph cfg) {
             this.context = context;
             this.guardAnchor = guardAnchor;
             this.activeGuards = activeGuards;
@@ -88,7 +88,7 @@
         }
 
         @Override
-        public GuardingNode getCurrentGuardAnchor() {
+        public AnchoringNode getCurrentGuardAnchor() {
             return guardAnchor;
         }
 
@@ -103,7 +103,7 @@
         }
 
         private class DummyGuardHandle extends ValueNode implements GuardedNode {
-            @Input private GuardingNode guard;
+            @Input(InputType.Guard) private GuardingNode guard;
 
             public DummyGuardHandle(GuardingNode guard) {
                 super(StampFactory.forVoid());
@@ -115,7 +115,7 @@
             }
 
             public void setGuard(GuardingNode guard) {
-                updateUsages(this.guard == null ? null : this.guard.asNode(), guard == null ? null : guard.asNode());
+                updateUsagesInterface(this.guard, guard);
                 this.guard = guard;
             }
 
@@ -177,7 +177,7 @@
 
     /**
      * Checks that second lowering of a given graph did not introduce any new nodes.
-     * 
+     *
      * @param graph a graph that was just {@linkplain #lower lowered}
      * @throws AssertionError if the check fails
      */
@@ -206,7 +206,7 @@
      * Checks that lowering of a given node did not introduce any new {@link Lowerable} nodes that
      * could be lowered in the current {@link LoweringPhase}. Such nodes must be recursively lowered
      * as part of lowering {@code node}.
-     * 
+     *
      * @param node a node that was just lowered
      * @param preLoweringMark the graph mark before {@code node} was lowered
      * @param unscheduledUsages set of {@code node}'s usages that were unscheduled before it was
@@ -253,9 +253,9 @@
             processBlock(schedule.getCFG().getStartBlock(), graph.createNodeBitMap(), null);
         }
 
-        private void processBlock(Block block, NodeBitMap activeGuards, GuardingNode parentAnchor) {
+        private void processBlock(Block block, NodeBitMap activeGuards, AnchoringNode parentAnchor) {
 
-            GuardingNode anchor = parentAnchor;
+            AnchoringNode anchor = parentAnchor;
             if (anchor == null) {
                 anchor = block.getBeginNode();
             }
@@ -284,7 +284,7 @@
             }
         }
 
-        private GuardingNode process(final Block b, final NodeBitMap activeGuards, final GuardingNode startAnchor) {
+        private AnchoringNode process(final Block b, final NodeBitMap activeGuards, final AnchoringNode startAnchor) {
 
             final LoweringToolImpl loweringTool = new LoweringToolImpl(context, startAnchor, activeGuards, b.getBeginNode(), schedule.getCFG());
 
@@ -349,7 +349,7 @@
          * the context of a usage that dominates all other usages. The fixed nodes resulting from
          * lowering are attached to the fixed node context of the dominating usage. This ensures the
          * post-lowering graph still has a valid schedule.
-         * 
+         *
          * @param node a {@link Lowerable} node
          */
         private Collection<Node> getUnscheduledUsages(Node node) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -64,7 +64,7 @@
                     // loops never end
                     if (newAnchor != begin) {
                         for (GuardNode guard : guards.snapshot()) {
-                            guard.setGuard(newAnchor);
+                            guard.setAnchor(newAnchor);
                         }
                         metricGuardsAnchorOptimized.increment();
                     }
@@ -101,7 +101,7 @@
             }
             for (GuardNode conditonGuard : guard.condition().usages().filter(GuardNode.class)) {
                 if (conditonGuard != guard) {
-                    GuardingNode conditonGuardAnchor = conditonGuard.getGuard();
+                    AnchoringNode conditonGuardAnchor = conditonGuard.getAnchor();
                     if (conditonGuardAnchor.asNode().predecessor() == controlSplit && compatibleGuards(guard, conditonGuard)) {
                         otherGuards.add(conditonGuard);
                     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ProfileCompiledMethodsPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ProfileCompiledMethodsPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,11 +43,11 @@
  * for each node would be too costly, so this phase takes the compromise that it trusts split
  * probabilities, but not loop frequencies. This means that it will insert counters at the start of
  * a method and at each loop header.
- * 
+ *
  * A schedule is created so that floating nodes can also be taken into account. The weight of a node
  * is determined heuristically in the
  * {@link ProfileCompiledMethodsPhase#getNodeWeight(ScheduledNode)} method.
- * 
+ *
  * Additionally, there's a second counter that's only increased for code sections without invokes.
  */
 public class ProfileCompiledMethodsPhase extends Phase {
@@ -65,18 +65,18 @@
         schedule.apply(graph, false);
 
         ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
-        for (Loop loop : cfg.getLoops()) {
-            double loopProbability = probabilities.get(loop.loopBegin());
+        for (Loop<Block> loop : cfg.getLoops()) {
+            double loopProbability = probabilities.get(loop.header.getBeginNode());
             if (loopProbability > (1D / Integer.MAX_VALUE)) {
-                addSectionCounters(loop.loopBegin(), loop.blocks, loop.children, schedule, probabilities);
+                addSectionCounters(loop.header.getBeginNode(), loop.blocks, loop.children, schedule, probabilities);
             }
         }
-        addSectionCounters(graph.start(), Arrays.asList(cfg.getBlocks()), Arrays.asList(cfg.getLoops()), schedule, probabilities);
+        addSectionCounters(graph.start(), Arrays.asList(cfg.getBlocks()), cfg.getLoops(), schedule, probabilities);
     }
 
-    private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop> childLoops, SchedulePhase schedule, NodesToDoubles probabilities) {
+    private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, SchedulePhase schedule, NodesToDoubles probabilities) {
         HashSet<Block> blocks = new HashSet<>(sectionBlocks);
-        for (Loop loop : childLoops) {
+        for (Loop<?> loop : childLoops) {
             blocks.removeAll(loop.blocks);
         }
         double weight = getSectionWeight(schedule, probabilities, blocks) / probabilities.get(start);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -60,9 +60,9 @@
             WriteNode other = (WriteNode) lastLocationAccess;
             return other.object() == n.object() && other.location() == n.location();
         }
-        if (lastLocationAccess instanceof PhiNode) {
+        if (lastLocationAccess instanceof MemoryPhiNode) {
             visited.mark(ValueNodeUtil.asNode(lastLocationAccess));
-            for (ValueNode value : ((PhiNode) lastLocationAccess).values()) {
+            for (ValueNode value : ((MemoryPhiNode) lastLocationAccess).values()) {
                 if (!isWrites(n, (MemoryNode) value, visited)) {
                     return false;
                 }
@@ -85,9 +85,9 @@
         if (lastLocationAccess instanceof WriteNode) {
             return ((WriteNode) lastLocationAccess).value();
         }
-        if (lastLocationAccess instanceof PhiNode) {
-            PhiNode phi = (PhiNode) lastLocationAccess;
-            PhiNode newPhi = phi.graph().addWithoutUnique(new PhiNode(n.stamp().unrestricted(), phi.merge()));
+        if (lastLocationAccess instanceof MemoryPhiNode) {
+            MemoryPhiNode phi = (MemoryPhiNode) lastLocationAccess;
+            ValuePhiNode newPhi = phi.graph().addWithoutUnique(new ValuePhiNode(n.stamp().unrestricted(), phi.merge()));
             nodeMap.set(phi, newPhi);
             for (ValueNode value : phi.values()) {
                 newPhi.addInput(getValue(n, (MemoryNode) value, nodeMap));
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.phases.common;
 
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.*;
 import com.oracle.graal.phases.*;
 
 public class RemoveValueProxyPhase extends Phase {
@@ -31,7 +30,7 @@
     @Override
     protected void run(StructuredGraph graph) {
         for (ProxyNode vpn : graph.getNodes(ProxyNode.class)) {
-            if (vpn.type() == PhiType.Value) {
+            if (vpn instanceof ValueProxyNode) {
                 graph.replaceFloating(vpn, vpn.value());
             }
         }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,8 +28,10 @@
 
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.Graph.DuplicationReplacement;
+import com.oracle.graal.graph.Graph.Mark;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Graph.Mark;
+import com.oracle.graal.graph.NodeClass.NodeClassIterator;
+import com.oracle.graal.graph.NodeClass.Position;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.VirtualState.NodeClosure;
 import com.oracle.graal.nodes.extended.*;
@@ -57,6 +59,12 @@
 
     private final CanonicalizerPhase canonicalizer;
 
+    private static final class DummyAnchorNode extends FixedWithNextNode implements GuardingNode {
+        public DummyAnchorNode() {
+            super(StampFactory.forVoid());
+        }
+    }
+
     /**
      * This interface is used by tail duplication to let clients decide if tail duplication should
      * be performed.
@@ -67,7 +75,7 @@
          * Queries if tail duplication should be performed at the given merge. If this method
          * returns true then the tail duplication will be performed, because all other checks have
          * happened before.
-         * 
+         *
          * @param merge The merge at which tail duplication can be performed.
          * @param fixedNodeCount The size of the set of fixed nodes that forms the base for the
          *            duplicated set of nodes.
@@ -162,7 +170,7 @@
      * {@link MergeNode#stateAfter()}) then the decision callback is used to determine whether the
      * tail duplication should actually be performed. If replacements is non-null, then this list of
      * {@link PiNode}s is used to replace one value per merge end.
-     * 
+     *
      * @param merge The merge whose tail should be duplicated.
      * @param decision A callback that can make the final decision if tail duplication should occur
      *            or not.
@@ -210,7 +218,7 @@
 
         /**
          * Initializes the tail duplication operation without actually performing any work.
-         * 
+         *
          * @param merge The merge whose tail should be duplicated.
          * @param replacements A list of replacement {@link PiNode}s, or null. If this is non-null,
          *            then the size of the list needs to match the number of end nodes at the merge.
@@ -232,7 +240,7 @@
          * <li>Determines the complete set of duplicated nodes.</li>
          * <li>Performs the actual duplication.</li>
          * </ul>
-         * 
+         *
          * @param phaseContext
          */
         private void duplicate(PhaseContext phaseContext) {
@@ -240,7 +248,7 @@
 
             Mark startMark = graph.getMark();
 
-            ValueAnchorNode anchor = addValueAnchor();
+            DummyAnchorNode anchor = addValueAnchor();
 
             // determine the fixed nodes that should be duplicated (currently: all nodes up until
             // the first control
@@ -283,11 +291,17 @@
 
                 // re-wire the duplicated ValueAnchorNode to the predecessor of the corresponding
                 // EndNode
-                FixedNode anchorDuplicate = (FixedNode) duplicates.get(anchor);
-                ((FixedWithNextNode) forwardEnd.predecessor()).setNext(anchorDuplicate);
+                FixedWithNextNode anchorDuplicate = (FixedWithNextNode) duplicates.get(anchor);
                 // move dependencies on the ValueAnchorNode to the previous BeginNode
-                AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(anchorDuplicate);
-                anchorDuplicate.replaceAtUsages(prevBegin);
+                AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(forwardEnd);
+                anchorDuplicate.replaceAtUsages(InputType.Guard, prevBegin);
+                anchorDuplicate.replaceAtUsages(InputType.Anchor, prevBegin);
+                assert anchorDuplicate.usages().isEmpty();
+
+                FixedNode next = anchorDuplicate.next();
+                anchorDuplicate.setNext(null);
+                ((FixedWithNextNode) forwardEnd.predecessor()).setNext(next);
+                anchorDuplicate.safeDelete();
 
                 // re-wire the phi duplicates to the correct input
                 for (PhiNode phi : phiSnapshot) {
@@ -315,19 +329,14 @@
         /**
          * Inserts a new ValueAnchorNode after the merge and transfers all dependency-usages (not
          * phis) to this ValueAnchorNode.
-         * 
+         *
          * @return The new {@link ValueAnchorNode} that was created.
          */
-        private ValueAnchorNode addValueAnchor() {
-            ValueAnchorNode anchor = graph.add(new ValueAnchorNode(null));
+        private DummyAnchorNode addValueAnchor() {
+            DummyAnchorNode anchor = graph.add(new DummyAnchorNode());
             graph.addAfterFixed(merge, anchor);
-            for (Node usage : merge.usages().snapshot()) {
-                if (usage instanceof PhiNode && ((PhiNode) usage).merge() == merge) {
-                    // nothing to do
-                } else {
-                    usage.replaceFirstInput(merge, anchor);
-                }
-            }
+            merge.replaceAtUsages(InputType.Guard, anchor);
+            merge.replaceAtUsages(InputType.Anchor, anchor);
             return anchor;
         }
 
@@ -335,7 +344,7 @@
          * Given a set of fixed nodes, this method determines the set of fixed and floating nodes
          * that needs to be duplicated, i.e., all nodes that due to data flow and other dependencies
          * needs to be duplicated.
-         * 
+         *
          * @param fixedNodes The set of fixed nodes that should be duplicated.
          * @param stateAfter The frame state of the merge that follows the set of fixed nodes. All
          *            {@link ValueNode}s reachable from this state are considered to be reachable
@@ -427,7 +436,7 @@
         /**
          * Creates a new merge and end node construct at the end of the duplicated area. While it is
          * useless in itself (merge with only one end) it simplifies the later duplication step.
-         * 
+         *
          * @param successor The successor of the duplicated set of nodes, i.e., the first node that
          *            should not be duplicated.
          * @param stateAfterMerge The frame state that should be used for the merge.
@@ -446,22 +455,18 @@
         /**
          * Expands the set of nodes to be duplicated by looking at a number of conditions:
          * <ul>
-         * <li>{@link ValueNode}s that have usages on the outside need to be replaced with phis for
-         * the outside usages.</li>
-         * <li>Non-{@link ValueNode} nodes that have outside usages (frame states, virtual object
-         * states, ...) need to be cloned immediately for the outside usages.</li>
-         * <li>Nodes that have a {@link StampFactory#extension()} or
-         * {@link StampFactory#condition()} stamp need to be cloned immediately for the outside
-         * usages.</li>
+         * <li>Inputs of type {@link InputType#Value} into the duplicated set will be rerouted to a
+         * new phi node.</li>
+         * <li>Inputs of type {@link InputType#Association}, {@link InputType#Condition} and
+         * {@link InputType#State} into the duplicated set will be rerouted to a duplicated version
+         * of the inside node.</li>
          * <li>Dependencies into the duplicated nodes will be replaced with dependencies on the
          * merge.</li>
-         * <li>Outside non-{@link ValueNode}s with usages within the duplicated set of nodes need to
-         * also be duplicated.</li>
-         * <li>Outside {@link ValueNode}s with {@link StampFactory#extension()} or
-         * {@link StampFactory#condition()} stamps that have usages within the duplicated set of
-         * nodes need to also be duplicated.</li>
+         * <li>Inputs of type {@link InputType#Association}, {@link InputType#Condition} and
+         * {@link InputType#State} to outside the duplicated set will cause the outside node to be
+         * pulled into the duplicated set.</li>
          * </ul>
-         * 
+         *
          * @param duplicatedNodes The set of duplicated nodes that will be modified (expanded).
          * @param newBottomMerge The merge that follows the duplicated set of nodes. It will be used
          *            for newly created phis and to as a target for dependencies that pointed into
@@ -472,91 +477,88 @@
 
             while (!worklist.isEmpty()) {
                 Node duplicated = worklist.remove();
-                if (hasUsagesOutside(duplicated, duplicatedNodes)) {
-                    boolean cloneForOutsideUsages = false;
-                    if (duplicated instanceof ValueNode) {
-                        ValueNode node = (ValueNode) duplicated;
-                        if (node.stamp() == StampFactory.dependency()) {
-                            // re-route dependencies to the merge
-                            replaceUsagesOutside(node, newBottomMerge, duplicatedNodes);
-                            // TODO(ls) maybe introduce phis for dependencies
-                        } else if (node.stamp() == StampFactory.extension() || node.stamp() == StampFactory.condition()) {
-                            cloneForOutsideUsages = true;
-                        } else {
-                            // introduce a new phi
-                            PhiNode newPhi = bottomPhis.get(node);
-                            if (newPhi == null) {
-                                newPhi = graph.addWithoutUnique(new PhiNode(node.stamp().unrestricted(), newBottomMerge));
-                                bottomPhis.put(node, newPhi);
-                                newPhi.addInput(node);
+                processUsages(duplicated, duplicatedNodes, newBottomMerge, worklist);
+                processInputs(duplicated, duplicatedNodes, worklist);
+            }
+        }
+
+        private void processUsages(Node duplicated, HashSet<Node> duplicatedNodes, MergeNode newBottomMerge, Deque<Node> worklist) {
+            HashSet<Node> unique = new HashSet<>();
+            duplicated.usages().snapshotTo(unique);
+            Node newOutsideClone = null;
+            for (Node usage : unique) {
+                if (!duplicatedNodes.contains(usage)) {
+                    NodeClassIterator iter = usage.inputs().iterator();
+                    while (iter.hasNext()) {
+                        Position pos = iter.nextPosition();
+                        if (pos.get(usage) == duplicated) {
+                            switch (pos.getInputType(usage)) {
+                                case Extension:
+                                case Condition:
+                                case State:
+                                    // clone the offending node to the outside
+                                    if (newOutsideClone == null) {
+                                        newOutsideClone = duplicated.copyWithInputs();
+                                        // this might cause other nodes to have outside usages
+                                        for (Node input : newOutsideClone.inputs()) {
+                                            if (duplicatedNodes.contains(input)) {
+                                                worklist.add(input);
+                                            }
+                                        }
+                                    }
+                                    pos.set(usage, newOutsideClone);
+                                    break;
+                                case Guard:
+                                case Anchor:
+                                    // re-route dependencies to the merge
+                                    pos.set(usage, newBottomMerge);
+                                    break;
+                                case Value:
+                                    // introduce a new phi
+                                    ValueNode node = (ValueNode) duplicated;
+                                    PhiNode newPhi = bottomPhis.get(node);
+                                    if (newPhi == null) {
+                                        newPhi = graph.addWithoutUnique(new ValuePhiNode(node.stamp().unrestricted(), newBottomMerge));
+                                        bottomPhis.put(node, newPhi);
+                                        newPhi.addInput(node);
+                                    }
+                                    pos.set(usage, newPhi);
+                                    break;
+                                case Association:
+                                default:
+                                    throw GraalInternalError.shouldNotReachHere();
                             }
-                            replaceUsagesOutside(node, newPhi, duplicatedNodes);
-                        }
-                    } else {
-                        cloneForOutsideUsages = true;
-                    }
-                    if (cloneForOutsideUsages) {
-                        // clone the offending node to the outside
-                        Node newOutsideClone = duplicated.copyWithInputs();
-                        replaceUsagesOutside(duplicated, newOutsideClone, duplicatedNodes);
-                        // this might cause other nodes to have outside usages, we need to look at
-                        // those as well
-                        for (Node input : newOutsideClone.inputs()) {
-                            if (duplicatedNodes.contains(input)) {
-                                worklist.add(input);
-                            }
-                        }
-                    }
-                }
-                // check if this node has an input that lies outside and cannot be shared
-                for (Node input : duplicated.inputs()) {
-                    if (!duplicatedNodes.contains(input)) {
-                        boolean duplicateInput = false;
-                        if (input instanceof VirtualState) {
-                            duplicateInput = true;
-                        } else if (input instanceof ValueNode) {
-                            Stamp inputStamp = ((ValueNode) input).stamp();
-                            if (inputStamp == StampFactory.extension() || inputStamp == StampFactory.condition()) {
-                                duplicateInput = true;
-                            }
-                        }
-                        if (duplicateInput) {
-                            duplicatedNodes.add(input);
-                            worklist.add(input);
                         }
                     }
                 }
             }
         }
 
-        /**
-         * Checks if the given node has usages that are not within the given set of nodes.
-         * 
-         * @param node The node whose usages are checked.
-         * @param nodeSet The set of nodes that are considered to be "within".
-         * @return true if the given node has usages on the outside, false otherwise.
-         */
-        private static boolean hasUsagesOutside(Node node, HashSet<Node> nodeSet) {
-            for (Node usage : node.usages()) {
-                if (!nodeSet.contains(usage)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        /**
-         * Replaces the given node with the given replacement at all usages that are not within the
-         * given set of nodes.
-         * 
-         * @param node The node to be replaced at outside usages.
-         * @param replacement The node that replaced the given node at outside usages.
-         * @param nodeSet The set of nodes that are considered to be "within".
-         */
-        private static void replaceUsagesOutside(Node node, Node replacement, HashSet<Node> nodeSet) {
-            for (Node usage : node.usages().snapshot()) {
-                if (!nodeSet.contains(usage)) {
-                    usage.replaceFirstInput(node, replacement);
+        private void processInputs(Node duplicated, HashSet<Node> duplicatedNodes, Deque<Node> worklist) {
+            // check if this node has an input that lies outside and cannot be shared
+            NodeClassIterator iter = duplicated.inputs().iterator();
+            while (iter.hasNext()) {
+                Position pos = iter.nextPosition();
+                Node input = pos.get(duplicated);
+                if (input != null && !duplicatedNodes.contains(input)) {
+                    switch (pos.getInputType(duplicated)) {
+                        case Extension:
+                        case Condition:
+                        case State:
+                            if (input != merge) {
+                                duplicatedNodes.add(input);
+                                worklist.add(input);
+                            }
+                            break;
+                        case Association:
+                        case Guard:
+                        case Anchor:
+                        case Value:
+                            // no change needed
+                            break;
+                        default:
+                            throw GraalInternalError.shouldNotReachHere();
+                    }
                 }
             }
         }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeChangeListener.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/util/HashSetNodeChangeListener.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,8 @@
 
 import java.util.*;
 
+import com.oracle.graal.graph.Graph.NodeChangedListener;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Graph.*;
 
 /**
  * A simple {@link NodeChangedListener} implementation that accumulates the changed nodes in a
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeInliningRelevanceClosure.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeInliningRelevanceClosure.java	Wed Apr 16 14:02:52 2014 +0200
@@ -105,26 +105,26 @@
         private Scope[] computeScopes() {
             ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, false, false);
 
-            Loop[] loops = cfg.getLoops();
-            HashMap<Loop, Scope> processedScopes = new HashMap<>();
-            Scope[] result = new Scope[loops.length + 1];
+            List<Loop<Block>> loops = cfg.getLoops();
+            HashMap<Loop<Block>, Scope> processedScopes = new HashMap<>();
+            Scope[] result = new Scope[loops.size() + 1];
             Scope methodScope = new Scope(graph.start(), null);
             processedScopes.put(null, methodScope);
 
             result[0] = methodScope;
-            for (int i = 0; i < loops.length; i++) {
-                result[i + 1] = createScope(loops[i], processedScopes);
+            for (int i = 0; i < loops.size(); i++) {
+                result[i + 1] = createScope(loops.get(i), processedScopes);
             }
 
             return result;
         }
 
-        private Scope createScope(Loop loop, HashMap<Loop, Scope> processedLoops) {
+        private Scope createScope(Loop<Block> loop, HashMap<Loop<Block>, Scope> processedLoops) {
             Scope parent = processedLoops.get(loop.parent);
             if (parent == null) {
                 parent = createScope(loop.parent, processedLoops);
             }
-            Scope result = new Scope(loop.loopBegin(), parent);
+            Scope result = new Scope(loop.header.getBeginNode(), parent);
             processedLoops.put(loop, result);
             return result;
         }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/InferStamps.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/InferStamps.java	Wed Apr 16 14:02:52 2014 +0200
@@ -47,10 +47,10 @@
          * when the phi function performs the "meet" operator on its input stamps.
          */
         for (Node n : graph.getNodes()) {
-            if (n instanceof PhiNode || n instanceof ValueAndStampProxy) {
+            if (n instanceof ValuePhiNode || n instanceof ValueAndStampProxy) {
                 ValueNode node = (ValueNode) n;
-                if (ObjectStamp.isObject(node.stamp())) {
-                    assert !(node.stamp() instanceof IllegalStamp) : "We assume all Phi and Proxy stamps are legal before the analysis";
+                if (node.stamp() instanceof ObjectStamp) {
+                    assert node.stamp().isLegal() : "We assume all Phi and Proxy stamps are legal before the analysis";
                     node.setStamp(node.stamp().illegal());
                 }
             }
@@ -68,7 +68,7 @@
             for (Node n : graph.getNodes()) {
                 if (n instanceof ValueNode) {
                     ValueNode node = (ValueNode) n;
-                    if (ObjectStamp.isObject(node.stamp())) {
+                    if (node.stamp() instanceof ObjectStamp) {
                         stampChanged |= node.inferStamp();
                     }
                 }
@@ -84,7 +84,7 @@
 
     private static boolean checkNoIllegalStamp(StructuredGraph graph) {
         for (Node n : graph.getNodes()) {
-            if (n instanceof PhiNode || n instanceof ValueAndStampProxy) {
+            if (n instanceof ValuePhiNode || n instanceof ValueAndStampProxy) {
                 ValueNode node = (ValueNode) n;
                 assert !(node.stamp() instanceof IllegalStamp) : "Stamp is illegal after analysis. This is not necessarily an error, but a condition that we want to investigate (and then maybe relax or remove the assertion).";
             }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -45,14 +45,14 @@
 
         protected abstract StateT cloneState(StateT oldState);
 
-        protected abstract List<StateT> processLoop(Loop loop, StateT initialState);
+        protected abstract List<StateT> processLoop(Loop<Block> loop, StateT initialState);
     }
 
     private ReentrantBlockIterator() {
         // no instances allowed
     }
 
-    public static <StateT> LoopInfo<StateT> processLoop(BlockIteratorClosure<StateT> closure, Loop loop, StateT initialState) {
+    public static <StateT> LoopInfo<StateT> processLoop(BlockIteratorClosure<StateT> closure, Loop<Block> loop, StateT initialState) {
         IdentityHashMap<FixedNode, StateT> blockEndStates = apply(closure, loop.header, initialState, new HashSet<>(loop.blocks));
 
         LoopInfo<StateT> info = new LoopInfo<>();
@@ -101,8 +101,8 @@
                             states.put(current.getEndNode(), state);
                         } else {
                             // recurse into the loop
-                            Loop loop = successor.getLoop();
-                            LoopBeginNode loopBegin = loop.loopBegin();
+                            Loop<Block> loop = successor.getLoop();
+                            LoopBeginNode loopBegin = (LoopBeginNode) loop.header.getBeginNode();
                             assert successor.getBeginNode() == loopBegin;
 
                             List<StateT> exitStates = closure.processLoop(loop, state);
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -152,7 +152,7 @@
         }
 
         @Override
-        protected List<KillSet> processLoop(Loop loop, KillSet state) {
+        protected List<KillSet> processLoop(Loop<Block> loop, KillSet state) {
             LoopInfo<KillSet> info = ReentrantBlockIterator.processLoop(this, loop, cloneState(state));
 
             assert loop.header.getBeginNode() instanceof LoopBeginNode;
@@ -345,7 +345,7 @@
             buf.format(", lastAccess: %s", frn.getLastLocationAccess());
             buf.format(", object: %s", frn.object());
         } else if (n instanceof GuardNode) {
-            buf.format(", guard: %s", ((GuardNode) n).getGuard());
+            buf.format(", anchor: %s", ((GuardNode) n).getAnchor());
         }
         Debug.log("%s", buf);
     }
@@ -649,7 +649,7 @@
          * implies that the inputs' blocks have a total ordering via their dominance relation. So in
          * order to find the earliest block placement for this node we need to find the input block
          * that is dominated by all other input blocks.
-         * 
+         *
          * While iterating over the inputs a set of dominator blocks of the current earliest
          * placement is maintained. When the block of an input is not within this set, it becomes
          * the current earliest placement and the list of dominator blocks is updated.
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,9 +29,10 @@
 import com.oracle.graal.nodes.VirtualState.NodeClosure;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.phases.graph.*;
-import com.oracle.graal.phases.graph.ReentrantBlockIterator.*;
+import com.oracle.graal.phases.graph.ReentrantBlockIterator.BlockIteratorClosure;
 import com.oracle.graal.phases.schedule.*;
-import com.oracle.graal.phases.schedule.SchedulePhase.*;
+import com.oracle.graal.phases.schedule.SchedulePhase.MemoryScheduling;
+import com.oracle.graal.phases.schedule.SchedulePhase.SchedulingStrategy;
 
 public final class GraphOrder {
 
@@ -42,7 +43,7 @@
      * Quick (and imprecise) assertion that there are no (invalid) cycles in the given graph. First,
      * an ordered list of all nodes in the graph (a total ordering) is created. A second run over
      * this list checks whether inputs are scheduled before their usages.
-     * 
+     *
      * @param graph the graph to be checked.
      * @throws AssertionError if a cycle was detected.
      */
@@ -60,13 +61,7 @@
                         if (input instanceof FrameState && node instanceof StateSplit && input == ((StateSplit) node).stateAfter()) {
                             // nothing to do - after frame states are known, allowed cycles
                         } else {
-                            /*
-                             * TODO assertion does not hold for Substrate VM (in general for all
-                             * notDataflow inputs)
-                             * 
-                             * assert false : "unexpected cycle detected at input " + node + " -> "
-                             * + input;
-                             */
+                            assert false : "unexpected cycle detected at input " + node + " -> " + input;
                         }
                     }
                 }
@@ -132,7 +127,7 @@
     /**
      * This method schedules the graph and makes sure that, for every node, all inputs are available
      * at the position where it is scheduled. This is a very expensive assertion.
-     * 
+     *
      * Also, this phase assumes ProxyNodes to exist at LoopExitNodes, so that it cannot be run after
      * phases that remove loop proxies or move proxies to BeginNodes.
      */
@@ -145,7 +140,7 @@
             BlockIteratorClosure<NodeBitMap> closure = new BlockIteratorClosure<NodeBitMap>() {
 
                 @Override
-                protected List<NodeBitMap> processLoop(Loop loop, NodeBitMap initialState) {
+                protected List<NodeBitMap> processLoop(Loop<Block> loop, NodeBitMap initialState) {
                     return ReentrantBlockIterator.processLoop(this, loop, initialState).exitStates;
                 }
 
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -282,7 +282,7 @@
         } else if (object instanceof Enum<?>) {
             writeByte(POOL_ENUM);
             writePoolObject(object.getClass());
-            writeInt(((Enum) object).ordinal());
+            writeInt(((Enum<?>) object).ordinal());
         } else if (object instanceof JavaType) {
             JavaType type = (JavaType) object;
             writeByte(POOL_CLASS);
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,6 +37,7 @@
 import com.oracle.graal.graph.NodeClass.NodeClassIterator;
 import com.oracle.graal.graph.NodeClass.Position;
 import com.oracle.graal.java.*;
+import com.oracle.graal.java.BciBlockMapping.BciBlock;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
@@ -53,10 +54,11 @@
     protected NodeLIRBuilder nodeLirGenerator;
     protected ControlFlowGraph cfg;
     protected SchedulePhase schedule;
+    protected ResolvedJavaMethod method;
 
     /**
      * Creates a control flow graph printer.
-     * 
+     *
      * @param out where the output generated via this printer shown be written
      */
     public CFGPrinter(OutputStream out) {
@@ -65,7 +67,7 @@
 
     /**
      * Prints the control flow graph denoted by a given block map.
-     * 
+     *
      * @param label A label describing the compilation phase that produced the control flow graph.
      * @param blockMap A data structure describing the blocks in a method and how they are
      *            connected.
@@ -125,7 +127,7 @@
 
     /**
      * Prints the specified list of blocks.
-     * 
+     *
      * @param label A label describing the compilation phase that produced the control flow graph.
      * @param blocks The list of blocks to be printed.
      */
@@ -154,12 +156,18 @@
             printBlock(block, printNodes);
         }
         end("cfg");
+        // NOTE: we do this only because the c1visualizer does not recognize the bytecode block if
+        // it is proceeding the cfg blocks. Currently we have no direct influence on the emit order.
+        // As a workaround we dump the bytecode after every cfg.
+        if (method != null) {
+            printBytecodes(new BytecodeDisassembler(false).disassemble(method));
+        }
 
         latestScheduling = null;
     }
 
     private void scheduleInputs(Node node, Block nodeBlock) {
-        if (node instanceof PhiNode) {
+        if (node instanceof ValuePhiNode) {
             PhiNode phi = (PhiNode) node;
             assert nodeBlock.getBeginNode() == phi.merge();
             for (Block pred : nodeBlock.getPredecessors()) {
@@ -204,8 +212,13 @@
         begin("block");
 
         out.print("name \"").print(blockToString(block)).println('"');
-        out.println("from_bci -1");
-        out.println("to_bci -1");
+        if (block instanceof BciBlock) {
+            out.print("from_bci ").println(((BciBlock) block).startBci);
+            out.print("to_bci ").println(((BciBlock) block).endBci);
+        } else {
+            out.println("from_bci -1");
+            out.println("to_bci -1");
+        }
 
         out.print("predecessors ");
         for (AbstractBlock<?> pred : block.getPredecessors()) {
@@ -289,7 +302,7 @@
         assert !printedNodes.isMarked(node);
         printedNodes.mark(node);
 
-        if (!(node instanceof PhiNode)) {
+        if (!(node instanceof ValuePhiNode)) {
             for (Node input : node.inputs()) {
                 if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
                     printNode(input, true);
@@ -425,7 +438,7 @@
 
     /**
      * Prints the LIR for each instruction in a given block.
-     * 
+     *
      * @param block the block to print
      */
     private void printLIR(AbstractBlock<?> block) {
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Wed Apr 16 14:02:52 2014 +0200
@@ -131,6 +131,9 @@
         if (!checkMethodScope()) {
             return;
         }
+        if (curMethod instanceof ResolvedJavaMethod) {
+            cfgPrinter.method = (ResolvedJavaMethod) curMethod;
+        }
 
         if (object instanceof LIR) {
             cfgPrinter.lir = (LIR) object;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.CodeUtil.*;
+import com.oracle.graal.api.code.CodeUtil.RefMapFormatter;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -136,6 +136,13 @@
                 printer = xmlPrinter;
             }
             TTY.println("Connected to the IGV on %s:%d", host, port);
+        } catch (ClosedByInterruptException | InterruptedIOException e) {
+            /*
+             * Interrupts should not count as errors because they may be caused by a cancelled Graal
+             * compilation. ClosedByInterruptException occurs if the SocketChannel could not be
+             * opened. InterruptedIOException occurs if new Socket(..) was interrupted.
+             */
+            printer = null;
         } catch (IOException e) {
             TTY.println("Could not connect to the IGV on %s:%d : %s", host, port, e);
             failuresCount++;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java	Wed Apr 16 14:02:52 2014 +0200
@@ -39,23 +39,23 @@
  *
  * <pre>
  *     HexCodeFile ::= Platform Delim HexCode Delim (OptionalSection Delim)*
- * 
+ *
  *     OptionalSection ::= Comment | OperandComment | JumpTable | LookupTable
- * 
+ *
  *     Platform ::= "Platform" ISA WordWidth
- * 
+ *
  *     HexCode ::= "HexCode" StartAddress HexDigits
- * 
+ *
  *     Comment ::= "Comment" Position String
- * 
+ *
  *     OperandComment ::= "OperandComment" Position String
- * 
+ *
  *     JumpTable ::= "JumpTable" Position EntrySize Low High
- * 
+ *
  *     LookupTable ::= "LookupTable" Position NPairs KeySize OffsetSize
- * 
+ *
  *     Position, EntrySize, Low, High, NPairs KeySize OffsetSize ::= int
- * 
+ *
  *     Delim := "&lt;||@"
  * </pre>
  *
@@ -184,15 +184,19 @@
      * Formats a byte array as a string of hex digits.
      */
     public static String hexCodeString(byte[] code) {
-        StringBuilder sb = new StringBuilder(code.length * 2);
-        for (int b : code) {
-            String hex = Integer.toHexString(b & 0xff);
-            if (hex.length() == 1) {
-                sb.append('0');
+        if (code == null) {
+            return "";
+        } else {
+            StringBuilder sb = new StringBuilder(code.length * 2);
+            for (int b : code) {
+                String hex = Integer.toHexString(b & 0xff);
+                if (hex.length() == 1) {
+                    sb.append('0');
+                }
+                sb.append(hex);
             }
-            sb.append(hex);
+            return sb.toString();
         }
-        return sb.toString();
     }
 
     /**
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java	Wed Apr 16 14:02:52 2014 +0200
@@ -46,7 +46,7 @@
 
     /**
      * Creates a new {@link IdealGraphPrinter} that writes to the specified output stream.
-     * 
+     *
      * @param tryToSchedule If false, no scheduling is done, which avoids exceptions for
      *            non-schedulable graphs.
      */
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,6 +26,7 @@
 import static com.oracle.graal.replacements.SnippetTemplate.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
@@ -49,7 +50,7 @@
      * conversion. If the float value is a NaN, infinity or if the result of the conversion is
      * larger than {@link Integer#MAX_VALUE} then CVTTSS2SI returns {@link Integer#MIN_VALUE} and
      * extra tests are required on the float value to return the correct int value.
-     * 
+     *
      * @param input the float being converted
      * @param result the result produced by the CVTTSS2SI instruction
      */
@@ -74,7 +75,7 @@
      * conversion. If the float value is a NaN or infinity then CVTTSS2SI returns
      * {@link Long#MIN_VALUE} and extra tests are required on the float value to return the correct
      * long value.
-     * 
+     *
      * @param input the float being converted
      * @param result the result produced by the CVTTSS2SI instruction
      */
@@ -99,7 +100,7 @@
      * conversion. If the double value is a NaN, infinity or if the result of the conversion is
      * larger than {@link Integer#MAX_VALUE} then CVTTSD2SI returns {@link Integer#MIN_VALUE} and
      * extra tests are required on the double value to return the correct int value.
-     * 
+     *
      * @param input the double being converted
      * @param result the result produced by the CVTTSS2SI instruction
      */
@@ -124,7 +125,7 @@
      * conversion. If the double value is a NaN, infinity or if the result of the conversion is
      * larger than {@link Long#MAX_VALUE} then CVTTSD2SI returns {@link Long#MIN_VALUE} and extra
      * tests are required on the double value to return the correct long value.
-     * 
+     *
      * @param input the double being converted
      * @param result the result produced by the CVTTSS2SI instruction
      */
@@ -149,8 +150,8 @@
         private final SnippetInfo d2i;
         private final SnippetInfo d2l;
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) {
+            super(providers, snippetReflection, target);
 
             f2i = snippet(AMD64ConvertSnippets.class, "f2i");
             f2l = snippet(AMD64ConvertSnippets.class, "f2l");
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,19 +22,15 @@
  */
 package com.oracle.graal.replacements.hsail;
 
-import com.oracle.graal.api.meta.Constant;
-import com.oracle.graal.api.meta.Value;
-import com.oracle.graal.compiler.hsail.HSAILLIRGenerator;
-import com.oracle.graal.graph.GraalInternalError;
-import com.oracle.graal.graph.Node;
-import com.oracle.graal.graph.spi.Canonicalizable;
-import com.oracle.graal.graph.spi.CanonicalizerTool;
-import com.oracle.graal.lir.hsail.HSAILArithmetic;
-import com.oracle.graal.nodes.calc.FloatingNode;
-import com.oracle.graal.nodes.ConstantNode;
-import com.oracle.graal.nodes.ValueNode;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.hsail.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.lir.hsail.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.StampFactory;
+import com.oracle.graal.nodes.type.*;
 
 /**
  * This node implements HSAIL intrinsics for specific {@link Math} routines.
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,8 @@
  */
 package com.oracle.graal.replacements.hsail;
 
-import com.oracle.graal.api.replacements.ClassSubstitution;
-import com.oracle.graal.api.replacements.MethodSubstitution;
-import com.oracle.graal.lir.hsail.HSAILArithmetic;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.lir.hsail.*;
 
 /**
  * Substitutions for {@link Math} methods. For any calls to the routines listed below and annotated
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CheckCastTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CheckCastTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,9 +23,9 @@
 package com.oracle.graal.replacements.test;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.test.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.test.*;
 
 /**
  * Tests the implementation of checkcast, allowing profiling information to be manually specified.
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfDynamicTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfDynamicTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,9 +22,9 @@
  */
 package com.oracle.graal.replacements.test;
 
-import com.oracle.graal.test.*;
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.test.*;
 
 /**
  * Tests for {@link InstanceOfDynamicNode}.
@@ -82,11 +82,11 @@
         return o.getClass().getName().length();
     }
 
-    public static boolean isInstanceDynamic(Class c, Object o) {
+    public static boolean isInstanceDynamic(Class<?> c, Object o) {
         return c.isInstance(o);
     }
 
-    public static int isInstanceIntDynamic(Class c, Object o) {
+    public static int isInstanceIntDynamic(Class<?> c, Object o) {
         if (c.isInstance(o)) {
             return o.toString().length();
         }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/InstanceOfTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -116,7 +116,7 @@
 
     @LongTest
     public void test5() {
-        Map map = new HashMap<>();
+        Map<?, ?> map = new HashMap<>();
         test("isMap", profile(), map);
         test("isMap", profile(HashMap.class), map);
         test("isMap", profile(TreeMap.class, HashMap.class), map);
@@ -129,7 +129,7 @@
 
     @LongTest
     public void test6() {
-        Map map = new HashMap<>();
+        Map<?, ?> map = new HashMap<>();
         test("isMapInt", profile(), map);
         test("isMapInt", profile(HashMap.class), map);
         test("isMapInt", profile(TreeMap.class, HashMap.class), map);
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewInstanceTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewInstanceTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -135,8 +135,8 @@
         return new String(value);
     }
 
-    public static HashMap newHashMap(int initialCapacity) {
-        return new HashMap(initialCapacity);
+    public static HashMap<?, ?> newHashMap(int initialCapacity) {
+        return new HashMap<>(initialCapacity);
     }
 
     static class SomeObject {
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewMultiArrayTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewMultiArrayTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,9 +28,9 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.test.*;
-import com.oracle.graal.test.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.test.*;
 
 /**
  * Tests the lowering of the MULTIANEWARRAY instruction.
@@ -83,12 +83,12 @@
 
     ResolvedJavaType arrayType;
     ResolvedJavaType bottomType;
-    Class bottomClass;
+    Class<?> bottomClass;
     int[] dimensions;
 
     @LongTest
     public void test1() {
-        for (Class clazz : new Class[]{byte.class, char.class, short.class, int.class, float.class, long.class, double.class, String.class}) {
+        for (Class<?> clazz : new Class[]{byte.class, char.class, short.class, int.class, float.class, long.class, double.class, String.class}) {
             bottomClass = clazz;
             bottomType = getMetaAccess().lookupJavaType(clazz);
             arrayType = bottomType;
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,7 @@
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ReplacementsImpl.*;
+import com.oracle.graal.replacements.ReplacementsImpl.FrameStateProcessing;
 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy;
 import com.oracle.graal.word.*;
 
@@ -47,7 +47,7 @@
     private final ReplacementsImpl installer;
 
     public ObjectAccessTest() {
-        installer = new ReplacementsImpl(getProviders(), new Assumptions(false), getTarget());
+        installer = new ReplacementsImpl(getProviders(), getSnippetReflection(), new Assumptions(false), getTarget());
     }
 
     private static final ThreadLocal<SnippetInliningPolicy> inliningPolicy = new ThreadLocal<>();
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,7 +36,7 @@
 import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ReplacementsImpl.*;
+import com.oracle.graal.replacements.ReplacementsImpl.FrameStateProcessing;
 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy;
 import com.oracle.graal.word.*;
 import com.oracle.graal.word.nodes.*;
@@ -53,7 +53,7 @@
 
     public PointerTest() {
         target = getCodeCache().getTarget();
-        installer = new ReplacementsImpl(getProviders(), new Assumptions(false), getTarget());
+        installer = new ReplacementsImpl(getProviders(), getSnippetReflection(), new Assumptions(false), getTarget());
     }
 
     private static final ThreadLocal<SnippetInliningPolicy> inliningPolicy = new ThreadLocal<>();
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -173,8 +173,8 @@
         assertEquals(unsafe.compareAndSwapLong(l1, off(l1, "value"), 42, 53), compareAndSwapLong(unsafe, l2, off(l2, "value"), 42, 53));
         assertEquals(l1.get(), l2.get());
 
-        AtomicReference o1 = new AtomicReference<>("42");
-        AtomicReference o2 = new AtomicReference<>("42");
+        AtomicReference<String> o1 = new AtomicReference<>("42");
+        AtomicReference<String> o2 = new AtomicReference<>("42");
         assertEquals(unsafe.compareAndSwapObject(o1, off(o1, "value"), "42", "53"), compareAndSwapObject(unsafe, o2, off(o2, "value"), "42", "53"));
         assertEquals(o1.get(), o2.get());
 
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/TypeCheckTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/TypeCheckTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -48,11 +48,11 @@
         return super.getCode(method, graph, forceCompile);
     }
 
-    protected JavaTypeProfile profile(Class... types) {
+    protected JavaTypeProfile profile(Class<?>... types) {
         return profile(TriState.FALSE, types);
     }
 
-    protected JavaTypeProfile profile(TriState nullSeen, Class... types) {
+    protected JavaTypeProfile profile(TriState nullSeen, Class<?>... types) {
         if (types.length == 0) {
             return null;
         }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,7 @@
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.ReplacementsImpl.*;
+import com.oracle.graal.replacements.ReplacementsImpl.FrameStateProcessing;
 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy;
 import com.oracle.graal.test.*;
 import com.oracle.graal.word.*;
@@ -42,7 +42,7 @@
     private final ReplacementsImpl installer;
 
     public WordTest() {
-        installer = new ReplacementsImpl(getProviders(), new Assumptions(false), getTarget());
+        installer = new ReplacementsImpl(getProviders(), getSnippetReflection(), new Assumptions(false), getTarget());
     }
 
     private static final ThreadLocal<SnippetInliningPolicy> inliningPolicy = new ThreadLocal<>();
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/APHotSpotSignature.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/APHotSpotSignature.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,7 +27,7 @@
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
 import javax.lang.model.type.*;
-import javax.tools.Diagnostic.*;
+import javax.tools.Diagnostic.Kind;
 
 /**
  * Pretty much copied from HotSpotSignature but using a different method for resolving types. This
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/ClassSubstitutionVerifier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,7 +27,7 @@
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
 import javax.lang.model.type.*;
-import javax.tools.Diagnostic.*;
+import javax.tools.Diagnostic.Kind;
 
 import com.oracle.graal.api.replacements.*;
 
--- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/MethodSubstitutionVerifier.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/MethodSubstitutionVerifier.java	Wed Apr 16 14:02:52 2014 +0200
@@ -89,17 +89,17 @@
         }
 
         String originalName = originalName(substitutionMethod, annotation);
-        TypeMirror[] originalSignature = originalSignature(substitutionMethod, annotation);
+        TypeMirror[] originalSignature = originalSignature(originalType, substitutionMethod, annotation);
         if (originalSignature == null) {
             return;
         }
         ExecutableElement originalMethod = originalMethod(substitutionMethod, annotation, originalType, originalName, originalSignature);
         if (DEBUG && originalMethod != null) {
-            env.getMessager().printMessage(Kind.ERROR, String.format("Found original method %s in type %s.", originalMethod, findEnclosingClass(originalMethod)));
+            env.getMessager().printMessage(Kind.NOTE, String.format("Found original method %s in type %s.", originalMethod, findEnclosingClass(originalMethod)));
         }
     }
 
-    private TypeMirror[] originalSignature(ExecutableElement method, AnnotationMirror annotation) {
+    private TypeMirror[] originalSignature(TypeElement originalType, ExecutableElement method, AnnotationMirror annotation) {
         boolean isStatic = resolveAnnotationValue(Boolean.class, findAnnotationValue(annotation, ORIGINAL_IS_STATIC));
         AnnotationValue signatureValue = findAnnotationValue(annotation, ORIGINAL_SIGNATURE);
         String signatureString = resolveAnnotationValue(String.class, signatureValue);
@@ -113,7 +113,11 @@
                     env.getMessager().printMessage(Kind.ERROR, "Method signature must be a static method with the 'this' object as its first parameter", method, annotation);
                     return null;
                 } else {
-                    parameters.remove(0);
+                    TypeMirror thisParam = parameters.remove(0);
+                    if (!isSubtype(originalType.asType(), thisParam)) {
+                        Name thisName = method.getParameters().get(0).getSimpleName();
+                        env.getMessager().printMessage(Kind.ERROR, String.format("The type of %s must assignable from %s", thisName, originalType), method, annotation);
+                    }
                 }
             }
             parameters.add(0, method.getReturnType());
@@ -201,6 +205,26 @@
         return env.getTypeUtils().isSameType(original, substitution);
     }
 
+    /**
+     * Tests whether one type is a subtype of another. Any type is considered to be a subtype of
+     * itself.
+     *
+     * @param t1 the first type
+     * @param t2 the second type
+     * @return {@code true} if and only if the first type is a subtype of the second
+     */
+    private boolean isSubtype(TypeMirror t1, TypeMirror t2) {
+        TypeMirror t1Erased = t1;
+        TypeMirror t2Erased = t2;
+        if (needsErasure(t1Erased)) {
+            t1Erased = env.getTypeUtils().erasure(t1Erased);
+        }
+        if (needsErasure(t2Erased)) {
+            t2Erased = env.getTypeUtils().erasure(t2Erased);
+        }
+        return env.getTypeUtils().isSubtype(t1Erased, t2Erased);
+    }
+
     private static boolean needsErasure(TypeMirror typeMirror) {
         return typeMirror.getKind() != TypeKind.NONE && typeMirror.getKind() != TypeKind.VOID && !typeMirror.getKind().isPrimitive() && typeMirror.getKind() != TypeKind.OTHER &&
                         typeMirror.getKind() != TypeKind.NULL;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,6 +30,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.*;
@@ -173,30 +174,13 @@
         return value.shortValue();
     }
 
-    public static FloatingNode canonicalizeBoxing(BoxNode box, MetaAccessProvider metaAccess) {
+    public static FloatingNode canonicalizeBoxing(BoxNode box, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) {
         ValueNode value = box.getValue();
         if (value.isConstant()) {
             Constant sourceConstant = value.asConstant();
-            switch (box.getBoxingKind()) {
-                case Boolean:
-                    return ConstantNode.forObject(Boolean.valueOf(sourceConstant.asInt() != 0), metaAccess, box.graph());
-                case Byte:
-                    return ConstantNode.forObject(Byte.valueOf((byte) sourceConstant.asInt()), metaAccess, box.graph());
-                case Char:
-                    return ConstantNode.forObject(Character.valueOf((char) sourceConstant.asInt()), metaAccess, box.graph());
-                case Short:
-                    return ConstantNode.forObject(Short.valueOf((short) sourceConstant.asInt()), metaAccess, box.graph());
-                case Int:
-                    return ConstantNode.forObject(Integer.valueOf(sourceConstant.asInt()), metaAccess, box.graph());
-                case Long:
-                    return ConstantNode.forObject(Long.valueOf(sourceConstant.asLong()), metaAccess, box.graph());
-                case Float:
-                    return ConstantNode.forObject(Float.valueOf(sourceConstant.asFloat()), metaAccess, box.graph());
-                case Double:
-                    return ConstantNode.forObject(Double.valueOf(sourceConstant.asDouble()), metaAccess, box.graph());
-                default:
-                    assert false : "Unexpected source kind for boxing";
-                    break;
+            Constant boxedConstant = constantReflection.boxPrimitive(sourceConstant);
+            if (boxedConstant != null && boxedConstant.getKind() == box.getBoxingKind()) {
+                return ConstantNode.forConstant(boxedConstant, metaAccess, box.graph());
             }
         }
         return null;
@@ -207,8 +191,8 @@
         private final EnumMap<Kind, SnippetInfo> boxSnippets = new EnumMap<>(Kind.class);
         private final EnumMap<Kind, SnippetInfo> unboxSnippets = new EnumMap<>(Kind.class);
 
-        public Templates(Providers providers, TargetDescription target) {
-            super(providers, target);
+        public Templates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) {
+            super(providers, snippetReflection, target);
             for (Kind kind : new Kind[]{Kind.Boolean, Kind.Byte, Kind.Char, Kind.Double, Kind.Float, Kind.Int, Kind.Long, Kind.Short}) {
                 boxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "ValueOf"));
                 unboxSnippets.put(kind, snippet(BoxingSnippets.class, kind.getJavaName() + "Value"));
@@ -216,7 +200,7 @@
         }
 
         public void lower(BoxNode box, LoweringTool tool) {
-            FloatingNode canonical = canonicalizeBoxing(box, providers.getMetaAccess());
+            FloatingNode canonical = canonicalizeBoxing(box, providers.getMetaAccess(), providers.getConstantReflection());
             // if in AOT mode, we don't want to embed boxed constants.
             if (canonical != null && !ImmutableCode.getValue()) {
                 box.graph().replaceFloating(box, canonical);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CompositeValueClassSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.replacements;
-
-import static com.oracle.graal.phases.GraalOptions.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.replacements.nodes.*;
-
-/**
- * Substitutions for improving the performance of {@link CompositeValueClass#getClass()}.
- */
-@ClassSubstitution(CompositeValueClass.class)
-public class CompositeValueClassSubstitutions {
-
-    /**
-     * A macro node for calls to {@link CompositeValueClass#get(Class)}. It can use the compiler's
-     * knowledge about node classes to replace itself with a constant value for a constant
-     * {@link Class} parameter.
-     */
-    public static class CompositeValueClassGetNode extends PureFunctionMacroNode {
-
-        public CompositeValueClassGetNode(Invoke invoke) {
-            super(invoke);
-        }
-
-        @SuppressWarnings("unchecked")
-        @Override
-        protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
-            if (param.isNull() || ImmutableCode.getValue()) {
-                return null;
-            }
-            return Constant.forObject(CompositeValueClass.get((Class<? extends CompositeValue>) param.asObject()));
-        }
-    }
-
-    @MacroSubstitution(isStatic = true, forced = true, macro = CompositeValueClassGetNode.class)
-    private static native CompositeValueClass get(Class<?> c);
-}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -50,8 +50,6 @@
             replacements.registerSubstitutions(CharacterSubstitutions.class);
             replacements.registerSubstitutions(ShortSubstitutions.class);
             replacements.registerSubstitutions(UnsignedMathSubstitutions.class);
-            replacements.registerSubstitutions(NodeClassSubstitutions.class);
-            replacements.registerSubstitutions(CompositeValueClassSubstitutions.class);
         }
     }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
@@ -179,16 +180,16 @@
     /**
      * Rewrite all word types in the graph.
      */
-    public void rewriteWordTypes() {
-        new WordTypeRewriterPhase(providers.getMetaAccess(), providers.getCodeCache().getTarget().wordKind).apply(graph);
+    public void rewriteWordTypes(SnippetReflectionProvider snippetReflection) {
+        new WordTypeRewriterPhase(providers.getMetaAccess(), snippetReflection, providers.getCodeCache().getTarget().wordKind).apply(graph);
     }
 
     /**
-     * {@linkplain #inline(InvokeNode) Inlines} all invocations currently in the graph.
+     * {@linkplain #inline Inlines} all invocations currently in the graph.
      */
-    public void inlineInvokes() {
+    public void inlineInvokes(SnippetReflectionProvider snippetReflection) {
         for (InvokeNode invoke : graph.getNodes().filter(InvokeNode.class).snapshot()) {
-            inline(invoke);
+            inline(invoke, snippetReflection);
         }
 
         // Clean up all code that is now dead after inlining.
@@ -201,9 +202,9 @@
      * {@linkplain ReplacementsImpl#makeGraph processed} in the same manner as for snippets and
      * method substitutions.
      */
-    public void inline(InvokeNode invoke) {
+    public void inline(InvokeNode invoke, SnippetReflectionProvider snippetReflection) {
         ResolvedJavaMethod method = ((MethodCallTargetNode) invoke.callTarget()).targetMethod();
-        ReplacementsImpl repl = new ReplacementsImpl(providers, new Assumptions(false), providers.getCodeCache().getTarget());
+        ReplacementsImpl repl = new ReplacementsImpl(providers, snippetReflection, new Assumptions(false), providers.getCodeCache().getTarget());
         StructuredGraph calleeGraph = repl.makeGraph(method, null, method, null, FrameStateProcessing.CollapseFrameForSingleSideEffect);
         InliningUtil.inline(invoke, calleeGraph, false);
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 import java.util.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
@@ -53,8 +54,8 @@
  */
 public abstract class InstanceOfSnippetsTemplates extends AbstractTemplates {
 
-    public InstanceOfSnippetsTemplates(Providers providers, TargetDescription target) {
-        super(providers, target);
+    public InstanceOfSnippetsTemplates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) {
+        super(providers, snippetReflection, target);
     }
 
     /**
@@ -130,7 +131,7 @@
 
         /**
          * Gets the result of this instantiation as a condition.
-         * 
+         *
          * @param testValue the returned condition is true if the result is equal to this value
          */
         LogicNode asCondition(ValueNode testValue) {
@@ -148,7 +149,7 @@
 
         /**
          * Gets the result of the instantiation as a materialized value.
-         * 
+         *
          * @param t the true value for the materialization
          * @param f the false value for the materialization
          */
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeClassSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,15 +22,11 @@
  */
 package com.oracle.graal.replacements;
 
-import static com.oracle.graal.phases.GraalOptions.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.replacements.nodes.*;
 
 /**
  * Substitutions for improving the performance of some critical methods in {@link NodeClass}
@@ -42,33 +38,13 @@
 @ClassSubstitution(NodeClass.class)
 public class NodeClassSubstitutions {
 
-    /**
-     * A macro node for calls to {@link NodeClass#get(Class)}. It can use the compiler's knowledge
-     * about node classes to replace itself with a constant value for a constant {@link Class}
-     * parameter.
-     */
-    public static class NodeClassGetNode extends PureFunctionMacroNode {
-
-        public NodeClassGetNode(Invoke invoke) {
-            super(invoke);
-        }
-
-        @Override
-        protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
-            return param.isNull() || ImmutableCode.getValue() ? null : Constant.forObject(NodeClass.get((Class<?>) param.asObject()));
-        }
-    }
-
-    @MacroSubstitution(isStatic = true, forced = true, macro = NodeClassGetNode.class)
-    private static native NodeClass get(Class<?> c);
-
     @MethodSubstitution
     private static Node getNode(Node node, long offset) {
         return PiNode.piCast(UnsafeLoadNode.load(node, offset, Kind.Object, LocationIdentity.ANY_LOCATION), Node.class);
     }
 
     @MethodSubstitution
-    private static NodeList getNodeList(Node node, long offset) {
+    private static NodeList<?> getNodeList(Node node, long offset) {
         return PiNode.piCast(UnsafeLoadNode.load(node, offset, Kind.Object, LocationIdentity.ANY_LOCATION), NodeList.class);
     }
 
@@ -78,7 +54,7 @@
     }
 
     @MethodSubstitution
-    private static void putNodeList(Node node, long offset, NodeList value) {
+    private static void putNodeList(Node node, long offset, NodeList<?> value) {
         UnsafeStoreNode.store(node, offset, value, Kind.Object, LocationIdentity.ANY_LOCATION);
     }
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,12 +29,14 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Node.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.InjectedNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -51,9 +53,11 @@
 public class NodeIntrinsificationPhase extends Phase {
 
     private final Providers providers;
+    private final SnippetReflectionProvider snippetReflection;
 
-    public NodeIntrinsificationPhase(Providers providers) {
+    public NodeIntrinsificationPhase(Providers providers, SnippetReflectionProvider snippetReflection) {
         this.providers = providers;
+        this.snippetReflection = snippetReflection;
     }
 
     @Override
@@ -70,9 +74,10 @@
 
     protected boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List<Node> cleanUpReturnList) {
         ResolvedJavaMethod target = methodCallTargetNode.targetMethod();
-        NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class);
         ResolvedJavaType declaringClass = target.getDeclaringClass();
         StructuredGraph graph = methodCallTargetNode.graph();
+
+        NodeIntrinsic intrinsic = getIntrinsic(target);
         if (intrinsic != null) {
             assert target.getAnnotation(Fold.class) == null;
             assert Modifier.isStatic(target.getModifiers()) : "node intrinsic must be static: " + target;
@@ -129,6 +134,13 @@
     }
 
     /**
+     * Permits a subclass to override the default definition of "intrinsic".
+     */
+    protected NodeIntrinsic getIntrinsic(ResolvedJavaMethod method) {
+        return method.getAnnotation(Node.NodeIntrinsic.class);
+    }
+
+    /**
      * Permits a subclass to override the default definition of "foldable".
      */
     protected boolean isFoldable(ResolvedJavaMethod method) {
@@ -158,25 +170,25 @@
                 }
                 ConstantNode constantNode = (ConstantNode) argument;
                 Constant constant = constantNode.asConstant();
-                Object o = constant.asBoxedValue();
-                if (o instanceof Class<?>) {
-                    reflectionCallArguments[i] = Constant.forObject(providers.getMetaAccess().lookupJavaType((Class<?>) o));
+                ResolvedJavaType type = providers.getConstantReflection().asJavaType(constant);
+                if (type != null) {
+                    reflectionCallArguments[i] = snippetReflection.forObject(type);
                     parameterTypes[i] = providers.getMetaAccess().lookupJavaType(ResolvedJavaType.class);
                 } else {
                     if (parameterTypes[i].getKind() == Kind.Boolean) {
-                        reflectionCallArguments[i] = Constant.forObject(Boolean.valueOf(constant.asInt() != 0));
+                        reflectionCallArguments[i] = snippetReflection.forObject(Boolean.valueOf(constant.asInt() != 0));
                     } else if (parameterTypes[i].getKind() == Kind.Byte) {
-                        reflectionCallArguments[i] = Constant.forObject(Byte.valueOf((byte) constant.asInt()));
+                        reflectionCallArguments[i] = snippetReflection.forObject(Byte.valueOf((byte) constant.asInt()));
                     } else if (parameterTypes[i].getKind() == Kind.Short) {
-                        reflectionCallArguments[i] = Constant.forObject(Short.valueOf((short) constant.asInt()));
+                        reflectionCallArguments[i] = snippetReflection.forObject(Short.valueOf((short) constant.asInt()));
                     } else if (parameterTypes[i].getKind() == Kind.Char) {
-                        reflectionCallArguments[i] = Constant.forObject(Character.valueOf((char) constant.asInt()));
+                        reflectionCallArguments[i] = snippetReflection.forObject(Character.valueOf((char) constant.asInt()));
                     } else {
                         reflectionCallArguments[i] = constant;
                     }
                 }
             } else {
-                reflectionCallArguments[i] = Constant.forObject(argument);
+                reflectionCallArguments[i] = snippetReflection.forObject(argument);
                 parameterTypes[i] = providers.getMetaAccess().lookupJavaType(ValueNode.class);
             }
         }
@@ -217,7 +229,7 @@
         }
 
         try {
-            ValueNode intrinsicNode = (ValueNode) constructor.newInstance(arguments).asObject();
+            ValueNode intrinsicNode = (ValueNode) snippetReflection.asObject(constructor.newInstance(arguments));
 
             if (setStampFromReturnType) {
                 intrinsicNode.setStamp(invokeStamp);
@@ -258,11 +270,13 @@
             if (getParameterAnnotation(InjectedNodeParameter.class, i, c) != null) {
                 injected = injected == null ? new Constant[1] : Arrays.copyOf(injected, injected.length + 1);
                 if (signature[i].equals(metaAccess.lookupJavaType(MetaAccessProvider.class))) {
-                    injected[injected.length - 1] = Constant.forObject(metaAccess);
+                    injected[injected.length - 1] = snippetReflection.forObject(metaAccess);
                 } else if (signature[i].equals(metaAccess.lookupJavaType(StructuredGraph.class))) {
-                    injected[injected.length - 1] = Constant.forObject(graph);
+                    injected[injected.length - 1] = snippetReflection.forObject(graph);
                 } else if (signature[i].equals(metaAccess.lookupJavaType(ForeignCallsProvider.class))) {
-                    injected[injected.length - 1] = Constant.forObject(providers.getForeignCalls());
+                    injected[injected.length - 1] = snippetReflection.forObject(providers.getForeignCalls());
+                } else if (signature[i].equals(metaAccess.lookupJavaType(SnippetReflectionProvider.class))) {
+                    injected[injected.length - 1] = snippetReflection.forObject(snippetReflection);
                 } else {
                     throw new GraalInternalError("Cannot handle injected argument of type %s in %s", toJavaName(signature[i]), format("%H.%n(%p)", c));
                 }
@@ -302,9 +316,9 @@
             arguments = Arrays.copyOf(nodeConstructorArguments, fixedArgs + 1);
             arguments[fixedArgs] = componentType.newArray(nodeConstructorArguments.length - fixedArgs);
 
-            Object varargs = arguments[fixedArgs].asObject();
+            Object varargs = snippetReflection.asObject(arguments[fixedArgs]);
             for (int i = fixedArgs; i < nodeConstructorArguments.length; i++) {
-                Array.set(varargs, i - fixedArgs, nodeConstructorArguments[i].asBoxedValue());
+                Array.set(varargs, i - fixedArgs, snippetReflection.asBoxedValue(nodeConstructorArguments[i]));
             }
         } else {
             return null;
@@ -379,8 +393,8 @@
             }
         } else if (usage instanceof ProxyNode) {
             ProxyNode proxy = (ProxyNode) usage;
-            assert proxy.type() == PhiType.Value;
-            ProxyNode newProxy = graph.unique(new ProxyNode((ValueNode) intrinsifiedNode, proxy.proxyPoint(), PhiType.Value));
+            assert proxy instanceof ValueProxyNode;
+            ProxyNode newProxy = ProxyNode.forValue((ValueNode) intrinsifiedNode, proxy.proxyPoint(), graph);
             for (Node proxyUsage : usage.usages().snapshot()) {
                 checkCheckCastUsage(graph, newProxy, proxy, proxyUsage);
             }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -39,6 +39,7 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.Graph.Mark;
 import com.oracle.graal.java.*;
 import com.oracle.graal.java.GraphBuilderPhase.Instance;
 import com.oracle.graal.nodes.*;
@@ -56,6 +57,7 @@
 public class ReplacementsImpl implements Replacements {
 
     protected final Providers providers;
+    protected final SnippetReflectionProvider snippetReflection;
     protected final TargetDescription target;
     protected final Assumptions assumptions;
 
@@ -71,8 +73,9 @@
     private final Set<ResolvedJavaMethod> forcedSubstitutions;
     private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache;
 
-    public ReplacementsImpl(Providers providers, Assumptions assumptions, TargetDescription target) {
+    public ReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target) {
         this.providers = providers.copyWith(this);
+        this.snippetReflection = snippetReflection;
         this.target = target;
         this.assumptions = assumptions;
         this.graphs = new ConcurrentHashMap<>();
@@ -121,7 +124,7 @@
 
         // Do deferred intrinsification of node intrinsics
 
-        new NodeIntrinsificationPhase(providers).apply(specializedSnippet);
+        new NodeIntrinsificationPhase(providers, snippetReflection).apply(specializedSnippet);
         new CanonicalizerPhase(true).apply(specializedSnippet, new PhaseContext(providers, assumptions));
         NodeIntrinsificationVerificationPhase.verify(specializedSnippet);
     }
@@ -220,7 +223,7 @@
 
     /**
      * Registers a method substitution.
-     * 
+     *
      * @param originalMember a method or constructor being substituted
      * @param substituteMethod the substitute method
      * @return the original method
@@ -232,7 +235,7 @@
         if (originalMember instanceof Method) {
             original = metaAccess.lookupJavaMethod((Method) originalMember);
         } else {
-            original = metaAccess.lookupJavaConstructor((Constructor) originalMember);
+            original = metaAccess.lookupJavaConstructor((Constructor<?>) originalMember);
         }
         if (Debug.isLogEnabled()) {
             Debug.log("substitution: %s --> %s", MetaUtil.format("%H.%n(%p) %r", original), MetaUtil.format("%H.%n(%p) %r", substitute));
@@ -244,7 +247,7 @@
 
     /**
      * Registers a macro substitution.
-     * 
+     *
      * @param originalMethod a method or constructor being substituted
      * @param macro the substitute macro node class
      * @return the original method
@@ -255,7 +258,7 @@
         if (originalMethod instanceof Method) {
             originalJavaMethod = metaAccess.lookupJavaMethod((Method) originalMethod);
         } else {
-            originalJavaMethod = metaAccess.lookupJavaConstructor((Constructor) originalMethod);
+            originalJavaMethod = metaAccess.lookupJavaConstructor((Constructor<?>) originalMethod);
         }
         registeredMacroSubstitutions.put(originalJavaMethod, macro);
         return originalJavaMethod;
@@ -283,7 +286,7 @@
 
     /**
      * Creates a preprocessed graph for a snippet or method substitution.
-     * 
+     *
      * @param method the snippet or method substitution for which a graph will be created
      * @param original the original method if {@code method} is a {@linkplain MethodSubstitution
      *            substitution} otherwise null
@@ -364,7 +367,7 @@
          * Does final processing of a snippet graph.
          */
         protected void finalizeGraph(StructuredGraph graph) {
-            new NodeIntrinsificationPhase(providers).apply(graph);
+            new NodeIntrinsificationPhase(providers, snippetReflection).apply(graph);
             if (!SnippetTemplate.hasConstantParameter(method)) {
                 NodeIntrinsificationVerificationPhase.verify(graph);
             }
@@ -412,8 +415,8 @@
             try (Scope s = Debug.scope("buildInitialGraph", graph)) {
                 MetaAccessProvider metaAccess = providers.getMetaAccess();
                 createGraphBuilder(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), OptimisticOptimizations.NONE).apply(graph);
-                new WordTypeVerificationPhase(metaAccess, target.wordKind).apply(graph);
-                new WordTypeRewriterPhase(metaAccess, target.wordKind).apply(graph);
+                new WordTypeVerificationPhase(metaAccess, snippetReflection, target.wordKind).apply(graph);
+                new WordTypeRewriterPhase(metaAccess, snippetReflection, target.wordKind).apply(graph);
 
                 if (OptCanonicalizer.getValue()) {
                     new CanonicalizerPhase(true).apply(graph, new PhaseContext(providers, assumptions));
@@ -434,7 +437,7 @@
 
         /**
          * Called after a graph is inlined.
-         * 
+         *
          * @param caller the graph into which {@code callee} was inlined
          * @param callee the graph that was inlined into {@code caller}
          * @param beforeInlineData value returned by {@link #beforeInline}.
@@ -449,7 +452,7 @@
          * Called after all inlining for a given graph is complete.
          */
         protected void afterInlining(StructuredGraph graph) {
-            new NodeIntrinsificationPhase(providers).apply(graph);
+            new NodeIntrinsificationPhase(providers, snippetReflection).apply(graph);
             new DeadCodeEliminationPhase().apply(graph);
             if (OptCanonicalizer.getValue()) {
                 new CanonicalizerPhase(true).apply(graph, new PhaseContext(providers, assumptions));
@@ -458,17 +461,30 @@
 
         private StructuredGraph buildGraph(final ResolvedJavaMethod methodToParse, final SnippetInliningPolicy policy, int inliningDepth) {
             assert inliningDepth < MAX_GRAPH_INLINING_DEPTH : "inlining limit exceeded";
-            assert isInlinableSnippet(methodToParse) : methodToParse;
+            assert isInlinable(methodToParse) : methodToParse;
             final StructuredGraph graph = buildInitialGraph(methodToParse);
             try (Scope s = Debug.scope("buildGraph", graph)) {
-
+                Set<MethodCallTargetNode> doNotInline = null;
                 for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.class)) {
+                    if (doNotInline != null && doNotInline.contains(callTarget)) {
+                        continue;
+                    }
                     ResolvedJavaMethod callee = callTarget.targetMethod();
                     if (callee.equals(recursiveEntry)) {
-                        if (isInlinableSnippet(substitutedMethod)) {
+                        if (isInlinable(substitutedMethod)) {
                             final StructuredGraph originalGraph = buildInitialGraph(substitutedMethod);
+                            Mark mark = graph.getMark();
                             InliningUtil.inline(callTarget.invoke(), originalGraph, true);
-
+                            for (MethodCallTargetNode inlinedCallTarget : graph.getNewNodes(mark).filter(MethodCallTargetNode.class)) {
+                                if (doNotInline == null) {
+                                    doNotInline = new HashSet<>();
+                                }
+                                // We do not want to do further inlining (now) for calls
+                                // in the original method as this can cause unlimited
+                                // recursive inlining given an eager inlining policy such
+                                // as DefaultSnippetInliningPolicy.
+                                doNotInline.add(inlinedCallTarget);
+                            }
                             Debug.dump(graph, "after inlining %s", callee);
                             afterInline(graph, originalGraph, null);
                         }
@@ -514,8 +530,8 @@
         }
     }
 
-    private static boolean isInlinableSnippet(final ResolvedJavaMethod methodToParse) {
-        return !Modifier.isAbstract(methodToParse.getModifiers()) && !Modifier.isNative(methodToParse.getModifiers());
+    private static boolean isInlinable(final ResolvedJavaMethod method) {
+        return !Modifier.isAbstract(method.getModifiers()) && !Modifier.isNative(method.getModifiers());
     }
 
     private static String originalName(Method substituteMethod, String methodSubstitution) {
@@ -528,12 +544,12 @@
 
     /**
      * Resolves a name to a class.
-     * 
+     *
      * @param className the name of the class to resolve
      * @param optional if true, resolution failure returns null
      * @return the resolved class or null if resolution fails and {@code optional} is true
      */
-    static Class resolveType(String className, boolean optional) {
+    static Class<?> resolveType(String className, boolean optional) {
         try {
             // Need to use launcher class path to handle classes
             // that are not on the boot class path
@@ -547,7 +563,7 @@
         }
     }
 
-    private static Class resolveType(JavaType type) {
+    private static Class<?> resolveType(JavaType type) {
         JavaType base = type;
         int dimensions = 0;
         while (base.getComponentType() != null) {
@@ -555,15 +571,15 @@
             dimensions++;
         }
 
-        Class baseClass = base.getKind() != Kind.Object ? base.getKind().toJavaClass() : resolveType(toJavaName(base), false);
+        Class<?> baseClass = base.getKind() != Kind.Object ? base.getKind().toJavaClass() : resolveType(toJavaName(base), false);
         return dimensions == 0 ? baseClass : Array.newInstance(baseClass, new int[dimensions]).getClass();
     }
 
     static class JavaSignature {
-        final Class returnType;
-        final Class[] parameters;
+        final Class<?> returnType;
+        final Class<?>[] parameters;
 
-        public JavaSignature(Class returnType, Class[] parameters) {
+        public JavaSignature(Class<?> returnType, Class<?>[] parameters) {
             this.parameters = parameters;
             this.returnType = returnType;
         }
@@ -582,8 +598,8 @@
     }
 
     private JavaSignature originalSignature(Method substituteMethod, String methodSubstitution, boolean isStatic) {
-        Class[] parameters;
-        Class returnType;
+        Class<?>[] parameters;
+        Class<?> returnType;
         if (methodSubstitution.isEmpty()) {
             parameters = substituteMethod.getParameterTypes();
             if (!isStatic) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Apr 16 14:02:52 2014 +0200
@@ -61,7 +61,7 @@
 /**
  * A snippet template is a graph created by parsing a snippet method and then specialized by binding
  * constants to the snippet's {@link ConstantParameter} parameters.
- * 
+ *
  * Snippet templates can be managed in a cache maintained by {@link AbstractTemplates}.
  */
 public class SnippetTemplate {
@@ -79,14 +79,14 @@
 
         /**
          * Times instantiations of all templates derived form this snippet.
-         * 
+         *
          * @see SnippetTemplate#instantiationTimer
          */
         private final DebugTimer instantiationTimer;
 
         /**
          * Counts instantiations of all templates derived from this snippet.
-         * 
+         *
          * @see SnippetTemplate#instantiationCounter
          */
         private final DebugMetric instantiationCounter;
@@ -207,7 +207,7 @@
             return this;
         }
 
-        public Arguments addVarargs(String name, Class componentType, Stamp argStamp, Object value) {
+        public Arguments addVarargs(String name, Class<?> componentType, Stamp argStamp, Object value) {
             assert check(name, false, true);
             Varargs varargs = new Varargs(componentType, argStamp, value);
             values[nextParamIdx] = varargs;
@@ -276,17 +276,17 @@
      */
     static class Varargs {
 
-        protected final Class componentType;
+        protected final Class<?> componentType;
         protected final Stamp stamp;
         protected final Object value;
         protected final int length;
 
-        protected Varargs(Class componentType, Stamp stamp, Object value) {
+        protected Varargs(Class<?> componentType, Stamp stamp, Object value) {
             this.componentType = componentType;
             this.stamp = stamp;
             this.value = value;
             if (value instanceof List) {
-                this.length = ((List) value).size();
+                this.length = ((List<?>) value).size();
             } else {
                 this.length = Array.getLength(value);
             }
@@ -399,11 +399,13 @@
     public abstract static class AbstractTemplates implements SnippetTemplateCache {
 
         protected final Providers providers;
+        protected final SnippetReflectionProvider snippetReflection;
         protected final TargetDescription target;
         private final ConcurrentHashMap<CacheKey, SnippetTemplate> templates;
 
-        protected AbstractTemplates(Providers providers, TargetDescription target) {
+        protected AbstractTemplates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target) {
             this.providers = providers;
+            this.snippetReflection = snippetReflection;
             this.target = target;
             if (UseSnippetTemplateCache) {
                 this.templates = new ConcurrentHashMap<>();
@@ -419,11 +421,15 @@
          */
         protected SnippetInfo snippet(Class<? extends Snippets> declaringClass, String methodName) {
             Method found = null;
-            for (Method method : declaringClass.getDeclaredMethods()) {
-                if (method.getAnnotation(Snippet.class) != null && (methodName == null || method.getName().equals(methodName))) {
-                    assert found == null : "found more than one @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
-                    found = method;
+            Class<?> clazz = declaringClass;
+            while (clazz != Object.class) {
+                for (Method method : clazz.getDeclaredMethods()) {
+                    if (method.getAnnotation(Snippet.class) != null && (methodName == null || method.getName().equals(methodName))) {
+                        assert found == null : "found more than one @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
+                        found = method;
+                    }
                 }
+                clazz = clazz.getSuperclass();
             }
             assert found != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
             ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(found);
@@ -439,7 +445,7 @@
             if (template == null) {
                 SnippetTemplates.increment();
                 try (TimerCloseable a = SnippetTemplateCreationTime.start(); Scope s = Debug.scope("SnippetSpecialization", args.info.method)) {
-                    template = new SnippetTemplate(providers, args);
+                    template = new SnippetTemplate(providers, snippetReflection, args);
                     if (UseSnippetTemplateCache) {
                         templates.put(args.cacheKey, template);
                     }
@@ -466,10 +472,14 @@
         return false;
     }
 
+    private final SnippetReflectionProvider snippetReflection;
+
     /**
      * Creates a snippet template.
      */
-    protected SnippetTemplate(final Providers providers, Arguments args) {
+    protected SnippetTemplate(final Providers providers, SnippetReflectionProvider snippetReflection, Arguments args) {
+        this.snippetReflection = snippetReflection;
+
         StructuredGraph snippetGraph = providers.getReplacements().getSnippet(args.info.method);
         instantiationTimer = Debug.timer("SnippetTemplateInstantiationTime[%#s]", args);
         instantiationCounter = Debug.metric("SnippetTemplateInstantiationCount[%#s]", args);
@@ -498,7 +508,7 @@
                 if (arg instanceof Constant) {
                     constantArg = (Constant) arg;
                 } else {
-                    constantArg = Constant.forBoxed(kind, arg);
+                    constantArg = snippetReflection.forBoxed(kind, arg);
                 }
                 nodeReplacements.put(snippetGraph.getParameter(i), ConstantNode.forConstant(constantArg, metaAccess, snippetCopy));
             } else if (args.info.isVarargsParameter(i)) {
@@ -627,12 +637,24 @@
 
         new FloatingReadPhase(FloatingReadPhase.ExecutionMode.ANALYSIS_ONLY).apply(snippetCopy);
 
+        MemoryAnchorNode memoryAnchor = snippetCopy.add(new MemoryAnchorNode());
+        snippetCopy.start().replaceAtUsages(InputType.Memory, memoryAnchor);
+        if (memoryAnchor.usages().isEmpty()) {
+            memoryAnchor.safeDelete();
+        } else {
+            snippetCopy.addAfterFixed(snippetCopy.start(), memoryAnchor);
+        }
+
         this.snippet = snippetCopy;
+
+        Debug.dump(snippet, "SnippetTemplate after fixing memory anchoring");
+
         List<ReturnNode> returnNodes = new ArrayList<>(4);
         List<MemoryMapNode> memMaps = new ArrayList<>(4);
         StartNode entryPointNode = snippet.start();
         for (ReturnNode retNode : snippet.getNodes(ReturnNode.class)) {
             MemoryMapNode memMap = retNode.getMemoryMap();
+            memMap.replaceLastLocationAccess(snippetCopy.start(), memoryAnchor);
             memMaps.add(memMap);
             retNode.setMemoryMap(null);
             returnNodes.add(retNode);
@@ -686,9 +708,7 @@
             assert arg instanceof Constant : method + ": word constant parameters must be passed boxed in a Constant value: " + arg;
             return true;
         }
-        if (kind == Kind.Object) {
-            assert arg == null || type.isInstance(Constant.forObject(arg)) : method + ": wrong value type for " + name + ": expected " + type.getName() + ", got " + arg.getClass().getName();
-        } else {
+        if (kind != Kind.Object) {
             assert arg != null && kind.toBoxedJavaClass() == arg.getClass() : method + ": wrong value kind for " + name + ": expected " + kind + ", got " +
                             (arg == null ? "null" : arg.getClass().getSimpleName());
         }
@@ -750,21 +770,21 @@
 
     /**
      * Times instantiations of this template.
-     * 
+     *
      * @see SnippetInfo#instantiationTimer
      */
     private final DebugTimer instantiationTimer;
 
     /**
      * Counts instantiations of this template.
-     * 
+     *
      * @see SnippetInfo#instantiationCounter
      */
     private final DebugMetric instantiationCounter;
 
     /**
      * Gets the instantiation-time bindings to this template's parameters.
-     * 
+     *
      * @return the map that will be used to bind arguments to parameters when inlining this template
      */
     private IdentityHashMap<Node, Node> bind(StructuredGraph replaceeGraph, MetaAccessProvider metaAccess, Arguments args) {
@@ -787,10 +807,10 @@
                 ParameterNode[] params = (ParameterNode[]) parameter;
                 Varargs varargs = (Varargs) argument;
                 int length = params.length;
-                List list = null;
+                List<?> list = null;
                 Object array = null;
                 if (varargs.value instanceof List) {
-                    list = (List) varargs.value;
+                    list = (List<?>) varargs.value;
                     assert list.size() == length : length + " != " + list.size();
                 } else {
                     array = varargs.value;
@@ -821,26 +841,16 @@
      * Converts a Java boxed value to a {@link Constant} of the right kind. This adjusts for the
      * limitation that a {@link Local}'s kind is a {@linkplain Kind#getStackKind() stack kind} and
      * so cannot be used for re-boxing primitives smaller than an int.
-     * 
+     *
      * @param argument a Java boxed value
      * @param localKind the kind of the {@link Local} to which {@code argument} will be bound
      */
     protected Constant forBoxed(Object argument, Kind localKind) {
         assert localKind == localKind.getStackKind();
-        if (localKind == Kind.Int && !(argument instanceof Integer)) {
-            if (argument instanceof Boolean) {
-                return Constant.forBoxed(Kind.Boolean, argument);
-            }
-            if (argument instanceof Byte) {
-                return Constant.forBoxed(Kind.Byte, argument);
-            }
-            if (argument instanceof Short) {
-                return Constant.forBoxed(Kind.Short, argument);
-            }
-            assert argument instanceof Character;
-            return Constant.forBoxed(Kind.Char, argument);
+        if (localKind == Kind.Int) {
+            return Constant.forBoxedPrimitive(argument);
         }
-        return Constant.forBoxed(localKind, argument);
+        return snippetReflection.forBoxed(localKind, argument);
     }
 
     /**
@@ -929,7 +939,7 @@
             // check if some node in snippet graph also kills the same location
             LocationIdentity locationIdentity = ((MemoryCheckpoint.Single) replacee).getLocationIdentity();
             if (locationIdentity == ANY_LOCATION) {
-                assert !(memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof StartNode) : replacee + " kills ANY_LOCATION, but snippet does not";
+                assert !(memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof MemoryAnchorNode) : replacee + " kills ANY_LOCATION, but snippet does not";
             }
             assert kills.contains(locationIdentity) : replacee + " kills " + locationIdentity + ", but snippet doesn't contain a kill to this location";
             return true;
@@ -939,7 +949,7 @@
         Debug.log("WARNING: %s is not a MemoryCheckpoint, but the snippet graph contains kills (%s). You might want %s to be a MemoryCheckpoint", replacee, kills, replacee);
 
         // remove ANY_LOCATION if it's just a kill by the start node
-        if (memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof StartNode) {
+        if (memoryMap.getLastLocationAccess(ANY_LOCATION) instanceof MemoryAnchorNode) {
             kills.remove(ANY_LOCATION);
         }
 
@@ -985,11 +995,16 @@
         public Set<LocationIdentity> getLocations() {
             return memoryMap.getLocations();
         }
+
+        @Override
+        public void replaceLastLocationAccess(MemoryNode oldNode, MemoryNode newNode) {
+            throw GraalInternalError.shouldNotReachHere();
+        }
     }
 
     /**
      * Replaces a given fixed node with this specialized snippet.
-     * 
+     *
      * @param metaAccess
      * @param replacee the node that will be replaced
      * @param replacer object that replaces the usages of {@code replacee}
@@ -1110,7 +1125,7 @@
     private void propagateStamp(Node node) {
         if (node instanceof PhiNode) {
             PhiNode phi = (PhiNode) node;
-            if (phi.inferPhiStamp()) {
+            if (phi.inferStamp()) {
                 for (Node usage : node.usages()) {
                     propagateStamp(usage);
                 }
@@ -1140,7 +1155,7 @@
 
     /**
      * Replaces a given floating node with this specialized snippet.
-     * 
+     *
      * @param metaAccess
      * @param replacee the node that will be replaced
      * @param replacer object that replaces the usages of {@code replacee}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.replacements.nodes.*;
 
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import edu.umd.cs.findbugs.annotations.*;
 
 /**
  * Substitutions for {@link java.lang.String} methods.
@@ -41,7 +41,7 @@
     /**
      * Offset of the {@link String#value} field.
      */
-    @SuppressWarnings("javadoc") private static final long valueOffset;
+    @java.lang.SuppressWarnings("javadoc") private static final long valueOffset;
 
     static {
         try {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsafeSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -42,17 +42,17 @@
 
     @MethodSubstitution(isStatic = false)
     public static boolean compareAndSwapObject(@SuppressWarnings("unused") final Object thisObj, Object o, long offset, Object expected, Object x) {
-        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x);
+        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x, Kind.Object);
     }
 
     @MethodSubstitution(isStatic = false)
     public static boolean compareAndSwapInt(@SuppressWarnings("unused") final Object thisObj, Object o, long offset, int expected, int x) {
-        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x);
+        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x, Kind.Int);
     }
 
     @MethodSubstitution(isStatic = false)
     public static boolean compareAndSwapLong(@SuppressWarnings("unused") final Object thisObj, Object o, long offset, long expected, long x) {
-        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x);
+        return CompareAndSwapNode.compareAndSwap(o, 0, offset, expected, x, Kind.Long);
     }
 
     @MethodSubstitution(isStatic = false)
@@ -387,7 +387,7 @@
     }
 
     @MethodSubstitution(isStatic = false)
-    public static Object allocateInstance(final Unsafe thisObj, Class clazz) throws InstantiationException {
+    public static Object allocateInstance(final Unsafe thisObj, Class<?> clazz) throws InstantiationException {
         if (clazz.isPrimitive()) {
             throw new InstantiationException(clazz.getName());
         }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/UnsignedMathSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,12 +22,14 @@
  */
 package com.oracle.graal.replacements;
 
+import static com.oracle.graal.nodes.calc.Condition.*;
 import static com.oracle.graal.nodes.calc.ConditionalNode.*;
-import static com.oracle.graal.nodes.calc.Condition.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.graph.Node.ConstantNodeParameter;
+import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.calc.*;
 
 /**
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,7 +59,9 @@
     @Override
     public void lower(LoweringTool tool) {
         IndexedLocationNode location = IndexedLocationNode.create(locationIdentity, value.getKind(), displacement, offset, graph(), 1);
-        WriteNode write = graph().add(new WriteNode(object, value, location, BarrierType.NONE, value.getKind() == Kind.Object));
+        JavaWriteNode write = graph().add(new JavaWriteNode(object, value, location, BarrierType.NONE, value.getKind() == Kind.Object, false));
         graph().replaceFixedWithFixed(this, write);
+
+        tool.getLowerer().lower(write, tool);
     }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ExplodeLoopNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ExplodeLoopNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,7 +27,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.VarargsParameter;
 
 /**
  * Placeholder node to denote to snippet preparation that the following loop must be completely
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/LoadSnippetVarargParameterNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/LoadSnippetVarargParameterNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,7 @@
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.replacements.Snippet.*;
+import com.oracle.graal.replacements.Snippet.VarargsParameter;
 
 /**
  * Implements the semantics of {@link VarargsParameter}.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -102,7 +102,7 @@
 
     /**
      * Applies {@linkplain LoweringPhase lowering} to a replacement graph.
-     * 
+     *
      * @param replacementGraph a replacement (i.e., snippet or method substitution) graph
      */
     protected StructuredGraph lowerReplacement(final StructuredGraph replacementGraph, LoweringTool tool) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MemoryAnchorNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014, 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.replacements.nodes;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Memory})
+public class MemoryAnchorNode extends FixedWithNextNode implements LIRLowerable, MemoryNode, Canonicalizable {
+
+    public MemoryAnchorNode() {
+        super(StampFactory.forVoid());
+    }
+
+    public void generate(NodeLIRBuilderTool generator) {
+        // Nothing to emit, since this node is used for structural purposes only.
+    }
+
+    @Override
+    public Node canonical(CanonicalizerTool tool) {
+        return usages().isEmpty() ? null : this;
+    }
+
+    public MemoryCheckpoint asMemoryCheckpoint() {
+        return null;
+    }
+
+    public MemoryPhiNode asMemoryPhi() {
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotFrameInstance.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2014, 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.truffle.hotspot;
+
+import java.lang.reflect.*;
+
+import com.oracle.graal.api.code.stack.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+public abstract class HotSpotFrameInstance implements FrameInstance {
+
+    protected final InspectedFrame stackFrame;
+
+    public HotSpotFrameInstance(InspectedFrame stackFrame) {
+        this.stackFrame = stackFrame;
+    }
+
+    protected abstract int getNotifyIndex();
+
+    protected abstract int getCallTargetIndex();
+
+    protected abstract int getFrameIndex();
+
+    @SlowPath
+    public Frame getFrame(FrameAccess access, boolean slowPath) {
+        if (access == FrameAccess.NONE) {
+            return null;
+        }
+        if (!slowPath && getNotifyIndex() != -1) {
+            MaterializedFrameNotify notify = (MaterializedFrameNotify) stackFrame.getLocal(getNotifyIndex());
+            if (notify != null) {
+                if (access.ordinal() > notify.getOutsideFrameAccess().ordinal()) {
+                    notify.setOutsideFrameAccess(access);
+                }
+                if (stackFrame.isVirtual(getFrameIndex())) {
+                    stackFrame.materializeVirtualObjects(true);
+                }
+            }
+        }
+        switch (access) {
+            case READ_ONLY: {
+                Frame frame = (Frame) stackFrame.getLocal(getFrameIndex());
+                // assert that it is really used read only
+                assert (frame = new ReadOnlyFrame(frame)) != null;
+                return frame;
+            }
+            case READ_WRITE:
+            case MATERIALIZE:
+                if (stackFrame.isVirtual(getFrameIndex())) {
+                    stackFrame.materializeVirtualObjects(false);
+                }
+                return (Frame) stackFrame.getLocal(getFrameIndex());
+            default:
+                throw GraalInternalError.unimplemented();
+        }
+    }
+
+    public boolean isVirtualFrame() {
+        return stackFrame.isVirtual(getFrameIndex());
+    }
+
+    public abstract CallTarget getCallTarget();
+
+    public abstract CallTarget getTargetCallTarget();
+
+    public DirectCallNode getCallNode() {
+        Object receiver = stackFrame.getLocal(getNotifyIndex());
+        if (receiver instanceof DirectCallNode) {
+            return (DirectCallNode) receiver;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * This class represents a frame that is taken from the
+     * {@link OptimizedDirectCallNode#callProxy(MaterializedFrameNotify, CallTarget, VirtualFrame, Object[], boolean)}
+     * method.
+     */
+    public static final class CallNodeFrame extends HotSpotFrameInstance {
+        public static final Method METHOD;
+        static {
+            try {
+                METHOD = OptimizedDirectCallNode.class.getDeclaredMethod("callProxy", MaterializedFrameNotify.class, CallTarget.class, VirtualFrame.class, Object[].class, boolean.class);
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new GraalInternalError(e);
+            }
+        }
+        private static final int NOTIFY_INDEX = 0;
+        private static final int CALL_TARGET_INDEX = 1;
+        private static final int FRAME_INDEX = 2;
+
+        public CallNodeFrame(InspectedFrame stackFrame) {
+            super(stackFrame);
+        }
+
+        @Override
+        protected int getNotifyIndex() {
+            return NOTIFY_INDEX;
+        }
+
+        @Override
+        protected int getCallTargetIndex() {
+            return CALL_TARGET_INDEX;
+        }
+
+        @Override
+        protected int getFrameIndex() {
+            return FRAME_INDEX;
+        }
+
+        @Override
+        public CallTarget getCallTarget() {
+            return getCallNode().getRootNode().getCallTarget();
+        }
+
+        @Override
+        public CallTarget getTargetCallTarget() {
+            return (CallTarget) stackFrame.getLocal(getCallTargetIndex());
+        }
+    }
+
+    /**
+     * This class represents a frame that is taken from the
+     * {@link RootCallTarget#callProxy(VirtualFrame)} method.
+     */
+    @SuppressWarnings("javadoc")
+    public static final class CallTargetFrame extends HotSpotFrameInstance {
+        public static final Method METHOD;
+        static {
+            try {
+                METHOD = RootCallTarget.class.getDeclaredMethod("callProxy", VirtualFrame.class);
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new GraalInternalError(e);
+            }
+        }
+        private static final int NOTIFY_INDEX = -1;
+        private static final int CALL_TARGET_INDEX = 0;
+        private static final int FRAME_INDEX = 1;
+        private final boolean currentFrame;
+
+        public CallTargetFrame(InspectedFrame stackFrame, boolean currentFrame) {
+            super(stackFrame);
+            this.currentFrame = currentFrame;
+        }
+
+        @Override
+        public Frame getFrame(FrameAccess access, boolean slowPath) {
+            if (!slowPath && currentFrame) {
+                throw new UnsupportedOperationException("cannot access current frame as fast path");
+            }
+            return super.getFrame(access, slowPath);
+        }
+
+        @Override
+        protected int getNotifyIndex() {
+            return NOTIFY_INDEX;
+        }
+
+        @Override
+        protected int getCallTargetIndex() {
+            return CALL_TARGET_INDEX;
+        }
+
+        @Override
+        protected int getFrameIndex() {
+            return FRAME_INDEX;
+        }
+
+        @Override
+        public CallTarget getCallTarget() {
+            return (CallTarget) stackFrame.getLocal(getCallTargetIndex());
+        }
+
+        @Override
+        public CallTarget getTargetCallTarget() {
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,185 @@
+/*
+ * 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.truffle.hotspot;
+
+import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+import static com.oracle.graal.truffle.OptimizedCallTargetLog.*;
+
+import java.util.concurrent.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * Call target for running truffle on a standard VM (and not in SubstrateVM).
+ */
+public final class HotSpotOptimizedCallTarget extends OptimizedCallTarget {
+
+    protected final TruffleCompiler compiler;
+    private Future<InstalledCode> installedCodeTask;
+    private SpeculationLog speculationLog = new HotSpotSpeculationLog();
+
+    HotSpotOptimizedCallTarget(RootNode rootNode, TruffleCompiler compiler, int invokeCounter, int compilationThreshold, boolean compilationEnabled) {
+        super(rootNode, invokeCounter, compilationThreshold, compilationEnabled, TruffleUseTimeForCompilationDecision.getValue() ? new TimedCompilationPolicy() : new DefaultCompilationPolicy());
+        this.compiler = compiler;
+    }
+
+    @Override
+    public SpeculationLog getSpeculationLog() {
+        return speculationLog;
+    }
+
+    public boolean isOptimized() {
+        return installedCode != null || installedCodeTask != null;
+    }
+
+    @CompilerDirectives.SlowPath
+    @Override
+    public Object call(Object[] args) {
+        return CompilerDirectives.inInterpreter() ? callHelper(args) : executeHelper(args);
+    }
+
+    private Object callHelper(Object[] args) {
+        if (installedCode != null && installedCode.isValid()) {
+            reinstallCallMethodShortcut();
+        }
+        if (TruffleCallTargetProfiling.getValue()) {
+            callCount++;
+        }
+        if (CompilerDirectives.injectBranchProbability(CompilerDirectives.FASTPATH_PROBABILITY, installedCode != null)) {
+            try {
+                return installedCode.executeVarargs(new Object[]{this, args});
+            } catch (InvalidInstalledCodeException ex) {
+                return compiledCodeInvalidated(args);
+            }
+        } else {
+            return interpreterCall(args);
+        }
+    }
+
+    private static void reinstallCallMethodShortcut() {
+        if (TraceTruffleCompilation.getValue()) {
+            OUT.println("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut.");
+        }
+        HotSpotTruffleRuntime.installOptimizedCallTargetCallMethod();
+    }
+
+    private Object compiledCodeInvalidated(Object[] args) {
+        invalidate(null, null, "Compiled code invalidated");
+        return call(args);
+    }
+
+    @Override
+    protected void invalidate(Node oldNode, Node newNode, CharSequence reason) {
+        InstalledCode m = this.installedCode;
+        if (m != null) {
+            CompilerAsserts.neverPartOfCompilation();
+            installedCode = null;
+            compilationProfile.reportInvalidated();
+            logOptimizedInvalidated(this, oldNode, newNode, reason);
+        }
+        cancelInstalledTask(oldNode, newNode, reason);
+    }
+
+    private void cancelInstalledTask(Node oldNode, Node newNode, CharSequence reason) {
+        Future<InstalledCode> task = this.installedCodeTask;
+        if (task != null) {
+            task.cancel(true);
+            this.installedCodeTask = null;
+            logOptimizingUnqueued(this, oldNode, newNode, reason);
+            compilationProfile.reportInvalidated();
+        }
+    }
+
+    private Object interpreterCall(Object[] args) {
+        CompilerAsserts.neverPartOfCompilation();
+        compilationProfile.reportInterpreterCall();
+
+        if (compilationEnabled && compilationPolicy.shouldCompile(compilationProfile)) {
+            InstalledCode code = compile();
+            if (code != null && code.isValid()) {
+                this.installedCode = code;
+                try {
+                    return code.executeVarargs(new Object[]{this, args});
+                } catch (InvalidInstalledCodeException ex) {
+                    return compiledCodeInvalidated(args);
+                }
+            }
+        }
+        return executeHelper(args);
+    }
+
+    private boolean isCompiling() {
+        Future<InstalledCode> codeTask = this.installedCodeTask;
+        if (codeTask != null) {
+            if (codeTask.isCancelled()) {
+                installedCodeTask = null;
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public InstalledCode compile() {
+        if (isCompiling()) {
+            if (installedCodeTask.isDone()) {
+                return receiveInstalledCode();
+            }
+            return null;
+        } else {
+            performInlining();
+            logOptimizingQueued(this);
+            this.installedCodeTask = compiler.compile(this);
+            if (!TruffleBackgroundCompilation.getValue()) {
+                return receiveInstalledCode();
+            }
+            return null;
+        }
+    }
+
+    private InstalledCode receiveInstalledCode() {
+        try {
+            return installedCodeTask.get();
+        } catch (InterruptedException | ExecutionException e) {
+            compilationEnabled = false;
+            logOptimizingFailed(this, e.getMessage());
+            if (e.getCause() instanceof BailoutException) {
+                // Bailout => move on.
+            } else {
+                if (TraceTruffleCompilationExceptions.getValue()) {
+                    e.printStackTrace(OUT);
+                }
+                if (TruffleCompilationExceptionsAreFatal.getValue()) {
+                    System.exit(-1);
+                }
+            }
+            return null;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleReplacements.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,50 @@
+/*
+ * 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.truffle.hotspot;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.graal.truffle.hotspot.substitutions.*;
+
+public final class HotSpotTruffleReplacements extends TruffleReplacements {
+
+    private HotSpotTruffleReplacements(Providers providers, SnippetReflectionProvider snippetReflection) {
+        super(providers, snippetReflection);
+    }
+
+    public static Replacements makeInstance() {
+        Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
+        SnippetReflectionProvider snippetReflection = Graal.getRequiredCapability(SnippetReflectionProvider.class);
+        return new HotSpotTruffleReplacements(providers, snippetReflection);
+    }
+
+    @Override
+    protected void registerTruffleSubstitutions() {
+        super.registerTruffleSubstitutions();
+        registerSubstitutions(HotSpotOptimizedCallTargetSubstitutions.class);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,275 @@
+/*
+ * 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.truffle.hotspot;
+
+import static com.oracle.graal.api.code.CodeUtil.*;
+import static com.oracle.graal.compiler.GraalCompiler.*;
+import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.CallingConvention.Type;
+import com.oracle.graal.api.code.stack.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.java.*;
+import com.oracle.graal.lir.asm.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.common.*;
+import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.impl.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * Implementation of the Truffle runtime when running on top of Graal.
+ */
+public final class HotSpotTruffleRuntime implements GraalTruffleRuntime {
+
+    public static HotSpotTruffleRuntime makeInstance() {
+        return new HotSpotTruffleRuntime();
+    }
+
+    private TruffleCompiler truffleCompiler;
+    private Replacements truffleReplacements;
+    private StackIntrospection stackIntrospection;
+    private ArrayList<String> includes;
+    private ArrayList<String> excludes;
+
+    private final ResolvedJavaMethod[] callNodeMethod;
+    private final ResolvedJavaMethod[] callTargetMethod;
+    private final ResolvedJavaMethod[] anyFrameMethod;
+
+    private HotSpotTruffleRuntime() {
+        installOptimizedCallTargetCallMethod();
+
+        callNodeMethod = new ResolvedJavaMethod[]{getGraalProviders().getMetaAccess().lookupJavaMethod(HotSpotFrameInstance.CallNodeFrame.METHOD)};
+        callTargetMethod = new ResolvedJavaMethod[]{getGraalProviders().getMetaAccess().lookupJavaMethod(HotSpotFrameInstance.CallTargetFrame.METHOD)};
+        anyFrameMethod = new ResolvedJavaMethod[]{callNodeMethod[0], callTargetMethod[0]};
+    }
+
+    public String getName() {
+        return "Graal Truffle Runtime";
+    }
+
+    public RootCallTarget createCallTarget(RootNode rootNode) {
+        if (truffleCompiler == null) {
+            truffleCompiler = new TruffleCompilerImpl();
+        }
+        return new HotSpotOptimizedCallTarget(rootNode, truffleCompiler, TruffleMinInvokeThreshold.getValue(), TruffleCompilationThreshold.getValue(), acceptForCompilation(rootNode));
+    }
+
+    public DirectCallNode createDirectCallNode(CallTarget target) {
+        if (target instanceof OptimizedCallTarget) {
+            return OptimizedDirectCallNode.create((OptimizedCallTarget) target);
+        } else {
+            return new DefaultDirectCallNode(target);
+        }
+    }
+
+    public IndirectCallNode createIndirectCallNode() {
+        return new OptimizedIndirectCallNode();
+    }
+
+    @Override
+    public VirtualFrame createVirtualFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
+        return OptimizedCallTarget.createFrame(frameDescriptor, arguments);
+    }
+
+    @Override
+    public MaterializedFrame createMaterializedFrame(Object[] arguments) {
+        return createMaterializedFrame(arguments, new FrameDescriptor());
+    }
+
+    @Override
+    public MaterializedFrame createMaterializedFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
+        return new FrameWithoutBoxing(frameDescriptor, arguments);
+    }
+
+    @Override
+    public Assumption createAssumption() {
+        return createAssumption(null);
+    }
+
+    @Override
+    public Assumption createAssumption(String name) {
+        return new OptimizedAssumption(name);
+    }
+
+    public Replacements getReplacements() {
+        if (truffleReplacements == null) {
+            truffleReplacements = HotSpotTruffleReplacements.makeInstance();
+        }
+        return truffleReplacements;
+    }
+
+    private boolean acceptForCompilation(RootNode rootNode) {
+        if (TruffleCompileOnly.getValue() != null) {
+            if (includes == null) {
+                parseCompileOnly();
+            }
+
+            String name = rootNode.toString();
+            boolean included = includes.isEmpty();
+            for (int i = 0; !included && i < includes.size(); i++) {
+                if (name.contains(includes.get(i))) {
+                    included = true;
+                }
+            }
+            if (!included) {
+                return false;
+            }
+            for (String exclude : excludes) {
+                if (name.contains(exclude)) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    private void parseCompileOnly() {
+        includes = new ArrayList<>();
+        excludes = new ArrayList<>();
+
+        String[] items = TruffleCompileOnly.getValue().split(",");
+        for (String item : items) {
+            if (item.startsWith("~")) {
+                excludes.add(item.substring(1));
+            } else {
+                includes.add(item);
+            }
+        }
+    }
+
+    public static void installOptimizedCallTargetCallMethod() {
+        Providers providers = getGraalProviders();
+        MetaAccessProvider metaAccess = providers.getMetaAccess();
+        CodeCacheProvider codeCache = providers.getCodeCache();
+        ResolvedJavaMethod resolvedCallMethod = metaAccess.lookupJavaMethod(getCallMethod());
+        CompilationResult compResult = compileMethod(resolvedCallMethod);
+        try (Scope s = Debug.scope("CodeInstall", codeCache, resolvedCallMethod)) {
+            codeCache.setDefaultMethod(resolvedCallMethod, compResult);
+        }
+    }
+
+    private static Method getCallMethod() {
+        Method method;
+        try {
+            method = HotSpotOptimizedCallTarget.class.getDeclaredMethod("call", new Class[]{Object[].class});
+        } catch (NoSuchMethodException | SecurityException e) {
+            throw GraalInternalError.shouldNotReachHere();
+        }
+        return method;
+    }
+
+    private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch, ResolvedJavaMethod method) {
+        for (OptimizedCallTargetInstrumentationFactory factory : ServiceLoader.loadInstalled(OptimizedCallTargetInstrumentationFactory.class)) {
+            if (factory.getArchitecture().equals(arch)) {
+                factory.setInstrumentedMethod(method);
+                return factory;
+            }
+        }
+        // No specialization of OptimizedCallTarget on this platform.
+        return CompilationResultBuilderFactory.Default;
+    }
+
+    private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
+        Providers providers = getGraalProviders();
+        MetaAccessProvider metaAccess = providers.getMetaAccess();
+        SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites();
+        Suites suites = suitesProvider.createSuites();
+        suites.getHighTier().findPhase(InliningPhase.class).remove();
+        StructuredGraph graph = new StructuredGraph(javaMethod);
+        new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
+        PhaseSuite<HighTierContext> graphBuilderSuite = suitesProvider.getDefaultGraphBuilderSuite();
+        CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
+        Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
+        CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod);
+        return compileGraph(graph, null, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null,
+                        suites, new CompilationResult(), factory);
+    }
+
+    private static Providers getGraalProviders() {
+        RuntimeProvider runtimeProvider = Graal.getRequiredCapability(RuntimeProvider.class);
+        return runtimeProvider.getHostBackend().getProviders();
+    }
+
+    @SlowPath
+    public Iterable<FrameInstance> getStackTrace() {
+        if (stackIntrospection == null) {
+            stackIntrospection = Graal.getRequiredCapability(StackIntrospection.class);
+        }
+        final Iterator<InspectedFrame> frames = stackIntrospection.getStackTrace(anyFrameMethod, anyFrameMethod, 1).iterator();
+        class FrameIterator implements Iterator<FrameInstance> {
+
+            public boolean hasNext() {
+                return frames.hasNext();
+            }
+
+            public FrameInstance next() {
+                InspectedFrame frame = frames.next();
+                if (frame.getMethod().equals(callNodeMethod[0])) {
+                    assert frames.hasNext();
+                    InspectedFrame calltarget2 = frames.next();
+                    assert calltarget2.getMethod().equals(callTargetMethod[0]);
+                    return new HotSpotFrameInstance.CallNodeFrame(frame);
+                } else {
+                    assert frame.getMethod().equals(callTargetMethod[0]);
+                    return new HotSpotFrameInstance.CallTargetFrame(frame, false);
+                }
+            }
+        }
+        return new Iterable<FrameInstance>() {
+            public Iterator<FrameInstance> iterator() {
+                return new FrameIterator();
+            }
+        };
+    }
+
+    public FrameInstance getCurrentFrame() {
+        if (stackIntrospection == null) {
+            stackIntrospection = Graal.getRequiredCapability(StackIntrospection.class);
+        }
+        Iterator<InspectedFrame> frames = stackIntrospection.getStackTrace(callTargetMethod, callTargetMethod, 0).iterator();
+        if (frames.hasNext()) {
+            return new HotSpotFrameInstance.CallTargetFrame(frames.next(), true);
+        } else {
+            System.out.println("no current frame found");
+            return null;
+        }
+    }
+}
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,17 +29,14 @@
 import com.oracle.graal.asm.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.truffle.*;
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
 
 /**
- * Mechanism for injecting special code into
- * {@link OptimizedCallTarget#call(PackedFrame, Arguments)} .
+ * Mechanism for injecting special code into {@link OptimizedCallTarget#call(Object[])} .
  */
 public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder {
 
@@ -58,7 +55,7 @@
         return mark;
     }
 
-    protected static int getFieldOffset(String name, Class declaringClass) {
+    protected static int getFieldOffset(String name, Class<?> declaringClass) {
         try {
             declaringClass.getDeclaredField(name).setAccessible(true);
             Field field = declaringClass.getDeclaredField(name);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/ReadOnlyFrame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2014, 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.truffle.hotspot;
+
+import com.oracle.graal.graph.*;
+import com.oracle.truffle.api.frame.*;
+
+class ReadOnlyFrame implements Frame {
+    private final Frame delegate;
+
+    public ReadOnlyFrame(Frame delegate) {
+        this.delegate = delegate;
+    }
+
+    public FrameDescriptor getFrameDescriptor() {
+        return delegate.getFrameDescriptor();
+    }
+
+    public Object[] getArguments() {
+        return delegate.getArguments().clone();
+    }
+
+    public Object getObject(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getObject(slot);
+    }
+
+    public void setObject(FrameSlot slot, Object value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public byte getByte(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getByte(slot);
+    }
+
+    public void setByte(FrameSlot slot, byte value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getBoolean(slot);
+    }
+
+    public void setBoolean(FrameSlot slot, boolean value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public int getInt(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getInt(slot);
+    }
+
+    public void setInt(FrameSlot slot, int value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public long getLong(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getLong(slot);
+    }
+
+    public void setLong(FrameSlot slot, long value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public float getFloat(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getFloat(slot);
+    }
+
+    public void setFloat(FrameSlot slot, float value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public double getDouble(FrameSlot slot) throws FrameSlotTypeException {
+        return delegate.getDouble(slot);
+    }
+
+    public void setDouble(FrameSlot slot, double value) {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public Object getValue(FrameSlot slot) {
+        return delegate.getValue(slot);
+    }
+
+    public MaterializedFrame materialize() {
+        throw GraalInternalError.shouldNotReachHere();
+    }
+
+    public boolean isObject(FrameSlot slot) {
+        return delegate.isObject(slot);
+    }
+
+    public boolean isByte(FrameSlot slot) {
+        return delegate.isByte(slot);
+    }
+
+    public boolean isBoolean(FrameSlot slot) {
+        return delegate.isBoolean(slot);
+    }
+
+    public boolean isInt(FrameSlot slot) {
+        return delegate.isInt(slot);
+    }
+
+    public boolean isLong(FrameSlot slot) {
+        return delegate.isLong(slot);
+    }
+
+    public boolean isFloat(FrameSlot slot) {
+        return delegate.isFloat(slot);
+    }
+
+    public boolean isDouble(FrameSlot slot) {
+        return delegate.isDouble(slot);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/substitutions/HotSpotOptimizedCallTargetSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,42 @@
+/*
+ * 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.truffle.hotspot.substitutions;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.graal.truffle.hotspot.*;
+import com.oracle.graal.truffle.nodes.asserts.*;
+
+@ClassSubstitution(HotSpotOptimizedCallTarget.class)
+public class HotSpotOptimizedCallTargetSubstitutions {
+
+    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
+    public static native Object callHelper(OptimizedCallTarget target, Object[] args);
+
+    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
+    public static native Object interpreterCall(OptimizedCallTarget target, Object[] args);
+
+    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
+    public static native Object compiledCodeInvalidated(OptimizedCallTarget target, Object[] args);
+}
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/AssumptionPartialEvaluationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -46,7 +46,7 @@
         InstalledCode installedCode = assertPartialEvalEquals("constant42", rootNode);
         Assert.assertTrue(installedCode.isValid());
         try {
-            assertEquals(42, installedCode.execute(null, null, null));
+            assertEquals(42, installedCode.executeVarargs(null, null, null));
         } catch (InvalidInstalledCodeException e) {
             Assert.fail("Code must not have been invalidated.");
         }
@@ -65,7 +65,7 @@
         Assert.assertFalse(installedCode.isValid());
 
         try {
-            installedCode.execute(null, null, null);
+            installedCode.executeVarargs(null, null, null);
             Assert.fail("Code must have been invalidated.");
         } catch (InvalidInstalledCodeException e) {
         }
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -51,17 +51,17 @@
 
     public PartialEvaluationTest() {
         // Make sure Truffle runtime is initialized.
-        Assert.assertTrue(Truffle.getRuntime() instanceof GraalTruffleRuntime);
+        Assert.assertTrue(Truffle.getRuntime() != null);
         this.truffleCompiler = new TruffleCompilerImpl();
 
         DebugEnvironment.initialize(System.out);
     }
 
     protected InstalledCode assertPartialEvalEquals(String methodName, RootNode root) {
-        return assertPartialEvalEquals(methodName, root, Arguments.EMPTY_ARGUMENTS);
+        return assertPartialEvalEquals(methodName, root, new Object[0]);
     }
 
-    protected InstalledCode assertPartialEvalEquals(String methodName, RootNode root, Arguments arguments) {
+    protected InstalledCode assertPartialEvalEquals(String methodName, RootNode root, Object[] arguments) {
         Assumptions assumptions = new Assumptions(true);
         StructuredGraph actual = partialEval(root, arguments, assumptions, true);
         InstalledCode result = truffleCompiler.compileMethodHelper(actual, assumptions, root.toString(), getSpeculationLog());
@@ -72,10 +72,10 @@
     }
 
     protected void assertPartialEvalNoInvokes(RootNode root) {
-        assertPartialEvalNoInvokes(root, Arguments.EMPTY_ARGUMENTS);
+        assertPartialEvalNoInvokes(root, new Object[0]);
     }
 
-    protected void assertPartialEvalNoInvokes(RootNode root, Arguments arguments) {
+    protected void assertPartialEvalNoInvokes(RootNode root, Object[] arguments) {
         Assumptions assumptions = new Assumptions(true);
         StructuredGraph actual = partialEval(root, arguments, assumptions, true);
         removeFrameStates(actual);
@@ -84,13 +84,13 @@
         }
     }
 
-    protected StructuredGraph partialEval(RootNode root, Arguments arguments, final Assumptions assumptions, final boolean canonicalizeReads) {
-        final OptimizedCallTargetImpl compilable = (OptimizedCallTargetImpl) Truffle.getRuntime().createCallTarget(root);
+    protected StructuredGraph partialEval(RootNode root, Object[] arguments, final Assumptions assumptions, final boolean canonicalizeReads) {
+        final OptimizedCallTarget compilable = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(root);
 
         // Executed AST so that all classes are loaded and initialized.
-        compilable.call(null, arguments);
-        compilable.call(null, arguments);
-        compilable.call(null, arguments);
+        compilable.call(arguments);
+        compilable.call(arguments);
+        compilable.call(arguments);
         compilable.performInlining();
 
         try (Scope s = Debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable))) {
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleRuntimeTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleRuntimeTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,8 +28,8 @@
 
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.runtime.*;
-import com.oracle.graal.truffle.*;
 import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.impl.*;
 
 public class TruffleRuntimeTest {
 
@@ -46,6 +46,6 @@
     @Test
     public void testRuntimeIsGraalRuntime() {
         TruffleRuntime runtime = Truffle.getRuntime();
-        assertEquals(GraalTruffleRuntime.class, runtime.getClass());
+        assertTrue(runtime.getClass() != DefaultTruffleRuntime.class);
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Wed Apr 16 14:02:52 2014 +0200
@@ -126,7 +126,7 @@
         this.previousTimestamp = timestamp;
     }
 
-    void reportInvalidated() {
+    public void reportInvalidated() {
         invalidationCount++;
         int reprofile = TruffleInvalidationReprofileCount.getValue();
         ensureProfiling(reprofile, reprofile);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultInliningPolicy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,61 @@
+/*
+ * 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.truffle;
+
+import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+
+public class DefaultInliningPolicy implements TruffleInliningPolicy {
+
+    private static final String REASON_RECURSION = "recursion";
+    private static final String REASON_MAXIMUM_NODE_COUNT = "deepNodeCount * callSites  > " + TruffleInliningMaxCallerSize.getValue();
+    private static final String REASON_MAXIMUM_TOTAL_NODE_COUNT = "totalNodeCount > " + TruffleInliningMaxCallerSize.getValue();
+
+    public double calculateScore(TruffleInliningProfile profile) {
+        return profile.getFrequency() / profile.getDeepNodeCount();
+    }
+
+    public boolean isAllowed(TruffleInliningProfile profile, int currentBudgetLeft) {
+        if (profile.isRecursiveCall()) {
+            // recursive call found
+            profile.setFailedReason(REASON_RECURSION);
+            return false;
+        }
+
+        if (profile.isForced()) {
+            return true;
+        }
+
+        if (currentBudgetLeft - profile.getDeepNodeCount() < 0) {
+            profile.setFailedReason(REASON_MAXIMUM_TOTAL_NODE_COUNT);
+            return false;
+        }
+
+        int cappedCallSites = Math.min(Math.max(profile.getCallSites(), 1), 10);
+        if (profile.getDeepNodeCount() * cappedCallSites > TruffleInliningMaxCallerSize.getValue()) {
+            profile.setFailedReason(REASON_MAXIMUM_NODE_COUNT);
+            return false;
+        }
+
+        return true;
+    }
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Wed Apr 16 14:02:52 2014 +0200
@@ -34,18 +34,16 @@
  * and therefore is much faster. Should not be used during debugging as potential misuses of the
  * frame object would show up very late and would be hard to identify.
  */
-public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame, PackedFrame {
+public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame {
 
     private final FrameDescriptor descriptor;
-    private final PackedFrame caller;
-    private final Arguments arguments;
+    private final Object[] arguments;
     private Object[] locals;
     private long[] primitiveLocals;
     private byte[] tags;
 
-    public FrameWithoutBoxing(FrameDescriptor descriptor, PackedFrame caller, Arguments arguments) {
+    public FrameWithoutBoxing(FrameDescriptor descriptor, Object[] arguments) {
         this.descriptor = descriptor;
-        this.caller = caller;
         this.arguments = arguments;
         this.locals = new Object[descriptor.getSize()];
         Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue());
@@ -54,18 +52,8 @@
     }
 
     @Override
-    public <T extends Arguments> T getArguments(Class<T> clazz) {
-        return CompilerDirectives.unsafeCast(arguments, clazz, true, true);
-    }
-
-    @Override
-    public PackedFrame getCaller() {
-        return caller;
-    }
-
-    @Override
-    public PackedFrame pack() {
-        return this;
+    public Object[] getArguments() {
+        return CompilerDirectives.unsafeCast(arguments, Object[].class, true, true);
     }
 
     @Override
@@ -74,11 +62,6 @@
     }
 
     @Override
-    public VirtualFrame unpack() {
-        return this;
-    }
-
-    @Override
     public Object getObject(FrameSlot slot) throws FrameSlotTypeException {
         verifyGet(slot, FrameSlotKind.Object);
         return getObjectUnsafe(slot);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,193 +22,10 @@
  */
 package com.oracle.graal.truffle;
 
-import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.compiler.GraalCompiler.*;
-import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.CallingConvention.Type;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.phases.util.*;
-import com.oracle.graal.runtime.*;
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.impl.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Implementation of the Truffle runtime when running on top of Graal.
- */
-public final class GraalTruffleRuntime implements TruffleRuntime {
-
-    public static GraalTruffleRuntime makeInstance() {
-        return new GraalTruffleRuntime();
-    }
-
-    private TruffleCompiler truffleCompiler;
-    private Replacements truffleReplacements;
-    private ArrayList<String> includes;
-    private ArrayList<String> excludes;
-
-    private GraalTruffleRuntime() {
-        installOptimizedCallTargetCallMethod();
-    }
-
-    public String getName() {
-        return "Graal Truffle Runtime";
-    }
-
-    public RootCallTarget createCallTarget(RootNode rootNode) {
-        if (truffleCompiler == null) {
-            truffleCompiler = new TruffleCompilerImpl();
-        }
-        return new OptimizedCallTargetImpl(rootNode, truffleCompiler, TruffleMinInvokeThreshold.getValue(), TruffleCompilationThreshold.getValue(), acceptForCompilation(rootNode));
-    }
-
-    public CallNode createCallNode(CallTarget target) {
-        if (target instanceof OptimizedCallTarget) {
-            return OptimizedCallNode.create((OptimizedCallTarget) target);
-        } else {
-            return new DefaultCallNode(target);
-        }
-    }
-
-    @Override
-    public VirtualFrame createVirtualFrame(PackedFrame caller, Arguments arguments, FrameDescriptor frameDescriptor) {
-        return OptimizedCallTargetImpl.createFrame(frameDescriptor, caller, arguments);
-    }
-
-    @Override
-    public MaterializedFrame createMaterializedFrame(Arguments arguments) {
-        return createMaterializedFrame(arguments, new FrameDescriptor());
-    }
-
-    @Override
-    public MaterializedFrame createMaterializedFrame(Arguments arguments, FrameDescriptor frameDescriptor) {
-        return new FrameWithoutBoxing(frameDescriptor, null, arguments);
-    }
-
-    @Override
-    public Assumption createAssumption() {
-        return createAssumption(null);
-    }
-
-    @Override
-    public Assumption createAssumption(String name) {
-        return new OptimizedAssumption(name);
-    }
 
-    public Replacements getReplacements() {
-        if (truffleReplacements == null) {
-            truffleReplacements = TruffleReplacements.makeInstance();
-        }
-        return truffleReplacements;
-    }
-
-    private boolean acceptForCompilation(RootNode rootNode) {
-        if (TruffleCompileOnly.getValue() != null) {
-            if (includes == null) {
-                parseCompileOnly();
-            }
-
-            String name = rootNode.toString();
-            boolean included = includes.isEmpty();
-            for (int i = 0; !included && i < includes.size(); i++) {
-                if (name.contains(includes.get(i))) {
-                    included = true;
-                }
-            }
-            if (!included) {
-                return false;
-            }
-            for (String exclude : excludes) {
-                if (name.contains(exclude)) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    private void parseCompileOnly() {
-        includes = new ArrayList<>();
-        excludes = new ArrayList<>();
-
-        String[] items = TruffleCompileOnly.getValue().split(",");
-        for (String item : items) {
-            if (item.startsWith("~")) {
-                excludes.add(item.substring(1));
-            } else {
-                includes.add(item);
-            }
-        }
-    }
+public interface GraalTruffleRuntime extends TruffleRuntime {
 
-    public static void installOptimizedCallTargetCallMethod() {
-        Providers providers = getGraalProviders();
-        MetaAccessProvider metaAccess = providers.getMetaAccess();
-        CodeCacheProvider codeCache = providers.getCodeCache();
-        ResolvedJavaMethod resolvedCallMethod = metaAccess.lookupJavaMethod(getCallMethod());
-        CompilationResult compResult = compileMethod(resolvedCallMethod);
-        try (Scope s = Debug.scope("CodeInstall", codeCache, resolvedCallMethod)) {
-            codeCache.setDefaultMethod(resolvedCallMethod, compResult);
-        }
-    }
-
-    private static Method getCallMethod() {
-        Method method;
-        try {
-            method = OptimizedCallTargetImpl.class.getDeclaredMethod("call", new Class[]{PackedFrame.class, Arguments.class});
-        } catch (NoSuchMethodException | SecurityException e) {
-            throw GraalInternalError.shouldNotReachHere();
-        }
-        return method;
-    }
-
-    private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch, ResolvedJavaMethod method) {
-        for (OptimizedCallTargetInstrumentationFactory factory : ServiceLoader.loadInstalled(OptimizedCallTargetInstrumentationFactory.class)) {
-            if (factory.getArchitecture().equals(arch)) {
-                factory.setInstrumentedMethod(method);
-                return factory;
-            }
-        }
-        // No specialization of OptimizedCallTarget on this platform.
-        return CompilationResultBuilderFactory.Default;
-    }
-
-    private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
-        Providers providers = getGraalProviders();
-        MetaAccessProvider metaAccess = providers.getMetaAccess();
-        SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites();
-        Suites suites = suitesProvider.createSuites();
-        suites.getHighTier().findPhase(InliningPhase.class).remove();
-        StructuredGraph graph = new StructuredGraph(javaMethod);
-        new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
-        PhaseSuite<HighTierContext> graphBuilderSuite = suitesProvider.getDefaultGraphBuilderSuite();
-        CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
-        Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
-        CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod);
-        return compileGraph(graph, null, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null,
-                        suites, new CompilationResult(), factory);
-    }
-
-    private static Providers getGraalProviders() {
-        RuntimeProvider runtimeProvider = Graal.getRequiredCapability(RuntimeProvider.class);
-        return runtimeProvider.getHostBackend().getProviders();
-    }
+    Replacements getReplacements();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/MaterializedFrameNotify.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, 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.truffle;
+
+import com.oracle.truffle.api.frame.FrameInstance.*;
+
+public interface MaterializedFrameNotify {
+
+    FrameAccess getOutsideFrameAccess();
+
+    void setOutsideFrameAccess(FrameAccess outsideFrameAccess);
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,290 +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.truffle;
-
-import java.util.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.impl.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
-
-/**
- * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
- */
-public abstract class OptimizedCallNode extends DefaultCallNode {
-
-    protected int callCount;
-
-    private OptimizedCallNode(OptimizedCallTarget target) {
-        super(target);
-    }
-
-    @Override
-    public final boolean isSplittable() {
-        return getCallTarget().getRootNode().isSplittable();
-    }
-
-    @Override
-    public final OptimizedCallTarget getCallTarget() {
-        return (OptimizedCallTarget) super.getCallTarget();
-    }
-
-    public final int getCallCount() {
-        return callCount;
-    }
-
-    public TruffleInliningProfile createInliningProfile(OptimizedCallTarget target) {
-        return new OptimizedCallNodeProfile(target, this);
-    }
-
-    @SuppressWarnings("unused")
-    public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
-    }
-
-    @Override
-    public final OptimizedCallTarget getCurrentCallTarget() {
-        return (OptimizedCallTarget) super.getCurrentCallTarget();
-    }
-
-    @Override
-    public OptimizedCallTarget getSplitCallTarget() {
-        return null;
-    }
-
-    protected OptimizedCallNode inlineImpl() {
-        if (getParent() == null) {
-            throw new IllegalStateException("CallNode must be adopted before it is split.");
-        }
-
-        return replace(new InlinedOptimizedCallNode(getCallTarget(), getSplitCallTarget(), callCount));
-    }
-
-    public static OptimizedCallNode create(OptimizedCallTarget target) {
-        return new DefaultOptimizedCallNode(target);
-    }
-
-    @Override
-    public boolean isInlinable() {
-        return true;
-    }
-
-    private static final class DefaultOptimizedCallNode extends OptimizedCallNode {
-
-        private boolean trySplit = true;
-
-        DefaultOptimizedCallNode(OptimizedCallTarget target) {
-            super(target);
-            registerCallTarget(this);
-        }
-
-        @Override
-        public Object call(PackedFrame caller, Arguments arguments) {
-            if (CompilerDirectives.inInterpreter()) {
-                callCount++;
-                if (trySplit && callCount > 1) {
-                    trySplit = false;
-                    return trySplit(caller, arguments);
-                }
-            }
-            return callTarget.call(caller, arguments);
-        }
-
-        private Object trySplit(PackedFrame caller, Arguments arguments) {
-            if (shouldSplit()) {
-                return splitImpl(true).call(caller, arguments);
-            }
-            return callTarget.call(caller, arguments);
-        }
-
-        private boolean shouldSplit() {
-            if (!TruffleCompilerOptions.TruffleSplittingEnabled.getValue()) {
-                return false;
-            }
-            if (!isSplittable()) {
-                return false;
-            }
-            int nodeCount = NodeUtil.countNodes(getCallTarget().getRootNode(), OptimizedCallNodeProfile.COUNT_FILTER, false);
-            if (nodeCount > TruffleCompilerOptions.TruffleSplittingMaxCalleeSize.getValue()) {
-                return false;
-            }
-
-            // disable recursive splitting for now
-            OptimizedCallTarget splitTarget = getCallTarget();
-            List<OptimizedCallTarget> compilationRoots = OptimizedCallNodeProfile.findCompilationRoots(this);
-            for (OptimizedCallTarget compilationRoot : compilationRoots) {
-                if (compilationRoot == splitTarget || compilationRoot.getSplitSource() == splitTarget) {
-                    // recursive call found
-                    return false;
-                }
-            }
-
-            // max one child call and callCount > 2 and kind of small number of nodes
-            if (isMaxSingleCall()) {
-                return true;
-            }
-            return countPolymorphic() >= 1;
-        }
-
-        @Override
-        public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
-            trySplit = true;
-        }
-
-        private boolean isMaxSingleCall() {
-            return NodeUtil.countNodes(getCurrentCallTarget().getRootNode(), new NodeCountFilter() {
-                public boolean isCounted(Node node) {
-                    return node instanceof CallNode;
-                }
-            }) <= 1;
-        }
-
-        private int countPolymorphic() {
-            return NodeUtil.countNodes(getCallTarget().getRootNode(), new NodeCountFilter() {
-                public boolean isCounted(Node node) {
-                    NodeCost cost = node.getCost();
-                    boolean polymorphic = cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC;
-                    return polymorphic;
-                }
-            });
-        }
-
-        @Override
-        public boolean isInlined() {
-            return false;
-        }
-
-        @Override
-        public boolean split() {
-            if (!isSplittable()) {
-                // split is only allowed once and if the root node supports it
-                return false;
-            }
-            if (getParent() == null) {
-                throw new IllegalStateException("CallNode must be adopted before it is split.");
-            }
-            splitImpl(false);
-            return true;
-        }
-
-        private OptimizedCallNode splitImpl(boolean heuristic) {
-            OptimizedCallTarget splitCallTarget = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(getCallTarget().getRootNode().split());
-            splitCallTarget.setSplitSource(getCallTarget());
-            if (heuristic) {
-                OptimizedCallTarget.logSplit(this, getCallTarget(), splitCallTarget);
-            }
-            return replace(new SplitOptimizedCallNode(getCallTarget(), splitCallTarget, callCount));
-        }
-
-        @Override
-        public void inline() {
-            inlineImpl();
-        }
-
-        @Override
-        public OptimizedCallTarget getSplitCallTarget() {
-            return null;
-        }
-
-    }
-
-    private static final class InlinedOptimizedCallNode extends OptimizedCallNode {
-
-        private final OptimizedCallTarget splittedTarget;
-
-        public InlinedOptimizedCallNode(OptimizedCallTarget target, OptimizedCallTarget splittedTarget, int callCount) {
-            super(target);
-            this.splittedTarget = splittedTarget;
-            this.callCount = callCount;
-        }
-
-        @Override
-        public Object call(PackedFrame caller, Arguments arguments) {
-            if (CompilerDirectives.inInterpreter()) {
-                callCount++;
-            }
-            return getCurrentCallTarget().callInlined(caller, arguments);
-        }
-
-        @Override
-        public void inline() {
-        }
-
-        @Override
-        public boolean split() {
-            return false;
-        }
-
-        @Override
-        public boolean isInlined() {
-            return true;
-        }
-
-        @Override
-        public OptimizedCallTarget getSplitCallTarget() {
-            return splittedTarget;
-        }
-    }
-
-    private static class SplitOptimizedCallNode extends OptimizedCallNode {
-
-        private final OptimizedCallTarget splittedTarget;
-
-        public SplitOptimizedCallNode(OptimizedCallTarget target, OptimizedCallTarget splittedTarget, int callCount) {
-            super(target);
-            this.callCount = callCount;
-            this.splittedTarget = splittedTarget;
-        }
-
-        @Override
-        public Object call(PackedFrame caller, Arguments arguments) {
-            if (CompilerDirectives.inInterpreter()) {
-                callCount++;
-            }
-            return splittedTarget.call(caller, arguments);
-        }
-
-        @Override
-        public boolean isInlined() {
-            return false;
-        }
-
-        @Override
-        public final boolean split() {
-            return false;
-        }
-
-        @Override
-        public void inline() {
-            inlineImpl();
-        }
-
-        @Override
-        public final OptimizedCallTarget getSplitCallTarget() {
-            return splittedTarget;
-        }
-
-    }
-
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNodeProfile.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,256 +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.truffle;
-
-import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
-
-import java.util.*;
-
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.*;
-
-public class OptimizedCallNodeProfile implements TruffleInliningProfile {
-
-    static final CountFilter COUNT_FILTER = new CountFilter();
-
-    private static final String REASON_RECURSION = "recursion";
-    private static final String REASON_MAXIMUM_NODE_COUNT = "shallowTargetCount  > " + TruffleInliningMaxCalleeSize.getValue();
-    private static final String REASON_MAXIMUM_TOTAL_NODE_COUNT = "inlinedTotalCount > " + TruffleInliningMaxCallerSize.getValue();
-
-    private final OptimizedCallTarget callTarget;
-    private final OptimizedCallNode callNode;
-
-    private int targetDeepNodeCount;
-    private List<OptimizedCallTarget> compilationRoots;
-    private final int targetShallowNodeCount;
-    private final double averageFrequency;
-    private final double score;
-    private final boolean leaf;
-    private String reason;
-
-    public OptimizedCallNodeProfile(OptimizedCallTarget target, OptimizedCallNode callNode) {
-        this.callNode = callNode;
-        RootNode inlineRoot = callNode.getCurrentCallTarget().getRootNode();
-        this.callTarget = target;
-        this.targetShallowNodeCount = NodeUtil.countNodes(inlineRoot, COUNT_FILTER, false);
-        this.targetDeepNodeCount = NodeUtil.countNodes(inlineRoot, COUNT_FILTER, true);
-        this.compilationRoots = findCompilationRoots(callNode);
-        this.averageFrequency = calculateFrequency();
-        this.score = calculateScore();
-        this.leaf = calculateLeaf();
-
-    }
-
-    private boolean calculateLeaf() {
-        return NodeUtil.countNodes(callNode.getCurrentRootNode(), new NodeCountFilter() {
-            public boolean isCounted(Node node) {
-                if (node instanceof CallNode) {
-                    CallNode childCall = (CallNode) node;
-                    if (!childCall.isInlined()) {
-                        return true;
-                    }
-                }
-                return false;
-            }
-        }, true) <= 0;
-    }
-
-    private double calculateFrequency() {
-        return calculateAdvancedFrequency();
-    }
-
-    public OptimizedCallNode getCallNode() {
-        return callNode;
-    }
-
-    public double getScore() {
-        return score;
-    }
-
-    public double calculateScore() {
-        return averageFrequency / Math.max(1, targetDeepNodeCount);
-    }
-
-    public boolean isInliningAllowed() {
-        this.compilationRoots = findCompilationRoots(getCallNode());
-
-        OptimizedCallTarget inlineTarget = callNode.getCurrentCallTarget();
-        for (OptimizedCallTarget compilationRoot : compilationRoots) {
-            if (compilationRoot == inlineTarget) {
-                // recursive call found
-                reason = REASON_RECURSION;
-                return false;
-            }
-        }
-
-        if (targetShallowNodeCount > TruffleInliningMaxCalleeSize.getValue()) {
-            reason = REASON_MAXIMUM_NODE_COUNT;
-            return false;
-        }
-
-        this.targetDeepNodeCount = NodeUtil.countNodes(inlineTarget.getRootNode(), COUNT_FILTER, true);
-        // The maximum total node count cannot be cached since it may change during inlining.
-        int nextNodeCount = calculateInlinedTotalNodeCount(getCallNode());
-        if (nextNodeCount > TruffleInliningMaxCallerSize.getValue()) {
-            reason = REASON_MAXIMUM_TOTAL_NODE_COUNT;
-            return false;
-        }
-
-        return true;
-    }
-
-    private int calculateInlinedTotalNodeCount(OptimizedCallNode node) {
-        int currentNodeCount = 0;
-        for (OptimizedCallTarget compilationRoot : compilationRoots) {
-            TotalNodeCountVisitor visitor = new TotalNodeCountVisitor(node, targetDeepNodeCount);
-            compilationRoot.getRootNode().accept(visitor);
-            currentNodeCount = Math.max(currentNodeCount, visitor.count);
-        }
-        return currentNodeCount;
-    }
-
-    static class CountFilter implements NodeCountFilter {
-        public boolean isCounted(Node node) {
-            return countNode(node) >= 1;
-        }
-    }
-
-    static int countNode(Node node) {
-        NodeCost cost = node.getCost();
-        if (cost != null && cost != NodeCost.NONE && cost != NodeCost.UNINITIALIZED) {
-            return 1;
-        }
-        return 0;
-    }
-
-    private static class TotalNodeCountVisitor implements NodeVisitor {
-
-        private final OptimizedCallNode inlinedNode;
-        private final int inlinedNodeCount;
-
-        private int count;
-
-        public TotalNodeCountVisitor(OptimizedCallNode inlinedNode, int inlinedNodeCount) {
-            this.inlinedNode = inlinedNode;
-            this.inlinedNodeCount = inlinedNodeCount;
-        }
-
-        public boolean visit(Node node) {
-            count += countNode(node);
-            if (node instanceof OptimizedCallNode) {
-                OptimizedCallNode callNode = ((OptimizedCallNode) node);
-                if (callNode == inlinedNode) {
-                    count += inlinedNodeCount;
-                } else if (callNode.isInlined()) {
-                    callNode.getCurrentRootNode().accept(this);
-                }
-            }
-            return true;
-        }
-
-    }
-
-    double calculateAdvancedFrequency() {
-        // get the call hierarchy from call target to the call node
-        final ArrayDeque<OptimizedCallNode> callStack = new ArrayDeque<>();
-        callTarget.getRootNode().accept(new NodeVisitor() {
-            private boolean found = false;
-
-            public boolean visit(Node node) {
-                if (node == callNode) {
-                    // found our call
-                    callStack.push((OptimizedCallNode) node);
-                    found = true;
-                    return false;
-                }
-
-                if (node instanceof OptimizedCallNode) {
-                    OptimizedCallNode c = ((OptimizedCallNode) node);
-                    if (c.isInlined()) {
-                        if (!found) {
-                            callStack.push(c);
-                        }
-                        c.getCurrentRootNode().accept(this);
-                        if (!found) {
-                            callStack.pop();
-                        }
-                    }
-                }
-                return !found;
-            }
-        });
-
-        int parentCallCount = callTarget.getCompilationProfile().getCallCount();
-        double frequency = 1.0d;
-        for (OptimizedCallNode c : callStack) {
-            int childCallCount = c.getCallCount();
-            frequency *= childCallCount / (double) parentCallCount;
-            parentCallCount = c.getCurrentCallTarget().getCompilationProfile().getCallCount();
-        }
-        return frequency;
-    }
-
-    double calculateSimpleFrequency() {
-        return callNode.getCallCount() / (double) ((OptimizedCallTarget) callNode.getRootNode().getCallTarget()).getCompilationProfile().getCallCount();
-    }
-
-    static List<OptimizedCallTarget> findCompilationRoots(Node call) {
-        RootNode root = call.getRootNode();
-        if (root == null) {
-            return Collections.emptyList();
-        }
-        List<OptimizedCallTarget> roots = new ArrayList<>();
-        roots.add((OptimizedCallTarget) root.getCallTarget());
-        for (CallNode callNode : root.getCachedCallNodes()) {
-            if (callNode.isInlined()) {
-                roots.addAll(findCompilationRoots(callNode));
-            }
-        }
-        return roots;
-    }
-
-    public int compareTo(TruffleInliningProfile o) {
-        if (o instanceof OptimizedCallNodeProfile) {
-            int cmp = Boolean.compare(((OptimizedCallNodeProfile) o).leaf, leaf);
-            if (cmp == 0) {
-                return Double.compare(((OptimizedCallNodeProfile) o).getScore(), getScore());
-            }
-            return cmp;
-        }
-        return 0;
-    }
-
-    public Map<String, Object> getDebugProperties() {
-        Map<String, Object> properties = new LinkedHashMap<>();
-        OptimizedCallTarget.addASTSizeProperty(getCallNode().getCurrentRootNode().getRootNode(), properties);
-        properties.put("shallowCount", targetShallowNodeCount);
-        properties.put("currentCount", calculateInlinedTotalNodeCount(null));
-        properties.put("inlinedTotalCount", calculateInlinedTotalNodeCount(getCallNode()));
-        properties.put("score", score);
-        properties.put("frequency", averageFrequency);
-        properties.put("leaf", leaf);
-        properties.put("reason", reason);
-        return properties;
-    }
-
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,12 @@
  */
 package com.oracle.graal.truffle;
 
+import static com.oracle.graal.truffle.OptimizedCallTargetLog.*;
 import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
 
 import java.io.*;
 import java.util.*;
+import java.util.concurrent.atomic.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.debug.*;
@@ -33,7 +35,6 @@
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
 import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
 
 /**
  * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
@@ -44,31 +45,40 @@
 
     protected InstalledCode installedCode;
     protected boolean compilationEnabled;
-    private boolean inlined;
     protected int callCount;
-
+    protected boolean inliningPerformed;
     protected final CompilationProfile compilationProfile;
     protected final CompilationPolicy compilationPolicy;
-    private SpeculationLog speculationLog = new SpeculationLog();
     private OptimizedCallTarget splitSource;
+    private final AtomicInteger callSitesKnown = new AtomicInteger(0);
 
     public OptimizedCallTarget(RootNode rootNode, int invokeCounter, int compilationThreshold, boolean compilationEnabled, CompilationPolicy compilationPolicy) {
         super(rootNode);
-
         this.compilationEnabled = compilationEnabled;
         this.compilationPolicy = compilationPolicy;
-
         this.compilationProfile = new CompilationProfile(compilationThreshold, invokeCounter, rootNode.toString());
         if (TruffleCallTargetProfiling.getValue()) {
             registerCallTarget(this);
         }
     }
 
-    public OptimizedCallTarget getSplitSource() {
+    public final int getKnownCallSiteCount() {
+        return callSitesKnown.get();
+    }
+
+    public final void incrementKnownCallSites() {
+        callSitesKnown.incrementAndGet();
+    }
+
+    public final void decrementKnownCallSites() {
+        callSitesKnown.decrementAndGet();
+    }
+
+    public final OptimizedCallTarget getSplitSource() {
         return splitSource;
     }
 
-    public void setSplitSource(OptimizedCallTarget splitSource) {
+    public final void setSplitSource(OptimizedCallTarget splitSource) {
         this.splitSource = splitSource;
     }
 
@@ -89,378 +99,78 @@
     }
 
     @Override
-    public abstract Object call(PackedFrame caller, Arguments args);
+    public abstract Object call(Object[] args);
 
     public abstract InstalledCode compile();
 
-    public Object callInlined(PackedFrame caller, Arguments arguments) {
+    public final Object callInlined(Object[] arguments) {
         if (CompilerDirectives.inInterpreter()) {
             compilationProfile.reportInlinedCall();
         }
-        return executeHelper(caller, arguments);
+        return executeHelper(arguments);
     }
 
-    public void performInlining() {
-        if (!TruffleCompilerOptions.TruffleFunctionInlining.getValue()) {
+    public final void performInlining() {
+        if (!TruffleFunctionInlining.getValue()) {
             return;
         }
-        if (inlined) {
+        if (inliningPerformed) {
             return;
         }
-        inlined = true;
-
-        logInliningStart(this);
-        PriorityQueue<TruffleInliningProfile> queue = new PriorityQueue<>();
-
-        // Used to avoid running in cycles or inline nodes in Truffle trees
-        // which do not suffice the tree property.
-        Set<CallNode> visitedCallNodes = new HashSet<>();
-
-        queueCallSitesForInlining(this, getRootNode(), visitedCallNodes, queue);
-        TruffleInliningProfile callSite = queue.poll();
-        while (callSite != null) {
-            if (callSite.isInliningAllowed()) {
-                OptimizedCallNode callNode = callSite.getCallNode();
-                RootNode inlinedRoot = callNode.inlineImpl().getCurrentRootNode();
-                logInlined(this, callSite);
-                assert inlinedRoot != null;
-                queueCallSitesForInlining(this, inlinedRoot, visitedCallNodes, queue);
-            } else {
-                logInliningFailed(callSite);
-            }
-            callSite = queue.poll();
-        }
-        logInliningDone(this);
+        TruffleInliningHandler handler = new TruffleInliningHandler(new DefaultInliningPolicy());
+        TruffleInliningResult result = handler.decideInlining(this, 0);
+        performInlining(result);
+        logInliningDecision(result);
     }
 
-    private static void queueCallSitesForInlining(final OptimizedCallTarget target, RootNode rootNode, final Set<CallNode> visitedCallSites, final PriorityQueue<TruffleInliningProfile> queue) {
-        rootNode.accept(new NodeVisitor() {
-            public boolean visit(Node node) {
-                if (node instanceof OptimizedCallNode) {
-                    OptimizedCallNode call = ((OptimizedCallNode) node);
-                    if (!call.isInlined() && !visitedCallSites.contains(call)) {
-                        queue.add(call.createInliningProfile(target));
-                        visitedCallSites.add(call);
-                    }
-                    RootNode root = call.getCurrentRootNode();
-                    if (root != null && call.isInlined()) {
-                        root.accept(this);
-                    }
-                }
-                return true;
+    private void performInlining(TruffleInliningResult result) {
+        if (inliningPerformed) {
+            return;
+        }
+        inliningPerformed = true;
+        for (TruffleInliningProfile profile : result) {
+            profile.getCallNode().inline();
+            TruffleInliningResult recursiveResult = profile.getRecursiveResult();
+            if (recursiveResult != null) {
+                recursiveResult.getCallTarget().performInlining(recursiveResult);
             }
-        });
-    }
-
-    protected boolean shouldCompile() {
-        return compilationPolicy.shouldCompile(compilationProfile);
-    }
-
-    protected static boolean shouldInline() {
-        return TruffleFunctionInlining.getValue();
+        }
     }
 
     protected abstract void invalidate(Node oldNode, Node newNode, CharSequence reason);
 
-    public Object executeHelper(PackedFrame caller, Arguments args) {
-        VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), caller, args);
-        return getRootNode().execute(frame);
+    public final Object executeHelper(Object[] args) {
+        VirtualFrame frame = createFrame(getRootNode().getFrameDescriptor(), args);
+        return callProxy(frame);
     }
 
-    public static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, PackedFrame caller, Arguments args) {
-        return new FrameWithoutBoxing(descriptor, caller, args);
+    public static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, Object[] args) {
+        return new FrameWithoutBoxing(descriptor, args);
+    }
+
+    public static FrameWithoutBoxing createMaterializedFrame(FrameDescriptor descriptor, Object[] args) {
+        return new FrameWithoutBoxing(descriptor, args);
     }
 
     @Override
     public void reportLoopCount(int count) {
         compilationProfile.reportLoopCount(count);
-
-        // delegate to inlined call sites
-        for (CallNode callNode : getRootNode().getCachedCallNodes()) {
-            if (callNode.isInlined()) {
-                callNode.getRootNode().reportLoopCount(count);
-            }
-        }
     }
 
     @Override
     public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
         compilationProfile.reportNodeReplaced();
         invalidate(oldNode, newNode, reason);
-
-        // delegate to inlined call sites
-        for (CallNode callNode : getRootNode().getCachedCallNodes()) {
-            if (callNode.isInlined()) {
-                CallTarget target = callNode.getRootNode().getCallTarget();
-                if (target instanceof ReplaceObserver) {
-                    ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason);
-                }
-            }
-            if (callNode instanceof OptimizedCallNode) {
-                ((OptimizedCallNode) callNode).nodeReplaced(oldNode, newNode, reason);
-            }
-        }
     }
 
-    public SpeculationLog getSpeculationLog() {
-        return speculationLog;
-    }
+    public abstract SpeculationLog getSpeculationLog();
 
     public Map<String, Object> getDebugProperties() {
         Map<String, Object> properties = new LinkedHashMap<>();
-        addASTSizeProperty(getRootNode(), properties);
+        addASTSizeProperty(this, properties);
         properties.putAll(getCompilationProfile().getDebugProperties());
         return properties;
 
     }
 
-    private static void logInliningFailed(TruffleInliningProfile callSite) {
-        if (TraceTruffleInliningDetails.getValue()) {
-            log(2, "inline failed", callSite.getCallNode().getCurrentCallTarget().toString(), callSite.getDebugProperties());
-        }
-    }
-
-    private static void logInlined(final OptimizedCallTarget target, TruffleInliningProfile callSite) {
-        if (TraceTruffleInliningDetails.getValue() || TraceTruffleInlining.getValue()) {
-            log(2, "inline success", callSite.getCallNode().getCurrentCallTarget().toString(), callSite.getDebugProperties());
-
-            if (TraceTruffleInliningDetails.getValue()) {
-                RootNode root = callSite.getCallNode().getCurrentCallTarget().getRootNode();
-                root.accept(new NodeVisitor() {
-                    int depth = 1;
-
-                    public boolean visit(Node node) {
-                        if (node instanceof OptimizedCallNode) {
-                            OptimizedCallNode callNode = ((OptimizedCallNode) node);
-                            RootNode inlinedRoot = callNode.getCurrentRootNode();
-
-                            if (inlinedRoot != null) {
-                                Map<String, Object> properties = new LinkedHashMap<>();
-                                addASTSizeProperty(callNode.getCurrentRootNode(), properties);
-                                properties.putAll(callNode.createInliningProfile(target).getDebugProperties());
-                                String message;
-                                if (callNode.isInlined()) {
-                                    message = "inline success";
-                                } else {
-                                    message = "inline dispatch";
-                                }
-                                log(2 + (depth * 2), message, callNode.getCurrentCallTarget().toString(), properties);
-
-                                if (callNode.isInlined()) {
-                                    depth++;
-                                    inlinedRoot.accept(this);
-                                    depth--;
-                                }
-                            }
-                        }
-                        return true;
-                    }
-                });
-            }
-        }
-    }
-
-    private static void logInliningStart(OptimizedCallTarget target) {
-        if (TraceTruffleInliningDetails.getValue()) {
-            log(0, "inline start", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    private static void logInliningDone(OptimizedCallTarget target) {
-        if (TraceTruffleInliningDetails.getValue()) {
-            log(0, "inline done", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizingQueued(OptimizedCallTarget target) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            log(0, "opt queued", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addReplaceProperties(properties, oldNode, newNode);
-            properties.put("Reason", reason);
-            log(0, "opt unqueued", target.toString(), properties);
-        }
-    }
-
-    private static void addReplaceProperties(Map<String, Object> properties, Node oldNode, Node newNode) {
-        if (oldNode != null && newNode != null) {
-            properties.put("OldClass", oldNode.getClass().getSimpleName());
-            properties.put("NewClass", newNode.getClass().getSimpleName());
-            properties.put("Node", newNode);
-        }
-    }
-
-    static void logOptimizingStart(OptimizedCallTarget target) {
-        if (TraceTruffleCompilationDetails.getValue()) {
-            log(0, "opt start", target.toString(), target.getDebugProperties());
-        }
-    }
-
-    protected static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
-        if (TraceTruffleCompilation.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addReplaceProperties(properties, oldNode, newNode);
-            properties.put("Reason", reason);
-            log(0, "opt invalidated", target.toString(), properties);
-        }
-    }
-
-    protected static void logOptimizingFailed(OptimizedCallTarget callSite, CharSequence reason) {
-        Map<String, Object> properties = new LinkedHashMap<>();
-        properties.put("Reason", reason);
-        log(0, "opt fail", callSite.toString(), properties);
-    }
-
-    static void logOptimizingDone(OptimizedCallTarget target, Map<String, Object> properties) {
-        if (TraceTruffleCompilationDetails.getValue() || TraceTruffleCompilation.getValue()) {
-            log(0, "opt done", target.toString(), properties);
-        }
-        if (TraceTruffleCompilationPolymorphism.getValue()) {
-
-            target.getRootNode().accept(new NodeVisitor() {
-                public boolean visit(Node node) {
-                    NodeCost kind = node.getCost();
-                    if (kind == NodeCost.POLYMORPHIC || kind == NodeCost.MEGAMORPHIC) {
-                        Map<String, Object> props = new LinkedHashMap<>();
-                        props.put("simpleName", node.getClass().getSimpleName());
-                        String msg = kind == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
-                        log(0, msg, node.toString(), props);
-                    }
-                    if (node instanceof CallNode) {
-                        CallNode callNode = (CallNode) node;
-                        if (callNode.isInlined()) {
-                            callNode.getCurrentRootNode().accept(this);
-                        }
-                    }
-                    return true;
-                }
-            });
-
-        }
-    }
-
-    private static int splitCount = 0;
-
-    static void logSplit(OptimizedCallNode callNode, OptimizedCallTarget target, OptimizedCallTarget newTarget) {
-        if (TraceTruffleSplitting.getValue()) {
-            Map<String, Object> properties = new LinkedHashMap<>();
-            addASTSizeProperty(target.getRootNode(), properties);
-            properties.put("Split#", ++splitCount);
-            properties.put("Source", callNode.getEncapsulatingSourceSection());
-            log(0, "split", newTarget.toString(), properties);
-        }
-    }
-
-    static void addASTSizeProperty(RootNode target, Map<String, Object> properties) {
-        int polymorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
-            public boolean isCounted(Node node) {
-                return node.getCost() == NodeCost.POLYMORPHIC;
-            }
-        }, true);
-
-        int megamorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
-            public boolean isCounted(Node node) {
-                return node.getCost() == NodeCost.MEGAMORPHIC;
-            }
-        }, true);
-
-        String value = String.format("%4d (%d/%d)", NodeUtil.countNodes(target.getRootNode(), OptimizedCallNodeProfile.COUNT_FILTER, true), //
-                        polymorphicCount, megamorphicCount); //
-
-        properties.put("ASTSize", value);
-    }
-
-    static void log(int indent, String msg, String details, Map<String, Object> properties) {
-        StringBuilder sb = new StringBuilder();
-        sb.append(String.format("[truffle] %-16s ", msg));
-        for (int i = 0; i < indent; i++) {
-            sb.append(' ');
-        }
-        sb.append(String.format("%-" + (60 - indent) + "s", details));
-        if (properties != null) {
-            for (String property : properties.keySet()) {
-                Object value = properties.get(property);
-                if (value == null) {
-                    continue;
-                }
-                sb.append('|');
-                sb.append(property);
-
-                StringBuilder propertyBuilder = new StringBuilder();
-                if (value instanceof Integer) {
-                    propertyBuilder.append(String.format("%6d", value));
-                } else if (value instanceof Double) {
-                    propertyBuilder.append(String.format("%8.2f", value));
-                } else {
-                    propertyBuilder.append(value);
-                }
-
-                int length = Math.max(1, 20 - property.length());
-                sb.append(String.format(" %" + length + "s ", propertyBuilder.toString()));
-            }
-        }
-        OUT.println(sb.toString());
-    }
-
-    private static void printProfiling() {
-        List<OptimizedCallTarget> sortedCallTargets = new ArrayList<>(OptimizedCallTarget.callTargets.keySet());
-        Collections.sort(sortedCallTargets, new Comparator<OptimizedCallTarget>() {
-
-            @Override
-            public int compare(OptimizedCallTarget o1, OptimizedCallTarget o2) {
-                return o2.callCount - o1.callCount;
-            }
-        });
-
-        int totalCallCount = 0;
-        int totalInlinedCallSiteCount = 0;
-        int totalNodeCount = 0;
-        int totalInvalidationCount = 0;
-
-        OUT.println();
-        OUT.printf("%-50s | %-10s | %s / %s | %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count", "Inv");
-        for (OptimizedCallTarget callTarget : sortedCallTargets) {
-            if (callTarget.callCount == 0) {
-                continue;
-            }
-
-            int nodeCount = NodeUtil.countNodes(callTarget.getRootNode(), OptimizedCallNodeProfile.COUNT_FILTER, false);
-            int inlinedCallSiteCount = NodeUtil.countNodes(callTarget.getRootNode(), OptimizedCallNodeProfile.COUNT_FILTER, true);
-            String comment = callTarget.installedCode == null ? " int" : "";
-            comment += callTarget.compilationEnabled ? "" : " fail";
-            OUT.printf("%-50s | %10d | %15d | %10d | %3d%s\n", callTarget.getRootNode(), callTarget.callCount, inlinedCallSiteCount, nodeCount,
-                            callTarget.getCompilationProfile().getInvalidationCount(), comment);
-
-            totalCallCount += callTarget.callCount;
-            totalInlinedCallSiteCount += inlinedCallSiteCount;
-            totalNodeCount += nodeCount;
-            totalInvalidationCount += callTarget.getCompilationProfile().getInvalidationCount();
-        }
-        OUT.printf("%-50s | %10d | %15d | %10d | %3d\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNodeCount, totalInvalidationCount);
-    }
-
-    private static void registerCallTarget(OptimizedCallTarget callTarget) {
-        callTargets.put(callTarget, 0);
-    }
-
-    private static Map<OptimizedCallTarget, Integer> callTargets;
-    static {
-        if (TruffleCallTargetProfiling.getValue()) {
-            callTargets = new WeakHashMap<>();
-
-            Runtime.getRuntime().addShutdownHook(new Thread() {
-
-                @Override
-                public void run() {
-                    printProfiling();
-                }
-            });
-        }
-    }
-
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +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.truffle;
-
-import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
-
-import java.util.concurrent.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Call target for running truffle on a standard VM (and not in SubstrateVM).
- */
-public final class OptimizedCallTargetImpl extends OptimizedCallTarget {
-
-    protected final TruffleCompiler compiler;
-    private Future<InstalledCode> installedCodeTask;
-
-    OptimizedCallTargetImpl(RootNode rootNode, TruffleCompiler compiler, int invokeCounter, int compilationThreshold, boolean compilationEnabled) {
-        super(rootNode, invokeCounter, compilationThreshold, compilationEnabled, TruffleUseTimeForCompilationDecision.getValue() ? new TimedCompilationPolicy() : new DefaultCompilationPolicy());
-        this.compiler = compiler;
-    }
-
-    public boolean isOptimized() {
-        return installedCode != null || installedCodeTask != null;
-    }
-
-    @CompilerDirectives.SlowPath
-    @Override
-    public Object call(PackedFrame caller, Arguments args) {
-        return callHelper(caller, args);
-    }
-
-    private Object callHelper(PackedFrame caller, Arguments args) {
-        if (installedCode != null && installedCode.isValid()) {
-            reinstallCallMethodShortcut();
-        }
-        if (TruffleCallTargetProfiling.getValue()) {
-            callCount++;
-        }
-        if (CompilerDirectives.injectBranchProbability(CompilerDirectives.FASTPATH_PROBABILITY, installedCode != null)) {
-            try {
-                return installedCode.execute(this, caller, args);
-            } catch (InvalidInstalledCodeException ex) {
-                return compiledCodeInvalidated(caller, args);
-            }
-        } else {
-            return interpreterCall(caller, args);
-        }
-    }
-
-    private static void reinstallCallMethodShortcut() {
-        if (TraceTruffleCompilation.getValue()) {
-            OUT.println("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut.");
-        }
-        GraalTruffleRuntime.installOptimizedCallTargetCallMethod();
-    }
-
-    private Object compiledCodeInvalidated(PackedFrame caller, Arguments args) {
-        invalidate(null, null, "Compiled code invalidated");
-        return call(caller, args);
-    }
-
-    @Override
-    protected void invalidate(Node oldNode, Node newNode, CharSequence reason) {
-        InstalledCode m = this.installedCode;
-        if (m != null) {
-            CompilerAsserts.neverPartOfCompilation();
-            installedCode = null;
-            compilationProfile.reportInvalidated();
-            logOptimizedInvalidated(this, oldNode, newNode, reason);
-        }
-        cancelInstalledTask(oldNode, newNode, reason);
-    }
-
-    private void cancelInstalledTask(Node oldNode, Node newNode, CharSequence reason) {
-        Future<InstalledCode> task = this.installedCodeTask;
-        if (task != null) {
-            task.cancel(true);
-            this.installedCodeTask = null;
-            logOptimizingUnqueued(this, oldNode, newNode, reason);
-            compilationProfile.reportInvalidated();
-        }
-    }
-
-    private Object interpreterCall(PackedFrame caller, Arguments args) {
-        CompilerAsserts.neverPartOfCompilation();
-        compilationProfile.reportInterpreterCall();
-
-        if (compilationEnabled && compilationPolicy.shouldCompile(compilationProfile)) {
-            InstalledCode code = compile();
-            if (code != null && code.isValid()) {
-                this.installedCode = code;
-                try {
-                    return code.execute(this, caller, args);
-                } catch (InvalidInstalledCodeException ex) {
-                    return compiledCodeInvalidated(caller, args);
-                }
-            }
-        }
-        return executeHelper(caller, args);
-    }
-
-    private boolean isCompiling() {
-        Future<InstalledCode> codeTask = this.installedCodeTask;
-        if (codeTask != null) {
-            if (codeTask.isCancelled()) {
-                installedCodeTask = null;
-                return false;
-            }
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public InstalledCode compile() {
-        if (isCompiling()) {
-            if (installedCodeTask.isDone()) {
-                return receiveInstalledCode();
-            }
-            return null;
-        } else {
-            performInlining();
-            logOptimizingQueued(this);
-            this.installedCodeTask = compiler.compile(this);
-            if (!TruffleBackgroundCompilation.getValue()) {
-                return receiveInstalledCode();
-            }
-            return null;
-        }
-    }
-
-    private InstalledCode receiveInstalledCode() {
-        try {
-            return installedCodeTask.get();
-        } catch (InterruptedException | ExecutionException e) {
-            compilationEnabled = false;
-            logOptimizingFailed(this, e.getMessage());
-            if (e.getCause() instanceof BailoutException) {
-                // Bailout => move on.
-            } else {
-                if (TraceTruffleCompilationExceptions.getValue()) {
-                    e.printStackTrace(OUT);
-                }
-                if (TruffleCompilationExceptionsAreFatal.getValue()) {
-                    System.exit(-1);
-                }
-            }
-            return null;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,12 +24,10 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.lir.asm.*;
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
 
 /**
  * A service for creating a specialized {@link CompilationResultBuilder} used to inject code into
- * {@link OptimizedCallTarget#call(PackedFrame, Arguments)}.
+ * {@link OptimizedCallTarget#call(Object[])}.
  */
 public interface OptimizedCallTargetInstrumentationFactory extends CompilationResultBuilderFactory {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,285 @@
+/*
+ * 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.truffle;
+
+import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
+
+import java.io.*;
+import java.util.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
+
+public final class OptimizedCallTargetLog {
+
+    protected static final PrintStream OUT = TTY.out().out();
+
+    private static Map<OptimizedCallTarget, Integer> callTargets;
+    static {
+        if (TruffleCallTargetProfiling.getValue()) {
+            callTargets = new WeakHashMap<>();
+
+            Runtime.getRuntime().addShutdownHook(new Thread() {
+
+                @Override
+                public void run() {
+                    printProfiling();
+                }
+            });
+        }
+    }
+
+    private OptimizedCallTargetLog() {
+    }
+
+    public static void logInliningDecision(TruffleInliningResult result) {
+        if (!TraceTruffleInlining.getValue()) {
+            return;
+        }
+
+        logInliningStart(result.getCallTarget());
+        logInliningDecisionRecursive(result, 0);
+        logInliningDone(result.getCallTarget());
+    }
+
+    private static void logInliningDecisionRecursive(TruffleInliningResult result, int depth) {
+        List<OptimizedDirectCallNode> callNodes = searchCallNodes(result.getCallTarget());
+        for (OptimizedDirectCallNode callNode : callNodes) {
+            TruffleInliningProfile profile = result.getProfiles().get(callNode);
+            boolean inlined = result.isInlined(callNode);
+            String msg = inlined ? "inline success" : "inline failed";
+            logInlinedImpl(msg, callNode, profile, depth);
+            if (profile.getRecursiveResult() != null && inlined) {
+                logInliningDecisionRecursive(profile.getRecursiveResult(), depth + 1);
+            }
+        }
+    }
+
+    private static List<OptimizedDirectCallNode> searchCallNodes(final OptimizedCallTarget target) {
+        final List<OptimizedDirectCallNode> callNodes = new ArrayList<>();
+        target.getRootNode().accept(new NodeVisitor() {
+            public boolean visit(Node node) {
+                if (node instanceof OptimizedDirectCallNode) {
+                    callNodes.add((OptimizedDirectCallNode) node);
+                }
+                return true;
+            }
+        });
+        return callNodes;
+    }
+
+    private static void logInlinedImpl(String status, OptimizedDirectCallNode callNode, TruffleInliningProfile profile, int depth) {
+        Map<String, Object> properties = new LinkedHashMap<>();
+        addASTSizeProperty(callNode.getCurrentCallTarget(), properties);
+        if (profile != null) {
+            properties.putAll(profile.getDebugProperties());
+        }
+        log((depth * 2), status, callNode.getCurrentCallTarget().toString(), properties);
+    }
+
+    private static void logInliningStart(OptimizedCallTarget target) {
+        if (TraceTruffleInlining.getValue()) {
+            log(0, "inline start", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    private static void logInliningDone(OptimizedCallTarget target) {
+        if (TraceTruffleInlining.getValue()) {
+            log(0, "inline done", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizingQueued(OptimizedCallTarget target) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            log(0, "opt queued", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addReplaceProperties(properties, oldNode, newNode);
+            properties.put("Reason", reason);
+            log(0, "opt unqueued", target.toString(), properties);
+        }
+    }
+
+    private static void addReplaceProperties(Map<String, Object> properties, Node oldNode, Node newNode) {
+        if (oldNode != null && newNode != null) {
+            properties.put("OldClass", oldNode.getClass().getSimpleName());
+            properties.put("NewClass", newNode.getClass().getSimpleName());
+            properties.put("Node", newNode);
+        }
+    }
+
+    static void logOptimizingStart(OptimizedCallTarget target) {
+        if (TraceTruffleCompilationDetails.getValue()) {
+            log(0, "opt start", target.toString(), target.getDebugProperties());
+        }
+    }
+
+    public static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
+        if (TraceTruffleCompilation.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addReplaceProperties(properties, oldNode, newNode);
+            properties.put("Reason", reason);
+            log(0, "opt invalidated", target.toString(), properties);
+        }
+    }
+
+    public static void logOptimizingFailed(OptimizedCallTarget callSite, CharSequence reason) {
+        Map<String, Object> properties = new LinkedHashMap<>();
+        properties.put("Reason", reason);
+        log(0, "opt fail", callSite.toString(), properties);
+    }
+
+    static void logOptimizingDone(OptimizedCallTarget target, Map<String, Object> properties) {
+        if (TraceTruffleCompilationDetails.getValue() || TraceTruffleCompilation.getValue()) {
+            log(0, "opt done", target.toString(), properties);
+        }
+        if (TraceTruffleCompilationPolymorphism.getValue()) {
+
+            target.getRootNode().accept(new NodeVisitor() {
+                public boolean visit(Node node) {
+                    NodeCost kind = node.getCost();
+                    if (kind == NodeCost.POLYMORPHIC || kind == NodeCost.MEGAMORPHIC) {
+                        Map<String, Object> props = new LinkedHashMap<>();
+                        props.put("simpleName", node.getClass().getSimpleName());
+                        String msg = kind == NodeCost.MEGAMORPHIC ? "megamorphic" : "polymorphic";
+                        log(0, msg, node.toString(), props);
+                    }
+                    if (node instanceof DirectCallNode) {
+                        DirectCallNode callNode = (DirectCallNode) node;
+                        if (callNode.isInliningForced()) {
+                            callNode.getCurrentRootNode().accept(this);
+                        }
+                    }
+                    return true;
+                }
+            });
+
+        }
+    }
+
+    private static int splitCount = 0;
+
+    static void logSplit(OptimizedDirectCallNode callNode, OptimizedCallTarget target, OptimizedCallTarget newTarget) {
+        if (TraceTruffleSplitting.getValue()) {
+            Map<String, Object> properties = new LinkedHashMap<>();
+            addASTSizeProperty(target, properties);
+            properties.put("Split#", ++splitCount);
+            properties.put("Source", callNode.getEncapsulatingSourceSection());
+            log(0, "split", newTarget.toString(), properties);
+        }
+    }
+
+    static void addASTSizeProperty(OptimizedCallTarget target, Map<String, Object> properties) {
+        int polymorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node.getCost() == NodeCost.POLYMORPHIC;
+            }
+        }, true);
+
+        int megamorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node.getCost() == NodeCost.MEGAMORPHIC;
+            }
+        }, true);
+
+        String value = String.format("%4d (%d/%d)", OptimizedCallUtils.countNonTrivialNodes(target, true), polymorphicCount, megamorphicCount);
+        properties.put("ASTSize", value);
+    }
+
+    static void log(int indent, String msg, String details, Map<String, Object> properties) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(String.format("[truffle] %-16s ", msg));
+        for (int i = 0; i < indent; i++) {
+            sb.append(' ');
+        }
+        sb.append(String.format("%-" + (60 - indent) + "s", details));
+        if (properties != null) {
+            for (String property : properties.keySet()) {
+                Object value = properties.get(property);
+                if (value == null) {
+                    continue;
+                }
+                sb.append('|');
+                sb.append(property);
+
+                StringBuilder propertyBuilder = new StringBuilder();
+                if (value instanceof Integer) {
+                    propertyBuilder.append(String.format("%6d", value));
+                } else if (value instanceof Double) {
+                    propertyBuilder.append(String.format("%8.2f", value));
+                } else {
+                    propertyBuilder.append(value);
+                }
+
+                int length = Math.max(1, 20 - property.length());
+                sb.append(String.format(" %" + length + "s ", propertyBuilder.toString()));
+            }
+        }
+        OUT.println(sb.toString());
+    }
+
+    private static void printProfiling() {
+        List<OptimizedCallTarget> sortedCallTargets = new ArrayList<>(callTargets.keySet());
+        Collections.sort(sortedCallTargets, new Comparator<OptimizedCallTarget>() {
+
+            @Override
+            public int compare(OptimizedCallTarget o1, OptimizedCallTarget o2) {
+                return o2.callCount - o1.callCount;
+            }
+        });
+
+        int totalCallCount = 0;
+        int totalInlinedCallSiteCount = 0;
+        int totalNodeCount = 0;
+        int totalInvalidationCount = 0;
+
+        OUT.println();
+        OUT.printf("%-50s | %-10s | %s / %s | %s | %s\n", "Call Target", "Call Count", "Calls Sites Inlined", "Not Inlined", "Node Count", "Inv");
+        for (OptimizedCallTarget callTarget : sortedCallTargets) {
+            if (callTarget.callCount == 0) {
+                continue;
+            }
+
+            int nodeCount = OptimizedCallUtils.countNonTrivialNodes(callTarget, true);
+            String comment = callTarget.installedCode == null ? " int" : "";
+            comment += callTarget.compilationEnabled ? "" : " fail";
+            OUT.printf("%-50s | %10d | %15d | %10d | %3d%s\n", callTarget.getRootNode(), callTarget.callCount, nodeCount, nodeCount, callTarget.getCompilationProfile().getInvalidationCount(), comment);
+
+            totalCallCount += callTarget.callCount;
+            totalInlinedCallSiteCount += nodeCount;
+            totalNodeCount += nodeCount;
+            totalInvalidationCount += callTarget.getCompilationProfile().getInvalidationCount();
+        }
+        OUT.printf("%-50s | %10d | %15d | %10d | %3d\n", "Total", totalCallCount, totalInlinedCallSiteCount, totalNodeCount, totalInvalidationCount);
+    }
+
+    public static void registerCallTarget(OptimizedCallTarget callTarget) {
+        callTargets.put(callTarget, 0);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallUtils.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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.truffle;
+
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
+
+class OptimizedCallUtils {
+
+    public static int countCalls(OptimizedCallTarget target) {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node instanceof DirectCallNode;
+            }
+        }, true);
+    }
+
+    public static int countCallsInlined(OptimizedCallTarget target) {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return (node instanceof OptimizedDirectCallNode) && ((OptimizedDirectCallNode) node).isInlined();
+            }
+        }, true);
+    }
+
+    public static int countNonTrivialNodes(final OptimizedCallTarget target, final boolean inlined) {
+        return NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                NodeCost cost = node.getCost();
+                if (cost != null && cost != NodeCost.NONE && cost != NodeCost.UNINITIALIZED) {
+                    return true;
+                }
+                return false;
+            }
+        }, inlined);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedDirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,220 @@
+/*
+ * 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.truffle;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.frame.FrameInstance.FrameAccess;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
+
+/**
+ * A call node with a constant {@link CallTarget} that can be optimized by Graal.
+ */
+public final class OptimizedDirectCallNode extends DirectCallNode implements MaterializedFrameNotify {
+
+    private int callCount;
+    private boolean trySplit = true;
+    private boolean inliningForced;
+
+    @CompilationFinal private boolean inlined;
+    @CompilationFinal private OptimizedCallTarget splitCallTarget;
+    @CompilationFinal private FrameAccess outsideFrameAccess = FrameAccess.NONE;
+
+    private OptimizedDirectCallNode(OptimizedCallTarget target) {
+        super(target);
+    }
+
+    @Override
+    public Object call(VirtualFrame frame, Object[] arguments) {
+        if (CompilerDirectives.inInterpreter()) {
+            onInterpreterCall();
+        }
+        return callProxy(this, getCurrentCallTarget(), frame, arguments, inlined);
+    }
+
+    public static Object callProxy(MaterializedFrameNotify notify, CallTarget callTarget, VirtualFrame frame, Object[] arguments, boolean inlined) {
+        try {
+            if (notify.getOutsideFrameAccess() != FrameAccess.NONE) {
+                CompilerDirectives.materialize(frame);
+            }
+            if (inlined) {
+                return ((OptimizedCallTarget) callTarget).callInlined(arguments);
+            } else {
+                return callTarget.call(arguments);
+            }
+        } finally {
+            // this assertion is needed to keep the values from being cleared as non-live locals
+            assert notify != null & callTarget != null & frame != null;
+        }
+    }
+
+    @Override
+    public boolean isInlinable() {
+        return true;
+    }
+
+    @Override
+    public void forceInlining() {
+        inliningForced = true;
+    }
+
+    @Override
+    public boolean isInliningForced() {
+        return inliningForced;
+    }
+
+    @Override
+    public FrameAccess getOutsideFrameAccess() {
+        return outsideFrameAccess;
+    }
+
+    @Override
+    public void setOutsideFrameAccess(FrameAccess outsideFrameAccess) {
+        this.outsideFrameAccess = outsideFrameAccess;
+    }
+
+    @Override
+    public boolean isSplittable() {
+        return getCallTarget().getRootNode().isSplittable();
+    }
+
+    @Override
+    public OptimizedCallTarget getCallTarget() {
+        return (OptimizedCallTarget) super.getCallTarget();
+    }
+
+    public int getCallCount() {
+        return callCount;
+    }
+
+    @Override
+    public OptimizedCallTarget getCurrentCallTarget() {
+        return (OptimizedCallTarget) super.getCurrentCallTarget();
+    }
+
+    @Override
+    public OptimizedCallTarget getSplitCallTarget() {
+        return splitCallTarget;
+    }
+
+    private void onInterpreterCall() {
+        callCount++;
+        if (trySplit) {
+            if (callCount == 1) {
+                // on first call
+                getCurrentCallTarget().incrementKnownCallSites();
+            }
+            if (callCount > 1 && !inlined) {
+                trySplit = false;
+                if (shouldSplit()) {
+                    splitImpl(true);
+                }
+            }
+        }
+    }
+
+    /* Called by the runtime system if this CallNode is really going to be inlined. */
+    void inline() {
+        inlined = true;
+    }
+
+    @Override
+    public boolean isInlined() {
+        return inlined;
+    }
+
+    @Override
+    public boolean split() {
+        splitImpl(false);
+        return true;
+    }
+
+    private void splitImpl(boolean heuristic) {
+        CompilerAsserts.neverPartOfCompilation();
+
+        OptimizedCallTarget splitTarget = (OptimizedCallTarget) Truffle.getRuntime().createCallTarget(getCallTarget().getRootNode().split());
+        splitTarget.setSplitSource(getCallTarget());
+        if (heuristic) {
+            OptimizedCallTargetLog.logSplit(this, getCallTarget(), splitTarget);
+        }
+        if (callCount >= 1) {
+            getCallTarget().decrementKnownCallSites();
+            splitTarget.incrementKnownCallSites();
+        }
+        this.splitCallTarget = splitTarget;
+    }
+
+    private boolean shouldSplit() {
+        if (splitCallTarget != null) {
+            return false;
+        }
+        if (!TruffleCompilerOptions.TruffleSplittingEnabled.getValue()) {
+            return false;
+        }
+        if (!isSplittable()) {
+            return false;
+        }
+        OptimizedCallTarget splitTarget = getCallTarget();
+        int nodeCount = OptimizedCallUtils.countNonTrivialNodes(splitTarget, false);
+        if (nodeCount > TruffleCompilerOptions.TruffleSplittingMaxCalleeSize.getValue()) {
+            return false;
+        }
+
+        // disable recursive splitting for now
+        OptimizedCallTarget root = (OptimizedCallTarget) getRootNode().getCallTarget();
+        if (root == splitTarget || root.getSplitSource() == splitTarget) {
+            // recursive call found
+            return false;
+        }
+
+        // max one child call and callCount > 2 and kind of small number of nodes
+        if (isMaxSingleCall()) {
+            return true;
+        }
+        return countPolymorphic() >= 1;
+    }
+
+    private boolean isMaxSingleCall() {
+        return NodeUtil.countNodes(getCurrentCallTarget().getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                return node instanceof DirectCallNode;
+            }
+        }) <= 1;
+    }
+
+    private int countPolymorphic() {
+        return NodeUtil.countNodes(getCurrentCallTarget().getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
+                NodeCost cost = node.getCost();
+                boolean polymorphic = cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC;
+                return polymorphic;
+            }
+        });
+    }
+
+    public static OptimizedDirectCallNode create(OptimizedCallTarget target) {
+        return new OptimizedDirectCallNode(target);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedIndirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,53 @@
+/*
+ * 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.truffle;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.frame.FrameInstance.FrameAccess;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * A call node with a constant {@link CallTarget} that can be optimized by Graal.
+ */
+public final class OptimizedIndirectCallNode extends IndirectCallNode implements MaterializedFrameNotify {
+
+    @CompilationFinal private FrameAccess outsideFrameAccess = FrameAccess.NONE;
+
+    @Override
+    public Object call(VirtualFrame frame, CallTarget target, Object[] arguments) {
+        return OptimizedDirectCallNode.callProxy(this, target, frame, arguments, false);
+    }
+
+    @Override
+    public FrameAccess getOutsideFrameAccess() {
+        return outsideFrameAccess;
+    }
+
+    @Override
+    public void setOutsideFrameAccess(FrameAccess outsideFrameAccess) {
+        this.outsideFrameAccess = outsideFrameAccess;
+    }
+
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PackedFrameImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +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.truffle;
-
-import com.oracle.truffle.api.frame.*;
-
-/**
- * Implementation of a packed frame that contains only a raw pointer to the native stack. This
- * packed frame is only handed out by Truffle compiled methods.
- * 
- */
-public class PackedFrameImpl implements PackedFrame {
-
-    private long stackPointer;
-
-    @Override
-    public VirtualFrame unpack() {
-        return unpackNative();
-    }
-
-    private native VirtualFrame unpackNative();
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,6 +30,8 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.internal.*;
@@ -84,7 +86,7 @@
             throw Debug.handle(e);
         }
 
-        if (TraceTruffleCompilationHistogram.getValue()) {
+        if (TraceTruffleCompilationHistogram.getValue() || TraceTruffleCompilationDetails.getValue()) {
             constantReceivers = new HashSet<>();
         }
 
@@ -95,7 +97,14 @@
 
             // Replace thisNode with constant.
             ParameterNode thisNode = graph.getParameter(0);
-            thisNode.replaceAndDelete(ConstantNode.forObject(callTarget, providers.getMetaAccess(), graph));
+
+            /*
+             * Converting the call target to a Constant using the SnippetReflectionProvider is a
+             * workaround, we should think about a better solution. Since object constants are
+             * VM-specific, only the hosting VM knows how to do the conversion.
+             */
+            SnippetReflectionProvider snippetReflection = Graal.getRequiredCapability(SnippetReflectionProvider.class);
+            thisNode.replaceAndDelete(ConstantNode.forConstant(snippetReflection.forObject(callTarget), providers.getMetaAccess(), graph));
 
             // Canonicalize / constant propagate.
             PhaseContext baseContext = new PhaseContext(providers, assumptions);
@@ -114,8 +123,8 @@
             // Make sure frame does not escape.
             expandTree(graph, assumptions);
 
-            if (Thread.interrupted()) {
-                return graph;
+            if (Thread.currentThread().isInterrupted()) {
+                return null;
             }
 
             new VerifyFrameDoesNotEscapePhase().apply(graph, false);
@@ -123,7 +132,7 @@
             if (TraceTruffleCompilationHistogram.getValue() && constantReceivers != null) {
                 DebugHistogram histogram = Debug.createHistogram("Expanded Truffle Nodes");
                 for (Constant c : constantReceivers) {
-                    histogram.add(c.asObject().getClass().getSimpleName());
+                    histogram.add(providers.getMetaAccess().lookupJavaType(c).getName());
                 }
                 new DebugHistogramAsciiPrinter(TTY.out().out()).print(histogram);
             }
@@ -170,7 +179,7 @@
         PhaseContext phaseContext = new PhaseContext(providers, assumptions);
         TruffleExpansionLogger expansionLogger = null;
         if (TraceTruffleExpansion.getValue()) {
-            expansionLogger = new TruffleExpansionLogger(graph);
+            expansionLogger = new TruffleExpansionLogger(providers, graph);
         }
         boolean changed;
         do {
@@ -179,10 +188,10 @@
                 InvokeKind kind = methodCallTargetNode.invokeKind();
                 try (Indent id1 = Debug.logAndIndent("try inlining %s, kind = %s", methodCallTargetNode.targetMethod(), kind)) {
                     if (kind == InvokeKind.Static || (kind == InvokeKind.Special && (methodCallTargetNode.receiver().isConstant() || isFrame(methodCallTargetNode.receiver())))) {
-                        if (TraceTruffleCompilationHistogram.getValue() && kind == InvokeKind.Special) {
-                            ConstantNode constantNode = (ConstantNode) methodCallTargetNode.arguments().first();
-                            constantReceivers.add(constantNode.asConstant());
+                        if ((TraceTruffleCompilationHistogram.getValue() || TraceTruffleCompilationDetails.getValue()) && kind == InvokeKind.Special && methodCallTargetNode.receiver().isConstant()) {
+                            constantReceivers.add(methodCallTargetNode.receiver().asConstant());
                         }
+
                         Replacements replacements = providers.getReplacements();
                         Class<? extends FixedWithNextNode> macroSubstitution = replacements.getMacroSubstitution(methodCallTargetNode.targetMethod());
                         if (macroSubstitution != null) {
@@ -191,14 +200,9 @@
                             continue;
                         }
 
-                        if (TraceTruffleCompilationDetails.getValue() && kind == InvokeKind.Special) {
-                            ConstantNode constantNode = (ConstantNode) methodCallTargetNode.arguments().first();
-                            constantReceivers.add(constantNode.asConstant());
-                        }
-
                         StructuredGraph inlineGraph = replacements.getMethodSubstitution(methodCallTargetNode.targetMethod());
                         if (inlineGraph == null && !Modifier.isNative(methodCallTargetNode.targetMethod().getModifiers())) {
-                            inlineGraph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), assumptions, phaseContext);
+                            inlineGraph = parseGraph(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), assumptions, phaseContext, false);
                         }
 
                         if (inlineGraph != null) {
@@ -210,28 +214,23 @@
                                     expansionLogger.preExpand(methodCallTargetNode, inlineGraph);
                                 }
                                 List<Node> invokeUsages = methodCallTargetNode.invoke().asNode().usages().snapshot();
-                                // try (Indent in2 = Debug.logAndIndent(false, "do inlining")) {
                                 Map<Node, Node> inlined = InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, false);
                                 if (TraceTruffleExpansion.getValue()) {
                                     expansionLogger.postExpand(inlined);
                                 }
-                                // }
                                 if (Debug.isDumpEnabled()) {
                                     Debug.log("dump enabled");
                                     int nodeCountAfter = graph.getNodeCount();
                                     Debug.dump(graph, "After inlining %s %+d (%d)", methodCallTargetNode.targetMethod().toString(), nodeCountAfter - nodeCountBefore, nodeCountAfter);
                                 }
                                 canonicalizer.applyIncremental(graph, phaseContext, invokeUsages, mark);
+
                                 changed = true;
                             }
                         }
                     }
                 }
 
-                if (Thread.interrupted()) {
-                    return;
-                }
-
                 if (graph.getNodeCount() > TruffleCompilerOptions.TruffleGraphMaxNodes.getValue()) {
                     throw new BailoutException("Truffle compilation is exceeding maximum node count: " + graph.getNodeCount());
                 }
@@ -247,9 +246,10 @@
         return receiver instanceof NewFrameNode || Objects.equals(ObjectStamp.typeOrNull(receiver.stamp()), frameType);
     }
 
-    private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final PhaseContext phaseContext) {
+    private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final PhaseContext phaseContext,
+                    boolean ignoreSlowPath) {
 
-        StructuredGraph graph = truffleCache.lookup(targetMethod, arguments, assumptions, canonicalizer);
+        StructuredGraph graph = truffleCache.lookup(targetMethod, arguments, assumptions, canonicalizer, ignoreSlowPath);
 
         if (graph != null && targetMethod.getAnnotation(ExplodeLoop.class) != null) {
             assert graph.hasLoops() : graph + " does not contain a loop";
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluatorCanonicalizer.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluatorCanonicalizer.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,6 @@
 
 import java.lang.reflect.*;
 
-import sun.misc.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.Node;
 import com.oracle.graal.nodes.*;
@@ -44,8 +42,6 @@
         this.constantReflection = constantReflection;
     }
 
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
-
     @Override
     public Node canonicalize(Node node) {
         if (node instanceof LoadFieldNode) {
@@ -60,14 +56,11 @@
             }
         } else if (node instanceof LoadIndexedNode) {
             LoadIndexedNode loadIndexedNode = (LoadIndexedNode) node;
-            if (loadIndexedNode.array().isConstant() && !loadIndexedNode.array().isNullConstant() && loadIndexedNode.index().isConstant()) {
-                Object array = loadIndexedNode.array().asConstant().asObject();
-                long index = loadIndexedNode.index().asConstant().asLong();
-                if (index >= 0 && index < Array.getLength(array)) {
-                    int arrayBaseOffset = unsafe.arrayBaseOffset(array.getClass());
-                    int arrayIndexScale = unsafe.arrayIndexScale(array.getClass());
-                    Constant constant = constantReflection.readUnsafeConstant(loadIndexedNode.elementKind(), array, arrayBaseOffset + index * arrayIndexScale,
-                                    loadIndexedNode.elementKind() == Kind.Object);
+            if (loadIndexedNode.array().isConstant() && loadIndexedNode.index().isConstant()) {
+                int index = loadIndexedNode.index().asConstant().asInt();
+
+                Constant constant = constantReflection.readArrayElement(loadIndexedNode.array().asConstant(), index);
+                if (constant != null) {
                     return ConstantNode.forConstant(constant, metaAccess, loadIndexedNode.graph());
                 }
             }
@@ -75,9 +68,10 @@
         return node;
     }
 
-    private static boolean verifyFieldValue(ResolvedJavaField field, Constant constant) {
-        assert field.getAnnotation(Child.class) == null || constant.isNull() || constant.asObject() instanceof com.oracle.truffle.api.nodes.Node : "@Child field value must be a Node: " + field +
-                        ", but was: " + constant.asObject();
+    private boolean verifyFieldValue(ResolvedJavaField field, Constant constant) {
+        assert field.getAnnotation(Child.class) == null || constant.isNull() ||
+                        metaAccess.lookupJavaType(com.oracle.truffle.api.nodes.Node.class).isAssignableFrom(metaAccess.lookupJavaType(constant)) : "@Child field value must be a Node: " + field +
+                        ", but was: " + constant;
         return true;
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java	Wed Apr 16 14:02:52 2014 +0200
@@ -37,6 +37,8 @@
 
     /**
      * Returns a cached graph for a method with given arguments.
+     *
+     * @param ignoreSlowPath TODO
      */
-    StructuredGraph lookup(final ResolvedJavaMethod method, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final CanonicalizerPhase finalCanonicalizer);
+    StructuredGraph lookup(final ResolvedJavaMethod method, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final CanonicalizerPhase finalCanonicalizer, boolean ignoreSlowPath);
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -49,7 +49,6 @@
 import com.oracle.graal.truffle.phases.*;
 import com.oracle.graal.virtual.phases.ea.*;
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
 
 /**
@@ -76,7 +75,7 @@
         this.optimisticOptimizations = optimisticOptimizations;
         this.stringBuilderClass = providers.getMetaAccess().lookupJavaType(StringBuilder.class);
         try {
-            executeHelperMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.class.getDeclaredMethod("executeHelper", PackedFrame.class, Arguments.class));
+            executeHelperMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.class.getDeclaredMethod("executeHelper", Object[].class));
         } catch (NoSuchMethodException ex) {
             throw new RuntimeException(ex);
         }
@@ -89,9 +88,10 @@
     }
 
     @SuppressWarnings("unused")
-    public StructuredGraph lookup(final ResolvedJavaMethod method, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final CanonicalizerPhase finalCanonicalizer) {
+    public StructuredGraph lookup(final ResolvedJavaMethod method, final NodeInputList<ValueNode> arguments, final Assumptions assumptions, final CanonicalizerPhase finalCanonicalizer,
+                    boolean ignoreSlowPath) {
 
-        if (method.getAnnotation(CompilerDirectives.SlowPath.class) != null) {
+        if (!ignoreSlowPath && method.getAnnotation(CompilerDirectives.SlowPath.class) != null) {
             return null;
         }
 
@@ -236,7 +236,7 @@
     private void expandInvoke(MethodCallTargetNode methodCallTargetNode) {
         StructuredGraph inlineGraph = providers.getReplacements().getMethodSubstitution(methodCallTargetNode.targetMethod());
         if (inlineGraph == null) {
-            inlineGraph = TruffleCacheImpl.this.lookup(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), null, null);
+            inlineGraph = TruffleCacheImpl.this.lookup(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), null, null, false);
         }
         if (inlineGraph == this.markerGraph) {
             // Can happen for recursive calls.
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,7 +26,6 @@
 import static com.oracle.graal.compiler.GraalCompiler.*;
 import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
 
-import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
 
@@ -58,8 +57,6 @@
  */
 public class TruffleCompilerImpl implements TruffleCompiler {
 
-    private static final PrintStream OUT = TTY.out().out();
-
     private final Providers providers;
     private final Suites suites;
     private final PartialEvaluator partialEvaluator;
@@ -69,7 +66,7 @@
     private final TruffleCache truffleCache;
     private final ThreadPoolExecutor compileQueue;
 
-    private static final Class[] SKIPPED_EXCEPTION_CLASSES = new Class[]{UnexpectedResultException.class, SlowPathException.class, ArithmeticException.class};
+    private static final Class<?>[] SKIPPED_EXCEPTION_CLASSES = new Class[]{UnexpectedResultException.class, SlowPathException.class, ArithmeticException.class};
 
     public static final OptimisticOptimizations Optimizations = OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.UseExceptionProbability,
                     OptimisticOptimizations.Optimization.RemoveNeverExecutedCode, OptimisticOptimizations.Optimization.UseTypeCheckedInlining, OptimisticOptimizations.Optimization.UseTypeCheckHints);
@@ -123,7 +120,7 @@
             @Override
             public InstalledCode call() throws Exception {
                 try (Scope s = Debug.scope("Truffle", new TruffleDebugJavaMethod(compilable))) {
-                    return compileMethodImpl((OptimizedCallTargetImpl) compilable);
+                    return compileMethodImpl(compilable);
                 } catch (Throwable e) {
                     throw Debug.handle(e);
                 }
@@ -135,15 +132,11 @@
     public static final DebugTimer CompilationTime = Debug.timer("CompilationTime");
     public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation");
 
-    private InstalledCode compileMethodImpl(final OptimizedCallTargetImpl compilable) {
+    private InstalledCode compileMethodImpl(final OptimizedCallTarget compilable) {
         final StructuredGraph graph;
 
         if (TraceTruffleCompilation.getValue()) {
-            OptimizedCallTargetImpl.logOptimizingStart(compilable);
-        }
-
-        if (TraceTruffleInliningTree.getValue()) {
-            NodeUtil.printInliningTree(OUT, compilable.getRootNode());
+            OptimizedCallTargetLog.logOptimizingStart(compilable);
         }
 
         long timeCompilationStarted = System.nanoTime();
@@ -151,9 +144,11 @@
         try (TimerCloseable a = PartialEvaluationTime.start()) {
             graph = partialEvaluator.createGraph(compilable, assumptions);
         }
-        if (Thread.interrupted()) {
+
+        if (Thread.currentThread().isInterrupted()) {
             return null;
         }
+
         long timePartialEvaluationFinished = System.nanoTime();
         int nodeCountPartialEval = graph.getNodeCount();
         InstalledCode compiledMethod = compileMethodHelper(graph, assumptions, compilable.toString(), compilable.getSpeculationLog());
@@ -163,23 +158,28 @@
         if (compiledMethod == null) {
             throw new BailoutException("Could not install method, code cache is full!");
         }
+
         if (!compiledMethod.isValid()) {
             return null;
         }
 
         if (TraceTruffleCompilation.getValue()) {
             byte[] code = compiledMethod.getCode();
+            int calls = OptimizedCallUtils.countCalls(compilable);
+            int inlinedCalls = OptimizedCallUtils.countCallsInlined(compilable);
+            int dispatchedCalls = calls - inlinedCalls;
             Map<String, Object> properties = new LinkedHashMap<>();
-            OptimizedCallTarget.addASTSizeProperty(compilable.getRootNode(), properties);
+            OptimizedCallTargetLog.addASTSizeProperty(compilable, properties);
             properties.put("Time", String.format("%5.0f(%4.0f+%-4.0f)ms", //
                             (timeCompilationFinished - timeCompilationStarted) / 1e6, //
                             (timePartialEvaluationFinished - timeCompilationStarted) / 1e6, //
                             (timeCompilationFinished - timePartialEvaluationFinished) / 1e6));
-            properties.put("Nodes", String.format("%5d/%5d", nodeCountPartialEval, nodeCountLowered));
+            properties.put("CallNodes", String.format("I %5d/D %5d", inlinedCalls, dispatchedCalls));
+            properties.put("GraalNodes", String.format("%5d/%5d", nodeCountPartialEval, nodeCountLowered));
             properties.put("CodeSize", code != null ? code.length : 0);
             properties.put("Source", formatSourceSection(compilable.getRootNode().getSourceSection()));
 
-            OptimizedCallTargetImpl.logOptimizingDone(compilable, properties);
+            OptimizedCallTargetLog.logOptimizingDone(compilable, properties);
         }
         return compiledMethod;
     }
@@ -222,7 +222,7 @@
 
         result.setAssumptions(newAssumptions);
 
-        InstalledCode installedCode = null;
+        InstalledCode installedCode;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache()); TimerCloseable a = CodeInstallationTime.start()) {
             installedCode = providers.getCodeCache().addMethod(graph.method(), result, speculationLog);
         } catch (Throwable e) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -54,11 +54,11 @@
     @Option(help = "Enable automatic inlining of call targets")
     public static final OptionValue<Boolean> TruffleFunctionInlining = new OptionValue<>(true);
     @Option(help = "Maximum number of Graal IR nodes during partial evaluation")
-    public static final OptionValue<Integer> TruffleGraphMaxNodes = new OptionValue<>(30000);
+    public static final OptionValue<Integer> TruffleGraphMaxNodes = new OptionValue<>(45000);
     @Option(help = "Stop inlining if caller's cumulative tree size would exceed this limit")
     public static final OptionValue<Integer> TruffleInliningMaxCallerSize = new OptionValue<>(2250);
     @Option(help = "Skip inlining candidate if its tree size exceeds this limit")
-    public static final OptionValue<Integer> TruffleInliningMaxCalleeSize = new OptionValue<>(350);
+    public static final OptionValue<Integer> TruffleInliningMaxCalleeSize = new OptionValue<>(500);
     @Option(help = "Call frequency relative to call target")
     public static final OptionValue<Double> TruffleInliningMinFrequency = new OptionValue<>(0.3);
     @Option(help = "Allow inlining of less hot candidates if tree size is small")
@@ -80,7 +80,7 @@
 
     // tracing
     @Option(help = "")
-    public static final OptionValue<Boolean> TraceTruffleCompilation = new OptionValue<>(true);
+    public static final OptionValue<Boolean> TraceTruffleCompilation = new OptionValue<>(false);
     @Option(help = "")
     public static final OptionValue<Boolean> TraceTruffleCompilationDetails = new OptionValue<>(false);
     @Option(help = "")
@@ -100,10 +100,6 @@
     @Option(help = "")
     public static final OptionValue<Boolean> TraceTruffleInlining = new OptionValue<>(false);
     @Option(help = "")
-    public static final OptionValue<Boolean> TraceTruffleInliningTree = new OptionValue<>(false);
-    @Option(help = "")
-    public static final OptionValue<Boolean> TraceTruffleInliningDetails = new OptionValue<>(false);
-    @Option(help = "")
     public static final OptionValue<Boolean> TraceTruffleSplitting = new OptionValue<>(false);
     @Option(help = "")
     public static final OptionValue<Boolean> TruffleCallTargetProfiling = new StableOptionValue<>(false);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,13 +31,16 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.phases.util.*;
 
 public class TruffleExpansionLogger {
 
+    private final Providers providers;
     private final ExpansionTree root;
     private final Map<MethodCallTargetNode, ExpansionTree> callToParentTree = new HashMap<>();
 
-    public TruffleExpansionLogger(StructuredGraph graph) {
+    public TruffleExpansionLogger(Providers providers, StructuredGraph graph) {
+        this.providers = providers;
         root = new ExpansionTree(null, null, graph.method(), -1);
         registerParentInCalls(root, graph);
     }
@@ -47,16 +50,18 @@
 
         int sourceMethodBci = callTarget.invoke().bci();
         ResolvedJavaMethod targetMethod = callTarget.targetMethod();
-        Object targetReceiver = null;
-        if (!Modifier.isStatic(sourceMethod.getModifiers())) {
-            targetReceiver = callTarget.arguments().first().asConstant().asObject();
+        ResolvedJavaType targetReceiverType = null;
+        if (!Modifier.isStatic(sourceMethod.getModifiers()) && callTarget.receiver().isConstant()) {
+            targetReceiverType = providers.getMetaAccess().lookupJavaType(callTarget.arguments().first().asConstant());
         }
 
-        ExpansionTree parent = callToParentTree.get(callTarget);
-        assert parent != null;
-        callToParentTree.remove(callTarget);
-        ExpansionTree tree = new ExpansionTree(parent, targetReceiver, targetMethod, sourceMethodBci);
-        registerParentInCalls(tree, inliningGraph);
+        if (targetReceiverType != null) {
+            ExpansionTree parent = callToParentTree.get(callTarget);
+            assert parent != null;
+            callToParentTree.remove(callTarget);
+            ExpansionTree tree = new ExpansionTree(parent, targetReceiverType, targetMethod, sourceMethodBci);
+            registerParentInCalls(tree, inliningGraph);
+        }
     }
 
     @SuppressWarnings("unchecked")
@@ -92,14 +97,14 @@
     private static final class ExpansionTree implements Comparable<ExpansionTree> {
 
         private final ExpansionTree parent;
-        private final Object targetReceiver;
+        private final ResolvedJavaType targetReceiverType;
         private final ResolvedJavaMethod targetMethod;
         private final int parentBci;
         private final List<ExpansionTree> children = new ArrayList<>();
 
-        public ExpansionTree(ExpansionTree parent, Object receiver, ResolvedJavaMethod targetMethod, int parentBci) {
+        public ExpansionTree(ExpansionTree parent, ResolvedJavaType targetReceiverType, ResolvedJavaMethod targetMethod, int parentBci) {
             this.parent = parent;
-            this.targetReceiver = receiver;
+            this.targetReceiverType = targetReceiverType;
             this.targetMethod = targetMethod;
             this.parentBci = parentBci;
             if (parent != null) {
@@ -139,9 +144,9 @@
             }
 
             String constantType = "";
-            if (targetReceiver != null) {
-                if (!targetReceiver.getClass().getSimpleName().equals(className)) {
-                    constantType = "<" + targetReceiver.getClass().getSimpleName() + ">";
+            if (targetReceiverType != null) {
+                if (!targetReceiverType.getName().equals(className)) {
+                    constantType = "<" + targetReceiverType.getName() + ">";
                 }
             }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningHandler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.truffle;
+
+import java.util.*;
+
+import com.oracle.truffle.api.nodes.*;
+
+public final class TruffleInliningHandler {
+
+    private static final int MAXIMUM_RECURSIVE_DEPTH = 15;
+    private static final ProfileScoreComparator INLINING_SCORE = new ProfileScoreComparator();
+    private final TruffleInliningPolicy policy;
+    private final Map<OptimizedCallTarget, TruffleInliningResult> resultCache;
+
+    public TruffleInliningHandler(TruffleInliningPolicy policy) {
+        this.policy = policy;
+        this.resultCache = new HashMap<>();
+    }
+
+    public TruffleInliningResult decideInlining(OptimizedCallTarget target, int depth) {
+        if (resultCache.containsKey(target)) {
+            return resultCache.get(target);
+        }
+        resultCache.put(target, null);
+        TruffleInliningResult result = decideInliningImpl(target, depth);
+        resultCache.put(target, result);
+        return result;
+    }
+
+    private TruffleInliningResult decideInliningImpl(OptimizedCallTarget target, int depth) {
+        List<TruffleInliningProfile> profiles = lookupProfiles(target, depth);
+        Set<TruffleInliningProfile> inlined = new HashSet<>();
+        Collections.sort(profiles, INLINING_SCORE);
+        int budget = TruffleCompilerOptions.TruffleInliningMaxCallerSize.getValue() - OptimizedCallUtils.countNonTrivialNodes(target, true);
+        int index = 0;
+        for (TruffleInliningProfile profile : profiles) {
+            profile.setQueryIndex(index++);
+            if (policy.isAllowed(profile, budget)) {
+                inlined.add(profile);
+                budget -= profile.getDeepNodeCount();
+            }
+        }
+
+        int deepNodeCount = TruffleCompilerOptions.TruffleInliningMaxCallerSize.getValue() - budget;
+        return new TruffleInliningResult(target, profiles, inlined, deepNodeCount);
+    }
+
+    private List<TruffleInliningProfile> lookupProfiles(final OptimizedCallTarget target, int depth) {
+        final List<OptimizedDirectCallNode> callNodes = new ArrayList<>();
+        target.getRootNode().accept(new NodeVisitor() {
+            public boolean visit(Node node) {
+                if (node instanceof OptimizedDirectCallNode) {
+                    callNodes.add((OptimizedDirectCallNode) node);
+                }
+                return true;
+            }
+        });
+        final List<TruffleInliningProfile> profiles = new ArrayList<>();
+        for (OptimizedDirectCallNode callNode : callNodes) {
+            profiles.add(lookupProfile(target, callNode, depth));
+        }
+        return profiles;
+    }
+
+    public TruffleInliningProfile lookupProfile(OptimizedCallTarget parentTarget, OptimizedDirectCallNode ocn, int depth) {
+        OptimizedCallTarget target = ocn.getCurrentCallTarget();
+
+        int callSites = ocn.getCurrentCallTarget().getKnownCallSiteCount();
+        int nodeCount = OptimizedCallUtils.countNonTrivialNodes(target, false);
+        double frequency = calculateFrequency(parentTarget, ocn);
+        boolean forced = ocn.isInliningForced();
+
+        int deepNodeCount;
+        TruffleInliningResult recursiveResult;
+        boolean recursiveCall = false;
+        if (target.inliningPerformed || depth > MAXIMUM_RECURSIVE_DEPTH) {
+            deepNodeCount = OptimizedCallUtils.countNonTrivialNodes(target, true);
+            recursiveResult = null;
+        } else {
+            recursiveResult = decideInlining(ocn.getCurrentCallTarget(), depth + 1);
+            if (recursiveResult == null) {
+                recursiveCall = true;
+                deepNodeCount = Integer.MAX_VALUE;
+            } else {
+                deepNodeCount = recursiveResult.getNodeCount();
+            }
+        }
+
+        TruffleInliningProfile profile = new TruffleInliningProfile(ocn, callSites, nodeCount, deepNodeCount, frequency, forced, recursiveCall, recursiveResult);
+        profile.setScore(policy.calculateScore(profile));
+        return profile;
+    }
+
+    public TruffleInliningPolicy getPolicy() {
+        return policy;
+    }
+
+    private static double calculateFrequency(OptimizedCallTarget target, OptimizedDirectCallNode ocn) {
+        return (double) Math.max(1, target.getCompilationProfile().getCallCount()) / Math.max(1, ocn.getCallCount());
+    }
+
+    private final static class ProfileScoreComparator implements Comparator<TruffleInliningProfile> {
+
+        public int compare(TruffleInliningProfile o1, TruffleInliningProfile o2) {
+            return Double.compare(o2.getScore(), o1.getScore());
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningPolicy.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,31 @@
+/*
+ * 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.truffle;
+
+public interface TruffleInliningPolicy {
+
+    boolean isAllowed(TruffleInliningProfile profile, int currentBudgetLeft);
+
+    double calculateScore(TruffleInliningProfile profile);
+
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningProfile.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningProfile.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,14 +24,96 @@
 
 import java.util.*;
 
-public interface TruffleInliningProfile extends Comparable<TruffleInliningProfile> {
+public class TruffleInliningProfile {
+
+    private final OptimizedDirectCallNode callNode;
+    private final int nodeCount;
+    private final int deepNodeCount;
+    private final int callSites;
+    private final double frequency;
+    private final boolean forced;
+    private final boolean recursiveCall;
+    private final TruffleInliningResult recursiveResult;
+
+    private String failedReason;
+    private int queryIndex = -1;
+    private double score;
 
-    OptimizedCallNode getCallNode();
+    public TruffleInliningProfile(OptimizedDirectCallNode callNode, int callSites, int nodeCount, int deepNodeCount, double frequency, boolean forced, boolean recursiveCall,
+                    TruffleInliningResult recursiveResult) {
+        this.callNode = callNode;
+        this.callSites = callSites;
+        this.nodeCount = nodeCount;
+        this.deepNodeCount = deepNodeCount;
+        this.frequency = frequency;
+        this.recursiveCall = recursiveCall;
+        this.forced = forced;
+        this.recursiveResult = recursiveResult;
+    }
+
+    public boolean isRecursiveCall() {
+        return recursiveCall;
+    }
 
-    boolean isInliningAllowed();
+    public OptimizedDirectCallNode getCallNode() {
+        return callNode;
+    }
+
+    public int getCallSites() {
+        return callSites;
+    }
+
+    public int getNodeCount() {
+        return nodeCount;
+    }
+
+    public TruffleInliningResult getRecursiveResult() {
+        return recursiveResult;
+    }
 
-    int compareTo(TruffleInliningProfile o);
+    public void setScore(double score) {
+        this.score = score;
+    }
+
+    public double getScore() {
+        return score;
+    }
+
+    public String getFailedReason() {
+        return failedReason;
+    }
+
+    public void setQueryIndex(int queryIndex) {
+        this.queryIndex = queryIndex;
+    }
+
+    public int getQueryIndex() {
+        return queryIndex;
+    }
 
-    Map<String, Object> getDebugProperties();
+    public void setFailedReason(String reason) {
+        this.failedReason = reason;
+    }
+
+    public boolean isForced() {
+        return forced;
+    }
+
+    public double getFrequency() {
+        return frequency;
+    }
 
+    public int getDeepNodeCount() {
+        return deepNodeCount;
+    }
+
+    public Map<String, Object> getDebugProperties() {
+        Map<String, Object> properties = new LinkedHashMap<>();
+        properties.put("nodeCount", String.format("%5d/%5d", deepNodeCount, nodeCount));
+        properties.put("frequency", frequency);
+        properties.put("score", String.format("%8.4f", getScore()));
+        properties.put(String.format("index=%3d, force=%s, callSites=%2d", queryIndex, (forced ? "Y" : "N"), callSites), "");
+        properties.put("reason", failedReason);
+        return properties;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleInliningResult.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ * 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.truffle;
+
+import java.util.*;
+
+public final class TruffleInliningResult implements Iterable<TruffleInliningProfile> {
+
+    private final OptimizedCallTarget callTarget;
+    private final Map<OptimizedDirectCallNode, TruffleInliningProfile> profiles;
+    private final Set<TruffleInliningProfile> inlined;
+    private final int nodeCount;
+
+    public TruffleInliningResult(OptimizedCallTarget callTarget, List<TruffleInliningProfile> profiles, Set<TruffleInliningProfile> inlined, int nodeCount) {
+        this.callTarget = callTarget;
+        this.profiles = new HashMap<>();
+        for (TruffleInliningProfile profile : profiles) {
+            this.profiles.put(profile.getCallNode(), profile);
+        }
+        this.nodeCount = nodeCount;
+        this.inlined = inlined;
+    }
+
+    public Map<OptimizedDirectCallNode, TruffleInliningProfile> getProfiles() {
+        return profiles;
+    }
+
+    public int getNodeCount() {
+        return nodeCount;
+    }
+
+    public OptimizedCallTarget getCallTarget() {
+        return callTarget;
+    }
+
+    public boolean isInlined(OptimizedDirectCallNode path) {
+        return inlined.contains(profiles.get(path));
+    }
+
+    public int size() {
+        return inlined.size();
+    }
+
+    public Iterator<TruffleInliningProfile> iterator() {
+        return Collections.unmodifiableSet(inlined).iterator();
+    }
+
+    @Override
+    public String toString() {
+        return inlined.toString();
+    }
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Wed Apr 16 14:02:52 2014 +0200
@@ -26,40 +26,33 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
-import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.substitutions.*;
 
 /**
  * Custom {@link Replacements} for Truffle compilation.
  */
-public final class TruffleReplacements extends ReplacementsImpl {
+public abstract class TruffleReplacements extends ReplacementsImpl {
 
     private final Replacements graalReplacements;
 
-    private TruffleReplacements(Providers providers) {
-        super(providers, providers.getReplacements().getAssumptions(), providers.getCodeCache().getTarget());
+    protected TruffleReplacements(Providers providers, SnippetReflectionProvider snippetReflection) {
+        super(providers, snippetReflection, providers.getReplacements().getAssumptions(), providers.getCodeCache().getTarget());
         this.graalReplacements = providers.getReplacements();
+
+        registerTruffleSubstitutions();
     }
 
-    public static Replacements makeInstance() {
-        Providers graalProviders = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
-        Replacements truffleReplacements = new TruffleReplacements(graalProviders);
-
-        truffleReplacements.registerSubstitutions(CompilerAssertsSubstitutions.class);
-        truffleReplacements.registerSubstitutions(CompilerDirectivesSubstitutions.class);
-        truffleReplacements.registerSubstitutions(ExactMathSubstitutions.class);
-        truffleReplacements.registerSubstitutions(FrameWithoutBoxingSubstitutions.class);
-        truffleReplacements.registerSubstitutions(OptimizedAssumptionSubstitutions.class);
-        truffleReplacements.registerSubstitutions(OptimizedCallTargetSubstitutions.class);
-        truffleReplacements.registerSubstitutions(OptimizedCallTargetImplSubstitutions.class);
-
-        return truffleReplacements;
+    protected void registerTruffleSubstitutions() {
+        registerSubstitutions(CompilerAssertsSubstitutions.class);
+        registerSubstitutions(CompilerDirectivesSubstitutions.class);
+        registerSubstitutions(ExactMathSubstitutions.class);
+        registerSubstitutions(OptimizedAssumptionSubstitutions.class);
+        registerSubstitutions(OptimizedCallTargetSubstitutions.class);
     }
 
     @Override
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleTreeDumpHandler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import com.oracle.graal.debug.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.GraphPrintVisitor.ChildSupplier;
 
 public class TruffleTreeDumpHandler implements DebugDumpHandler {
 
@@ -32,10 +33,40 @@
     public void dump(Object object, final String message) {
         if (object instanceof RootCallTarget) {
             RootCallTarget callTarget = (RootCallTarget) object;
-            if (callTarget.getRootNode() != null) {
-                new GraphPrintVisitor().beginGroup(callTarget.toString()).beginGraph(message).visit(callTarget.getRootNode()).printToNetwork(false);
+            dumpRootCallTarget(message, callTarget);
+        }
+    }
+
+    private static void dumpRootCallTarget(final String message, RootCallTarget callTarget) {
+        if (callTarget.getRootNode() != null) {
+            final GraphPrintVisitor visitor = new GraphPrintVisitor();
+
+            final OptimizedCallTarget oct = (OptimizedCallTarget) callTarget;
+
+            visitor.beginGroup(callTarget.toString());
+            dumpFullTree(visitor, message, oct);
+            visitor.printToNetwork(false);
+        }
+    }
+
+    private static void dumpFullTree(final GraphPrintVisitor visitor, final String message, final OptimizedCallTarget oct) {
+        visitor.setChildSupplier(new ChildSupplier() {
+
+            public Object startNode(Object callNode) {
+                if (callNode instanceof OptimizedDirectCallNode) {
+                    if (((OptimizedDirectCallNode) callNode).isInlined()) {
+                        return ((OptimizedDirectCallNode) callNode).getCurrentRootNode();
+                    }
+                }
+                return null;
             }
-        }
+
+            public void endNode(Object callNode) {
+            }
+        });
+
+        visitor.beginGraph(message).visit(oct.getRootNode());
+        visitor.setChildSupplier(null);
     }
 
     public void close() {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/AssumptionNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/AssumptionNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,8 @@
 package com.oracle.graal.truffle.nodes;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.replacements.nodes.*;
@@ -39,13 +41,21 @@
         return arguments.first();
     }
 
+    private static SnippetReflectionProvider getSnippetReflection() {
+        /*
+         * This class requires access to the objects encapsulated in Constants, and therefore breaks
+         * the compiler-VM separation of object constants.
+         */
+        return Graal.getRequiredCapability(SnippetReflectionProvider.class);
+    }
+
     @Override
     public void simplify(SimplifierTool tool) {
         ValueNode assumption = getAssumption();
         if (tool.assumptions() != null && assumption.isConstant()) {
             Constant c = assumption.asConstant();
             assert c.getKind() == Kind.Object;
-            Object object = c.asObject();
+            Object object = getSnippetReflection().asObject(c);
             OptimizedAssumption assumptionObject = (OptimizedAssumption) object;
             StructuredGraph graph = graph();
             if (assumptionObject.isValid()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,7 +40,7 @@
         ValueNode arg = arguments.get(0);
         String message = "";
         if (arg.isConstant()) {
-            message = (String) arg.asConstant().asObject();
+            message = arg.asConstant().toValueString();
         }
         throw new BailoutException(message);
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/LoadIndexedFinalNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/LoadIndexedFinalNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,10 +22,6 @@
  */
 package com.oracle.graal.truffle.nodes;
 
-import java.lang.reflect.*;
-
-import sun.misc.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
@@ -52,13 +48,9 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (array().isConstant() && !array().isNullConstant() && index().isConstant()) {
-            Object array = array().asConstant().asObject();
-            long index = index().asConstant().asLong();
-            if (index >= 0 && index < Array.getLength(array)) {
-                int arrayBaseOffset = Unsafe.getUnsafe().arrayBaseOffset(array.getClass());
-                int arrayIndexScale = Unsafe.getUnsafe().arrayIndexScale(array.getClass());
-                Constant constant = tool.getConstantReflection().readUnsafeConstant(elementKind(), array().asConstant(), arrayBaseOffset + index * arrayIndexScale, elementKind() == Kind.Object);
+        if (array().isConstant() && index().isConstant()) {
+            Constant constant = tool.getConstantReflection().readArrayElement(array().asConstant(), index().asConstant().asInt());
+            if (constant != null) {
                 return ConstantNode.forConstant(constant, tool.getMetaAccess(), graph());
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/ObjectLocationIdentity.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013, 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.truffle.nodes;
+
+import java.util.*;
+
+import com.oracle.graal.api.meta.*;
+
+/**
+ * A {@link LocationIdentity} wrapping an object.
+ */
+public final class ObjectLocationIdentity implements LocationIdentity {
+
+    private static HashMap<Constant, LocationIdentity> map = new HashMap<>();
+
+    private Constant object;
+
+    public static LocationIdentity create(Constant object) {
+        assert object.getKind() == Kind.Object && object.isNonNull();
+        synchronized (map) {
+            if (map.containsKey(object)) {
+                return map.get(object);
+            } else {
+                ObjectLocationIdentity locationIdentity = new ObjectLocationIdentity(object);
+                map.put(object, locationIdentity);
+                return locationIdentity;
+            }
+        }
+    }
+
+    private ObjectLocationIdentity(Constant object) {
+        this.object = object;
+    }
+
+    @Override
+    public String toString() {
+        return "Identity(" + object + ")";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/ForceMaterializeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, 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.truffle.nodes.frame;
+
+import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.type.*;
+
+public class ForceMaterializeNode extends FixedWithNextNode implements LIRGenLowerable {
+
+    @Input private ValueNode object;
+
+    public ForceMaterializeNode(ValueNode object) {
+        super(StampFactory.forVoid());
+        this.object = object;
+    }
+
+    public void generate(NodeLIRBuilder generator) {
+        // nothing to do
+    }
+
+    @NodeIntrinsic
+    public native static void force(Object object);
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,8 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
@@ -35,7 +37,6 @@
 import com.oracle.graal.nodes.virtual.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.truffle.nodes.*;
-import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
 /**
@@ -45,35 +46,37 @@
 public class NewFrameNode extends FixedWithNextNode implements IterableNodeType, VirtualizableAllocation, Canonicalizable {
 
     @Input private ValueNode descriptor;
-    @Input private ValueNode caller;
     @Input private ValueNode arguments;
 
-    public NewFrameNode(Stamp stamp, ValueNode descriptor, ValueNode caller, ValueNode arguments) {
+    public NewFrameNode(Stamp stamp, ValueNode descriptor, ValueNode arguments) {
         super(stamp);
         this.descriptor = descriptor;
-        this.caller = caller;
         this.arguments = arguments;
     }
 
-    public NewFrameNode(ResolvedJavaType frameType, ValueNode descriptor, ValueNode caller, ValueNode arguments) {
-        this(StampFactory.exactNonNull(frameType), descriptor, caller, arguments);
+    public NewFrameNode(ResolvedJavaType frameType, ValueNode descriptor, ValueNode arguments) {
+        this(StampFactory.exactNonNull(frameType), descriptor, arguments);
     }
 
     public ValueNode getDescriptor() {
         return descriptor;
     }
 
-    public ValueNode getCaller() {
-        return caller;
-    }
-
     public ValueNode getArguments() {
         return arguments;
     }
 
+    private static SnippetReflectionProvider getSnippetReflection() {
+        /*
+         * This class requires access to the objects encapsulated in Constants, and therefore breaks
+         * the compiler-VM separation of object constants.
+         */
+        return Graal.getRequiredCapability(SnippetReflectionProvider.class);
+    }
+
     private FrameDescriptor getConstantFrameDescriptor() {
         assert descriptor.isConstant() && !descriptor.isNullConstant();
-        return (FrameDescriptor) descriptor.asConstant().asObject();
+        return (FrameDescriptor) getSnippetReflection().asObject(descriptor.asConstant());
     }
 
     private int getFrameSize() {
@@ -142,7 +145,6 @@
         ResolvedJavaField[] frameFields = frameType.getInstanceFields(true);
 
         ResolvedJavaField descriptorField = findField(frameFields, "descriptor");
-        ResolvedJavaField callerField = findField(frameFields, "caller");
         ResolvedJavaField argumentsField = findField(frameFields, "arguments");
         ResolvedJavaField localsField = findField(frameFields, "locals");
         ResolvedJavaField primitiveLocalsField = findField(frameFields, "primitiveLocals");
@@ -159,7 +161,7 @@
 
         if (frameSize > 0) {
             FrameDescriptor frameDescriptor = getConstantFrameDescriptor();
-            ConstantNode objectDefault = ConstantNode.forObject(frameDescriptor.getTypeConversion().getDefaultValue(), tool.getMetaAccessProvider(), graph());
+            ConstantNode objectDefault = ConstantNode.forConstant(getSnippetReflection().forObject(frameDescriptor.getTypeConversion().getDefaultValue()), tool.getMetaAccessProvider(), graph());
             ConstantNode tagDefault = ConstantNode.forByte((byte) 0, graph());
             for (int i = 0; i < frameSize; i++) {
                 objectArrayEntryState[i] = objectDefault;
@@ -173,11 +175,10 @@
         tool.createVirtualObject(virtualFramePrimitiveArray, primitiveArrayEntryState, Collections.<MonitorIdNode> emptyList());
         tool.createVirtualObject(virtualFrameTagArray, tagArrayEntryState, Collections.<MonitorIdNode> emptyList());
 
-        assert frameFields.length == 6;
+        assert frameFields.length == 5;
         ValueNode[] frameEntryState = new ValueNode[frameFields.length];
         List<ResolvedJavaField> frameFieldList = Arrays.asList(frameFields);
         frameEntryState[frameFieldList.indexOf(descriptorField)] = getDescriptor();
-        frameEntryState[frameFieldList.indexOf(callerField)] = getCaller();
         frameEntryState[frameFieldList.indexOf(argumentsField)] = getArguments();
         frameEntryState[frameFieldList.indexOf(localsField)] = virtualFrameObjectArray;
         frameEntryState[frameFieldList.indexOf(primitiveLocalsField)] = virtualFramePrimitiveArray;
@@ -229,5 +230,5 @@
     }
 
     @NodeIntrinsic
-    public static native FrameWithoutBoxing allocate(@ConstantNodeParameter Class<? extends VirtualFrame> frameType, FrameDescriptor descriptor, PackedFrame caller, Arguments args);
+    public static native FrameWithoutBoxing allocate(@ConstantNodeParameter Class<? extends VirtualFrame> frameType, FrameDescriptor descriptor, Object[] args);
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,11 +30,12 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
+import com.oracle.graal.truffle.nodes.*;
 import com.oracle.truffle.api.*;
 
 /**
  * Load of a final value from a location specified as an offset relative to an object.
- * 
+ *
  * Substitution for method {@link CompilerDirectives#unsafeGetFinalObject} and friends.
  */
 public class CustomizedUnsafeLoadFinalNode extends FixedWithNextNode implements Canonicalizable, Virtualizable, Lowerable {
@@ -56,7 +57,7 @@
     @Override
     public Node canonical(CanonicalizerTool tool) {
         if (object.isConstant() && !object.isNullConstant() && offset.isConstant()) {
-            Constant constant = tool.getConstantReflection().readUnsafeConstant(accessKind, object.asConstant().asObject(), offset.asConstant().asLong(), accessKind == Kind.Object);
+            Constant constant = tool.getConstantReflection().readUnsafeConstant(accessKind, object.asConstant(), offset.asConstant().asLong());
             return ConstantNode.forConstant(constant, tool.getMetaAccess(), graph());
         }
         return this;
@@ -86,12 +87,11 @@
     @Override
     public void lower(LoweringTool tool) {
         CompareNode compare = CompareNode.createCompareNode(graph(), Condition.EQ, condition, ConstantNode.forBoolean(true, graph()));
-        Object locationIdentityObject = location.asConstant().asObject();
         LocationIdentity locationIdentity;
-        if (locationIdentityObject == null) {
+        if (location.asConstant().isNull()) {
             locationIdentity = LocationIdentity.ANY_LOCATION;
         } else {
-            locationIdentity = ObjectLocationIdentity.create(locationIdentityObject);
+            locationIdentity = ObjectLocationIdentity.create(location.asConstant());
         }
         UnsafeLoadNode result = graph().add(new UnsafeLoadNode(object, offset, accessKind, locationIdentity, compare));
         graph().replaceFixedWithFixed(this, result);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
 import com.oracle.truffle.api.*;
 
@@ -54,12 +55,11 @@
             ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX);
             ValueNode offsetArgument = arguments.get(OFFSET_ARGUMENT_INDEX);
             ValueNode conditionArgument = arguments.get(CONDITION_ARGUMENT_INDEX);
-            Object locationIdentityObject = locationArgument.asConstant().asObject();
             LocationIdentity locationIdentity;
-            if (locationIdentityObject == null) {
+            if (locationArgument.asConstant().isNull()) {
                 locationIdentity = LocationIdentity.ANY_LOCATION;
             } else {
-                locationIdentity = ObjectLocationIdentity.create(locationIdentityObject);
+                locationIdentity = ObjectLocationIdentity.create(locationArgument.asConstant());
             }
             CompareNode compare = CompareNode.createCompareNode(graph(), Condition.EQ, conditionArgument, ConstantNode.forBoolean(true, graph()));
             Kind returnKind = this.getTargetMethod().getSignature().getReturnKind();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreMacroNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreMacroNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
 import com.oracle.truffle.api.*;
 
@@ -53,12 +54,11 @@
             ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX);
             ValueNode offsetArgument = arguments.get(OFFSET_ARGUMENT_INDEX);
             ValueNode valueArgument = arguments.get(VALUE_ARGUMENT_INDEX);
-            Object locationIdentityObject = locationArgument.asConstant().asObject();
             LocationIdentity locationIdentity;
-            if (locationIdentityObject == null) {
+            if (locationArgument.asConstant().isNull()) {
                 locationIdentity = LocationIdentity.ANY_LOCATION;
             } else {
-                locationIdentity = ObjectLocationIdentity.create(locationIdentityObject);
+                locationIdentity = ObjectLocationIdentity.create(locationArgument.asConstant());
             }
 
             UnsafeStoreNode unsafeStoreNode = graph().add(
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -55,11 +55,10 @@
         if (classArgument.isConstant() && nonNullArgument.isConstant()) {
             ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX);
             ValueNode conditionArgument = arguments.get(CONDITION_ARGUMENT_INDEX);
-            Class c = (Class) classArgument.asConstant().asObject();
-            if (c == null) {
+            ResolvedJavaType lookupJavaType = tool.getConstantReflection().asJavaType(classArgument.asConstant());
+            if (lookupJavaType == null) {
                 return objectArgument;
             }
-            ResolvedJavaType lookupJavaType = tool.getMetaAccess().lookupJavaType(c);
             Stamp stamp = StampFactory.declared(lookupJavaType, nonNullArgument.asConstant().asInt() != 0);
             ConditionAnchorNode valueAnchorNode = graph().add(new ConditionAnchorNode(CompareNode.createCompareNode(graph(), Condition.EQ, conditionArgument, ConstantNode.forBoolean(true, graph()))));
             UnsafeCastNode piCast = graph().unique(new UnsafeCastNode(objectArgument, stamp, valueAnchorNode));
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,6 +31,7 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.truffle.nodes.*;
+import com.oracle.graal.truffle.nodes.frame.*;
 import com.oracle.graal.truffle.nodes.typesystem.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
@@ -71,7 +72,7 @@
     public static native void bailout(String reason);
 
     @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true)
-    public static native Object unsafeCast(Object value, Class clazz, boolean condition, boolean nonNull);
+    public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
 
     @MethodSubstitution
     private static Class<? extends MaterializedFrame> getUnsafeFrameType() {
@@ -165,4 +166,10 @@
     public static Object unsafeGetFinalObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return CustomizedUnsafeLoadFinalNode.load(receiver, offset, condition, locationIdentity, Kind.Object);
     }
+
+    @MethodSubstitution
+    public static void materialize(Object obj) {
+        ForceMaterializeNode.force(obj);
+    }
+
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +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.truffle.substitutions;
-
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.truffle.*;
-import com.oracle.truffle.api.frame.*;
-
-@ClassSubstitution(FrameWithoutBoxing.class)
-public class FrameWithoutBoxingSubstitutions {
-
-    @SuppressWarnings("unused")
-    @MethodSubstitution(isStatic = false, forced = true)
-    public static PackedFrame pack(FrameWithoutBoxing frame) {
-        return null;
-    }
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetImplSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +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.truffle.substitutions;
-
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.truffle.*;
-import com.oracle.graal.truffle.nodes.asserts.*;
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-
-@ClassSubstitution(OptimizedCallTargetImpl.class)
-public class OptimizedCallTargetImplSubstitutions {
-
-    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
-    public static native Object callHelper(OptimizedCallTarget target, PackedFrame caller, Arguments args);
-
-    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
-    public static native Object interpreterCall(OptimizedCallTarget target, PackedFrame caller, Arguments args);
-
-    @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)
-    public static native Object compiledCodeInvalidated(OptimizedCallTarget target, PackedFrame caller, Arguments args);
-}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetSubstitutions.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetSubstitutions.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,14 +25,13 @@
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.truffle.nodes.frame.*;
-import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
 @ClassSubstitution(OptimizedCallTarget.class)
 public class OptimizedCallTargetSubstitutions {
 
     @MethodSubstitution
-    private static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, PackedFrame caller, Arguments args) {
-        return NewFrameNode.allocate(FrameWithoutBoxing.class, descriptor, caller, args);
+    private static FrameWithoutBoxing createFrame(FrameDescriptor descriptor, Object[] args) {
+        return NewFrameNode.allocate(FrameWithoutBoxing.class, descriptor, args);
     }
 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Wed Apr 16 14:02:52 2014 +0200
@@ -43,7 +43,7 @@
 
     protected final NodeMap<ValueNode> aliases;
     protected final BlockMap<GraphEffectList> blockEffects;
-    private final IdentityHashMap<Loop, GraphEffectList> loopMergeEffects = new IdentityHashMap<>();
+    private final IdentityHashMap<Loop<Block>, GraphEffectList> loopMergeEffects = new IdentityHashMap<>();
     private final IdentityHashMap<LoopBeginNode, BlockT> loopEntryStates = new IdentityHashMap<>();
 
     private boolean changed;
@@ -105,7 +105,7 @@
             }
 
             @Override
-            protected List<Void> processLoop(Loop loop, Void initialState) {
+            protected List<Void> processLoop(Loop<Block> loop, Void initialState) {
                 LoopInfo<Void> info = ReentrantBlockIterator.processLoop(this, loop, initialState);
                 apply(loopMergeEffects.get(loop), loop);
                 return info.exitStates;
@@ -150,7 +150,7 @@
     }
 
     @Override
-    protected final List<BlockT> processLoop(Loop loop, BlockT initialState) {
+    protected final List<BlockT> processLoop(Loop<Block> loop, BlockT initialState) {
         BlockT loopEntryState = initialState;
         BlockT lastMergedState = cloneState(initialState);
         MergeProcessor mergeProcessor = createMergeProcessor(loop.header);
@@ -174,7 +174,7 @@
                 loopMergeEffects.put(loop, mergeProcessor.afterMergeEffects);
 
                 assert info.exitStates.size() == loop.exits.size();
-                loopEntryStates.put(loop.loopBegin(), loopEntryState);
+                loopEntryStates.put((LoopBeginNode) loop.header.getBeginNode(), loopEntryState);
                 for (int i = 0; i < loop.exits.size(); i++) {
                     assert info.exitStates.get(i) != null : "no loop exit state at " + loop.exits.get(i) + " / " + loop.header;
                 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/GraphEffectList.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/GraphEffectList.java	Wed Apr 16 14:02:52 2014 +0200
@@ -69,7 +69,7 @@
     /**
      * Adds the given fixed node to the graph's control flow, before position (so that the original
      * predecessor of position will then be node's predecessor).
-     * 
+     *
      * @param node The fixed node to be added to the graph.
      * @param position The fixed node before which the node should be added.
      */
@@ -91,7 +91,7 @@
 
     /**
      * Add the given floating node to the graph.
-     * 
+     *
      * @param node The floating node to be added.
      */
     public void addFloatingNode(final ValueNode node, final String cause) {
@@ -112,7 +112,7 @@
 
     /**
      * Adds an value to the given phi node.
-     * 
+     *
      * @param node The phi node to which the value should be added.
      * @param value The value that will be added to the phi node.
      */
@@ -135,7 +135,7 @@
     /**
      * Sets the phi node's input at the given index to the given value, adding new phi inputs as
      * needed.
-     * 
+     *
      * @param node The phi node whose input should be changed.
      * @param index The index of the phi input to be changed.
      * @param value The new value for the phi input.
@@ -159,7 +159,7 @@
     /**
      * Adds a virtual object's state to the given frame state. If the given reusedVirtualObjects set
      * contains the virtual object then old states for this object will be removed.
-     * 
+     *
      * @param node The frame state to which the state should be added.
      * @param state The virtual object state to add.
      */
@@ -192,7 +192,7 @@
 
     /**
      * Removes the given fixed node from the control flow and deletes it.
-     * 
+     *
      * @param node The fixed node that should be deleted.
      */
     public void deleteFixedNode(final FixedWithNextNode node) {
@@ -218,11 +218,11 @@
      * Replaces the given node at its usages without deleting it. If the current node is a fixed
      * node it will be disconnected from the control flow, so that it will be deleted by a
      * subsequent {@link DeadCodeEliminationPhase}
-     * 
+     *
      * @param node The node to be replaced.
      * @param replacement The node that should replace the original value. If the replacement is a
      *            non-connected {@link FixedWithNextNode} it will be added to the control flow.
-     * 
+     *
      */
     public void replaceAtUsages(final ValueNode node, final ValueNode replacement) {
         add(new Effect() {
@@ -252,7 +252,7 @@
 
     /**
      * Replaces the first occurrence of oldInput in node with newInput.
-     * 
+     *
      * @param node The node whose input should be changed.
      * @param oldInput The value to look for.
      * @param newInput The value to replace with.
@@ -280,7 +280,7 @@
 
     /**
      * Performs a custom action.
-     * 
+     *
      * @param action The action that should be performed when the effects are applied.
      */
     public void customAction(final Runnable action) {
@@ -301,7 +301,7 @@
     /**
      * Add the materialization node to the graph's control flow at the given position, and then sets
      * its values.
-     * 
+     *
      * @param position The fixed node before which the materialization node should be added.
      * @param objects The allocated objects.
      * @param locks The lock depths for each object.
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -40,8 +39,8 @@
 
 public class PEReadEliminationClosure extends PartialEscapeClosure<PEReadEliminationBlockState> {
 
-    public PEReadEliminationClosure(SchedulePhase schedule, MetaAccessProvider metaAccess, Assumptions assumptions) {
-        super(schedule, metaAccess, assumptions);
+    public PEReadEliminationClosure(SchedulePhase schedule, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Assumptions assumptions) {
+        super(schedule, metaAccess, constantReflection, assumptions);
     }
 
     @Override
@@ -114,7 +113,7 @@
             if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
                 ValueNode value = exitState.getReadCache(entry.getKey().object, entry.getKey().identity, this);
                 if (!(value instanceof ProxyNode) || ((ProxyNode) value).proxyPoint() != exitNode) {
-                    ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value);
+                    ProxyNode proxy = new ValueProxyNode(value, exitNode);
                     effects.addFloatingNode(proxy, "readCacheProxy");
                     entry.setValue(proxy);
                 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,6 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.VirtualState.NodeClosure;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.extended.*;
@@ -64,8 +63,8 @@
      */
     public static final class Final extends PartialEscapeClosure<PartialEscapeBlockState.Final> {
 
-        public Final(SchedulePhase schedule, MetaAccessProvider metaAccess, Assumptions assumptions) {
-            super(schedule, metaAccess, assumptions);
+        public Final(SchedulePhase schedule, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Assumptions assumptions) {
+            super(schedule, metaAccess, constantReflection, assumptions);
         }
 
         @Override
@@ -79,10 +78,10 @@
         }
     }
 
-    public PartialEscapeClosure(SchedulePhase schedule, MetaAccessProvider metaAccess, Assumptions assumptions) {
+    public PartialEscapeClosure(SchedulePhase schedule, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Assumptions assumptions) {
         super(schedule);
         this.usages = schedule.getCFG().graph.createNodeBitMap();
-        this.tool = new VirtualizerToolImpl(metaAccess, assumptions, this);
+        this.tool = new VirtualizerToolImpl(metaAccess, constantReflection, assumptions, this);
     }
 
     public Map<Invoke, Double> getHints() {
@@ -248,7 +247,7 @@
                     ValueNode value = obj.getEntry(i);
                     if (!(value instanceof VirtualObjectNode || value.isConstant())) {
                         if (exitNode.loopBegin().isPhiAtMerge(value) || initialObj == null || !initialObj.isVirtual() || initialObj.getEntry(i) != value) {
-                            ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value);
+                            ProxyNode proxy = new ValueProxyNode(value, exitNode);
                             obj.setEntry(i, proxy);
                             effects.addFloatingNode(proxy, "virtualProxy");
                         }
@@ -258,7 +257,7 @@
                 if (initialObj == null || initialObj.isVirtual()) {
                     ProxyNode proxy = proxies.get(obj.virtual);
                     if (proxy == null) {
-                        proxy = new ProxyNode(obj.getMaterializedValue(), exitNode, PhiType.Value);
+                        proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode);
                         effects.addFloatingNode(proxy, "proxy");
                     } else {
                         effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue());
@@ -281,34 +280,34 @@
 
     protected class MergeProcessor extends EffectsClosure<BlockT>.MergeProcessor {
 
-        private final HashMap<Object, PhiNode> materializedPhis = new HashMap<>();
-        private final IdentityHashMap<ValueNode, PhiNode[]> valuePhis = new IdentityHashMap<>();
-        private final IdentityHashMap<PhiNode, VirtualObjectNode> valueObjectVirtuals = new IdentityHashMap<>();
+        private final HashMap<Object, ValuePhiNode> materializedPhis = new HashMap<>();
+        private final IdentityHashMap<ValueNode, ValuePhiNode[]> valuePhis = new IdentityHashMap<>();
+        private final IdentityHashMap<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = new IdentityHashMap<>();
 
         public MergeProcessor(Block mergeBlock) {
             super(mergeBlock);
         }
 
         protected <T> PhiNode getCachedPhi(T virtual, Stamp stamp) {
-            PhiNode result = materializedPhis.get(virtual);
+            ValuePhiNode result = materializedPhis.get(virtual);
             if (result == null) {
-                result = new PhiNode(stamp, merge);
+                result = new ValuePhiNode(stamp, merge);
                 materializedPhis.put(virtual, result);
             }
             return result;
         }
 
         private PhiNode[] getValuePhis(ValueNode key, int entryCount) {
-            PhiNode[] result = valuePhis.get(key);
+            ValuePhiNode[] result = valuePhis.get(key);
             if (result == null) {
-                result = new PhiNode[entryCount];
+                result = new ValuePhiNode[entryCount];
                 valuePhis.put(key, result);
             }
             assert result.length == entryCount;
             return result;
         }
 
-        private VirtualObjectNode getValueObjectVirtual(PhiNode phi, VirtualObjectNode virtual) {
+        private VirtualObjectNode getValueObjectVirtual(ValuePhiNode phi, VirtualObjectNode virtual) {
             VirtualObjectNode result = valueObjectVirtuals.get(phi);
             if (result == null) {
                 result = virtual.duplicate();
@@ -380,8 +379,8 @@
                 }
 
                 for (PhiNode phi : merge.phis()) {
-                    if (usages.isMarked(phi) && phi.type() == PhiType.Value) {
-                        materialized |= processPhi(phi, states, virtualObjTemp);
+                    if (usages.isMarked(phi) && phi instanceof ValuePhiNode) {
+                        materialized |= processPhi((ValuePhiNode) phi, states, virtualObjTemp);
                     }
                 }
                 if (materialized) {
@@ -466,7 +465,7 @@
                     for (int i = 1; i < objStates.length; i++) {
                         ValueNode[] fields = objStates[i].getEntries();
                         if (phis[valueIndex] == null && values[valueIndex] != fields[valueIndex]) {
-                            phis[valueIndex] = new PhiNode(values[valueIndex].stamp().unrestricted(), merge);
+                            phis[valueIndex] = new ValuePhiNode(values[valueIndex].stamp().unrestricted(), merge);
                         }
                     }
                     if (twoSlotKinds != null && twoSlotKinds[valueIndex] != null) {
@@ -556,7 +555,7 @@
          *            and therefore also exist in the merged state
          * @return true if materialization happened during the merge, false otherwise
          */
-        private boolean processPhi(PhiNode phi, List<BlockT> states, Set<VirtualObjectNode> mergedVirtualObjects) {
+        private boolean processPhi(ValuePhiNode phi, List<BlockT> states, Set<VirtualObjectNode> mergedVirtualObjects) {
             aliases.set(phi, null);
             assert states.size() == phi.valueCount();
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -72,9 +72,9 @@
     @Override
     protected Closure<?> createEffectsClosure(PhaseContext context, SchedulePhase schedule) {
         if (readElimination) {
-            return new PEReadEliminationClosure(schedule, context.getMetaAccess(), context.getAssumptions());
+            return new PEReadEliminationClosure(schedule, context.getMetaAccess(), context.getConstantReflection(), context.getAssumptions());
         } else {
-            return new PartialEscapeClosure.Final(schedule, context.getMetaAccess(), context.getAssumptions());
+            return new PartialEscapeClosure.Final(schedule, context.getMetaAccess(), context.getConstantReflection(), context.getAssumptions());
         }
     }
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.PhiNode.PhiType;
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.java.*;
@@ -175,7 +174,7 @@
     protected void processLoopExit(LoopExitNode exitNode, ReadEliminationBlockState initialState, ReadEliminationBlockState exitState, GraphEffectList effects) {
         for (Map.Entry<CacheEntry<?>, ValueNode> entry : exitState.getReadCache().entrySet()) {
             if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) {
-                ProxyNode proxy = new ProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode, PhiType.Value);
+                ProxyNode proxy = new ValueProxyNode(exitState.getCacheEntry(entry.getKey()), exitNode);
                 effects.addFloatingNode(proxy, "readCacheProxy");
                 entry.setValue(proxy);
             }
@@ -194,16 +193,16 @@
 
     private class ReadEliminationMergeProcessor extends EffectsClosure<ReadEliminationBlockState>.MergeProcessor {
 
-        private final HashMap<Object, PhiNode> materializedPhis = new HashMap<>();
+        private final HashMap<Object, ValuePhiNode> materializedPhis = new HashMap<>();
 
         public ReadEliminationMergeProcessor(Block mergeBlock) {
             super(mergeBlock);
         }
 
         protected <T> PhiNode getCachedPhi(T virtual, Stamp stamp) {
-            PhiNode result = materializedPhis.get(virtual);
+            ValuePhiNode result = materializedPhis.get(virtual);
             if (result == null) {
-                result = new PhiNode(stamp, merge);
+                result = new ValuePhiNode(stamp, merge);
                 materializedPhis.put(virtual, result);
             }
             return result;
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,11 +40,13 @@
 class VirtualizerToolImpl implements VirtualizerTool {
 
     private final MetaAccessProvider metaAccess;
+    private final ConstantReflectionProvider constantReflection;
     private final Assumptions assumptions;
     private final PartialEscapeClosure<?> closure;
 
-    VirtualizerToolImpl(MetaAccessProvider metaAccess, Assumptions assumptions, PartialEscapeClosure<?> closure) {
+    VirtualizerToolImpl(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, Assumptions assumptions, PartialEscapeClosure<?> closure) {
         this.metaAccess = metaAccess;
+        this.constantReflection = constantReflection;
         this.assumptions = assumptions;
         this.closure = closure;
     }
@@ -60,12 +62,16 @@
         return metaAccess;
     }
 
+    public ConstantReflectionProvider getConstantReflectionProvider() {
+        return constantReflection;
+    }
+
     @Override
     public Assumptions getAssumptions() {
         return assumptions;
     }
 
-    public void reset(PartialEscapeBlockState newState, ValueNode newCurrent, FixedNode newPosition, GraphEffectList newEffects) {
+    public void reset(PartialEscapeBlockState<?> newState, ValueNode newCurrent, FixedNode newPosition, GraphEffectList newEffects) {
         deleted = false;
         state = newState;
         current = newCurrent;
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,8 +29,8 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.calc.*;
 
 public abstract class Word implements Signed, Unsigned, Pointer {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/SnippetLocationNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013, 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.word.nodes;
+
+import static com.oracle.graal.api.meta.LocationIdentity.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Location node that can be used inside a snippet without having the elements (including the
+ * location identity and kind) as a snippet constant. Can represent locations in the form of [base +
+ * index * scale + disp]. When the location is created, all elements (base, index, scale, disp) are
+ * nodes. Both scale and disp must eventually canonicalize to {@link ConstantNode constants} so that
+ * this node can be canonicalized to a {@link IndexedLocationNode} or {@link ConstantLocationNode}.
+ */
+public final class SnippetLocationNode extends LocationNode implements Canonicalizable {
+
+    private final SnippetReflectionProvider snippetReflection;
+
+    @Input private ValueNode valueKind;
+    @Input(InputType.Association) private ValueNode locationIdentity;
+    @Input private ValueNode displacement;
+    @Input private ValueNode index;
+    @Input private ValueNode indexScaling;
+
+    public static SnippetLocationNode create(SnippetReflectionProvider snippetReflection, ValueNode identity, ValueNode kind, ValueNode displacement, ValueNode index, ValueNode indexScaling,
+                    Graph graph) {
+        return graph.unique(new SnippetLocationNode(snippetReflection, identity, kind, displacement, index, indexScaling));
+    }
+
+    private SnippetLocationNode(@InjectedNodeParameter SnippetReflectionProvider snippetReflection, ValueNode locationIdentity, ValueNode kind, ValueNode displacement) {
+        this(snippetReflection, locationIdentity, kind, displacement, null, null);
+    }
+
+    private SnippetLocationNode(@InjectedNodeParameter SnippetReflectionProvider snippetReflection, ValueNode locationIdentity, ValueNode kind, ValueNode displacement, ValueNode index,
+                    ValueNode indexScaling) {
+        super(StampFactory.object());
+        this.snippetReflection = snippetReflection;
+        this.valueKind = kind;
+        this.locationIdentity = locationIdentity;
+        this.displacement = displacement;
+        this.index = index;
+        this.indexScaling = indexScaling;
+    }
+
+    @Override
+    public Kind getValueKind() {
+        if (valueKind.isConstant()) {
+            return (Kind) snippetReflection.asObject(valueKind.asConstant());
+        }
+        throw new GraalInternalError("Cannot access kind yet because it is not constant: " + valueKind);
+    }
+
+    @Override
+    public LocationIdentity getLocationIdentity() {
+        if (locationIdentity.isConstant()) {
+            return (LocationIdentity) snippetReflection.asObject(locationIdentity.asConstant());
+        }
+        // We do not know our actual location identity yet, so be conservative.
+        return ANY_LOCATION;
+    }
+
+    @Override
+    public Node canonical(CanonicalizerTool tool) {
+        if (valueKind.isConstant() && locationIdentity.isConstant() && displacement.isConstant() && (indexScaling == null || indexScaling.isConstant())) {
+            Kind constKind = (Kind) snippetReflection.asObject(valueKind.asConstant());
+            LocationIdentity constLocation = (LocationIdentity) snippetReflection.asObject(locationIdentity.asConstant());
+            long constDisplacement = displacement.asConstant().asLong();
+            int constIndexScaling = indexScaling == null ? 0 : indexScaling.asConstant().asInt();
+
+            if (index == null || constIndexScaling == 0) {
+                return ConstantLocationNode.create(constLocation, constKind, constDisplacement, graph());
+            } else if (index.isConstant()) {
+                return ConstantLocationNode.create(constLocation, constKind, index.asConstant().asLong() * constIndexScaling + constDisplacement, graph());
+            } else {
+                return IndexedLocationNode.create(constLocation, constKind, constDisplacement, index, graph(), constIndexScaling);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public Value generateAddress(NodeMappableLIRBuilder builder, LIRGeneratorTool gen, Value base) {
+        throw new GraalInternalError("locationIdentity must be a constant so that this node can be canonicalized: " + locationIdentity);
+    }
+
+    @NodeIntrinsic
+    public static native Location constantLocation(LocationIdentity identity, Kind kind, long displacement);
+
+    @NodeIntrinsic
+    public static native Location indexedLocation(LocationIdentity identity, Kind kind, long displacement, int index, int indexScaling);
+}
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -27,6 +27,7 @@
 import java.lang.reflect.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
@@ -49,13 +50,15 @@
 public class WordTypeRewriterPhase extends Phase {
 
     protected final MetaAccessProvider metaAccess;
+    protected final SnippetReflectionProvider snippetReflection;
     protected final ResolvedJavaType wordBaseType;
     protected final ResolvedJavaType wordImplType;
     protected final ResolvedJavaType objectAccessType;
     protected final Kind wordKind;
 
-    public WordTypeRewriterPhase(MetaAccessProvider metaAccess, Kind wordKind) {
+    public WordTypeRewriterPhase(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, Kind wordKind) {
         this.metaAccess = metaAccess;
+        this.snippetReflection = snippetReflection;
         this.wordKind = wordKind;
         this.wordBaseType = metaAccess.lookupJavaType(WordBase.class);
         this.wordImplType = metaAccess.lookupJavaType(Word.class);
@@ -86,7 +89,7 @@
             if (node.isConstant()) {
                 ConstantNode oldConstant = (ConstantNode) node;
                 assert oldConstant.getValue().getKind() == Kind.Object;
-                WordBase value = (WordBase) oldConstant.getValue().asObject();
+                WordBase value = (WordBase) snippetReflection.asObject(oldConstant.getValue());
                 ConstantNode newConstant = ConstantNode.forIntegerKind(wordKind, value.rawValue(), node.graph());
                 graph.replaceFloating(oldConstant, newConstant);
 
@@ -221,7 +224,7 @@
                 assert arguments.size() == 3;
                 Kind readKind = asKind(callTargetNode.returnType());
                 LocationNode location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
-                BarrierType barrierType = (BarrierType) arguments.get(2).asConstant().asObject();
+                BarrierType barrierType = (BarrierType) snippetReflection.asObject(arguments.get(2).asConstant());
                 replace(invoke, readOp(graph, arguments.get(0), invoke, location, barrierType, true));
                 break;
             }
@@ -359,10 +362,10 @@
 
     private LocationNode makeLocation(StructuredGraph graph, ValueNode offset, Kind readKind, ValueNode locationIdentity) {
         if (locationIdentity.isConstant()) {
-            return makeLocation(graph, offset, readKind, (LocationIdentity) locationIdentity.asConstant().asObject());
+            return makeLocation(graph, offset, readKind, (LocationIdentity) snippetReflection.asObject(locationIdentity.asConstant()));
         }
-        return SnippetLocationNode.create(locationIdentity, ConstantNode.forObject(readKind, metaAccess, graph), ConstantNode.forLong(0, graph), fromSigned(graph, offset),
-                        ConstantNode.forInt(1, graph), graph);
+        return SnippetLocationNode.create(snippetReflection, locationIdentity, ConstantNode.forConstant(snippetReflection.forObject(readKind), metaAccess, graph), ConstantNode.forLong(0, graph),
+                        fromSigned(graph, offset), ConstantNode.forInt(1, graph), graph);
     }
 
     protected LocationNode makeLocation(StructuredGraph graph, ValueNode offset, Kind readKind, LocationIdentity locationIdentity) {
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 import java.lang.reflect.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.*;
@@ -44,8 +45,8 @@
 
     private final WordTypeRewriterPhase wordAccess;
 
-    public WordTypeVerificationPhase(MetaAccessProvider metaAccess, Kind wordKind) {
-        this.wordAccess = new WordTypeRewriterPhase(metaAccess, wordKind);
+    public WordTypeVerificationPhase(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, Kind wordKind) {
+        this.wordAccess = new WordTypeRewriterPhase(metaAccess, snippetReflection, wordKind);
     }
 
     @Override
@@ -90,9 +91,9 @@
                     verify(!isWord(node) || ((ObjectEqualsNode) usage).y() != node, node, usage, "cannot use word type in comparison");
                 } else if (usage instanceof ArrayLengthNode) {
                     verify(!isWord(node) || ((ArrayLengthNode) usage).array() != node, node, usage, "cannot get array length from word value");
-                } else if (usage instanceof PhiNode) {
+                } else if (usage instanceof ValuePhiNode) {
                     if (!(node instanceof MergeNode)) {
-                        PhiNode phi = (PhiNode) usage;
+                        ValuePhiNode phi = (ValuePhiNode) usage;
                         for (ValueNode input : phi.values()) {
                             verify(isWord(node) == isWord(input), node, input, "cannot merge word and non-word values");
                         }
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ExecuteEvaluatedTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -39,7 +39,6 @@
 import com.oracle.truffle.api.dsl.test.ExecuteEvaluatedTestFactory.UseEvaluatedNodeFactory;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode;
-import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestArguments;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 import com.oracle.truffle.api.frame.*;
@@ -52,7 +51,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         CallTarget callTarget = TestHelper.createCallTarget(UseEvaluatedNodeFactory.create(arg0, EvaluatedNodeFactory.create(null)));
 
-        Assert.assertEquals(43, callTarget.call(new TestArguments(42)));
+        Assert.assertEquals(43, callTarget.call(new Object[]{42}));
         Assert.assertEquals(1, arg0.getInvocationCount());
     }
 
@@ -85,7 +84,7 @@
         ArgumentNode arg1 = new ArgumentNode(1);
         CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluatedNodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null)));
 
-        Assert.assertEquals(85, callTarget.call(new TestArguments(42, 43)));
+        Assert.assertEquals(85, callTarget.call(new Object[]{42, 43}));
         Assert.assertEquals(1, arg0.getInvocationCount());
         Assert.assertEquals(1, arg1.getInvocationCount());
     }
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,6 @@
 import com.oracle.truffle.api.dsl.test.ShortCircuitTestFactory.SingleChildNodeFactory;
 import com.oracle.truffle.api.dsl.test.ShortCircuitTestFactory.VarArgsNodeFactory;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode;
-import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestArguments;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 
 public class ShortCircuitTest {
@@ -42,7 +41,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         CallTarget callTarget = TestHelper.createCallTarget(SingleChildNodeFactory.create(arg0));
         SingleChildNode.needsChild = true;
-        assertEquals(42, callTarget.call(new TestArguments(42)));
+        assertEquals(42, callTarget.call(new Object[]{42}));
         assertEquals(1, arg0.getInvocationCount());
     }
 
@@ -51,7 +50,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         CallTarget callTarget = TestHelper.createCallTarget(SingleChildNodeFactory.create(arg0));
         SingleChildNode.needsChild = false;
-        assertEquals(0, callTarget.call(new TestArguments(42)));
+        assertEquals(0, callTarget.call(new Object[]{42}));
         assertEquals(0, arg0.getInvocationCount());
     }
 
@@ -78,7 +77,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         ArgumentNode arg1 = new ArgumentNode(1);
         CallTarget callTarget = TestHelper.createCallTarget(DoubleChildNodeFactory.create(arg0, arg1));
-        assertEquals(42, callTarget.call(new TestArguments(41, 42)));
+        assertEquals(42, callTarget.call(new Object[]{41, 42}));
         assertEquals(1, arg1.getInvocationCount());
     }
 
@@ -87,7 +86,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         ArgumentNode arg1 = new ArgumentNode(1);
         CallTarget callTarget = TestHelper.createCallTarget(DoubleChildNodeFactory.create(arg0, arg1));
-        assertEquals(0, callTarget.call(new TestArguments(42, 42)));
+        assertEquals(0, callTarget.call(new Object[]{42, 42}));
         assertEquals(0, arg1.getInvocationCount());
     }
 
@@ -112,7 +111,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         ArgumentNode arg1 = new ArgumentNode(1);
         CallTarget callTarget = TestHelper.createCallTarget(VarArgsNodeFactory.create(new ValueNode[]{arg0, arg1}));
-        assertEquals(42, callTarget.call(new TestArguments(41, 42)));
+        assertEquals(42, callTarget.call(new Object[]{41, 42}));
         assertEquals(1, arg1.getInvocationCount());
     }
 
@@ -121,7 +120,7 @@
         ArgumentNode arg0 = new ArgumentNode(0);
         ArgumentNode arg1 = new ArgumentNode(1);
         CallTarget callTarget = TestHelper.createCallTarget(VarArgsNodeFactory.create(new ValueNode[]{arg0, arg1}));
-        assertEquals(0, callTarget.call(new TestArguments(42, 42)));
+        assertEquals(0, callTarget.call(new Object[]{42, 42}));
         assertEquals(0, arg1.getInvocationCount());
     }
 
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,6 @@
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode;
-import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestArguments;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 
@@ -96,7 +95,7 @@
     }
 
     static <E> Object executeWith(TestRootNode<? extends ValueNode> node, Object... values) {
-        return createCallTarget(node).call(new TestArguments(values));
+        return createCallTarget(node).call(values);
     }
 
     static Object array(Object... val) {
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,7 +23,7 @@
 package com.oracle.truffle.api.dsl.test;
 
 import com.oracle.truffle.api.dsl.*;
-import com.oracle.truffle.api.dsl.test.TypeSystemTest.*;
+import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 
 public class TypeSystemErrorsTest {
 
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -113,24 +113,6 @@
         }
     }
 
-    public static class TestArguments extends Arguments {
-
-        private final Object[] values;
-
-        public TestArguments(Object... values) {
-            this.values = values;
-        }
-
-        public Object[] getValues() {
-            return values;
-        }
-
-        public Object get(int index) {
-            return values[index];
-        }
-
-    }
-
     public static class ArgumentNode extends ValueNode {
 
         private int invocationCount;
@@ -147,13 +129,13 @@
         @Override
         public Object execute(VirtualFrame frame) {
             invocationCount++;
-            return frame.getArguments(TestArguments.class).get(index);
+            return frame.getArguments()[index];
         }
 
         @Override
         public int executeInt(VirtualFrame frame) throws UnexpectedResultException {
             // avoid casts for some tests
-            Object o = frame.getArguments(TestArguments.class).get(index);
+            Object o = frame.getArguments()[index];
             if (o instanceof Integer) {
                 return (int) o;
             }
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -38,7 +38,7 @@
      * Instantiates the node using the arguments array. The arguments length and types must suffice
      * one of the returned signatures in {@link #getNodeSignatures()}. If the arguments array does
      * not suffice one of the node signatures an {@link IllegalArgumentException} is thrown.
-     * 
+     *
      * @param arguments the argument values
      * @return the instantiated node
      * @throws IllegalArgumentException
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystem.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystem.java	Wed Apr 16 14:02:52 2014 +0200
@@ -61,12 +61,12 @@
  *
  * {@literal @}TypeSystem(types = {boolean.class, int.class, double.class})
  * public abstract class ExampleTypeSystem {
- *
+ * 
  *     {@literal @}TypeCheck
  *     public boolean isInteger(Object value) {
  *         return value instanceof Integer || value instanceof Double;
  *     }
- *
+ * 
  *     {@literal @}TypeCast
  *     public double asInteger(Object value) {
  *         return ((Number)value).doubleValue();
@@ -85,6 +85,6 @@
     /**
      * The list of types as child elements of the {@link TypeSystem}. Each precedes its super type.
      */
-    Class[] value();
+    Class<?>[] value();
 
 }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,21 +30,20 @@
 
 /**
  * <h3>Passing Arguments</h3>
- * 
+ *
  * <p>
- * A guest language can pass its own custom arguments when invoking a Truffle method by creating a
- * subclass of {@link Arguments}. When invoking a call target with
- * {@link CallTarget#call(Arguments)}, the arguments can be passed. A Truffle node can access the
- * arguments passed into the Truffle method by using {@link VirtualFrame#getArguments}.
+ * When invoking a call target with {@link CallTarget#call(Object[])}, arguments can be passed. A
+ * Truffle node can access the arguments passed into the Truffle method by using
+ * {@link VirtualFrame#getArguments}.
  * </p>
- * 
+ *
  * <p>
  * The arguments class should only contain fields that are declared as final. This allows the
  * Truffle runtime to improve optimizations around guest language method calls. Also, the arguments
- * object must never be stored into a field. It should be created immediately before invoking
- * {@link CallTarget#call(Arguments)} and no longer be accessed afterwards.
+ * object array must never be stored into a field. It should be created immediately before invoking
+ * {@link CallTarget#call(Object[])} and no longer be accessed afterwards.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.FrameTest}
  * .
@@ -57,19 +56,10 @@
         TruffleRuntime runtime = Truffle.getRuntime();
         TestRootNode rootNode = new TestRootNode(new TestArgumentNode[]{new TestArgumentNode(0), new TestArgumentNode(1)});
         CallTarget target = runtime.createCallTarget(rootNode);
-        Object result = target.call(new TestArguments(20, 22));
+        Object result = target.call(new Object[]{20, 22});
         Assert.assertEquals(42, result);
     }
 
-    private static class TestArguments extends Arguments {
-
-        final int[] values;
-
-        TestArguments(int... values) {
-            this.values = values;
-        }
-    }
-
     private static class TestRootNode extends RootNode {
 
         @Children private final TestArgumentNode[] children;
@@ -99,7 +89,7 @@
         }
 
         int execute(VirtualFrame frame) {
-            return frame.getArguments(TestArguments.class).values[index];
+            return (Integer) frame.getArguments()[index];
         }
     }
 }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,13 +30,13 @@
 
 /**
  * <h3>Calling Another Tree</h3>
- * 
+ *
  * <p>
  * A guest language implementation can create multiple call targets using the
  * {@link TruffleRuntime#createCallTarget(RootNode)} method. Those call targets can be passed around
  * as normal Java objects and used for calling guest language methods.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.ArgumentsTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -33,7 +33,7 @@
 
 /**
  * <h3>Creating a Child Node</h3>
- * 
+ *
  * <p>
  * Child nodes are stored in the class of the parent node in fields that are marked with the
  * {@link Child} annotation. Before such a field is assigned, {@link Node#adoptChild} must be
@@ -41,13 +41,13 @@
  * {@link Node#getParent()} method allows access to this field. Every node also provides the ability
  * to iterate over its children using {@link Node#getChildren()}.
  * </p>
- * 
+ *
  * <p>
  * A child node field must be declared private and non-final. It may only be assigned in the
  * constructor of the parent node. For changing the structure of the tree at run time, the method
  * {@link Node#replace(Node)} must be used (see {@link ReplaceTest}).
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.ChildrenNodesTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
 
 /**
  * <h3>Creating an Array of Children Nodes</h3>
- * 
+ *
  * <p>
  * An array of children nodes can be used as a field in a parent node. The field has to be annotated
  * with {@link com.oracle.truffle.api.nodes.Node.Children} and must be declared private and final.
@@ -41,7 +41,7 @@
  * its first values, it must never be changed. It is only possible to call {@link Node#replace} on a
  * child node.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.FinalFieldTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,20 +30,20 @@
 
 /**
  * <h3>Using Final Fields in Node Classes</h3>
- * 
+ *
  * <p>
  * The usage of final fields in node classes is highly encouraged. It is beneficial for performance
  * to declare every field that is not pointing to a child node as final. This gives the Truffle
  * runtime an increased opportunity to optimize this node.
  * </p>
- * 
+ *
  * <p>
  * If a node has a value which may change at run time, but will rarely do so, it is recommended to
  * speculate on the field being final. This involves starting executing with a node where this field
  * is final and only if this turns out to be no longer the case, the node is replaced with an
  * alternative implementation of the operation (see {@link ReplaceTest}).
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.ReplaceTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,13 +30,13 @@
 
 /**
  * <h3>Specializing Frame Slot Types</h3>
- * 
+ *
  * <p>
  * Dynamically typed languages can speculate on the type of a frame slot and only fall back at run
  * time to a more generic type if necessary. The new type of a frame slot can be set using the
  * {@link FrameSlot#setKind(FrameSlotKind)} method.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.ReturnTypeSpecializationTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -30,7 +30,7 @@
 
 /**
  * <h3>Storing Values in Frame Slots</h3>
- * 
+ *
  * <p>
  * The frame is the preferred data structure for passing values between nodes. It can in particular
  * be used for storing the values of local variables of the guest language. The
@@ -40,7 +40,7 @@
  * current value of a particular frame slot. Values can be removed from a frame via the
  * {@link FrameDescriptor#removeFrameSlot(Object)} method.
  * </p>
- * 
+ *
  * <p>
  * There are five primitive types for slots available: {@link java.lang.Boolean},
  * {@link java.lang.Integer}, {@link java.lang.Long}, {@link java.lang.Float}, and
@@ -53,7 +53,7 @@
  * {@link Frame#setLong}, {@link Frame#setFloat}, or {@link Frame#setDouble}) in the {@link Frame}
  * class.
  * </p>
- * 
+ *
  * <p>
  * The next part of the Truffle API introduction is at
  * {@link com.oracle.truffle.api.test.FrameSlotTypeSpecializationTest}.
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ThreadSafetyTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ThreadSafetyTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,7 +24,6 @@
 
 import static org.junit.Assert.*;
 
-import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -50,7 +49,7 @@
         RecursiveCallNode callNode = new RecursiveCallNode(new ConstNode(42));
         TestRootNode rootNode2 = new TestRootNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(new RewritingNode(callNode))))));
         final CallTarget target2 = runtime.createCallTarget(rootNode2);
-        callNode.setCallNode(runtime.createCallNode(target2));
+        callNode.setCallNode(runtime.createDirectCallNode(target2));
         NodeUtil.verify(rootNode2);
 
         testTarget(target1, 47, 1_000_000);
@@ -64,12 +63,11 @@
             executorService.submit(new Runnable() {
                 public void run() {
                     try {
-                        Object result = target.call(new TestArguments(5));
+                        Object result = target.call(new Object[]{5});
                         assertEquals(expectedResult, result);
                         ai.incrementAndGet();
                     } catch (Throwable t) {
-                        PrintStream out = System.out;
-                        out.println(t);
+                        t.printStackTrace(System.out);
                     }
                 }
             });
@@ -80,14 +78,6 @@
         assertEquals(numberOfIterations, ai.get());
     }
 
-    static class TestArguments extends Arguments {
-        final int arg;
-
-        public TestArguments(int arg) {
-            this.arg = arg;
-        }
-    }
-
     static class TestRootNode extends RootNode {
 
         @Child private ValueNode child;
@@ -173,7 +163,7 @@
     }
 
     static class RecursiveCallNode extends ValueNode {
-        @Child CallNode callNode;
+        @Child DirectCallNode callNode;
         @Child private ValueNode valueNode;
 
         RecursiveCallNode(ValueNode value) {
@@ -182,15 +172,15 @@
 
         @Override
         int execute(VirtualFrame frame) {
-            int arg = frame.getArguments(TestArguments.class).arg;
+            int arg = (Integer) frame.getArguments()[0];
             if (arg > 0) {
-                return (int) callNode.call(frame.pack(), new TestArguments(arg - 1));
+                return (int) callNode.call(frame, new Object[]{(arg - 1)});
             } else {
                 return valueNode.execute(frame);
             }
         }
 
-        void setCallNode(CallNode callNode) {
+        void setCallNode(DirectCallNode callNode) {
             this.callNode = insert(callNode);
         }
     }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.truffle.api.test.utilities;
 
 import static org.junit.Assert.*;
+
 import org.junit.*;
 
 import com.oracle.truffle.api.nodes.*;
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -23,6 +23,7 @@
 package com.oracle.truffle.api.test.utilities;
 
 import static org.junit.Assert.*;
+
 import org.junit.*;
 
 import com.oracle.truffle.api.utilities.*;
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/BranchProfileTest.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.truffle.api.test.utilities;
 
+import static org.junit.Assert.*;
+
 import org.junit.*;
 
 import com.oracle.truffle.api.utilities.*;
@@ -35,4 +37,16 @@
         profile.enter();
     }
 
+    @Test
+    public void testToString() {
+        BranchProfile profile = new BranchProfile();
+        assertTrue(profile.toString().contains(profile.getClass().getSimpleName()));
+        assertTrue(profile.toString().contains("not-visited"));
+        assertTrue(profile.toString().contains(Integer.toHexString(profile.hashCode())));
+        profile.enter();
+        assertTrue(profile.toString().contains(profile.getClass().getSimpleName()));
+        assertTrue(profile.toString().contains("visited"));
+        assertTrue(profile.toString().contains(Integer.toHexString(profile.hashCode())));
+    }
+
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Arguments.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api;
-
-/**
- * Base class for arguments passed to guest language methods via the
- * {@link CallTarget#call(com.oracle.truffle.api.frame.PackedFrame, Arguments)} method. A guest
- * language create a subclass with immutable fields representing the arguments passed to a guest
- * language method. The {@link Arguments} object must be created immediately before a method call
- * and it must not be stored in a field or cast to {@link java.lang.Object}.
- */
-public class Arguments {
-
-    /**
-     * Constant that can be used as an argument to
-     * {@link CallTarget#call(com.oracle.truffle.api.frame.PackedFrame, Arguments)} in case no
-     * arguments should be supplied.
-     */
-    public static final Arguments EMPTY_ARGUMENTS = new Arguments();
-
-    /**
-     * Constructs an empty {@link Arguments} instance. Guest languages should create a subclass to
-     * specify their own arguments.
-     */
-    protected Arguments() {
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CallTarget.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CallTarget.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,48 +24,24 @@
  */
 package com.oracle.truffle.api;
 
-import com.oracle.truffle.api.frame.*;
-
 /**
  * Represents the target of a call.
  */
 public abstract class CallTarget {
 
+    public static final Object[] NO_ARGUMENTS = new Object[0];
+
     /**
-     * Calls this target as a root method and without arguments.
-     * 
+     * Calls this target as a root method..
+     *
+     * @param arguments passed arguments as an object array
      * @return the return result of the call
      */
-    public final Object call() {
-        return call(null, Arguments.EMPTY_ARGUMENTS);
-    }
+    public abstract Object call(Object[] arguments);
 
-    /**
-     * Calls this target with a caller frame and no arguments.
-     * 
-     * @param caller the caller frame
-     * @return the return result of the call
-     */
-    public final Object call(PackedFrame caller) {
-        return call(caller, Arguments.EMPTY_ARGUMENTS);
+    public final Object call() {
+        return call(NO_ARGUMENTS);
     }
 
-    /**
-     * Calls this target as a root method passing arguments.
-     * 
-     * @param arguments the arguments that should be passed to the callee
-     * @return the return result of the call
-     */
-    public final Object call(Arguments arguments) {
-        return call(null, arguments);
-    }
-
-    /**
-     * Calls this target passing a caller frame and arguments.
-     * 
-     * @param caller the caller frame
-     * @param arguments the arguments that should be passed to the callee
-     * @return the return result of the call
-     */
-    public abstract Object call(PackedFrame caller, Arguments arguments);
+    public abstract void setNeedsMaterializedFrame();
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,9 +28,9 @@
 import java.lang.reflect.*;
 import java.util.concurrent.*;
 
-import com.oracle.truffle.api.frame.*;
+import sun.misc.*;
 
-import sun.misc.*;
+import com.oracle.truffle.api.frame.*;
 
 /**
  * Directives that influence the optimizations of the Truffle compiler. All of the operations have
@@ -196,7 +196,7 @@
      * @return the value to be casted to the new type
      */
     public static MaterializedFrame unsafeFrameCast(MaterializedFrame value) {
-        return unsafeCast(value, getUnsafeFrameType(), true);
+        return unsafeCast(value, getUnsafeFrameType(), true, true);
     }
 
     private static Class<? extends MaterializedFrame> getUnsafeFrameType() {
@@ -619,4 +619,13 @@
     @Target({ElementType.TYPE})
     public @interface ValueType {
     }
+
+    /**
+     * Ensures that the given object is not virtual, i.e., not removed by Escape Analysis at the
+     * point of this call.
+     *
+     * @param obj the object to exclude from Escape Analysis
+     */
+    public static void materialize(Object obj) {
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,6 +24,7 @@
  */
 package com.oracle.truffle.api;
 
+import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
 
 /**
@@ -36,8 +37,8 @@
 
     public RootCallTarget(RootNode function) {
         this.rootNode = function;
+        this.rootNode.adoptChildren();
         this.rootNode.setCallTarget(this);
-        this.rootNode.adoptChildren();
     }
 
     @Override
@@ -45,7 +46,16 @@
         return rootNode.toString();
     }
 
-    public RootNode getRootNode() {
+    public final RootNode getRootNode() {
         return rootNode;
     }
+
+    protected final Object callProxy(VirtualFrame frame) {
+        try {
+            return getRootNode().execute(frame);
+        } finally {
+            // this assertion is needed to keep the values from being cleared as non-live locals
+            assert frame != null && this != null;
+        }
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleRuntime.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleRuntime.java	Wed Apr 16 14:02:52 2014 +0200
@@ -35,14 +35,14 @@
 
     /**
      * Name describing this runtime implementation for debugging purposes.
-     * 
+     *
      * @return the name as a String
      */
     String getName();
 
     /**
      * Creates a new call target for a given root node.
-     * 
+     *
      * @param rootNode the root node whose
      *            {@link RootNode#execute(com.oracle.truffle.api.frame.VirtualFrame)} method
      *            represents the entry point
@@ -50,18 +50,31 @@
      */
     RootCallTarget createCallTarget(RootNode rootNode);
 
-    CallNode createCallNode(CallTarget target);
+    /**
+     * Creates a new runtime specific version of {@link DirectCallNode}.
+     *
+     * @param target the direct {@link CallTarget} to call
+     * @return the new call node
+     */
+    DirectCallNode createDirectCallNode(CallTarget target);
+
+    /**
+     * Creates a new runtime specific version of {@link IndirectCallNode}.
+     *
+     * @return the new call node
+     */
+    IndirectCallNode createIndirectCallNode();
 
     /**
      * Creates a new assumption object that can be checked and invalidated.
-     * 
+     *
      * @return the newly created assumption object
      */
     Assumption createAssumption();
 
     /**
      * Creates a new assumption object with a given name that can be checked and invalidated.
-     * 
+     *
      * @param name the name for the new assumption
      * @return the newly created assumption object
      */
@@ -70,24 +83,39 @@
     /**
      * Creates a new virtual frame object that can be used to store values and is potentially
      * optimizable by the runtime.
-     * 
+     *
      * @return the newly created virtual frame object
      */
-    VirtualFrame createVirtualFrame(PackedFrame caller, Arguments arguments, FrameDescriptor frameDescriptor);
+    VirtualFrame createVirtualFrame(Object[] arguments, FrameDescriptor frameDescriptor);
 
     /**
      * Creates a new materialized frame object that can be used to store values.
-     * 
+     *
      * @return the newly created materialized frame object
      */
-    MaterializedFrame createMaterializedFrame(Arguments arguments);
+    MaterializedFrame createMaterializedFrame(Object[] arguments);
 
     /**
      * Creates a new materialized frame object with the given frame descriptor that can be used to
      * store values.
-     * 
+     *
      * @param frameDescriptor the frame descriptor describing this frame's values
      * @return the newly created materialized frame object
      */
-    MaterializedFrame createMaterializedFrame(Arguments arguments, FrameDescriptor frameDescriptor);
+    MaterializedFrame createMaterializedFrame(Object[] arguments, FrameDescriptor frameDescriptor);
+
+    /**
+     * Accesses the current stack, i.e., the contents of the {@link Frame}s and the associated
+     * {@link CallTarget}s.
+     *
+     * @return a lazy collection of {@link FrameInstance}.
+     */
+    Iterable<FrameInstance> getStackTrace();
+
+    /**
+     * Accesses the current frame, i.e., the frame of the closest {@link CallTarget}. It is
+     * important to note that this {@link FrameInstance} supports only slow path access.
+     */
+    FrameInstance getCurrentFrame();
+
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DebugContext.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DebugContext.java	Wed Apr 16 14:02:52 2014 +0200
@@ -67,6 +67,6 @@
     /**
      * Invokes appropriate debugging action when Truffle execution halts.
      */
-    void executionHalted(Node node, VirtualFrame frame);
+    void executionHalted(Node node, MaterializedFrame frame);
 
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DebugManager.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DebugManager.java	Wed Apr 16 14:02:52 2014 +0200
@@ -66,6 +66,6 @@
      *            not to be any kind of {@link InstrumentationNode},
      * @param frame execution frame at the site where execution suspended
      */
-    void haltedAt(Node astNode, VirtualFrame frame);
+    void haltedAt(Node astNode, MaterializedFrame frame);
 
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DefaultDebugManager.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/DefaultDebugManager.java	Wed Apr 16 14:02:52 2014 +0200
@@ -105,7 +105,7 @@
         beingLoaded = null;
     }
 
-    public void haltedAt(Node astNode, VirtualFrame frame) {
+    public void haltedAt(Node astNode, MaterializedFrame frame) {
     }
 
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,6 @@
  */
 package com.oracle.truffle.api.frame;
 
-import com.oracle.truffle.api.*;
-
 /**
  * Represents a frame containing values of local variables of the guest language. Instances of this
  * type must not be stored in a field or cast to {@link java.lang.Object}.
@@ -39,19 +37,15 @@
 
     /**
      * Retrieves the arguments object from this frame. The runtime assumes that the arguments object
-     * is never null. Additionally, the runtime may assume that the given parameter indicating the
-     * class of the arguments object is correct. The runtime is not required to actually check the
-     * type of the arguments object. The parameter must be a value that can be reduced to a compile
-     * time constant.
-     * 
-     * @param clazz the known type of the arguments object as a compile time constant
+     * is never null.
+     *
      * @return the arguments used when calling this method
      */
-    <T extends Arguments> T getArguments(Class<T> clazz);
+    Object[] getArguments();
 
     /**
      * Read access to a local variable of type {@link Object}.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -59,7 +53,7 @@
 
     /**
      * Write access to a local variable of type {@link Object}.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -67,7 +61,7 @@
 
     /**
      * Read access to a local variable of type byte.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      * @throws FrameSlotTypeException
@@ -76,7 +70,7 @@
 
     /**
      * Write access to a local variable of type byte.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -85,7 +79,7 @@
 
     /**
      * Read access to a local variable of type boolean.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -93,7 +87,7 @@
 
     /**
      * Write access to a local variable of type boolean.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -101,7 +95,7 @@
 
     /**
      * Read access to a local variable of type int.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -109,7 +103,7 @@
 
     /**
      * Write access to a local variable of type int.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -117,7 +111,7 @@
 
     /**
      * Read access to a local variable of type long.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -125,7 +119,7 @@
 
     /**
      * Write access to a local variable of type long.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -133,7 +127,7 @@
 
     /**
      * Read access to a local variable of type float.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -141,7 +135,7 @@
 
     /**
      * Write access to a local variable of type float.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -149,7 +143,7 @@
 
     /**
      * Read access to a local variable of type double.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable
      */
@@ -157,7 +151,7 @@
 
     /**
      * Write access to a local variable of type double.
-     * 
+     *
      * @param slot the slot of the local variable
      * @param value the new value of the local variable
      */
@@ -165,27 +159,17 @@
 
     /**
      * Read access to a local variable of any type.
-     * 
+     *
      * @param slot the slot of the local variable
      * @return the current value of the local variable or defaultValue if unset
      */
     Object getValue(FrameSlot slot);
 
     /**
-     * Converts this virtual frame into a packed frame that has no longer direct access to the local
-     * variables. This packing is an important hint to the Truffle optimizer and therefore passing
-     * around a {@link PackedFrame} should be preferred over passing around a {@link VirtualFrame}
-     * when the probability that an unpacking will occur is low.
-     * 
-     * @return the packed frame
-     */
-    PackedFrame pack();
-
-    /**
      * Materializes this frame, which allows it to be stored in a field or cast to
      * {@link java.lang.Object}. The frame however looses the ability to be packed or to access the
      * caller frame.
-     * 
+     *
      * @return the new materialized frame
      */
     MaterializedFrame materialize();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameInstance.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.frame;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.nodes.*;
+
+public interface FrameInstance {
+
+    public static enum FrameAccess {
+        NONE,
+        READ_ONLY,
+        READ_WRITE,
+        MATERIALIZE
+    }
+
+    Frame getFrame(FrameAccess access, boolean slowPath);
+
+    boolean isVirtualFrame();
+
+    DirectCallNode getCallNode();
+
+    CallTarget getCallTarget();
+
+    CallTarget getTargetCallTarget();
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/NativeFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.frame;
-
-import com.oracle.truffle.api.*;
-
-/**
- * Represents a native frame without any local variables. Instances of this type must not be stored
- * in a field or cast to {@link java.lang.Object}.
- */
-public class NativeFrame implements VirtualFrame, PackedFrame {
-
-    private PackedFrame caller;
-    private Arguments arguments;
-
-    public NativeFrame(PackedFrame caller, Arguments arguments) {
-        this.caller = caller;
-        this.arguments = arguments;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T extends Arguments> T getArguments(Class<T> clazz) {
-        return (T) arguments;
-    }
-
-    @Override
-    public Object getObject(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setObject(FrameSlot slot, Object value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public byte getByte(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setByte(FrameSlot slot, byte value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean getBoolean(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setBoolean(FrameSlot slot, boolean value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public int getInt(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setInt(FrameSlot slot, int value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public long getLong(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setLong(FrameSlot slot, long value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public float getFloat(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setFloat(FrameSlot slot, float value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public double getDouble(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public void setDouble(FrameSlot slot, double value) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public Object getValue(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public PackedFrame pack() {
-        return this;
-    }
-
-    @Override
-    public PackedFrame getCaller() {
-        return caller;
-    }
-
-    @Override
-    public MaterializedFrame materialize() {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public VirtualFrame unpack() {
-        return this;
-    }
-
-    @Override
-    public FrameDescriptor getFrameDescriptor() {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isObject(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isByte(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isBoolean(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isInt(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isLong(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isFloat(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    @Override
-    public boolean isDouble(FrameSlot slot) {
-        throw unsupportedInNativeFrame();
-    }
-
-    private static UnsupportedOperationException unsupportedInNativeFrame() {
-        throw new UnsupportedOperationException("native frame");
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/PackedFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.frame;
-
-/**
- * Represents a packed frame that represents a virtual frame. A packed frame instance can be
- * retrieved with the {@link VirtualFrame#pack()} method. It can be converted back into a virtual
- * frame using {@link PackedFrame#unpack()}. Instances of this type must not be stored in a field or
- * cast to {@link java.lang.Object}.
- */
-public interface PackedFrame {
-
-    /**
-     * Unpacks this frame and converts it back to a virtual frame.
-     * 
-     * @return the virtual frame that was the content of this packed frame
-     */
-    Frame unpack();
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/VirtualFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/VirtualFrame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,23 +24,11 @@
  */
 package com.oracle.truffle.api.frame;
 
-import com.oracle.truffle.api.*;
-
 /**
  * Represents a frame containing values of local variables of the guest language. Instances of this
  * type must not be stored in a field or cast to {@link java.lang.Object}. If this is necessary, the
  * frame must be explicitly converted into a materialized frame using the
- * {@link VirtualFrame#materialize()} method. Whenever fast access to the local variables of a frame
- * is no longer necessary, a virtual frame should be converted into a packed frame using the
- * {@link VirtualFrame#pack()} method.
+ * {@link VirtualFrame#materialize()} method.
  */
 public interface VirtualFrame extends Frame {
-
-    /**
-     * Accesses the caller frame passed in via {@link CallTarget#call}. To get full access, it must
-     * be first unpacked using {@link PackedFrame#unpack()}.
-     * 
-     * @return the caller frame or null if this was a root method call
-     */
-    PackedFrame getCaller();
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.impl;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-public class DefaultCallNode extends CallNode {
-
-    public DefaultCallNode(CallTarget target) {
-        super(target);
-    }
-
-    @Override
-    public Object call(PackedFrame caller, Arguments arguments) {
-        return getCallTarget().call(caller, arguments);
-    }
-
-    @Override
-    public void inline() {
-    }
-
-    @Override
-    public CallTarget getSplitCallTarget() {
-        return null;
-    }
-
-    @Override
-    public boolean split() {
-        return false;
-    }
-
-    @Override
-    public boolean isSplittable() {
-        return false;
-    }
-
-    @Override
-    public boolean isInlined() {
-        return false;
-    }
-
-    @Override
-    public boolean isInlinable() {
-        return false;
-    }
-
-    @Override
-    public String toString() {
-        return getParent() != null ? getParent().toString() : super.toString();
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultCallTarget.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,6 +25,7 @@
 package com.oracle.truffle.api.impl;
 
 import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
 
@@ -34,13 +35,20 @@
  */
 public class DefaultCallTarget extends RootCallTarget {
 
+    @CompilationFinal protected boolean needsMaterializedFrame = true;
+
     protected DefaultCallTarget(RootNode function) {
         super(function);
     }
 
     @Override
-    public Object call(PackedFrame caller, Arguments args) {
-        VirtualFrame frame = new DefaultVirtualFrame(getRootNode().getFrameDescriptor(), caller, args);
-        return getRootNode().execute(frame);
+    public Object call(Object[] args) {
+        VirtualFrame frame = new DefaultVirtualFrame(getRootNode().getFrameDescriptor(), args);
+        return callProxy(frame);
+    }
+
+    @Override
+    public void setNeedsMaterializedFrame() {
+        needsMaterializedFrame = true;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultDirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.impl;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * This is runtime specific API. Do not use in a guest language.
+ */
+public final class DefaultDirectCallNode extends DirectCallNode {
+
+    private boolean inliningForced;
+
+    public DefaultDirectCallNode(CallTarget target) {
+        super(target);
+    }
+
+    @Override
+    public Object call(VirtualFrame frame, Object[] arguments) {
+        return getCurrentCallTarget().call(arguments);
+    }
+
+    @Override
+    public void forceInlining() {
+        inliningForced = true;
+    }
+
+    @Override
+    public boolean isInliningForced() {
+        return inliningForced;
+    }
+
+    @Override
+    public CallTarget getSplitCallTarget() {
+        return null;
+    }
+
+    @Override
+    public boolean split() {
+        return false;
+    }
+
+    @Override
+    public boolean isInlined() {
+        return false;
+    }
+
+    @Override
+    public boolean isSplittable() {
+        return false;
+    }
+
+    @Override
+    public boolean isInlinable() {
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return (getParent() != null ? getParent().toString() : super.toString()) + " call " + getCurrentCallTarget().toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultIndirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.impl;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * This is runtime specific API. Do not use in a guest language.
+ */
+final class DefaultIndirectCallNode extends IndirectCallNode {
+
+    @Override
+    public Object call(VirtualFrame frame, CallTarget target, Object[] arguments) {
+        return target.call(arguments);
+    }
+
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultMaterializedFrame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,10 +29,10 @@
 
 /**
  * This is an implementation-specific class. Do not use or instantiate it. Instead, use
- * {@link TruffleRuntime#createMaterializedFrame(Arguments)} or {@link Frame#materialize()} to
- * create a {@link MaterializedFrame}.
+ * {@link TruffleRuntime#createMaterializedFrame(Object[])} or {@link Frame#materialize()} to create
+ * a {@link MaterializedFrame}.
  */
-final class DefaultMaterializedFrame implements MaterializedFrame, PackedFrame {
+final class DefaultMaterializedFrame implements MaterializedFrame {
 
     private final DefaultVirtualFrame wrapped;
 
@@ -41,8 +41,8 @@
     }
 
     @Override
-    public <T extends Arguments> T getArguments(Class<T> clazz) {
-        return wrapped.getArguments(clazz);
+    public Object[] getArguments() {
+        return wrapped.getArguments();
     }
 
     @Override
@@ -121,21 +121,11 @@
     }
 
     @Override
-    public PackedFrame pack() {
-        return this;
-    }
-
-    @Override
     public MaterializedFrame materialize() {
         return this;
     }
 
     @Override
-    public Frame unpack() {
-        return this;
-    }
-
-    @Override
     public FrameDescriptor getFrameDescriptor() {
         return wrapped.getFrameDescriptor();
     }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultPackedFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.impl;
-
-import com.oracle.truffle.api.frame.*;
-
-/**
- * This is an implementation-specific class. Do not use or instantiate it. Instead, use
- * {@link Frame#pack()} to create a {@link PackedFrame}.
- */
-final class DefaultPackedFrame implements PackedFrame {
-
-    private final DefaultVirtualFrame wrapped;
-
-    DefaultPackedFrame(DefaultVirtualFrame wrapped) {
-        this.wrapped = wrapped;
-    }
-
-    @Override
-    public VirtualFrame unpack() {
-        return wrapped;
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Wed Apr 16 14:02:52 2014 +0200
@@ -53,23 +53,27 @@
         return new DefaultCallTarget(rootNode);
     }
 
-    public CallNode createCallNode(CallTarget target) {
-        return new DefaultCallNode(target);
+    public DirectCallNode createDirectCallNode(CallTarget target) {
+        return new DefaultDirectCallNode(target);
+    }
+
+    public IndirectCallNode createIndirectCallNode() {
+        return new DefaultIndirectCallNode();
     }
 
     @Override
-    public VirtualFrame createVirtualFrame(PackedFrame caller, Arguments arguments, FrameDescriptor frameDescriptor) {
-        return new DefaultVirtualFrame(frameDescriptor, caller, arguments);
+    public VirtualFrame createVirtualFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
+        return new DefaultVirtualFrame(frameDescriptor, arguments);
     }
 
     @Override
-    public MaterializedFrame createMaterializedFrame(Arguments arguments) {
+    public MaterializedFrame createMaterializedFrame(Object[] arguments) {
         return createMaterializedFrame(arguments, new FrameDescriptor());
     }
 
     @Override
-    public MaterializedFrame createMaterializedFrame(Arguments arguments, FrameDescriptor frameDescriptor) {
-        return new DefaultMaterializedFrame(new DefaultVirtualFrame(frameDescriptor, null, arguments));
+    public MaterializedFrame createMaterializedFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
+        return new DefaultMaterializedFrame(new DefaultVirtualFrame(frameDescriptor, arguments));
     }
 
     @Override
@@ -81,4 +85,14 @@
     public Assumption createAssumption(String name) {
         return new DefaultAssumption(name);
     }
+
+    public Iterable<FrameInstance> getStackTrace() {
+        // TODO(lstadler) implement this using ThreadLocal
+        return null;
+    }
+
+    public FrameInstance getCurrentFrame() {
+        // TODO(lstadler) implement this using ThreadLocal
+        return null;
+    }
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,40 +31,27 @@
 
 /**
  * This is an implementation-specific class. Do not use or instantiate it. Instead, use
- * {@link TruffleRuntime#createVirtualFrame(PackedFrame, Arguments, FrameDescriptor)} to create a
+ * {@link TruffleRuntime#createVirtualFrame(Object[], FrameDescriptor)} to create a
  * {@link VirtualFrame}.
  */
 final class DefaultVirtualFrame implements VirtualFrame {
 
     private final FrameDescriptor descriptor;
-    private final PackedFrame caller;
-    private final Arguments arguments;
+    private final Object[] arguments;
     private Object[] locals;
     private byte[] tags;
 
-    DefaultVirtualFrame(FrameDescriptor descriptor, PackedFrame caller, Arguments arguments) {
+    DefaultVirtualFrame(FrameDescriptor descriptor, Object[] arguments) {
         this.descriptor = descriptor;
-        this.caller = caller;
         this.arguments = arguments;
         this.locals = new Object[descriptor.getSize()];
         Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue());
         this.tags = new byte[descriptor.getSize()];
     }
 
-    @SuppressWarnings("unchecked")
     @Override
-    public <T extends Arguments> T getArguments(Class<T> clazz) {
-        return (T) arguments;
-    }
-
-    @Override
-    public PackedFrame getCaller() {
-        return caller;
-    }
-
-    @Override
-    public PackedFrame pack() {
-        return new DefaultPackedFrame(this);
+    public Object[] getArguments() {
+        return arguments;
     }
 
     @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2012, 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.truffle.api.nodes;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-
-/**
- * Represents a call to a {@link CallTarget} in the Truffle AST. Addtionally to calling the
- * {@link CallTarget} this {@link Node} enables the runtime system to implement further
- * optimizations. Optimizations that can possibly applied to a {@link CallNode} are inlining and
- * splitting. Inlining inlines this call site into the call graph of the parent {@link CallTarget}.
- * Splitting duplicates the {@link CallTarget} using {@link RootNode#split()} to collect call site
- * sensitive profiling information.
- * 
- * Please note: This class is not intended to be subclassed by guest language implementations.
- * 
- * @see TruffleRuntime#createCallNode(CallTarget)
- * @see #inline()
- * @see #split()
- */
-public abstract class CallNode extends Node {
-
-    protected final CallTarget callTarget;
-
-    protected CallNode(CallTarget callTarget) {
-        this.callTarget = callTarget;
-    }
-
-    /**
-     * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}.
-     * 
-     * @param caller the caller frame
-     * @param arguments the arguments that should be passed to the callee
-     * @return the return result of the call
-     */
-    public abstract Object call(PackedFrame caller, Arguments arguments);
-
-    /**
-     * Returns the originally supplied {@link CallTarget} when this call node was created. Please
-     * note that the returned {@link CallTarget} is not necessarily the {@link CallTarget} that is
-     * called. For that use {@link #getCurrentCallTarget()} instead.
-     * 
-     * @return the {@link CallTarget} provided.
-     */
-    public CallTarget getCallTarget() {
-        return callTarget;
-    }
-
-    /**
-     * Returns <code>true</code> if the underlying runtime system supports inlining for the
-     * {@link CallTarget} in this {@link CallNode}.
-     * 
-     * @return true if inlining is supported.
-     */
-    public abstract boolean isInlinable();
-
-    /**
-     * Returns <code>true</code> if the {@link CallTarget} in this {@link CallNode} is inlined. A
-     * {@link CallNode} can either be inlined manually by invoking {@link #inline()} or by the
-     * runtime system which may at any point decide to inline.
-     * 
-     * @return true if this method was inlined else false.
-     */
-    public abstract boolean isInlined();
-
-    /**
-     * Enforces the runtime system to inline the {@link CallTarget} at this call site. If the
-     * runtime system does not support inlining or it is already inlined this method has no effect.
-     */
-    public abstract void inline();
-
-    /**
-     * Returns <code>true</code> if this {@link CallNode} can be split. A {@link CallNode} can only
-     * be split if the runtime system supports splitting and if the {@link RootNode} contained the
-     * {@link CallTarget} returns <code>true</code> for {@link RootNode#isSplittable()}.
-     * 
-     * @return <code>true</code> if the target can be split
-     */
-    public abstract boolean isSplittable();
-
-    /**
-     * Enforces the runtime system to split the {@link CallTarget}. If the {@link CallNode} is not
-     * splittable this methods has no effect.
-     */
-    public abstract boolean split();
-
-    /**
-     * Returns <code>true</code> if the target of the {@link CallNode} was split.
-     * 
-     * @return if the target was split
-     */
-    public final boolean isSplit() {
-        return getSplitCallTarget() != null;
-    }
-
-    /**
-     * Returns the splitted {@link CallTarget} if this method is split.
-     * 
-     * @return the split {@link CallTarget}
-     */
-    public abstract CallTarget getSplitCallTarget();
-
-    /**
-     * Returns the used call target when {@link #call(PackedFrame, Arguments)} is invoked. If the
-     * {@link CallTarget} was split this method returns the {@link CallTarget} returned by
-     * {@link #getSplitCallTarget()}.
-     * 
-     * @return the used {@link CallTarget} when node is called
-     */
-    public CallTarget getCurrentCallTarget() {
-        CallTarget split = getSplitCallTarget();
-        if (split != null) {
-            return split;
-        } else {
-            return getCallTarget();
-        }
-    }
-
-    /**
-     * Returns the {@link RootNode} associated with {@link CallTarget} returned by
-     * {@link #getCurrentCallTarget()}. If the stored {@link CallTarget} does not contain a
-     * {@link RootNode} this method returns <code>null</code>.
-     * 
-     * @see #getCurrentCallTarget()
-     * @return the root node of the used call target
-     */
-    public final RootNode getCurrentRootNode() {
-        CallTarget target = getCurrentCallTarget();
-        if (target instanceof RootCallTarget) {
-            return ((RootCallTarget) target).getRootNode();
-        }
-        return null;
-    }
-
-    @Override
-    protected void onReplace(Node newNode, CharSequence reason) {
-        super.onReplace(newNode, reason);
-
-        /*
-         * Old call nodes are removed in the old target root node.
-         */
-        CallNode oldCall = this;
-        RootNode oldRoot = getCurrentRootNode();
-        if (oldRoot != null) {
-            oldRoot.removeCachedCallNode(oldCall);
-        }
-
-        registerCallTarget((CallNode) newNode);
-    }
-
-    /**
-     * Internal API for the runtime system.
-     */
-    protected static final void registerCallTarget(CallNode newNode) {
-        RootNode newRoot = newNode.getCurrentRootNode();
-        if (newRoot != null) {
-            newRoot.addCachedCallNode(newNode);
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/DirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2012, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.nodes;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+
+/**
+ * Represents a direct call to a {@link CallTarget}. Direct calls are calls for which the
+ * {@link CallTarget} remains the same for each consecutive call. This part of the Truffle API
+ * enables the runtime system to perform additional optimizations on direct calls.
+ *
+ * Optimizations that can be applied to a {@link DirectCallNode} are inlining and splitting.
+ * Inlining inlines this call site into the call graph of the parent {@link CallTarget}. Splitting
+ * duplicates the {@link CallTarget} using {@link RootNode#split()} to collect call site sensitive
+ * profiling information.
+ *
+ * Please note: This class is not intended to be subclassed by guest language implementations.
+ *
+ * @see IndirectCallNode for calls with a non-constant target
+ * @see TruffleRuntime#createDirectCallNode(CallTarget)
+ * @see #forceInlining()
+ * @see #split()
+ */
+public abstract class DirectCallNode extends Node {
+
+    protected final CallTarget callTarget;
+
+    protected DirectCallNode(CallTarget callTarget) {
+        this.callTarget = callTarget;
+    }
+
+    /**
+     * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}.
+     *
+     * @param arguments the arguments that should be passed to the callee
+     * @return the return result of the call
+     */
+    public abstract Object call(VirtualFrame frame, Object[] arguments);
+
+    /**
+     * Returns the originally supplied {@link CallTarget} when this call node was created. Please
+     * note that the returned {@link CallTarget} is not necessarily the {@link CallTarget} that is
+     * called. For that use {@link #getCurrentCallTarget()} instead.
+     *
+     * @return the {@link CallTarget} provided.
+     */
+    public CallTarget getCallTarget() {
+        return callTarget;
+    }
+
+    /**
+     * Returns <code>true</code> if the underlying runtime system supports inlining for the
+     * {@link CallTarget} in this {@link DirectCallNode}.
+     *
+     * @return true if inlining is supported.
+     */
+    public abstract boolean isInlinable();
+
+    /**
+     * Returns <code>true</code> if the {@link CallTarget} is forced to be inlined. A
+     * {@link DirectCallNode} can either be inlined manually by invoking {@link #forceInlining()} or
+     * by the runtime system which may at any point decide to inline.
+     *
+     * @return true if this method was inlined else false.
+     */
+    public abstract boolean isInliningForced();
+
+    /**
+     * Enforces the runtime system to inline the {@link CallTarget} at this call site. If the
+     * runtime system does not support inlining or it is already inlined this method has no effect.
+     * The runtime system may decide to not inline calls which were forced to inline.
+     */
+    public abstract void forceInlining();
+
+    /**
+     * Returns true if the runtime system has decided to inline this call-site. If the
+     * {@link DirectCallNode} was forced to inline then this does not necessarily mean that the
+     * {@link DirectCallNode} is really going to be inlined. This depends on whether or not the
+     * runtime system supports inlining. The runtime system may also decide to not inline calls
+     * which were forced to inline.
+     */
+    public abstract boolean isInlined();
+
+    /**
+     * Returns <code>true</code> if this {@link DirectCallNode} can be split. A
+     * {@link DirectCallNode} can only be split if the runtime system supports splitting and if the
+     * {@link RootNode} contained the {@link CallTarget} returns <code>true</code> for
+     * {@link RootNode#isSplittable()}.
+     *
+     * @return <code>true</code> if the target can be split
+     */
+    public abstract boolean isSplittable();
+
+    /**
+     * Enforces the runtime system to split the {@link CallTarget}. If the {@link DirectCallNode} is
+     * not splittable this methods has no effect.
+     */
+    public abstract boolean split();
+
+    /**
+     * Returns <code>true</code> if the target of the {@link DirectCallNode} was split.
+     *
+     * @return if the target was split
+     */
+    public final boolean isSplit() {
+        return getSplitCallTarget() != null;
+    }
+
+    /**
+     * Returns the split {@link CallTarget} if this method is split.
+     *
+     * @return the split {@link CallTarget}
+     */
+    public abstract CallTarget getSplitCallTarget();
+
+    /**
+     * Returns the used call target when {@link #call(VirtualFrame, Object[])} is invoked. If the
+     * {@link CallTarget} was split this method returns the {@link CallTarget} returned by
+     * {@link #getSplitCallTarget()}.
+     *
+     * @return the used {@link CallTarget} when node is called
+     */
+    public CallTarget getCurrentCallTarget() {
+        CallTarget split = getSplitCallTarget();
+        if (split != null) {
+            return split;
+        } else {
+            return getCallTarget();
+        }
+    }
+
+    /**
+     * Returns the {@link RootNode} associated with {@link CallTarget} returned by
+     * {@link #getCurrentCallTarget()}. If the stored {@link CallTarget} does not contain a
+     * {@link RootNode} this method returns <code>null</code>.
+     *
+     * @see #getCurrentCallTarget()
+     * @return the root node of the used call target
+     */
+    public final RootNode getCurrentRootNode() {
+        CallTarget target = getCurrentCallTarget();
+        if (target instanceof RootCallTarget) {
+            return ((RootCallTarget) target).getRootNode();
+        }
+        return null;
+    }
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -59,6 +59,8 @@
     private Element nodesElement;
     private Element edgesElement;
 
+    private ChildSupplier childSupplier;
+
     public GraphPrintVisitor() {
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         try {
@@ -73,6 +75,14 @@
         dom.appendChild(graphDocument);
     }
 
+    public void setChildSupplier(ChildSupplier callNodeVisitor) {
+        this.childSupplier = callNodeVisitor;
+    }
+
+    public ChildSupplier getChildSupplier() {
+        return childSupplier;
+    }
+
     public GraphPrintVisitor beginGroup(String groupName) {
         groupElement = dom.createElement("group");
         graphDocument.appendChild(groupElement);
@@ -328,6 +338,15 @@
             // default handler
             createElementForNode(node);
 
+            if (childSupplier != null) {
+                Object result = childSupplier.startNode(node);
+                if (result != null) {
+                    visit(result);
+                    connectNodes(node, result, "inlined");
+                }
+                childSupplier.endNode(node);
+            }
+
             if (node instanceof Node) {
                 for (Map.Entry<String, Node> child : findNamedNodeChildren((Node) node).entrySet()) {
                     visit(child.getValue());
@@ -343,13 +362,6 @@
         LinkedHashMap<String, Node> nodes = new LinkedHashMap<>();
         NodeClass nodeClass = NodeClass.get(node.getClass());
 
-        if (node instanceof CallNode) {
-            CallNode callNode = ((CallNode) node);
-            RootNode inlinedRoot = callNode.getCurrentRootNode();
-            if (inlinedRoot != null && callNode.isInlined()) {
-                nodes.put("inlinedRoot", inlinedRoot);
-            }
-        }
         for (NodeField field : nodeClass.getFields()) {
             NodeFieldKind kind = field.getKind();
             if (kind == NodeFieldKind.CHILD || kind == NodeFieldKind.CHILDREN) {
@@ -396,6 +408,15 @@
         void visit(Object node, GraphPrintAdapter gPrinter);
     }
 
+    public interface ChildSupplier {
+
+        /** Supplies an additional child if available. */
+        Object startNode(Object callNode);
+
+        void endNode(Object callNode);
+
+    }
+
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ElementType.TYPE)
     public @interface CustomGraphPrintHandler {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/IndirectCallNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.truffle.api.nodes;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+
+/**
+ * Represents an indirect call to a {@link CallTarget}. Indirect calls are calls for which the
+ * {@link CallTarget} may change dynamically for each consecutive call. This part of the Truffle API
+ * enables the runtime system to perform additional optimizations on indirect calls.
+ *
+ * Please note: This class is not intended to be sub classed by guest language implementations.
+ *
+ * @see DirectCallNode for faster calls with a constantly known {@link CallTarget}.
+ */
+public abstract class IndirectCallNode extends Node {
+
+    /**
+     * Performs an indirect call to the given {@link CallTarget} target with the provided arguments.
+     *
+     * @param frame the caller frame
+     * @param target the {@link CallTarget} to call
+     * @param arguments the arguments to provide
+     * @return the return value of the call
+     */
+    public abstract Object call(VirtualFrame frame, CallTarget target, Object[] arguments);
+
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Wed Apr 16 14:02:52 2014 +0200
@@ -67,7 +67,7 @@
 
     /**
      * Assigns a link to a guest language source section to this node.
-     * 
+     *
      * @param section the object representing a section in guest language source code
      */
     public final void assignSourceSection(SourceSection section) {
@@ -107,7 +107,7 @@
 
     /**
      * Retrieves the guest language source code section that is currently assigned to this node.
-     * 
+     *
      * @return the assigned source code section
      */
     public final SourceSection getSourceSection() {
@@ -116,7 +116,7 @@
 
     /**
      * Retrieves the guest language source code section that is currently assigned to this node.
-     * 
+     *
      * @return the assigned source code section
      */
     @CompilerDirectives.SlowPath
@@ -130,7 +130,7 @@
     /**
      * Method that updates the link to the parent in the array of specified new child nodes to this
      * node.
-     * 
+     *
      * @param newChildren the array of new children whose parent should be updated
      * @return the array of new children
      */
@@ -142,7 +142,7 @@
 
     /**
      * Method that updates the link to the parent in the specified new child node to this node.
-     * 
+     *
      * @param newChild the new child whose parent should be updated
      * @return the new child
      */
@@ -155,7 +155,7 @@
     /**
      * Method that updates the link to the parent in the array of specified new child nodes to this
      * node.
-     * 
+     *
      * @param newChildren the array of new children whose parent should be updated
      * @return the array of new children
      */
@@ -170,7 +170,7 @@
 
     /**
      * Method that updates the link to the parent in the specified new child node to this node.
-     * 
+     *
      * @param newChild the new child whose parent should be updated
      * @return the new child
      */
@@ -225,7 +225,7 @@
     /**
      * Returns properties of this node interesting for debugging and can be overwritten by
      * subclasses to add their own custom properties.
-     * 
+     *
      * @return the properties as a key/value hash map
      */
     public Map<String, Object> getDebugProperties() {
@@ -235,7 +235,7 @@
 
     /**
      * The current parent node of this node.
-     * 
+     *
      * @return the parent node
      */
     public final Node getParent() {
@@ -245,7 +245,7 @@
     /**
      * Replaces this node with another node. If there is a source section (see
      * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
-     * 
+     *
      * @param newNode the new node that is the replacement
      * @param reason a description of the reason for the replacement
      * @return the new node
@@ -263,7 +263,7 @@
     /**
      * Replaces this node with another node. If there is a source section (see
      * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
-     * 
+     *
      * @param newNode the new node that is the replacement
      * @return the new node
      */
@@ -294,7 +294,7 @@
 
     /**
      * Checks if this node is properly adopted by a parent and can be replaced.
-     * 
+     *
      * @return {@code true} if it is safe to replace this node.
      */
     public final boolean isReplaceable() {
@@ -321,7 +321,7 @@
     /**
      * Intended to be implemented by subclasses of {@link Node} to receive a notification when the
      * node is rewritten. This method is invoked before the actual replace has happened.
-     * 
+     *
      * @param newNode the replacement node
      * @param reason the reason the replace supplied
      */
@@ -396,7 +396,7 @@
     /**
      * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all
      * child nodes.
-     * 
+     *
      * @param nodeVisitor the visitor
      */
     public final void accept(NodeVisitor nodeVisitor) {
@@ -411,7 +411,7 @@
 
     /**
      * Iterator over the children of this node.
-     * 
+     *
      * @return the iterator
      */
     public final Iterable<Node> getChildren() {
@@ -426,7 +426,7 @@
 
     /**
      * Creates a shallow copy of this node.
-     * 
+     *
      * @return the new copy
      */
     public Node copy() {
@@ -449,7 +449,7 @@
 
     /**
      * Get the root node of the tree a node belongs to.
-     * 
+     *
      * @return the {@link RootNode} or {@code null} if there is none.
      */
     public final RootNode getRootNode() {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Wed Apr 16 14:02:52 2014 +0200
@@ -636,8 +636,8 @@
                 nodeCount++;
             }
 
-            if (visitInlinedCallNodes && node instanceof CallNode) {
-                CallNode call = (CallNode) node;
+            if (visitInlinedCallNodes && node instanceof DirectCallNode) {
+                DirectCallNode call = (DirectCallNode) node;
                 if (call.isInlined()) {
                     Node target = ((RootCallTarget) call.getCurrentCallTarget()).getRootNode();
                     if (target != null) {
@@ -651,39 +651,6 @@
 
     }
 
-    public static void printInliningTree(final PrintStream stream, RootNode root) {
-        printRootNode(stream, 0, root);
-        root.accept(new NodeVisitor() {
-            int depth = 1;
-
-            public boolean visit(Node node) {
-                if (node instanceof CallNode) {
-                    CallNode callNode = ((CallNode) node);
-                    RootNode inlinedRoot = callNode.getCurrentRootNode();
-                    if (inlinedRoot != null && callNode.isInlined()) {
-                        depth++;
-                        printRootNode(stream, depth * 2, inlinedRoot);
-                        inlinedRoot.accept(this);
-                        depth--;
-                    }
-                }
-                return true;
-            }
-        });
-    }
-
-    private static void printRootNode(PrintStream stream, int indent, RootNode root) {
-        for (int i = 0; i < indent; i++) {
-            stream.print(" ");
-        }
-        stream.print(root.toString());
-        stream.print(" (");
-        stream.print(countNodes(root));
-        stream.print("/");
-        stream.print(countNodes(root, null, true));
-        stream.println(")");
-    }
-
     public static String printCompactTreeToString(Node node) {
         StringWriter out = new StringWriter();
         printCompactTree(new PrintWriter(out), null, node, 1);
@@ -796,7 +763,7 @@
     /**
      * Prints a human readable form of a {@link Node} AST to the given {@link PrintStream}. This
      * print method does not check for cycles in the node structure.
-     * 
+     *
      * @param out the stream to print to.
      * @param node the root node to write
      */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/RootNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,8 +24,6 @@
  */
 package com.oracle.truffle.api.nodes;
 
-import java.util.*;
-
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
@@ -39,11 +37,6 @@
     private RootCallTarget callTarget;
     private final FrameDescriptor frameDescriptor;
 
-    /*
-     * Internal set to keep back-references to the call-sites.
-     */
-    private final Set<CallNode> cachedCallNodes = Collections.newSetFromMap(new WeakHashMap<CallNode, Boolean>());
-
     protected RootNode() {
         this(null, null);
     }
@@ -65,7 +58,7 @@
      * Creates a split {@link RootNode} based on the current {@link RootNode}. This method should
      * return an AST that was never executed and must not be shared with other {@link RootNode} or
      * {@link CallTarget} instances. This method is intended to be overridden by a subclass.
-     * 
+     *
      * @return the split {@link RootNode}
      */
     public RootNode split() {
@@ -74,10 +67,10 @@
 
     /**
      * Returns <code>true</code> if this {@link RootNode} can be split. A {@link RootNode} can be
-     * split inside of a {@link CallTarget} that is invoked using a {@link CallNode}. If this method
-     * returns <code>true</code> a proper implementation of {@link #split()} must also be provided.
-     * This method is intended to be overridden by a subclass.
-     * 
+     * split inside of a {@link CallTarget} that is invoked using a {@link DirectCallNode}. If this
+     * method returns <code>true</code> a proper implementation of {@link #split()} must also be
+     * provided. This method is intended to be overridden by a subclass.
+     *
      * @return <code>true</code> if splittable else <code>false</code>.
      */
     public boolean isSplittable() {
@@ -96,7 +89,7 @@
 
     /**
      * Executes this function using the specified frame and returns the result value.
-     * 
+     *
      * @param frame the frame of the currently executing guest language method
      * @return the value of the execution
      */
@@ -114,26 +107,4 @@
         this.callTarget = callTarget;
     }
 
-    /* Internal API. Do not use. */
-    final void addCachedCallNode(CallNode callSite) {
-        this.cachedCallNodes.add(callSite);
-    }
-
-    /* Internal API. Do not use. */
-    final void removeCachedCallNode(CallNode callSite) {
-        this.cachedCallNodes.remove(callSite);
-    }
-
-    /**
-     * Returns a {@link Set} of {@link CallNode} nodes which are created to invoke this RootNode.
-     * This method does not make any guarantees to contain all the {@link CallNode} nodes that are
-     * invoking this method. Due to its weak nature the elements returned by this method may change
-     * with each consecutive call.
-     * 
-     * @return a set of {@link CallNode} nodes
-     */
-    public final Set<CallNode> getCachedCallNodes() {
-        return Collections.unmodifiableSet(cachedCallNodes);
-    }
-
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -379,7 +379,7 @@
                     CompilerDirectives.transferToInterpreter();
                 }
                 if (stepping) {
-                    getContext().getDebugContext().getDebugManager().haltedAt(astNode, frame);
+                    getContext().getDebugContext().getDebugManager().haltedAt(astNode, frame.materialize());
                 }
                 if (next != null) {
                     next.internalEnter(astNode, frame);
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,9 @@
 
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeClass;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeField;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeFieldKind;
 
 /**
  * Experimental API. May change without notice.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceLineLocation.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceLineLocation.java	Wed Apr 16 14:02:52 2014 +0200
@@ -31,7 +31,7 @@
  * instance of {@link Source}, suitable for hash table keys with equality defined in terms of
  * content.
  */
-public class SourceLineLocation implements Comparable {
+public class SourceLineLocation implements Comparable<Object> {
 
     private final Source source;
     private final int line;
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,7 +25,7 @@
 package com.oracle.truffle.api.utilities;
 
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
 
 /**
  * Utility class to speculate on branches to be never visited. If the {@link #enter()} method is
@@ -44,4 +44,9 @@
         }
     }
 
+    @Override
+    public String toString() {
+        return String.format("%s(%s)@%x", getClass().getSimpleName(), visited ? "visited" : "not-visited", hashCode());
+    }
+
 }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ProcessorContext.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
 import javax.lang.model.util.*;
 
 import com.oracle.truffle.dsl.processor.ast.*;
-import com.oracle.truffle.dsl.processor.ast.CodeTypeMirror.*;
+import com.oracle.truffle.dsl.processor.ast.CodeTypeMirror.ArrayCodeTypeMirror;
 import com.oracle.truffle.dsl.processor.template.*;
 
 /**
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleProcessor.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,9 +28,9 @@
 import javax.annotation.processing.*;
 import javax.lang.model.*;
 import javax.lang.model.element.*;
-import javax.tools.Diagnostic.*;
+import javax.tools.Diagnostic.Kind;
 
-import com.oracle.truffle.dsl.processor.ProcessorContext.*;
+import com.oracle.truffle.dsl.processor.ProcessorContext.ProcessCallback;
 import com.oracle.truffle.dsl.processor.node.*;
 import com.oracle.truffle.dsl.processor.typesystem.*;
 
@@ -60,7 +60,7 @@
         // TODO run verifications that other annotations are not processed out of scope of the
         // operation or typelattice.
         try {
-            for (AnnotationProcessor generator : getGenerators()) {
+            for (AnnotationProcessor<?> generator : getGenerators()) {
                 AbstractParser<?> parser = generator.getParser();
                 if (parser.getAnnotationType() != null) {
                     for (Element e : env.getElementsAnnotatedWith(parser.getAnnotationType())) {
@@ -86,7 +86,7 @@
         }
     }
 
-    private static void processElement(RoundEnvironment env, AnnotationProcessor generator, Element e, boolean callback) {
+    private static void processElement(RoundEnvironment env, AnnotationProcessor<?> generator, Element e, boolean callback) {
         try {
             generator.process(env, e, callback);
         } catch (Throwable e1) {
@@ -94,16 +94,15 @@
         }
     }
 
-    private static void handleThrowable(AnnotationProcessor generator, Throwable t, Element e) {
+    private static void handleThrowable(AnnotationProcessor<?> generator, Throwable t, Element e) {
         String message = "Uncaught error in " + generator.getClass().getSimpleName() + " while processing " + e;
         generator.getContext().getEnvironment().getMessager().printMessage(Kind.ERROR, message + ": " + Utils.printException(t), e);
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public void callback(TypeElement template) {
-        for (AnnotationProcessor generator : generators) {
-            Class annotationType = generator.getParser().getAnnotationType();
+        for (AnnotationProcessor<?> generator : generators) {
+            Class<? extends Annotation> annotationType = generator.getParser().getAnnotationType();
             if (annotationType != null) {
                 Annotation annotation = template.getAnnotation(annotationType);
                 if (annotation != null) {
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/TruffleTypes.java	Wed Apr 16 14:02:52 2014 +0200
@@ -29,7 +29,8 @@
 import javax.tools.Diagnostic.Kind;
 
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
@@ -111,7 +112,7 @@
         return nodeCost;
     }
 
-    private DeclaredType getRequired(ProcessorContext context, Class clazz) {
+    private DeclaredType getRequired(ProcessorContext context, Class<?> clazz) {
         TypeMirror type = context.getType(clazz);
         if (type == null) {
             errors.add(String.format("Could not find required type: %s", clazz.getSimpleName()));
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/ast/CodeTypeElement.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-import com.oracle.truffle.dsl.processor.ast.CodeTypeMirror.*;
+import com.oracle.truffle.dsl.processor.ast.CodeTypeMirror.DeclaredCodeTypeMirror;
 
 public class CodeTypeElement extends CodeElement<Element> implements TypeElement {
 
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/compiler/AbstractCompiler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/compiler/AbstractCompiler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -32,7 +32,7 @@
         return method.invoke(o);
     }
 
-    protected static Object method(Object o, String methodName, Class[] paramTypes, Object... values) throws Exception {
+    protected static Object method(Object o, String methodName, Class<?>[] paramTypes, Object... values) throws Exception {
         Method method = o.getClass().getMethod(methodName, paramTypes);
         method.setAccessible(true);
         return method.invoke(o, values);
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/compiler/JavaCCompiler.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/compiler/JavaCCompiler.java	Wed Apr 16 14:02:52 2014 +0200
@@ -44,8 +44,8 @@
         return type.getEnclosedElements();
     }
 
-    private static final Class[] getTreeAndTopLevelSignature = new Class[]{Element.class, AnnotationMirror.class, AnnotationValue.class};
-    private static final Class[] getCharContentSignature = new Class[]{boolean.class};
+    private static final Class<?>[] getTreeAndTopLevelSignature = new Class[]{Element.class, AnnotationMirror.class, AnnotationValue.class};
+    private static final Class<?>[] getCharContentSignature = new Class[]{boolean.class};
 
     @Override
     public String getMethodBody(ProcessingEnvironment env, ExecutableElement method) {
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 import javax.lang.model.type.*;
 
 import com.oracle.truffle.dsl.processor.*;
-import com.oracle.truffle.dsl.processor.node.NodeChildData.*;
+import com.oracle.truffle.dsl.processor.node.NodeChildData.Cardinality;
 import com.oracle.truffle.dsl.processor.template.*;
 import com.oracle.truffle.dsl.processor.typesystem.*;
 
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeExecutionData.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeExecutionData.java	Wed Apr 16 14:02:52 2014 +0200
@@ -24,7 +24,7 @@
 
 import javax.lang.model.type.*;
 
-import com.oracle.truffle.dsl.processor.node.NodeChildData.*;
+import com.oracle.truffle.dsl.processor.node.NodeChildData.Cardinality;
 
 public class NodeExecutionData {
 
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/CodeElementFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/CodeElementFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -44,7 +44,7 @@
     protected void createChildren(M m) {
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "rawtypes"})
     public CodeElement<?> process(CodeElement parent, M m) {
         model = m;
         element = (CodeElement<? super Element>) create(model);
@@ -57,6 +57,7 @@
         return element;
     }
 
+    @SuppressWarnings("rawtypes")
     public CodeElement getElement() {
         return element;
     }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/CompilationUnitFactory.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/CompilationUnitFactory.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,6 +36,7 @@
         return new CodeCompilationUnit();
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
     public CodeCompilationUnit process(CodeElement parent, M m) {
         return (CodeCompilationUnit) super.process(parent, m);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl.test/tests/HelloEqualsWorld.sl	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,22 @@
+function doIt(a) {
+//  println("Initial stack trace:");
+//  println(stacktrace());
+  
+  hello = 123;
+//  println("After 123 assignment:");
+//  println(stacktrace());
+  
+//  helloEqualsWorld();
+//  println("After hello assignment:");
+//  println(stacktrace());
+  
+//  readln();
+}
+
+function main() {
+  i = 0;
+  while (i < 10) {
+    doIt(i);
+    i = i + 1;
+  }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed Apr 16 14:02:52 2014 +0200
@@ -163,7 +163,7 @@
                 long start = System.nanoTime();
                 /* Call the main entry point, without any arguments. */
                 try {
-                    Object result = main.getCallTarget().call(null, new SLArguments(new Object[0]));
+                    Object result = main.getCallTarget().call();
                     if (result != SLNull.SINGLETON) {
                         context.getOutput().println(result);
                     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLHelloEqualsWorldBuiltin.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, 2014, 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.truffle.sl.builtins;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.frame.FrameInstance.FrameAccess;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * This builtin sets the variable named "hello" in the caller frame to the string "world".
+ */
+@NodeInfo(shortName = "helloEqualsWorld")
+public abstract class SLHelloEqualsWorldBuiltin extends SLBuiltinNode {
+
+    @Specialization
+    public Object change() {
+        FrameInstance frameInstance = Truffle.getRuntime().getStackTrace().iterator().next();
+        Frame frame = frameInstance.getFrame(FrameAccess.READ_WRITE, false);
+        FrameSlot slot = frame.getFrameDescriptor().findOrAddFrameSlot("hello");
+        frame.setObject(slot, "world");
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/builtins/SLStackTraceBuiltin.java	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, 2014, 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.truffle.sl.builtins;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.SlowPath;
+import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.frame.FrameInstance.FrameAccess;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * Returns a string representation of the current stack. This includes the {@link CallTarget}s and
+ * the contents of the {@link Frame}. Note that this is implemented as a slow path by passing
+ * {@code true} to {@link FrameInstance#getFrame(FrameAccess, boolean)}.
+ */
+@NodeInfo(shortName = "stacktrace")
+public abstract class SLStackTraceBuiltin extends SLBuiltinNode {
+
+    @Specialization
+    public String trace() {
+        return createStackTrace();
+    }
+
+    @SlowPath
+    private static String createStackTrace() {
+        StringBuilder str = new StringBuilder();
+        Iterable<FrameInstance> frames = Truffle.getRuntime().getStackTrace();
+
+        if (frames != null) {
+            for (FrameInstance frame : frames) {
+                dumpFrame(str, frame.getCallTarget(), frame.getFrame(FrameAccess.READ_ONLY, true), frame.isVirtualFrame());
+            }
+        }
+        return str.toString();
+    }
+
+    private static void dumpFrame(StringBuilder str, CallTarget rootNode, Frame frame, boolean isVirtual) {
+        if (str.length() > 0) {
+            str.append("\n");
+        }
+        str.append("Frame: ").append(rootNode).append(isVirtual ? " (virtual)" : "");
+        FrameDescriptor frameDescriptor = frame.getFrameDescriptor();
+        for (FrameSlot s : frameDescriptor.getSlots()) {
+            str.append(", ").append(s.getIdentifier()).append("=").append(frame.getValue(s));
+        }
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLAbstractDispatchNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLAbstractDispatchNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -49,5 +49,5 @@
 
     protected static final int INLINE_CACHE_SIZE = 2;
 
-    protected abstract Object executeDispatch(VirtualFrame frame, SLFunction function, SLArguments arguments);
+    protected abstract Object executeDispatch(VirtualFrame frame, SLFunction function, Object[] arguments);
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLDirectDispatchNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -36,11 +36,11 @@
     private final SLFunction cachedFunction;
 
     /**
-     * {@link CallNode} is part of the Truffle API and handles all the steps necessary for method
-     * inlining: if the call is executed frequently and the callee is small, then the call is
+     * {@link DirectCallNode} is part of the Truffle API and handles all the steps necessary for
+     * method inlining: if the call is executed frequently and the callee is small, then the call is
      * inlined, i.e., the call node is replaced with a copy of the callee's AST.
      */
-    @Child private CallNode callCachedTargetNode;
+    @Child private DirectCallNode callCachedTargetNode;
 
     /** Assumption that the {@link #callCachedTargetNode} is still valid. */
     private final Assumption cachedTargetStable;
@@ -53,7 +53,7 @@
 
     protected SLDirectDispatchNode(SLAbstractDispatchNode next, SLFunction cachedFunction) {
         this.cachedFunction = cachedFunction;
-        this.callCachedTargetNode = Truffle.getRuntime().createCallNode(cachedFunction.getCallTarget());
+        this.callCachedTargetNode = Truffle.getRuntime().createDirectCallNode(cachedFunction.getCallTarget());
         this.cachedTargetStable = cachedFunction.getCallTargetStable();
         this.nextNode = next;
     }
@@ -71,7 +71,7 @@
      * the call target allows method inlining.
      */
     @Override
-    protected Object executeDispatch(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+    protected Object executeDispatch(VirtualFrame frame, SLFunction function, Object[] arguments) {
         /*
          * The inline cache check. Note that cachedFunction must be a final field so that the
          * compiler can optimize the check.
@@ -92,7 +92,7 @@
                  * Now we are really ready to perform the call. We use a Truffle CallNode for that,
                  * because it does all the work for method inlining.
                  */
-                return callCachedTargetNode.call(frame.pack(), arguments);
+                return callCachedTargetNode.call(frame, arguments);
 
             } catch (InvalidAssumptionException ex) {
                 /*
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLGenericDispatchNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLGenericDispatchNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,9 @@
  */
 package com.oracle.truffle.sl.nodes.call;
 
+import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.sl.runtime.*;
 
 /**
@@ -31,12 +33,20 @@
  */
 final class SLGenericDispatchNode extends SLAbstractDispatchNode {
 
+    /**
+     * {@link IndirectCallNode} is part of the Truffle API and handles all the steps necessary for
+     * calling a megamorphic call-site. The Graal specific version of this node performs additional
+     * optimizations for the fast access of the SimpleLanguage stack trace.
+     */
+    @Child private IndirectCallNode callNode = Truffle.getRuntime().createIndirectCallNode();
+
     @Override
-    protected Object executeDispatch(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+    protected Object executeDispatch(VirtualFrame frame, SLFunction function, Object[] arguments) {
         /*
          * SL has a quite simple call lookup: just ask the function for the current call target, and
          * call it.
          */
-        return function.getCallTarget().call(frame.pack(), arguments);
+        return callNode.call(frame, function.getCallTarget(), arguments);
     }
+
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInvokeNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLInvokeNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -70,9 +70,8 @@
         for (int i = 0; i < argumentNodes.length; i++) {
             argumentValues[i] = argumentNodes[i].executeGeneric(frame);
         }
-        SLArguments arguments = new SLArguments(argumentValues);
 
-        return dispatchNode.executeDispatch(frame, function, arguments);
+        return dispatchNode.executeDispatch(frame, function, argumentValues);
     }
 
     private SLFunction evaluateFunction(VirtualFrame frame) {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLUninitializedDispatchNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/call/SLUninitializedDispatchNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -40,7 +40,7 @@
      * {@link SLGenericDispatchNode}.
      */
     @Override
-    protected Object executeDispatch(VirtualFrame frame, SLFunction function, SLArguments arguments) {
+    protected Object executeDispatch(VirtualFrame frame, SLFunction function, Object[] arguments) {
         /* The following code modifies the AST, so compiled code must be invalidated. */
         CompilerDirectives.transferToInterpreterAndInvalidate();
 
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/local/SLReadArgumentNode.java	Wed Apr 16 14:02:52 2014 +0200
@@ -22,7 +22,6 @@
  */
 package com.oracle.truffle.sl.nodes.local;
 
-import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.utilities.*;
 import com.oracle.truffle.sl.nodes.*;
@@ -30,9 +29,7 @@
 import com.oracle.truffle.sl.runtime.*;
 
 /**
- * Reads a function argument. Arguments are passed in as a {@link SLArguments} object, which
- * encapsulates an {@link SLArguments#getFromFrame Object[] array}. Language-defined subclasses of
- * {@link Arguments} are the standard Truffle way to pass values between functions.
+ * Reads a function argument. Arguments are passed in as an object array.
  * <p>
  * Arguments are not type-specialized. To ensure that repeated accesses within a method are
  * specialized and can, e.g., be accessed without unboxing, all arguments are loaded into local
@@ -55,7 +52,7 @@
 
     @Override
     public Object executeGeneric(VirtualFrame frame) {
-        Object[] args = SLArguments.getFromFrame(frame);
+        Object[] args = frame.getArguments();
         if (index < args.length) {
             return args[index];
         } else {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Wed Apr 16 14:02:52 2014 +0200
@@ -25,11 +25,8 @@
 
 package com.oracle.truffle.sl.parser;
 
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Map;
-import java.util.HashMap;
+import java.io.*;
+import java.util.*;
 
 // Checkstyle: stop
 // @formatter:off
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLArguments.java	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2012, 2014, 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.truffle.sl.runtime;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.sl.nodes.call.*;
-import com.oracle.truffle.sl.nodes.local.*;
-
-/**
- * Encapsulation of SL function arguments, as required by the Truffle API. An instance of this class
- * is allocated by the caller, and read by the callee.
- */
-public final class SLArguments extends Arguments {
-
-    private final Object[] argumentValues;
-
-    /**
-     * Used by the caller, i.e., the {@link SLInvokeNode node that performs a function call}.
-     */
-    public SLArguments(Object[] arguments) {
-        this.argumentValues = arguments;
-    }
-
-    /**
-     * Used by the callee, i.e., the {@link SLReadArgumentNode note that reads a function argument}.
-     */
-    public static Object[] getFromFrame(VirtualFrame frame) {
-        return frame.getArguments(SLArguments.class).argumentValues;
-    }
-}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Tue Apr 15 19:08:29 2014 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/runtime/SLContext.java	Wed Apr 16 14:02:52 2014 +0200
@@ -97,6 +97,8 @@
         installBuiltin(SLPrintlnBuiltinFactory.getInstance());
         installBuiltin(SLNanoTimeBuiltinFactory.getInstance());
         installBuiltin(SLDefineFunctionBuiltinFactory.getInstance());
+        installBuiltin(SLStackTraceBuiltinFactory.getInstance());
+        installBuiltin(SLHelloEqualsWorldBuiltinFactory.getInstance());
     }
 
     private void installBuiltin(NodeFactory<? extends SLBuiltinNode> factory) {
--- a/make/bsd/makefiles/mapfile-vers-debug	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/bsd/makefiles/mapfile-vers-debug	Wed Apr 16 14:02:52 2014 +0200
@@ -221,8 +221,6 @@
                 _JVM_SetLength
                 _JVM_SetNativeThreadName
                 _JVM_SetPrimitiveArrayElement
-                # Preserved so that Graal repo can link against a JDK7 libjava.so works
-                _JVM_SetProtectionDomain
                 _JVM_SetSockOpt
                 _JVM_SetThreadPriority
                 _JVM_Sleep
--- a/make/bsd/makefiles/mapfile-vers-product	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/bsd/makefiles/mapfile-vers-product	Wed Apr 16 14:02:52 2014 +0200
@@ -221,8 +221,6 @@
                 _JVM_SetLength
                 _JVM_SetNativeThreadName
                 _JVM_SetPrimitiveArrayElement
-                # Preserved so that Graal repo can link against a JDK7 libjava.so works
-                _JVM_SetProtectionDomain
                 _JVM_SetSockOpt
                 _JVM_SetThreadPriority
                 _JVM_Sleep
--- a/make/bsd/makefiles/vm.make	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/bsd/makefiles/vm.make	Wed Apr 16 14:02:52 2014 +0200
@@ -111,6 +111,10 @@
 CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
 endif
 
+ifeq ($(INCLUDE_GRAAL), true)
+  CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\""
+endif
+
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 CFLAGS += $(CFLAGS_WARN/BYFILE)
 
--- a/make/linux/makefiles/mapfile-vers-debug	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/linux/makefiles/mapfile-vers-debug	Wed Apr 16 14:02:52 2014 +0200
@@ -223,8 +223,6 @@
                 JVM_SetLength;
                 JVM_SetNativeThreadName;
                 JVM_SetPrimitiveArrayElement;
-                # Preserved so that Graal repo can link against a JDK7 libjava.so works
-                JVM_SetProtectionDomain;
                 JVM_SetSockOpt;
                 JVM_SetThreadPriority;
                 JVM_Sleep;
--- a/make/linux/makefiles/mapfile-vers-product	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/linux/makefiles/mapfile-vers-product	Wed Apr 16 14:02:52 2014 +0200
@@ -223,8 +223,6 @@
                 JVM_SetLength;
                 JVM_SetNativeThreadName;
                 JVM_SetPrimitiveArrayElement;
-                # Preserved so that Graal repo can link against a JDK7 libjava.so works
-                JVM_SetProtectionDomain;
                 JVM_SetSockOpt;
                 JVM_SetThreadPriority;
                 JVM_Sleep;
--- a/make/linux/makefiles/vm.make	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/linux/makefiles/vm.make	Wed Apr 16 14:02:52 2014 +0200
@@ -113,6 +113,10 @@
 CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64
 endif # ifneq ($(LP64), 1)
 
+ifeq ($(INCLUDE_GRAAL), true)
+  CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\""
+endif
+
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 CFLAGS += $(CFLAGS_WARN/BYFILE)
 
--- a/make/solaris/makefiles/mapfile-vers	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/solaris/makefiles/mapfile-vers	Wed Apr 16 14:02:52 2014 +0200
@@ -223,8 +223,6 @@
                 JVM_SetLength;
                 JVM_SetNativeThreadName;
                 JVM_SetPrimitiveArrayElement;
-                # Preserved so that Graal repo can link against a JDK7 libjava.so works
-                JVM_SetProtectionDomain;
                 JVM_SetSockOpt;
                 JVM_SetThreadPriority;
                 JVM_Sleep;
--- a/make/solaris/makefiles/vm.make	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/solaris/makefiles/vm.make	Wed Apr 16 14:02:52 2014 +0200
@@ -100,6 +100,10 @@
 CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64
 endif # ifneq ($(LP64), 1)
 
+ifeq ($(INCLUDE_GRAAL), true)
+  CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\""
+endif
+
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 CFLAGS += $(CFLAGS_WARN)
 
--- a/make/windows/makefiles/vm.make	Tue Apr 15 19:08:29 2014 +0200
+++ b/make/windows/makefiles/vm.make	Wed Apr 16 14:02:52 2014 +0200
@@ -71,6 +71,10 @@
 # Define that so jni.h is on correct side
 CXX_FLAGS=$(CXX_FLAGS) /D "_JNI_IMPLEMENTATION_"
 
+!if "$(INCLUDE_GRAAL)" == "true"
+  CXX_FLAGS=$(CXX_FLAGS) /D "GRAAL_VERSION=\"$(GRAAL_VERSION)\""
+!endif
+
 !if "$(BUILDARCH)" == "ia64"
 STACK_SIZE="/STACK:1048576,262144"
 !else
--- a/mx/eclipse-settings/org.eclipse.jdt.core.prefs	Tue Apr 15 19:08:29 2014 +0200
+++ b/mx/eclipse-settings/org.eclipse.jdt.core.prefs	Wed Apr 16 14:02:52 2014 +0200
@@ -87,7 +87,7 @@
 org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
 org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
 org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
 org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
@@ -100,7 +100,6 @@
 org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
 org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
 org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.tasks=ignore
 org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
 org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
 org.eclipse.jdt.core.compiler.problem.unclosedCloseable=ignore
--- a/mx/mx_graal.py	Tue Apr 15 19:08:29 2014 +0200
+++ b/mx/mx_graal.py	Wed Apr 16 14:02:52 2014 +0200
@@ -28,7 +28,7 @@
 
 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO
 from os.path import join, exists, dirname, basename, getmtime
-from argparse import ArgumentParser, REMAINDER
+from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER
 from outputparser import OutputParser, ValuesMatcher
 import mx
 import xml.dom.minidom
@@ -404,15 +404,6 @@
     graalJar = graalDist.path
     jdks = _jdksDir()
 
-    m2Install = mx.get_env('MAVEN_INSTALL_GRAAL_JAR', None)
-    if m2Install and m2Install.lower() == 'true':
-        cmd = ['mvn', 'install:install-file', '-q',
-               '-Dfile=' + graalJar, '-DgroupId=com.oracle.graal', '-DartifactId=graal',
-               '-Dversion=1.0-SNAPSHOT', '-Dpackaging=jar']
-        if graalDist.sourcesPath:
-            cmd = cmd + ['-Dsources=' + graalDist.sourcesPath]
-        mx.run(cmd)
-
     if exists(jdks):
         for e in os.listdir(jdks):
             jreLibDir = join(jdks, e, 'jre', 'lib')
@@ -663,18 +654,6 @@
             env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
             env.setdefault('ALT_BOOTDIR', mx.java().jdk)
 
-            # extract latest release tag for graal
-            try:
-                tags = [x.split(' ')[0] for x in subprocess.check_output(['hg', 'tags']).split('\n') if x.startswith("graal-")]
-            except:
-                # not a mercurial repository or hg commands are not available.
-                tags = None
-
-            if tags:
-                # extract the most recent tag
-                tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0]
-                env.setdefault('USER_RELEASE_SUFFIX', tag)
-
             if not mx._opts.verbose:
                 runCmd.append('MAKE_VERBOSE=')
             env['JAVA_HOME'] = jdk
@@ -682,6 +661,22 @@
                 env['INCLUDE_GRAAL'] = 'false'
                 env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()))
             else:
+                # extract latest release tag for graal
+                try:
+                    tags = [x.split(' ')[0] for x in subprocess.check_output(['hg', '-R', _graal_home, 'tags']).split('\n') if x.startswith("graal-")]
+                except:
+                    # not a mercurial repository or hg commands are not available.
+                    tags = None
+
+                if tags:
+                    # extract the most recent tag
+                    tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0]
+                    env.setdefault('USER_RELEASE_SUFFIX', tag)
+                    env.setdefault('GRAAL_VERSION', tag[len("graal-"):])
+                else:
+                    version = 'unknown-{}-{}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
+                    env.setdefault('USER_RELEASE_SUFFIX', 'graal-' + version)
+                    env.setdefault('GRAAL_VERSION', version)
                 env['INCLUDE_GRAAL'] = 'true'
             env.setdefault('INSTALL', 'y')
             if mx.get_os() == 'solaris':
@@ -833,7 +828,7 @@
     else:
         return [], args
 
-def _run_tests(args, harness, annotations, testfile):
+def _run_tests(args, harness, annotations, testfile, whitelist):
 
 
     vmArgs, tests = _extract_VM_args(args)
@@ -865,6 +860,9 @@
                 mx.log('warning: no tests matched by substring "' + t)
         projectscp = mx.classpath(projs)
 
+    if whitelist:
+        classes = list(set(classes) & set(whitelist))
+
     if len(classes) != 0:
         f_testfile = open(testfile, 'w')
         for c in classes:
@@ -872,7 +870,7 @@
         f_testfile.close()
         harness(projectscp, vmArgs)
 
-def _unittest(args, annotations, prefixcp=""):
+def _unittest(args, annotations, prefixcp="", whitelist=None):
     mxdir = dirname(__file__)
     name = 'JUnitWrapper'
     javaSource = join(mxdir, name + '.java')
@@ -899,12 +897,20 @@
             vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp + os.pathsep + mxdir, name] + [testfile])
 
     try:
-        _run_tests(args, harness, annotations, testfile)
+        _run_tests(args, harness, annotations, testfile, whitelist)
     finally:
         if os.environ.get('MX_TESTFILE') is None:
             os.remove(testfile)
 
 _unittestHelpSuffix = """
+    Unittest options:
+
+      --short-only           run short testcases only
+      --long-only            run long testcases only
+      --baseline-whitelist   run only testcases which are known to
+                             work with the baseline compiler
+
+    To avoid conflicts with VM options '--' can be used as delimiter.
 
     If filters are supplied, only tests whose fully qualified name
     includes a filter as a substring are run.
@@ -933,17 +939,64 @@
 def unittest(args):
     """run the JUnit tests (all testcases){0}"""
 
-    _unittest(args, ['@Test', '@LongTest', '@Parameters'])
+    parser = ArgumentParser(prog='mx unittest',
+          description='run the JUnit tests',
+          add_help=False,
+          formatter_class=RawDescriptionHelpFormatter,
+          epilog=_unittestHelpSuffix,
+        )
+    group = parser.add_mutually_exclusive_group()
+    group.add_argument('--short-only', action='store_true', help='run short testcases only')
+    group.add_argument('--long-only', action='store_true', help='run long testcases only')
+    parser.add_argument('--baseline-whitelist', action='store_true', help='run baseline testcases only')
+
+    ut_args = []
+    delimiter = False
+    # check for delimiter
+    while len(args) > 0:
+        arg = args.pop(0)
+        if arg == '--':
+            delimiter = True
+            break
+        ut_args.append(arg)
+
+    if delimiter:
+        # all arguments before '--' must be recognized
+        parsed_args = parser.parse_args(ut_args)
+    else:
+        # parse all know arguments
+        parsed_args, remaining_args = parser.parse_known_args(ut_args)
+        args = remaining_args + args
+
+    whitelist = None
+    if parsed_args.baseline_whitelist:
+        baseline_whitelist_file = 'test/baseline_whitelist.txt'
+        try:
+            with open(join(_graal_home, baseline_whitelist_file)) as fp:
+                whitelist = [l.rstrip() for l in fp.readlines()]
+        except IOError:
+            mx.log('warning: could not read baseline whitelist: ' + baseline_whitelist_file)
+
+    if parsed_args.long_only:
+        annotations = ['@LongTest', '@Parameters']
+    elif parsed_args.short_only:
+        annotations = ['@Test']
+    else:
+        annotations = ['@Test', '@LongTest', '@Parameters']
+
+    _unittest(args, annotations, whitelist=whitelist)
 
 def shortunittest(args):
-    """run the JUnit tests (short testcases only){0}"""
+    """alias for 'unittest --short-only'{0}"""
 
-    _unittest(args, ['@Test'])
+    args.insert(0, '--short-only')
+    unittest(args)
 
 def longunittest(args):
-    """run the JUnit tests (long testcases only){0}"""
+    """alias for 'unittest --long-only'{0}"""
 
-    _unittest(args, ['@LongTest', '@Parameters'])
+    args.insert(0, '--long-only')
+    unittest(args)
 
 def buildvms(args):
     """build one or more VMs in various configurations"""
@@ -1354,17 +1407,38 @@
     """run the JMH_BENCHMARKS"""
 
     # TODO: add option for `mvn clean package'
-    # TODO: add options to pass through arguments directly to JMH
+
+    vmArgs, benchmarksAndJsons = _extract_VM_args(args)
+
+    benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')]
+    jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')]
+
+    jmhArgs = {'-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'}
 
-    vmArgs, benchmarks = _extract_VM_args(args)
+    # e.g. '{"-wi" : 20}'
+    for j in jmhArgJsons:
+        try:
+            for n, v in json.loads(j).iteritems():
+                if v is None:
+                    del jmhArgs[n]
+                else:
+                    jmhArgs[n] = v
+        except ValueError as e:
+            mx.abort('error parsing JSON input: {}"\n{}'.format(j, e))
+
     jmhPath = mx.get_env('JMH_BENCHMARKS', None)
     if not jmhPath or not exists(jmhPath):
         mx.abort("$JMH_BENCHMARKS not properly defined: " + str(jmhPath))
 
     def _blackhole(x):
         mx.logv(x[:-1])
+
+
+    env = os.environ.copy()
+    env['JAVA_HOME'] = _jdk(vmToCheck='graal')
+    env['MAVEN_OPTS'] = '-graal'
     mx.log("Building benchmarks...")
-    mx.run(['mvn', 'package'], cwd=jmhPath, out=_blackhole)
+    mx.run(['mvn', 'package'], cwd=jmhPath, out=_blackhole, env=env)
 
     matchedSuites = set()
     numBench = [0]
@@ -1410,15 +1484,14 @@
         (pfx, exe, vm, forkedVmArgs, _) = _parseVmArgs(vmArgs)
         if pfx:
             mx.warn("JMH ignores prefix: \"" + pfx + "\"")
-        mx.run_java(
-           ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"),
-            "-f", "1",
-            "-v", "EXTRA" if mx._opts.verbose else "NORMAL",
-            "-i", "10", "-wi", "10",
-            "--jvm", exe,
-            "--jvmArgs", " ".join(["-" + vm] + forkedVmArgs)] + regex,
-            addDefaultArgs=False,
-            cwd=jmhPath)
+        javaArgs = ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"),
+                    '--jvm', exe,
+                    '--jvmArgs', ' '.join(["-" + vm] + forkedVmArgs)]
+        for k, v in jmhArgs.iteritems():
+            javaArgs.append(k)
+            if len(str(v)):
+                javaArgs.append(str(v))
+        mx.run_java(javaArgs + regex, addDefaultArgs=False, cwd=jmhPath)
 
 
 def specjvm2008(args):
@@ -1761,7 +1834,7 @@
         'hcfdis': [hcfdis, ''],
         'igv' : [igv, ''],
         'jdkhome': [print_jdkhome, ''],
-        'jmh': [jmh, '[VM options] [filters...]'],
+        'jmh': [jmh, '[VM options] [filters|JMH-args-as-json...]'],
         'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'],
         'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'],
         'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'],
@@ -1769,9 +1842,9 @@
         'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
         'gate' : [gate, '[-options]'],
         'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
-        'unittest' : [unittest, '[VM options] [filters...]', _unittestHelpSuffix],
-        'longunittest' : [longunittest, '[VM options] [filters...]', _unittestHelpSuffix],
-        'shortunittest' : [shortunittest, '[VM options] [filters...]', _unittestHelpSuffix],
+        'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
+        'longunittest' : [longunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
+        'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
         'jacocoreport' : [jacocoreport, '[output directory]'],
         'site' : [site, '[-options]'],
         'vm': [vm, '[-options] class [args...]'],
--- a/mx/projects	Tue Apr 15 19:08:29 2014 +0200
+++ b/mx/projects	Wed Apr 16 14:02:52 2014 +0200
@@ -45,6 +45,9 @@
 library@JAVA_ALLOCATION_INSTRUMENTER@urls=http://lafo.ssw.uni-linz.ac.at/java-allocation-instrumenter/java-allocation-instrumenter-8f0db117e64e.jar
 library@JAVA_ALLOCATION_INSTRUMENTER@sha1=64c0a5329fbcb8284640e58d83252e0a3b08c23e
 
+library@VECMATH@path=lib/vecmath-1.3.1.jar
+library@VECMATH@urls=http://mirrors.ibiblio.org/pub/mirrors/maven/java3d/jars/vecmath-1.3.1.jar
+
 distribution@GRAAL@path=graal.jar
 distribution@GRAAL@sourcesPath=graal.src.zip
 distribution@GRAAL@dependencies=\
@@ -611,7 +614,7 @@
 # graal.compiler.hsail.test
 project@com.oracle.graal.compiler.hsail.test@subDir=graal
 project@com.oracle.graal.compiler.hsail.test@sourceDirs=src
-project@com.oracle.graal.compiler.hsail.test@dependencies=com.oracle.graal.compiler.hsail.test.infra,com.oracle.graal.compiler.test
+project@com.oracle.graal.compiler.hsail.test@dependencies=com.oracle.graal.compiler.hsail.test.infra,com.oracle.graal.compiler.test,VECMATH
 project@com.oracle.graal.compiler.hsail.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.compiler.hsail.test@javaCompliance=1.8
 
--- a/mxtool/.pylintrc	Tue Apr 15 19:08:29 2014 +0200
+++ b/mxtool/.pylintrc	Wed Apr 16 14:02:52 2014 +0200
@@ -44,7 +44,7 @@
         too-many-lines,missing-docstring,no-init,no-self-use,too-many-statements,
         too-many-locals,too-few-public-methods,too-many-instance-attributes,
         too-many-arguments,too-many-branches,too-many-public-methods,
-        abstract-method,F0401
+        multiple-statements,abstract-method,F0401
 
 # F0401: http://www.logilab.org/ticket/9386
 
--- a/mxtool/mx.py	Tue Apr 15 19:08:29 2014 +0200
+++ b/mxtool/mx.py	Wed Apr 16 14:02:52 2014 +0200
@@ -36,6 +36,7 @@
 import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch
 import textwrap
 import socket
+import tarfile
 import hashlib
 import xml.parsers.expat
 import shutil, re, xml.dom.minidom
@@ -65,9 +66,8 @@
         self.suite = suite
         self.name = name
         self.path = path.replace('/', os.sep)
-        self.sourcesPath = sourcesPath.replace('/', os.sep) if sourcesPath else None
-        if not isabs(self.path):
-            self.path = join(suite.dir, self.path)
+        self.path = _make_absolute(self.path, suite.dir)
+        self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None
         self.deps = deps
         self.update_listeners = set()
         self.excludedLibs = excludedLibs
@@ -359,6 +359,14 @@
                     print >> fp, ap
         return outOfDate
 
+def _make_absolute(path, prefix):
+    """
+    Makes 'path' absolute if it isn't already by prefixing 'prefix'
+    """
+    if not isabs(path):
+        return join(prefix, path)
+    return path
+
 def _download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False):
     def _download_lib():
         print 'Downloading ' + ("Sources " if sources else "") + name + ' from ' + str(urls)
@@ -429,9 +437,7 @@
 
 
     def get_path(self, resolve):
-        path = self.path
-        if not isabs(path):
-            path = join(self.suite.dir, path)
+        path = _make_absolute(self.path, self.suite.dir)
         sha1path = path + '.sha1'
 
         includedInJDK = getattr(self, 'includedInJDK', None)
@@ -442,11 +448,9 @@
 
 
     def get_source_path(self, resolve):
-        path = self.sourcePath
-        if path is None:
+        if self.path is None:
             return None
-        if not isabs(path):
-            path = join(self.suite.dir, path)
+        path = _make_absolute(self.path, self.suite.dir)
         sha1path = path + '.sha1'
 
         return _download_file_with_sha1(self.name, path, self.sourceUrls, self.sourceSha1, sha1path, resolve, len(self.sourceUrls) != 0, sources=True)
@@ -1690,6 +1694,7 @@
     parser.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not')
     parser.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler (default: ' + defaultEcjPath + ')', default=defaultEcjPath, metavar='<path>')
     parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors')
+    parser.add_argument('--jdt-show-task-tags', action='store_true', help='show task tags as Eclipse batch compiler warnings')
     parser.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>')
 
     if suppliedParser:
@@ -1915,11 +1920,15 @@
                 if not exists(jdtProperties):
                     log('JDT properties file {0} not found'.format(jdtProperties))
                 else:
-                    # convert all warnings to errors
-                    if args.jdt_warning_as_error:
+                    with open(jdtProperties) as fp:
+                        origContent = fp.read()
+                        content = origContent
+                        if args.jdt_warning_as_error:
+                            content = content.replace('=warning', '=error')
+                        if not args.jdt_show_task_tags:
+                            content = content + '\norg.eclipse.jdt.core.compiler.problem.tasks=ignore'
+                    if origContent != content:
                         jdtPropertiesTmp = jdtProperties + '.tmp'
-                        with open(jdtProperties) as fp:
-                            content = fp.read().replace('=warning', '=error')
                         with open(jdtPropertiesTmp, 'w') as fp:
                             fp.write(content)
                         toBeDeleted.append(jdtPropertiesTmp)
@@ -2168,25 +2177,43 @@
     parser.add_argument('names', nargs=REMAINDER, metavar='[<project>|@<distribution>]...')
     args = parser.parse_args(args)
 
+
+    class Archive:
+        def __init__(self, path):
+            self.path = path
+
+        def __enter__(self):
+            if self.path:
+                fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(self.path) + '.', dir=dirname(self.path))
+                self.tmpFd = fd
+                self.tmpPath = tmp
+                self.zf = zipfile.ZipFile(tmp, 'w')
+            else:
+                self.tmpFd = None
+                self.tmpPath = None
+                self.zf = None
+            return self
+
+        def __exit__(self, exc_type, exc_value, traceback):
+            if self.zf:
+                self.zf.close()
+                os.close(self.tmpFd)
+                # Correct the permissions on the temporary file which is created with restrictive permissions
+                os.chmod(self.tmpPath, 0o666 & ~currentUmask)
+                # Atomic on Unix
+                shutil.move(self.tmpPath, self.path)
+
     archives = []
     for name in args.names:
         if name.startswith('@'):
             dname = name[1:]
             d = distribution(dname)
-            fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
-            if d.sourcesPath:
-                sourcesFd, sourcesTmp = tempfile.mkstemp(suffix='', prefix=basename(d.sourcesPath) + '.', dir=dirname(d.sourcesPath))
-            else:
-                sourcesTmp = None
-            services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path))
-
-            def overwriteCheck(zf, arcname, source):
-                if arcname in zf.namelist():
-                    log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']')
-
-            try:
-                zf = zipfile.ZipFile(tmp, 'w')
-                szf = zipfile.ZipFile(sourcesTmp, 'w') if sourcesTmp else None
+            with Archive(d.path) as arc, Archive(d.sourcesPath) as srcArc:
+                services = {}
+                def overwriteCheck(zf, arcname, source):
+                    if arcname in zf.namelist():
+                        log('warning: ' + d.path + ': overwriting ' + arcname + ' [source: ' + source + ']')
+
                 for dep in d.sorted_deps(includeLibs=True):
                     if dep.isLibrary():
                         l = dep
@@ -2198,18 +2225,17 @@
                             with zipfile.ZipFile(lpath, 'r') as lp:
                                 for arcname in lp.namelist():
                                     if arcname.startswith('META-INF/services/') and not arcname == 'META-INF/services/':
-                                        f = arcname[len('META-INF/services/'):].replace('/', os.sep)
-                                        with open(join(services, f), 'a') as outfile:
-                                            for line in lp.read(arcname).splitlines():
-                                                outfile.write(line)
+                                        service = arcname[len('META-INF/services/'):]
+                                        assert '/' not in service
+                                        services.setdefault(service, []).extend(lp.read(arcname).splitlines())
                                     else:
-                                        overwriteCheck(zf, arcname, lpath + '!' + arcname)
-                                        zf.writestr(arcname, lp.read(arcname))
-                        if szf and libSourcePath:
+                                        overwriteCheck(arc.zf, arcname, lpath + '!' + arcname)
+                                        arc.zf.writestr(arcname, lp.read(arcname))
+                        if srcArc.zf and libSourcePath:
                             with zipfile.ZipFile(libSourcePath, 'r') as lp:
                                 for arcname in lp.namelist():
-                                    overwriteCheck(szf, arcname, lpath + '!' + arcname)
-                                    szf.writestr(arcname, lp.read(arcname))
+                                    overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname)
+                                    srcArc.zf.writestr(arcname, lp.read(arcname))
                     else:
                         p = dep
                         # skip a  Java project if its Java compliance level is "higher" than the configured JDK
@@ -2223,79 +2249,47 @@
                         for root, _, files in os.walk(outputDir):
                             relpath = root[len(outputDir) + 1:]
                             if relpath == join('META-INF', 'services'):
-                                for f in files:
-                                    with open(join(services, f), 'a') as outfile:
-                                        with open(join(root, f), 'r') as infile:
-                                            for line in infile:
-                                                outfile.write(line)
+                                for service in files:
+                                    with open(join(root, service), 'r') as fp:
+                                        services.setdefault(service, []).extend([provider.strip() for provider in fp.readlines()])
                             elif relpath == join('META-INF', 'providers'):
-                                for f in files:
-                                    with open(join(root, f), 'r') as infile:
-                                        for line in infile:
-                                            with open(join(services, line.strip()), 'a') as outfile:
-                                                outfile.write(f + '\n')
+                                for provider in files:
+                                    with open(join(root, provider), 'r') as fp:
+                                        for service in fp:
+                                            services.setdefault(service.strip(), []).append(provider)
                             else:
                                 for f in files:
                                     arcname = join(relpath, f).replace(os.sep, '/')
-                                    overwriteCheck(zf, arcname, join(root, f))
-                                    zf.write(join(root, f), arcname)
-                        if szf:
+                                    overwriteCheck(arc.zf, arcname, join(root, f))
+                                    arc.zf.write(join(root, f), arcname)
+                        if srcArc.zf:
                             for srcDir in p.source_dirs():
                                 for root, _, files in os.walk(srcDir):
                                     relpath = root[len(srcDir) + 1:]
                                     for f in files:
                                         if f.endswith('.java'):
                                             arcname = join(relpath, f).replace(os.sep, '/')
-                                            overwriteCheck(szf, arcname, join(root, f))
-                                            szf.write(join(root, f), arcname)
-
-                for f in os.listdir(services):
-                    arcname = join('META-INF', 'services', f).replace(os.sep, '/')
-                    zf.write(join(services, f), arcname)
-                zf.close()
-                os.close(fd)
-                shutil.rmtree(services)
-                # Atomic on Unix
-                shutil.move(tmp, d.path)
-                # Correct the permissions on the temporary file which is created with restrictive permissions
-                os.chmod(d.path, 0o666 & ~currentUmask)
-                archives.append(d.path)
-
-                if szf:
-                    szf.close()
-                    os.close(sourcesFd)
-                    shutil.move(sourcesTmp, d.sourcesPath)
-                    os.chmod(d.sourcesPath, 0o666 & ~currentUmask)
-
-                d.notify_updated()
-            finally:
-                if exists(tmp):
-                    os.remove(tmp)
-                if exists(services):
-                    shutil.rmtree(services)
+                                            overwriteCheck(srcArc.zf, arcname, join(root, f))
+                                            srcArc.zf.write(join(root, f), arcname)
+
+                for service, providers in services.iteritems():
+                    arcname = 'META-INF/services/' + service
+                    arc.zf.writestr(arcname, '\n'.join(providers))
+
+            d.notify_updated()
+            archives.append(d.path)
 
         else:
             p = project(name)
             outputDir = p.output_dir()
-            fd, tmp = tempfile.mkstemp(suffix='', prefix=p.name, dir=p.dir)
-            try:
-                zf = zipfile.ZipFile(tmp, 'w')
+            with Archive(join(p.dir, p.name + '.jar')) as arc:
                 for root, _, files in os.walk(outputDir):
                     for f in files:
                         relpath = root[len(outputDir) + 1:]
                         arcname = join(relpath, f).replace(os.sep, '/')
-                        zf.write(join(root, f), arcname)
-                zf.close()
-                os.close(fd)
-                # Atomic on Unix
-                jarFile = join(p.dir, p.name + '.jar')
-                shutil.move(tmp, jarFile)
-                # Correct the permissions on the temporary file which is created with restrictive permissions
-                os.chmod(jarFile, 0o666 & ~currentUmask)
-                archives.append(jarFile)
-            finally:
-                if exists(tmp):
-                    os.remove(tmp)
+                        arc.zf.write(join(root, f), arcname)
+                archives.append(arc.path)
+
     return archives
 
 def canonicalizeprojects(args):
@@ -2880,11 +2874,10 @@
                     if not path or (not exists(path) and not dep.mustExist):
                         continue
 
-                    if not isabs(path):
-                        # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
-                        # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
-                        # safest to simply use absolute paths.
-                        path = join(p.suite.dir, path)
+                    # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
+                    # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
+                    # safest to simply use absolute paths.
+                    path = _make_absolute(path, p.suite.dir)
 
                     attributes = {'exported' : 'true', 'kind' : 'lib', 'path' : path}
 
@@ -3039,11 +3032,10 @@
                             if dep.mustExist:
                                 path = dep.get_path(resolve=True)
                                 if path:
-                                    if not isabs(path):
-                                        # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
-                                        # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
-                                        # safest to simply use absolute paths.
-                                        path = join(p.suite.dir, path)
+                                    # Relative paths for "lib" class path entries have various semantics depending on the Eclipse
+                                    # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's
+                                    # safest to simply use absolute paths.
+                                    path = _make_absolute(path, p.suite.dir)
                                     out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'})
                                     files.append(path)
                     else:
@@ -3568,6 +3560,193 @@
     _zip_files(files, suite.dir, configZip.path)
     _zip_files(libFiles, suite.dir, configLibsZip)
 
+def intellijinit(args, refreshOnly=False):
+    """(re)generate Intellij project configurations"""
+
+    for suite in suites(True):
+        _intellij_suite(args, suite, refreshOnly)
+
+def _intellij_suite(args, suite, refreshOnly=False):
+
+    libraries = set()
+
+    ideaProjectDirectory = join(suite.dir, '.idea')
+
+    if not exists(ideaProjectDirectory):
+        os.mkdir(ideaProjectDirectory)
+    nameFile = join(ideaProjectDirectory, '.name')
+    update_file(nameFile, "Graal")
+    modulesXml = XMLDoc()
+    modulesXml.open('project', attributes={'version': '4'})
+    modulesXml.open('component', attributes={'name': 'ProjectModuleManager'})
+    modulesXml.open('modules')
+
+
+    def _intellij_exclude_if_exists(xml, p, name):
+        path = join(p.dir, name)
+        if exists(path):
+            xml.element('excludeFolder', attributes={'url':'file://$MODULE_DIR$/' + name})
+
+    annotationProcessorProfiles = {}
+
+    def _complianceToIntellijLanguageLevel(compliance):
+        return 'JDK_1_' + str(compliance.value)
+
+    # create the modules (1 module  = 1 Intellij project)
+    for p in suite.projects:
+        if p.native:
+            continue
+
+        if not java(p.javaCompliance):
+            log('Excluding {0} (JDK with compliance level {1} not available)'.format(p.name, p.javaCompliance))
+            continue
+
+        if not exists(p.dir):
+            os.makedirs(p.dir)
+
+        annotationProcessorProfileKey = tuple(p.annotation_processors())
+
+        if not annotationProcessorProfileKey in annotationProcessorProfiles:
+            annotationProcessorProfiles[annotationProcessorProfileKey] = [p]
+        else:
+            annotationProcessorProfiles[annotationProcessorProfileKey].append(p)
+
+        intellijLanguageLevel = _complianceToIntellijLanguageLevel(p.javaCompliance)
+
+        moduleXml = XMLDoc()
+        moduleXml.open('module', attributes={'type': 'JAVA_MODULE', 'version': '4'})
+
+        moduleXml.open('component', attributes={'name': 'NewModuleRootManager', 'LANGUAGE_LEVEL': intellijLanguageLevel, 'inherit-compiler-output': 'false'})
+        moduleXml.element('output', attributes={'url': 'file://$MODULE_DIR$/bin'})
+        moduleXml.element('exclude-output')
+
+        moduleXml.open('content', attributes={'url': 'file://$MODULE_DIR$'})
+        for src in p.srcDirs:
+            srcDir = join(p.dir, src)
+            if not exists(srcDir):
+                os.mkdir(srcDir)
+            moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + src, 'isTestSource': 'false'})
+
+        if len(p.annotation_processors()) > 0:
+            genDir = p.source_gen_dir()
+            if not exists(genDir):
+                os.mkdir(genDir)
+            moduleXml.element('sourceFolder', attributes={'url':'file://$MODULE_DIR$/' + os.path.relpath(genDir, p.dir), 'isTestSource': 'false'})
+
+        for name in ['.externalToolBuilders', '.settings', 'nbproject']:
+            _intellij_exclude_if_exists(moduleXml, p, name)
+        moduleXml.close('content')
+
+        moduleXml.element('orderEntry', attributes={'type': 'jdk', 'jdkType': 'JavaSDK', 'jdkName': str(p.javaCompliance)})
+        moduleXml.element('orderEntry', attributes={'type': 'sourceFolder', 'forTests': 'false'})
+
+        deps = p.all_deps([], True, includeAnnotationProcessors=True)
+        for dep in deps:
+            if dep == p:
+                continue
+
+            if dep.isLibrary():
+                if dep.mustExist:
+                    libraries.add(dep)
+                    moduleXml.element('orderEntry', attributes={'type': 'library', 'name': dep.name, 'level': 'project'})
+            else:
+                moduleXml.element('orderEntry', attributes={'type': 'module', 'module-name': dep.name})
+
+        moduleXml.close('component')
+        moduleXml.close('module')
+        moduleFile = join(p.dir, p.name + '.iml')
+        update_file(moduleFile, moduleXml.xml(indent='  ', newl='\n'))
+
+        moduleFilePath = "$PROJECT_DIR$/" + os.path.relpath(moduleFile, suite.dir)
+        modulesXml.element('module', attributes={'fileurl': 'file://' + moduleFilePath, 'filepath': moduleFilePath})
+
+    modulesXml.close('modules')
+    modulesXml.close('component')
+    modulesXml.close('project')
+    moduleXmlFile = join(ideaProjectDirectory, 'modules.xml')
+    update_file(moduleXmlFile, modulesXml.xml(indent='  ', newl='\n'))
+
+    # TODO What about cross-suite dependencies?
+
+    librariesDirectory = join(ideaProjectDirectory, 'libraries')
+
+    if not exists(librariesDirectory):
+        os.mkdir(librariesDirectory)
+
+    # Setup the libraries that were used above
+    # TODO: setup all the libraries from the suite regardless of usage?
+    for library in libraries:
+        libraryXml = XMLDoc()
+
+        libraryXml.open('component', attributes={'name': 'libraryTable'})
+        libraryXml.open('library', attributes={'name': library.name})
+        libraryXml.open('CLASSES')
+        libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.path, suite.dir) + '!/'})
+        libraryXml.close('CLASSES')
+        libraryXml.element('JAVADOC')
+        if library.sourcePath:
+            libraryXml.open('SOURCES')
+            libraryXml.element('root', attributes={'url': 'jar://$PROJECT_DIR$/' + os.path.relpath(library.sourcePath, suite.dir) + '!/'})
+            libraryXml.close('SOURCES')
+        else:
+            libraryXml.element('SOURCES')
+        libraryXml.close('library')
+        libraryXml.close('component')
+
+        libraryFile = join(librariesDirectory, library.name + '.xml')
+        update_file(libraryFile, libraryXml.xml(indent='  ', newl='\n'))
+
+
+
+    # Set annotation processor profiles up, and link them to modules in compiler.xml
+    compilerXml = XMLDoc()
+    compilerXml.open('project', attributes={'version': '4'})
+    compilerXml.open('component', attributes={'name': 'CompilerConfiguration'})
+
+    compilerXml.element('option', attributes={'name': "DEFAULT_COMPILER", 'value': 'Javac'})
+    compilerXml.element('resourceExtensions')
+    compilerXml.open('wildcardResourcePatterns')
+    compilerXml.element('entry', attributes={'name': '!?*.java'})
+    compilerXml.close('wildcardResourcePatterns')
+
+    if annotationProcessorProfiles:
+        compilerXml.open('annotationProcessing')
+        for processors, modules in annotationProcessorProfiles.items():
+            compilerXml.open('profile', attributes={'default': 'false', 'name': '-'.join(processors), 'enabled': 'true'})
+            compilerXml.element('sourceOutputDir', attributes={'name': 'src_gen'})  # TODO use p.source_gen_dir() ?
+            compilerXml.element('outputRelativeToContentRoot', attributes={'value': 'true'})
+            compilerXml.open('processorPath', attributes={'useClasspath': 'false'})
+            for apName in processors:
+                pDep = dependency(apName)
+                for entry in pDep.all_deps([], True):
+                    if entry.isLibrary():
+                        compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.path, suite.dir)})
+                    else:
+                        assert entry.isProject()
+                        compilerXml.element('entry', attributes={'name': '$PROJECT_DIR$/' + os.path.relpath(entry.output_dir(), suite.dir)})
+            compilerXml.close('processorPath')
+            for module in modules:
+                compilerXml.element('module', attributes={'name': module.name})
+            compilerXml.close('profile')
+        compilerXml.close('annotationProcessing')
+
+    compilerXml.close('component')
+    compilerXml.close('project')
+    compilerFile = join(ideaProjectDirectory, 'compiler.xml')
+    update_file(compilerFile, compilerXml.xml(indent='  ', newl='\n'))
+
+    # Wite misc.xml for global JDK config
+    miscXml = XMLDoc()
+    miscXml.open('project', attributes={'version': '4'})
+    miscXml.element('component', attributes={'name': 'ProjectRootManager', 'version': '2', 'languagelevel': _complianceToIntellijLanguageLevel(java().javaCompliance), 'project-jdk-name': str(java().javaCompliance), 'project-jdk-type': 'JavaSDK'})
+    miscXml.close('project')
+    miscFile = join(ideaProjectDirectory, 'misc.xml')
+    update_file(miscFile, miscXml.xml(indent='  ', newl='\n'))
+
+
+    # TODO look into copyright settings
+    # TODO should add vcs.xml support
+
 def ideclean(args):
     """remove all Eclipse and NetBeans project configurations"""
     def rm(path):
@@ -3577,6 +3756,7 @@
     for s in suites():
         rm(join(s.mxDir, 'eclipse-config.zip'))
         rm(join(s.mxDir, 'netbeans-config.zip'))
+        shutil.rmtree(join(s.dir, '.idea'), ignore_errors=True)
 
     for p in projects():
         if p.native:
@@ -3589,6 +3769,7 @@
         rm(join(p.dir, '.checkstyle'))
         rm(join(p.dir, '.project'))
         rm(join(p.dir, '.factorypath'))
+        rm(join(p.dir, p.name + '.iml'))
         rm(join(p.dir, 'build.xml'))
         rm(join(p.dir, 'eclipse-build.xml'))
         try:
@@ -3601,6 +3782,7 @@
     """(re)generate Eclipse and NetBeans project configurations"""
     eclipseinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
     netbeansinit(args, refreshOnly=refreshOnly, buildProcessorJars=buildProcessorJars)
+    intellijinit(args, refreshOnly=refreshOnly)
     if not refreshOnly:
         fsckprojects([])
 
@@ -4094,6 +4276,75 @@
                 return items[indexes[0]]
             return None
 
+def exportlibs(args):
+    """export libraries to an archive file"""
+
+    parser = ArgumentParser(prog='exportlibs')
+    parser.add_argument('-b', '--base', action='store', help='base name of archive (default: libs)', default='libs', metavar='<path>')
+    parser.add_argument('--arc', action='store', choices=['tgz', 'tbz2', 'tar', 'zip'], default='tgz', help='the type of the archive to create')
+    parser.add_argument('--no-sha1', action='store_false', dest='sha1', help='do not create SHA1 signature of archive')
+    parser.add_argument('--no-md5', action='store_false', dest='md5', help='do not create MD5 signature of archive')
+    parser.add_argument('--include-system-libs', action='store_true', help='include system libraries (i.e., those not downloaded from URLs)')
+    parser.add_argument('extras', nargs=REMAINDER, help='extra files and directories to add to archive', metavar='files...')
+    args = parser.parse_args(args)
+
+    def createArchive(addMethod):
+        entries = {}
+        def add(path, arcname):
+            apath = os.path.abspath(path)
+            if not entries.has_key(arcname):
+                entries[arcname] = apath
+                logv('[adding ' + path + ']')
+                addMethod(path, arcname=arcname)
+            elif entries[arcname] != apath:
+                logv('[warning: ' + apath + ' collides with ' + entries[arcname] + ' as ' + arcname + ']')
+            else:
+                logv('[already added ' + path + ']')
+
+        for lib in _libs.itervalues():
+            if len(lib.urls) != 0 or args.include_system_libs:
+                add(lib.get_path(resolve=True), lib.path)
+        if args.extras:
+            for e in args.extras:
+                if os.path.isdir(e):
+                    for root, _, filenames in os.walk(e):
+                        for name in filenames:
+                            f = join(root, name)
+                            add(f, f)
+                else:
+                    add(e, e)
+
+    if args.arc == 'zip':
+        path = args.base + '.zip'
+        with zipfile.ZipFile(path, 'w') as zf:
+            createArchive(zf.write)
+    else:
+        path = args.base + '.tar'
+        mode = 'w'
+        if args.arc != 'tar':
+            sfx = args.arc[1:]
+            mode = mode + ':' + sfx
+            path = path + '.' + sfx
+        with tarfile.open(path, mode) as tar:
+            createArchive(tar.add)
+    log('created ' + path)
+
+    def digest(enabled, path, factory, suffix):
+        if enabled:
+            d = factory()
+            with open(path, 'rb') as f:
+                while True:
+                    buf = f.read(4096)
+                    if not buf:
+                        break
+                    d.update(buf)
+            with open(path + '.' + suffix, 'w') as fp:
+                print >> fp, d.hexdigest()
+            log('created ' + path + '.' + suffix)
+
+    digest(args.sha1, path, hashlib.sha1, 'sha1')
+    digest(args.md5, path, hashlib.md5, 'md5')
+
 def javap(args):
     """disassemble classes matching given pattern with javap"""
 
@@ -4162,11 +4413,13 @@
     'clean': [clean, ''],
     'eclipseinit': [eclipseinit, ''],
     'eclipseformat': [eclipseformat, ''],
+    'exportlibs': [exportlibs, ''],
     'findclass': [findclass, ''],
     'fsckprojects': [fsckprojects, ''],
     'help': [help_, '[command]'],
     'ideclean': [ideclean, ''],
     'ideinit': [ideinit, ''],
+    'intellijinit': [intellijinit, ''],
     'archive': [archive, '[options]'],
     'projectgraph': [projectgraph, ''],
     'pylint': [pylint, ''],
--- a/src/cpu/sparc/vm/compiledIC_sparc.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/compiledIC_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -81,25 +81,26 @@
 // ----------------------------------------------------------------------------
 
 #define __ _masm.
-void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
-#ifdef COMPILER2
+void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
   // Stub is fixed up when the corresponding call is converted from calling
   // compiled code to calling interpreted code.
   // set (empty), G5
   // jmp -1
 
-  address mark = cbuf.insts_mark();  // Get mark within main instrs section.
+  if (mark == NULL) {
+    mark = cbuf.insts_mark();  // Get mark within main instrs section.
+  }
 
   MacroAssembler _masm(&cbuf);
 
   address base =
-  __ start_a_stub(to_interp_stub_size()*2);
-  if (base == NULL) return;  // CodeBuffer::expand failed.
+  __ start_a_stub(to_interp_stub_size());
+  guarantee(base != NULL, "out of space");
 
   // Static stub relocation stores the instruction address of the call.
   __ relocate(static_stub_Relocation::spec(mark));
 
-  __ set_metadata(NULL, as_Register(Matcher::inline_cache_reg_encode()));
+  __ set_metadata(NULL, G5);
 
   __ set_inst_mark();
   AddressLiteral addrlit(-1);
@@ -107,11 +108,10 @@
 
   __ delayed()->nop();
 
+  assert(__ pc() - base <= to_interp_stub_size(), "wrong stub size"); 
+
   // Update current stubs pointer and restore code_end.
   __ end_a_stub();
-#else
-  ShouldNotReachHere();
-#endif
 }
 #undef __
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/sparc/vm/graalCodeInstaller_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013, 2014, 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.
+ */
+
+#include "graal/graalCodeInstaller.hpp"
+#include "graal/graalCompiler.hpp"
+#include "graal/graalCompilerToVM.hpp"
+#include "graal/graalJavaAccess.hpp"
+
+jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
+  if (inst->is_call() || inst->is_jump()) {
+    return pc_offset + NativeCall::instruction_size;
+  } else if (inst->is_call_reg()) {
+    return pc_offset + NativeCallReg::instruction_size;
+  } else if (inst->is_sethi()) {
+    return pc_offset + NativeFarCall::instruction_size;
+  } else {
+    fatal("unsupported type of instruction for call site");
+    return 0;
+  }
+}
+
+void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) {
+  address pc = _instructions->start() + pc_offset;
+  Handle obj = OopData::object(data);
+  jobject value = JNIHandles::make_local(obj());
+  if (OopData::compressed(data)) {
+    fatal("unimplemented: narrow oop relocation");
+  } else {
+    NativeMovConstReg* move = nativeMovConstReg_at(pc);
+    move->set_data((intptr_t) value);
+
+    // We need two relocations:  one on the sethi and one on the add.
+    int oop_index = _oop_recorder->find_index(value);
+    RelocationHolder rspec = oop_Relocation::spec(oop_index);
+    _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
+    _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
+  }
+}
+
+void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) {
+  address pc = _instructions->start() + pc_offset;
+  jint offset = DataSectionReference::offset(data);
+
+  NativeMovRegMem* load = nativeMovRegMem_at(pc);
+  int disp = _constants_size + pc_offset - offset - BytesPerInstWord;
+  load->set_offset(-disp);
+}
+
+void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
+  fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");
+}
+
+void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
+  address pc = (address) inst;
+  if (inst->is_call()) {
+    NativeCall* call = nativeCall_at(pc);
+    call->set_destination((address) foreign_call_destination);
+    _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
+  } else if (inst->is_sethi()) {
+    NativeJump* jump = nativeJump_at(pc);
+    jump->set_jump_destination((address) foreign_call_destination);
+    _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
+  } else {
+    fatal(err_msg("unknown call or jump instruction at %p", pc));
+  }
+  TRACE_graal_3("relocating (foreign call) at %p", inst);
+}
+
+void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
+#ifdef ASSERT
+  Method* method = NULL;
+  // we need to check, this might also be an unresolved method
+  if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) {
+    method = getMethodFromHotSpotMethod(hotspot_method);
+  }
+#endif
+  switch (_next_call_type) {
+    case INLINE_INVOKE:
+      break;
+    case INVOKEVIRTUAL:
+    case INVOKEINTERFACE: {
+      assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
+      _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
+      break;
+    }
+    case INVOKESTATIC: {
+      assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_static_call_stub());
+      _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
+      break;
+    }
+    case INVOKESPECIAL: {
+      assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
+      _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
+      break;
+    }
+    default:
+      fatal("invalid _next_call_type value");
+      break;
+  }
+}
+
+void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
+  switch (mark) {
+    case POLL_NEAR:
+      fatal("unimplemented");
+      break;
+    case POLL_FAR:
+      _instructions->relocate(pc, relocInfo::poll_type);
+      break;
+    case POLL_RETURN_NEAR:
+      fatal("unimplemented");
+      break;
+    case POLL_RETURN_FAR:
+      _instructions->relocate(pc, relocInfo::poll_return_type);
+      break;
+    default:
+      fatal("invalid mark value");
+      break;
+  }
+}
--- a/src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +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.
- */
-
-#ifndef CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP
-#define CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP
-
-#include "graal/graalCompiler.hpp"
-#include "graal/graalCompilerToVM.hpp"
-#include "graal/graalJavaAccess.hpp"
-
-inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
-  if (inst->is_call() || inst->is_jump()) {
-    return pc_offset + NativeCall::instruction_size;
-  } else if (inst->is_call_reg()) {
-    return pc_offset + NativeCallReg::instruction_size;
-  } else if (inst->is_sethi()) {
-    return pc_offset + NativeFarCall::instruction_size;
-  } else {
-    fatal("unsupported type of instruction for call site");
-    return 0;
-  }
-}
-
-inline void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) {
-  if (OopData::compressed(obj)) {
-    fatal("unimplemented: narrow oop relocation");
-  } else {
-    address pc = _instructions->start() + pc_offset;
-    Handle obj = OopData::object(data);
-    jobject value = JNIHandles::make_local(obj());
-
-    NativeMovConstReg* move = nativeMovConstReg_at(pc);
-    move->set_data((intptr_t) value);
-
-    // We need two relocations:  one on the sethi and one on the add.
-    int oop_index = _oop_recorder->find_index(value);
-    RelocationHolder rspec = oop_Relocation::spec(oop_index);
-    _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
-    _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
-  }
-}
-
-inline void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) {
-  address pc = _instructions->start() + pc_offset;
-  jint offset = DataSectionReference::offset(data);
-
-  NativeMovRegMem* load = nativeMovRegMem_at(pc);
-  int disp = _constants_size + pc_offset - offset - BytesPerInstWord;
-  load->set_offset(-disp);
-}
-
-inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
-  fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");
-}
-
-inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
-  address pc = (address) inst;
-  if (inst->is_call()) {
-    NativeCall* call = nativeCall_at(pc);
-    call->set_destination((address) foreign_call_destination);
-    _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec());
-  } else if (inst->is_sethi()) {
-    NativeJump* jump = nativeJump_at(pc);
-    jump->set_jump_destination((address) foreign_call_destination);
-    _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec());
-  } else {
-    fatal(err_msg("unknown call or jump instruction at %p", pc));
-  }
-  TRACE_graal_3("relocating (foreign call) at %p", inst);
-}
-
-inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
-#ifdef ASSERT
-  Method* method = NULL;
-  // we need to check, this might also be an unresolved method
-  if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) {
-    method = getMethodFromHotSpotMethod(hotspot_method);
-  }
-#endif
-  switch (_next_call_type) {
-    case INLINE_INVOKE:
-      break;
-    case INVOKEVIRTUAL:
-    case INVOKEINTERFACE: {
-      assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
-      _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
-      break;
-    }
-    case INVOKESTATIC: {
-      assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_static_call_stub());
-      _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
-      break;
-    }
-    case INVOKESPECIAL: {
-      assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
-      _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
-      break;
-    }
-    default:
-      fatal("invalid _next_call_type value");
-      break;
-  }
-}
-
-inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
-  switch (mark) {
-    case POLL_NEAR: {
-      fatal("unimplemented");
-    }
-    case POLL_FAR:
-      _instructions->relocate(pc, relocInfo::poll_type);
-      break;
-    case POLL_RETURN_NEAR: {
-      fatal("unimplemented");
-    }
-    case POLL_RETURN_FAR:
-      _instructions->relocate(pc, relocInfo::poll_return_type);
-      break;
-    default:
-      fatal("invalid mark value");
-      break;
-  }
-}
-
-#endif // CPU_SPARC_VM_CODEINSTALLER_SPARC_HPP
--- a/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/interpreterGenerator_sparc.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -33,9 +33,6 @@
 
   address generate_normal_entry(bool synchronized);
   address generate_native_entry(bool synchronized);
-#ifdef GRAAL
-  address generate_execute_compiled_method_entry();
-#endif
  address generate_abstract_entry(void);
   address generate_math_entry(AbstractInterpreter::MethodKind kind);
   address generate_empty_entry(void);
--- a/src/cpu/sparc/vm/interpreter_sparc.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/interpreter_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -381,9 +381,6 @@
     case Interpreter::zerolocals_synchronized: synchronized = true;                                                        break;
     case Interpreter::native                 : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false);  break;
     case Interpreter::native_synchronized    : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true);   break;
-#ifdef GRAAL
-    case Interpreter::execute_compiled_method: entry_point = ((InterpreterGenerator*)this)->generate_execute_compiled_method_entry();   break;
-#endif
     case Interpreter::empty                  : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry();        break;
     case Interpreter::accessor               : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry();     break;
     case Interpreter::abstract               : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry();     break;
--- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -1821,31 +1821,6 @@
   verify_oop_args(masm, method, sig_bt, regs);
   vmIntrinsics::ID iid = method->intrinsic_id();
 
-#ifdef GRAAL
-  if (iid == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod) {
-    // We are called from compiled code here. The three object arguments
-    // are already in the correct registers (j_rarg0, jrarg1, jrarg2). The
-    // fourth argument (j_rarg3) is a pointer to the HotSpotInstalledCode object.
-
-    // Load the nmethod pointer from the HotSpotInstalledCode object
-//    __ movq(j_rarg3, Address(j_rarg3, sizeof(oopDesc)));
-
-    // Check whether the nmethod was invalidated
-//    __ testq(j_rarg3, j_rarg3);
-//    Label invalid_nmethod;
-//    __ jcc(Assembler::zero, invalid_nmethod);
-
-    // Perform a tail call to the verified entry point of the nmethod.
-//    __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset()));
-
-//    __ bind(invalid_nmethod);
-
-//    __ jump(RuntimeAddress(StubRoutines::throw_InvalidInstalledCodeException_entry()));
-    __ stop("_CompilerToVMImpl_executeCompiledMethod not implemented");
-    return;
-  }
-#endif
-
   // Now write the args into the outgoing interpreter space
   bool     has_receiver   = false;
   Register receiver_reg   = noreg;
--- a/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/stubGenerator_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -3347,7 +3347,6 @@
     // These entry points require SharedInfo::stack0 to be set up in non-core builds
     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
-    StubRoutines::_throw_InvalidInstalledCodeException_entry= generate_throw_exception("InvalidInstalledCodeException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_InvalidInstalledCodeException));
     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
 
     StubRoutines::_handler_for_unsafe_access_entry =
--- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -804,18 +804,6 @@
   return generate_accessor_entry();
 }
 
-#ifdef GRAAL
-
-// Interpreter stub for calling a compiled method with 3 object arguments
-address InterpreterGenerator::generate_execute_compiled_method_entry() {
-  address entry_point = __ pc();
-
-  __ stop("graal-sparc unimp");
-
-  return entry_point;
-}
-
-#endif
 
 //
 // Interpreter stub for calling a native method. (asm interpreter)
--- a/src/cpu/x86/vm/compiledIC_x86.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/compiledIC_x86.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -78,21 +78,24 @@
 // ----------------------------------------------------------------------------
 
 #define __ _masm.
-void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) {
+void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) {
   // Stub is fixed up when the corresponding call is converted from
   // calling compiled code to calling interpreted code.
   // movq rbx, 0
   // jmp -5 # to self
 
-  address mark = cbuf.insts_mark();  // Get mark within main instrs section.
+  if (mark == NULL) {
+    mark = cbuf.insts_mark();  // Get mark within main instrs section.
+  }
 
   // Note that the code buffer's insts_mark is always relative to insts.
   // That's why we must use the macroassembler to generate a stub.
   MacroAssembler _masm(&cbuf);
 
   address base =
-  __ start_a_stub(to_interp_stub_size()*2);
-  if (base == NULL) return;  // CodeBuffer::expand failed.
+  __ start_a_stub(to_interp_stub_size());
+  guarantee(base != NULL, "out of space");
+
   // Static stub relocation stores the instruction address of the call.
   __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand);
   // Static stub relocation also tags the Method* in the code-stream.
@@ -100,6 +103,8 @@
   // This is recognized as unresolved by relocs/nativeinst/ic code.
   __ jump(RuntimeAddress(__ pc()));
 
+  assert(__ pc() - base <= to_interp_stub_size(), "wrong stub size"); 
+
   // Update current stubs pointer and restore insts_end.
   __ end_a_stub();
 }
@@ -117,12 +122,6 @@
 
 void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) {
   address stub = find_stub();
-#ifdef GRAAL
-  if (stub == NULL) {
-    set_destination_mt_safe(entry);
-    return;
-  }
-#endif
   guarantee(stub != NULL, "stub not found");
 
   if (TraceICs) {
@@ -172,14 +171,12 @@
     verify_alignment();
   }
 
-#ifndef GRAAL
   // Verify stub.
   address stub = find_stub();
   assert(stub != NULL, "no stub found for static call");
   // Creation also verifies the object.
   NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
   NativeJump*        jump          = nativeJump_at(method_holder->next_instruction_address());
-#endif
 
   // Verify state.
   assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/x86/vm/graalCodeInstaller_x86.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2013, 2014, 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.
+ */
+
+#include "compiler/disassembler.hpp"
+#include "runtime/javaCalls.hpp"
+#include "graal/graalEnv.hpp"
+#include "graal/graalCompiler.hpp"
+#include "graal/graalCodeInstaller.hpp"
+#include "graal/graalJavaAccess.hpp"
+#include "graal/graalCompilerToVM.hpp"
+#include "graal/graalRuntime.hpp"
+#include "asm/register.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "code/vmreg.hpp"
+
+jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
+  if (inst->is_call() || inst->is_jump()) {
+    assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size");
+    return (pc_offset + NativeCall::instruction_size);
+  } else if (inst->is_mov_literal64()) {
+    // mov+call instruction pair
+    jint offset = pc_offset + NativeMovConstReg::instruction_size;
+    u_char* call = (u_char*) (_instructions->start() + offset);
+    assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte");
+    offset += 3; /* prefix byte + opcode byte + modrm byte */
+    return (offset);
+  } else if (inst->is_call_reg()) {
+    // the inlined vtable stub contains a "call register" instruction
+    assert(method != NULL, "only valid for virtual calls");
+    return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset());
+  } else if (inst->is_cond_jump()) {
+    address pc = (address) (inst);
+    return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc);
+  } else {
+    fatal("unsupported type of instruction for call site");
+    return 0;
+  }
+}
+
+void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) {
+  address pc = _instructions->start() + pc_offset;
+  Handle obj = OopData::object(data);
+  jobject value = JNIHandles::make_local(obj());
+  if (OopData::compressed(data)) {
+    address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
+    int oop_index = _oop_recorder->find_index(value);
+    _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand);
+    TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand);
+  } else {
+    address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
+    *((jobject*) operand) = value;
+    _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
+    TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand);
+  }
+}
+
+void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) {
+  address pc = _instructions->start() + pc_offset;
+  jint offset = DataSectionReference::offset(data);
+
+  address operand = Assembler::locate_operand(pc, Assembler::disp32_operand);
+  address next_instruction = Assembler::locate_next_instruction(pc);
+  address dest = _constants->start() + offset;
+
+  long disp = dest - next_instruction;
+  assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
+  *((jint*) operand) = (jint) disp;
+
+  _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
+  TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, offset);
+}
+
+void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
+  if (cb->is_nmethod()) {
+    nmethod* nm = (nmethod*) cb;
+    nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point());
+  } else {
+    nativeJump_at((address)inst)->set_jump_destination(cb->code_begin());
+  }
+  _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand);
+}
+
+void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
+  address pc = (address) inst;
+  if (inst->is_call()) {
+    // NOTE: for call without a mov, the offset must fit a 32-bit immediate
+    //       see also CompilerToVM.getMaxCallTargetOffset()
+    NativeCall* call = nativeCall_at(pc);
+    call->set_destination((address) foreign_call_destination);
+    _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
+  } else if (inst->is_mov_literal64()) {
+    NativeMovConstReg* mov = nativeMovConstReg_at(pc);
+    mov->set_data((intptr_t) foreign_call_destination);
+    _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand);
+  } else if (inst->is_jump()) {
+    NativeJump* jump = nativeJump_at(pc);
+    jump->set_jump_destination((address) foreign_call_destination);
+    _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
+  } else if (inst->is_cond_jump()) {
+    address old_dest = nativeGeneralJump_at(pc)->jump_destination();
+    address disp = Assembler::locate_operand(pc, Assembler::call32_operand);
+    *(jint*) disp += ((address) foreign_call_destination) - old_dest;
+    _instructions->relocate(pc, runtime_call_Relocation::spec(), Assembler::call32_operand);
+  } else {
+    fatal("unsupported relocation for foreign call");
+  }
+
+  TRACE_graal_3("relocating (foreign call)  at %p", inst);
+}
+
+void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
+#ifdef ASSERT
+  Method* method = NULL;
+  // we need to check, this might also be an unresolved method
+  if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) {
+    method = getMethodFromHotSpotMethod(hotspot_method);
+  }
+#endif
+  switch (_next_call_type) {
+    case INLINE_INVOKE:
+      break;
+    case INVOKEVIRTUAL:
+    case INVOKEINTERFACE: {
+      assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
+
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
+      _instructions->relocate(call->instruction_address(),
+                                             virtual_call_Relocation::spec(_invoke_mark_pc),
+                                             Assembler::call32_operand);
+      break;
+    }
+    case INVOKESTATIC: {
+      assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
+
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_static_call_stub());
+      _instructions->relocate(call->instruction_address(),
+                                             relocInfo::static_call_type, Assembler::call32_operand);
+      break;
+    }
+    case INVOKESPECIAL: {
+      assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
+      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
+      call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
+      _instructions->relocate(call->instruction_address(),
+                              relocInfo::opt_virtual_call_type, Assembler::call32_operand);
+      break;
+    }
+    default:
+      break;
+  }
+}
+
+static void relocate_poll_near(address pc) {
+  NativeInstruction* ni = nativeInstruction_at(pc);
+  int32_t* disp = (int32_t*) Assembler::locate_operand(pc, 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;
+}
+
+
+void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
+  switch (mark) {
+    case POLL_NEAR: {
+      relocate_poll_near(pc);
+      _instructions->relocate(pc, relocInfo::poll_type, Assembler::disp32_operand);
+      break;
+    }
+    case POLL_FAR:
+      // This is a load from a register so there is no relocatable operand.
+      // We just have to ensure that the format is not disp32_operand
+      // so that poll_Relocation::fix_relocation_after_move does the right
+      // thing (i.e. ignores this relocation record)
+      _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand);
+      break;
+    case POLL_RETURN_NEAR: {
+      relocate_poll_near(pc);
+      _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::disp32_operand);
+      break;
+    }
+    case POLL_RETURN_FAR:
+      // see comment above for POLL_FAR
+      _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand);
+      break;
+    default:
+      fatal("invalid mark value");
+      break;
+  }
+}
--- a/src/cpu/x86/vm/graalCodeInstaller_x86.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +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.
- */
-#ifndef CPU_X86_VM_CODEINSTALLER_X86_HPP
-#define CPU_X86_VM_CODEINSTALLER_X86_HPP
-
-#include "compiler/disassembler.hpp"
-#include "runtime/javaCalls.hpp"
-#include "graal/graalEnv.hpp"
-#include "graal/graalCompiler.hpp"
-#include "graal/graalCodeInstaller.hpp"
-#include "graal/graalJavaAccess.hpp"
-#include "graal/graalCompilerToVM.hpp"
-#include "graal/graalRuntime.hpp"
-#include "asm/register.hpp"
-#include "classfile/vmSymbols.hpp"
-#include "code/vmreg.hpp"
-
-inline jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) {
-  if (inst->is_call() || inst->is_jump()) {
-    assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size");
-    return (pc_offset + NativeCall::instruction_size);
-  } else if (inst->is_mov_literal64()) {
-    // mov+call instruction pair
-    jint offset = pc_offset + NativeMovConstReg::instruction_size;
-    u_char* call = (u_char*) (_instructions->start() + offset);
-    assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte");
-    offset += 3; /* prefix byte + opcode byte + modrm byte */
-    return (offset);
-  } else if (inst->is_call_reg()) {
-    // the inlined vtable stub contains a "call register" instruction
-    assert(method != NULL, "only valid for virtual calls");
-    return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset());
-  } else if (inst->is_cond_jump()) {
-    address pc = (address) (inst);
-    return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc);
-  } else {
-    fatal("unsupported type of instruction for call site");
-    return 0;
-  }
-}
-
-inline bool check_metaspace_data(address pc, oop data) {
-  jlong value = MetaspaceData::value(data);
-  address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
-  if (MetaspaceData::compressed(data)) {
-    assert(*((jint*) operand) == value, err_msg("wrong compressed metaspace pointer: %p != %p", *((jint*) operand), value));
-  } else {
-    assert(*((jlong*) operand) == value, err_msg("wrong metaspace pointer: %p != %p", *((jlong*) operand), value));
-  }
-  return true;
-}
-
-inline void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) {
-  address pc = _instructions->start() + pc_offset;
-
-  Handle obj = OopData::object(data);
-  jobject value = JNIHandles::make_local(obj());
-  if (OopData::compressed(data)) {
-    address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
-    int oop_index = _oop_recorder->find_index(value);
-    _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand);
-    TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand);
-  } else {
-    address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
-    *((jobject*) operand) = value;
-    _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
-    TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand);
-  }
-}
-
-inline void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) {
-  address pc = _instructions->start() + pc_offset;
-  jint offset = DataSectionReference::offset(data);
-
-  address operand = Assembler::locate_operand(pc, Assembler::disp32_operand);
-  address next_instruction = Assembler::locate_next_instruction(pc);
-  address dest = _constants->start() + offset;
-
-  long disp = dest - next_instruction;
-  assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
-  *((jint*) operand) = (jint) disp;
-
-  _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
-  TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, offset);
-}
-
-inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
-  if (cb->is_nmethod()) {
-    nmethod* nm = (nmethod*) cb;
-    nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point());
-  } else {
-    nativeJump_at((address)inst)->set_jump_destination(cb->code_begin());
-  }
-  _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand);
-}
-
-inline void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) {
-  address pc = (address) inst;
-  if (inst->is_call()) {
-    // NOTE: for call without a mov, the offset must fit a 32-bit immediate
-    //       see also CompilerToVM.getMaxCallTargetOffset()
-    NativeCall* call = nativeCall_at(pc);
-    call->set_destination((address) foreign_call_destination);
-    _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
-  } else if (inst->is_mov_literal64()) {
-    NativeMovConstReg* mov = nativeMovConstReg_at(pc);
-    mov->set_data((intptr_t) foreign_call_destination);
-    _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand);
-  } else if (inst->is_jump()) {
-    NativeJump* jump = nativeJump_at(pc);
-    jump->set_jump_destination((address) foreign_call_destination);
-    _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
-  } else if (inst->is_cond_jump()) {
-    address old_dest = nativeGeneralJump_at(pc)->jump_destination();
-    address disp = Assembler::locate_operand(pc, Assembler::call32_operand);
-    *(jint*) disp += ((address) foreign_call_destination) - old_dest;
-    _instructions->relocate(pc, runtime_call_Relocation::spec(), Assembler::call32_operand);
-  } else {
-    fatal("unsupported relocation for foreign call");
-  }
-
-  TRACE_graal_3("relocating (foreign call)  at %p", inst);
-}
-
-inline void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) {
-#ifdef ASSERT
-  Method* method = NULL;
-  // we need to check, this might also be an unresolved method
-  if (hotspot_method->is_a(HotSpotResolvedJavaMethod::klass())) {
-    method = getMethodFromHotSpotMethod(hotspot_method);
-  }
-#endif
-  switch (_next_call_type) {
-    case INLINE_INVOKE:
-      break;
-    case INVOKEVIRTUAL:
-    case INVOKEINTERFACE: {
-      assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
-
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
-      _instructions->relocate(call->instruction_address(),
-                                             virtual_call_Relocation::spec(_invoke_mark_pc),
-                                             Assembler::call32_operand);
-      break;
-    }
-    case INVOKESTATIC: {
-      assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
-
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_static_call_stub());
-      _instructions->relocate(call->instruction_address(),
-                                             relocInfo::static_call_type, Assembler::call32_operand);
-      break;
-    }
-    case INVOKESPECIAL: {
-      assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
-      NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
-      _instructions->relocate(call->instruction_address(),
-                              relocInfo::opt_virtual_call_type, Assembler::call32_operand);
-      break;
-    }
-    default:
-      break;
-  }
-}
-
-static void relocate_poll_near(address pc) {
-  NativeInstruction* ni = nativeInstruction_at(pc);
-  int32_t* disp = (int32_t*) Assembler::locate_operand(pc, 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;
-}
-
-
-inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
-  switch (mark) {
-    case POLL_NEAR: {
-      relocate_poll_near(pc);
-      _instructions->relocate(pc, relocInfo::poll_type, Assembler::disp32_operand);
-      break;
-    }
-    case POLL_FAR:
-      // This is a load from a register so there is no relocatable operand.
-      // We just have to ensure that the format is not disp32_operand
-      // so that poll_Relocation::fix_relocation_after_move does the right
-      // thing (i.e. ignores this relocation record)
-      _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand);
-      break;
-    case POLL_RETURN_NEAR: {
-      relocate_poll_near(pc);
-      _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::disp32_operand);
-      break;
-    }
-    case POLL_RETURN_FAR:
-      // see comment above for MARK_POLL_FAR
-      _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand);
-      break;
-    default:
-      fatal("invalid mark value");
-      break;
-  }
-}
-
-#endif // CPU_X86_VM_CODEINSTALLER_X86_HPP
-
--- a/src/cpu/x86/vm/interpreterGenerator_x86.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/interpreterGenerator_x86.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -36,9 +36,6 @@
 
   address generate_normal_entry(bool synchronized);
   address generate_native_entry(bool synchronized);
-#ifdef GRAAL
-  address generate_execute_compiled_method_entry();
-#endif
   address generate_abstract_entry(void);
   address generate_math_entry(AbstractInterpreter::MethodKind kind);
   address generate_empty_entry(void);
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -1677,30 +1677,6 @@
   verify_oop_args(masm, method, sig_bt, regs);
   vmIntrinsics::ID iid = method->intrinsic_id();
 
-#ifdef GRAAL
-  if (iid == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod) {
-    // We are called from compiled code here. The three object arguments
-    // are already in the correct registers (j_rarg0, jrarg1, jrarg2). The
-    // fourth argument (j_rarg3) is a pointer to the HotSpotInstalledCode object.
-
-    // Load the nmethod pointer from the HotSpotInstalledCode object
-    __ movq(j_rarg4, Address(j_rarg3, sizeof(oopDesc)));
-
-    // Check whether the nmethod was invalidated
-    __ testq(j_rarg4, j_rarg4);
-    Label invalid_nmethod;
-    __ jcc(Assembler::zero, invalid_nmethod);
-
-    // Perform a tail call to the verified entry point of the nmethod.
-    __ jmp(Address(j_rarg4, nmethod::verified_entry_point_offset()));
-
-    __ bind(invalid_nmethod);
-
-    __ jump(RuntimeAddress(StubRoutines::throw_InvalidInstalledCodeException_entry()));
-    return;
-  }
-#endif
-
   // Now write the args into the outgoing interpreter space
   bool     has_receiver   = false;
   Register receiver_reg   = noreg;
@@ -3384,10 +3360,9 @@
 
 #ifdef GRAAL
   int implicit_exception_uncommon_trap_offset = __ pc() - start;
+
   __ pushptr(Address(r15_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset())));
 
-  int uncommon_trap_offset = __ pc() - start;
-
   // Save everything in sight.
   RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words);
   // fetch_unroll_info needs to call last_java_frame()
@@ -3667,7 +3642,6 @@
   _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words);
   _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset);
 #ifdef GRAAL
-  _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset);
   _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset);
 #endif
 }
--- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -2988,7 +2988,6 @@
     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
-    StubRoutines::_throw_InvalidInstalledCodeException_entry         = generate_throw_exception("InvalidInstalledCodeException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_InvalidInstalledCodeException));
     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
 
     //------------------------------------------------------------------------------------------------------------------------
--- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -3860,12 +3860,6 @@
                                                 SharedRuntime::
                                                 throw_IncompatibleClassChangeError));
 
-    StubRoutines::_throw_InvalidInstalledCodeException_entry =
-      generate_throw_exception("InvalidInstalledCodeException throw_exception",
-                               CAST_FROM_FN_PTR(address,
-                                                SharedRuntime::
-                                                throw_InvalidInstalledCodeException));
-
     StubRoutines::_throw_NullPointerException_at_call_entry =
       generate_throw_exception("NullPointerException at call throw_exception",
                                CAST_FROM_FN_PTR(address,
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -45,9 +45,6 @@
 #include "runtime/vframeArray.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/macros.hpp"
-#ifdef GRAAL
-#include "graal/graalJavaAccess.hpp"
-#endif
 
 #define __ _masm->
 
@@ -852,65 +849,6 @@
   return generate_accessor_entry();
 }
 
-#ifdef GRAAL
-
-// Interpreter stub for calling a compiled method with 3 object arguments
-address InterpreterGenerator::generate_execute_compiled_method_entry() {
-  address entry_point = __ pc();
-
-  // Pick up the return address
-  __ movptr(rax, Address(rsp, 0));
-
-  // Must preserve original SP for loading incoming arguments because
-  // we need to align the outgoing SP for compiled code.
-  __ movptr(r11, rsp);
-
-  // Move first object argument from interpreter calling convention to compiled
-  // code calling convention.
-  __ movq(j_rarg0, Address(r11, Interpreter::stackElementSize*4));
-
-  // Move second object argument.
-  __ movq(j_rarg1, Address(r11, Interpreter::stackElementSize*3));
-
-  // Move third object argument.
-  __ movq(j_rarg2, Address(r11, Interpreter::stackElementSize*2));
-
-  // Load the raw pointer to the HotSpotInstalledCode object.
-  __ movq(j_rarg3, Address(r11, Interpreter::stackElementSize));
-
-  // Load the nmethod pointer from the HotSpotInstalledCode object
-  __ movq(j_rarg3, Address(j_rarg3, sizeof(oopDesc)));
-
-  // Check whether the nmethod was invalidated
-  __ testq(j_rarg3, j_rarg3);
-  Label invalid_nmethod;
-  __ jcc(Assembler::zero, invalid_nmethod);
-
-  // Ensure compiled code always sees stack at proper alignment
-  __ andptr(rsp, -16);
-
-  // push the return address and misalign the stack that youngest frame always sees
-  // as far as the placement of the call instruction
-  __ push(rax);
-
-  // Perform a tail call to the verified entry point of the nmethod.
-  __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset()));
-
-  __ bind(invalid_nmethod);
-
-  //  pop return address, reset last_sp to NULL
-  __ empty_expression_stack();
-  __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
-  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_InvalidInstalledCodeException));
-  // the call_VM checks for exception, so we should never return here.
-  __ should_not_reach_here();
-
-  return entry_point;
-}
-
-#endif
-
 /**
  * Method entry for static native methods:
  *   int java.util.zip.CRC32.update(int crc, int b)
@@ -1702,9 +1640,6 @@
   switch (kind) {
   case Interpreter::zerolocals             :                                                      break;
   case Interpreter::zerolocals_synchronized: synchronized = true;                                 break;
-#ifdef GRAAL
-  case Interpreter::execute_compiled_method: entry_point = ig_this->generate_execute_compiled_method_entry(); break;
-#endif
   case Interpreter::native                 : entry_point = ig_this->generate_native_entry(false); break;
   case Interpreter::native_synchronized    : entry_point = ig_this->generate_native_entry(true);  break;
   case Interpreter::empty                  : entry_point = ig_this->generate_empty_entry();       break;
--- a/src/cpu/x86/vm/vmStructs_x86.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/cpu/x86/vm/vmStructs_x86.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -47,6 +47,8 @@
 
 #define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) \
   declare_constant(frame::arg_reg_save_area_bytes)                  \
+  declare_constant(frame::interpreter_frame_sender_sp_offset)       \
+  declare_constant(frame::interpreter_frame_last_sp_offset)         \
   declare_constant(VM_Version::CPU_CX8)                             \
   declare_constant(VM_Version::CPU_CMOV)                            \
   declare_constant(VM_Version::CPU_FXSR)                            \
--- a/src/gpu/hsail/vm/gpu_hsail.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/gpu/hsail/vm/gpu_hsail.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -59,16 +59,15 @@
 
 #define OBJECT                "Ljava/lang/Object;"
 #define STRING                "Ljava/lang/String;"
+#define JLTHREAD              "Ljava/lang/Thread;"
 #define HS_INSTALLED_CODE     "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
 #define HS_COMPILED_NMETHOD   "Lcom/oracle/graal/hotspot/HotSpotCompiledNmethod;"
 #define HS_NMETHOD            "Lcom/oracle/graal/hotspot/meta/HotSpotNmethod;"
 
-//  public native void executeKernel(HotSpotNmethod kernel, int jobSize, int i, int j, Object[] args) throws InvalidInstalledCodeException;
-
 JNINativeMethod Hsail::HSAIL_methods[] = {
   {CC"initialize",       CC"()Z",                               FN_PTR(Hsail::initialize)},
   {CC"generateKernel",   CC"([B" STRING ")J",                   FN_PTR(Hsail::generate_kernel)},
-  {CC"executeKernel0",   CC"("HS_INSTALLED_CODE"I["OBJECT"["OBJECT")Z",  FN_PTR(Hsail::execute_kernel_void_1d)},
+  {CC"executeKernel0",   CC"("HS_INSTALLED_CODE"I["OBJECT"["OBJECT"["JLTHREAD"I)Z",  FN_PTR(Hsail::execute_kernel_void_1d)},
 };
 
 void * Hsail::_device_context = NULL;
@@ -86,6 +85,43 @@
 Hsail::okra_clearargs_func_t       Hsail::_okra_clearargs;
 Hsail::okra_register_heap_func_t   Hsail::_okra_register_heap;
 
+struct Stats {
+  int _dispatches;
+  int _deopts;
+  int _overflows;
+  bool _changeSeen;
+
+public:
+  Stats() {
+    _dispatches = _deopts = _overflows = 0;
+    _changeSeen = false;
+  }
+
+  void incDeopts() {
+    _deopts++;
+    _changeSeen = true;
+  }
+  void incOverflows() {
+    _overflows++;
+    _changeSeen = true;
+  }
+
+  void finishDispatch() {
+    _dispatches++;
+    if (_changeSeen) {
+      // print();
+      _changeSeen = false;
+    }
+  }
+
+  void print() {
+    tty->print_cr("Disp=%d, Deopts=%d, Ovflows=%d", _dispatches, _deopts, _overflows);
+  }
+
+};
+
+static Stats kernelStats;
+
 
 void Hsail::register_heap() {
   // After the okra functions are set up and the heap is initialized, register the java heap with HSA
@@ -97,7 +133,8 @@
   _okra_register_heap(Universe::heap()->base(), Universe::heap()->capacity());
 }
 
-GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args_handle, jobject oops_save_handle))
+GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args, jobject oops_save,
+                                                      jobject donor_threads, jint allocBytesPerWorkitem))
 
   ResourceMark rm;
   jlong nmethodValue = HotSpotInstalledCode::codeBlob(kernel_handle);
@@ -113,7 +150,7 @@
     SharedRuntime::throw_and_post_jvmti_exception(JavaThread::current(), vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException(), NULL);
   }
 
-  return execute_kernel_void_1d_internal((address) kernel, dimX, args_handle, mh, nm, oops_save_handle, CHECK_0);
+  return execute_kernel_void_1d_internal((address) kernel, dimX, args, mh, nm, oops_save, donor_threads, allocBytesPerWorkitem, CHECK_0);
 GPU_END
 
 static void showRanges(jboolean *a, int len) {
@@ -133,24 +170,90 @@
   }
 }
 
+// fill and retire old tlab and get a new one
+// if we can't get one, no problem someone will eventually do a gc
+void Hsail::getNewTlabForDonorThread(ThreadLocalAllocBuffer* tlab, size_t tlabMinHsail) {
+  tlab->clear_before_allocation();    // fill and retire old tlab (will also check for null)
 
-// for experimentation
-static bool useDeoptInfo = true;
+  // get a size for a new tlab that is at least tlabMinHsail.
+  size_t new_tlab_size = tlab->compute_size(tlabMinHsail);
+  if (new_tlab_size == 0) return;
+
+  HeapWord* tlab_start = Universe::heap()->allocate_new_tlab(new_tlab_size);
+  if (tlab_start == NULL) return;
+
+  // ..and clear it if required
+  if (ZeroTLAB) {
+    Copy::zero_to_words(tlab_start, new_tlab_size);
+  }
+  // and init the tlab pointers
+  tlab->fill(tlab_start, tlab_start, new_tlab_size);
+}
+
+static void printTlabInfo (ThreadLocalAllocBuffer* tlab) {
+  HeapWord *start = tlab->start();
+  HeapWord *top = tlab->top();
+  HeapWord *end = tlab->end();
+  // sizes are in bytes
+  size_t tlabFree = tlab->free() * HeapWordSize;
+  size_t tlabUsed = tlab->used() * HeapWordSize;
+  size_t tlabSize = tlabFree + tlabUsed;
+  double freePct = 100.0 * (double) tlabFree/(double) tlabSize;
+  tty->print_cr("(%p, %p, %p), siz=%ld, free=%ld (%f%%)", start, top, end, tlabSize, tlabFree, freePct);
+}
+
+
 
-jboolean Hsail::execute_kernel_void_1d_internal(address kernel, int dimX, jobject args_handle, methodHandle& mh, nmethod *nm, jobject oops_save_handle, TRAPS) {
+jboolean Hsail::execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod *nm, jobject oops_save,
+                                                jobject donor_threads, int allocBytesPerWorkitem, TRAPS) {
+  ResourceMark rm(THREAD);
+  objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args);
+
+  // TODO: avoid donor thread logic if kernel does not allocate
+  objArrayOop donorThreadObjects = (objArrayOop) JNIHandles::resolve(donor_threads);
+  int numDonorThreads = donorThreadObjects->length();
+  guarantee(numDonorThreads > 0, "need at least one donor thread");
+  JavaThread** donorThreads = NEW_RESOURCE_ARRAY(JavaThread*, numDonorThreads);
+  for (int i = 0; i < numDonorThreads; i++) {
+    donorThreads[i] = java_lang_Thread::thread(donorThreadObjects->obj_at(i));
+  }
+
 
-  ResourceMark rm(THREAD);
-  objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args_handle);
+  // compute tlabMinHsail based on number of workitems, number of donor
+  // threads, allocBytesPerWorkitem rounded up
+  size_t tlabMinHsail = (allocBytesPerWorkitem * dimX + (numDonorThreads - 1)) / numDonorThreads;
+  if (TraceGPUInteraction) {
+    tty->print_cr("computed tlabMinHsail = %d", tlabMinHsail);
+  }
+
+  for (int i = 0; i < numDonorThreads; i++) {
+    JavaThread* donorThread = donorThreads[i];
+    ThreadLocalAllocBuffer* tlab = &donorThread->tlab();
+    if (TraceGPUInteraction) {
+      tty->print("donorThread %d, is %p, tlab at %p -> ", i, donorThread, tlab);
+      printTlabInfo(tlab);
+    }
+
+    // note: this used vs. free limit checking should be based on some
+    // heuristic where we see how much this kernel tends to allocate
+    if ((tlab->end() == NULL) || (tlab->free() * HeapWordSize < tlabMinHsail)) {
+      getNewTlabForDonorThread(tlab, tlabMinHsail);
+      if (TraceGPUInteraction) {
+        tty->print("donorThread %d, refilled tlab, -> ", i);
+        printTlabInfo(tlab);
+      }
+    }
+  }
 
   // Reset the kernel arguments
   _okra_clearargs(kernel);
 
-  
   HSAILDeoptimizationInfo* e;
-  if (useDeoptInfo) {
+  if (UseHSAILDeoptimization) {
     e = new (ResourceObj::C_HEAP, mtInternal) HSAILDeoptimizationInfo();
     e->set_never_ran_array(NEW_C_HEAP_ARRAY(jboolean, dimX, mtInternal));
     memset(e->never_ran_array(), 0, dimX * sizeof(jboolean));
+    e->set_donor_threads(donorThreads);
   }
 
   // This object sets up the kernel arguments
@@ -168,153 +271,183 @@
   }
 
   // Run the kernel
-  bool success = _okra_execute_with_range(kernel, dimX);
-  // check if any workitem requested a deopt
-  // currently we only support at most one such workitem
-
-
-  int deoptcode = e->deopt_occurred();
-  if (useDeoptInfo &&  deoptcode != 0) {
-    if (deoptcode != 1) {
-      // error condition detected in deopt code
-      char msg[200];
-      sprintf(msg, "deopt error detected, slot for workitem %d was not empty", -1*(deoptcode + 1));
-      guarantee(deoptcode == 1, msg);
-    }
-    if (TraceGPUInteraction) {
-      tty->print_cr("deopt happened.");
-      HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[0];
-      tty->print_cr("first deopter was workitem %d", pdeopt->workitem());
-    }
+  bool success = false;
+  {
+    TraceTime t1("execute kernel", TraceGPUInteraction);
+    success = _okra_execute_with_range(kernel, dimX);
+  }
 
-    // Before handling any deopting workitems, save the pointers from
-    // the hsail frames in oops_save so they get adjusted by any
-    // GC. Need to do this before leaving thread_in_vm mode.
-    // resolve handle only needed once here (not exiting vm mode)
-    objArrayOop oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save_handle);
-
-    // since slots are allocated from the beginning, we know how far to look
-    assert(e->num_deopts() < MAX_DEOPT_SAVE_STATES_SIZE, "deopt save state overflow");
-    for (int k = 0; k < e->num_deopts(); k++) {
-      HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k];
-      jint workitem = pdeopt->workitem();
-      if (workitem != -1) {      
-        // this is a workitem that deopted
-        HSAILFrame *hsailFrame = pdeopt->first_frame();
-        int dregOopMap = hsailFrame->dreg_oops_map();
-        for (int bit = 0; bit < 16; bit++) {
-          if ((dregOopMap & (1 << bit)) != 0) {
-            // the dregister at this bit is an oop, save it in the array
-            int index = k * 16 + bit;
-            void* saved_oop = (void*) hsailFrame->get_d_reg(bit);
-            oopsSaveArray->obj_at_put(index, (oop) saved_oop);
-          }
-        }
+  // fix up any tlab tops that overflowed
+  bool anyOverflows = false;
+  for (int i = 0; i < numDonorThreads; i++) {
+    JavaThread * donorThread = donorThreads[i];
+    ThreadLocalAllocBuffer* tlab = &donorThread->tlab();
+    if (tlab->top() > tlab->end()) {
+      anyOverflows = true;
+      long overflowAmount = (long) tlab->top() - (long) tlab->pf_top(); 
+      // tlab->set_top is private this ugly hack gets around that
+      *(long *)((char *)tlab + in_bytes(tlab->top_offset())) = (long) tlab->pf_top();
+      if (TraceGPUInteraction) {
+        tty->print_cr("donorThread %d at %p overflowed by %ld bytes, setting last good top to %p", i, donorThread, overflowAmount, tlab->top());
       }
-    }   
+    }
+  }
+  if (anyOverflows) {
+    kernelStats.incOverflows();
+  }
 
-    // Handle any deopting workitems. 
-    int count_deoptimized = 0;
-    for (int k = 0; k < e->num_deopts(); k++) {
-      HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k];
-    
-      jint workitem = pdeopt->workitem();
-      if (workitem != -1) {      
-        int deoptId = pdeopt->pc_offset();
-        HSAILFrame *hsailFrame = pdeopt->first_frame();
-
-        // update the hsailFrame from the oopsSaveArray
-        // re-resolve the handle
-        oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save_handle);
+  if (UseHSAILDeoptimization) {
+    // check if any workitem requested a deopt
+    // currently we only support at most one such workitem
+    int deoptcode = e->deopt_occurred();
+    if (deoptcode != 0) {
+      if (deoptcode != 1) {
+        // error condition detected in deopt code
+        char msg[200];
+        sprintf(msg, "deopt error detected, slot for workitem %d was not empty", -1 * (deoptcode + 1));
+        guarantee(deoptcode == 1, msg);
+      }
+      kernelStats.incDeopts();
+      {
+        TraceTime t3("handle deoptimizing workitems", TraceGPUInteraction);
+        if (TraceGPUInteraction) {
+          tty->print_cr("deopt happened.");
+          HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[0];
+          tty->print_cr("first deopter was workitem %d", pdeopt->workitem());
+        }
 
-        int dregOopMap = hsailFrame->dreg_oops_map();
-        for (int bit = 0; bit < 16; bit++) {
-          if ((dregOopMap & (1 << bit)) != 0) {
-            // the dregister at this bit is an oop, retrieve it from array and put back in frame
-            int index = k * 16 + bit;
-            void * dregValue = (void *) oopsSaveArray->obj_at(index);
-            void * oldDregValue = (void *) hsailFrame->get_d_reg(bit);
-            assert((oldDregValue != 0 ? dregValue != 0 : dregValue == 0) , "bad dregValue retrieved");
-            if (TraceGPUInteraction) {
-              if (dregValue != oldDregValue) {
-                tty->print_cr("oop moved for $d%d, workitem %d, slot %d, old=%p, new=%p", bit, workitem, k, oldDregValue, dregValue);
+        // Before handling any deopting workitems, save the pointers from
+        // the hsail frames in oops_save so they get adjusted by any
+        // GC. Need to do this before leaving thread_in_vm mode.
+        // resolve handle only needed once here (not exiting vm mode)
+        objArrayOop oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save);
+
+        // since slots are allocated from the beginning, we know how far to look
+        assert(e->num_deopts() < MAX_DEOPT_SAVE_STATES_SIZE, "deopt save state overflow");
+        for (int k = 0; k < e->num_deopts(); k++) {
+          HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k];
+          jint workitem = pdeopt->workitem();
+          if (workitem != -1) {
+            // this is a workitem that deopted
+            HSAILFrame *hsailFrame = pdeopt->first_frame();
+            int dregOopMap = hsailFrame->dreg_oops_map();
+            for (int bit = 0; bit < 16; bit++) {
+              if ((dregOopMap & (1 << bit)) != 0) {
+                // the dregister at this bit is an oop, save it in the array
+                int index = k * 16 + bit;
+                void* saved_oop = (void*) hsailFrame->get_d_reg(bit);
+                oopsSaveArray->obj_at_put(index, (oop) saved_oop);
               }
             }
-            hsailFrame->put_d_reg(bit, (jlong) dregValue);
-          }
-        }
-       
-        JavaValue result(T_VOID);
-        JavaCallArguments javaArgs;
-        javaArgs.set_alternative_target(nm);
-        javaArgs.push_int(deoptId);
-        javaArgs.push_long((jlong) hsailFrame);
-
-        // override the deoptimization action with Action_none until we decide
-        // how to handle the other actions.
-        int myActionReason = Deoptimization::make_trap_request(Deoptimization::trap_request_reason(pdeopt->reason()), Deoptimization::Action_none);
-        javaArgs.push_int(myActionReason);
-        javaArgs.push_oop((oop)NULL);
-        if (TraceGPUInteraction) {
-          int dregOopMap = hsailFrame->dreg_oops_map();
-          tty->print_cr("[HSAIL] Deoptimizing to host for workitem=%d (slot=%d) with deoptId=%d, frame=" INTPTR_FORMAT ", actionAndReason=%d, dregOopMap=%04x", workitem, k, deoptId, hsailFrame, myActionReason, dregOopMap);
-          // show the registers containing references
-          for (int bit = 0; bit < 16; bit++) {
-            if ((dregOopMap & (1 << bit)) != 0) {
-              tty->print_cr("  oop $d%d = %p", bit, hsailFrame->get_d_reg(bit));
-            }
           }
         }
-        JavaCalls::call(&result, mh, &javaArgs, THREAD);
-        count_deoptimized++;
-      }
-    }    
-    if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] Deoptimizing to host completed for %d workitems", count_deoptimized);
-    }
+
+        // Handle any deopting workitems.
+        int count_deoptimized = 0;
+        for (int k = 0; k < e->num_deopts(); k++) {
+          HSAILKernelDeoptimization * pdeopt = &e->_deopt_save_states[k];
+
+          jint workitem = pdeopt->workitem();
+          if (workitem != -1) {
+            int deoptId = pdeopt->pc_offset();
+            HSAILFrame *hsailFrame = pdeopt->first_frame();
+
+            // update the hsailFrame from the oopsSaveArray
+            // re-resolve the handle
+            oopsSaveArray = (objArrayOop) JNIHandles::resolve(oops_save);
 
-    // Handle any never_ran workitems if there were any
-    int count_never_ran = 0;
-    bool handleNeverRansHere = true;
-    // turn off verbose trace stuff for javacall arg setup
-    bool savedTraceGPUInteraction = TraceGPUInteraction;
-    TraceGPUInteraction = false;
-    jboolean *never_ran_array = e->never_ran_array();
-    if (handleNeverRansHere) {
-      for (int k = 0; k < dimX; k++) {
-        if (never_ran_array[k]) {
-          // run it as a javaCall
-          KlassHandle methKlass = mh->method_holder();
-          Thread* THREAD = Thread::current();
-          JavaValue result(T_VOID);
-          JavaCallArguments javaArgs;
-          // re-resolve the args_handle here
-          objArrayOop resolvedArgsArray = (objArrayOop) JNIHandles::resolve(args_handle);
-          // This object sets up the javaCall arguments
-          // the way argsArray is set up, this should work for instance methods as well
-          // (the receiver will be the first oop pushed)
-          HSAILJavaCallArguments hjca(&javaArgs, k, mh->signature(), resolvedArgsArray, mh->is_static());
-          if (mh->is_static()) {
-            JavaCalls::call_static(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD);
-          } else {
-            JavaCalls::call_virtual(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD);
+            int dregOopMap = hsailFrame->dreg_oops_map();
+            for (int bit = 0; bit < 16; bit++) {
+              if ((dregOopMap & (1 << bit)) != 0) {
+                // the dregister at this bit is an oop, retrieve it from array and put back in frame
+                int index = k * 16 + bit;
+                void * dregValue = (void *) oopsSaveArray->obj_at(index);
+                void * oldDregValue = (void *) hsailFrame->get_d_reg(bit);
+                assert((oldDregValue != 0 ? dregValue != 0 : dregValue == 0), "bad dregValue retrieved");
+                if (TraceGPUInteraction) {
+                  if (dregValue != oldDregValue) {
+                    tty->print_cr("oop moved for $d%d, workitem %d, slot %d, old=%p, new=%p", bit, workitem, k, oldDregValue, dregValue);
+                  }
+                }
+                hsailFrame->put_d_reg(bit, (jlong) dregValue);
+              }
+            }
+
+            JavaValue result(T_VOID);
+            JavaCallArguments javaArgs;
+            javaArgs.set_alternative_target(nm);
+            javaArgs.push_int(deoptId);
+            javaArgs.push_long((jlong) hsailFrame);
+
+            // override the deoptimization action with Action_none until we decide
+            // how to handle the other actions.
+            int myActionReason = Deoptimization::make_trap_request(Deoptimization::trap_request_reason(pdeopt->reason()), Deoptimization::Action_none);
+            javaArgs.push_int(myActionReason);
+            javaArgs.push_oop((oop) NULL);
+            if (TraceGPUInteraction) {
+              int dregOopMap = hsailFrame->dreg_oops_map();
+              tty->print_cr("[HSAIL] Deoptimizing to host for workitem=%d (slot=%d) with deoptId=%d, frame=" INTPTR_FORMAT ", actionAndReason=%d, dregOopMap=%04x", workitem, k, deoptId, hsailFrame, myActionReason, dregOopMap);
+              // show the registers containing references
+              for (int bit = 0; bit < 16; bit++) {
+                if ((dregOopMap & (1 << bit)) != 0) {
+                  tty->print_cr("  oop $d%d = %p", bit, hsailFrame->get_d_reg(bit));
+                }
+              }
+            }
+            JavaCalls::call(&result, mh, &javaArgs, THREAD);
+            count_deoptimized++;
           }
-          count_never_ran++;
+        }
+        if (TraceGPUInteraction) {
+          tty->print_cr("[HSAIL] Deoptimizing to host completed for %d workitems", count_deoptimized);
         }
       }
-      TraceGPUInteraction = savedTraceGPUInteraction;
-      if (TraceGPUInteraction) {
-        tty->print_cr("%d workitems never ran, have been run via JavaCall", count_never_ran);
-        showRanges(never_ran_array, dimX);
+
+      {
+        TraceTime t3("handle never-rans", TraceGPUInteraction);
+
+        // Handle any never_ran workitems if there were any
+        int count_never_ran = 0;
+        bool handleNeverRansHere = true;
+        // turn off verbose trace stuff for javacall arg setup
+        bool savedTraceGPUInteraction = TraceGPUInteraction;
+        TraceGPUInteraction = false;
+        jboolean *never_ran_array = e->never_ran_array();
+        if (handleNeverRansHere) {
+          for (int k = 0; k < dimX; k++) {
+            if (never_ran_array[k]) {
+              // run it as a javaCall
+              KlassHandle methKlass = mh->method_holder();
+              Thread* THREAD = Thread::current();
+              JavaValue result(T_VOID);
+              JavaCallArguments javaArgs;
+              // re-resolve the args_handle here
+              objArrayOop resolvedArgsArray = (objArrayOop) JNIHandles::resolve(args);
+              // This object sets up the javaCall arguments
+              // the way argsArray is set up, this should work for instance methods as well
+              // (the receiver will be the first oop pushed)
+              HSAILJavaCallArguments hjca(&javaArgs, k, mh->signature(), resolvedArgsArray, mh->is_static());
+              if (mh->is_static()) {
+                JavaCalls::call_static(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD);
+              } else {
+                JavaCalls::call_virtual(&result, methKlass, mh->name(), mh->signature(), &javaArgs, THREAD);
+              }
+              count_never_ran++;
+            }
+          }
+          TraceGPUInteraction = savedTraceGPUInteraction;
+          if (TraceGPUInteraction) {
+            tty->print_cr("%d workitems never ran, have been run via JavaCall", count_never_ran);
+            showRanges(never_ran_array, dimX);
+          }
+        } // end of never-ran handling
       }
-    } // end of never-ran handling
-
-  }
-
-  if (useDeoptInfo) {
+    }
+    
     FREE_C_HEAP_ARRAY(jboolean, e->never_ran_array(), mtInternal);
     delete e;
   }
+  kernelStats.finishDispatch();
   return success;
 }
 
@@ -355,7 +488,7 @@
 
 #define LOOKUP_OKRA_FUNCTION(name, alias)  \
   _##alias =                               \
-    CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \
+    CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(okra_lib_handle, STRINGIFY(name))); \
   if (_##alias == NULL) {      \
   tty->print_cr("[HSAIL] ***** Error: Failed to lookup %s in %s, wrong version of OKRA?", STRINGIFY(name), okra_library_name); \
         return false; \
@@ -371,22 +504,25 @@
 
   // here we know we have a valid okra_library_name to try to load
   char ebuf[O_BUFLEN];
+  char *okra_lib_name_from_env_var = getenv("_OKRA_SIM_LIB_PATH_");
+  if (okra_lib_name_from_env_var != NULL) {
+    okra_library_name = okra_lib_name_from_env_var;
+  }
   if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] library is %s", okra_library_name);
+    tty->print_cr("[HSAIL] library is %s", okra_library_name);
   }
-
-  void *handle = os::dll_load(okra_library_name, ebuf, O_BUFLEN);
-  // try alternate location if env variable set
-  char *okra_lib_name_from_env_var = getenv("_OKRA_SIM_LIB_PATH_");
-  if ((handle == NULL) && (okra_lib_name_from_env_var != NULL)) {
-    handle = os::dll_load(okra_lib_name_from_env_var, ebuf, O_BUFLEN);
-    if ((handle != NULL) && TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] using _OKRA_SIM_LIB_PATH_=%s", getenv("_OKRA_SIM_LIB_PATH_"));
-    }
-  }
-
-  if (handle == NULL) {
-    // Unable to dlopen okra
+  void *okra_lib_handle = NULL;
+#if defined(LINUX)
+  // Check first if the Okra library is already loaded.
+  // TODO: Figure out how to do this on other OSes.
+  okra_lib_handle = ::dlopen(okra_library_name, RTLD_LAZY | RTLD_NOLOAD);
+#endif
+  // If Okra library is not already loaded, load it here
+  if (okra_lib_handle == NULL) {
+    okra_lib_handle = os::dll_load(okra_library_name, ebuf, O_BUFLEN);
+  }  
+  if (okra_lib_handle == NULL) {
+    // Unable to open Okra library
     if (TraceGPUInteraction) {
       tty->print_cr("[HSAIL] library load failed.");
     }
@@ -395,7 +531,8 @@
   
   guarantee(_okra_create_context == NULL, "cannot repeat GPU initialization");
 
-  // at this point we know handle is valid and we can lookup the functions
+  // at this point we know  okra_lib_handle is valid whether we loaded
+  // here or earlier.  In either case, we can lookup the functions
   LOOKUP_OKRA_FUNCTION(okra_create_context, okra_create_context);
   LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel);
   LOOKUP_OKRA_FUNCTION(okra_push_object, okra_push_object);
--- a/src/gpu/hsail/vm/gpu_hsail.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/gpu/hsail/vm/gpu_hsail.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -60,6 +60,7 @@
    private:
     jint _deopt_occurred;
     jint _deopt_next_index;
+    JavaThread** _donor_threads;
     jboolean * _never_ran_array;
 
    public:
@@ -77,6 +78,7 @@
     inline jint num_deopts() { return _deopt_next_index; }
     inline jboolean *never_ran_array() { return _never_ran_array; }
     inline void  set_never_ran_array(jboolean *p) { _never_ran_array = p; }
+    inline void  set_donor_threads(JavaThread **threads) { _donor_threads = threads; }
   };
 
 
@@ -91,13 +93,16 @@
   JNIEXPORT static jlong generate_kernel(JNIEnv *env, jclass, jbyteArray code_handle, jstring name_handle);
 
   // static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args);
-  JNIEXPORT static jboolean execute_kernel_void_1d(JNIEnv *env, jclass, jobject hotspotInstalledCode, jint dimX, jobject args, jobject oopsSave);
+  JNIEXPORT static jboolean execute_kernel_void_1d(JNIEnv *env, jclass, jobject hotspotInstalledCode, jint dimX, jobject args, jobject oopsSave,
+                                                   jobject donorThreads, int allocBytesPerWorkitem);
 
-  // static native void setSimulatorSingleThreaded0();
-  JNIEXPORT static void setSimulatorSingleThreaded0(JNIEnv *env, jclass);
+  // static native void getThreadPointers(Object[] donorThreads, long[] threadPointersOut);
+  JNIEXPORT static void get_thread_pointers(JNIEnv *env, jclass, jobject donor_threads_handle, jobject thread_ptrs_handle);
 
+  static void getNewTlabForDonorThread(ThreadLocalAllocBuffer* tlab, size_t tlabMinHsail);
 
-  static jboolean execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod *nm, jobject oopsSave, TRAPS);
+  static jboolean execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod *nm, jobject oopsSave,
+                                                  jobject donorThreads, int allocBytesPerWorkitem, TRAPS);
 
   static void register_heap();
 
--- a/src/gpu/hsail/vm/hsailKernelArguments.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/gpu/hsail/vm/hsailKernelArguments.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -79,11 +79,13 @@
         assert(pushed == true, "arg push failed");
     }
     virtual void pushTrailingArgs() {
-        // Last argument is the exception info block
-        if (TraceGPUInteraction) {
-            tty->print_cr("[HSAIL] exception block=" PTR_FORMAT, _exceptionHolder);
+        if (UseHSAILDeoptimization) {
+            // Last argument is the exception info block
+            if (TraceGPUInteraction) {
+                tty->print_cr("[HSAIL] exception block=" PTR_FORMAT, _exceptionHolder);
+            }
+            pushObject(_exceptionHolder);
         }
-        pushObject(_exceptionHolder);
     }
 
     // For kernel arguments we don't pass the final int parameter
--- a/src/gpu/hsail/vm/vmStructs_hsail.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/gpu/hsail/vm/vmStructs_hsail.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -32,17 +32,18 @@
 // constants required by the Serviceability Agent. This file is
 // referenced by vmStructs.cpp.
 
-#define VM_STRUCTS_GPU_HSAIL(nonstatic_field)                                                                                                    \
+#define VM_STRUCTS_GPU_HSAIL(nonstatic_field)                                                                                         \
   nonstatic_field(HSAILFrame, _pc_offset,                                                  jint)                                      \
   nonstatic_field(HSAILFrame, _num_s_regs,                                                 jbyte)                                     \
   nonstatic_field(HSAILFrame, _save_area[0],                                               jlong)                                     \
-                                                                                                                                                                                                                                                                                      \
+                                                                                                                                      \
   nonstatic_field(Hsail::HSAILKernelDeoptimization, _workitemid,                                jint)                                 \
   nonstatic_field(Hsail::HSAILKernelDeoptimization, _actionAndReason,                           jint)                                 \
-  nonstatic_field(Hsail::HSAILKernelDeoptimization, _first_frame,                               HSAILFrame)                      \
-                                                                                                                                           \
+  nonstatic_field(Hsail::HSAILKernelDeoptimization, _first_frame,                               HSAILFrame)                           \
+                                                                                                                                      \
   nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_occurred,                         jint)                                      \
   nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_next_index,                       jint)                                      \
+  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _donor_threads,                          JavaThread**)                              \
   nonstatic_field(Hsail::HSAILDeoptimizationInfo, _never_ran_array,                        jboolean *)                                \
   nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_save_states[0],                   Hsail::HSAILKernelDeoptimization)          \
   nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_save_states[1],                   Hsail::HSAILKernelDeoptimization)
--- a/src/share/vm/classfile/systemDictionary.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/classfile/systemDictionary.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -186,6 +186,9 @@
   /* Support for Graal */                                                                                                \
   do_klass(CompilerThread_klass,                  com_oracle_graal_compiler_CompilerThread,                     Opt) \
   do_klass(BitSet_klass,                          java_util_BitSet,                                             Opt) \
+  /* graal.graph */                                                                                                  \
+  do_klass(Node_klass,                            com_oracle_graal_graph_Node,                                  Opt) \
+  do_klass(NodeClass_klass,                       com_oracle_graal_graph_NodeClass,                             Opt) \
   /* graal.hotspot */                                                                                                \
   do_klass(HotSpotCompiledCode_klass,             com_oracle_graal_hotspot_HotSpotCompiledCode,                 Opt) \
   do_klass(HotSpotCompiledCode_Comment_klass,     com_oracle_graal_hotspot_HotSpotCompiledCode_Comment,         Opt) \
@@ -204,6 +207,9 @@
   do_klass(HotSpotResolvedJavaMethod_klass,       com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethod,      Opt) \
   do_klass(HotSpotResolvedObjectType_klass,       com_oracle_graal_hotspot_meta_HotSpotResolvedObjectType,      Opt) \
   do_klass(HotSpotMonitorValue_klass,             com_oracle_graal_hotspot_meta_HotSpotMonitorValue,            Opt) \
+  do_klass(HotSpotObjectConstant_klass,           com_oracle_graal_hotspot_meta_HotSpotObjectConstant,          Opt) \
+  do_klass(HotSpotMetaspaceConstant_klass,        com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstant,       Opt) \
+  do_klass(HotSpotStackFrameReference_klass,      com_oracle_graal_hotspot_HotSpotStackFrameReference,          Opt) \
   /* graal.api.code */                                                                                               \
   do_klass(Assumptions_klass,                     com_oracle_graal_api_code_Assumptions,                        Opt) \
   do_klass(Assumptions_ConcreteMethod_klass,      com_oracle_graal_api_code_Assumptions_ConcreteMethod,         Opt) \
@@ -231,6 +237,8 @@
   do_klass(SpeculationLog_klass,                  com_oracle_graal_api_code_SpeculationLog,                     Opt) \
   /* graal.api.meta */                                                                                               \
   do_klass(Constant_klass,                        com_oracle_graal_api_meta_Constant,                           Opt) \
+  do_klass(PrimitiveConstant_klass,               com_oracle_graal_api_meta_PrimitiveConstant,                  Opt) \
+  do_klass(NullConstant_klass,                    com_oracle_graal_api_meta_NullConstant,                       Opt) \
   do_klass(ExceptionHandler_klass,                com_oracle_graal_api_meta_ExceptionHandler,                   Opt) \
   do_klass(Kind_klass,                            com_oracle_graal_api_meta_Kind,                               Opt) \
   do_klass(JavaMethod_klass,                      com_oracle_graal_api_meta_JavaMethod,                         Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -292,6 +292,9 @@
   /* Support for Graal */                                                                                                             \
   template(com_oracle_graal_compiler_CompilerThread,                 "com/oracle/graal/compiler/CompilerThread")                      \
   template(java_util_BitSet,	                                       "java/util/BitSet")                                              \
+  /* graal.graph */                                                                                                                   \
+  template(com_oracle_graal_graph_Node,                              "com/oracle/graal/graph/Node")                                   \
+  template(com_oracle_graal_graph_NodeClass,                         "com/oracle/graal/graph/NodeClass")                              \
   /* graal.hotspot */                                                                                                                 \
   template(com_oracle_graal_hotspot_HotSpotGraalRuntime,             "com/oracle/graal/hotspot/HotSpotGraalRuntime")                  \
   template(com_oracle_graal_hotspot_HotSpotKlassOop,                 "com/oracle/graal/hotspot/HotSpotKlassOop")                      \
@@ -315,8 +318,13 @@
   template(com_oracle_graal_hotspot_meta_HotSpotResolvedJavaMethod,  "com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod")       \
   template(com_oracle_graal_hotspot_meta_HotSpotResolvedObjectType,  "com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType")       \
   template(com_oracle_graal_hotspot_meta_HotSpotMonitorValue,        "com/oracle/graal/hotspot/meta/HotSpotMonitorValue")             \
+  template(com_oracle_graal_hotspot_meta_HotSpotObjectConstant,      "com/oracle/graal/hotspot/meta/HotSpotObjectConstant")           \
+  template(com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstant,   "com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstant")        \
+  template(com_oracle_graal_hotspot_HotSpotStackFrameReference,      "com/oracle/graal/hotspot/HotSpotStackFrameReference")           \
   /* graal.api.meta */                                                                                                                \
   template(com_oracle_graal_api_meta_Constant,                       "com/oracle/graal/api/meta/Constant")                            \
+  template(com_oracle_graal_api_meta_PrimitiveConstant,              "com/oracle/graal/api/meta/PrimitiveConstant")                   \
+  template(com_oracle_graal_api_meta_NullConstant,                   "com/oracle/graal/api/meta/NullConstant")                        \
   template(com_oracle_graal_api_meta_ConstantPool,                   "com/oracle/graal/api/meta/ConstantPool")                        \
   template(com_oracle_graal_api_meta_ExceptionHandler,               "com/oracle/graal/api/meta/ExceptionHandler")                    \
   template(com_oracle_graal_api_meta_JavaMethod,                     "com/oracle/graal/api/meta/JavaMethod")                          \
@@ -352,7 +360,7 @@
   /* graal.gpu */                                                                                                                     \
   template(com_oracle_graal_gpu_ExternalCompilationResult,           "com/oracle/graal/gpu/ExternalCompilationResult")                \
   /* graal.truffle */                                                                                                                 \
-  template(com_oracle_graal_truffle_GraalTruffleRuntime,             "com/oracle/graal/truffle/GraalTruffleRuntime")                  \
+  template(com_oracle_graal_truffle_hotspot_HotSpotTruffleRuntime,   "com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime")        \
   template(startCompiler_name,                    "startCompiler")                                                                    \
   template(bootstrap_name,                        "bootstrap")                                                                        \
   template(compileTheWorld_name,                  "compileTheWorld")                                                                  \
@@ -367,7 +375,7 @@
   template(runtime_name,                          "runtime")                                                                          \
   template(runtime_signature,                     "()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;")                                 \
   template(makeInstance_name,                     "makeInstance")                                                                     \
-  template(makeInstance_signature,                "()Lcom/oracle/graal/truffle/GraalTruffleRuntime;")                                 \
+  template(makeInstance_signature,                "()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;")                       \
   template(initialize_name,                       "initialize")                                                                       \
   template(forObject_name,                        "forObject")                                                                        \
   template(callbackInternal_name,                 "callbackInternal")                                                                 \
@@ -1154,9 +1162,6 @@
   do_intrinsic(_Double_valueOf,           java_lang_Double,       valueOf_name, Double_valueOf_signature, F_S)          \
    do_name(     Double_valueOf_signature,                        "(D)Ljava/lang/Double;")                               \
                                                                                                                         \
-  do_intrinsic(_CompilerToVMImpl_executeCompiledMethod,           com_oracle_graal_hotspot_bridge_CompilerToVMImpl, executeCompiledMethod_name, CompilerToVMImpl_executeCompiledMethod_signature, F_SN)\
-   do_name(     CompilerToVMImpl_executeCompiledMethod_signature, "(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;)Ljava/lang/Object;")                               \
-   do_name(     executeCompiledMethod_name,                       "executeCompiledMethodIntrinsic")                     \
     /*end*/
 
 
--- a/src/share/vm/code/codeBlob.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/code/codeBlob.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -358,8 +358,6 @@
   int _unpack_with_exception_in_tls;
 
 #ifdef GRAAL
-  // (thomaswue) Offset when Graal calls uncommon_trap.
-  int _uncommon_trap_offset;
   int _implicit_exception_uncommon_trap_offset;
 #endif
 
@@ -417,12 +415,6 @@
   address unpack_with_exception_in_tls() const   { return code_begin() + _unpack_with_exception_in_tls; }
 
 #ifdef GRAAL
-  // (thomaswue) Offset when Graal calls uncommon_trap.
-  void set_uncommon_trap_offset(int offset) {
-    _uncommon_trap_offset = offset;
-    assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob");
-  }
-  address uncommon_trap() const                  { return code_begin() + _uncommon_trap_offset;     }
   void set_implicit_exception_uncommon_trap_offset(int offset) {
     _implicit_exception_uncommon_trap_offset = offset;
     assert(contains(code_begin() + _implicit_exception_uncommon_trap_offset), "must be PC inside codeblob");
--- a/src/share/vm/code/compiledIC.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/code/compiledIC.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -76,7 +76,7 @@
   // Don't use ic_destination for this test since that forwards
   // through ICBuffer instead of returning the actual current state of
   // the CompiledIC.
-  if (is_icholder_entry(_ic_call->destination()) GRAAL_ONLY(&& _value != NULL)) {
+  if (is_icholder_entry(_ic_call->destination())) {
     // When patching for the ICStub case the cached value isn't
     // overwritten until the ICStub copied into the CompiledIC during
     // the next safepoint.  Make sure that the CompiledICHolder* is
@@ -107,13 +107,6 @@
   _ic_call->set_destination_mt_safe(entry_point);
 }
 
-#ifdef GRAAL
-  if (_value == NULL) {
-    // Can happen when Graal converted a virtual call into an invoke special based on static analysis.
-    return;
-  }
-#endif
-
   if (is_optimized() || is_icstub) {
     // Optimized call sites don't have a cache value and ICStub call
     // sites only change the entry point.  Changing the value in that
@@ -235,7 +228,9 @@
   bool is_monomorphic = (cb != NULL && cb->is_nmethod());
   // Check that the cached_value is a klass for non-optimized monomorphic calls
   // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used
-  // for calling directly to vep without using the inline cache (i.e., cached_value == NULL)
+  // for calling directly to vep without using the inline cache (i.e., cached_value == NULL).
+  // For Graal this occurs because CHA is only used to improve inlining so call sites which could be optimized
+  // virtuals because there are no currently loaded subclasses of a type are left as virtual call sites.
 #ifdef ASSERT
   CodeBlob* caller = CodeCache::find_blob_unsafe(instruction_address());
   bool is_c1_or_graal_method = caller->is_compiled_by_c1() || caller->is_compiled_by_graal();
@@ -264,14 +259,12 @@
     // Check if we are calling into our own codeblob (i.e., to a stub)
     CodeBlob* cb = CodeCache::find_blob(_ic_call->instruction_address());
     address dest = ic_destination();
-#ifndef GRAAL
 #ifdef ASSERT
     {
       CodeBlob* db = CodeCache::find_blob_unsafe(dest);
       assert(!db->is_adapter_blob(), "must use stub!");
     }
 #endif /* ASSERT */
-#endif
     is_call_to_interpreted = cb->contains(dest);
   }
   return is_call_to_interpreted;
--- a/src/share/vm/code/compiledIC.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/code/compiledIC.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -308,7 +308,7 @@
   friend CompiledStaticCall* compiledStaticCall_at(Relocation* call_site);
 
   // Code
-  static void emit_to_interp_stub(CodeBuffer &cbuf);
+  static void emit_to_interp_stub(CodeBuffer &cbuf, address mark = NULL);
   static int to_interp_stub_size();
   static int reloc_to_interp_stub();
 
--- a/src/share/vm/code/debugInfoRec.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/code/debugInfoRec.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -235,10 +235,16 @@
 
 
 int DebugInformationRecorder::find_sharable_decode_offset(int stream_offset) {
+  // It's always a space win to share and Graal generates quite a bit
+  // of scopes data so always enable the sharing logic with Graal.
+  // Presumably this is disabled in regular HotSpot because it makes
+  // recording more expensive?
+#ifndef GRAAL
   // Only pull this trick if non-safepoint recording
   // is enabled, for now.
   if (!recording_non_safepoints())
     return serialized_null;
+#endif
 
   NOT_PRODUCT(++dir_stats.chunks_queried);
   int stream_length = stream()->position() - stream_offset;
--- a/src/share/vm/code/nmethod.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/code/nmethod.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -1972,7 +1972,7 @@
   // should not get GC'd.  Skip the first few bytes of oops on
   // not-entrant methods.
   address low_boundary = verified_entry_point();
-  if (is_not_entrant() || is_zombie()) {
+  if (is_not_entrant()) {
     low_boundary += NativeJump::instruction_size;
     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
     // (See comment above.)
--- a/src/share/vm/compiler/compileBroker.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/compiler/compileBroker.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -1255,7 +1255,7 @@
   assert(method->method_holder()->oop_is_instance(), "not an instance method");
   assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
   assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods");
-  assert(!method->method_holder()->is_not_initialized() || method->intrinsic_id() == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod, "method holder must be initialized");
+  assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized");
   // allow any levels for WhiteBox
   assert(WhiteBoxAPI || TieredCompilation || comp_level == CompLevel_highest_tier, "only CompLevel_highest_tier must be used in non-tiered");
   // return quickly if possible
--- a/src/share/vm/compiler/disassembler.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/compiler/disassembler.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -522,7 +522,7 @@
   nm->method()->method_holder()->name()->print_symbol_on(env.output());
   env.output()->print(".");
   nm->method()->name()->print_symbol_on(env.output());
-  env.output()->print_cr("  [" PTR_FORMAT ", " PTR_FORMAT "]  %d bytes", p, end, ((jlong)(end - p)) * sizeof(unsigned char*));
+  env.output()->print_cr("  [" PTR_FORMAT ", " PTR_FORMAT "]  %d bytes", p, end, ((jlong)(end - p)));
 
   // If there has been profiling, print the buckets.
   if (FlatProfiler::bucket_start_for(p) != NULL) {
--- a/src/share/vm/compiler/oopMap.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/compiler/oopMap.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -176,8 +176,6 @@
 
 void OopMap::set_value(VMReg reg) {
   // At this time, we only need value entries in our OopMap when ZapDeadCompiledLocals is active.
-  if (ZapDeadCompiledLocals)
-    set_xxx(reg, OopMapValue::value_value, VMRegImpl::Bad());
 }
 
 
@@ -409,7 +407,7 @@
   }
 
   // We want coop, value and oop oop_types
-  int mask = OopMapValue::oop_value | OopMapValue::value_value | OopMapValue::narrowoop_value;
+  int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value;
   {
     for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) {
       omv = oms.current();
@@ -440,10 +438,6 @@
           }
 #endif // ASSERT
           oop_fn->do_oop(loc);
-        } else if ( omv.type() == OopMapValue::value_value ) {
-          assert((*loc) == (oop)NULL || !Universe::is_narrow_oop_base(*loc),
-                 "found invalid value pointer");
-          value_fn->do_oop(loc);
         } else if ( omv.type() == OopMapValue::narrowoop_value ) {
           narrowOop *nl = (narrowOop*)loc;
 #ifndef VM_LITTLE_ENDIAN
@@ -544,9 +538,6 @@
   case OopMapValue::oop_value:
     st->print("Oop");
     break;
-  case OopMapValue::value_value:
-    st->print("Value");
-    break;
   case OopMapValue::narrowoop_value:
     st->print("NarrowOop");
     break;
--- a/src/share/vm/compiler/oopMap.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/compiler/oopMap.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -54,7 +54,7 @@
 
 public:
   // Constants
-  enum { type_bits                = 5,
+  enum { type_bits                = 4,
          register_bits            = BitsPerShort - type_bits };
 
   enum { type_shift               = 0,
@@ -68,10 +68,9 @@
   enum oop_types {              // must fit in type_bits
          unused_value =0,       // powers of 2, for masking OopMapStream
          oop_value = 1,
-         value_value = 2,
-         narrowoop_value = 4,
-         callee_saved_value = 8,
-         derived_oop_value= 16 };
+         narrowoop_value = 2,
+         callee_saved_value = 4,
+         derived_oop_value= 8 };
 
   // Constructors
   OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
@@ -96,13 +95,11 @@
 
   // Querying
   bool is_oop()               { return mask_bits(value(), type_mask_in_place) == oop_value; }
-  bool is_value()             { return mask_bits(value(), type_mask_in_place) == value_value; }
   bool is_narrowoop()           { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
   bool is_callee_saved()      { return mask_bits(value(), type_mask_in_place) == callee_saved_value; }
   bool is_derived_oop()       { return mask_bits(value(), type_mask_in_place) == derived_oop_value; }
 
   void set_oop()              { set_value((value() & register_mask_in_place) | oop_value); }
-  void set_value()            { set_value((value() & register_mask_in_place) | value_value); }
   void set_narrowoop()          { set_value((value() & register_mask_in_place) | narrowoop_value); }
   void set_callee_saved()     { set_value((value() & register_mask_in_place) | callee_saved_value); }
   void set_derived_oop()      { set_value((value() & register_mask_in_place) | derived_oop_value); }
--- a/src/share/vm/gc_interface/collectedHeap.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/gc_interface/collectedHeap.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -84,6 +84,7 @@
 class CollectedHeap : public CHeapObj<mtInternal> {
   friend class VMStructs;
   friend class IsGCActiveMark; // Block structured external access to _is_gc_active
+  friend class Hsail;  // access to allocate_new_tlab
 
 #ifdef ASSERT
   static int       _fire_out_of_memory_count;
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 
 #include "precompiled.hpp"
+#include "code/compiledIC.hpp"
 #include "compiler/compileBroker.hpp"
 #include "compiler/disassembler.hpp"
 #include "runtime/javaCalls.hpp"
@@ -180,14 +181,14 @@
 
 // Records any Metadata values embedded in a Constant (e.g., the value returned by HotSpotResolvedObjectType.klass()).
 static void record_metadata_in_constant(oop constant, OopRecorder* oop_recorder) {
-  char kind = Kind::typeChar(Constant::kind(constant));
-  char wordKind = 'j';
-  if (kind == wordKind) {
-    oop obj = Constant::object(constant);
-    jlong prim = Constant::primitive(constant);
-    if (obj != NULL) {
-      record_metadata_reference(obj, prim, false, oop_recorder);
-    }
+  if (constant->is_a(HotSpotMetaspaceConstant::klass())) {
+    oop obj = HotSpotMetaspaceConstant::metaspaceObject(constant);
+    jlong prim = HotSpotMetaspaceConstant::primitive(constant);
+    assert(Kind::typeChar(Constant::kind(constant)) == 'j', "must have word kind");
+    assert(obj != NULL, "must have an object");
+    assert(prim != 0, "must have a primitive value");
+
+    record_metadata_reference(obj, prim, false, oop_recorder);
   }
 }
 
@@ -263,17 +264,19 @@
     return value;
   } else if (value->is_a(Constant::klass())){
     record_metadata_in_constant(value, oop_recorder);
-    jlong prim = Constant::primitive(value);
     if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BOOLEAN || type == T_BYTE) {
+      jlong prim = PrimitiveConstant::primitive(value);
       return new ConstantIntValue(*(jint*)&prim);
     } else if (type == T_LONG || type == T_DOUBLE) {
+      jlong prim = PrimitiveConstant::primitive(value);
       second = new ConstantIntValue(0);
       return new ConstantLongValue(prim);
     } else if (type == T_OBJECT) {
-      oop obj = Constant::object(value);
-      if (obj == NULL) {
+      if (value->is_a(NullConstant::klass())) {
         return new ConstantOopWriteValue(NULL);
       } else {
+        oop obj = HotSpotObjectConstant::object(value);
+        assert(obj != NULL, "null value must be in NullConstant");
         return new ConstantOopWriteValue(JNIHandles::make_local(obj));
       }
     } else if (type == T_ADDRESS) {
@@ -472,12 +475,35 @@
   _next_call_type = INVOKE_INVALID;
 }
 
+int CodeInstaller::estimate_stub_entries() {
+  // Estimate the number of static call stubs that might be emitted.
+  int static_call_stubs = 0;
+  for (int i = 0; i < _sites->length(); i++) {
+    oop site = ((objArrayOop) (_sites))->obj_at(i);
+    if (site->is_a(CompilationResult_Mark::klass())) {
+      oop id_obj = CompilationResult_Mark::id(site);
+      if (id_obj != NULL) {
+        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));
+        if (id == INVOKESTATIC || id == INVOKESPECIAL) {
+          static_call_stubs++;
+        }
+      }
+    }
+  }
+  return static_call_stubs;
+}
+
 // perform data and call relocation on the CodeBuffer
 bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) {
   int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo));
   char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
   buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo));
-  buffer.initialize_stubs_size(256);
+  // Allocate enough space in the stub section for the static call
+  // stubs.  Stubs have extra relocs but they are managed by the stub
+  // section itself so they don't need to be accounted for in the
+  // locs_buffer above.
+  buffer.initialize_stubs_size(estimate_stub_entries() * CompiledStaticCall::to_interp_stub_size());
   buffer.initialize_consts_size(_constants_size);
 
   _debug_recorder = new DebugInformationRecorder(_oop_recorder);
@@ -776,6 +802,10 @@
 
     TRACE_graal_3("method call");
     CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset);
+    if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) {
+      // Need a static call stub for transitions from compiled to interpreted.
+      CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset);
+    }
   }
 
   _next_call_type = INVOKE_INVALID;
--- a/src/share/vm/graal/graalCodeInstaller.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalCodeInstaller.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -102,7 +102,9 @@
   // extract the fields of the CompilationResult
   void initialize_fields(oop target_method);
   void initialize_assumptions(oop target_method);
-
+  
+  int estimate_stub_entries();
+  
   // perform data and call relocation on the CodeBuffer
   bool initialize_buffer(CodeBuffer& buffer);
 
@@ -120,7 +122,7 @@
   void record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects);
 
   void process_exception_handlers();
-
+  int estimateStubSpace(int static_call_stubs);
 };
 
 /**
@@ -128,20 +130,4 @@
  */
 Method* getMethodFromHotSpotMethod(oop hotspot_method);
 
-#ifdef TARGET_ARCH_x86
-# include "graalCodeInstaller_x86.hpp"
-#endif
-#ifdef TARGET_ARCH_sparc
-# include "graalCodeInstaller_sparc.hpp"
-#endif
-#ifdef TARGET_ARCH_zero
-# error
-#endif
-#ifdef TARGET_ARCH_arm
-# error
-#endif
-#ifdef TARGET_ARCH_ppc
-# error
-#endif
-
 #endif // SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -22,6 +22,7 @@
  */
 
 #include "precompiled.hpp"
+#include "code/scopeDesc.hpp"
 #include "memory/oopFactory.hpp"
 #include "oops/generateOopMap.hpp"
 #include "oops/fieldStreams.hpp"
@@ -39,6 +40,9 @@
 #include "graal/graalVMToCompiler.hpp"
 #include "gc_implementation/g1/heapRegion.hpp"
 #include "runtime/javaCalls.hpp"
+#include "runtime/deoptimization.hpp"
+#include "runtime/vframe.hpp"
+#include "runtime/vframe_hp.hpp"
 #include "runtime/vmStructs.hpp"
 #include "runtime/gpu.hpp"
 
@@ -153,7 +157,6 @@
   //------------------------------------------------------------------------------------------------
 
   set_address("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
-  set_address("uncommonTrapStub", SharedRuntime::deopt_blob()->uncommon_trap());
 
   set_address("registerFinalizerAddress", SharedRuntime::register_finalizer);
   set_address("exceptionHandlerForReturnAddressAddress", SharedRuntime::exception_handler_for_return_address);
@@ -187,6 +190,10 @@
   set_address("writeBarrierPostAddress", GraalRuntime::write_barrier_post);
   set_address("validateObject", GraalRuntime::validate_object);
 
+  set_address("deoptimizationFetchUnrollInfo", Deoptimization::fetch_unroll_info);
+  set_address("deoptimizationUncommonTrap", Deoptimization::uncommon_trap);
+  set_address("deoptimizationUnpackFrames", Deoptimization::unpack_frames);
+
   //------------------------------------------------------------------------------------------------
 
   set_int("graalCountersThreadOffset", in_bytes(JavaThread::graal_counters_offset()));
@@ -727,11 +734,9 @@
   HotSpotInstalledCode::set_codeBlob(hotspotInstalledCode, 0);
 C2V_END
 
-
-C2V_VMENTRY(jobject, readUnsafeUncompressedPointer, (JNIEnv *env, jobject, jobject o, jlong offset))
-  oop resolved_o = JNIHandles::resolve(o);
-  address addr = ((address)resolved_o) + offset;
-  return JNIHandles::make_local(*((oop*)addr));
+C2V_VMENTRY(jobject, getJavaMirror, (JNIEnv *env, jobject, jlong metaspace_klass))
+  Klass* klass = asKlass(metaspace_klass);
+  return JNIHandles::make_local(klass->java_mirror());
 C2V_END
 
 C2V_VMENTRY(jlong, readUnsafeKlassPointer, (JNIEnv *env, jobject, jobject o))
@@ -772,6 +777,254 @@
   return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL;
 C2V_END
 
+C2V_VMENTRY(jlong, getTimeStamp, (JNIEnv *env, jobject))
+  // tty->time_stamp is the time since VM start which should be used
+  // for all HotSpot log output when a timestamp is required.
+  return tty->time_stamp().milliseconds();
+C2V_END
+
+bool matches(jlongArray methods, Method* method) {
+  typeArrayOop methods_oop = (typeArrayOop) JNIHandles::resolve(methods);
+
+  for (int i = 0; i < methods_oop->length(); i++) {
+    if (methods_oop->long_at(i) == (jlong) method) {
+      return true;
+    }
+  }
+  return false;
+}
+
+C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv *env, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip))
+  ResourceMark rm;
+
+  if (!thread->has_last_Java_frame()) return NULL;
+  Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread);
+  HotSpotStackFrameReference::klass()->initialize(thread);
+
+  StackFrameStream fst(thread);
+  if (hs_frame != NULL) {
+    // look for the correct stack frame if one is given
+    intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame);
+    while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
+      fst.next();
+    }
+    if (fst.current()->sp() != stack_pointer) {
+      THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "stack frame not found")
+    }
+  }
+
+  int frame_number = 0;
+  vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
+  if (hs_frame != NULL) {
+    // look for the correct vframe within the stack frame if one is given
+    int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame);
+    while (frame_number < last_frame_number) {
+      if (vf->is_top()) {
+        THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "invalid frame number")
+      }
+      vf = vf->sender();
+      frame_number ++;
+    }
+    // move one frame forward
+    if (vf->is_top()) {
+      if (fst.is_done()) {
+        return NULL;
+      }
+      fst.next();
+      vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
+      frame_number = 0;
+    } else {
+      vf = vf->sender();
+      frame_number++;
+    }
+  }
+
+  while (true) {
+    // look for the given method
+    while (true) {
+      StackValueCollection* locals = NULL;
+      if (vf->is_compiled_frame()) {
+        // compiled method frame
+        compiledVFrame* cvf = compiledVFrame::cast(vf);
+        if (methods == NULL || matches(methods, cvf->method())) {
+          if (initialSkip > 0) {
+            initialSkip --;
+          } else {
+            GrowableArray<ScopeValue*>* objects = cvf->scope()->objects();
+            bool reallocated = false;
+            if (objects != NULL) {
+              reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD);
+              if (reallocated) {
+                Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects);
+              }
+
+              GrowableArray<ScopeValue*>* local_values = cvf->scope()->locals();
+              typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread);
+              for (int i = 0; i < local_values->length(); i++) {
+                ScopeValue* value = local_values->at(i);
+                if (value->is_object()) {
+                  array->bool_at_put(i, true);
+                }
+              }
+              HotSpotStackFrameReference::set_localIsVirtual(result, array());
+            } else {
+              HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
+            }
+
+            locals = cvf->locals();
+            HotSpotStackFrameReference::set_bci(result, cvf->bci());
+            HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) cvf->method());
+          }
+        }
+      } else if (vf->is_interpreted_frame()) {
+        // interpreted method frame
+        interpretedVFrame* ivf = interpretedVFrame::cast(vf);
+        if (methods == NULL || matches(methods, ivf->method())) {
+          if (initialSkip > 0) {
+            initialSkip --;
+          } else {
+            locals = ivf->locals();
+            HotSpotStackFrameReference::set_bci(result, ivf->bci());
+            HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) ivf->method());
+            HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
+          }
+        }
+      }
+
+      // locals != NULL means that we found a matching frame and result is already partially initialized
+      if (locals != NULL) {
+        HotSpotStackFrameReference::set_compilerToVM(result, JNIHandles::resolve(compilerToVM));
+        HotSpotStackFrameReference::set_stackPointer(result, (jlong) fst.current()->sp());
+        HotSpotStackFrameReference::set_frameNumber(result, frame_number);
+
+        // initialize the locals array
+        objArrayHandle array = oopFactory::new_objectArray(locals->size(), thread);
+        for (int i = 0; i < locals->size(); i++) {
+          StackValue* var = locals->at(i);
+          if (var->type() == T_OBJECT) {
+            array->obj_at_put(i, locals->at(i)->get_obj()());
+          }
+        }
+        HotSpotStackFrameReference::set_locals(result, array());
+
+        return JNIHandles::make_local(thread, result());
+      }
+
+      if (vf->is_top()) {
+        break;
+      }
+      frame_number++;
+      vf = vf->sender();
+    } // end of vframe loop
+
+    if (fst.is_done()) {
+      break;
+    }
+    fst.next();
+    vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
+    frame_number = 0;
+  } // end of frame loop
+
+  // the end was reached without finding a matching method
+  return NULL;
+C2V_END
+
+
+
+// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
+C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv *env, jobject, jobject hs_frame, bool invalidate))
+  ResourceMark rm;
+
+  if (hs_frame == NULL) {
+    THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null")
+  }
+
+  HotSpotStackFrameReference::klass()->initialize(thread);
+
+  // look for the given stack frame
+  StackFrameStream fst(thread);
+  intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame);
+  while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
+    fst.next();
+  }
+  if (fst.current()->sp() != stack_pointer) {
+    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found")
+  }
+
+  if (invalidate) {
+    assert(fst.current()->cb()->is_nmethod(), "nmethod expected");
+    ((nmethod*) fst.current()->cb())->make_not_entrant();
+  }
+  Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none);
+
+  vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
+  if (!vf->is_compiled_frame()) {
+    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected")
+  }
+
+  GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10);
+  while (true) {
+    assert(vf->is_compiled_frame(), "Wrong frame type");
+    virtualFrames->push(compiledVFrame::cast(vf));
+    if (vf->is_top()) {
+      break;
+    }
+    vf = vf->sender();
+  }
+
+  int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame);
+  if (last_frame_number >= virtualFrames->length()) {
+    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number")
+  }
+
+  // Reallocate the non-escaping objects and restore their fields.
+  assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope");
+  GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects();
+
+  if (objects == NULL) {
+    // no objects to materialize
+    return;
+  }
+
+  bool reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD);
+  if (reallocated) {
+    Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects);
+
+    for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) {
+      compiledVFrame* cvf = virtualFrames->at(frame_index);
+
+      GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals();
+      StackValueCollection* locals = cvf->locals();
+
+      if (locals != NULL) {
+        for (int i2 = 0; i2 < locals->size(); i2++) {
+          StackValue* var = locals->at(i2);
+          if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) {
+            jvalue val;
+            val.l = (jobject) locals->at(i2)->get_obj()();
+            cvf->update_local(T_OBJECT, i2, val);
+          }
+        }
+      }
+    }
+
+    // all locals are materialized by now
+    HotSpotStackFrameReference::set_localIsVirtual(hs_frame, NULL);
+
+    // update the locals array
+    objArrayHandle array = (objArrayOop) HotSpotStackFrameReference::locals(hs_frame);
+    StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals();
+    for (int i = 0; i < locals->size(); i++) {
+      StackValue* var = locals->at(i);
+      if (var->type() == T_OBJECT) {
+        array->obj_at_put(i, locals->at(i)->get_obj()());
+      }
+    }
+  }
+C2V_END
+
+
+
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
 
@@ -784,9 +1037,12 @@
 #define CLASS                 "Ljava/lang/Class;"
 #define STACK_TRACE_ELEMENT   "Ljava/lang/StackTraceElement;"
 #define HS_RESOLVED_METHOD    "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod;"
+#define RESOLVED_METHOD       "Lcom/oracle/graal/api/meta/ResolvedJavaMethod;"
 #define HS_COMPILED_CODE      "Lcom/oracle/graal/hotspot/HotSpotCompiledCode;"
 #define HS_CONFIG             "Lcom/oracle/graal/hotspot/HotSpotVMConfig;"
 #define HS_INSTALLED_CODE     "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
+#define NODE_CLASS            "Lcom/oracle/graal/graph/NodeClass;"
+#define HS_STACK_FRAME_REF    "Lcom/oracle/graal/hotspot/HotSpotStackFrameReference;"
 #define METASPACE_KLASS       "J"
 #define METASPACE_METHOD      "J"
 #define METASPACE_METHOD_DATA "J"
@@ -835,13 +1091,16 @@
   {CC"getLocalVariableTableLength",                  CC"("METASPACE_METHOD")I",                                        FN_PTR(getLocalVariableTableLength)},
   {CC"reprofile",                                    CC"("METASPACE_METHOD")V",                                        FN_PTR(reprofile)},
   {CC"invalidateInstalledCode",                      CC"("HS_INSTALLED_CODE")V",                                       FN_PTR(invalidateInstalledCode)},
-  {CC"readUnsafeUncompressedPointer",                CC"("OBJECT"J)"OBJECT,                                            FN_PTR(readUnsafeUncompressedPointer)},
+  {CC"getJavaMirror",                                CC"("METASPACE_KLASS")"CLASS,                                     FN_PTR(getJavaMirror)},
   {CC"readUnsafeKlassPointer",                       CC"("OBJECT")J",                                                  FN_PTR(readUnsafeKlassPointer)},
   {CC"collectCounters",                              CC"()[J",                                                         FN_PTR(collectCounters)},
   {CC"getGPUs",                                      CC"()"STRING,                                                     FN_PTR(getGPUs)},
   {CC"allocateCompileId",                            CC"("METASPACE_METHOD"I)I",                                       FN_PTR(allocateCompileId)},
   {CC"isMature",                                     CC"("METASPACE_METHOD_DATA")Z",                                   FN_PTR(isMature)},
   {CC"hasCompiledCodeForOSR",                        CC"("METASPACE_METHOD"II)Z",                                      FN_PTR(hasCompiledCodeForOSR)},
+  {CC"getTimeStamp",                                 CC"()J",                                                          FN_PTR(getTimeStamp)},
+  {CC"getNextStackFrame",                            CC"("HS_STACK_FRAME_REF "[JI)"HS_STACK_FRAME_REF,                 FN_PTR(getNextStackFrame)},
+  {CC"materializeVirtualObjects",                    CC"("HS_STACK_FRAME_REF"Z)V",                                     FN_PTR(materializeVirtualObjects)},
 };
 
 int CompilerToVM_methods_count() {
--- a/src/share/vm/graal/graalGlobals.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalGlobals.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -85,6 +85,9 @@
   develop(bool, TraceUncollectedSpeculations, false,                        \
           "Print message when a failed speculation was not collected")      \
                                                                             \
+  product(bool, UseHSAILDeoptimization, true,                               \
+          "Code gen and runtime support for deoptimizing HSAIL kernels")    \
+                                                                            \
   product(bool, GPUOffload, false,                                          \
           "Offload execution to GPU whenever possible")                     \
                                                                             \
--- a/src/share/vm/graal/graalJavaAccess.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -201,8 +201,18 @@
   end_class                                                                                                                                                    \
   start_class(Constant)                                                                                                                                        \
     oop_field(Constant, kind, "Lcom/oracle/graal/api/meta/Kind;")                                                                                              \
-    oop_field(Constant, object, "Ljava/lang/Object;")                                                                                                          \
-    long_field(Constant, primitive)                                                                                                                            \
+  end_class                                                                                                                                                    \
+  start_class(PrimitiveConstant)                                                                                                                               \
+    long_field(PrimitiveConstant, primitive)                                                                                                                   \
+  end_class                                                                                                                                                    \
+  start_class(NullConstant)                                                                                                                                    \
+  end_class                                                                                                                                                    \
+  start_class(HotSpotObjectConstant)                                                                                                                           \
+    oop_field(HotSpotObjectConstant, object, "Ljava/lang/Object;")                                                                                             \
+  end_class                                                                                                                                                    \
+  start_class(HotSpotMetaspaceConstant)                                                                                                                        \
+    long_field(HotSpotMetaspaceConstant, primitive)                                                                                                            \
+    oop_field(HotSpotMetaspaceConstant, metaspaceObject, "Ljava/lang/Object;")                                                                                 \
   end_class                                                                                                                                                    \
   start_class(Kind)                                                                                                                                            \
     char_field(Kind, typeChar)                                                                                                                                 \
@@ -239,7 +249,16 @@
   end_class                                                                                                                                                    \
   start_class(SpeculationLog)                                                                                                                                  \
     oop_field(SpeculationLog, lastFailed, "Ljava/lang/Object;")                                                                                                \
-  end_class
+  end_class                                                                                                                                                    \
+  start_class(HotSpotStackFrameReference)                                                                                                                      \
+    oop_field(HotSpotStackFrameReference, compilerToVM, "Lcom/oracle/graal/hotspot/bridge/CompilerToVM;")                                                      \
+    long_field(HotSpotStackFrameReference, stackPointer)                                                                                                       \
+    int_field(HotSpotStackFrameReference, frameNumber)                                                                                                         \
+    int_field(HotSpotStackFrameReference, bci)                                                                                                                 \
+    long_field(HotSpotStackFrameReference, metaspaceMethod)                                                                                                    \
+    oop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;")                                                                                       \
+    oop_field(HotSpotStackFrameReference, localIsVirtual, "[Z")                                                                                                \
+  end_class                                                                                                                                                    \
   /* end*/
 
 #define START_CLASS(name)                                                                                                                                      \
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/graalVMToCompiler.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -49,12 +49,12 @@
 }
 
 Handle VMToCompiler::truffleRuntime() {
-  Symbol* name = vmSymbols::com_oracle_graal_truffle_GraalTruffleRuntime();
+  Symbol* name = vmSymbols::com_oracle_graal_truffle_hotspot_HotSpotTruffleRuntime();
   KlassHandle klass = loadClass(name);
 
   JavaValue result(T_OBJECT);
   JavaCalls::call_static(&result, klass, vmSymbols::makeInstance_name(), vmSymbols::makeInstance_signature(), Thread::current());
-  check_pending_exception("Couldn't initialize GraalTruffleRuntime");
+  check_pending_exception("Couldn't initialize HotSpotTruffleRuntime");
   return Handle((oop) result.get_jobject());
 }
 
--- a/src/share/vm/graal/vmStructs_graal.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/graal/vmStructs_graal.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -31,9 +31,10 @@
 #include "graal/graalEnv.hpp"
 
 #define VM_STRUCTS_GRAAL(nonstatic_field, static_field)                       \
-  nonstatic_field(ThreadShadow, _pending_deoptimization, int)                 \
-  nonstatic_field(ThreadShadow, _pending_failed_speculation, oop)             \
-  nonstatic_field(MethodData,   _graal_node_count, int)                       \
+  nonstatic_field(InstanceKlass, _graal_node_class, oop)                      \
+  nonstatic_field(ThreadShadow,  _pending_deoptimization, int)                \
+  nonstatic_field(ThreadShadow,  _pending_failed_speculation, oop)            \
+  nonstatic_field(MethodData,    _graal_node_count, int)                      \
 
 #define VM_TYPES_GRAAL(declare_type, declare_toplevel_type)                   \
 
--- a/src/share/vm/interpreter/abstractInterpreter.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/interpreter/abstractInterpreter.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -82,9 +82,6 @@
     zerolocals_synchronized,                                    // method needs locals initialization & is synchronized
     native,                                                     // native method
     native_synchronized,                                        // native method & is synchronized
-#ifdef GRAAL
-    execute_compiled_method,                                    // direct call to compiled method address
-#endif
     empty,                                                      // empty method (code: _return)
     accessor,                                                   // accessor method (code: _aload_0, _getfield, _(a|i)return)
     abstract,                                                   // abstract method (throws an AbstractMethodException)
--- a/src/share/vm/interpreter/interpreter.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/interpreter/interpreter.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -188,13 +188,6 @@
   // Method handle primitive?
   if (m->is_method_handle_intrinsic()) {
     vmIntrinsics::ID id = m->intrinsic_id();
-#ifdef GRAAL
-    if (id == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod) {
-      // Special method kind for directly executing the verified entry point
-      // of a given nmethod.
-      return AbstractInterpreter::execute_compiled_method;
-    }
-#endif
     assert(MethodHandles::is_signature_polymorphic(id), "must match an intrinsic");
     MethodKind kind = (MethodKind)( method_handle_invoke_FIRST +
                                     ((int)id - vmIntrinsics::FIRST_MH_SIG_POLY) );
@@ -305,9 +298,6 @@
     case zerolocals_synchronized: tty->print("zerolocals_synchronized"); break;
     case native                 : tty->print("native"                 ); break;
     case native_synchronized    : tty->print("native_synchronized"    ); break;
-#ifdef GRAAL
-    case execute_compiled_method: tty->print("execute_compiled_method"); break;
-#endif
     case empty                  : tty->print("empty"                  ); break;
     case accessor               : tty->print("accessor"               ); break;
     case abstract               : tty->print("abstract"               ); break;
--- a/src/share/vm/interpreter/interpreterRuntime.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -500,11 +500,6 @@
   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
 IRT_END
 
-
-IRT_ENTRY(void, InterpreterRuntime::throw_InvalidInstalledCodeException(JavaThread* thread))
-  THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException());
-IRT_END
-
 //------------------------------------------------------------------------------------------------------------------------
 // Fields
 //
--- a/src/share/vm/interpreter/interpreterRuntime.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/interpreter/interpreterRuntime.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -89,7 +89,6 @@
   // Exceptions thrown by the interpreter
   static void    throw_AbstractMethodError(JavaThread* thread);
   static void    throw_IncompatibleClassChangeError(JavaThread* thread);
-  static void    throw_InvalidInstalledCodeException(JavaThread* thread);
   static void    throw_StackOverflowError(JavaThread* thread);
   static void    throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index);
   static void    throw_ClassCastException(JavaThread* thread, oopDesc* obj);
--- a/src/share/vm/interpreter/templateInterpreter.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/interpreter/templateInterpreter.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -369,9 +369,6 @@
   method_entry(zerolocals)
   method_entry(zerolocals_synchronized)
   method_entry(empty)
-#ifdef GRAAL
-  method_entry(execute_compiled_method)
-#endif
   method_entry(accessor)
   method_entry(abstract)
   method_entry(java_lang_math_sin  )
--- a/src/share/vm/oops/instanceKlass.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/oops/instanceKlass.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -288,6 +288,9 @@
   set_init_state(InstanceKlass::allocated);
   set_init_thread(NULL);
   set_reference_type(rt);
+#ifdef GRAAL
+  set_graal_node_class(NULL);
+#endif
   set_oop_map_cache(NULL);
   set_jni_ids(NULL);
   set_osr_nmethods_head(NULL);
@@ -317,6 +320,12 @@
   set_layout_helper(Klass::instance_layout_helper(0, true));
 }
 
+#ifdef GRAAL
+void InstanceKlass::oops_do(OopClosure* cl) {
+  Klass::oops_do(cl);
+  cl->do_oop(adr_graal_node_class());
+}
+#endif
 
 void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
                                        Array<Method*>* methods) {
@@ -1192,6 +1201,21 @@
     JavaValue result(T_VOID);
     JavaCalls::call(&result, h_method, &args, CHECK); // Static call (no args)
   }
+
+#ifdef GRAAL
+  if (this_oop->is_subtype_of(SystemDictionary::Node_klass())) {
+    if (this_oop() != SystemDictionary::Node_klass()) {
+      // Create the NodeClass for a Node subclass.
+      TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/Class;)Lcom/oracle/graal/graph/NodeClass;", CHECK);
+      JavaValue result(T_OBJECT);
+      JavaCalls::call_static(&result, SystemDictionary::NodeClass_klass(), vmSymbols::get_name(), sig, this_oop->java_mirror(), CHECK);
+      this_oop->set_graal_node_class((oop) result.get_jobject());
+    } else {
+      // A NodeClass cannot be created for Node due to checks in
+      // NodeClass.FieldScanner.scanField()
+    }
+  }
+#endif
 }
 
 
@@ -2254,6 +2278,10 @@
   }
   init_implementor();
 
+#ifdef GRAAL
+  set_graal_node_class(NULL);
+#endif
+
   constants()->remove_unshareable_info();
 
   for (int i = 0; i < methods()->length(); i++) {
--- a/src/share/vm/oops/instanceKlass.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/oops/instanceKlass.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -241,6 +241,10 @@
   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
   int             _vtable_len;           // length of Java vtable (in words)
   int             _itable_len;           // length of Java itable (in words)
+#ifdef GRAAL
+  // com/oracle/graal/graph/NodeClass instance mirroring this class
+  oop             _graal_node_class;
+#endif
   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
   MemberNameTable* _member_names;        // Member names
   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
@@ -745,6 +749,16 @@
   void call_class_initializer(TRAPS);
   void set_initialization_state_and_notify(ClassState state, TRAPS);
 
+#ifdef GRAAL
+  // Graal com.oracle.graal.graph.NodeClass mirror
+  oop graal_node_class()           { return _graal_node_class;               }
+  void set_graal_node_class(oop m) { klass_oop_store(&_graal_node_class, m); }
+  oop* adr_graal_node_class()      { return (oop*)&this->_graal_node_class;  }
+
+  // GC support
+  virtual void oops_do(OopClosure* cl);
+#endif
+
   // OopMapCache support
   OopMapCache* oop_map_cache()               { return _oop_map_cache; }
   void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }
--- a/src/share/vm/oops/klass.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/oops/klass.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -298,10 +298,6 @@
   static ByteSize modifier_flags_offset()        { return in_ByteSize(offset_of(Klass, _modifier_flags)); }
   static ByteSize layout_helper_offset()         { return in_ByteSize(offset_of(Klass, _layout_helper)); }
   static ByteSize access_flags_offset()          { return in_ByteSize(offset_of(Klass, _access_flags)); }
-#ifdef GRAAL
-  static ByteSize next_sibling_offset()          { return in_ByteSize(offset_of(Klass, _next_sibling)); }
-  static ByteSize subklass_offset()              { return in_ByteSize(offset_of(Klass, _subklass)); }
-#endif
 
   // Unpacking layout_helper:
   enum {
--- a/src/share/vm/oops/method.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/oops/method.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -216,7 +216,7 @@
 
   Thread* myThread    = Thread::current();
   methodHandle h_this(myThread, this);
-#ifdef ASSERT
+#if defined(ASSERT) && !defined(GRAAL)
   bool has_capability = myThread->is_VM_thread() ||
                         myThread->is_ConcurrentGC_thread() ||
                         myThread->is_GC_task_thread();
@@ -742,13 +742,10 @@
 
 bool Method::is_always_compilable() const {
   // Generated adapters must be compiled
-  if (is_method_handle_intrinsic()) {
-    bool is_executeCompiled = intrinsic_id() == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod;
-    if (is_synthetic() || is_executeCompiled) {
-      assert(!is_not_c1_compilable() || is_executeCompiled, "sanity check");
-      assert(!is_not_c2_compilable() || is_executeCompiled, "sanity check");
-      return true;
-    }
+  if (is_method_handle_intrinsic() && is_synthetic()) {
+    assert(!is_not_c1_compilable(), "sanity check");
+    assert(!is_not_c2_compilable(), "sanity check");
+    return true;
   }
 
   return false;
@@ -892,14 +889,6 @@
 
   // ONLY USE the h_method now as make_adapter may have blocked
 
-#ifdef GRAAL
-  // Check for special intrinsic that executes a compiled method.
-  if (h_method->intrinsic_id() == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod) {
-    // Actively install the stub for calling the intrinsic from compiled code.
-    CompileBroker::compile_method(h_method, InvocationEntryBci, CompLevel_highest_tier,
-                                  methodHandle(), CompileThreshold, "executeCompiledMethod", CHECK);
-  }
-#endif
 }
 
 address Method::make_adapters(methodHandle mh, TRAPS) {
@@ -1053,7 +1042,7 @@
 bool Method::is_method_handle_intrinsic() const {
   vmIntrinsics::ID iid = intrinsic_id();
   return (MethodHandles::is_signature_polymorphic(iid) &&
-          MethodHandles::is_signature_polymorphic_intrinsic(iid)) || iid == vmIntrinsics::_CompilerToVMImpl_executeCompiledMethod;
+          MethodHandles::is_signature_polymorphic_intrinsic(iid));
 }
 
 bool Method::has_member_arg() const {
--- a/src/share/vm/prims/jvm.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/prims/jvm.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -1121,18 +1121,6 @@
   return (jobject) JNIHandles::make_local(env, pd);
 JVM_END
 
-// Preserved in Graal repo so that linking against a JDK7 libjava.so works
-JVM_ENTRY(void, JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain))
-  JVMWrapper("JVM_SetProtectionDomain");
-
-  ResourceMark rm(THREAD);
-  const char* msg = "Obsolete JVM_SetProtectionDomain function called";
-  size_t buflen = strlen(msg);
-  char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
-  jio_snprintf(buf, buflen, msg);
-  THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
-JVM_END
-
 static bool is_authorized(Handle context, instanceKlassHandle klass, TRAPS) {
   // If there is a security manager and protection domain, check the access
   // in the protection domain, otherwise it is authorized.
--- a/src/share/vm/prims/jvm.h	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/prims/jvm.h	Wed Apr 16 14:02:52 2014 +0200
@@ -477,11 +477,6 @@
 JNIEXPORT jboolean JNICALL
 JVM_IsArrayClass(JNIEnv *env, jclass cls);
 
-// Preserved in Graal repo so that linking against a JDK7 libjava.so works
-JNIEXPORT void JNICALL
-JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain);
-
-
 JNIEXPORT jboolean JNICALL
 JVM_IsPrimitiveClass(JNIEnv *env, jclass cls);
 
--- a/src/share/vm/runtime/arguments.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -35,7 +35,6 @@
 #include "prims/jvmtiExport.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/globals_extension.hpp"
-#include "runtime/gpu.hpp"
 #include "runtime/java.hpp"
 #include "services/management.hpp"
 #include "services/memTracker.hpp"
@@ -182,6 +181,13 @@
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(),  false));
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(),  false));
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(),  true));
+#ifdef GRAAL
+#ifdef GRAAL_VERSION
+  PropertyList_add(&_system_properties, new SystemProperty("graal.version", GRAAL_VERSION,  true));
+#else
+  PropertyList_add(&_system_properties, new SystemProperty("graal.version", "unknown",  true));
+#endif
+#endif
 
   // following are JVMTI agent writeable properties.
   // Properties values are set to NULL and they are
--- a/src/share/vm/runtime/arguments.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/arguments.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -264,9 +264,6 @@
   static SystemProperty *_java_home;
   static SystemProperty *_java_class_path;
   static SystemProperty *_sun_boot_class_path;
-#ifdef GRAAL
-  static SystemProperty *_graal_gpu_isalist;
-#endif
 
   // Meta-index for knowing what packages are in the boot class path
   static char* _meta_index_path;
--- a/src/share/vm/runtime/deoptimization.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/deoptimization.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -357,7 +357,10 @@
     unpack_sp = deoptee.unextended_sp();
 
 #ifdef ASSERT
-  assert(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub(), "just checking");
+  assert(cb->is_deoptimization_stub() ||
+         cb->is_uncommon_trap_stub() ||
+         strcmp("Stub<DeoptimizationStub.uncommonTrapHandler>", cb->name()) == 0,
+         err_msg("unexpected code blob: %s", cb->name()));
 #endif
 #else
   intptr_t* unpack_sp = stub_frame.sender(&dummy_map).unextended_sp();
--- a/src/share/vm/runtime/deoptimization.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/deoptimization.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -139,6 +139,8 @@
   static void revoke_biases_of_monitors(CodeBlob* cb);
 
 #if defined(COMPILER2) || defined(GRAAL)
+GRAAL_ONLY(public:)
+
   // Support for restoring non-escaping objects
   static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS);
   static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type);
--- a/src/share/vm/runtime/mutexLocker.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/mutexLocker.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -280,6 +280,7 @@
   def(JfrStream_lock               , Mutex,   nonleaf+2,   true);
   def(JfrStacktrace_lock           , Mutex,   special,     true );
 #endif
+
 }
 
 GCMutexLocker::GCMutexLocker(Monitor * mutex) {
--- a/src/share/vm/runtime/sharedRuntime.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/sharedRuntime.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -752,11 +752,6 @@
   throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError(), "vtable stub");
 JRT_END
 
-JRT_ENTRY(void, SharedRuntime::throw_InvalidInstalledCodeException(JavaThread* thread))
-  // These errors occur only at call sites
-  throw_and_post_jvmti_exception(thread, vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException());
-JRT_END
-
 JRT_ENTRY(void, SharedRuntime::throw_ArithmeticException(JavaThread* thread))
   throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArithmeticException(), "/ by zero");
 JRT_END
--- a/src/share/vm/runtime/sharedRuntime.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/sharedRuntime.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -186,7 +186,6 @@
   };
   static void    throw_AbstractMethodError(JavaThread* thread);
   static void    throw_IncompatibleClassChangeError(JavaThread* thread);
-  static void    throw_InvalidInstalledCodeException(JavaThread* thread);
   static void    throw_ArithmeticException(JavaThread* thread);
   static void    throw_NullPointerException(JavaThread* thread);
   static void    throw_NullPointerException_at_call(JavaThread* thread);
--- a/src/share/vm/runtime/stubRoutines.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/stubRoutines.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -51,7 +51,6 @@
 address StubRoutines::_forward_exception_entry                  = NULL;
 address StubRoutines::_throw_AbstractMethodError_entry          = NULL;
 address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
-address StubRoutines::_throw_InvalidInstalledCodeException_entry = NULL;
 address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
 address StubRoutines::_throw_StackOverflowError_entry           = NULL;
 address StubRoutines::_handler_for_unsafe_access_entry          = NULL;
--- a/src/share/vm/runtime/stubRoutines.hpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/stubRoutines.hpp	Wed Apr 16 14:02:52 2014 +0200
@@ -128,7 +128,6 @@
   static address _catch_exception_entry;
   static address _throw_AbstractMethodError_entry;
   static address _throw_IncompatibleClassChangeError_entry;
-  static address _throw_InvalidInstalledCodeException_entry;
   static address _throw_NullPointerException_at_call_entry;
   static address _throw_StackOverflowError_entry;
   static address _handler_for_unsafe_access_entry;
@@ -273,7 +272,6 @@
   // Implicit exceptions
   static address throw_AbstractMethodError_entry()         { return _throw_AbstractMethodError_entry; }
   static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; }
-  static address throw_InvalidInstalledCodeException_entry(){ return _throw_InvalidInstalledCodeException_entry; }
   static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; }
   static address throw_StackOverflowError_entry()          { return _throw_StackOverflowError_entry; }
 
--- a/src/share/vm/runtime/vmStructs.cpp	Tue Apr 15 19:08:29 2014 +0200
+++ b/src/share/vm/runtime/vmStructs.cpp	Wed Apr 16 14:02:52 2014 +0200
@@ -576,6 +576,7 @@
   nonstatic_field(ThreadLocalAllocBuffer,      _start,                                        HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _top,                                          HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _end,                                          HeapWord*)                             \
+  nonstatic_field(ThreadLocalAllocBuffer,      _pf_top,                                       HeapWord*)                             \
   nonstatic_field(ThreadLocalAllocBuffer,      _desired_size,                                 size_t)                                \
   nonstatic_field(ThreadLocalAllocBuffer,      _refill_waste_limit,                           size_t)                                \
      static_field(ThreadLocalAllocBuffer,      _target_refills,                               unsigned)                              \
@@ -2422,6 +2423,7 @@
   declare_constant(Method::_force_inline)                                 \
   declare_constant(Method::_dont_inline)                                  \
   declare_constant(Method::_hidden)                                       \
+  declare_constant(Method::nonvirtual_vtable_index)                       \
                                                                           \
   declare_constant(ConstMethod::_has_linenumber_table)                    \
   declare_constant(ConstMethod::_has_checked_exceptions)                  \
@@ -2646,7 +2648,6 @@
   declare_constant(OopMapValue::register_mask_in_place)                   \
   declare_constant(OopMapValue::unused_value)                             \
   declare_constant(OopMapValue::oop_value)                                \
-  declare_constant(OopMapValue::value_value)                              \
   declare_constant(OopMapValue::narrowoop_value)                          \
   declare_constant(OopMapValue::callee_saved_value)                       \
   declare_constant(OopMapValue::derived_oop_value)                        \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/baseline_whitelist.txt	Wed Apr 16 14:02:52 2014 +0200
@@ -0,0 +1,7 @@
+com.oracle.graal.jtt.loop.Loop03
+com.oracle.graal.jtt.bytecode.BC_iadd
+com.oracle.graal.jtt.bytecode.BC_iadd2
+com.oracle.graal.jtt.bytecode.BC_iadd3
+com.oracle.graal.jtt.bytecode.BC_ifeq_2
+com.oracle.graal.jtt.bytecode.BC_ifeq_3
+com.oracle.graal.jtt.bytecode.BC_ifeq