changeset 19033:74b144f7c54a

Merge.
author Josef Eisl <josef.eisl@jku.at>
date Wed, 28 Jan 2015 19:32:47 +0100
parents b646e37bc989 (current diff) 9c2396ef02db (diff)
children 94ca6ce786ee
files graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/AbstractHSAILAssembler.java graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAddress.java graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/AbstractPTXAssembler.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAddress.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAsmOptions.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXMacroAssembler.java graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXStateSpace.java graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/ForceDeoptSubstitutions.java graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntInstIITest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntInstIJTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntStatAIITest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntStatAIJTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjInstIITest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjInstIJTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjStatIITest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjStatIJTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndSetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndSetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicReferenceGetAndSetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany16384Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany5000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany8192Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654HighTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany99999Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchManyBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost1000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000StressGCTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle16384Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle5000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle8192Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingleBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckDoubleNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFailsInMiddleTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFloatNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckInlineTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckLongNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CallTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DVec3.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleAbsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleCeilTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleFloorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleNegTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleRintTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleSqrtTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewFloatStringTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewFloatTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewIntArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewIntegerTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStoreFieldTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringConcatTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringInternTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringLargeRangeTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3ArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Base.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3LargeRangeDisp3Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3LargeRangeTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3MediumRangeTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Partial2Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3PartialTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FcompUnorderedTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyRangeFinalTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatAbsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDivPrecisionTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatNegTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatSqrtTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/InstanceOfTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/InstanceOfTwoLevelTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAbsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddIndexTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseNotTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftLeftTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightUnsignedTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDivTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubleConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubledTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLookupSwitchTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntModTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntMulTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntNegTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSqrAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredGidCmpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTernaryTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCatchNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullNonArrayParamCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullParamCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSubTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSumArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTableSwitchTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTestBranchTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongAbsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseNotTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftLeftTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightUnsignedTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongModTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongNegTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/NestedStaticCallTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/NestedVirtualCallTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany5000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany99999Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptManyBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost5000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost99999Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMostBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptSingle100Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptSingle20000Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreNullTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/SingleExceptionTestBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticCallTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillBoundsCatchOneTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillBoundsCatchTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticIntSpillTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelBoundsCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethodThreeIntArrays.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethodTwoIntArrays.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyCallTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodySpillTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringEqualsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringSwitchTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamClassCastNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamClassCastTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamFloatCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntFloatCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullCheckNonZeroBciTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullParamCheckTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjFieldTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/VolatileIntTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayFieldAccessTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListSetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListStreamTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetGidTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntDecAndGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndDecTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndIncTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntIncAndGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongAddAndGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndAddTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndIncTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongIncAndGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/BigIntegerSquaredTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Body.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayCopyConjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayCopyDisjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CharArrayCopyConjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CharArrayCopyDisjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CountMatchesBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAcosTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAsinTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAtan2Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAtanTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCbrtTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCosTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCoshTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleExpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleExpm1Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleFieldAccessTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleGetExponentTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleHypotTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleIeeeRemainderTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleLog10Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleLogTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleMathBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleMathLargeBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleNextAfterTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleNextUpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoublePowTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleRoundTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleScalbTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSignumTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSinTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSinhTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTanTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTanhTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleToLongTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTwoInputMathBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleUlpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DremTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FibRecursionTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplyRangeFinalTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplySingleOutTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAcosTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAsinTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAtan2Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAtanTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCbrtTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCondMoveTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCosTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCoshTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatExpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatExpm1Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatFieldAccessTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatFieldWriteTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatGetExponentTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatIeeeRemainderTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatLog10Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatLogTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatMathBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatMathLargeBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatNextAfterTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatNextUpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatPowTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatRoundTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatScalbTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSignumTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSinTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSinhTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTanTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTanhTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTwoInputMathBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatUlpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ForEachToGraalTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/HashMapGetTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceNBodyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOfNullTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOfTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOopNBodyAccTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOopNBodyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntArrayCopyConjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntArrayCopyDisjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntCondMoveTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntFieldAccessTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntNegateInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntSquaredInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntSquaredStaticTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntToLongTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntegerObjectCreateTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntegerObjectReadTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongAdderTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongArrayCopyConjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongArrayCopyDisjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongCmpTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongCondMoveTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongNegateInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongSquaredInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Main.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MandelInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MandelStaticTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MathTestBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MoreThanEightArgsOOBTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MoreThanEightArgsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NewStringEqualsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NewStringLenTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewObjWithArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyConjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyDisjointNonExactTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyDisjointTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectArrayInstanceDerivedTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectArrayInstanceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectStoreNullTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectStoreTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/OverloadMethodTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceMaxTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceMinTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceSumTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ShortArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticFloatFieldReadTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntField2ReadTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldReadTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldSameClassTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldWriteTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticNBodyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringBuilderTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringContainsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringEqualsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringHashTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringLenTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringSubsequenceTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringSubstringTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringUtilsCountMatches2Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringUtilsCountMatchesTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/SynchronizedMethodTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/TooSimpleNewTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/TwoDIntArrayTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VarArgsTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamFloatCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamIntCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamIntFloatCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamObjCaptureTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamObjFieldTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyDeoptTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VectorStreamTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCall3Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCall4Test.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCallBase.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCallTest.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/CompileAndDispatch.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRBuilder.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/BasicPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/FloatPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/LogicPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ObjectPTXTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation1Test.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation2Test.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTest.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSenReduTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSensitiveReductionTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.gpu/src/com/oracle/graal/gpu/ExternalCompilationResult.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotAssembler.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/HSAILHotSpotBackendFactory.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotCodeCacheProvider.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotForeignCallsProvider.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerationResult.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotRegisterConfig.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotReplacementsImpl.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectLoadAcquireNode.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectStoreReleaseNode.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILHotSpotReplacementsUtil.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILWorkItemAbsIdNode.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotCodeCacheProvider.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotForeignCallsProvider.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLoweringProvider.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotNodeLIRBuilder.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXWrapperBuilder.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/BootstrapTest.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/example/Example.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/Decompiler.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerLoopSimplify.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerPhiRemover.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerBasicBlock.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerBlock.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerLoopBlock.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerAssignmentLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerControlSplitLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerIfLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerPhiLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerPhiResolveLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerProxyLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerReturnLine.java graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerSyntaxLine.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ParallelOver.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ThreadDimension.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/Warp.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ScheduledNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/BaseReduction.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CastCheckExtractor.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CheckCastReduction.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Evidence.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FixedGuardReduction.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReduction.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReductionPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowUtil.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/GuardingPiReduction.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Histogram.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Witness.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathSubstitutions.java graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/JStrictMath.java graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/AccessException.java graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/TypeException.java graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InstrumentationTest.java graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/SourceTextTest.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineToProbesMap.java graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineToSourceSectionMap.java src/gpu/hsail/vm/gpu_hsail.cpp src/gpu/hsail/vm/gpu_hsail.hpp src/gpu/hsail/vm/gpu_hsail_Frame.hpp src/gpu/hsail/vm/gpu_hsail_OopMapHelper.hpp src/gpu/hsail/vm/gpu_hsail_Tlab.hpp src/gpu/hsail/vm/hsailArgumentsBase.cpp src/gpu/hsail/vm/hsailArgumentsBase.hpp src/gpu/hsail/vm/hsailJavaCallArguments.hpp src/gpu/hsail/vm/hsailKernelArguments.cpp src/gpu/hsail/vm/hsailKernelArguments.hpp src/gpu/hsail/vm/vmStructs_hsail.hpp src/gpu/ptx/vm/gpu_ptx.cpp src/gpu/ptx/vm/gpu_ptx.hpp src/os/bsd/vm/gpu_bsd.cpp src/os/linux/vm/gpu_linux.cpp src/os/windows/vm/gpu_windows.cpp src/share/vm/runtime/gpu.cpp src/share/vm/runtime/gpu.hpp
diffstat 952 files changed, 7834 insertions(+), 60189 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Jan 28 19:12:57 2015 +0100
+++ b/.hgtags	Wed Jan 28 19:32:47 2015 +0100
@@ -524,3 +524,4 @@
 7d4f630172a16e983212d46c0f1ad6cdb826dfce graal-0.4
 ae5b662550836e851c39e4fbb5c80517fc62488f graal-0.5
 3b60f720b955c466d913abb0113af9b38962950b graal-0.6
+1b0ef9634252c422b6f9839fc62eebc112545486 gpu-0.1
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BytecodeFrame.java	Wed Jan 28 19:32:47 2015 +0100
@@ -168,7 +168,7 @@
         for (int i = 0; i < numLocals + numStack; i++) {
             if (values[i] != null) {
                 Kind kind = values[i].getKind();
-                if (kind == Kind.Long || kind == Kind.Double) {
+                if (kind.needsTwoSlots()) {
                     assert values.length > i + 1 : String.format("missing second word %s", this);
                     assert values[i + 1] == null || values[i + 1].getKind() == Kind.Illegal;
                 }
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Wed Jan 28 19:32:47 2015 +0100
@@ -234,6 +234,7 @@
 
         private static final long serialVersionUID = 9011681879878139182L;
 
+        private boolean initialized;
         private int offset;
 
         public DataSectionReference() {
@@ -242,10 +243,15 @@
         }
 
         public int getOffset() {
+            assert initialized;
+
             return offset;
         }
 
         public void setOffset(int offset) {
+            assert !initialized;
+            initialized = true;
+
             this.offset = offset;
         }
 
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java	Wed Jan 28 19:32:47 2015 +0100
@@ -54,7 +54,7 @@
                 ResolvedJavaField rf = lookupField(type.getInstanceFields(true), f);
                 assertNotNull(rf);
                 long offset = isStatic(f.getModifiers()) ? unsafe.staticFieldOffset(f) : unsafe.objectFieldOffset(f);
-                ResolvedJavaField result = type.findInstanceFieldWithOffset(offset);
+                ResolvedJavaField result = type.findInstanceFieldWithOffset(offset, rf.getKind());
                 assertNotNull(result);
                 assertTrue(fieldsEqual(f, result));
             }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,47 +33,50 @@
  */
 public enum Kind implements PlatformKind {
     /** The primitive boolean kind, represented as an int on the stack. */
-    Boolean('z', "boolean", true, java.lang.Boolean.TYPE, java.lang.Boolean.class),
+    Boolean('z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class),
 
     /** The primitive byte kind, represented as an int on the stack. */
-    Byte('b', "byte", true, java.lang.Byte.TYPE, java.lang.Byte.class),
+    Byte('b', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class),
 
     /** The primitive short kind, represented as an int on the stack. */
-    Short('s', "short", true, java.lang.Short.TYPE, java.lang.Short.class),
+    Short('s', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class),
 
     /** The primitive char kind, represented as an int on the stack. */
-    Char('c', "char", true, java.lang.Character.TYPE, java.lang.Character.class),
+    Char('c', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class),
 
     /** The primitive int kind, represented as an int on the stack. */
-    Int('i', "int", true, java.lang.Integer.TYPE, java.lang.Integer.class),
+    Int('i', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class),
 
     /** The primitive float kind. */
-    Float('f', "float", false, java.lang.Float.TYPE, java.lang.Float.class),
+    Float('f', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class),
 
     /** The primitive long kind. */
-    Long('j', "long", false, java.lang.Long.TYPE, java.lang.Long.class),
+    Long('j', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class),
 
     /** The primitive double kind. */
-    Double('d', "double", false, java.lang.Double.TYPE, java.lang.Double.class),
+    Double('d', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class),
 
     /** The Object kind, also used for arrays. */
-    Object('a', "Object", false, null, null),
+    Object('a', "Object", 1, false, null, null),
 
     /** The void float kind. */
-    Void('v', "void", false, java.lang.Void.TYPE, java.lang.Void.class),
+    Void('v', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class),
 
     /** The non-type. */
-    Illegal('-', "illegal", false, null, null);
+    Illegal('-', "illegal", 0, false, null, null);
 
     private final char typeChar;
     private final String javaName;
     private final boolean isStackInt;
     private final Class<?> primitiveJavaClass;
     private final Class<?> boxedJavaClass;
+    private final EnumKey key = new EnumKey(this);
+    private final int slotCount;
 
-    private Kind(char typeChar, String javaName, boolean isStackInt, Class<?> primitiveJavaClass, Class<?> boxedJavaClass) {
+    private Kind(char typeChar, String javaName, int slotCount, boolean isStackInt, Class<?> primitiveJavaClass, Class<?> boxedJavaClass) {
         this.typeChar = typeChar;
         this.javaName = javaName;
+        this.slotCount = slotCount;
         this.isStackInt = isStackInt;
         this.primitiveJavaClass = primitiveJavaClass;
         this.boxedJavaClass = boxedJavaClass;
@@ -81,6 +84,21 @@
     }
 
     /**
+     * Returns the number of stack slots occupied by this kind according to the Java bytecodes
+     * specification.
+     */
+    public int getSlotCount() {
+        return this.slotCount;
+    }
+
+    /**
+     * Returns whether this kind occupied two stack slots.
+     */
+    public boolean needsTwoSlots() {
+        return this.slotCount == 2;
+    }
+
+    /**
      * Returns the name of the kind as a single character.
      */
     public char getTypeChar() {
@@ -95,6 +113,10 @@
         return javaName;
     }
 
+    public Key getKey() {
+        return key;
+    }
+
     /**
      * Checks whether this type is a Java primitive type.
      *
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/NullConstant.java	Wed Jan 28 19:32:47 2015 +0100
@@ -85,7 +85,7 @@
 
     @Override
     public int hashCode() {
-        return System.identityHashCode(this);
+        return 13;
     }
 
     @Override
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,6 +31,43 @@
 
     JavaConstant getDefaultValue();
 
+    public interface Key {
+
+    }
+
+    public class EnumKey implements Key {
+        @SuppressWarnings("rawtypes") private final Enum e;
+
+        @SuppressWarnings("rawtypes")
+        public EnumKey(Enum e) {
+            this.e = e;
+        }
+
+        @Override
+        public int hashCode() {
+            return e.ordinal() ^ e.name().hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj == this) {
+                return true;
+            }
+            if (obj instanceof EnumKey) {
+                EnumKey that = (EnumKey) obj;
+                return this.e == that.e;
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Gets a value associated with this object that can be used as a stable key in a map. The
+     * {@link Object#hashCode()} implementation of the returned value should be stable between VM
+     * executions.
+     */
+    Key getKey();
+
     default int getVectorLength() {
         return 1;
     }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Remote.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * 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.meta;
-
-/**
- * Marker interface for classes whose values are proxied during replay compilation capture or remote
- * compilation.
- */
-public interface Remote {
-}
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java	Wed Jan 28 19:32:47 2015 +0100
@@ -298,7 +298,7 @@
      * @param offset the offset of the field to look for
      * @return the field with the given offset, or {@code null} if there is no such field.
      */
-    ResolvedJavaField findInstanceFieldWithOffset(long offset);
+    ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedKind);
 
     /**
      * Returns name of source file of this type.
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/AbstractHSAILAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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.asm.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.asm.*;
-
-/**
- * The platform-dependent base class for the HSAIL assembler.
- */
-public abstract class AbstractHSAILAssembler extends Assembler {
-
-    public AbstractHSAILAssembler(TargetDescription target) {
-        super(target);
-    }
-
-    @Override
-    public final void bind(Label l) {
-        super.bind(l);
-        emitString0(nameOf(l) + ":\n");
-    }
-
-    @Override
-    public void align(int modulus) {
-        // Nothing to do
-    }
-
-    @Override
-    public void jmp(Label l) {
-        emitJumpToLabelName(nameOf(l));
-    }
-
-    public void emitJumpToLabelName(String labelName) {
-        emitString("brn " + labelName + ";");
-    }
-
-    @Override
-    protected void patchJumpTarget(int branch, int jumpTarget) {
-        // Nothing to do
-    }
-
-    @Override
-    protected String createLabelName(Label l, int id) {
-        int blockId = l.getBlockId();
-        return "@L" + (blockId == -1 ? id : blockId);
-    }
-}
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAddress.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +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.asm.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-
-/**
- * Represents an address in target machine memory, specified via some combination of a base register
- * and a displacement.
- */
-public final class HSAILAddress extends AbstractAddress {
-
-    private final Register base;
-    private final long displacement;
-
-    /**
-     * Creates an {@link HSAILAddress} with given base register and no displacement.
-     * 
-     * 
-     * @param base the base register
-     */
-    public HSAILAddress(Register base) {
-        this(base, 0);
-    }
-
-    /**
-     * Creates an {@link HSAILAddress} with given base register and a displacement. This is the most
-     * general constructor.
-     * 
-     * @param base the base register
-     * @param displacement the displacement
-     */
-    public HSAILAddress(Register base, long displacement) {
-        this.base = base;
-        this.displacement = displacement;
-    }
-
-    /**
-     * @return Base register that defines the start of the address computation. If not present, is
-     *         denoted by {@link Value#ILLEGAL}.
-     */
-    public Register getBase() {
-        return base;
-    }
-
-    /**
-     * @return Optional additive displacement.
-     */
-    public long getDisplacement() {
-        return displacement;
-    }
-
-}
--- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,661 +0,0 @@
-/*
- * 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.asm.hsail;
-
-import static com.oracle.graal.api.code.MemoryBarriers.*;
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.hsail.*;
-
-/**
- * This class contains routines to emit HSAIL assembly code.
- */
-public abstract class HSAILAssembler extends AbstractHSAILAssembler {
-
-    /**
-     * Stack size in bytes (used to keep track of spilling).
-     */
-    private int maxDataTypeSize;
-
-    /**
-     * Maximum stack offset used by a store operation.
-     */
-    private long maxStackOffset = 0;
-
-    public long upperBoundStackSize() {
-        return maxStackOffset + maxDataTypeSize;
-    }
-
-    public HSAILAssembler(TargetDescription target) {
-        super(target);
-    }
-
-    @Override
-    public HSAILAddress makeAddress(Register base, int displacement) {
-        return new HSAILAddress(base, displacement);
-    }
-
-    @Override
-    public HSAILAddress getPlaceholder() {
-        return null;
-    }
-
-    @Override
-    public final void ensureUniquePC() {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public final void undefined(String str) {
-        emitString("undefined operation " + str);
-    }
-
-    public final void exit() {
-        emitString("ret;" + "");
-    }
-
-    /**
-     * Moves an Object into a register.
-     *
-     * Because Object references become stale after Garbage collection (GC) the technique used here
-     * is to load a JNI global reference to that Object into the register. These JNI global
-     * references get updated by the GC whenever the GC moves an Object.
-     *
-     * @param a the destination register
-     * @param src the Object Constant being moved
-     */
-    public abstract void mov(Register a, JavaConstant src);
-
-    private static String getBitTypeFromKind(Kind kind) {
-        switch (kind) {
-            case Boolean:
-            case Byte:
-            case Short:
-            case Char:
-            case Int:
-            case Float:
-                return "b32";
-            case Long:
-            case Double:
-            case Object:
-                return "b64";
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    public final void emitMov(Kind kind, Value dst, Value src) {
-        if (isRegister(dst) && isConstant(src) && kind.getStackKind() == Kind.Object) {
-            mov(asRegister(dst), asConstant(src));
-        } else {
-            String argtype = getBitTypeFromKind(kind);
-            emitString("mov_" + argtype + " " + mapRegOrConstToString(dst) + ", " + mapRegOrConstToString(src) + ";");
-        }
-    }
-
-    private void emitAddrOp(String instr, Value reg, HSAILAddress addr) {
-        String storeValue = mapRegOrConstToString(reg);
-        emitString(instr + " " + storeValue + ", " + mapAddress(addr) + ";");
-    }
-
-    /**
-     * Emits a memory barrier instruction.
-     *
-     * @param barriers the kind of barrier to emit
-     */
-    public final void emitMembar(int barriers) {
-        if (barriers == 0) {
-            emitString("// no barrier before volatile read");
-        } else if (barriers == JMM_POST_VOLATILE_READ) {
-            emitString("sync; // barriers=" + MemoryBarriers.barriersString(barriers));
-        } else if (barriers == JMM_PRE_VOLATILE_WRITE) {
-            emitString("sync; // barriers=" + MemoryBarriers.barriersString(barriers));
-        } else if (barriers == JMM_POST_VOLATILE_WRITE) {
-            emitString("sync; // barriers=" + MemoryBarriers.barriersString(barriers));
-        }
-    }
-
-    public final void emitLoad(Kind kind, Value dest, HSAILAddress addr) {
-        emitLoad(dest, addr, getArgTypeFromKind(kind));
-    }
-
-    public final void emitLoad(Value dest, HSAILAddress addr, String argTypeStr) {
-        emitAddrOp("ld_global_" + argTypeStr, dest, addr);
-    }
-
-    public final void emitLda(Value dest, HSAILAddress addr) {
-        emitAddrOp("lda_global_u64", dest, addr);
-    }
-
-    public final void emitLea(Value dest, HSAILAddress addr) {
-        String prefix = getArgType(dest);
-        emitString(String.format("add_%s %s, $%s, 0x%s;", prefix, HSAIL.mapRegister(dest), addr.getBase().name, Long.toHexString(addr.getDisplacement())));
-    }
-
-    public final void emitLoadKernelArg(Value dest, String kernArgName, String argTypeStr) {
-        emitString("ld_kernarg_" + argTypeStr + " " + HSAIL.mapRegister(dest) + ", [" + kernArgName + "];");
-    }
-
-    public final void emitStore(Kind kind, Value src, HSAILAddress addr) {
-        emitStore(src, addr, getArgTypeFromKind(kind));
-    }
-
-    public final void emitStore(Value dest, HSAILAddress addr, String argTypeStr) {
-        emitAddrOp("st_global_" + argTypeStr, dest, addr);
-    }
-
-    private void storeImmediateImpl(String storeType, String value, HSAILAddress addr) {
-        emitString("st_global_" + storeType + " " + value + ", " + mapAddress(addr) + ";");
-    }
-
-    public final void emitStoreImmediate(Kind kind, long src, HSAILAddress addr) {
-        assert (kind != Kind.Float && kind != Kind.Double);
-        storeImmediateImpl(getArgTypeFromKind(kind), Long.toString(src), addr);
-    }
-
-    public final void emitStoreImmediate(float src, HSAILAddress addr) {
-        storeImmediateImpl("f32", floatToString(src), addr);
-    }
-
-    public final void emitStoreImmediate(double src, HSAILAddress addr) {
-        storeImmediateImpl("f64", doubleToString(src), addr);
-    }
-
-    public final void emitSpillLoad(Kind kind, Value dest, Value src) {
-        emitString("ld_spill_" + getArgTypeFromKind(kind) + " " + HSAIL.mapRegister(dest) + ", " + mapStackSlot(src, getArgSizeFromKind(kind)) + ";");
-    }
-
-    public final void emitStore(Value src, HSAILAddress addr) {
-        emitString("st_global_" + getArgType(src) + " " + HSAIL.mapRegister(src) + ", " + mapAddress(addr) + ";");
-    }
-
-    public final void emitSpillStore(Kind kind, Value src, Value dest) {
-        int sizestored = getArgSizeFromKind(kind);
-        if (maxDataTypeSize < sizestored) {
-            maxDataTypeSize = sizestored;
-        }
-        int stackoffset = HSAIL.getStackOffset(dest);
-        if (maxStackOffset < stackoffset) {
-            maxStackOffset = stackoffset;
-        }
-        emitString("st_spill_" + getArgTypeFromKind(kind) + " " + HSAIL.mapRegister(src) + ", " + mapStackSlot(dest, getArgSizeFromKind(kind)) + ";");
-    }
-
-    public static String mapStackSlot(Value reg, int argSize) {
-        long startOffset = HSAIL.getStackOffsetStart(reg, argSize);
-        return "[%spillseg]" + "[" + startOffset + "]";
-    }
-
-    public void cbr(String target1) {
-        emitString("cbr " + "$c0" + ", " + target1 + ";");
-    }
-
-    public int getArgSize(Value src) {
-        return getArgSizeFromKind(src.getKind());
-    }
-
-    private static int getArgSizeFromKind(Kind kind) {
-        switch (kind) {
-            case Int:
-            case Float:
-                return 32;
-            case Double:
-            case Long:
-            case Object:
-                return 64;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    private static String getArgType(Value src) {
-        return getArgTypeFromKind(src.getKind());
-    }
-
-    private static String getArgTypeFromKind(Kind kind) {
-        String prefix = "";
-        switch (kind) {
-            case Float:
-                prefix = "f32";
-                break;
-            case Double:
-                prefix = "f64";
-                break;
-            case Int:
-                prefix = "s32";
-                break;
-            case Long:
-                prefix = "s64";
-                break;
-            case Object:
-                prefix = "u64";
-                break;
-            case Char:
-                prefix = "u16";
-                break;
-            case Short:
-                prefix = "s16";
-                break;
-            case Byte:
-                prefix = "s8";
-                break;
-            case Boolean:
-                prefix = "u8";
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return prefix;
-    }
-
-    public static final String getArgTypeForceUnsigned(Value src) {
-        return getArgTypeForceUnsignedKind(src.getKind());
-    }
-
-    public static final String getArgTypeForceUnsignedKind(Kind kind) {
-        switch (kind) {
-            case Int:
-                return "u32";
-            case Long:
-            case Object:
-                return "u64";
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    public static final String getArgTypeBitwiseLogical(Value src) {
-        String length = getArgType(src);
-        String prefix = "_b" + (length.endsWith("64") ? "64" : "32");
-        return prefix;
-    }
-
-    /**
-     * Emits a compare instruction.
-     *
-     * @param src0 - the first source register
-     * @param src1 - the second source register
-     * @param condition - the compare condition i.e., eq, ne, lt, gt
-     * @param unordered - flag specifying if this is an unordered compare. This only applies to
-     *            float compares.
-     * @param isUnsignedCompare - flag specifying if this is a compare of unsigned values.
-     */
-    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(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).isNull()) ? " // null test " : "");
-        // Emit the instruction.
-        emitString(prefix + " $c0, " + mapRegOrConstToString(src0) + ", " + mapRegOrConstToString(src1) + ";" + comment);
-    }
-
-    public void emitConvert(Value dest, Value src, String destType, String srcType) {
-        String prefix = "cvt_";
-        if (destType.equals("f32") && srcType.equals("f64")) {
-            prefix = "cvt_near_";
-        } else if (srcType.startsWith("f") && (destType.startsWith("s") || destType.startsWith("u"))) {
-            prefix = "cvt_zeroi_sat_";
-        }
-        emitString(prefix + destType + "_" + srcType + " " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
-    }
-
-    public void emitConvert(Value dest, Value src, Kind destKind, Kind srcKind) {
-        String destType = getArgTypeFromKind(destKind);
-        String srcType = getArgTypeFromKind(srcKind);
-        emitConvert(dest, src, destType, srcType);
-    }
-
-    /**
-     * Emits a convert instruction that uses unsigned prefix, regardless of the type of dest and
-     * src.
-     *
-     * @param dest the destination operand
-     * @param src the source operand
-     */
-    public void emitConvertForceUnsigned(Value dest, Value src) {
-        emitString("cvt_" + getArgTypeForceUnsigned(dest) + "_" + getArgTypeForceUnsigned(src) + " " + HSAIL.mapRegister(dest) + ", " + HSAIL.mapRegister(src) + ";");
-    }
-
-    public static String mapAddress(HSAILAddress addr) {
-        if (addr.getBase().encoding() < 0) {
-            return "[0x" + Long.toHexString(addr.getDisplacement()) + "]";
-        } else {
-            return "[$d" + addr.getBase().encoding() + " + " + addr.getDisplacement() + "]";
-        }
-    }
-
-    private static String doubleToString(double dval) {
-        long lval = Double.doubleToRawLongBits(dval);
-        long lvalIgnoreSign = lval & 0x7fffffffffffffffL;
-        if (lvalIgnoreSign >= 0x7ff0000000000000L) {
-            return "0D" + String.format("%16x", lval);
-        } else {
-            return Double.toString(dval);
-        }
-    }
-
-    private static String floatToString(float fval) {
-        int ival = Float.floatToRawIntBits(fval);
-        int ivalIgnoreSign = ival & 0x7fffffff;
-        if (ivalIgnoreSign >= 0x7f800000) {
-            return "0F" + String.format("%8x", ival);
-        } else {
-            return Float.toString(fval) + "f";
-        }
-    }
-
-    private static String mapRegOrConstToString(Value src) {
-        if (!isConstant(src)) {
-            return HSAIL.mapRegister(src);
-        } else {
-            JavaConstant consrc = asConstant(src);
-            switch (src.getKind()) {
-                case Boolean:
-                case Int:
-                    return Integer.toString(consrc.asInt());
-                case Float:
-                    return floatToString(consrc.asFloat());
-                case Double:
-                    return doubleToString(consrc.asDouble());
-                case Long:
-                    return "0x" + Long.toHexString(consrc.asLong());
-                case Object:
-                    if (consrc.isNull()) {
-                        return "0";
-                    } else {
-                        throw GraalInternalError.shouldNotReachHere("unknown type: " + src);
-                    }
-                default:
-                    throw GraalInternalError.shouldNotReachHere("unknown type: " + src);
-            }
-        }
-
-    }
-
-    /**
-     * Emits an instruction.
-     *
-     * @param mnemonic the instruction mnemonic
-     * @param dest the destination operand
-     * @param sources the source operands
-     */
-    public final void emit(String mnemonic, Value dest, Value... sources) {
-        String prefix = getArgType(dest);
-        emitTextFormattedInstruction(mnemonic + "_" + prefix, dest, sources);
-    }
-
-    /**
-     * Emits an unsigned instruction.
-     *
-     * @param mnemonic the instruction mnemonic
-     * @param dest the destination argument
-     * @param sources the source arguments
-     *
-     */
-    public final void emitForceUnsigned(String mnemonic, Value dest, Value... sources) {
-        String prefix = getArgTypeForceUnsigned(dest);
-        emitTextFormattedInstruction(mnemonic + "_" + prefix, dest, sources);
-    }
-
-    public final void emitForceUnsignedKind(String mnemonic, Kind kind, Value dest, Value... sources) {
-        String prefix = getArgTypeForceUnsignedKind(kind);
-        emitTextFormattedInstruction(mnemonic + "_" + prefix, dest, sources);
-    }
-
-    /**
-     * Emits an instruction for a bitwise logical operation.
-     *
-     * @param mnemonic the instruction mnemonic
-     * @param dest the destination
-     * @param sources the source operands
-     */
-    public final void emitForceBitwise(String mnemonic, Value dest, Value... sources) {
-        String prefix = getArgTypeBitwiseLogical(dest);
-        emitTextFormattedInstruction(mnemonic + prefix, dest, sources);
-    }
-
-    /**
-     * Central helper routine that emits a text formatted HSAIL instruction via call to
-     * AbstractAssembler.emitString. All the emit routines in the assembler end up calling this one.
-     *
-     * @param instr the full instruction mnenomics including any prefixes
-     * @param dest the destination operand
-     * @param sources the source operand
-     */
-    private void emitTextFormattedInstruction(String instr, Value dest, Value... sources) {
-        /**
-         * Destination can't be a constant and no instruction has > 3 source operands.
-         */
-        assert (!isConstant(dest) && sources.length <= 3);
-        switch (sources.length) {
-            case 3:
-                // Emit an instruction with three source operands.
-                emitString(String.format("%s %s, %s, %s, %s;", instr, HSAIL.mapRegister(dest), mapRegOrConstToString(sources[0]), mapRegOrConstToString(sources[1]), mapRegOrConstToString(sources[2])));
-                break;
-            case 2:
-                // Emit an instruction with two source operands.
-                emitString(String.format("%s %s, %s, %s;", instr, HSAIL.mapRegister(dest), mapRegOrConstToString(sources[0]), mapRegOrConstToString(sources[1])));
-                break;
-            case 1:
-                // Emit an instruction with one source operand.
-                emitString(String.format("%s %s, %s;", instr, HSAIL.mapRegister(dest), mapRegOrConstToString(sources[0])));
-                break;
-            default:
-                // Emit an instruction with one source operand.
-                emitString(String.format("%s %s;", instr, HSAIL.mapRegister(dest)));
-                break;
-        }
-    }
-
-    /**
-     * Emits a conditional move instruction.
-     *
-     * @param dest the destination operand storing result of the move
-     * @param trueReg the register that should be copied to dest if the condition is true
-     * @param falseReg the register that should be copied to dest if the condition is false
-     * @param width the width of the instruction (32 or 64 bits)
-     */
-    public final void emitConditionalMove(Value dest, Value trueReg, Value falseReg, int width) {
-        assert (!isConstant(dest));
-        String instr = (width == 32 ? "cmov_b32" : "cmov_b64");
-        emitString(String.format("%s %s, %s%s, %s;", instr, HSAIL.mapRegister(dest), "$c0, ", mapRegOrConstToString(trueReg), mapRegOrConstToString(falseReg)));
-    }
-
-    /**
-     * Emits code to build a 64-bit pointer from a compressed value and the associated base and
-     * shift. The compressed value could represent either a normal oop or a klass ptr. If the
-     * compressed value is 0, the uncompressed must also be 0. We only emit this if base and shift
-     * are not both zero.
-     *
-     * @param result the register containing the compressed value on input and the uncompressed ptr
-     *            on output
-     * @param base the amount to be added to the compressed value
-     * @param shift the number of bits to shift left the compressed value
-     * @param testForNull true if the compressed value might be null
-     */
-    public void emitCompressedOopDecode(Value result, long base, int shift, boolean testForNull) {
-        assert (base != 0 || shift != 0);
-        assert (!isConstant(result));
-        if (base == 0) {
-            // we don't have to test for null if shl is the only operation
-            emitForceUnsignedKind("shl", Kind.Long, result, result, JavaConstant.forInt(shift));
-        } else if (shift == 0) {
-            // only use add if result is not starting as null (test only if testForNull is true)
-            emitWithOptionalTestForNull(testForNull, "add", result, result, JavaConstant.forLong(base));
-        } else {
-            // only use mad if result is not starting as null (test only if testForNull is true)
-            emitWithOptionalTestForNull(testForNull, "mad", result, result, JavaConstant.forInt(1 << shift), JavaConstant.forLong(base));
-        }
-    }
-
-    /**
-     * Emits code to build a compressed value from a full 64-bit pointer using the associated base
-     * and shift. The compressed value could represent either a normal oop or a klass ptr. If the
-     * ptr is 0, the compressed value must also be 0. We only emit this if base and shift are not
-     * both zero.
-     *
-     * @param result the register containing the 64-bit pointer on input and the compressed value on
-     *            output
-     * @param base the amount to be subtracted from the 64-bit pointer
-     * @param shift the number of bits to shift right the 64-bit pointer
-     * @param testForNull true if the 64-bit pointer might be null
-     */
-    public void emitCompressedOopEncode(Value result, long base, int shift, boolean testForNull) {
-        assert (base != 0 || shift != 0);
-        assert (!isConstant(result));
-        if (base != 0) {
-            // only use sub if result is not starting as null (test only if testForNull is true)
-            emitWithOptionalTestForNull(testForNull, "sub", result, result, JavaConstant.forLong(base));
-        }
-        if (shift != 0) {
-            // note that the shr can still be done even if the result is null
-            emitForceUnsignedKind("shr", Kind.Long, result, result, JavaConstant.forInt(shift));
-        }
-    }
-
-    /**
-     * Emits code for the requested mnemonic on the result and sources. In addition, if testForNull
-     * is true, surrounds the instruction with code that will guarantee that if the result starts as
-     * 0, it will remain 0.
-     *
-     * @param testForNull true if we want to add the code to check for and preserve null
-     * @param mnemonic the instruction to be applied (without size prefix)
-     * @param result the register which is both an input and the final output
-     * @param sources the sources for the mnemonic instruction
-     */
-    private void emitWithOptionalTestForNull(boolean testForNull, String mnemonic, Value result, Value... sources) {
-        if (testForNull) {
-            emitCompare(Kind.Long, result, JavaConstant.forLong(0), "eq", false, true);
-        }
-        emitForceUnsigned(mnemonic, result, sources);
-        if (testForNull) {
-            emitConditionalMove(result, JavaConstant.forLong(0), result, 64);
-        }
-    }
-
-    /**
-     * Emits an atomic_cas_global instruction.
-     *
-     * @param result result operand that gets the original contents of the memory location
-     * @param address the memory location
-     * @param cmpValue the value that will be compared against the memory location
-     * @param newValue the new value that will be written to the memory location if the cmpValue
-     *            comparison matches
-     */
-    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)));
-    }
-
-    /**
-     * Emits an atomic_add_global instruction.
-     *
-     * @param result result operand that gets the original contents of the memory location
-     * @param address the memory location
-     * @param delta the amount to add
-     */
-    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)));
-    }
-
-    /**
-     * Emits an atomic_exch_global instruction.
-     *
-     * @param result result operand that gets the original contents of the memory location
-     * @param address the memory location
-     * @param newValue the new value to write to the memory location
-     */
-    public void emitAtomicExch(Kind accessKind, AllocatableValue result, HSAILAddress address, Value newValue) {
-        emitString(String.format("atomic_exch_global_b%d   %s, %s, %s;", getArgSizeFromKind(accessKind), HSAIL.mapRegister(result), mapAddress(address), mapRegOrConstToString(newValue)));
-    }
-
-    /**
-     * Emits a comment. Useful for debugging purposes.
-     *
-     * @param comment
-     */
-    public void emitComment(String comment) {
-        emitString(comment);
-    }
-
-    public String getDeoptInfoName() {
-        return "%_deoptInfo";
-    }
-
-    public String getDeoptLabelName() {
-        return "@L_Deopt";
-    }
-
-    public void emitWorkItemAbsId(Value dest) {
-        emitString(String.format("workitemabsid_u32 %s, 0;", HSAIL.mapRegister(dest)));
-    }
-
-    public void emitCuId(Value dest) {
-        emitString(String.format("cuid_u32 %s;", HSAIL.mapRegister(dest)));
-    }
-
-    public void emitLaneId(Value dest) {
-        emitString(String.format("laneid_u32 %s;", HSAIL.mapRegister(dest)));
-    }
-
-    public void emitWaveId(Value dest) {
-        emitString(String.format("waveid_u32 %s;", HSAIL.mapRegister(dest)));
-    }
-
-    public void emitMaxWaveId(Value dest) {
-        // emitString(String.format("maxwaveid_u32 %s;", HSAIL.mapRegister(dest)));
-        int hardCodedMaxWaveId = 36;
-        emitComment("// Hard-coded maxwaveid=" + hardCodedMaxWaveId + " until it works");
-        emitMov(Kind.Int, dest, JavaConstant.forInt(hardCodedMaxWaveId));
-    }
-
-    public void emitMultiplyByWavesize(Value dest) {
-        String regName = HSAIL.mapRegister(dest);
-        emitString(String.format("mul_u%d %s, %s, WAVESIZE;", getArgSize(dest), regName, regName));
-    }
-
-    public void emitGetWavesize(Value dest) {
-        String regName = HSAIL.mapRegister(dest);
-        emitString(String.format("mov_b%d %s, WAVESIZE;", getArgSize(dest), regName));
-    }
-
-    public void emitLoadAcquire(Value dest, HSAILAddress address) {
-        emitString(String.format("ld_global_acq_u%d %s, %s;", getArgSize(dest), HSAIL.mapRegister(dest), mapAddress(address)));
-    }
-
-    public void emitStoreRelease(Value src, HSAILAddress address) {
-        emitString(String.format("st_global_rel_u%d %s, %s;", getArgSize(src), HSAIL.mapRegister(src), mapAddress(address)));
-    }
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/AbstractPTXAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +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.asm.ptx;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.asm.*;
-
-/**
- * The platform-dependent base class for the PTX assembler.
- */
-public abstract class AbstractPTXAssembler extends Assembler {
-
-    public AbstractPTXAssembler(TargetDescription target) {
-        super(target);
-    }
-
-    @Override
-    public final void bind(Label l) {
-        super.bind(l);
-        emitString0(nameOf(l) + ":\n");
-    }
-
-    @Override
-    public void align(int modulus) {
-        // Nothing to do
-    }
-
-    @Override
-    public void jmp(Label l) {
-        // Nothing to do
-    }
-
-    @Override
-    protected void patchJumpTarget(int branch, int jumpTarget) {
-        // Nothing to do. All branches already point to the right label.
-    }
-
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAddress.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +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.asm.ptx;
-
-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
- * and a displacement.
- */
-public final class PTXAddress extends AbstractAddress {
-
-    private final Variable base;
-    private final long displacement;
-
-    /**
-     * Creates an {@link PTXAddress} with given base register and no displacement.
-     * 
-     * @param base the base register
-     */
-    public PTXAddress(Variable base) {
-        this(base, 0);
-    }
-
-    /**
-     * Creates an {@link PTXAddress} with given base register and a displacement. This is the most
-     * general constructor.
-     * 
-     * @param base the base register
-     * @param displacement the displacement
-     */
-    public PTXAddress(Variable base, long displacement) {
-        this.base = base;
-        this.displacement = displacement;
-    }
-
-    /**
-     * @return Base register that defines the start of the address computation. If not present, is
-     *         denoted by {@link Value#ILLEGAL}.
-     */
-    public Variable getBase() {
-        return base;
-    }
-
-    /**
-     * @return Optional additive displacement.
-     */
-    public long getDisplacement() {
-        return displacement;
-    }
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAsmOptions.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.asm.ptx;
-
-public class PTXAsmOptions {
-    // Nothing for now
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,712 +0,0 @@
-/*
- * 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.asm.ptx;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.lir.*;
-
-public class PTXAssembler extends AbstractPTXAssembler {
-
-    public PTXAssembler(TargetDescription target, @SuppressWarnings("unused") RegisterConfig registerConfig) {
-        super(target);
-    }
-
-    public enum ConditionOperator {
-        // @formatter:off
-
-        // Signed integer operators
-        S_EQ("eq"),
-        S_NE("ne"),
-        S_LT("lt"),
-        S_LE("le"),
-        S_GT("gt"),
-        S_GE("ge"),
-
-        // Unsigned integer operators
-        U_EQ("eq"),
-        U_NE("ne"),
-        U_LO("lo"),
-        U_LS("ls"),
-        U_HI("hi"),
-        U_HS("hs"),
-
-        // Bit-size integer operators
-        B_EQ("eq"),
-        B_NE("ne"),
-
-        // Floating-point operators
-        F_EQ("eq"),
-        F_NE("ne"),
-        F_LT("lt"),
-        F_LE("le"),
-        F_GT("gt"),
-        F_GE("ge"),
-
-        // Floating-point operators accepting NaN
-        F_EQU("equ"),
-        F_NEU("neu"),
-        F_LTU("ltu"),
-        F_LEU("leu"),
-        F_GTU("gtu"),
-        F_GEU("geu"),
-
-        // Floating-point operators testing for NaN
-        F_NUM("num"),
-        F_NAN("nan");
-
-        // @formatter:on
-
-        private final String operator;
-
-        private ConditionOperator(String op) {
-            this.operator = op;
-        }
-
-        public String getOperator() {
-            return operator;
-        }
-    }
-
-    public static class StandardFormat {
-
-        // Type of destination value
-        protected Kind valueKind;
-        protected Variable dest;
-        protected Value source1;
-        protected Value source2;
-
-        public StandardFormat(Variable dst, Value src1, Value src2) {
-            setDestination(dst);
-            setSource1(src1);
-            setSource2(src2);
-            setKind(dst.getKind());
-        }
-
-        public void setKind(Kind k) {
-            valueKind = k;
-        }
-
-        public void setDestination(Variable var) {
-            assert var != null;
-            dest = var;
-            setKind(var.getKind());
-        }
-
-        public void setSource1(Value val) {
-            assert val != null;
-            source1 = val;
-        }
-
-        public void setSource2(Value val) {
-            assert val != null;
-            source2 = val;
-        }
-
-        public String typeForKind(Kind k) {
-            switch (k.getTypeChar()) {
-            // Boolean
-                case 'z':
-                    return "u8";
-                    // Byte
-                case 'b':
-                    return "b8";
-                    // Short
-                case 's':
-                    return "s16";
-                case 'c':
-                    return "u16";
-                case 'i':
-                    return "s32";
-                case 'f':
-                    return "f32";
-                case 'j':
-                    return "s64";
-                case 'd':
-                    return "f64";
-                case 'a':
-                    return "u64";
-                case '-':
-                    return "u32";
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public String emit() {
-            return (typeForKind(valueKind) + emitRegister(dest, true) + emitValue(source1, true) + emitValue(source2, false) + ";");
-        }
-
-        public String emitValue(Value v, boolean comma) {
-            assert v != null;
-
-            if (isConstant(v)) {
-                return (emitConstant(v, comma));
-            } else {
-                return (emitRegister((Variable) v, comma));
-            }
-        }
-
-        public String emitRegister(Variable v, boolean comma) {
-            return (" %r" + v.index + (comma ? "," : ""));
-        }
-
-        public String emitConstant(Value v, boolean comma) {
-            JavaConstant constant = (JavaConstant) v;
-            String str = null;
-
-            switch (v.getKind().getTypeChar()) {
-                case 'i':
-                    str = String.valueOf((int) constant.asLong());
-                    break;
-                case 'f':
-                    str = String.valueOf(constant.asFloat());
-                    break;
-                case 'j':
-                    str = String.valueOf(constant.asLong());
-                    break;
-                case 'd':
-                    str = String.valueOf(constant.asDouble());
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-            if (comma) {
-                return (str + ",");
-            } else {
-                return str;
-            }
-        }
-    }
-
-    public static class LogicInstructionFormat extends StandardFormat {
-        public LogicInstructionFormat(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        @Override
-        public String emit() {
-            String kindStr;
-            switch (valueKind.getTypeChar()) {
-                case 's':
-                    kindStr = "b16";
-                    break;
-                case 'i':
-                    kindStr = "b32";
-                    break;
-                case 'j':
-                    kindStr = "b64";
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-
-            return (kindStr + emitRegister(dest, true) + emitValue(source1, true) + emitValue(source2, false) + ";");
-        }
-    }
-
-    public static class SingleOperandFormat {
-
-        protected Variable dest;
-        protected Value source;
-
-        public SingleOperandFormat(Variable dst, Value src) {
-            setDestination(dst);
-            setSource(src);
-        }
-
-        public void setDestination(Variable var) {
-            dest = var;
-        }
-
-        public void setSource(Value var) {
-            source = var;
-        }
-
-        public String typeForKind(Kind k) {
-            switch (k.getTypeChar()) {
-                case 'z':
-                    return "u8";
-                case 'b':
-                    return "s8";
-                case 's':
-                    return "s16";
-                case 'c':
-                    return "u16";
-                case 'i':
-                    return "s32";
-                case 'f':
-                    return "f32";
-                case 'j':
-                    return "s64";
-                case 'd':
-                    return "f64";
-                case 'a':
-                    return "u64";
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public String emit() {
-            return (typeForKind(dest.getKind()) + " " + emitVariable(dest) + ", " + emitValue(source) + ";");
-        }
-
-        public String emitValue(Value v) {
-            assert v != null;
-
-            if (isConstant(v)) {
-                return (emitConstant(v));
-            } else {
-                return (emitVariable((Variable) v));
-            }
-        }
-
-        public String emitConstant(Value v) {
-            JavaConstant constant = (JavaConstant) v;
-
-            switch (v.getKind().getTypeChar()) {
-                case 'i':
-                    return (String.valueOf((int) constant.asLong()));
-                case 'f':
-                    return (String.valueOf(constant.asFloat()));
-                case 'j':
-                    return (String.valueOf(constant.asLong()));
-                case 'd':
-                    return (String.valueOf(constant.asDouble()));
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public String emitVariable(Variable v) {
-            String name = v.getName();
-
-            if (name == null) {
-                return (" %r" + v.index);
-            } else {
-                return name;
-            }
-        }
-    }
-
-    public static class BinarySingleOperandFormat extends SingleOperandFormat {
-
-        public BinarySingleOperandFormat(Variable dst, Value src) {
-            super(dst, src);
-        }
-
-        @Override
-        public String typeForKind(Kind k) {
-            switch (k.getTypeChar()) {
-                case 's':
-                    return "b16";
-                case 'i':
-                    return "b32";
-                case 'j':
-                    return "b64";
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    public static class ConversionFormat extends SingleOperandFormat {
-
-        private final Kind dstKind;
-        private final Kind srcKind;
-
-        public ConversionFormat(Variable dst, Value src, Kind dstKind, Kind srcKind) {
-            super(dst, src);
-            this.dstKind = dstKind;
-            this.srcKind = srcKind;
-        }
-
-        @Override
-        public String emit() {
-            return (typeForKind(dstKind) + "." + typeForKind(srcKind) + " " + emitVariable(dest) + ", " + emitValue(source) + ";");
-        }
-    }
-
-    public static class LoadStoreFormat extends StandardFormat {
-
-        protected PTXStateSpace space;
-
-        public LoadStoreFormat(PTXStateSpace space, Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-            setStateSpace(space);
-        }
-
-        public void setStateSpace(PTXStateSpace ss) {
-            space = ss;
-        }
-
-        public String emitAddress(Value var, Value val) {
-            assert var instanceof Variable;
-            assert val instanceof JavaConstant;
-            JavaConstant constant = (JavaConstant) val;
-            return ("[" + ((space == PTXStateSpace.Parameter) ? emitParameter((Variable) var) : emitRegister((Variable) var, false)) + " + " + constant.toValueString() + "]");
-        }
-
-        @Override
-        public String emitRegister(Variable var, boolean comma) {
-            return ("%r" + var.index);
-        }
-
-        public String emitParameter(Variable v) {
-            return ("param" + v.index);
-        }
-
-        public String emit(boolean isLoad) {
-            if (isLoad) {
-                return (space.getStateName() + "." + typeForKind(valueKind) + " " + emitRegister(dest, false) + ", " + emitAddress(source1, source2) + ";");
-            } else {
-                return (space.getStateName() + "." + typeForKind(valueKind) + " " + emitAddress(source1, source2) + ", " + emitRegister(dest, false) + ";");
-            }
-        }
-    }
-
-    // Checkstyle: stop method name check
-    /*
-     * Emit conditional branch to target 'tgt' guarded by predicate register 'pred' whose state is
-     * tested to be 'predCheck'.
-     */
-    public final void bra(String tgt, int pred, boolean predCheck) {
-        assert pred >= 0;
-
-        if (tgt.equals("?")) {
-            Thread.dumpStack();
-        }
-        emitString("@" + (predCheck ? "%p" : "!%p") + pred + " " + "bra" + " " + tgt + ";");
-    }
-
-    public final void bra(String src) {
-        emitString("bra " + src + ";");
-    }
-
-    public final void bra_uni(String tgt) {
-        emitString("bra.uni" + " " + tgt + ";" + "");
-    }
-
-    public final void exit() {
-        emitString("exit;" + " " + "");
-    }
-
-    public static class Global {
-
-        private Kind kind;
-        private String name;
-        private LabelRef[] targets;
-
-        public Global(Value val, String name, LabelRef[] targets) {
-            this.kind = val.getKind();
-            this.name = name;
-            this.targets = targets;
-        }
-
-        private static String valueForKind(Kind k) {
-            switch (k.getTypeChar()) {
-                case 'i':
-                    return "s32";
-                case 'j':
-                    return "s64";
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        private static String emitTargets(PTXAssembler asm, LabelRef[] refs) {
-            StringBuffer sb = new StringBuffer();
-
-            for (int i = 0; i < refs.length; i++) {
-                sb.append(asm.nameOf(refs[i].label()));
-                if (i < (refs.length - 1)) {
-                    sb.append(", ");
-                }
-            }
-
-            return sb.toString();
-        }
-
-        public void emit(PTXAssembler asm) {
-            asm.emitString(".global ." + valueForKind(kind) + " " + name + "[" + targets.length + "] = " + "{ " + emitTargets(asm, targets) + " };");
-        }
-    }
-
-    public final void popc_b32(Register d, Register a) {
-        emitString("popc.b32" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ";" + "");
-    }
-
-    public final void popc_b64(Register d, Register a) {
-        emitString("popc.b64" + " " + "%r" + d.encoding() + ", %r" + a.encoding() + ";" + "");
-    }
-
-    public final void ret() {
-        emitString("ret;" + " " + "");
-    }
-
-    public final void ret_uni() {
-        emitString("ret.uni;" + " " + "");
-    }
-
-    public enum BooleanOperator {
-        AND("and"),
-        OR("or"),
-        XOR("xor");
-
-        private final String output;
-
-        private BooleanOperator(String out) {
-            this.output = out;
-        }
-
-        public String getOperator() {
-            return output + ".";
-        }
-    }
-
-    public static class Setp {
-
-        private BooleanOperator booleanOperator;
-        private ConditionOperator operator;
-        private Value first, second;
-        private Kind kind;
-        private int predicate;
-
-        public Setp(Condition condition, Value first, Value second, int predicateRegisterNumber) {
-            setFirst(first);
-            setSecond(second);
-            setPredicate(predicateRegisterNumber);
-            setKind();
-            setConditionOperator(operatorForConditon(condition));
-        }
-
-        public Setp(Condition condition, BooleanOperator operator, Value first, Value second, int predicateRegisterNumber) {
-            setFirst(first);
-            setSecond(second);
-            setPredicate(predicateRegisterNumber);
-            setKind();
-            setConditionOperator(operatorForConditon(condition));
-            setBooleanOperator(operator);
-        }
-
-        public void setFirst(Value v) {
-            first = v;
-        }
-
-        public void setSecond(Value v) {
-            second = v;
-        }
-
-        public void setPredicate(int p) {
-            predicate = p;
-        }
-
-        public void setConditionOperator(ConditionOperator co) {
-            operator = co;
-        }
-
-        public void setBooleanOperator(BooleanOperator bo) {
-            booleanOperator = bo;
-        }
-
-        private ConditionOperator operatorForConditon(Condition condition) {
-            char typeChar = kind.getTypeChar();
-
-            switch (typeChar) {
-                case 'z':
-                case 'c':
-                case 'a':
-                    // unsigned
-                    switch (condition) {
-                        case EQ:
-                            return ConditionOperator.U_EQ;
-                        case NE:
-                            return ConditionOperator.U_NE;
-                        case LT:
-                            return ConditionOperator.U_LO;
-                        case LE:
-                            return ConditionOperator.U_LS;
-                        case GT:
-                            return ConditionOperator.U_HI;
-                        case GE:
-                            return ConditionOperator.U_HS;
-                        default:
-                            throw GraalInternalError.shouldNotReachHere();
-                    }
-                case 'b':
-                case 's':
-                case 'i':
-                case 'j':
-                    // signed
-                    switch (condition) {
-                        case EQ:
-                            return ConditionOperator.S_EQ;
-                        case NE:
-                            return ConditionOperator.S_NE;
-                        case LT:
-                            return ConditionOperator.S_LT;
-                        case LE:
-                            return ConditionOperator.S_LE;
-                        case GT:
-                            return ConditionOperator.S_GT;
-                        case GE:
-                        case AE:
-                            return ConditionOperator.S_GE;
-                        default:
-                            throw GraalInternalError.shouldNotReachHere();
-                    }
-                case 'f':
-                case 'd':
-                    // floating point - do these need to accept NaN??
-                    switch (condition) {
-                        case EQ:
-                            return ConditionOperator.F_EQ;
-                        case NE:
-                            return ConditionOperator.F_NE;
-                        case LT:
-                            return ConditionOperator.F_LT;
-                        case LE:
-                            return ConditionOperator.F_LE;
-                        case GT:
-                            return ConditionOperator.F_GT;
-                        case GE:
-                            return ConditionOperator.F_GE;
-                        default:
-                            throw GraalInternalError.shouldNotReachHere();
-                    }
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public void setKind() {
-            // assert isConstant(first) && isConstant(second) == false;
-
-            if (isConstant(first)) {
-                kind = second.getKind();
-            } else {
-                kind = first.getKind();
-            }
-        }
-
-        public String emitValue(Value v) {
-            assert v != null;
-
-            if (isConstant(v)) {
-                return (", " + emitConstant(v));
-            } else {
-                return (", " + emitVariable((Variable) v));
-            }
-        }
-
-        public String typeForKind(Kind k) {
-            switch (k.getTypeChar()) {
-                case 'z':
-                    return "u8";
-                case 'b':
-                    return "s8";
-                case 's':
-                    return "s16";
-                case 'c':
-                    return "u16";
-                case 'i':
-                    return "s32";
-                case 'f':
-                    return "f32";
-                case 'j':
-                    return "s64";
-                case 'd':
-                    return "f64";
-                case 'a':
-                    return "u64";
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public String emitConstant(Value v) {
-            JavaConstant constant = (JavaConstant) v;
-
-            switch (v.getKind().getTypeChar()) {
-                case 'i':
-                    return (String.valueOf((int) constant.asLong()));
-                case 'f':
-                    return (String.valueOf(constant.asFloat()));
-                case 'j':
-                    return (String.valueOf(constant.asLong()));
-                case 'd':
-                    return (String.valueOf(constant.asDouble()));
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        public String emitVariable(Variable v) {
-            return ("%r" + v.index);
-        }
-
-        public void emit(PTXAssembler asm) {
-
-            if (booleanOperator != null) {
-                // Predicates need to be objects
-                asm.emitString("setp." + operator.getOperator() + "." + booleanOperator.getOperator() + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ", %r;");
-            } else {
-                asm.emitString("setp." + operator.getOperator() + "." + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ";");
-            }
-        }
-    }
-
-    @Override
-    public PTXAddress makeAddress(Register base, int displacement) {
-        throw GraalInternalError.shouldNotReachHere();
-    }
-
-    @Override
-    public PTXAddress getPlaceholder() {
-        return null;
-    }
-
-    @Override
-    public final void ensureUniquePC() {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void jmp(Label l) {
-        String str = nameOf(l);
-        bra(str);
-    }
-
-    /**
-     * @param r
-     */
-    public void nullCheck(Register r) {
-        // setp(....);
-    }
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXMacroAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,322 +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.asm.ptx;
-
-import sun.misc.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.lir.*;
-
-public class PTXMacroAssembler extends PTXAssembler {
-
-    public PTXMacroAssembler(TargetDescription target, RegisterConfig registerConfig) {
-        super(target, registerConfig);
-    }
-
-    public static class LoadAddr extends LoadStoreFormat {
-
-        public LoadAddr(PTXStateSpace space, Variable dst, Variable src1, Value src2) {
-            super(space, dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler masm) {
-            String ldAddrStr = "ld." + space.getStateName();
-            if (Unsafe.ADDRESS_SIZE == 8) {
-                ldAddrStr = ldAddrStr + ".u64";
-            } else {
-                ldAddrStr = ldAddrStr + ".u32";
-            }
-            masm.emitString(ldAddrStr + " " + emitRegister(dest, false) + ", " + emitAddress(source1, source2) + ";");
-        }
-    }
-
-    public static class Ld extends LoadStoreFormat {
-
-        public Ld(PTXStateSpace space, Variable dst, Variable src1, Value src2) {
-            super(space, dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("ld." + super.emit(true));
-        }
-    }
-
-    public static class St extends LoadStoreFormat {
-
-        public St(PTXStateSpace space, Variable dst, Variable src1, Value src2) {
-            super(space, dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("st." + super.emit(false));
-        }
-    }
-
-    public static class LoadParam extends Ld {
-        // Type of the operation is dependent on src1's type.
-        public LoadParam(PTXStateSpace space, Variable dst, Variable src1, Value src2) {
-            super(space, dst, src1, src2);
-            setKind(src1.getKind());
-        }
-    }
-
-    public static class Add extends StandardFormat {
-
-        public Add(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("add." + super.emit());
-        }
-    }
-
-    public static class And extends LogicInstructionFormat {
-
-        public And(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("and." + super.emit());
-        }
-    }
-
-    public static class Div extends StandardFormat {
-
-        public Div(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("div." + super.emit());
-        }
-    }
-
-    public static class Mul extends StandardFormat {
-
-        public Mul(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("mul.lo." + super.emit());
-        }
-    }
-
-    public static class Or extends LogicInstructionFormat {
-
-        public Or(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("or." + super.emit());
-        }
-    }
-
-    public static class Rem extends StandardFormat {
-
-        public Rem(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("rem." + super.emit());
-        }
-    }
-
-    public static class Shl extends LogicInstructionFormat {
-
-        public Shl(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("shl." + super.emit());
-        }
-    }
-
-    public static class Shr extends StandardFormat {
-
-        public Shr(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("shr." + super.emit());
-        }
-    }
-
-    public static class Sub extends StandardFormat {
-
-        public Sub(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("sub." + super.emit());
-        }
-    }
-
-    public static class Ushr extends StandardFormat {
-
-        public Ushr(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-            setKind(Kind.Illegal);  // get around not having an Unsigned Kind
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("shr." + super.emit());
-        }
-    }
-
-    public static class Xor extends LogicInstructionFormat {
-
-        public Xor(Variable dst, Value src1, Value src2) {
-            super(dst, src1, src2);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("xor." + super.emit());
-        }
-    }
-
-    public static class Cvt extends ConversionFormat {
-
-        public Cvt(Variable dst, Variable src, Kind dstKind, Kind srcKind) {
-            super(dst, src, dstKind, srcKind);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            if (dest.getKind() == Kind.Float || dest.getKind() == Kind.Double) {
-                // round-to-zero - might not be right
-                asm.emitString("cvt.rz." + super.emit());
-            } else {
-                asm.emitString("cvt." + super.emit());
-            }
-        }
-    }
-
-    public static class Mov extends SingleOperandFormat {
-
-        private int predicateRegisterNumber = -1;
-
-        public Mov(Variable dst, Value src) {
-            super(dst, src);
-        }
-
-        public Mov(Variable dst, Value src, int predicate) {
-            super(dst, src);
-            this.predicateRegisterNumber = predicate;
-        }
-
-        /*
-         * public Mov(Variable dst, AbstractAddress src) { throw
-         * GraalInternalError.unimplemented("AbstractAddress Mov"); }
-         */
-
-        public void emit(PTXMacroAssembler asm) {
-            if (predicateRegisterNumber >= 0) {
-                asm.emitString("@%p" + String.valueOf(predicateRegisterNumber) + " mov." + super.emit());
-            } else {
-                asm.emitString("mov." + super.emit());
-            }
-        }
-    }
-
-    public static class Neg extends SingleOperandFormat {
-
-        public Neg(Variable dst, Variable src) {
-            super(dst, src);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("neg." + super.emit());
-        }
-    }
-
-    public static class Not extends BinarySingleOperandFormat {
-
-        public Not(Variable dst, Variable src) {
-            super(dst, src);
-        }
-
-        public void emit(PTXMacroAssembler asm) {
-            asm.emitString("not." + super.emit());
-        }
-    }
-
-    public static class Param extends SingleOperandFormat {
-        boolean isReturnParameter;
-
-        public Param(Variable d, boolean isRet) {
-            super(d, null);
-            isReturnParameter = isRet;
-        }
-
-        public String emitParameter(Variable v) {
-            return (" param" + v.index);
-        }
-
-        public void emit(PTXMacroAssembler asm, boolean isLastParam) {
-            asm.emitString(".param ." + paramForKind(dest.getKind()) + emitParameter(dest) + (isLastParam ? "" : ","));
-        }
-
-        public String paramForKind(Kind k) {
-            if (isReturnParameter) {
-                if (Unsafe.ADDRESS_SIZE == 8) {
-                    return "u64";
-                } else {
-                    return "u32";
-                }
-            } else {
-                switch (k.getTypeChar()) {
-                    case 'z':
-                    case 'f':
-                        return "s32";
-                    case 'b':
-                        return "b8";
-                    case 's':
-                        return "s16";
-                    case 'c':
-                        return "u16";
-                    case 'i':
-                        return "s32";
-                    case 'j':
-                        return "s64";
-                    case 'd':
-                        return "f64";
-                    case 'a':
-                        return "u64";
-                    default:
-                        throw GraalInternalError.shouldNotReachHere();
-                }
-            }
-        }
-
-    }
-
-}
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXStateSpace.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.asm.ptx;
-
-/**
- * Represents the various PTX state spaces.
- */
-public enum PTXStateSpace {
-
-    Parameter("param"),
-
-    Shared("shared"),
-
-    Local("local"),
-
-    Global("global"),
-
-    Const("const");
-
-    private final String stateName;
-
-    private PTXStateSpace(String name) {
-        this.stateName = name;
-    }
-
-    public String getStateName() {
-        return stateName;
-    }
-}
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,7 +29,6 @@
 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.alloc.*;
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.calc.*;
@@ -74,17 +73,17 @@
     }
 
     public BaselineBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
-                    BaselineFrameStateBuilder frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI, Backend backend) {
+                    BaselineFrameStateBuilder frameState, Backend backend) {
 
-        super(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI);
+        super(metaAccess, method, graphBuilderConfig, optimisticOpts);
         this.backend = backend;
+        this.setCurrentFrameState(frameState);
     }
 
     public LIRGenerationResult getLIRGenerationResult() {
         return lirGenRes;
     }
 
-    @Override
     protected void build() {
         if (PrintProfilingInformation.getValue()) {
             TTY.println("Profiling info for " + method.format("%H.%n(%p)"));
@@ -715,7 +714,6 @@
         resolver.dispose();
     }
 
-    @Override
     protected void processBlock(BciBlock block) {
         frameState = (BaselineFrameStateBuilder) block.entryState;
         setCurrentFrameState(frameState);
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Wed Jan 28 19:32:47 2015 +0100
@@ -51,15 +51,12 @@
 
     public CompilationResult generate(ResolvedJavaMethod method, int entryBCI, Backend backend, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner,
                     CompilationResultBuilderFactory factory, OptimisticOptimizations optimisticOpts) {
-        ProfilingInfo profilingInfo = method.getProfilingInfo();
         assert method.getCode() != null : "method must contain bytecodes: " + method;
-        BytecodeStream stream = new BytecodeStream(method.getCode());
-        ConstantPool constantPool = method.getConstantPool();
         TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
 
         BaselineFrameStateBuilder frameState = new BaselineFrameStateBuilder(method);
 
-        BaselineBytecodeParser parser = new BaselineBytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI, backend);
+        BaselineBytecodeParser parser = new BaselineBytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, backend);
 
         // build blocks and LIR instructions
         try {
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -105,6 +105,28 @@
         }
     }
 
+    /**
+     * Checks whether the supplied constant can be used without loading it into a register for store
+     * operations, i.e., on the right hand side of a memory access.
+     *
+     * @param c The constant to check.
+     * @return True if the constant can be used directly, false if the constant needs to be in a
+     *         register.
+     */
+    protected boolean canStoreConstant(JavaConstant c) {
+        // there is no immediate move of 64-bit constants on Intel
+        switch (c.getKind()) {
+            case Long:
+                return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c);
+            case Double:
+                return false;
+            case Object:
+                return c.isNull();
+            default:
+                return true;
+        }
+    }
+
     protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) {
         if (src instanceof AMD64AddressValue) {
             return new LeaOp(dst, (AMD64AddressValue) src);
@@ -966,7 +988,7 @@
     public abstract void emitCCall(long address, CallingConvention nativeCallingConvention, Value[] args, int numberOfFloatingPointArguments);
 
     @Override
-    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
+    protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
         long maxOffset = linkage.getMaxCallTargetOffset();
         if (maxOffset != (int) maxOffset) {
             append(new AMD64Call.DirectFarForeignCallOp(linkage, result, arguments, temps, info));
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -60,6 +60,12 @@
     @Option(help = "Graphs with less than this number of nodes are trivial and therefore always inlined.", type = OptionType.Expert)
     public static final OptionValue<Integer> TrivialInliningSize = new OptionValue<>(10);
 
+    @Option(help = "Inlines trivial methods during parsing of the bytecodes.", type = OptionType.Expert)
+    public static final StableOptionValue<Boolean> InlineDuringParsing = new StableOptionValue<>(false);
+
+    @Option(help = "Maximum depth when inlining during parsing.", type = OptionType.Debug)
+    public static final StableOptionValue<Integer> InlineDuringParsingMaxDepth = new StableOptionValue<>(10);
+
     @Option(help = "Inlining is explored up to this number of nodes in the graph for each call site.", type = OptionType.Expert)
     public static final OptionValue<Integer> MaximumInliningSize = new OptionValue<>(300);
 
@@ -172,6 +178,9 @@
     @Option(help = "Enable dumping LIR, register allocation and code generation info to the C1Visualizer.", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintBackendCFG = new OptionValue<>(true);
 
+    @Option(help = "Enable dumping to the IdealGraphVisualizer.", type = OptionType.Debug)
+    public static final OptionValue<Boolean> PrintIdealGraph = new OptionValue<>(true);
+
     @Option(help = "", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintIdealGraphFile = new OptionValue<>(false);
 
@@ -215,9 +224,6 @@
     @Option(help = "", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintStackTraceOnException = new OptionValue<>(false);
 
-    @Option(help = "Set a phase after which the decompiler dumps the graph, -G:Dump= required", type = OptionType.Debug)
-    public static final OptionValue<String> DecompileAfterPhase = new OptionValue<>(null);
-
     // HotSpot command line options
     @Option(help = "Print inlining optimizations", type = OptionType.Debug)
     public static final OptionValue<Boolean> HotSpotPrintInlining = new OptionValue<>(false);
@@ -226,10 +232,6 @@
     @Option(help = "Comma separated list of register that the allocation is limited to.", type = OptionType.Debug)
     public static final OptionValue<String> RegisterPressure = new OptionValue<>(null);
 
-    // Code generator settings
-    @Option(help = "", type = OptionType.Debug)
-    public static final OptionValue<Boolean> FlowSensitiveReduction = new OptionValue<>(false);
-
     @Option(help = "", type = OptionType.Debug)
     public static final OptionValue<Boolean> ConditionalElimination = new OptionValue<>(true);
 
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ArithmeticOpTable.java	Wed Jan 28 19:32:47 2015 +0100
@@ -79,6 +79,7 @@
     private final IntegerConvertOp<Narrow> narrow;
 
     private final FloatConvertOp[] floatConvert;
+    private final int hash;
 
     public static ArithmeticOpTable forStamp(Stamp s) {
         if (s instanceof ArithmeticStamp) {
@@ -170,6 +171,13 @@
         this.narrow = narrow;
         this.floatConvert = new FloatConvertOp[FloatConvert.values().length];
         floatConvert.forEach(op -> this.floatConvert[op.getFloatConvert().ordinal()] = op);
+
+        this.hash = Objects.hash(neg, add, sub, mul, div, rem, not, and, or, xor, shl, shr, ushr, abs, sqrt, zeroExtend, signExtend, narrow);
+    }
+
+    @Override
+    public int hashCode() {
+        return hash;
     }
 
     /**
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/ForceDeoptSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.infra;
-
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.api.meta.*;
-
-@ClassSubstitution(GraalKernelTester.class)
-class ForceDeoptSubstitutions {
-
-    /**
-     * Allows us to force a non-exception throwing deopt from java code.
-     */
-    @MethodSubstitution
-    public static int forceDeopt(int x) {
-        DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
-        // will never get here but keep the compiler happy
-        return x * x;
-    }
-
-    @MethodSubstitution
-    public static double forceDeopt(double x) {
-        DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint);
-        // will never get here but keep the compiler happy
-        return x * x;
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/GraalKernelTester.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,226 +0,0 @@
-/*
- * 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.infra;
-
-/**
- * This class extends KernelTester and provides a base class
- * for which the HSAIL code comes from the Graal compiler.
- */
-import static com.oracle.graal.compiler.common.GraalOptions.*;
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static org.junit.Assume.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.hsail.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hsail.*;
-import com.oracle.graal.options.*;
-import com.oracle.graal.options.OptionValue.OverrideScope;
-
-public abstract class GraalKernelTester extends KernelTester {
-
-    private static boolean substitutionsInstalled;
-
-    private static synchronized void installSubstitutions() {
-        if (!substitutionsInstalled) {
-            getHSAILBackend().getProviders().getReplacements().registerSubstitutions(GraalKernelTester.class, ForceDeoptSubstitutions.class);
-            substitutionsInstalled = true;
-        }
-    }
-
-    public GraalKernelTester() {
-        super(getHSAILBackend().isDeviceInitialized());
-        installSubstitutions();
-    }
-
-    protected static HSAILHotSpotBackend getHSAILBackend() {
-        Backend backend = runtime().getBackend(HSAIL.class);
-        Assume.assumeTrue("No HSAIL backend, skipping test!", backend instanceof HSAILHotSpotBackend);
-        return (HSAILHotSpotBackend) backend;
-    }
-
-    ExternalCompilationResult hsailCode;
-    private boolean showHsailSource = false;
-    private boolean saveInFile = false;
-
-    @Override
-    public String getCompiledHSAILSource(Method method) {
-        if (hsailCode == null) {
-            HSAILHotSpotBackend backend = getHSAILBackend();
-            ResolvedJavaMethod javaMethod = backend.getProviders().getMetaAccess().lookupJavaMethod(method);
-            hsailCode = backend.compileKernel(javaMethod, false);
-        }
-        String hsailSource = hsailCode.getCodeString();
-        if (showHsailSource) {
-            logger.severe(hsailSource);
-        }
-        if (saveInFile) {
-            try {
-                File fout = File.createTempFile("tmp", ".hsail");
-                logger.fine("creating " + fout.getCanonicalPath());
-                FileWriter fw = new FileWriter(fout);
-                BufferedWriter bw = new BufferedWriter(fw);
-                bw.write(hsailSource);
-                bw.close();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return hsailSource;
-    }
-
-    public boolean aggressiveInliningEnabled() {
-        return (InlineEverything.getValue());
-    }
-
-    public boolean canHandleHSAILMethodCalls() {
-        // needs 2 things, backend needs to be able to generate such calls, and target needs to be
-        // able to run them
-        boolean canGenerateCalls = false;   // not implemented yet
-        boolean canExecuteCalls = runningOnSimulator();
-        return (canGenerateCalls && canExecuteCalls);
-    }
-
-    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 we are running CQE tests (via a -D flag).
-     */
-    public boolean runningCQETests() {
-        return Boolean.getBoolean("com.amd.CQE");
-    }
-
-    /**
-     * Determines if the JVM supports the required typeProfileWidth.
-     */
-    public boolean typeProfileWidthAtLeast(int val) {
-        return (getHSAILBackend().getRuntime().getConfig().typeProfileWidth >= val);
-    }
-
-    /**
-     * Determines if the runtime supports {@link VirtualObject}s in {@link DebugInfo} associated
-     * with HSAIL code.
-     */
-    public boolean canHandleDeoptVirtualObjects() {
-        return true;
-    }
-
-    /**
-     * Determines if the runtime has the capabilities required by this test.
-     */
-    protected boolean supportsRequiredCapabilities() {
-        return true;
-    }
-
-    HotSpotNmethod installedCode;
-
-    @Override
-    protected void dispatchKernelOkra(int range, Object... args) {
-        HSAILHotSpotBackend backend = getHSAILBackend();
-        if (backend.isDeviceInitialized()) {
-            try {
-                if (installedCode == null) {
-                    installedCode = backend.compileAndInstallKernel(testMethod);
-                }
-                backend.executeKernel(installedCode, range, args);
-            } catch (InvalidInstalledCodeException e) {
-                Debug.log("WARNING:Invalid installed code: " + e);
-                e.printStackTrace();
-            }
-        } else {
-            super.dispatchKernelOkra(range, args);
-        }
-    }
-
-    public static OptionValue<?> getOptionFromField(Class<?> declaringClass, String fieldName) {
-        try {
-            Field f = declaringClass.getDeclaredField(fieldName);
-            f.setAccessible(true);
-            return (OptionValue<?>) f.get(null);
-        } catch (Exception e) {
-            throw new GraalInternalError(e);
-        }
-    }
-
-    private OptionValue<?> accessibleRemoveNeverExecutedCode = getOptionFromField(GraalOptions.class, "RemoveNeverExecutedCode");
-
-    // Special overrides for the testGeneratedxxx routines which set
-    // required graal options that we need to run any junit test
-
-    private OverrideScope getOverrideScope() {
-        return OptionValue.override(GraalOptions.InlineEverything, true, accessibleRemoveNeverExecutedCode, false);
-    }
-
-    @Override
-    public void testGeneratedHsail() {
-        try (OverrideScope s = getOverrideScope()) {
-            assumeTrue("Orka environment not initialized or unsupported!", supportsRequiredCapabilities() && okraEnvIsInitialized());
-            super.testGeneratedHsail();
-        }
-    }
-
-    @Override
-    public void testGeneratedHsailUsingLambdaMethod() {
-        try (OverrideScope s = getOverrideScope()) {
-            assumeTrue("Orka environment not initialized or unsupported!", supportsRequiredCapabilities() && okraEnvIsInitialized());
-            super.testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-
-    // used for forcing a deoptimization
-    public static int forceDeopt(int x) {
-        return x * x;
-    }
-
-    public static double forceDeopt(double x) {
-        return x * x;
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test.infra/src/com/oracle/graal/compiler/hsail/test/infra/KernelTester.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,795 +0,0 @@
-/*
- * 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.infra;
-
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-
-import java.io.*;
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.nio.file.*;
-import java.util.*;
-import java.util.concurrent.atomic.*;
-import java.util.logging.*;
-
-import com.amd.okra.*;
-import com.oracle.graal.test.*;
-
-/**
- * Abstract class on which the HSAIL unit tests are built. Executes a method or lambda on both the
- * Java side and the Okra side and compares the results for fields that are annotated with
- * {@link Result}.
- */
-public abstract class KernelTester extends GraalTest {
-
-    /**
-     * Denotes a field whose value is to be
-     * {@linkplain KernelTester#assertResultFieldsEqual(KernelTester) compared} as part of computing
-     * the result of a test.
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @Target(ElementType.FIELD)
-    public @interface Result {
-    }
-
-    // Using these in case we want to compile with Java 7.
-    public interface MyIntConsumer {
-
-        void accept(int value);
-    }
-
-    public interface MyObjConsumer {
-
-        void accept(Object obj);
-    }
-
-    public enum DispatchMode {
-        SEQ,
-        JTP,
-        OKRA
-    }
-
-    public enum HsailMode {
-        COMPILED,
-        INJECT_HSAIL,
-        INJECT_OCL
-    }
-
-    public DispatchMode dispatchMode;
-    // Where the hsail comes from.
-    private HsailMode hsailMode;
-    protected Method testMethod;
-    // What type of okra dispatch to use when client calls.
-    private boolean useLambdaMethod;
-    private Class<?>[] testMethodParams = null;
-    private int id = nextId.incrementAndGet();
-    static AtomicInteger nextId = new AtomicInteger(0);
-    public static Logger logger;
-    private OkraContext okraContext;
-    private OkraKernel okraKernel;
-    private static final String propPkgName = KernelTester.class.getPackage().getName();
-    private static Level logLevel;
-    private static ConsoleHandler consoleHandler;
-    private boolean runOkraFirst = Boolean.getBoolean("kerneltester.runOkraFirst");
-
-    static {
-        logger = Logger.getLogger(propPkgName);
-        logLevel = Level.parse(System.getProperty("kerneltester.logLevel", "OFF"));
-
-        // This block configure the logger with handler and formatter.
-        consoleHandler = new ConsoleHandler();
-        logger.addHandler(consoleHandler);
-        logger.setUseParentHandlers(false);
-        SimpleFormatter formatter = new SimpleFormatter() {
-
-            @SuppressWarnings("sync-override")
-            @Override
-            public String format(LogRecord record) {
-                return (record.getMessage() + "\n");
-            }
-        };
-        consoleHandler.setFormatter(formatter);
-        setLogLevel(logLevel);
-    }
-
-    private static boolean gaveNoOkraWarning = false;
-    private boolean onSimulator;
-    private final boolean okraLibExists;
-
-    public boolean runningOnSimulator() {
-        return onSimulator;
-    }
-
-    public boolean okraEnvIsInitialized() {
-        return this.okraLibExists;
-    }
-
-    public KernelTester(boolean okraLibExists) {
-        dispatchMode = DispatchMode.SEQ;
-        hsailMode = HsailMode.COMPILED;
-        useLambdaMethod = false;
-
-        this.okraLibExists = okraLibExists || OkraUtil.okraLibExists();
-        if (!this.okraLibExists) {
-            logger.info("Okra native library cannot be found or loaded while running" + this.getClass().getSimpleName());
-            return;
-        }
-
-        // Control which okra instances can run the tests (isSimulator is static).
-        onSimulator = OkraContext.isSimulator();
-    }
-
-    public abstract void runTest();
-
-    /**
-     * Asserts that the value of all {@link Result} annotated fields in this object and
-     * {@code other} are {@linkplain #assertDeepEquals(Object, Object) equal}.
-     *
-     * @throws AssertionError if the value of a result field in this and {@code other} are not equal
-     */
-    public void assertResultFieldsEqual(KernelTester other) {
-        Class<?> clazz = this.getClass();
-        while (clazz != null && clazz != KernelTester.class) {
-            for (Field f : clazz.getDeclaredFields()) {
-                if (!Modifier.isStatic(f.getModifiers())) {
-                    Result annos = f.getAnnotation(Result.class);
-                    if (annos != null) {
-                        Object actualResult = getFieldFromObject(f, this);
-                        Object expectedResult = getFieldFromObject(f, other);
-                        assertDeepEquals(f.toString(), expectedResult, actualResult);
-                    }
-                }
-            }
-            clazz = clazz.getSuperclass();
-        }
-    }
-
-    public void setDispatchMode(DispatchMode dispatchMode) {
-        this.dispatchMode = dispatchMode;
-    }
-
-    public void setHsailMode(HsailMode hsailMode) {
-        this.hsailMode = hsailMode;
-    }
-
-    /**
-     * Return a clone of this instance unless overridden, we just call the null constructor.
-     */
-    public KernelTester newInstance() {
-        try {
-            return this.getClass().getConstructor((Class<?>[]) null).newInstance();
-        } catch (Throwable t) {
-            fail("Unexpected exception " + t);
-            return null;
-        }
-    }
-
-    public Method getMethodFromMethodName(String methName, Class<?> clazz) {
-        Class<?> clazz2 = clazz;
-        while (clazz2 != null) {
-            for (Method m : clazz2.getDeclaredMethods()) {
-                logger.fine(" in " + clazz2 + ", trying to match " + m);
-                if (m.getName().equals(methName)) {
-                    testMethodParams = m.getParameterTypes();
-                    if (logLevel.intValue() <= Level.FINE.intValue()) {
-                        logger.fine(" in " + clazz2 + ", matched " + m);
-                        logger.fine("parameter types are...");
-                        int paramNum = 0;
-                        for (Class<?> pclazz : testMethodParams) {
-                            logger.fine(paramNum++ + ") " + pclazz.toString());
-                        }
-                    }
-                    return m;
-                }
-            }
-            // Didn't find it in current clazz, try superclass.
-            clazz2 = clazz2.getSuperclass();
-        }
-        // If we got this far, no match.
-        return null;
-    }
-
-    private void setTestMethod(String methName, Class<?> inClazz) {
-        testMethod = getMethodFromMethodName(methName, inClazz);
-        if (testMethod == null) {
-            fail("cannot find method " + methName + " in class " + inClazz);
-        } else {
-            // Print info but only for first such class.
-            if (id == 1) {
-                logger.fine("testMethod to be compiled is \n   " + testMethod);
-            }
-        }
-    }
-
-    // Default is method name "run", but could be overridden.
-    private final String defaultMethodName = "run";
-
-    public String getTestMethodName() {
-        return defaultMethodName;
-    }
-
-    /**
-     * The dispatchMethodKernel dispatches a non-lambda method. All the parameters of the compiled
-     * method are supplied as parameters to this call.
-     */
-    public void dispatchMethodKernel(int range, Object... args) {
-        if (testMethod == null) {
-            setTestMethod(getTestMethodName(), this.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchMethodKernelSeq(range, args);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchMethodKernelOkra(range, args);
-        }
-    }
-
-    /**
-     * The "array stream" version of {@link #dispatchMethodKernel(int, Object...)}.
-     */
-    public void dispatchMethodKernel(Object[] ary, Object... args) {
-        if (testMethod == null) {
-            setTestMethod(getTestMethodName(), this.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchMethodKernelSeq(ary, args);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchMethodKernelOkra(ary, args);
-        }
-    }
-
-    /**
-     * This dispatchLambdaMethodKernel dispatches the lambda version of a kernel where the "kernel"
-     * is for the lambda method itself (like lambda$0).
-     */
-    public void dispatchLambdaMethodKernel(int range, MyIntConsumer consumer) {
-        if (testMethod == null) {
-            setTestMethod(findLambdaMethodName(), this.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchLambdaKernelSeq(range, consumer);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchLambdaMethodKernelOkra(range, consumer);
-        }
-    }
-
-    public void dispatchLambdaMethodKernel(Object[] ary, MyObjConsumer consumer) {
-        if (testMethod == null) {
-            setTestMethod(findLambdaMethodName(), this.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchLambdaKernelSeq(ary, consumer);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchLambdaMethodKernelOkra(ary, consumer);
-        }
-    }
-
-    /**
-     * 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) {
-            dispatchLambdaMethodKernel(range, consumer);
-            return;
-        }
-        if (testMethod == null) {
-            setTestMethod("accept", consumer.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchLambdaKernelSeq(range, consumer);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchLambdaKernelOkra(range, consumer);
-        }
-    }
-
-    public void dispatchLambdaKernel(Object[] ary, MyObjConsumer consumer) {
-        if (useLambdaMethod) {
-            dispatchLambdaMethodKernel(ary, consumer);
-            return;
-        }
-        if (testMethod == null) {
-            setTestMethod("accept", consumer.getClass());
-        }
-        if (dispatchMode == DispatchMode.SEQ) {
-            dispatchLambdaKernelSeq(ary, consumer);
-        } else if (dispatchMode == DispatchMode.OKRA) {
-            dispatchLambdaKernelOkra(ary, consumer);
-        }
-    }
-
-    private ArrayList<String> getLambdaMethodNames() {
-        Class<?> clazz = this.getClass();
-        ArrayList<String> lambdaNames = new ArrayList<>();
-        while (clazz != null && (lambdaNames.size() == 0)) {
-            for (Method m : clazz.getDeclaredMethods()) {
-                logger.fine(" in " + clazz + ", trying to match " + m);
-                if (m.getName().startsWith("lambda$")) {
-                    lambdaNames.add(m.getName());
-                }
-            }
-            // Didn't find it in current clazz, try superclass.
-            clazz = clazz.getSuperclass();
-        }
-        return lambdaNames;
-    }
-
-    /**
-     * findLambdaMethodName finds a name in the class starting with lambda$. If we find more than
-     * one, throw an error, and tell user to override explicitly
-     */
-    private String findLambdaMethodName() {
-        // If user overrode getTestMethodName, use that name.
-        if (!getTestMethodName().equals(defaultMethodName)) {
-            return getTestMethodName();
-        } else {
-            ArrayList<String> lambdaNames = getLambdaMethodNames();
-            switch (lambdaNames.size()) {
-                case 1:
-                    return lambdaNames.get(0);
-                case 0:
-                    fail("No lambda method found in " + this.getClass());
-                    return null;
-                default:
-                    // More than one lambda.
-                    String msg = "Multiple lambda methods found in " + this.getClass() + "\nYou should override getTestMethodName with one of the following\n";
-                    for (String name : lambdaNames) {
-                        msg = msg + name + "\n";
-                    }
-                    fail(msg);
-                    return null;
-            }
-        }
-    }
-
-    /**
-     * The getCompiledHSAILSource returns the string of HSAIL code for the compiled method. By
-     * default, throws an error. In graal for instance, this would be overridden in
-     * GraalKernelTester.
-     */
-    public String getCompiledHSAILSource(Method testMethod1) {
-        fail("no compiler connected so unable to compile " + testMethod1 + "\nYou could try injecting HSAIL or OpenCL");
-        return null;
-    }
-
-    public String getHSAILSource(Method testMethod1) {
-        switch (hsailMode) {
-            case COMPILED:
-                return getCompiledHSAILSource(testMethod1);
-            case INJECT_HSAIL:
-                return getHsailFromClassnameHsailFile();
-            case INJECT_OCL:
-                return getHsailFromClassnameOclFile();
-            default:
-                fail("unknown hsailMode = " + hsailMode);
-                return null;
-        }
-    }
-
-    /**
-     * The getHSAILKernelName returns the name of the hsail kernel. By default we use 'run'. unless
-     * coming from opencl injection. Could be overridden by the junit test.
-     */
-    public String getHSAILKernelName() {
-        return (hsailMode != HsailMode.INJECT_OCL ? "&run" : "&__OpenCL_run_kernel");
-    }
-
-    private void createOkraKernel() {
-        // Call routines in the derived class to get the hsail code and kernel name.
-        String hsailSource = getHSAILSource(testMethod);
-        if (!okraLibExists) {
-            if (!gaveNoOkraWarning) {
-                logger.severe("No Okra library detected, skipping all KernelTester tests in " + this.getClass().getPackage().getName());
-                gaveNoOkraWarning = true;
-            }
-        }
-        // Ignore any kerneltester test if okra does not exist.
-        assumeTrue("No Okra library detected, skipping test!", okraLibExists);
-        // Control which okra instances can run the tests.
-        onSimulator = OkraContext.isSimulator();
-        okraContext = new OkraContext();
-        if (!okraContext.isValid()) {
-            fail("...unable to create context");
-        }
-        // Control verbosity in okra from our logLevel.
-        if (logLevel.intValue() <= Level.INFO.intValue()) {
-            okraContext.setVerbose(true);
-        }
-        okraKernel = new OkraKernel(okraContext, hsailSource, getHSAILKernelName());
-        if (!okraKernel.isValid()) {
-            fail("...unable to create kernel");
-        }
-    }
-
-    /**
-     * Dispatches an okra kernel over a given range using JNI. Protected so that it can be
-     * overridden in {@link GraalKernelTester} which will dispatch without JNI.
-     */
-    protected void dispatchKernelOkra(int range, Object... args) {
-        if (okraKernel == null) {
-            createOkraKernel();
-        }
-        if (logLevel.intValue() <= Level.FINE.intValue()) {
-            logger.fine("Arguments passed to okra...");
-            for (Object arg : args) {
-                logger.fine("  " + arg);
-            }
-        }
-        okraKernel.setLaunchAttributes(range);
-        okraKernel.dispatchWithArgs(args);
-    }
-
-    // int stream version
-    private void dispatchMethodKernelSeq(int range, Object... args) {
-        Object[] invokeArgs = new Object[args.length + 1];
-        // Need space on the end for the gid parameter.
-        System.arraycopy(args, 0, invokeArgs, 0, args.length);
-        int gidArgIndex = invokeArgs.length - 1;
-        if (logLevel.intValue() <= Level.FINE.intValue()) {
-            for (Object arg : args) {
-                logger.fine(arg.toString());
-            }
-        }
-        for (int rangeIndex = 0; rangeIndex < range; rangeIndex++) {
-            invokeArgs[gidArgIndex] = rangeIndex;
-            invokeMethodKernelSeq(invokeArgs, rangeIndex);
-        }
-    }
-
-    // array stream version
-    private void dispatchMethodKernelSeq(Object[] ary, Object... args) {
-        Object[] invokeArgs = new Object[args.length + 1];
-        // Need space on the end for the final obj parameter.
-        System.arraycopy(args, 0, invokeArgs, 0, args.length);
-        int objArgIndex = invokeArgs.length - 1;
-        if (logLevel.intValue() <= Level.FINE.intValue()) {
-            for (Object arg : args) {
-                logger.fine(arg.toString());
-            }
-        }
-        int range = ary.length;
-        for (int rangeIndex = 0; rangeIndex < range; rangeIndex++) {
-            invokeArgs[objArgIndex] = ary[rangeIndex];
-            invokeMethodKernelSeq(invokeArgs, rangeIndex);
-        }
-    }
-
-    private void invokeMethodKernelSeq(Object[] invokeArgs, int rangeIndex) {
-        try {
-            testMethod.invoke(this, invokeArgs);
-        } catch (IllegalAccessException e) {
-            fail("could not invoke " + testMethod + ", make sure it is public");
-        } catch (IllegalArgumentException e) {
-            fail("wrong arguments invoking " + testMethod + ", check number and type of args passed to dispatchMethodKernel");
-        } catch (InvocationTargetException e) {
-            Throwable cause = e.getCause();
-            if (cause instanceof RuntimeException) {
-                throw ((RuntimeException) cause);
-            } else {
-                String errstr = testMethod + " threw a checked exception on gid=" + rangeIndex + ", exception was " + cause;
-                fail(errstr);
-            }
-        } catch (Exception e) {
-            fail("Unknown exception " + e + " invoking " + testMethod);
-        }
-    }
-
-    // int stream version
-    private void dispatchMethodKernelOkra(int range, Object... args) {
-        Object[] fixedArgs = fixArgTypes(args);
-        if (Modifier.isStatic(testMethod.getModifiers())) {
-            dispatchKernelOkra(range, fixedArgs);
-        } else {
-            // If it is a non-static method we have to push "this" as the first argument.
-            Object[] newFixedArgs = new Object[fixedArgs.length + 1];
-            System.arraycopy(fixedArgs, 0, newFixedArgs, 1, fixedArgs.length);
-            newFixedArgs[0] = this;
-            dispatchKernelOkra(range, newFixedArgs);
-        }
-    }
-
-    // array stream version
-    private void dispatchMethodKernelOkra(Object[] ary, Object... args) {
-        // add the ary itself as the last arg in the passed parameter list
-        Object[] argsWithAry = new Object[args.length + 1];
-        System.arraycopy(args, 0, argsWithAry, 0, args.length);
-        argsWithAry[argsWithAry.length - 1] = ary;
-
-        Object[] fixedArgs = fixArgTypes(argsWithAry);
-        int range = ary.length;
-        if (Modifier.isStatic(testMethod.getModifiers())) {
-            dispatchKernelOkra(range, fixedArgs);
-        } else {
-            // If it is a non-static method we have to push "this" as the first argument.
-            Object[] newFixedArgs = new Object[fixedArgs.length + 1];
-            System.arraycopy(fixedArgs, 0, newFixedArgs, 1, fixedArgs.length);
-            newFixedArgs[0] = this;
-            dispatchKernelOkra(range, newFixedArgs);
-        }
-    }
-
-    /**
-     * For primitive arg parameters, make sure arg types are cast to whatever the testMethod
-     * signature says they should be.
-     */
-    protected Object[] fixArgTypes(Object[] args) {
-        Object[] fixedArgs = new Object[args.length];
-        for (int i = 0; i < args.length; i++) {
-            Class<?> paramClass = testMethodParams[i];
-            if (paramClass.equals(Float.class) || paramClass.equals(float.class)) {
-                fixedArgs[i] = ((Number) args[i]).floatValue();
-            } else if (paramClass.equals(Integer.class) || paramClass.equals(int.class)) {
-                fixedArgs[i] = ((Number) args[i]).intValue();
-            } else if (paramClass.equals(Long.class) || paramClass.equals(long.class)) {
-                fixedArgs[i] = ((Number) args[i]).longValue();
-            } else if (paramClass.equals(Double.class) || paramClass.equals(double.class)) {
-                fixedArgs[i] = ((Number) args[i]).doubleValue();
-            } else if (paramClass.equals(Byte.class) || paramClass.equals(byte.class)) {
-                fixedArgs[i] = ((Number) args[i]).byteValue();
-            } else if (paramClass.equals(Boolean.class) || paramClass.equals(boolean.class)) {
-                fixedArgs[i] = (boolean) args[i];
-            } else {
-                // All others just move unchanged.
-                fixedArgs[i] = args[i];
-            }
-        }
-        return fixedArgs;
-    }
-
-    /**
-     * Dispatching a lambda on the java side is simple.
-     */
-    @SuppressWarnings("static-method")
-    private void dispatchLambdaKernelSeq(int range, MyIntConsumer consumer) {
-        for (int i = 0; i < range; i++) {
-            consumer.accept(i);
-        }
-    }
-
-    @SuppressWarnings("static-method")
-    private void dispatchLambdaKernelSeq(Object[] ary, MyObjConsumer consumer) {
-        for (Object obj : ary) {
-            consumer.accept(obj);
-        }
-    }
-
-    /**
-     * The dispatchLambdaMethodKernelOkra dispatches in the case where the hsail kernel implements
-     * the lambda method itself as opposed to the wrapper that calls the lambda method. From the
-     * consumer object, we need to find the fields and pass them to the kernel.
-     */
-    protected void dispatchLambdaMethodKernelOkra(int range, MyIntConsumer consumer) {
-        logger.info("To determine parameters to pass to hsail kernel, we will examine   " + consumer.getClass());
-        Field[] fields = consumer.getClass().getDeclaredFields();
-        Object[] args = new Object[fields.length];
-        int argIndex = 0;
-        for (Field f : fields) {
-            logger.info("... " + f);
-            args[argIndex++] = getFieldFromObject(f, consumer);
-        }
-        dispatchKernelOkra(range, args);
-    }
-
-    private void dispatchLambdaMethodKernelOkra(Object[] ary, MyObjConsumer consumer) {
-        logger.info("To determine parameters to pass to hsail kernel, we will examine   " + consumer.getClass());
-        Field[] fields = consumer.getClass().getDeclaredFields();
-        Object[] args = new Object[fields.length + 1];  // + 1 because we also pass the array
-        int argIndex = 0;
-        for (Field f : fields) {
-            logger.info("... " + f);
-            args[argIndex++] = getFieldFromObject(f, consumer);
-        }
-        args[argIndex] = ary;
-        dispatchKernelOkra(ary.length, args);
-    }
-
-    /**
-     * The dispatchLambdaKernelOkra dispatches in the case where the hsail kernel where the hsail
-     * kernel implements the accept method of the wrapper that calls the lambda method as opposed to
-     * the actual lambda method itself.
-     */
-    private void dispatchLambdaKernelOkra(int range, MyIntConsumer consumer) {
-        // The "wrapper" method always has only one arg consisting of the consumer.
-        Object[] args = new Object[1];
-        args[0] = consumer;
-        dispatchKernelOkra(range, args);
-    }
-
-    private void dispatchLambdaKernelOkra(Object[] ary, MyObjConsumer consumer) {
-        // The "wrapper" method always has only one arg consisting of the consumer.
-        Object[] args = new Object[2];
-        args[0] = consumer;
-        args[1] = ary;
-        dispatchKernelOkra(ary.length, args);
-    }
-
-    private void disposeKernelOkra() {
-        if (okraContext != null) {
-            okraContext.dispose();
-        }
-    }
-
-    private void assertOkraEqualsSeq(HsailMode hsailModeToUse) {
-        assertOkraEqualsSeq(hsailModeToUse, false);
-    }
-
-    /**
-     * Runs this instance on OKRA, and as SEQ and compares the output of the two executions. the
-     * runOkraFirst flag controls which order they are done in. Note the compiler must use eager
-     * resolving if Okra is done first.
-     */
-    private void assertOkraEqualsSeq(HsailMode hsailModeToUse, boolean useLambda) {
-        KernelTester testerSeq;
-        if (runOkraFirst) {
-            runOkraInstance(hsailModeToUse, useLambda);
-            testerSeq = runSeqInstance();
-        } else {
-            testerSeq = runSeqInstance();
-            runOkraInstance(hsailModeToUse, useLambda);
-        }
-        assertResultFieldsEqual(testerSeq);
-    }
-
-    private void runOkraInstance(HsailMode hsailModeToUse, boolean useLambda) {
-        // run Okra instance in exiting KernelTester object
-        this.setHsailMode(hsailModeToUse);
-        this.setDispatchMode(DispatchMode.OKRA);
-        this.useLambdaMethod = useLambda;
-        this.runTest();
-        this.disposeKernelOkra();
-    }
-
-    private KernelTester runSeqInstance() {
-        // Create and run sequential instance.
-        KernelTester testerSeq = newInstance();
-        testerSeq.setDispatchMode(DispatchMode.SEQ);
-        testerSeq.runTest();
-        return testerSeq;
-    }
-
-    public void testGeneratedHsail() {
-        assertOkraEqualsSeq(HsailMode.COMPILED);
-    }
-
-    public void testGeneratedHsailUsingLambdaMethod() {
-        assertOkraEqualsSeq(HsailMode.COMPILED, true);
-    }
-
-    public void testInjectedHsail() {
-        newInstance().assertOkraEqualsSeq(HsailMode.INJECT_HSAIL);
-    }
-
-    public void testInjectedOpencl() {
-        newInstance().assertOkraEqualsSeq(HsailMode.INJECT_OCL);
-    }
-
-    protected static Object getFieldFromObject(Field f, Object fromObj) {
-        try {
-            f.setAccessible(true);
-            Type type = f.getType();
-            logger.info("type = " + type);
-            if (type == double.class) {
-                return f.getDouble(fromObj);
-            } else if (type == float.class) {
-                return f.getFloat(fromObj);
-            } else if (type == long.class) {
-                return f.getLong(fromObj);
-            } else if (type == int.class) {
-                return f.getInt(fromObj);
-            } else if (type == byte.class) {
-                return f.getByte(fromObj);
-            } else if (type == boolean.class) {
-                return f.getBoolean(fromObj);
-            } else {
-                return f.get(fromObj);
-            }
-        } catch (Exception e) {
-            fail("unable to get field " + f + " from " + fromObj);
-            return null;
-        }
-    }
-
-    public static void checkFileExists(String fileName) {
-        assertTrue(fileName + " does not exist", fileExists(fileName));
-    }
-
-    public static boolean fileExists(String fileName) {
-        return new File(fileName).exists();
-    }
-
-    public static String getFileAsString(String sourceFileName) {
-        String source = null;
-        try {
-            checkFileExists(sourceFileName);
-            source = new String(Files.readAllBytes(FileSystems.getDefault().getPath(sourceFileName)));
-        } catch (IOException e) {
-            fail("could not open file " + sourceFileName);
-            return null;
-        }
-        return source;
-    }
-
-    public static String getHsailFromFile(String sourceFileName) {
-        logger.severe("... getting hsail from file " + sourceFileName);
-        return getFileAsString(sourceFileName);
-    }
-
-    private static void executeCmd(String... cmd) {
-        logger.info("spawning" + Arrays.toString(cmd));
-        try {
-            ProcessBuilder pb = new ProcessBuilder(cmd);
-            Process p = pb.start();
-            if (logLevel.intValue() <= Level.INFO.intValue()) {
-                InputStream in = p.getInputStream();
-                BufferedInputStream buf = new BufferedInputStream(in);
-                InputStreamReader inread = new InputStreamReader(buf);
-                BufferedReader bufferedreader = new BufferedReader(inread);
-                String line;
-                while ((line = bufferedreader.readLine()) != null) {
-                    logger.info(line);
-                }
-            }
-            p.waitFor();
-        } catch (Exception e) {
-            fail("could not execute <" + Arrays.toString(cmd) + ">");
-        }
-    }
-
-    public static String getHsailFromOpenCLFile(String openclFileName) {
-        String openclHsailFile = "opencl_out.hsail";
-        String tmpTahitiFile = "_temp_0_Tahiti.txt";
-        checkFileExists(openclFileName);
-        logger.severe("...converting " + openclFileName + " to HSAIL...");
-        executeCmd("aoc2", "-m64", "-I./", "-march=hsail", openclFileName);
-        if (fileExists(tmpTahitiFile)) {
-            return getFileAsString(tmpTahitiFile);
-        } else {
-            executeCmd("HSAILasm", "-disassemble", "-o", openclHsailFile, openclFileName.replace(".cl", ".bin"));
-            checkFileExists(openclHsailFile);
-            return getFileAsString(openclHsailFile);
-        }
-    }
-
-    public String getHsailFromClassnameHsailFile() {
-        return (getHsailFromFile(this.getClass().getSimpleName() + ".hsail"));
-    }
-
-    public String getHsailFromClassnameOclFile() {
-        return (getHsailFromOpenCLFile(this.getClass().getSimpleName() + ".cl"));
-    }
-
-    public static void logInfo(String msg) {
-        logger.info(msg);
-    }
-
-    public static void logSevere(String msg) {
-        logger.severe(msg);
-    }
-
-    public static void setLogLevel(Level level) {
-        logLevel = level;
-        logger.setLevel(level);
-        consoleHandler.setLevel(level);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Tests codegen for an IJ signature {@code IntStream} instance function.
- */
-public abstract class ArgsIntBase extends GraalKernelTester {
-
-    static final int NUM = 20;
-
-    @Result public double[] outArray = new double[NUM];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntInstIITest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an II signature {@code IntStream} instance function.
- */
-public class ArgsIntInstIITest extends ArgsIntBase {
-
-    public void run(int arg1, int arg2, int gid) {
-        outArray[gid] = gid + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(NUM, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntInstIJTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an IJ signature {@code IntStream} instance function.
- */
-public class ArgsIntInstIJTest extends ArgsIntBase {
-
-    public void run(int arg1, long arg2, int gid) {
-        outArray[gid] = gid + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(NUM, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntStatAIITest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an AII signature {@code IntStream} static function.
- */
-public class ArgsIntStatAIITest extends ArgsIntBase {
-
-    public static void run(double[] out, int arg1, int arg2, int gid) {
-        out[gid] = gid + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(NUM, outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsIntStatAIJTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an AIJ signature {@code IntStream} static function.
- */
-public class ArgsIntStatAIJTest extends ArgsIntBase {
-
-    public static void run(double[] out, int arg1, long arg2, int gid) {
-        out[gid] = gid + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(NUM, outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Tests codegen for an IJ signature Object stream instance function.
- */
-public abstract class ArgsObjBase extends GraalKernelTester {
-
-    static class MyObj {
-        public int id;
-        public double d;
-
-        public MyObj(int id) {
-            this.id = id;
-        }
-
-        @Override
-        public boolean equals(Object other) {
-            if (!(other instanceof MyObj)) {
-                return false;
-            }
-            MyObj oth = (MyObj) other;
-            return (oth.id == id && oth.d == d);
-        }
-
-        @Override
-        public String toString() {
-            return ("MyObj[" + id + ", " + d + "]");
-        }
-
-        @Override
-        public int hashCode() {
-            return id;
-        }
-
-    }
-
-    static final int NUM = 20;
-
-    @Result public MyObj[] outArray = new MyObj[NUM];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = new MyObj(i + 1);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjInstIITest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an II signature Object stream instance function.
- */
-public class ArgsObjInstIITest extends ArgsObjBase {
-
-    public void run(int arg1, int arg2, MyObj myobj) {
-        myobj.d = myobj.id + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjInstIJTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an IJ signature Object stream instance function.
- */
-public class ArgsObjInstIJTest extends ArgsObjBase {
-
-    public void run(int arg1, long arg2, MyObj myobj) {
-        myobj.d = myobj.id + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjStatIITest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an II signature Object stream static function.
- */
-public class ArgsObjStatIITest extends ArgsObjBase {
-
-    public static void run(int arg1, int arg2, MyObj myobj) {
-        myobj.d = myobj.id + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ArgsObjStatIJTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for an IJ signature Object stream static function.
- */
-public class ArgsObjStatIJTest extends ArgsObjBase {
-
-    public static void run(int arg1, long arg2, MyObj myobj) {
-        myobj.d = myobj.id + arg1 + arg2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(outArray, 7, 6);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests {@link AtomicInteger#getAndAdd(int)} which tests HSAIL atomic_add codegen.
- */
-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();
-
-        dispatchMethodKernel(NUM);
-
-        // note: the actual order of entries in outArray is not predictable
-        // thus we sort before we compare results
-        Arrays.sort(outArray);
-    }
-
-    public void run(int gid) {
-        outArray[gid] = atomicInt.getAndAdd(0x7);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndSetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests {@link AtomicInteger#getAndSet(int)} which tests HSAIL atomic_exch codegen.
- */
-public class AtomicIntGetAndSetTest extends GraalKernelTester {
-
-    static final int NUM = 1000;
-    @Result public int[] outArray = new int[NUM];
-    AtomicInteger atomicInt = new AtomicInteger(Integer.MAX_VALUE);
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM);
-        // to complete the circle, replace the initial get value with that of the last executor
-        for (int i = 0; i < NUM; i++) {
-            if (outArray[i] == Integer.MAX_VALUE) {
-                outArray[i] = atomicInt.get();
-            }
-        }
-
-        // note: the actual order of entries in outArray is not predictable
-        // thus we sort before we compare results
-        Arrays.sort(outArray);
-    }
-
-    public void run(int gid) {
-        outArray[gid] = atomicInt.getAndSet(gid);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests {@link AtomicLong#getAndAdd(long)} which tests HSAIL atomic_add codegen.
- */
-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();
-
-        dispatchMethodKernel(NUM);
-
-        // note: the actual order of entries in outArray is not predictable
-        // thus we sort before we compare results
-        Arrays.sort(outArray);
-    }
-
-    public void run(int gid) {
-        outArray[gid] = atomicLong.getAndAdd(0x7);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndSetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests {@link AtomicLong#getAndSet(long)} which tests HSAIL atomic_exch codegen.
- */
-public class AtomicLongGetAndSetTest extends GraalKernelTester {
-
-    static final int NUM = 1000;
-    @Result public long[] outArray = new long[NUM];
-    AtomicLong atomicLong = new AtomicLong(Long.MAX_VALUE);
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM);
-        // to complete the circle, replace the initial get value with that of the last executor
-        for (int i = 0; i < NUM; i++) {
-            if (outArray[i] == Long.MAX_VALUE) {
-                outArray[i] = atomicLong.get();
-            }
-        }
-
-        // note: the actual order of entries in outArray is not predictable
-        // thus we sort before we compare results
-        Arrays.sort(outArray);
-    }
-
-    public void run(int gid) {
-        outArray[gid] = atomicLong.getAndSet(gid);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicReferenceGetAndSetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.concurrent.atomic.*;
-
-import org.junit.*;
-
-import sun.misc.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-import com.oracle.graal.debug.*;
-
-/**
- * Tests {@link AtomicReference#getAndSet(Object)} which indirectly tests
- * {@link Unsafe#compareAndSwapObject(Object, long, Object, Object)}. The latter requires special
- * handling if compressed oops are enabled.
- */
-public class AtomicReferenceGetAndSetTest extends GraalKernelTester {
-
-    static final int NUM = 20;
-    @Result public int[] followedCount = new int[NUM];
-    public MyObj[] inArray = new MyObj[NUM];
-    AtomicReference<MyObj> atomicRef = new AtomicReference<>();
-
-    public static class MyObj {
-        public int val;
-        public boolean[] followedBy = new boolean[NUM + 1];
-
-        MyObj(int n) {
-            val = n;
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyObj(i + 1);
-        }
-        atomicRef.set(new MyObj(0)); // initial value
-    }
-
-    private static final boolean DEBUG = false;
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM);
-
-        // make a fake followedBy for the final object
-        MyObj finalObj = atomicRef.get();
-        finalObj.followedBy[0] = true;
-
-        // When the kernel is done, compute the number of true bits in each followedBy array;
-        for (int i = 0; i < NUM; i++) {
-            MyObj obj = inArray[i];
-            int count = 0;
-            for (int j = 0; j < NUM + 1; j++) {
-                boolean b = obj.followedBy[j];
-                if (b) {
-                    count++;
-                    if (DEBUG) {
-                        TTY.println("obj " + obj.val + " was followed by " + j);
-                    }
-                }
-
-            }
-            followedCount[i] = count;
-        }
-    }
-
-    public void run(int gid) {
-        MyObj newObj = inArray[gid];
-        MyObj oldObj = atomicRef.getAndSet(newObj);
-        oldObj.followedBy[newObj.val] = true;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +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.compiler.hsail.test;
-
-import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.compiler.test.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.hsail.*;
-import com.oracle.graal.hsail.*;
-
-/**
- * Test class for small Java methods compiled to HSAIL kernels.
- */
-public class BasicHSAILTest extends GraalCompilerTest {
-
-    public BasicHSAILTest() {
-        super(HSAIL.class);
-    }
-
-    public void testAdd() {
-        test("testAddSnippet");
-    }
-
-    public static int testAddSnippet(int a) {
-        return a * a;
-    }
-
-    public void testArrayConstantIndex() {
-        test("testArrayReturnFirstElement");
-    }
-
-    public void testArrayVariableIndex() {
-        test("testArrayReturnIthElement");
-    }
-
-    public void testArrayMultiplyConstant() {
-        test("testArrayMultiplyZero");
-    }
-
-    public void testArrayMultiplyVar() {
-        test("testArrayMultiplyGid");
-    }
-
-    public void testArrayMisc() {
-        test("testArrayLocalVariable");
-    }
-
-    public void testArrayLoopVar() {
-        test("testArrayMultiplyGidLoop");
-    }
-
-    void setupPalette(int[] in) {
-        for (int i = 0; i < in.length; i++) {
-            in[i] = i;
-        }
-    }
-
-    public void testNBody() {
-        test("nBodySpill");
-    }
-
-    public void testArrayMandel() {
-        final int width = 768;
-        final int height = width;
-        int loopiterations = 1;
-        int counter = 0;
-        final int range = width * height;
-        int[] rgb = new int[range];
-        int[] palette = new int[range];
-        setupPalette(palette);
-        while (counter < loopiterations) {
-            for (int gid = 0; gid < range; gid++) {
-                testMandelSimple(rgb, palette, -1.0f, 0.0f, 3f, gid);
-            }
-            counter++;
-        }
-        test("testMandelSimple");
-    }
-
-    public void testDanglingElse() {
-        test("danglingElse");
-    }
-
-    public void testIntSquaresTernary() {
-        test("intSquaresTernary");
-    }
-
-    public void testDanglingElse2() {
-        test("danglingElse2");
-    }
-
-    public void testDanglingElse3() {
-        test("danglingElse3");
-    }
-
-    public void testSimpleIf() {
-        test("simpleIf");
-    }
-
-    public void testParams11() {
-        test("testParams1");
-    }
-
-    public void testParams21() {
-        test("testParams2");
-    }
-
-    public void testParams31() {
-        test("testParams3");
-    }
-
-    public void testAssignment1() {
-        test("testAssignment");
-    }
-
-    public void testArithmetic1() {
-        test("testArithmetic");
-    }
-
-    public void testSimpleWhile1() {
-        test("testSimpleWhile");
-    }
-
-    public void testComplexWhile1() {
-        test("testComplexWhile");
-    }
-
-    public void testSquaresThree() {
-        test("testMulThreeArrays");
-    }
-
-    @Test
-    public void testCondMoves() {
-        test("testMinI");
-        test("testMinF");
-    }
-
-    public int testMinI(int a, int b) {
-        return (a < b ? 1 : 2);
-    }
-
-    public float testMinF(int a, int b) {
-        return (a < b ? 1.0f : 2.0f);
-    }
-
-    public static void testMulThreeArrays(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = ina[gid] * inb[gid];
-    }
-
-    public static int testArrayMultiplyZero(int[] array1, int[] array2) {
-        return array1[0] = array2[0] * array2[0];
-    }
-
-    public static int testArrayMultiplyGid(int[] array1, int[] array2, int gid) {
-        return array1[gid] = array2[gid] * array2[gid];
-    }
-
-    public static float testParams3(float c, float d, float e) {
-        return c + d + e;
-    }
-
-    public static int testAssignment() {
-        final int width = 768;
-        final int height = 768;
-        final int maxIterations = 64;
-        return width * height * maxIterations;
-    }
-
-    public static int testSimpleWhile(int i) {
-        int count = 0;
-        int j = 0;
-        final int maxIterations = 64;
-        while (count < maxIterations) {
-            j += count * i;
-            count++;
-        }
-        return j;
-    }
-
-    public static void testComplexWhile() {
-        float lx = 1;
-        float ly = 2;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-        final int maxIterations = 64;
-        int count = 0;
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-    }
-
-    public static void testMandel(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
-        final int width = 768;
-        final int height = 768;
-        final int maxIterations = 64;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-        /**
-         * Iterate until the algorithm converges or until maxIterations are reached.
-         */
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid] = pallette[count];
-    }
-
-    public static void testMandelSimple(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
-        final int width = 768;
-        final int height = width;
-        final int maxIterations = 64;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-        /**
-         * Iterate until the algorithm converges or until maxIterations are reached.
-         */
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid] = pallette[count];
-    }
-
-    public static void testMandel2(int[] rgb, int[] pallette, int xoffseti, int yoffseti, int scalei, int gid) {
-        final int width = 768;
-        final int height = 768;
-        final int maxIterations = 64;
-        float xoffset = xoffseti;
-        float yoffset = yoffseti;
-        float scale = scalei;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-        /**
-         * Iterate until the algorithm converges or until maxIterations are reached.
-         */
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid] = pallette[count];
-    }
-
-    public static int testArrayLocalVariable(int gid, int[] array) {
-        int foo = 198;
-        return array[gid + foo];
-    }
-
-    public static int testArrayReturnFirstElement(int[] array) {
-        return array[0];
-    }
-
-    public static int testArrayReturnIthElement(int i, int[] array) {
-        return array[i];
-    }
-
-    public static void simpleIf(int[] out, int[] in, int gid) {
-        if (gid > 9) {
-            out[gid] = in[gid] * in[gid];
-        }
-    }
-
-    public static int danglingElse(int a) {
-        return (a > 5) ? (a + 7) : (a - 3);
-    }
-
-    public static int danglingElse2(int a, int b) {
-        if (a > 5) {
-            return (a + 7 * (b - 4 + a));
-        } else {
-            return (a - 3 + b * 3 * a + 5);
-        }
-    }
-
-    public static int danglingElse3(int a, int b) {
-        int val;
-        if (a > 5) {
-            val = (a + 7 * (b - 4 + a));
-        } else {
-            val = (a - 3 + b * 3 * a + 5);
-        }
-        return val + a;
-    }
-
-    public static void intSquaresTernary(int[] out, int[] in, int gid) {
-        int val = in[gid] * in[gid];
-        val = (val % 2 == 1 ? val + 1 : val);
-        out[gid] = val;
-    }
-
-    @Override
-    protected HSAILHotSpotBackend getBackend() {
-        Backend backend = super.getBackend();
-        Assume.assumeTrue("No HSAIL backend, skipping test!", backend instanceof HSAILHotSpotBackend);
-        return (HSAILHotSpotBackend) backend;
-    }
-
-    private void test(final String snippet) {
-        try (DebugConfigScope dcs = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
-            try (Scope s = Debug.scope("HSAILCodeGen")) {
-                ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
-                ExternalCompilationResult hsailCode = getBackend().compileKernel(method, false);
-                Debug.log("HSAIL code generated for %s:%n%s", snippet, hsailCode.getCodeString());
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-        }
-    }
-
-    public static void nBodySpill(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int gid) {
-        final int bodies = 8;
-        final float delT = .005f;
-        final float espSqr = 1.0f;
-        final float mass = 5f;
-        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 = inxyz[i + 0] - inxyz[globalId + 0];
-            final float dy = inxyz[i + 1] - inxyz[globalId + 1];
-            final float dz = inxyz[i + 2] - inxyz[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;
-        outxyz[globalId + 0] = inxyz[globalId + 0] + (invxyz[globalId + 0] * delT) + (accx * .5f * delT);
-        outxyz[globalId + 1] = inxyz[globalId + 1] + (invxyz[globalId + 1] * delT) + (accy * .5f * delT);
-        outxyz[globalId + 2] = inxyz[globalId + 2] + (invxyz[globalId + 2] * delT) + (accz * .5f * delT);
-        outvxyz[globalId + 0] = invxyz[globalId + 0] + accx;
-        outvxyz[globalId + 1] = invxyz[globalId + 1] + accy;
-        outvxyz[globalId + 2] = invxyz[globalId + 2] + accz;
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two boolean values which are both false.
- */
-public class BooleanBitwiseAndTestFF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestFT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two booleans. First input is false and second input is true.
- */
-public class BooleanBitwiseAndTestFT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two booleans. First input is true and second is false.
- */
-public class BooleanBitwiseAndTestTF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseAndTestTT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two booleans. Both inputs are true.
- */
-public class BooleanBitwiseAndTestTT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two booleans. Both inputs are false.
- */
-public class BooleanBitwiseOrTestFF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestFT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two booleans. First input is false. Second input is true.
- */
-public class BooleanBitwiseOrTestFT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two booleans. First input is true. Second input is false.
- */
-public class BooleanBitwiseOrTestTF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseOrTestTT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two booleans. Both inputs are true.
- */
-public class BooleanBitwiseOrTestTT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two booleans. Both inputs are false.
- */
-public class BooleanBitwiseXorTestFF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestFT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two booleans. First input is false. Second input is true.
- */
-public class BooleanBitwiseXorTestFT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = false;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTF.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two booelans. First input is true. Second input is false.
- */
-public class BooleanBitwiseXorTestTF extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = false;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BooleanBitwiseXorTestTT.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two booleans. Both inputs are true.
- */
-public class BooleanBitwiseXorTestTT extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected boolean[] outArray = new boolean[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(boolean[] out, boolean[] ina, boolean[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(boolean[] in, boolean[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = true;
-            in2[i] = true;
-            outArray[i] = false;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        boolean[] inArray = new boolean[num];
-        boolean[] inArray2 = new boolean[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Base Class for tests that deopt but then catch the exception in the run routine itself.
- */
-public abstract class BoundsCatchBase extends GraalKernelTester {
-
-    abstract int getGlobalSize();
-
-    final int num = getGlobalSize();
-    @Result int[] outArray = new int[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            outArray[i] = -i;
-        }
-    }
-
-    // Note: could not push the whole run routine here because
-    // problems with indirect call to getDeoptGid
-    int getOutval(int gid) {
-        int adjustment = 0;
-        int tmp = gid + 10;
-        while (tmp > gid) {
-            adjustment += tmp;
-            tmp--;
-        }
-        int outval = (outArray[gid] * -1) + adjustment;
-        return outval;
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return canDeoptimize();
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        // we should not get an exception escaping from the kernel
-        dispatchMethodKernel(num);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany16384Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 16384, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany16384Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 16384;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 20000, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany20000Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 20000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany5000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 5000, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany5000Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 5000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany8192Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 8192, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany8192Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 8192;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654HighTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 987654, deopt on many gids but then catch the exception in the run routine itself
- * deopt ids are at the high end.
- */
-public class BoundsCatchMany987654HighTest extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 987654;
-    }
-
-    boolean isMyDeoptGid(int gid) {
-        return (gid > getGlobalSize() - 4096 && gid % 512 == 1);
-    }
-
-    // copied run routine here because otherwise polymorphic calls to isDeoptGid
-    @Override
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isMyDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] += outval;
-            // note: cannot record the exceptiongid here for many deopts in parallel
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany987654Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 987654, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany987654Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 987654;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMany99999Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 99999, deopt on many gids but then catch the exception in the run routine itself.
- */
-public class BoundsCatchMany99999Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 99999;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchManyBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-/**
- * Base Class for tests that deopt on multiple gids gid but then catches the exception in the run
- * routine itself.
- */
-public abstract class BoundsCatchManyBase extends BoundsCatchBase {
-
-    boolean isDeoptGid(int gid) {
-        return (gid < 4096 && gid % 512 == 1);
-    }
-
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] += outval;
-            // note: cannot record the exceptiongid here for many deopts in parallel
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost1000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 1000, deopt on almost all gids but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchMost1000Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 1000;
-    }
-
-    boolean isMyDeoptGid(int gid) {
-        return (gid % 100 != 1);
-    }
-
-    // copied run routine here because otherwise polymorphic calls to isDeoptGid
-    @Override
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isMyDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] += outval;
-            // note: cannot record the exceptiongid here for many deopts in parallel
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000StressGCTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * A version which is likely to get a GC while running the never_rans, and so is good for oops_do
- * testing.
- */
-public class BoundsCatchMost20000StressGCTest extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 20000;
-    }
-
-    boolean isMyDeoptGid(int gid) {
-        return (gid > 100 && gid % 100 != 1);
-    }
-
-    int[] dummyArray;
-
-    // copied run routine here because otherwise polymorphic calls to isDeoptGid
-    @Override
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isMyDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] += outval;
-            // note: cannot record the exceptiongid here for many deopts in parallel
-
-            // allocate something so GCs happen more often
-            dummyArray = new int[1000];
-        }
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        for (int i = 0; i < 10; i++) {
-            // we should not get an exception escaping from the kernel
-            dispatchMethodKernel(num);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchMost20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 20000, deopt on almost all gids but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchMost20000Test extends BoundsCatchManyBase {
-
-    @Override
-    int getGlobalSize() {
-        return 20000;
-    }
-
-    boolean isMyDeoptGid(int gid) {
-        return (gid % 100 != 1);
-    }
-
-    // copied run routine here because otherwise polymorphic calls to isDeoptGid
-    @Override
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isMyDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] += outval;
-            // note: cannot record the exceptiongid here for many deopts in parallel
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle16384Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 16384, deopt on a single gid but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchSingle16384Test extends BoundsCatchSingleBase {
-
-    @Override
-    int getGlobalSize() {
-        return 16384;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 20000, deopt on a single gid but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchSingle20000Test extends BoundsCatchSingleBase {
-
-    @Override
-    int getGlobalSize() {
-        return 20000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle5000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 5000, deopt on a single gid but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchSingle5000Test extends BoundsCatchSingleBase {
-
-    @Override
-    int getGlobalSize() {
-        return 5000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingle8192Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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.*;
-
-/**
- * For globalsize 8192, deopt on a single gid but then catch the exception in the run routine
- * itself.
- */
-public class BoundsCatchSingle8192Test extends BoundsCatchSingleBase {
-
-    @Override
-    int getGlobalSize() {
-        return 8192;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCatchSingleBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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;
-
-/**
- * Base Class for tests that deopt on a single gid but then catch the exception in the run routine
- * itself.
- */
-public abstract class BoundsCatchSingleBase extends BoundsCatchBase {
-
-    int getDeoptGid() {
-        return 512;
-    }
-
-    boolean isDeoptGid(int gid) {
-        return (gid == getDeoptGid());
-    }
-
-    @Result public int exceptionGid;
-
-    public void run(int gid) {
-        int outval = getOutval(gid);
-        try {
-            int index = (isDeoptGid(gid) ? num + 1 : gid);
-            outArray[index] = outval;
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // set up so we can detect if we go thru here twice
-            outArray[gid] -= outval;
-            exceptionGid = gid;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckDoubleNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckDoubleNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    double[] outArray = new double[num];
-
-    void setupArrays(double[] in1, double[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    static double dummyDouble = 10;
-
-    public static void run(double[] out, double[] ina, double[] inb, int gid) {
-        // This will fail when gid+1==num
-        double adjustment = 0;
-        double tmp = dummyDouble;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        out[gid + 1] = ina[gid] + inb[gid] + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        double[] inArray1 = new double[num];
-        double[] inArray2 = new double[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFailsInMiddleTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code, in the middle of the array.
- */
-public class BoundsCheckFailsInMiddleTest extends SingleExceptionTestBase {
-    static final int num = 128; // * 256;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    int[] outArray = new int[num];
-    static final int abortingGid = (new java.util.Random()).nextInt(num / 4);
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -99;
-        }
-    }
-
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        // Throw in the middle of doing the work
-        out[gid == abortingGid ? (gid + num) : gid] = ina[gid] + inb[gid];
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckFloatNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckFloatNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    float[] outArray = new float[num];
-
-    void setupArrays(float[] in1, float[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    static float dummyFloat = 10;
-
-    public static void run(float[] out, float[] ina, float[] inb, int gid) {
-        // This will fail when gid+1==num
-        float adjustment = 0;
-        float tmp = dummyFloat;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        out[gid + 1] = ina[gid] + inb[gid] + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        float[] inArray1 = new float[num];
-        float[] inArray2 = new float[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckInlineTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * 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.*;
-
-/**
- * 
- * @author ecaspole
- */
-public class BoundsCheckInlineTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    int[] outArray = new int[num];
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    static volatile int dummy;
-
-    static void writesum(int[] out, int gid, int val) {
-        out[gid + 1] = val;
-    }
-
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        // This will fail when gid+1==num
-        writesum(out, gid, ina[gid] + inb[gid]);
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckLongNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckLongNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    long[] outArray = new long[num];
-
-    void setupArrays(long[] in1, long[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    static long dummyLong = 10;
-
-    public static void run(long[] out, long[] ina, long[] inb, int gid) {
-        // This will fail when gid+1==num
-        long adjustment = 0x1234567890abcdefL;
-        long tmp = dummyLong;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        out[gid + 1] = ina[gid] + inb[gid] + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        long[] inArray1 = new long[num];
-        long[] inArray2 = new long[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckNonZeroBciInstanceTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    int[] outArray = new int[num];
-    int[] inArray1 = new int[num];
-    int[] inArray2 = new int[num];
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    int dummyInt = 10;
-
-    public void run(int gid) {
-        // This will fail when gid+1==num
-        int adjustment = 0;
-        int tmp = dummyInt;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        outArray[gid + 1] = inArray1[gid] + inArray2[gid] + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    int[] outArray = new int[num];
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    static int dummyInt = 10;
-
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        // This will fail when gid+1==num
-        int adjustment = 0;
-        int tmp = dummyInt;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        out[gid + 1] = ina[gid] + inb[gid] + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BoundsCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test deliberately causes an ArrayIndexOutOfBoundsException to test throwing the exception
- * back to the java code.
- */
-public class BoundsCheckTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    // note: outArray not marked as @Result because we can't predict
-    // which workitems will get done in parallel execution
-    int[] outArray = new int[num];
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in1[i] = i;
-            in2[i] = i + 1;
-            outArray[i] = -i;
-        }
-    }
-
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        // This will fail when gid+1==num
-        out[gid + 1] = ina[gid] + inb[gid];
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two bytes and casts the result to a byte.
- */
-public class ByteBitwiseAndCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected byte[] outArray1 = new byte[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (byte) (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i + i);
-            in2[i] = (byte) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseAndTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two bytes.
- */
-public class ByteBitwiseAndTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i + i);
-            in2[i] = (byte) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two bytes and casts the result to a byte.
- */
-public class ByteBitwiseOrCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected byte[] outArray1 = new byte[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (byte) (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i * 2);
-            in2[i] = (byte) (i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseOrTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two bytes.
- */
-public class ByteBitwiseOrTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i * 2);
-            in2[i] = (byte) (i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two bytes and casts the result to a byte.
- */
-public class ByteBitwiseXorCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected byte[] outArray1 = new byte[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(byte[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (byte) (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i);
-            in2[i] = (byte) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ByteBitwiseXorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two bytes.
- */
-public class ByteBitwiseXorTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, byte[] ina, byte[] inb, int gid) {
-        out1[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(byte[] in, byte[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (byte) (i);
-            in2[i] = (byte) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        byte[] inArray = new byte[num];
-        byte[] inArray2 = new byte[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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 direct method calls.
- */
-public class CallTest 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[] inArray = new float[range];
-
-    public static int foo(int gid, int i) {
-        if (gid < 25) {
-            return gid * i;
-        } else {
-            return gid - i;
-        }
-    }
-
-    public void run(float[] inArray1, int gid) {
-        for (int i = 0; i < iterations; i++) {
-            inArray1[gid] = foo(gid, i);
-        }
-    }
-
-    @Override
-    public void runTest() {
-        dispatchMethodKernel(range, inArray);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two chars and casts result to a char.
- */
-public class CharBitwiseAndCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected char[] outArray1 = new char[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (char) (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = (char) 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseAndTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two chars.
- */
-public class CharBitwiseAndTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two chars and casts the result to a char.
- */
-public class CharBitwiseOrCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected char[] outArray1 = new char[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (char) (ina[gid] | inb[gid]);
-
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = (char) 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseOrTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two chars.
- */
-public class CharBitwiseOrTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (ina[gid] | inb[gid]);
-
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two chars and casts the result to a char.
- */
-public class CharBitwiseXorCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected char[] outArray1 = new char[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(char[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (char) (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = (char) 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/CharBitwiseXorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two chars.
- */
-public class CharBitwiseXorTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, char[] ina, char[] inb, int gid) {
-        out1[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(char[] in, char[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (char) (i + 65);
-            in2[i] = (char) (i + 97);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        char[] inArray = new char[num];
-        char[] inArray2 = new char[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * This test deliberately causes a ClassCastException to test throwing the exception back to the
- * java code.
- */
-public class ClassCastNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-
-    static class BasePoint {
-        int x;
-        int y;
-
-        public BasePoint(int x, int y) {
-            this.x = x;
-            this.y = y;
-        }
-
-        public int getX() {
-            return x;
-        }
-
-        public int getY() {
-            return y;
-        }
-    }
-
-    static class MyPoint extends BasePoint {
-        public MyPoint(int x, int y) {
-            super(x, y);
-        }
-    }
-
-    BasePoint[] inputs = new BasePoint[num];
-    MyPoint[] outputs = new MyPoint[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            inputs[i] = new MyPoint(i, i + 1);
-        }
-        inputs[2] = new BasePoint(1, 1);
-    }
-
-    public void run(int gid) {
-        // gid 2 should always throw ClassCastException
-        int adjustment = 0;
-        int tmp = gid;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        MyPoint mp = (MyPoint) inputs[gid];
-        mp.x = mp.y + adjustment;
-        outputs[gid] = mp;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ClassCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * This test deliberately causes a ClassCastException to test throwing the exception back to the
- * java code.
- */
-public class ClassCastTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-
-    static class BasePoint {
-        int x;
-        int y;
-
-        public BasePoint(int x, int y) {
-            this.x = x;
-            this.y = y;
-        }
-
-        public int getX() {
-            return x;
-        }
-
-        public int getY() {
-            return y;
-        }
-    }
-
-    static class MyPoint extends BasePoint {
-        public MyPoint(int x, int y) {
-            super(x, y);
-        }
-    }
-
-    BasePoint[] inputs = new BasePoint[num];
-    MyPoint[] outputs = new MyPoint[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            inputs[i] = new MyPoint(i, i + 1);
-        }
-        inputs[2] = new BasePoint(1, 1);
-    }
-
-    public void run(int gid) {
-        // gid 2 should always throw ClassCastException
-        MyPoint mp = (MyPoint) inputs[gid];
-        mp.x = mp.y + 2;
-        outputs[gid] = mp;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DVec3.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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;
-
-/**
- * A simple 3 element Vector object used in some junit tests.
- */
-public class DVec3 {
-
-    public DVec3(double x, double y, double z) {
-        this.x = x;
-        this.y = y;
-        this.z = z;
-    }
-
-    public double x;
-    public double y;
-    public double z;
-
-    public static DVec3 add(DVec3 a, DVec3 b) {
-        return new DVec3(a.x + b.x, a.y + b.y, a.z + b.z);
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (!(other instanceof DVec3)) {
-            return false;
-        }
-        DVec3 oth = (DVec3) other;
-        return (oth.x == x && oth.y == y && oth.z == z);
-    }
-
-    @Override
-    public String toString() {
-        return ("DVec3[" + x + ", " + y + ", " + z + "]");
-    }
-
-    @Override
-    public int hashCode() {
-        return (int) (x + y + z);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleAbsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for calls to Math.abs(double). Generates a abs_f64 instruction.
- */
-public class DoubleAbsTest extends GraalKernelTester {
-
-    static final int num = 40;
-    // Output array storing the results of calling Math.abs().
-    @Result protected double[] outArray = new double[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.abs() on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] out, double[] ina, int gid) {
-        out[gid] = Math.abs(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(double[] in) {
-        for (int i = 0; i < num; i++) {
-            // Include positive and negative values as well as corner cases.
-            if (i == 1) {
-                in[i] = Double.NaN;
-            } else if (i == 2) {
-                in[i] = Double.NEGATIVE_INFINITY;
-            } else if (i == 3) {
-                in[i] = Double.POSITIVE_INFINITY;
-            } else if (i == 4) {
-                in[i] = -0.0;
-            } else {
-                in[i] = i < num / 2 ? i : -i;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleCeilTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for calls to Math.ceil(). Generates a ceil_f64 instruction.
- */
-public class DoubleCeilTest extends GraalKernelTester {
-
-    static final int num = 40;
-    // Output array storing the results.
-    @Result protected double[] outArray = new double[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.ceil() on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] out, double[] ina, int gid) {
-        out[gid] = Math.ceil(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(double[] in) {
-        // Initialize arrays with a mix of positive and negativ values and any corner cases.
-        for (int i = 0; i < num; i++) {
-            if (i == 0) {
-                in[i] = 0.0;
-            } else if (i == 1) {
-                in[i] = -0.0;
-            } else if (i == 2) {
-                in[i] = Double.NaN;
-            } else if (i == 3) {
-                in[i] = Double.NEGATIVE_INFINITY;
-            } else if (i == 4) {
-                in[i] = Double.POSITIVE_INFINITY;
-            } else {
-                in[i] = i < num / 2 ? i + 0.5 : -i - 0.5;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleFloorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for calls to Math.floor(). Generates a floor_f64 instruction.
- */
-public class DoubleFloorTest extends GraalKernelTester {
-
-    static final int num = 40;
-    // Output array storing the results.
-    @Result protected double[] outArray = new double[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.floor() on an element
-     * of an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] out, double[] ina, int gid) {
-        out[gid] = Math.floor(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(double[] in) {
-        // Initialize input array with a mix of positive and negative values and any corner cases.
-        for (int i = 0; i < num; i++) {
-            if (i == 0) {
-                in[i] = 0.0;
-            } else if (i == 1) {
-                in[i] = -0.0;
-            } else if (i == 2) {
-                in[i] = Double.NaN;
-            } else if (i == 3) {
-                in[i] = Double.NEGATIVE_INFINITY;
-            } else if (i == 4) {
-                in[i] = Double.POSITIVE_INFINITY;
-            } else {
-                in[i] = i < num / 2 ? i + 0.5 : -i - 0.5;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleLongConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests double to long conversion.
- */
-public class DoubleLongConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final double[] inputDouble = new double[size];
-    static final long[] inputLong = new long[size];
-    @Result static final double[] outputDouble = new double[size];
-    @Result static final long[] outputLong = new long[size];
-    static double[] seedDouble = new double[size];
-    {
-        for (int i = 0; i < seedDouble.length; i++) {
-            seedDouble[i] = (int) Math.random();
-        }
-    }
-    static long[] seedLong = new long[size];
-    {
-        for (int i = 0; i < seedLong.length; i++) {
-            seedLong[i] = (long) Math.random();
-        }
-    }
-
-    public static void run(double[] inDouble, long[] inLong, double[] outDouble, long[] outLong, int gid) {
-        outDouble[gid] = inLong[gid];
-        outLong[gid] = (long) inDouble[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
-        Arrays.fill(outputLong, 0);
-        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
-        Arrays.fill(outputDouble, 0);
-        dispatchMethodKernel(64, inputDouble, inputLong, outputDouble, outputLong);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleNegTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests negation of double values. Generates a neg_f64 instruction.
- */
-public class DoubleNegTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of negation operations.
-    @Result protected double[] outArray = new double[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a negation operation on
-     * an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] out, double[] ina, int gid) {
-        out[gid] = -(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(double[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleRintTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for Math.rint(). Generates an rint_f64 instruction.
- */
-public class DoubleRintTest extends GraalKernelTester {
-
-    static final int size = 64;
-    @Result double[] out = new double[size];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.rint() on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param in the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] out, double[] in, int gid) {
-        out[gid] = Math.rint(in[gid]);
-    }
-
-    /**
-     * Initialize input arrays.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(double[] in) {
-        // Initialize input array with a mix of positive and negative values and corner cases.
-        for (int i = 0; i < size; i++) {
-            if (i == 1) {
-                in[i] = Double.NaN;
-            } else if (i == 2) {
-                in[i] = Double.NEGATIVE_INFINITY;
-            } else if (i == 3) {
-                in[i] = Double.POSITIVE_INFINITY;
-
-            } else if (i == 4) {
-                in[i] = 0.0;
-            } else if (i == 5) {
-                in[i] = -0.0;
-            } else {
-                in[i] = i < size / 2 ? i + 0.5 : -i - 0.6;
-            }
-            out[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[size];
-        setupArrays(inArray);
-        dispatchMethodKernel(size, out, inArray);
-    }
-
-    /**
-     * 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() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/DoubleSqrtTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for call to Math.sqrt(double). Generates a sqrt_f64 instruction.
- */
-public class DoubleSqrtTest extends GraalKernelTester {
-
-    static final int size = 64;
-    @Result double[] out = new double[size];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.sqrt() on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param in the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(double[] in, double[] out, int gid) {
-        out[gid] = Math.sqrt(in[gid]);
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(double[] in) {
-        for (int i = 0; i < size; i++) {
-            // Include positive and negative values as well as corner cases.
-            if (i == 1) {
-                in[i] = Double.NaN;
-            } else if (i == 2) {
-                in[i] = Double.NEGATIVE_INFINITY;
-            } else if (i == 3) {
-                in[i] = Double.POSITIVE_INFINITY;
-            } else if (i == 4) {
-                in[i] = -0.0;
-            } else if (i > 5 && i < 10) {
-                in[i] = i + 0.5;
-            } else {
-                in[i] = i < size / 2 ? i : -i;
-            }
-            out[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        double[] inArray = new double[size];
-        setupArrays(inArray);
-        dispatchMethodKernel(size, inArray, out);
-    }
-
-    /**
-     * 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() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * 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();
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewFloatStringTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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.*;
-
-/**
- * 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);
-    }
-
-    @Ignore("problems runs out of memory space while inlining")
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewFloatTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewIntArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewIntegerTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStoreFieldTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringConcatTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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.*;
-
-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];
-    }
-
-    @Ignore("emitDirectCall unimplemented")
-    @Test
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringInternTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.compiler.common.GraalInternalError.class)
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringLargeRangeTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewStringTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3ArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Base.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * 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);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3LargeRangeDisp3Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3LargeRangeTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3MediumRangeTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Partial2Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3PartialTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/EscapingNewVec3Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * 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/FcompUnorderedTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This was a version of Mandel Test that happened to generate a Nan and so was useful for testing
- * ordered and unordered comparison. However, we should probably replace this with a test (or set of
- * tests) that is more focussed on Nan and comparisons.
- */
-public class FcompUnorderedTest extends GraalKernelTester {
-
-    static final int initialWidth = 5;
-    static final int initialHeight = initialWidth;
-    static final int range = 25;
-    @Result private int[] rgb = new int[range];
-    private float[] lxresult = new float[range];
-
-    public static void run(int[] rgb, float xoffset, float yoffset, float scale, int gid) {
-        final int width = initialWidth;
-        final int height = initialHeight;
-        final int maxIterations = 64;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-        /**
-         * Iterate until the algorithm converges or until maxIterations are reached.
-         */
-        while (count < maxIterations && zx < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid] = count;
-    }
-
-    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);
-        for (int i = 0; i < range; i++) {
-            lxresult[i] = -1;
-        }
-        /*
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         */
-        dispatchMethodKernel(range, rgb, 1.0f, 1.0f, 1.0f);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Base class used by other Float2DMatrix tests.
- */
-public abstract class Float2DMatrixBase extends GraalKernelTester {
-
-    float[][] matrixA;
-    float[][] matrixB;
-    @Result float[][] outMatrix;
-
-    public void setupArrays(int range) {
-        matrixA = new float[range][];
-        matrixB = new float[range][];
-        outMatrix = new float[range][];
-        for (int j = 0; j < range; j++) {
-            matrixA[j] = new float[range];
-            matrixB[j] = new float[range];
-            outMatrix[j] = new float[range];
-            for (int k = 0; k < range; k++) {
-                matrixA[j][k] = (j + k) % 7;
-                matrixB[j][k] = (j + k + 1) % 8;
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyRangeFinalTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests the mixing of 32-bit and 64-bit spills caused by loop unrolling.
- */
-public class Float2DMatrixMultiplyRangeFinalTest extends Float2DMatrixBase {
-
-    static final int range = 6;
-
-    public void run(int gid) {
-        for (int j = 0; j < range; j++) {
-            float sum = 0;
-            for (int k = 0; k < range; k++) {
-                sum += (matrixA[gid][k] * matrixB[k][j]);
-            }
-            outMatrix[gid][j] = sum;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays(range);
-        dispatchMethodKernel(range);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests 2D array access for Matrix Multiplication.
- */
-public class Float2DMatrixMultiplyTest extends Float2DMatrixBase {
-
-    int range = 20;
-
-    public void run(int gid) {
-        for (int j = 0; j < range; j++) {
-            float sum = 0;
-            for (int k = 0; k < range; k++) {
-                sum += (matrixA[gid][k] * matrixB[k][j]);
-            }
-            outMatrix[gid][j] = sum;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays(range);
-        dispatchMethodKernel(range);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatAbsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for calls to Math.abs(float). Generates an abs_f32 instruction.
- */
-public class FloatAbsTest extends GraalKernelTester {
-
-    static final int num = 40;
-    // Output array storing the results of calling Math.abs().
-    @Result protected float[] outArray = new float[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.abs() on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(float[] out, float[] ina, int gid) {
-        out[gid] = Math.abs(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(float[] in) {
-        for (int i = 0; i < num; i++) {
-            // Initialize array with positive and negative values as well as corner cases.
-            if (i == 1) {
-                in[i] = Float.NaN;
-            } else if (i == 2) {
-                in[i] = Float.NEGATIVE_INFINITY;
-            } else if (i == 3) {
-                in[i] = Float.POSITIVE_INFINITY;
-            } else if (i == 4) {
-                in[i] = -0;
-            } else {
-                in[i] = i < num / 2 ? i : -i;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        float[] inArray = new float[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests floating point comparison.
- */
-public class FloatConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final float[] inputFloat = new float[size];
-    static final double[] inputDouble = new double[size];
-    @Result static final float[] outputFloat = new float[size];
-    @Result static final double[] outputDouble = new double[size];
-    static float[] seedFloat = new float[size];
-    {
-        for (int i = 0; i < seedFloat.length; i++) {
-            seedFloat[i] = (float) Math.random();
-        }
-    }
-    static double[] seedDouble = new double[size];
-    {
-        for (int i = 0; i < seedDouble.length; i++) {
-            seedDouble[i] = Math.random();
-        }
-    }
-
-    public static void run(float[] inFloat, double[] inDouble, float[] outFloat, double[] outDouble, int gid) {
-        outFloat[gid] = (float) inDouble[gid];
-        outDouble[gid] = inFloat[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
-        Arrays.fill(outputDouble, 0f);
-        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
-        Arrays.fill(outputFloat, 0f);
-        dispatchMethodKernel(64, inputFloat, inputDouble, outputFloat, outputDouble);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDivPrecisionTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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.*;
-
-/**
- * This test (originally derived from a discrepancy seen in Mandel) showed a difference in the
- * division answers when run on Bonaire hardware (compared to Java).
- */
-public class FloatDivPrecisionTest extends GraalKernelTester {
-
-    static final int width = 768;
-    static final int height = width;
-    static final int range = width * height;
-    @Result private float[] floatResult = new float[range];
-
-    public static void run(float[] floatOut, int gid) {
-        floatOut[gid] = gid / (float) width;
-    }
-
-    @Override
-    public void runTest() {
-        dispatchMethodKernel(range, floatResult);
-
-    }
-
-    @Override
-    protected double equalFloatsOrDoublesDelta() {
-        return 0.0D;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatDoubleConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests float to double conversion.
- */
-public class FloatDoubleConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final float[] inputFloat = new float[size];
-    static final double[] inputDouble = new double[size];
-    @Result static final float[] outputFloat = new float[size];
-    @Result static final double[] outputDouble = new double[size];
-    static float[] seedFloat = new float[size];
-    {
-        for (int i = 0; i < seedFloat.length; i++) {
-            seedFloat[i] = (float) Math.random();
-        }
-    }
-    static double[] seedDouble = new double[size];
-    {
-        for (int i = 0; i < seedDouble.length; i++) {
-            seedDouble[i] = Math.random();
-        }
-    }
-
-    public static void run(float[] inFloat, double[] inDouble, float[] outFloat, double[] outDouble, int gid) {
-        outFloat[gid] = (float) inDouble[gid];
-        outDouble[gid] = inFloat[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
-        Arrays.fill(outputDouble, 0);
-        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
-        Arrays.fill(outputFloat, 0);
-        dispatchMethodKernel(64, inputFloat, inputDouble, outputFloat, outputDouble);
-    }
-
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatLongConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests float to long conversion.
- */
-public class FloatLongConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final float[] inputFloat = new float[size];
-    static final long[] inputLong = new long[size];
-    @Result static final float[] outputFloat = new float[size];
-    @Result static final long[] outputLong = new long[size];
-    static float[] seedFloat = new float[size];
-    {
-        for (int i = 0; i < seedFloat.length; i++) {
-            seedFloat[i] = (float) Math.random();
-        }
-    }
-    static long[] seedLong = new long[size];
-    {
-        for (int i = 0; i < seedLong.length; i++) {
-            seedLong[i] = (long) Math.random();
-        }
-    }
-
-    public static void run(float[] inFloat, long[] inLong, float[] outFloat, long[] outLong, int gid) {
-        outFloat[gid] = inLong[gid];
-        outLong[gid] = (long) inFloat[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
-        Arrays.fill(outputLong, 0);
-        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
-        Arrays.fill(outputFloat, 0);
-        dispatchMethodKernel(64, inputFloat, inputLong, outputFloat, outputLong);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatNegTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests negation of float values. Generates a neg_f32 instruction.
- */
-public class FloatNegTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of negation operations.
-    @Result protected float[] outArray = new float[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a negation operation on
-     * an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(float[] out, float[] ina, int gid) {
-        out[gid] = -(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(float[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        float[] inArray = new float[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/FloatSqrtTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests instanceof operator. Requires correct support for decompression of klass ptrs.
- */
-public class InstanceOfTest extends GraalKernelTester {
-
-    static final int NUM = 20;
-
-    abstract static class Shape {
-
-        public abstract 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) {
-            this.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;
-        }
-    }
-
-    public void run(int gid) {
-        outArray[gid] = (inShapeArray[gid] instanceof Circle ? 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/InstanceOfTwoLevelTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * 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;
-
-    abstract static class Shape {
-        public abstract 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) {
-            this.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	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for call to Math.abs(int). Generates an abs_s32 instruction.
- */
-public class IntAbsTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of negation operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.abs( ) on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(int[] out, int[] ina, int gid) {
-        out[gid] = Math.abs(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(int[] in) {
-        // initialize input array with a mix of positive and negative values and any corner cases.
-        for (int i = 0; i < num; i++) {
-            if (i == 1) {
-                in[i] = Integer.MIN_VALUE;
-            } else {
-                in[i] = i < num / 2 ? i : -i;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddIndexTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests array element addition.
- */
-public class IntAddIndexTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        int outIdx = gid + ina[0] - 1;
-        out[outIdx] = ina[gid] + inb[gid];
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests integer addition.
- */
-public class IntAddTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = ina[gid] + inb[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseAndTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two ints.
- */
-public class IntBitwiseAndTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(int[] in, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i + i;
-            in2[i] = i * i;
-            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);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseNotTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise not of an integer.
- */
-public class IntBitwiseNotTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of the operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise not operation
-     * on an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int gid) {
-        out[gid] = ~(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseOrTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two ints.
- */
-public class IntBitwiseOrTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(int[] in, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i + 1;
-            in2[i] = i * i;
-            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);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftLeftTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise shift left of int values. Generates an shl_s32 instruction.
- */
-public class IntBitwiseShiftLeftTest extends GraalKernelTester {
-
-    static final int num = 100;
-    // Output array containing the results of shift operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise shift left
-     * operation on each element of an input array and writes each result to the corresponding index
-     * of an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param shiftAmount an array of values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] << shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work items will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(int[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise shift right of int values. Generates an shr_s32 instruction.
- */
-public class IntBitwiseShiftRightTest extends GraalKernelTester {
-
-    static final int num = 100;
-    // Output array containing the results of shift operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise shift left
-     * operation on each element of an input array and writes each result to the corresponding index
-     * of an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param shiftAmount an array of values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] >> shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work items will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(int[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseShiftRightUnsignedTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests unsigned bitwise shift right of int values. Generates an shr_u32 instruction.
- */
-public class IntBitwiseShiftRightUnsignedTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array containing the results of shift operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise unsigned shift
-     * right operation on an element of an input array and writes the result to the corresponding
-     * index of an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param shiftAmount array containing values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] >>> shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work groups will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(int[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntBitwiseXorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two ints.
- */
-public class IntBitwiseXorTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(int[] in, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i;
-            in2[i] = i * i;
-            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);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntByteConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to byte conversion.
- */
-public class IntByteConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final byte[] inputByte = new byte[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final byte[] outputByte = new byte[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static byte[] seedByte = new byte[size];
-    {
-        for (int i = 0; i < seedByte.length; i++) {
-            seedByte[i] = (byte) Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, byte[] inByte, int[] outInt, byte[] outByte, int gid) {
-        outInt[gid] = inByte[gid];
-        outByte[gid] = (byte) inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedByte, 0, inputByte, 0, seedByte.length);
-        Arrays.fill(outputByte, (byte) 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputByte, outputInt, outputByte);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntCharConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to char conversion.
- */
-public class IntCharConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final char[] inputChar = new char[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final char[] outputChar = new char[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static char[] seedChar = new char[size];
-    {
-        for (int i = 0; i < seedChar.length; i++) {
-            seedChar[i] = (char) Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, char[] inChar, int[] outInt, char[] outChar, int gid) {
-        outInt[gid] = inChar[gid];
-        outChar[gid] = (char) inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedChar, 0, inputChar, 0, seedChar.length);
-        Arrays.fill(outputChar, (char) 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputChar, outputInt, outputChar);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDivTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests integer division.
- */
-public class IntDivTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     * @param out
-     * @param ina
-     * @param inb
-     * @param gid
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = inb[gid] / ina[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubleConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to double conversion.
- */
-public class IntDoubleConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final double[] inputDouble = new double[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final double[] outputDouble = new double[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static double[] seedDouble = new double[size];
-    {
-        for (int i = 0; i < seedDouble.length; i++) {
-            seedDouble[i] = Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, double[] inDouble, int[] outInt, double[] outDouble, int gid) {
-        outInt[gid] = (int) inDouble[gid];
-        outDouble[gid] = inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedDouble, 0, inputDouble, 0, seedDouble.length);
-        Arrays.fill(outputDouble, 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputDouble, outputInt, outputDouble);
-    }
-
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntDoubledTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests doubling an integer value.
- */
-public class IntDoubledTest 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) {
-        out[gid] = in[gid] + in[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntFloatConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to float conversion.
- */
-public class IntFloatConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final float[] inputFloat = new float[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final float[] outputFloat = new float[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static float[] seedFloat = new float[size];
-    {
-        for (int i = 0; i < seedFloat.length; i++) {
-            seedFloat[i] = (float) Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, float[] inFloat, int[] outInt, float[] outFloat, int gid) {
-        outInt[gid] = (int) inFloat[gid];
-        outFloat[gid] = inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedFloat, 0, inputFloat, 0, seedFloat.length);
-        Arrays.fill(outputFloat, 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputFloat, outputInt, outputFloat);
-    }
-
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLongConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to long conversion.
- */
-public class IntLongConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final long[] inputLong = new long[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final long[] outputLong = new long[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static long[] seedLong = new long[size];
-    {
-        for (int i = 0; i < seedLong.length; i++) {
-            seedLong[i] = (long) Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, long[] inLong, int[] outInt, long[] outLong, int gid) {
-        outInt[gid] = (int) inLong[gid];
-        outLong[gid] = inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedLong, 0, inputLong, 0, seedLong.length);
-        Arrays.fill(outputLong, 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputLong, outputInt, outputLong);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntLookupSwitchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests a switch statement with integer keys. This test exercises the LOOKUPSWITCH Java bytecode
- * instruction.
- *
- * The HSAIL code generated for this example is a series of cascading compare and branch
- * instructions for each case of the switch.
- *
- * These HSAIL instructions have the following form:
- *
- *
- * //Check whether the key matches the key constant of the case. Store the result of the compare (0
- * or 1) in the control register c0.
- *
- * cmp_eq $c0 &lt;source register&gt;, &lt;key constant for case statement&gt;
- *
- * //Branch to the corresponding label of that case if there's a match.
- *
- * cbr $c0 &lt;branch target for that case&gt;
- */
-public class IntLookupSwitchTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of the operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method writes to an output array based on
-     * switching on an element of an input array. By convention the gid is the last parameter.
-     *
-     * Note: Because the key constants used in the cases of the switch are sparsely distributed, the
-     * Java source compiler compiles this example into the LOOKUPSWITCH bytecode instruction. So
-     * this is really a test to see whether the HSAIL backend is appropriately handling the
-     * LOOKUPSWITCH bytecode.
-     *
-     * @param out the output array
-     * @param ina the input array
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int gid) {
-        switch (ina[gid]) {
-            case 0:
-                out[gid] = ina[gid];
-                break;
-            case 1:
-            case 2:
-                break;
-            case 5:
-                out[gid] = ina[gid] * ina[gid];
-                break;
-            case 10:
-                out[gid] = -ina[gid];
-                break;
-            case 15:
-                out[gid] = ina[gid] - ina[gid];
-                break;
-            case 19:
-                out[gid] = ina[gid] + ina[gid];
-                break;
-            default:
-                out[gid] = 9;
-                break;
-        }
-        out[gid] += ina[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     *
-     * @param in the input array
-     */
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntModTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests modulo operation.
- */
-public class IntModTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     * @param out
-     * @param ina
-     * @param inb
-     * @param gid
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = inb[gid] % ina[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntMulTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests array multiplication.
- */
-public class IntMulTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     * @param out
-     * @param ina
-     * @param inb
-     * @param gid
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = ina[gid] * inb[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntNegTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer negation. Generates a neg_s32 instruction.
- */
-public class IntNegTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of negation operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a negation operation on
-     * an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(int[] out, int[] ina, int gid) {
-        out[gid] = -(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntShortConvertTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests integer to short conversion.
- */
-public class IntShortConvertTest extends GraalKernelTester {
-
-    static final int size = 128;
-    static final int[] inputInt = new int[size];
-    static final short[] inputShort = new short[size];
-    @Result static final int[] outputInt = new int[size];
-    @Result static final short[] outputShort = new short[size];
-    static int[] seedInt = new int[size];
-    {
-        for (int i = 0; i < seedInt.length; i++) {
-            seedInt[i] = (int) Math.random();
-        }
-    }
-    static short[] seedShort = new short[size];
-    {
-        for (int i = 0; i < seedShort.length; i++) {
-            seedShort[i] = (short) Math.random();
-        }
-    }
-
-    public static void run(int[] inInt, short[] inShort, int[] outInt, short[] outShort, int gid) {
-        outInt[gid] = inShort[gid];
-        outShort[gid] = (short) inInt[gid];
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedShort, 0, inputShort, 0, seedShort.length);
-        Arrays.fill(outputShort, (short) 0);
-        System.arraycopy(seedInt, 0, inputInt, 0, seedInt.length);
-        Arrays.fill(outputInt, 0);
-        dispatchMethodKernel(64, inputInt, inputShort, outputInt, outputShort);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSqrAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests array addition and multiplication.
- */
-public class IntSqrAddTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     * @param out
-     * @param ina
-     * @param inb
-     * @param gid
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = (ina[gid] * ina[gid]) + inb[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredGidCmpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests comparison operation and array multiplication.
- */
-public class IntSquaredGidCmpTest 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 (gid > 9) {
-            out[gid] = in[gid] * in[gid];
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTernaryTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests conditionals, modulo arithmetic, and addition and multiplications.
- */
-public class IntSquaredTernaryTest 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) {
-        int val = in[gid] * in[gid];
-        val = (val % 2 == 1 ? val + 1 : val);
-        out[gid] = val;
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSquaredTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests squaring an array element.
- */
-public class IntSquaredTest 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) {
-        out[gid] = in[gid] * in[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCatchNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
- * back to the java code. In addition, it is set up so the bci of the exception point is not zero.
- */
-public class IntStreamNullCatchNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-
-    static class BasePoint {
-        int x;
-        int y;
-
-        public BasePoint(int x, int y) {
-            this.x = x;
-            this.y = y;
-        }
-
-        public int getX() {
-            return x;
-        }
-
-        public int getY() {
-            return y;
-        }
-    }
-
-    static class MyPoint extends BasePoint {
-        public MyPoint(int x, int y) {
-            super(x, y);
-        }
-    }
-
-    BasePoint[] inputs = new BasePoint[num];
-    MyPoint[] outputs = new MyPoint[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            inputs[i] = new MyPoint(i, i + 1);
-        }
-        inputs[10] = null;
-    }
-
-    @Result public int nullSeenGid;
-    @Result public int nullSeenAdjustment;
-
-    public void run(int gid) {
-        // gid 10 should always throw NPE
-        MyPoint mp = (MyPoint) inputs[gid];
-        int adjustment = 0;
-        int tmp = gid;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        try {
-            mp.x = mp.y + adjustment;
-        } catch (NullPointerException e) {
-            nullSeenGid = gid;
-            nullSeenAdjustment = adjustment;
-        }
-        outputs[gid] = mp;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
- * back to the java code. In addition, it is set up so the bci of the exception point is not zero.
- */
-public class IntStreamNullCheckNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-
-    static class BasePoint {
-        int x;
-        int y;
-
-        public BasePoint(int x, int y) {
-            this.x = x;
-            this.y = y;
-        }
-
-        public int getX() {
-            return x;
-        }
-
-        public int getY() {
-            return y;
-        }
-    }
-
-    static class MyPoint extends BasePoint {
-        public MyPoint(int x, int y) {
-            super(x, y);
-        }
-    }
-
-    BasePoint[] inputs = new BasePoint[num];
-    MyPoint[] outputs = new MyPoint[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            inputs[i] = new MyPoint(i, i + 1);
-        }
-        inputs[10] = null;
-    }
-
-    public void run(int gid) {
-        // gid 10 should always throw NPE
-        MyPoint mp = (MyPoint) inputs[gid];
-        int adjustment = 0;
-        int tmp = gid;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        mp.x = mp.y + adjustment;
-        outputs[gid] = mp;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * This test tests an int stream where we deliberately cause a NPE to test throwing the exception
- * back to the java code.
- */
-public class IntStreamNullCheckTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-
-    static class BasePoint {
-        int x;
-        int y;
-
-        public BasePoint(int x, int y) {
-            this.x = x;
-            this.y = y;
-        }
-
-        public int getX() {
-            return x;
-        }
-
-        public int getY() {
-            return y;
-        }
-    }
-
-    static class MyPoint extends BasePoint {
-        public MyPoint(int x, int y) {
-            super(x, y);
-        }
-    }
-
-    BasePoint[] inputs = new BasePoint[num];
-    MyPoint[] outputs = new MyPoint[num];
-
-    void setupArrays() {
-        for (int i = 0; i < num; i++) {
-            inputs[i] = new MyPoint(i, i + 1);
-        }
-        inputs[10] = null;
-    }
-
-    public void run(int gid) {
-        // gid 10 should always throw NPE
-        MyPoint mp = (MyPoint) inputs[gid];
-        mp.x = mp.y + 2;
-        outputs[gid] = mp;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(num);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullNonArrayParamCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests one of the kernel parameters being null.
- */
-public class IntStreamNullNonArrayParamCheckTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    static class MyObj {
-        public int val;
-    }
-
-    public static void run(int[] out, int[] ina, MyObj adjustment, int gid) {
-        out[gid] = ina[gid] + adjustment.val;
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, inArray1, null);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            // Fill input arrays with a mix of positive and negative values.
-            in1[i] = i < num / 2 ? i + 1 : -(i + 1);
-            in2[i] = (i & 1) == 0 ? in1[i] + 10 : -(in1[i] + 10);
-            outArray[i] = -i;
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntStreamNullParamCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests one of the kernel parameters being null.
- */
-public class IntStreamNullParamCheckTest extends SingleExceptionTestBase {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = ina[gid] + inb[gid];
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        try {
-            dispatchMethodKernel(num, outArray, null, inArray2);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            // Fill input arrays with a mix of positive and negative values.
-            in1[i] = i < num / 2 ? i + 1 : -(i + 1);
-            in2[i] = (i & 1) == 0 ? in1[i] + 10 : -(in1[i] + 10);
-            outArray[i] = -i;
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSubTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests subtracting one array element from another.
- */
-public class IntSubTest extends StaticMethodThreeIntArrays {
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     * @param out
-     * @param ina
-     * @param inb
-     * @param gid
-     */
-    public static void run(int[] out, int[] ina, int[] inb, int gid) {
-        out[gid] = ina[gid] - inb[gid];
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntSumArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests iteratively summing the elements of an array.
- */
-public class IntSumArrayTest 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) {
-        int sum = 0;
-        for (int n : in) {
-            sum += n;
-        }
-        out[gid] = sum;
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTableSwitchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests a switch statement with integer keys. This test exercises the TABLESWITCH Java bytecode
- * instruction.
- *
- * The HSAIL code generated for this example is a series of cascading compare and branch
- * instructions for each case of the switch.
- *
- * These instruction have the following form:
- *
- *
- * //Check whether the key matches the key constant of the case. Store the result of the compare (0
- * or 1) in the control register c0.
- *
- * cmp_eq $c0 &lt;source register&gt;, &lt;key constant for case statement&gt;
- *
- * //Branch to the corresponding label of that case if there's a match.
- *
- * cbr $c0 &lt;branch target for that case&gt;
- */
-public class IntTableSwitchTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of the operations.
-    @Result protected int[] outArray = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method writes to an output array based on
-     * switching on an element of an input array.
-     *
-     * Note: Because the key constants used in the cases of the switch are in consecutive order, the
-     * Java source compiler compiles this example into the TABLESWITCH bytecode instruction. So this
-     * is really a test to see whether the HSAIL backend is appropriately handling the TABLESWITCH
-     * bytecode.
-     *
-     * @param out the output array
-     * @param ina the input array
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, int[] ina, int gid) {
-        switch (ina[gid]) {
-            case 0:
-                out[gid] = ina[gid];
-                break;
-            case 1:
-                out[gid] = ina[gid] * ina[gid];
-                break;
-            case 2:
-                out[gid] = -ina[gid];
-                break;
-            case 3:
-                out[gid] = ina[gid] - ina[gid];
-                break;
-            case 4:
-                out[gid] = ina[gid] + ina[gid];
-                break;
-            case 5:
-            case 6:
-                out[gid] = ina[gid] * ina[gid];
-                break;
-            case 7:
-                out[gid] = -ina[gid] * 7;
-                break;
-            case 8:
-                break;
-            case 9:
-                int i = ina[gid] * 5;
-                out[gid] = ina[gid] - ina[gid] + i;
-                break;
-            case 10:
-                out[gid] = ina[gid] + ina[gid];
-                break;
-            default:
-                out[gid] = 9;
-                break;
-        }
-        out[gid] += ina[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     *
-     * @param in the input array
-     */
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/IntTestBranchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * 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	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests intrinsic for call to Math.abs(long). Generates an abs_s64 instruction.
- */
-public class LongAbsTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of the operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method calls Math.abs( ) on an element of
-     * an input array and writes the result to the corresponding index of an output array. By
-     * convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(long[] out, long[] ina, int gid) {
-        out[gid] = Math.abs(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(long[] in) {
-        // Initialize input array with a mix of positive and negative values and any corner cases.
-        for (int i = 0; i < num; i++) {
-            if (i == 1) {
-                in[i] = Long.MIN_VALUE;
-            } else {
-                in[i] = i < num / 2 ? i : -i;
-            }
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseAndTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two longs.
- */
-public class LongBitwiseAndTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(long[] out, long[] ina, long[] inb, int gid) {
-        out[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(long[] in, long[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i + i;
-            in2[i] = i * i;
-            outArray[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        long[] inArray2 = new long[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseNotTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise not of a long.
- */
-public class LongBitwiseNotTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of the operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise not operation
-     * on an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(long[] out, long[] ina, int gid) {
-        out[gid] = ~(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(long[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseOrTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two longs.
- */
-public class LongBitwiseOrTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(long[] out, long[] ina, long[] inb, int gid) {
-        out[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(long[] in, long[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i + 1;
-            in2[i] = i * i;
-            outArray[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        long[] inArray2 = new long[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftLeftTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise left shift of long values. Generates an shl_s64 instruction.
- */
-public class LongBitwiseShiftLeftTest extends GraalKernelTester {
-
-    static final int num = 100;
-    // Output array containing the results of shift operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise shift left
-     * operation on an element of an input array and writes the result to the corresponding index of
-     * an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param shiftAmount an array of values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(long[] out, long[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] << shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work items will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(long[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            /**
-             * Fill lower half of in[] with positive numbers and upper half with negative numbers.
-             */
-            in[i] = i < num / 2 ? i : -i;
-            /**
-             * Fill shiftAmount[] so that even elements are positive and odd elements are negative.
-             */
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests bitwise right shift of long values. Generates an shr_s64 instruction.
- */
-public class LongBitwiseShiftRightTest extends GraalKernelTester {
-
-    static final int num = 100;
-    // Output array containing the results of shift operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a bitwise shift righj
-     * operation on an element of an input array and writes the result to the corresponding index of
-     * an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array
-     * @param ina the input array
-     * @param shiftAmount an array of values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(long[] out, long[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] >> shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work items will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array
-     */
-    void setupArrays(long[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            /**
-             * Fill lower half of in[] with positive numbers and upper half with negative numbers.
-             */
-            in[i] = i < num / 2 ? i : -i;
-            /**
-             * Fill shiftAmount[] so that even elements are positive and odd elements are negative.
-             */
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseShiftRightUnsignedTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * 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 unsigned bitwise right shift of long values. Generates an shr_u64 instruction.
- */
-public class LongBitwiseShiftRightUnsignedTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array containing the results of shift operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs an unsigned bitwise shift
-     * right operation on an element of an input array and writes the result to the corresponding
-     * index of an output array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param shiftAmount array containing values used for the shift magnitude
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(long[] out, long[] ina, int[] shiftAmount, int gid) {
-        out[gid] = ina[gid] >>> shiftAmount[gid];
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the arrays passed to the run routine.
-     * 
-     * We do this in such a way that the input arrays contain a mix of negative and positive values.
-     * As a result, the work groups will exercise all the different combinations for the sign of the
-     * value being shifted and the sign of the shift magnitude.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(long[] in, int[] shiftAmount) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            shiftAmount[i] = (i & 1) == 0 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        int[] shiftAmount = new int[num];
-        setupArrays(inArray, shiftAmount);
-        dispatchMethodKernel(num, outArray, inArray, shiftAmount);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongBitwiseXorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two longs.
- */
-public class LongBitwiseXorTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(long[] out, long[] ina, long[] inb, int gid) {
-        out[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(long[] in, long[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i;
-            in2[i] = i * i;
-            outArray[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        long[] inArray2 = new long[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongModTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests the remainder operation (%) on two longs. Generates a rem_s64 instruction.
- */
-public class LongModTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * This routine performs the remainder operation (%) on elements from two input arrays and
-     * writes the result to the corresponding index of an output array.
-     * 
-     * @param out the output array
-     * @param ina the first input array
-     * @param inb the second input array
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(long[] out, long[] ina, long[] inb, int gid) {
-        out[gid] = (ina[gid] % inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initialize input and output arrays.
-     * 
-     * @param in first input array
-     * @param in2 second input array
-     */
-    void setupArrays(long[] in, long[] in2) {
-        for (int i = 0; i < num; i++) {
-            // Fill input arrays with a mix of positive and negative values.
-            in[i] = i < num / 2 ? i + 1 : -(i + 1);
-            in2[i] = (i & 1) == 0 ? i + 10 : -(i + 10);
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        long[] inArray2 = new long[num];
-        setupArrays(inArray, inArray2);
-        dispatchMethodKernel(num, outArray, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/LongNegTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests negation of long values. Generates a neg_s64 instruction.
- */
-public class LongNegTest extends GraalKernelTester {
-
-    static final int num = 20;
-    // Output array storing the results of negation operations.
-    @Result protected long[] outArray = new long[num];
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a negation operation on
-     * an element of an input array and writes the result to the corresponding index of an output
-     * array. By convention the gid is the last parameter.
-     * 
-     * @param out the output array.
-     * @param ina the input array.
-     * @param gid the parameter used to index into the input and output arrays.
-     */
-    public static void run(long[] out, long[] ina, int gid) {
-        out[gid] = -(ina[gid]);
-    }
-
-    /**
-     * 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() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     * 
-     * @param in the input array.
-     */
-    void setupArrays(long[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i < num / 2 ? i : -i;
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        long[] inArray = new long[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/NestedStaticCallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/NestedVirtualCallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * 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/ObjSpillDeoptBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * 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 java.util.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Base class for testing deopt when objects are in stack slots.
- */
-public abstract class ObjSpillDeoptBase extends GraalKernelTester {
-
-    abstract int getSize();
-
-    int loopcount = 5;
-    int objcount = 20;
-    @Result double[] out = new double[getSize()];
-    @Result double[] aux = new double[getSize()];
-    DVec3[] in = new DVec3[objcount];
-
-    public void doCompute(int gid, boolean causeDeopt) {
-        int idx = gid * 2 + 7;
-        DVec3 v0 = in[(idx++) % objcount];
-        DVec3 v1 = in[(idx++) % objcount];
-        DVec3 v2 = in[(idx++) % objcount];
-        DVec3 v3 = in[(idx++) % objcount];
-        DVec3 v4 = in[(idx++) % objcount];
-        DVec3 v5 = in[(idx++) % objcount];
-        DVec3 v6 = in[(idx++) % objcount];
-        DVec3 v7 = in[(idx++) % objcount];
-        DVec3 v8 = in[(idx++) % objcount];
-        DVec3 v9 = in[(idx++) % objcount];
-        idx += gid;
-        DVec3 v10 = in[(idx++) % objcount];
-        DVec3 v11 = in[(idx++) % objcount];
-        DVec3 v12 = in[(idx++) % objcount];
-        DVec3 v13 = in[(idx++) % objcount];
-        DVec3 v14 = in[(idx++) % objcount];
-        DVec3 v15 = in[(idx++) % objcount];
-        DVec3 v16 = in[(idx++) % objcount];
-        DVec3 v17 = in[(idx++) % objcount];
-        DVec3 v18 = in[(idx++) % objcount];
-        DVec3 v19 = in[(idx++) % objcount];
-        double sum = 0.0;
-        double sum1 = 0.0;
-        double sum2 = 0.0;
-        for (int i = 0; i < loopcount; i++) {
-            sum1 += v0.x + v1.y + v2.z + v3.x + v4.y + v5.z + v6.x + v7.y + v8.z + v9.x + i;
-            sum2 += v10.y + v11.z + v12.x + v13.y + v14.z + v15.x + v16.y + v17.z + v18.x + v19.y - i;
-            sum += sum1 - sum2 + i;
-            aux[gid] += sum1 + 1.2345;
-        }
-        if (causeDeopt) {
-            aux[gid] += forceDeopt(sum1);
-        }
-        out[gid] += sum;
-    }
-
-    @Override
-    public void runTest() {
-        Arrays.fill(out, -1.0);
-        for (int i = 0; i < objcount; i++) {
-            in[i] = new DVec3(i / 10f, (i + 1) / 10f, (i + 2) / 10f);
-        }
-        dispatchMethodKernel(getSize());
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return canDeoptimize();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with many items deopting.
- */
-public class ObjSpillDeoptMany20000Test extends ObjSpillDeoptManyBase {
-
-    @Override
-    int getSize() {
-        return 20000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany5000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with many items deopting.
- */
-public class ObjSpillDeoptMany5000Test extends ObjSpillDeoptManyBase {
-
-    @Override
-    int getSize() {
-        return 5000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMany99999Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with many items deopting.
- */
-public class ObjSpillDeoptMany99999Test extends ObjSpillDeoptManyBase {
-
-    @Override
-    int getSize() {
-        return 99999;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptManyBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * Base class for testing deopt with objects in stack slots, with many items deopting.
- */
-public abstract class ObjSpillDeoptManyBase extends ObjSpillDeoptBase {
-
-    public void run(int gid) {
-        boolean causeDeopt = (gid < 4096 && gid % 512 == 1);
-        doCompute(gid, causeDeopt);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with most items deopting.
- */
-public class ObjSpillDeoptMost20000Test extends ObjSpillDeoptMostBase {
-
-    @Override
-    int getSize() {
-        return 20000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost5000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with most items deopting.
- */
-public class ObjSpillDeoptMost5000Test extends ObjSpillDeoptMostBase {
-
-    @Override
-    int getSize() {
-        return 5000;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMost99999Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, with most items deopting.
- */
-public class ObjSpillDeoptMost99999Test extends ObjSpillDeoptMostBase {
-
-    @Override
-    int getSize() {
-        return 99999;
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptMostBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-/**
- * Base class for testing deopt with objects in stack slots.
- */
-public abstract class ObjSpillDeoptMostBase extends ObjSpillDeoptBase {
-
-    public void run(int gid) {
-        boolean causeDeopt = (gid % 500 != 1);
-        doCompute(gid, causeDeopt);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptSingle100Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, one item deopting.
- */
-public class ObjSpillDeoptSingle100Test extends ObjSpillDeoptBase {
-
-    final int size = 100;
-
-    @Override
-    int getSize() {
-        return size;
-    }
-
-    public void run(int gid) {
-        boolean causeDeopt = (gid == size / 2);
-        doCompute(gid, causeDeopt);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjSpillDeoptSingle20000Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests deopt with objects in stack slots, one item deopting.
- */
-public class ObjSpillDeoptSingle20000Test extends ObjSpillDeoptBase {
-
-    final int size = 20000;
-
-    @Override
-    int getSize() {
-        return size;
-    }
-
-    public void run(int gid) {
-        boolean causeDeopt = (gid == size / 2);
-        doCompute(gid, causeDeopt);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreNullTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests the storing of null in an Object array.
- */
-public class ObjectStoreNullTest extends ObjectStoreTest {
-
-    @Override
-    public void run(int gid) {
-        outIntegerArray[gid] = (gid % 3 == 1 ? null : inIntegerArray[gid]);
-    }
-
-    @Test
-    @Override
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ObjectStoreTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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 the storing of objects into an array.
- */
-public class ObjectStoreTest extends GraalKernelTester {
-
-    static final int NUM = 20;
-
-    @Result public Integer[] outIntegerArray = new Integer[NUM];
-    public Integer[] inIntegerArray = new Integer[NUM];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inIntegerArray[i] = new Integer(i);
-            outIntegerArray[i] = null;
-        }
-    }
-
-    public void run(int gid) {
-        outIntegerArray[gid] = inIntegerArray[gid];
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two shorts and casts the result to a short.
- */
-public class ShortBitwiseAndCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected short[] outArray1 = new short[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (short) (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i + i);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseAndTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise AND of two shorts.
- */
-public class ShortBitwiseAndTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (ina[gid] & inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i + i);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two shorts and casts the result to a short.
- */
-public class ShortBitwiseOrCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected short[] outArray1 = new short[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (short) (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i + 1);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseOrTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise OR of two shorts.
- */
-public class ShortBitwiseOrTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (ina[gid] | inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i + 1);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two shorts and casts the result to a short.
- */
-public class ShortBitwiseXorCastTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected short[] outArray1 = new short[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(short[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (short) (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/ShortBitwiseXorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * 
- * Tests bitwise XOR of two shorts.
- */
-public class ShortBitwiseXorTest extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray1 = new int[num];
-
-    /**
-     * The static "kernel" method we will be testing. By convention the gid is the last parameter.
-     * 
-     */
-    public static void run(int[] out1, short[] ina, short[] inb, int gid) {
-        out1[gid] = (ina[gid] ^ inb[gid]);
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    void setupArrays(short[] in, short[] in2) {
-        for (int i = 0; i < num; i++) {
-            in[i] = (short) (i);
-            in2[i] = (short) (i * i);
-            outArray1[i] = 0;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        short[] inArray = new short[num];
-        short[] inArray2 = new short[num];
-        setupArrays(inArray, inArray2);
-
-        dispatchMethodKernel(num, outArray1, inArray, inArray2);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/SingleExceptionTestBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.*;
-
-/**
- *
- * @author ecaspole
- */
-public abstract class SingleExceptionTestBase extends GraalKernelTester {
-
-    @Result Class<?> exceptionClass;
-    @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
-        exceptionClass = e.getClass();
-        // exception = e;
-        StackTraceElement[] elems = e.getStackTrace();
-        firstStackTraceElement = elems[0];
-        // for tests where the exception was in the method parameters
-        // ignore the firstStackTraceElement matching
-        if (firstStackTraceElement.getClassName().contains("KernelTester")) {
-            firstStackTraceElement = null;
-        }
-        for (StackTraceElement elem : elems) {
-            if (elem.toString().contains("KernelTester")) {
-                break;
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticCallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * 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/StaticDoubleSpillBoundsCatchOneTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests the spilling of double variables into memory with deopt.
- */
-public class StaticDoubleSpillBoundsCatchOneTest extends GraalKernelTester {
-
-    static final int size = 100;
-    private double[] in = new double[size * 400];
-    @Result public double[] out = new double[size * 400];
-    @Result public double[] aux = new double[2];
-
-    public static void run(double[] out, double[] in, double[] aux, int gid) {
-        int id = gid;
-        int step = 20;
-        double sum0;
-        double sum1;
-        double sum2;
-        double sum3;
-        double sum4;
-        double sum5;
-        double sum6;
-        double sum7;
-        double sum8;
-        double sum9;
-        double sum10;
-        double sum11;
-        double sum12;
-        double sum13;
-        double sum14;
-        double sum15;
-        double sum16;
-        double sum17;
-        double sum18;
-        double sum19;
-        sum0 = sum1 = sum2 = sum3 = sum4 = sum5 = sum6 = sum7 = sum8 = sum9 = 0;
-        sum10 = sum11 = sum12 = sum13 = sum14 = sum15 = sum16 = sum17 = sum18 = sum19 = 0;
-        try {
-            for (int i = 0; i < size; i += step) {
-                sum0 += in[i + 0];
-                sum1 += in[i + 1];
-                sum2 += in[i + 2];
-                sum3 += in[i + 3];
-                sum4 += in[i + 4];
-                sum5 += in[i + 5];
-                sum6 += in[i + 6];
-                sum7 += in[i + 7];
-                sum8 += in[i + 8];
-                sum9 += in[i + 9];
-                sum10 += in[i + 0];
-                sum11 += in[i + 1];
-                sum12 += in[i + 2];
-                sum13 += in[i + 3];
-                sum14 += in[i + 4];
-                sum15 += in[i + 5];
-                sum16 += in[i + 6];
-                sum17 += in[i + 7];
-                sum18 += in[i + 8];
-                sum19 += in[i + 9];
-
-                if (id == size / 2) {
-                    aux[id] = sum1 + sum2 + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9 + sum10 + sum11 + sum12 + sum13 + sum14 + sum15 + sum16;
-                }
-            }
-        } catch (ArrayIndexOutOfBoundsException e) {
-            aux[0] += sum1 + sum2;
-        }
-
-        out[id * step + 0] = sum0;
-        out[id * step + 1] = sum1;
-        out[id * step + 2] = sum2;
-        out[id * step + 3] = sum3;
-        out[id * step + 4] = sum4;
-        out[id * step + 5] = sum5;
-        out[id * step + 6] = sum6;
-        out[id * step + 7] = sum7;
-        out[id * step + 8] = sum8;
-        out[id * step + 9] = sum9;
-        out[id * step + 10] = sum10;
-        out[id * step + 11] = sum11;
-        out[id * step + 12] = sum12;
-        out[id * step + 13] = sum13;
-        out[id * step + 14] = sum14;
-        out[id * step + 15] = sum15;
-        out[id * step + 16] = sum16;
-        out[id * step + 17] = sum17;
-        out[id * step + 18] = sum18;
-        out[id * step + 19] = sum19;
-    }
-
-    @Override
-    public void runTest() {
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         *
-         */
-        Arrays.fill(out, -1f);
-        for (int i = 0; i < size; i++) {
-            in[i] = i + 1;
-        }
-        dispatchMethodKernel(size, out, in, aux);
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return canDeoptimize();
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillBoundsCatchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests the spilling of double variables into memory with deopt.
- */
-public class StaticDoubleSpillBoundsCatchTest extends GraalKernelTester {
-
-    static final int size = 100;
-    private double[] in = new double[size * 400];
-    @Result public double[] out = new double[size * 400];
-    @Result public double[] aux = new double[size];
-
-    public static void run(double[] out, double[] in, double[] aux, int gid) {
-        int id = gid;
-        int step = 20;
-        double sum0;
-        double sum1;
-        double sum2;
-        double sum3;
-        double sum4;
-        double sum5;
-        double sum6;
-        double sum7;
-        double sum8;
-        double sum9;
-        double sum10;
-        double sum11;
-        double sum12;
-        double sum13;
-        double sum14;
-        double sum15;
-        double sum16;
-        double sum17;
-        double sum18;
-        double sum19;
-        sum0 = sum1 = sum2 = sum3 = sum4 = sum5 = sum6 = sum7 = sum8 = sum9 = 0;
-        sum10 = sum11 = sum12 = sum13 = sum14 = sum15 = sum16 = sum17 = sum18 = sum19 = 0;
-        try {
-            for (int i = 0; i < size; i += step) {
-                sum0 += in[i + 0];
-                sum1 += in[i + 1];
-                sum2 += in[i + 2];
-                sum3 += in[i + 3];
-                sum4 += in[i + 4];
-                sum5 += in[i + 5];
-                sum6 += in[i + 6];
-                sum7 += in[i + 7];
-                sum8 += in[i + 8];
-                sum9 += in[i + 9];
-                sum10 += in[i + 0];
-                sum11 += in[i + 1];
-                sum12 += in[i + 2];
-                sum13 += in[i + 3];
-                sum14 += in[i + 4];
-                sum15 += in[i + 5];
-                sum16 += in[i + 6];
-                sum17 += in[i + 7];
-                sum18 += in[i + 8];
-                sum19 += in[i + 9];
-
-                if (id > size / 2) {
-                    aux[id + 10] += sum1 + sum2;
-                    // + sum3 + sum4 + sum5 + sum6 + sum7 + sum8 + sum9 + sum10 + sum11 + sum12 +
-                    // sum13 + sum14 + sum15 + sum16;
-                }
-            }
-        } catch (ArrayIndexOutOfBoundsException e) {
-            aux[id] += sum1 + sum2;
-        }
-
-        out[id * step + 0] = sum0;
-        out[id * step + 1] = sum1;
-        out[id * step + 2] = sum2;
-        out[id * step + 3] = sum3;
-        out[id * step + 4] = sum4;
-        out[id * step + 5] = sum5;
-        out[id * step + 6] = sum6;
-        out[id * step + 7] = sum7;
-        out[id * step + 8] = sum8;
-        out[id * step + 9] = sum9;
-        out[id * step + 10] = sum10;
-        out[id * step + 11] = sum11;
-        out[id * step + 12] = sum12;
-        out[id * step + 13] = sum13;
-        out[id * step + 14] = sum14;
-        out[id * step + 15] = sum15;
-        out[id * step + 16] = sum16;
-        out[id * step + 17] = sum17;
-        out[id * step + 18] = sum18;
-        out[id * step + 19] = sum19;
-    }
-
-    @Override
-    public void runTest() {
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         *
-         */
-        Arrays.fill(out, -1f);
-        Arrays.fill(aux, 0f);
-        for (int i = 0; i < size; i++) {
-            in[i] = i + 1;
-        }
-        dispatchMethodKernel(size, out, in, aux);
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return canDeoptimize();
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticDoubleSpillTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests the spilling of double variables into memory.
- */
-public class StaticDoubleSpillTest extends GraalKernelTester {
-
-    static final int size = 100;
-    private double[] in = new double[size * 400];
-    @Result private double[] out = new double[size * 400];
-
-    public static void run(double[] out, double[] in, int gid) {
-        int id = gid;
-        int step = 20;
-        double sum0;
-        double sum1;
-        double sum2;
-        double sum3;
-        double sum4;
-        double sum5;
-        double sum6;
-        double sum7;
-        double sum8;
-        double sum9;
-        double sum10;
-        double sum11;
-        double sum12;
-        double sum13;
-        double sum14;
-        double sum15;
-        double sum16;
-        double sum17;
-        double sum18;
-        double sum19;
-        sum0 = sum1 = sum2 = sum3 = sum4 = sum5 = sum6 = sum7 = sum8 = sum9 = 0;
-        sum10 = sum11 = sum12 = sum13 = sum14 = sum15 = sum16 = sum17 = sum18 = sum19 = 0;
-        for (int i = 0; i < size; i += step) {
-            sum0 += in[i + 0];
-            sum1 += in[i + 1];
-            sum2 += in[i + 2];
-            sum3 += in[i + 3];
-            sum4 += in[i + 4];
-            sum5 += in[i + 5];
-            sum6 += in[i + 6];
-            sum7 += in[i + 7];
-            sum8 += in[i + 8];
-            sum9 += in[i + 9];
-            sum10 += in[i + 0];
-            sum11 += in[i + 1];
-            sum12 += in[i + 2];
-            sum13 += in[i + 3];
-            sum14 += in[i + 4];
-            sum15 += in[i + 5];
-            sum16 += in[i + 6];
-            sum17 += in[i + 7];
-            sum18 += in[i + 8];
-            sum19 += in[i + 9];
-        }
-        out[id * step + 0] = sum0;
-        out[id * step + 1] = sum1;
-        out[id * step + 2] = sum2;
-        out[id * step + 3] = sum3;
-        out[id * step + 4] = sum4;
-        out[id * step + 5] = sum5;
-        out[id * step + 6] = sum6;
-        out[id * step + 7] = sum7;
-        out[id * step + 8] = sum8;
-        out[id * step + 9] = sum9;
-        out[id * step + 10] = sum10;
-        out[id * step + 11] = sum11;
-        out[id * step + 12] = sum12;
-        out[id * step + 13] = sum13;
-        out[id * step + 14] = sum14;
-        out[id * step + 15] = sum15;
-        out[id * step + 16] = sum16;
-        out[id * step + 17] = sum17;
-        out[id * step + 18] = sum18;
-        out[id * step + 19] = sum19;
-    }
-
-    @Override
-    public void runTest() {
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         * 
-         */
-        Arrays.fill(out, -1f);
-        for (int i = 0; i < size; i++) {
-            in[i] = i + 1;
-        }
-        dispatchMethodKernel(size, out, in);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticIntSpillTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests the spilling of integers into memory.
- */
-public class StaticIntSpillTest extends GraalKernelTester {
-
-    static final int size = 100;
-    private int[] in = new int[size * 400];
-    @Result private int[] out = new int[size * 400];
-
-    public static void run(int[] out, int[] in, int gid) {
-        int id = gid;
-        int step = 20;
-        int sum0;
-        int sum1;
-        int sum2;
-        int sum3;
-        int sum4;
-        int sum5;
-        int sum6;
-        int sum7;
-        int sum8;
-        int sum9;
-        sum0 = sum1 = sum2 = sum3 = sum4 = sum5 = sum6 = sum7 = sum8 = sum9 = 0;
-        for (int i = 0; i < size; i += step) {
-            sum0 += in[i + 0];
-            sum1 += in[i + 1];
-            sum2 += in[i + 2];
-            sum3 += in[i + 3];
-            sum4 += in[i + 4];
-            sum5 += in[i + 5];
-            sum6 += in[i + 6];
-            sum7 += in[i + 7];
-            sum8 += in[i + 8];
-            sum9 += in[i + 9];
-        }
-        out[id * step + 0] = sum0;
-        out[id * step + 1] = sum1;
-        out[id * step + 2] = sum2;
-        out[id * step + 3] = sum3;
-        out[id * step + 4] = sum4;
-        out[id * step + 5] = sum5;
-        out[id * step + 6] = sum6;
-        out[id * step + 7] = sum7;
-        out[id * step + 8] = sum8;
-        out[id * step + 9] = sum9;
-    }
-
-    @Override
-    public void runTest() {
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         * 
-         */
-        Arrays.fill(out, 0);
-        Arrays.fill(in, 0);
-        dispatchMethodKernel(size, out, in);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelBoundsCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Unit test that simulates the Mandelbrot application. The run method here is a static method
- * version of the original mandel kernel and the invoke parameters are for the starting point of the
- * mandel demo. Note: this will likely not pass the junit test on real hardware, but should pass on
- * the simulator.
- */
-public class StaticMandelBoundsCheckTest extends SingleExceptionTestBase {
-
-    static final int initWidth = 768;
-    static final int initHeight = initWidth;
-    static final int maxIterations = 64;
-    static final int range = initWidth * initHeight;
-    private int[] rgb = new int[range];
-
-    public static void run(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
-        final int width = initWidth;
-        final int height = initHeight;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-
-        // Iterate until the algorithm converges or until maxIterations are reached.
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid + 1] = pallette[count];   // will cause exception on last of 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);
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         */
-        try {
-            dispatchMethodKernel(range, rgb, palette, -1f, 0f, 3f);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMandelTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Unit test that simulates the Mandelbrot application. The run method here is a static method
- * version of the original mandel kernel and the invoke parameters are for the starting point of the
- * mandel demo. Note: this will likely not pass the junit test on real hardware, but should pass on
- * the simulator.
- */
-public class StaticMandelTest extends GraalKernelTester {
-
-    static final int initWidth = 768;
-    static final int initHeight = initWidth;
-    static final int maxIterations = 64;
-    static final int range = initWidth * initHeight;
-    @Result private int[] rgb = new int[range];
-
-    public static void run(int[] rgb, int[] pallette, float xoffset, float yoffset, float scale, int gid) {
-        final int width = initWidth;
-        final int height = initHeight;
-        float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + xoffset;
-        float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yoffset;
-        int count = 0;
-        float zx = lx;
-        float zy = ly;
-        float newzx = 0f;
-
-        // Iterate until the algorithm converges or until maxIterations are reached.
-        while (count < maxIterations && zx * zx + zy * zy < 8) {
-            newzx = zx * zx - zy * zy + lx;
-            zy = 2 * zx * zy + ly;
-            zx = newzx;
-            count++;
-        }
-        rgb[gid] = pallette[count];
-    }
-
-    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);
-        /**
-         * Call it for a range, specifying testmethod args (but not the fields it uses or the gid
-         * argument).
-         */
-        dispatchMethodKernel(range, rgb, palette, -1f, 0f, 3f);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethod16InArraysTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*;
-
-import org.junit.*;
-
-import com.oracle.graal.debug.*;
-
-/**
- * Tests the addition of elements from sixteen input arrays.
- */
-public class StaticMethod16InArraysTest extends StaticMethodTwoIntArrays {
-
-    @Override
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i;
-            outArray[i] = -i;
-        }
-    }
-
-    public static void run(int[] out, int[] ina, int[] inb, int[] inc, int[] ind, int[] ine, int[] inf, int[] ing, int[] inh, int[] ini, int[] inj, int[] ink, int[] inl, int[] inm, int[] inn,
-                    int[] ino, int[] inp, int gid) {
-        out[gid] = ina[gid] + inb[gid] + inc[gid] + ind[gid] + ine[gid] + inf[gid] + ing[gid] + inh[gid] + ini[gid] + inj[gid] + ink[gid] + inl[gid] + inm[gid] + inn[gid] + ino[gid] + inp[gid];
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        /**
-         * DumpArrayParameters(inArray); Call it for a range, specifying testmethod args (but not
-         * the fields it uses or the gid argument). Will put output in outArray.
-         */
-        dispatchMethodKernel(num, outArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray, inArray);
-    }
-
-    /**
-     * This test fails because we don't have correct logic to handle more input parameters than
-     * there are registers.
-     */
-    @Test(expected = java.lang.ClassCastException.class)
-    @Ignore("until GPU backends can co-exist")
-    public void test() {
-        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/StaticMethodThreeIntArrays.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-/**
- * Superclass that initializes two input arrays containing ints and one output array. Derived by
- * some of the other test cases that take two arrays of ints as input parameters.
- */
-public abstract class StaticMethodThreeIntArrays extends StaticMethodTwoIntArrays {
-
-    /**
-     * Initialize the input and output arrays.
-     * 
-     * @param in1 the first input array
-     * @param in2 the second input array
-     */
-    void setupArrays(int[] in1, int[] in2) {
-        for (int i = 0; i < num; i++) {
-            // Fill input arrays with a mix of positive and negative values.
-            in1[i] = i < num / 2 ? i + 1 : -(i + 1);
-            in2[i] = (i & 1) == 0 ? in1[i] + 10 : -(in1[i] + 10);
-            outArray[i] = -i;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray1 = new int[num];
-        int[] inArray2 = new int[num];
-        setupArrays(inArray1, inArray2);
-
-        /**
-         * DumpArrayParameters(inArray); Call it for a range, specifying testmethod args (but not
-         * the fields it uses or the gid argument). Will put output in outArray.
-         */
-        dispatchMethodKernel(num, outArray, inArray1, inArray2);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticMethodTwoIntArrays.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Superclass that initializes one input array and one output array. Derived by some of the other
- * test cases that take one array as input and write to an output array.
- */
-public abstract class StaticMethodTwoIntArrays extends GraalKernelTester {
-
-    static final int num = 20;
-    @Result protected int[] outArray = new int[num];
-
-    void setupArrays(int[] in) {
-        for (int i = 0; i < num; i++) {
-            in[i] = i;
-            outArray[i] = -i;
-        }
-    }
-
-    @Override
-    public void runTest() {
-        int[] inArray = new int[num];
-        setupArrays(inArray);
-        /**
-         * DumpArrayParameters(inArray); Call it for a range, specifying testmethod args (but not
-         * the fields it uses or the gid argument). Will put output in outArray.
-         */
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyCallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.*;
-
-/**
- * Unit test of NBody demo app. This version uses a call to the main routine which would normally be
- * too large to inline.
- */
-public class StaticNBodyCallTest extends StaticNBodyTest {
-
-    public static void run(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int gid) {
-        StaticNBodyTest.run(inxyz, outxyz, invxyz, outvxyz, gid);
-    }
-
-    @Override
-    public void runTest() {
-        super.runTest();
-    }
-
-    @Test
-    @Override
-    public void test() throws Exception {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodySpillTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * This version of NBody causes Graal to generate register spilling code.
- */
-public class StaticNBodySpillTest extends GraalKernelTester {
-
-    static final int bodies = 5;
-    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;
-    // Positions xy and z of bodies.
-    @Result private float[] inxyz = new float[bodies * 3];
-    // Positions xy and z of bodies.
-    @Result private float[] outxyz = new float[bodies * 3]; // positions xy and z of bodies
-    // Velocity component of x,y and z of bodies.
-    @Result private float[] invxyz = new float[bodies * 3];
-    @Result private float[] outvxyz = new float[bodies * 3];
-    static float[] seedxyz = 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);
-            seedxyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
-            seedxyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
-            seedxyz[body + 2] = (float) (radius * Math.cos(phi));
-        }
-    }
-
-    public static void run(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int 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 = inxyz[i + 0] - inxyz[globalId + 0];
-            final float dy = inxyz[i + 1] - inxyz[globalId + 1];
-            final float dz = inxyz[i + 2] - inxyz[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;
-        outxyz[globalId + 0] = inxyz[globalId + 0] + (invxyz[globalId + 0] * delT) + (accx * .5f * delT);
-        outxyz[globalId + 1] = inxyz[globalId + 1] + (invxyz[globalId + 1] * delT) + (accy * .5f * delT);
-        outxyz[globalId + 2] = inxyz[globalId + 2] + (invxyz[globalId + 2] * delT) + (accz * .5f * delT);
-        outvxyz[globalId + 0] = invxyz[globalId + 0] + accx;
-        outvxyz[globalId + 1] = invxyz[globalId + 1] + accy;
-        outvxyz[globalId + 2] = invxyz[globalId + 2] + accz;
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedxyz, 0, inxyz, 0, seedxyz.length);
-        Arrays.fill(outxyz, 0f);
-        Arrays.fill(outvxyz, 0f);
-        Arrays.fill(invxyz, 0f);
-        dispatchMethodKernel(bodies, inxyz, outxyz, invxyz, outvxyz);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StaticNBodyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Unit test of NBody demo app.
- */
-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;
-    // Positions xy and z of bodies.
-    @Result private float[] inxyz = new float[bodies * 3];
-    // Positions xy and z of bodies.
-    @Result private float[] outxyz = new float[bodies * 3];
-    // Velocity component of x,y and z of bodies.
-    @Result private float[] invxyz = new float[bodies * 3];
-    @Result private float[] outvxyz = new float[bodies * 3];
-    static float[] seedxyz = 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);
-            seedxyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
-            seedxyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
-            seedxyz[body + 2] = (float) (radius * Math.cos(phi));
-        }
-    }
-
-    public static void run(float[] inxyz, float[] outxyz, float[] invxyz, float[] outvxyz, int 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 = inxyz[i + 0] - inxyz[globalId + 0];
-            final float dy = inxyz[i + 1] - inxyz[globalId + 1];
-            final float dz = inxyz[i + 2] - inxyz[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;
-        outxyz[globalId + 0] = inxyz[globalId + 0] + (invxyz[globalId + 0] * delT) + (accx * .5f * delT);
-        outxyz[globalId + 1] = inxyz[globalId + 1] + (invxyz[globalId + 1] * delT) + (accy * .5f * delT);
-        outxyz[globalId + 2] = inxyz[globalId + 2] + (invxyz[globalId + 2] * delT) + (accz * .5f * delT);
-        outvxyz[globalId + 0] = invxyz[globalId + 0] + accx;
-        outvxyz[globalId + 1] = invxyz[globalId + 1] + accy;
-        outvxyz[globalId + 2] = invxyz[globalId + 2] + accz;
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedxyz, 0, inxyz, 0, seedxyz.length);
-        Arrays.fill(outxyz, 0f);
-        Arrays.fill(outvxyz, 0f);
-        Arrays.fill(invxyz, 0f);
-        dispatchMethodKernel(bodies, inxyz, outxyz, invxyz, outvxyz);
-    }
-
-    @Test
-    public void test() throws Exception {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests codegen for String.contains() but with a wrapper method such as one would get in the
- * IntConsumer.accept calls.
- */
-public class StringContainsAcceptTest extends StringContainsTest {
-
-    String base = "CDE";
-
-    // the accept method which "captured" the base
-    public void run(int gid) {
-        super.run(base, gid);
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM);
-    }
-
-    @Test
-    @Override
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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 codegen for 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);
-        }
-    }
-
-    public void run(String base, int gid) {
-        outArray[gid] = inArray[gid].contains(base);
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        String base = "CDE";
-        dispatchMethodKernel(NUM, base);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringEqualsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.*;
-
-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));
-        }
-    }
-
-    public void run(String base, int gid) {
-        outArray[gid] = inArray[gid].equals(base);
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchMethodKernel(NUM, "ABCDEFGHIJ");
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for String.indexOf().
- */
-public class StringIndexOfTest 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, i, 10);
-        }
-    }
-
-    public void run(String base, int gid) {
-        outArray[gid] = inArray[gid].indexOf(base);
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        String base = "CDE";
-        dispatchMethodKernel(NUM, base);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringSwitchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-
-/**
- * Tests switch statement with String literal keys.
- *
- * Note: In Java bytecode, this example reduces to a LOOKUPSWITCH over int keys because the Java
- * source compiler generates a call to String.hashcode( ) to convert to int values.
- *
- * The HSAIL code generated for this example is a series of cascading compare and branch
- * instructions for each case of the switch.
- *
- * These instruction have the following form:
- *
- *
- * //Check whether the key matches the key constant of the case. Store the result of the compare (0
- * or 1) in the control register c0.
- *
- * cmp_eq $c0 &lt;source register&gt;, &lt;key constant for case statement&gt;
- *
- * //Branch to the corresponding label of that case if there's a match.
- *
- * cbr $c0 &lt;branch target for that case&gt;
- */
-public class StringSwitchTest extends GraalKernelTester {
-
-    static final int num = 40;
-    // Output array storing the results of the operations.
-    @Result protected int[] outArray = new int[num];
-
-    // Array of Strings
-    String[] names = {"0-42L", "0-43-", "Mazda", "Nissan", "Chevrolet", "Porsche", "Ford Focus", "Volvo", "Cadillac", "BMW", "Indy Car", "Police Car", "Lexus", "Datsun", "Saab", "Volkswagen",
-                    "Honda Civic", "Jeeo Wrangler", "Toyota", "Mustang", "Chrysler", "Subaru"};
-
-    /**
-     * The static "kernel" method we will be testing. This method performs a switch statement over a
-     * String literal key.
-     *
-     * @param out the output array
-     * @param ina the input array of String literal keys
-     * @param gid the parameter used to index into the input and output arrays
-     */
-    public static void run(int[] out, String[] ina, int gid) {
-        switch (ina[gid]) {
-            case "Mazda":
-                out[gid] = 1;
-                break;
-            case "Nissan":
-                out[gid] = 2;
-                break;
-            case "Chevrolet":
-                out[gid] = 3;
-                break;
-            case "Porsche":
-                out[gid] = 4;
-                break;
-            case "Jeep Wrangler":
-                out[gid] = 5;
-                break;
-            case "Toyota":
-                out[gid] = 6;
-                break;
-            case "0-42L":
-                out[gid] = 890;
-                break;
-            case "0-43-":
-                out[gid] = 995;
-                break;
-            case "Chrysler":
-                out[gid] = 7;
-                break;
-            case "Mitsubishi":
-                out[gid] = 8;
-                break;
-            case "Ford Focus":
-                out[gid] = 9;
-                break;
-            case "Volvo":
-                out[gid] = 10;
-                break;
-            case "Subaru":
-                out[gid] = 11;
-                break;
-            case "BMW":
-                out[gid] = 12;
-                break;
-            case "Indy Car":
-                out[gid] = 13;
-                break;
-            case "Police Car":
-                out[gid] = 14;
-                break;
-        }
-    }
-
-    @Test
-    public void test() {
-        super.testGeneratedHsail();
-    }
-
-    /**
-     * Initializes the input and output arrays passed to the run routine.
-     *
-     * @param in the input array
-     */
-    void setupArrays(String[] in) {
-        for (int i = 0; i < num; i++) {
-            // fill the input array with Strings.
-            in[i] = names[i % names.length];
-            outArray[i] = 0;
-        }
-    }
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        String[] inArray = new String[num];
-        setupArrays(inArray);
-        dispatchMethodKernel(num, outArray, inArray);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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;
-
-/**
- * A simple 3 element Vector object used in some junit tests.
- */
-public class Vec3 {
-
-    public Vec3(float x, float y, float z) {
-        this.x = x;
-        this.y = y;
-        this.z = z;
-    }
-
-    public float x;
-    public float y;
-    public float z;
-
-    public static Vec3 add(Vec3 a, Vec3 b) {
-        return new Vec3(a.x + b.x, a.y + b.y, a.z + b.z);
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (!(other instanceof Vec3)) {
-            return false;
-        }
-        Vec3 oth = (Vec3) other;
-        return (oth.x == x && oth.y == y && oth.z == z);
-    }
-
-    @Override
-    public String toString() {
-        return ("Vec3[" + x + ", " + y + ", " + z + "]");
-    }
-
-    @Override
-    public int hashCode() {
-        return (int) (x + y + z);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamClassCastNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests an object array stream with one element being of the wrong class.
- */
-public class Vec3ObjStreamClassCastNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int NUM = 20;
-
-    public Vec3[] inArray = new Vec3[NUM];
-
-    static class MyVec3 extends Vec3 {
-        public MyVec3(float x, float y, float z) {
-            super(x, y, z);
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyVec3(i, i + 1, -1);
-        }
-        // insert one wrong type
-        inArray[10] = new Vec3(10, 11, -1);
-    }
-
-    int dummyInt = 10;
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        int adjustment = 0;
-        int tmp = dummyInt;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        MyVec3 myvec3 = (MyVec3) vec3;
-        myvec3.z = myvec3.x + myvec3.y + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(inArray);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamClassCastTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests an object array stream with one element being of the wrong class.
- */
-public class Vec3ObjStreamClassCastTest extends SingleExceptionTestBase {
-
-    static final int NUM = 20;
-
-    public Vec3[] inArray = new Vec3[NUM];
-
-    static class MyVec3 extends Vec3 {
-        public MyVec3(float x, float y, float z) {
-            super(x, y, z);
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyVec3(i, i + 1, -1);
-        }
-        // insert one wrong type
-        inArray[10] = new Vec3(10, 11, -1);
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        MyVec3 myvec3 = (MyVec3) vec3;
-        myvec3.z = myvec3.x + myvec3.y;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(inArray);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamFloatCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for a java 7 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];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new Vec3(i, i + 1, -1);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(float adjustment, Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y - adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray, 0.5f);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for a java 7 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];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new Vec3(i, i + 1, -1);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(int adjustment, Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y - adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray, 7);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamIntFloatCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for a java 7 style object array stream kernel, with one int and one float capture.
- */
-public class Vec3ObjStreamIntFloatCaptureTest 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);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(int adjustment, float multiplier, Vec3 vec3) {
-        vec3.z = (vec3.x + vec3.y - adjustment) * multiplier;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray, 7, 0.5f);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullCheckNonZeroBciTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests an object array stream with one element being null.
- */
-public class Vec3ObjStreamNullCheckNonZeroBciTest extends SingleExceptionTestBase {
-
-    static final int NUM = 20;
-
-    public Vec3[] inArray = new Vec3[NUM];
-
-    static class MyVec3 extends Vec3 {
-        public MyVec3(float x, float y, float z) {
-            super(x, y, z);
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyVec3(i, i + 1, -1);
-        }
-        // insert one null
-        inArray[10] = null;
-    }
-
-    int dummyInt = 10;
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        int adjustment = 0;
-        int tmp = dummyInt;
-        while (tmp-- >= 0) {
-            adjustment += tmp;
-        }
-        vec3.z = vec3.x + vec3.y + adjustment;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(inArray);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests an object array stream with one element being null.
- */
-public class Vec3ObjStreamNullCheckTest extends SingleExceptionTestBase {
-
-    static final int NUM = 20;
-
-    public Vec3[] inArray = new Vec3[NUM];
-
-    static class MyVec3 extends Vec3 {
-        public MyVec3(float x, float y, float z) {
-            super(x, y, z);
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyVec3(i, i + 1, -1);
-        }
-        // insert one null
-        inArray[10] = null;
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(inArray);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamNullParamCheckTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test;
-
-import org.junit.*;
-
-/**
- * Tests an object array stream with the object stream itself being null.
- */
-public class Vec3ObjStreamNullParamCheckTest extends SingleExceptionTestBase {
-
-    static final int NUM = 20;
-
-    public Vec3[] inArray = new Vec3[NUM];
-
-    static class MyVec3 extends Vec3 {
-        public MyVec3(float x, float y, float z) {
-            super(x, y, z);
-        }
-    }
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new MyVec3(i, i + 1, -1);
-        }
-        // insert one null
-        inArray[10] = null;
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        MyVec3 myvec3 = (MyVec3) vec3;
-        myvec3.z = myvec3.x + myvec3.y;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        try {
-            dispatchMethodKernel(null);
-        } catch (Exception e) {
-            recordException(e);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for a java 7 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];
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            inArray[i] = new Vec3(i, i + 1, -1);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 basevec, Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y - basevec.z;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray, new Vec3(1, 2, 3));
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamObjFieldTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * 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 codegen for a java 7 style object array stream kernel, no captures. 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);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y - basevec.z;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Vec3ObjStreamTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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 codegen for a java 7 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);
-        }
-    }
-
-    /**
-     * The "kernel" method we will be testing. For Array Stream, an object from the array will be
-     * the last parameter
-     */
-    public void run(Vec3 vec3) {
-        vec3.z = vec3.x + vec3.y;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchMethodKernel(inArray);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/VolatileIntTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * 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);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayFieldAccessTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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.*;
-
-/**
- * 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;
-        });
-    }
-
-    @Ignore("emitDirectCall unimplemented")
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListSetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-import java.util.*;
-
-/**
- * Tests calling ArrayList.set().
- */
-public class ArrayListSetTest extends GraalKernelTester {
-
-    static final int NUM = 50;
-    ArrayList<Integer> aryList = new ArrayList<>();
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            aryList.add(-1);
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            aryList.set(gid, gid);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    @Ignore
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ArrayListStreamTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * 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) {
-            this.x = x;
-            this.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);
-        }
-
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetGidTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntDecAndGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndDecTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndIncTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntIncAndGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongAddAndGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndAddTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndIncTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongIncAndGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/BigIntegerSquaredTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Body.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * 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);
-        this.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 value) {
-        m = value;
-    }
-
-    public void setX(float value) {
-        x = value;
-    }
-
-    public void setY(float value) {
-        y = value;
-    }
-
-    public void setZ(float value) {
-        z = value;
-    }
-
-    public void setVx(float value) {
-        v.x = value;
-    }
-
-    public void setVy(float value) {
-        v.y = value;
-    }
-
-    public void setVz(float value) {
-        v.z = value;
-    }
-
-    @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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayCopyConjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a byte array where src and dest overlap.
- */
-public class ByteArrayCopyConjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result byte[][] outArray = new byte[NUM][MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            for (int j = 0; j < outArray[i].length; j++) {
-                outArray[i][j] = (byte) (i + j);
-            }
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(outArray[gid], 0, outArray[gid], gid % NUM, NUM);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayCopyDisjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a byte array where src and dest do not overlap.
- */
-public class ByteArrayCopyDisjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result byte[][] outArray = new byte[NUM][MAXOUTSIZ];
-    byte[] inArray = new byte[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = (byte) i;
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ByteArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CharArrayCopyConjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a char array where src and dest overlap.
- */
-public class CharArrayCopyConjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result char[][] outArray = new char[NUM][MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            for (int j = 0; j < outArray[i].length; j++) {
-                outArray[i][j] = (char) (i + j);
-            }
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(outArray[gid], 0, outArray[gid], gid % NUM, NUM);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CharArrayCopyDisjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a char array where src and dest do not overlap.
- */
-public class CharArrayCopyDisjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result char[][] outArray = new char[NUM][MAXOUTSIZ];
-    char[] inArray = new char[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = (char) i;
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/CountMatchesBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * 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);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAcosTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#acos(double)}.
- */
-public class DoubleAcosTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.acos(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAsinTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#asin(double)}.
- */
-public class DoubleAsinTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.asin(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAtan2Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#atan2(double, double)}.
- */
-public class DoubleAtan2Test extends DoubleTwoInputMathBase {
-
-    // for atan2 ULPs can be off by 2 ulps.
-    @Override
-    protected int ulpsDelta() {
-        return 2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = Math.atan2(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleAtanTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#atan(double)}.
- */
-public class DoubleAtanTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.atan(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCbrtTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cbrt(double)}.
- */
-public class DoubleCbrtTest extends DoubleMathBase {
-
-    /**
-     * Dispatches the HSAIL kernel for this test case.
-     */
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.cbrt(inArray[gid]);
-        });
-    }
-
-    /**
-     * 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 testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCosTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cos(double)}.
- */
-public class DoubleCosTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.cos(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleCoshTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cosh(double)}.
- */
-public class DoubleCoshTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.cosh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleExpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#exp(double)}.
- */
-public class DoubleExpTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.exp(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleExpm1Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#expm1(double)}.
- */
-public class DoubleExpm1Test extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.expm1(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleFieldAccessTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleGetExponentTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#getExponent(double)}.
- */
-public class DoubleGetExponentTest extends DoubleMathLargeBase {
-
-    @Result int[] outIntArray = new int[size];
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outIntArray[gid] = Math.getExponent(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleHypotTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#hypot(double, double)}.
- */
-public class DoubleHypotTest extends DoubleTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = Math.hypot(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleIeeeRemainderTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#IEEEremainder(double, double)}.
- */
-public class DoubleIeeeRemainderTest extends DoubleTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        // for debugging
-        inArray1[0] = inArray1[258];
-        inArray2[0] = inArray2[258];
-
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = Math.IEEEremainder(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleLog10Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#log10(double)}.
- */
-public class DoubleLog10Test extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.log10(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleLogTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#log(double)}.
- */
-public class DoubleLogTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.log(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleMathBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class DoubleMathBase extends MathTestBase {
-
-    static final int size = 256;
-    @Result double[] outArray = new double[size];
-    double[] inArray = new double[size];
-
-    @Override
-    String getInputString(int idx) {
-        return Double.toString(inArray[idx]);
-    }
-
-    double largestValue() {
-        return Math.PI;
-    }
-
-    /**
-     * Initializes the input and output arrays.
-     */
-    void setupArrays() {
-        for (int i = 0; i < size / 2; i++) {
-            // Include positive and negative values as well as corner cases.
-            double val = (largestValue() / (size / 2)) * i;
-            inArray[i] = val;
-            inArray[i + size / 2] = -val;
-        }
-        // special values filled at end
-        inArray[size - 1] = Double.NaN;
-        inArray[size - 2] = Double.NEGATIVE_INFINITY;
-        inArray[size - 3] = Double.POSITIVE_INFINITY;
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleMathLargeBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class DoubleMathLargeBase extends DoubleMathBase {
-
-    @Override
-    void setupArrays() {
-        for (int i = 0; i < size / 2; i++) {
-            // Include positive and negative values as well as corner cases.
-            double val = (i == 0 ? 0 : Math.pow(1.99, i));
-            inArray[i] = val;
-            inArray[i + size / 2] = -val;
-        }
-        // special values filled at end
-        inArray[size - 1] = Double.NaN;
-        inArray[size - 2] = Double.NEGATIVE_INFINITY;
-        inArray[size - 3] = Double.POSITIVE_INFINITY;
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleNextAfterTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#nextAfter(double, double)}.
- */
-public class DoubleNextAfterTest extends DoubleMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            double direction = (gid & 1) == 0 ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
-            outArray[gid] = Math.nextAfter(inArray[gid], direction);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (runningOnSimulator() || runningCQETests());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleNextUpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#nextUp(double)}.
- */
-public class DoubleNextUpTest extends DoubleMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.nextUp(inArray[gid]);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (runningOnSimulator() || runningCQETests());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoublePowTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#pow(double, double)}.
- */
-public class DoublePowTest extends DoubleTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = Math.pow(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleRoundTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#round(double)}.
- */
-public class DoubleRoundTest extends DoubleMathLargeBase {
-
-    @Result long[] outLongArray = new long[size];
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        // for testing
-        inArray[0] = inArray[66];
-        dispatchLambdaKernel(size, (gid) -> {
-            outLongArray[gid] = Math.round(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleScalbTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#scalb(double, int)}.
- */
-public class DoubleScalbTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.scalb(inArray[gid], 64 - (gid % 128));
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSignumTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#signum(double)}.
- */
-public class DoubleSignumTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.signum(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSinTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#sin(double)}.
- */
-public class DoubleSinTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.sin(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleSinhTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#sinh(double)}.
- */
-public class DoubleSinhTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.sinh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTanTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#tan(double)}.
- */
-public class DoubleTanTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.tan(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTanhTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#tanh(double)}.
- */
-public class DoubleTanhTest extends DoubleMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.tanh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleToLongTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#round(double)}.
- */
-public class DoubleToLongTest extends DoubleMathLargeBase {
-
-    @Result long[] outLongArray = new long[size];
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        // for testing
-        // inArray[0] = inArray[66];
-        dispatchLambdaKernel(size, (gid) -> {
-            outLongArray[gid] = (long) inArray[gid];
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleTwoInputMathBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class DoubleTwoInputMathBase extends DoubleMathBase {
-
-    double[] inArray1 = new double[size * size];
-    double[] inArray2 = new double[size * size];
-    @Result double[] bigOutArray = new double[size * size];
-
-    @Override
-    String getInputString(int idx) {
-        return "(" + inArray1[idx] + ", " + inArray2[idx] + ")";
-    }
-
-    /**
-     * Initializes the input and output arrays.
-     */
-    @Override
-    void setupArrays() {
-        super.setupArrays();
-        // make combinations of the input array
-        for (int i = 0; i < size; i++) {
-            for (int j = 0; j < size; j++) {
-                int idx = i * size + j;
-                inArray1[idx] = inArray[i];
-                inArray2[idx] = inArray[j];
-                bigOutArray[idx] = 0;
-            }
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DoubleUlpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#ulp(double)}.
- */
-public class DoubleUlpTest extends DoubleMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.ulp(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/DremTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests the DREM bytecode instruction.
- */
-public class DremTest extends DoubleTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            double f1 = inArray1[gid];
-            double f2 = inArray2[gid];
-            bigOutArray[gid] = f1 % f2;
-        });
-    }
-
-    // ignoring until we implement support for DREM bytecode
-    @Ignore
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FibRecursionTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * 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;
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplyRangeFinalTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplySingleOutTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Float2DMatrixMultiplyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAcosTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#acos(double)} with float arg.
- */
-public class FloatAcosTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.acos(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAsinTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#asin(double)} with float arg.
- */
-public class FloatAsinTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.asin(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAtan2Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#atan2(double, double)}.
- */
-public class FloatAtan2Test extends FloatTwoInputMathBase {
-
-    // for atan2 ULPs can be off by 2 ulps.
-    @Override
-    protected int ulpsDelta() {
-        return 2;
-    }
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = (float) Math.atan2(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatAtanTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#atan(double)} with float arg.
- */
-public class FloatAtanTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.atan(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCbrtTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cbrt(double)} with float arg.
- */
-public class FloatCbrtTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.cbrt(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCondMoveTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCosTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cos(double)} with float arg.
- */
-public class FloatCosTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.cos(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatCoshTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#cosh(double)} with float arg.
- */
-public class FloatCoshTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.cosh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatExpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#exp(double)} with float arg.
- */
-public class FloatExpTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.exp(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatExpm1Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#expm1(double)} with float arg.
- */
-public class FloatExpm1Test extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.expm1(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatFieldAccessTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatFieldWriteTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatGetExponentTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#getExponent(double)} with float arg.
- */
-public class FloatGetExponentTest extends FloatMathLargeBase {
-
-    @Result int[] outIntArray = new int[size];
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outIntArray[gid] = Math.getExponent(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatIeeeRemainderTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#IEEEremainder(double, double)}.
- */
-public class FloatIeeeRemainderTest extends FloatTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = (float) Math.IEEEremainder(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatLog10Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#log10(double)} with float arg.
- */
-public class FloatLog10Test extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.log10(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatLogTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#log(double)} with float arg.
- */
-public class FloatLogTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.log(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatMathBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class FloatMathBase extends MathTestBase {
-
-    static final int size = 256;
-    @Result float[] outArray = new float[size];
-    float[] inArray = new float[size];
-
-    @Override
-    String getInputString(int idx) {
-        return Float.toString(inArray[idx]);
-    }
-
-    /**
-     * Initializes the input and output arrays.
-     */
-    void setupArrays() {
-        for (int i = 0; i < size / 2; i++) {
-            // Include positive and negative values as well as corner cases.
-            float val = (float) (i * Math.PI / (size / 2));
-            inArray[i] = val;
-            inArray[i + size / 2] = -val;
-            outArray[i] = 999.0f;
-            outArray[i + size / 2] = 999.0f;
-        }
-        // special values filled at end
-        inArray[size - 1] = Float.NaN;
-        inArray[size - 2] = Float.NEGATIVE_INFINITY;
-        inArray[size - 3] = Float.POSITIVE_INFINITY;
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatMathLargeBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class FloatMathLargeBase extends FloatMathBase {
-
-    @Override
-    void setupArrays() {
-        for (int i = 0; i < size / 2; i++) {
-            // Include positive and negative values as well as corner cases.
-            float val = (float) (i == 0 ? 0 : Math.pow(1.99, (i % 100)));
-            inArray[i] = val;
-            inArray[i + size / 2] = -val;
-        }
-        // special values filled at end
-        inArray[size - 1] = Float.NaN;
-        inArray[size - 2] = Float.NEGATIVE_INFINITY;
-        inArray[size - 3] = Float.POSITIVE_INFINITY;
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatNextAfterTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#nextAfter(float, double)}.
- */
-public class FloatNextAfterTest extends FloatMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            float direction = (gid & 1) == 0 ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY;
-            outArray[gid] = Math.nextAfter(inArray[gid], direction);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (runningOnSimulator() || runningCQETests());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatNextUpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#nextUp(float)} with float arg.
- */
-public class FloatNextUpTest extends FloatMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.nextUp(inArray[gid]);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (runningOnSimulator() || runningCQETests());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatPowTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#pow(double, double)}.
- */
-public class FloatPowTest extends FloatTwoInputMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size * size, (gid) -> {
-            bigOutArray[gid] = (float) Math.pow(inArray1[gid], inArray2[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatRoundTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#round(float)}.
- */
-public class FloatRoundTest extends FloatMathLargeBase {
-
-    @Result int[] outIntArray = new int[size];
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outIntArray[gid] = Math.round(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatScalbTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#scalb(float, int)}.
- */
-public class FloatScalbTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.scalb(inArray[gid], 64 - (gid % 128));
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSignumTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#signum(float)}.
- */
-public class FloatSignumTest extends FloatMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.signum(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSinTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#sin(double)} with float arg.
- */
-public class FloatSinTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.sin(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatSinhTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#sinh(double)} with float arg.
- */
-public class FloatSinhTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.sinh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTanTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#tan(double)} with float arg.
- */
-public class FloatTanTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.tan(inArray[gid]);
-        });
-    }
-
-    // internally allocates a Rempiostruct, escape analysis not catching it
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation());
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTanhTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#tanh(double)} with float arg.
- */
-public class FloatTanhTest extends FloatMathBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = (float) Math.tanh(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatTwoInputMathBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-public abstract class FloatTwoInputMathBase extends FloatMathBase {
-
-    float[] inArray1 = new float[size * size];
-    float[] inArray2 = new float[size * size];
-    @Result float[] bigOutArray = new float[size * size];
-
-    @Override
-    String getInputString(int idx) {
-        return "(" + inArray1[idx] + ", " + inArray2[idx] + ")";
-    }
-
-    /**
-     * Initializes the input and output arrays.
-     */
-    @Override
-    void setupArrays() {
-        super.setupArrays();
-        // make combinations of the input array
-        for (int i = 0; i < size; i++) {
-            for (int j = 0; j < size; j++) {
-                int idx = i * size + j;
-                inArray1[idx] = inArray[i];
-                inArray2[idx] = inArray[j];
-                bigOutArray[idx] = 0;
-            }
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/FloatUlpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-/**
- * Tests call to {@link Math#ulp(float)}.
- */
-public class FloatUlpTest extends FloatMathLargeBase {
-
-    @Override
-    public void runTest() {
-        setupArrays();
-        dispatchLambdaKernel(size, (gid) -> {
-            outArray[gid] = Math.ulp(inArray[gid]);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ForEachToGraalTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,316 +0,0 @@
-/*
- * 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.hotspot.HotSpotGraalRuntime.*;
-import static org.junit.Assert.*;
-
-import java.util.*;
-import java.util.stream.*;
-
-import org.junit.*;
-
-/**
- * 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) {
-            this.x = x;
-            this.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() {
-        if (runtime().getConfig().useHSAILDeoptimization == false) {
-            return;
-        }
-
-        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();
-    // }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/HashMapGetTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * 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.compiler.common.GraalInternalError.class)
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-
-    @Test(expected = com.oracle.graal.compiler.common.GraalInternalError.class)
-    public void testUsingLambdaMethod() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceNBodyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * 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[] inXyz = new float[bodies * 3]; // positions xy and z of bodies
-
-    @Result float[] outXyz = new float[bodies * 3]; // positions xy and z of bodies
-
-    @Result float[] inVxyz = new float[bodies * 3]; // velocity component of x,y and z of
-    // bodies
-
-    @Result float[] outVxyz = new float[bodies * 3];
-
-    static float[] seedXyz = 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);
-            seedXyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
-            seedXyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
-            seedXyz[body + 2] = (float) (radius * Math.cos(phi));
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedXyz, 0, inXyz, 0, seedXyz.length);
-        Arrays.fill(outXyz, 0f);
-        Arrays.fill(outVxyz, 0f);
-        Arrays.fill(inVxyz, 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 = inXyz[i + 0] - inXyz[globalId + 0];
-                final float dy = inXyz[i + 1] - inXyz[globalId + 1];
-                final float dz = inXyz[i + 2] - inXyz[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;
-            outXyz[globalId + 0] = inXyz[globalId + 0] + (inVxyz[globalId + 0] * delT) + (accx * .5f * delT);
-            outXyz[globalId + 1] = inXyz[globalId + 1] + (inVxyz[globalId + 1] * delT) + (accy * .5f * delT);
-            outXyz[globalId + 2] = inXyz[globalId + 2] + (inVxyz[globalId + 2] * delT) + (accz * .5f * delT);
-
-            outVxyz[globalId + 0] = inVxyz[globalId + 0] + accx;
-            outVxyz[globalId + 1] = inVxyz[globalId + 1] + accy;
-            outVxyz[globalId + 2] = inVxyz[globalId + 2] + accz;
-        });
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOfNullTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOfTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOopNBodyAccTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * 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[] inBodies, 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 < inBodies.length; b++) {
-                float dx = inBodies[b].getX() - myPosx;
-                float dy = inBodies[b].getY() - myPosy;
-                float dz = inBodies[b].getZ() - myPosz;
-                float invDist = 1.0f / (float) Math.sqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr1);
-                float s = inBodies[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[] inBodies = new Body[bodies];
-    @Result Body[] outBodies = new Body[bodies];
-
-    static Body[] seedBodies = 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));
-            seedBodies[body] = new Body(x, y, z, mass);
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedBodies, 0, inBodies, 0, seedBodies.length);
-        for (int b = 0; b < bodies; b++) {
-            outBodies[b] = new Body(0, 0, 0, mass);
-        }
-        // no local copies of arrays so we make it an instance lambda
-
-        dispatchLambdaKernel(bodies, (gid) -> {
-            Body bin = inBodies[gid];
-            Body bout = outBodies[gid];
-            Vec3 acc = bin.computeAcc(inBodies, 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/InstanceOopNBodyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * 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[] inBodies = new Body[bodies];
-
-    @Result Body[] outBodies = new Body[bodies];
-
-    static Body[] seedBodies = 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));
-            seedBodies[body] = new Body(x, y, z, mass);
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedBodies, 0, inBodies, 0, seedBodies.length);
-        for (int b = 0; b < bodies; b++) {
-            outBodies[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 = inBodies[gid];
-            Body outb = outBodies[gid];
-            float myPosx = inb.getX();
-            float myPosy = inb.getY();
-            float myPosz = inb.getZ();
-
-            for (Body b : inBodies) {
-                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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntArrayCopyConjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a int array where src and dest overlap.
- */
-public class IntArrayCopyConjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result int[][] outArray = new int[NUM][MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            for (int j = 0; j < outArray[i].length; j++) {
-                outArray[i][j] = i + j;
-            }
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(outArray[gid], 0, outArray[gid], gid % NUM, NUM);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntArrayCopyDisjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a int array where src and dest do not overlap.
- */
-public class IntArrayCopyDisjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result int[][] outArray = new int[NUM][MAXOUTSIZ];
-    int[] inArray = new int[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = i;
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntCondMoveTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntFieldAccessTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntNegateInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntSquaredInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntSquaredStaticTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntToLongTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntegerObjectCreateTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/IntegerObjectReadTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongAdderTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.compiler.common.GraalInternalError.class)
-    public void test() {
-        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
-            testGeneratedHsail();
-        }
-    }
-
-    @Test(expected = com.oracle.graal.compiler.common.GraalInternalError.class)
-    public void testUsingLambdaMethod() {
-        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
-            testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongArrayCopyConjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a long array where src and dest overlap.
- */
-public class LongArrayCopyConjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result long[][] outArray = new long[NUM][MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            for (int j = 0; j < outArray[i].length; j++) {
-                outArray[i][j] = i + j;
-            }
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(outArray[gid], 0, outArray[gid], gid % NUM, NUM);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongArrayCopyDisjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests copying a long array where src and dest do not overlap.
- */
-public class LongArrayCopyDisjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result long[][] outArray = new long[NUM][MAXOUTSIZ];
-    long[] inArray = new long[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = i;
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongCmpTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongCondMoveTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongNegateInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/LongSquaredInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Main.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MandelInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * 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 xOffset = -1f;
-        float yOffset = 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) + xOffset;
-            float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yOffset;
-
-            int count = 0;
-            float zx = lx;
-            float zy = ly;
-            float newZx = 0f;
-
-            // Iterate until the algorithm converges or until maxIterations are reached.
-                        while (count < maxIterations && zx * zx + zy * zy < 8) {
-                            newZx = zx * zx - zy * zy + lx;
-                            zy = 2 * zx * zy + ly;
-                            zx = newZx;
-                            count++;
-                        }
-
-                        rgb[gid] = palette[count];
-                    });
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MandelStaticTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * 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 xOffset = -1f;
-        float yOffset = 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) + xOffset;
-            float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + yOffset;
-
-            int count = 0;
-            float zx = lx;
-            float zy = ly;
-            float newZx = 0f;
-
-            // Iterate until the algorithm converges or until maxIterations are reached.
-                        while (count < maxIterations && zx * zx + zy * zy < 8) {
-                            newZx = zx * zx - zy * zy + lx;
-                            zy = 2 * zx * zy + ly;
-                            zx = newZx;
-                            count++;
-                        }
-
-                        rgb1[gid] = palette[count];
-                    });
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MathTestBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.oracle.graal.compiler.hsail.test.lambda;
-
-import org.junit.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-/**
- * Tests call to Math.tan(double).
- */
-public abstract class MathTestBase extends GraalKernelTester {
-
-    abstract String getInputString(int idx);
-
-    // standard ulps requirement for these tests is one ULP
-    @Override
-    protected int ulpsDelta() {
-        return 1;
-    }
-
-    // if logging of DeepEquals is set, override assertDeepEquals to just log all input and output
-    // with ulps errors if any
-    @Override
-    protected void assertDeepEquals(String message, Object expected, Object actual, int ulpsDelta) {
-        try (Scope s = Debug.scope("DeepEquals")) {
-            if (Debug.isLogEnabled()) {
-                if (expected != null && actual != null) {
-                    Class<?> expectedClass = expected.getClass();
-                    Class<?> actualClass = actual.getClass();
-                    Assert.assertEquals(message, expectedClass, actualClass);
-                    if (expectedClass.isArray()) {
-                        if (expected instanceof double[]) {
-                            double[] ae = (double[]) expected;
-                            double[] aa = (double[]) actual;
-                            for (int i = 0; i < ae.length; i++) {
-                                double de = ae[i];
-                                double da = aa[i];
-                                String ulpsStr = "";
-                                if (!Double.isNaN(de) && Double.isFinite(de)) {
-                                    double absdiff = Math.abs(de - da);
-                                    double absdiffUlps = absdiff / Math.ulp(de);
-                                    ulpsStr = ", absDiffUlps=" + absdiffUlps;
-                                }
-                                Debug.log(i + "| input=" + getInputString(i) + ", expected=" + de + ", actual=" + da + ulpsStr);
-                            }
-                            return;
-                        } else if (expected instanceof float[]) {
-                            float[] ae = (float[]) expected;
-                            float[] aa = (float[]) actual;
-                            for (int i = 0; i < ae.length; i++) {
-                                float fe = ae[i];
-                                float fa = aa[i];
-                                String ulpsStr = "";
-                                if (!Float.isNaN(fe) && Float.isFinite(fe)) {
-                                    float absdiff = Math.abs(fe - fa);
-                                    float absdiffUlps = absdiff / Math.ulp(fe);
-                                    ulpsStr = ", absDiffUlps=" + absdiffUlps;
-                                }
-                                Debug.log(i + "| input=" + getInputString(i) + ", expected=" + fe + ", actual=" + fa + ulpsStr);
-                            }
-                            return;
-                        }
-                    }
-                }
-            }
-        }
-        super.assertDeepEquals(message, expected, actual, ulpsDelta);
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MoreThanEightArgsOOBTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-
-import org.junit.*;
-
-public class MoreThanEightArgsOOBTest extends GraalKernelTester {
-
-    int[] makeIntArray(int size) {
-        int[] out = new int[size];
-
-        for (int i = 0; i < size; i++) {
-            out[i] = 1;
-        }
-        return out;
-    }
-
-    final int rows = 4096;
-    final int cols = 4096;
-    final int loops = 1;
-
-    @Result int[] result;
-
-    void innerTest(int[] res, int[] a, int[] b, int[] c, int[] d, int base, int stride) {
-        final int resCols = a.length;
-        final int resRows = res.length;
-        final int limit = resCols - stride;
-
-        dispatchLambdaKernel(resRows, (row) -> {
-            res[row] = 0;
-            if (a != null) {
-                for (int col = base; col < limit; col += 4) {
-                    int p0 = 0;
-                    int p1 = 0;
-                    int p2 = 0;
-                    int p3 = 0;
-                    p0 = a[col] + b[col] + c[col] + d[col] + stride;
-                    p1 = a[col + 1] + b[col + 1] + c[col + 1] + d[col + 1];
-                    p2 = a[col + 2] + b[col + 2] + c[col + 2] + d[col + 2];
-                    p3 = a[col + 3] + b[col + 3] + c[col + 3] + d[col + 5000];
-                    res[row] += p0 + p1 + p2 + p3;
-                }
-            }
-        });
-    }
-
-    @Override
-    public void runTest() {
-        int[] a;
-        int[] b;
-        int[] c;
-        int[] d;
-
-        result = makeIntArray(rows);
-        a = makeIntArray(cols);
-        b = makeIntArray(cols);
-        c = makeIntArray(cols);
-        d = makeIntArray(cols);
-        for (int i = 0; i < loops; i++) {
-            innerTest(result, a, b, c, d, 0, 4);
-        }
-    }
-
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/MoreThanEightArgsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester;
-
-import org.junit.*;
-
-public class MoreThanEightArgsTest extends GraalKernelTester {
-
-    int[] makeIntArray(int size) {
-        int[] out = new int[size];
-
-        for (int i = 0; i < size; i++) {
-            out[i] = 1;
-        }
-        return out;
-    }
-
-    final int rows = 4096;
-    final int cols = 4096;
-    final int loops = 2;
-
-    @Result int[] result;
-
-    void innerTest(int[] res, int[] a, int[] b, int[] c, int[] d, int base, int stride) {
-        final int resCols = a.length;
-        final int resRows = res.length;
-        final int limit = resCols - stride;
-
-        dispatchLambdaKernel(resRows, (row) -> {
-            res[row] = 0;
-            if (a != null) {
-                for (int col = base; col < limit; col += 4) {
-                    int p0 = 0;
-                    int p1 = 0;
-                    int p2 = 0;
-                    int p3 = 0;
-                    p0 = a[col] + b[col] + c[col] + d[col] + stride;
-                    p1 = a[col + 1] + b[col + 1] + c[col + 1] + d[col + 1];
-                    p2 = a[col + 2] + b[col + 2] + c[col + 2] + d[col + 2];
-                    p3 = a[col + 3] + b[col + 3] + c[col + 3] + d[col + 3];
-                    res[row] += p0 + p1 + p2 + p3;
-                }
-            }
-        });
-    }
-
-    @Override
-    public void runTest() {
-        int[] a;
-        int[] b;
-        int[] c;
-        int[] d;
-
-        result = makeIntArray(rows);
-        a = makeIntArray(cols);
-        b = makeIntArray(cols);
-        c = makeIntArray(cols);
-        d = makeIntArray(cols);
-        for (int i = 0; i < loops; i++) {
-            innerTest(result, a, b, c, d, 0, 4);
-        }
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NewStringEqualsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * 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 org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-import com.oracle.graal.debug.*;
-
-/**
- * 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";
-
-        // Resolving StringIndexOutOfBoundsException causes compilation of the
-        // lambda to fail as. Combined with use of InlineEverything and RemoveNeverExecutedCode
-        // the inlining budget is blown before String.equals can be inlined leaving
-        // a DirectCallTargetNode in the graph which cannot be lowered by HSAIL.
-        new StringIndexOutOfBoundsException().fillInStackTrace();
-
-        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());
-    }
-
-    @Ignore("see comment in runTest")
-    @Test
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-
-    @Ignore("see comment in runTest")
-    @Test
-    public void testUsingLambdaMethod() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NewStringLenTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewObjWithArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * 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 java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-import com.oracle.graal.debug.*;
-
-/**
- * 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
-    @Ignore
-    @Test
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-
-    @Ignore
-    @Test
-    public void testUsingLambdaMethod() {
-        try (DebugConfigScope dcs = setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) {
-            testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/NonEscapingNewTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyConjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests {@link System#arraycopy} for object arrays where dest and src type are same, and overlap.
- */
-public class ObjArrayCopyConjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result String[][] outArray = new String[NUM][MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            for (int j = 0; j < outArray[i].length; j++) {
-                outArray[i][j] = Integer.toString(i * 100 + j);
-            }
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(outArray[gid], 0, outArray[gid], gid % NUM, NUM);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyDisjointNonExactTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests {@link System#arraycopy} for object arrays where dest is a superclass of src.
- */
-public class ObjArrayCopyDisjointNonExactTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result Object[][] outArray = new Object[NUM][MAXOUTSIZ];
-    String[] inArray = new String[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = Integer.toString(i * 1111);
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    // this fails because we do not have a pure java snippet for this case
-    // see ArrayCopySnippets.arrayCopy(Object, int, Object, int, int)
-    @Test(expected = com.oracle.graal.compiler.common.GraalInternalError.class)
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjArrayCopyDisjointTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests {@link System#arraycopy} for object arrays where dest and src type are same, no overlap.
- */
-public class ObjArrayCopyDisjointTest extends GraalKernelTester {
-
-    static final int MAXOUTSIZ = 100;
-    static final int NUM = 20;
-
-    @Result String[][] outArray = new String[NUM][MAXOUTSIZ];
-    String[] inArray = new String[NUM + MAXOUTSIZ];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < inArray.length; i++) {
-            inArray[i] = Integer.toString(i * 1111);
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            System.arraycopy(inArray, gid, outArray[gid], 0, MAXOUTSIZ);
-        });
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectArrayInstanceDerivedTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * 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 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();
-        });
-    }
-
-    @Ignore
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Ignore
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectArrayInstanceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * 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.*;
-
-/**
- * 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();
-        });
-    }
-
-    @Ignore
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Ignore
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectStoreNullTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ObjectStoreTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/OverloadMethodTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceMaxTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * 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.lambda;
-
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-
-import java.util.*;
-import java.util.stream.*;
-
-import org.junit.*;
-
-import com.amd.okra.*;
-import com.oracle.graal.hotspot.*;
-
-public class ReduceMaxTest {
-    // The length of the input array
-    static int jobSize = 1027 * 1023 * 13;
-    static int loops = 1;
-
-    // The source array
-    int[] bigArray = null;
-
-    // result for baseline single threaded stream
-    int resultStream = 0;
-    // result for parallel CPU and offloaded streams
-    int resultOffload = 0;
-
-    int evaluate(boolean doParallelStream) {
-        int result = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                OptionalInt resultParallel = s.parallel().reduce(Integer::max);
-                result = resultParallel.getAsInt();
-            } else {
-                result = s.reduce(Integer::max).getAsInt();
-            }
-        }
-        return result;
-    }
-
-    int evaluateWithIdentity(boolean doParallelStream) {
-        int result = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                result = s.parallel().reduce(0, Integer::max);
-            } else {
-                result = s.reduce(0, Integer::max);
-            }
-        }
-        return result;
-    }
-
-    @Test
-    public void testReduce() {
-
-        // The simulator does not support HSA local memory as of June 2014
-        assumeTrue("The simulator does not support HSA local memory, skipping!", OkraUtil.okraLibExists() && OkraContext.isSimulator() == false);
-
-        // Handmade reduce does not support +UseCompressedOops
-        HotSpotVMConfig config = runtime().getConfig();
-        if (config.useCompressedOops == true || config.useHSAILDeoptimization == true) {
-            return;
-        }
-
-        bigArray = new int[jobSize];
-        for (int i = 0; i < jobSize; i++) {
-            // bigArray[i] = i + 1;
-            bigArray[i] = -1024 + i + 1;
-        }
-
-        // Get non parallel baseline
-        resultStream = evaluate(false);
-
-        // Get OptionalInt version kernel
-        resultOffload = evaluate(true);
-        assertTrue(resultStream == resultOffload);
-
-        // Do identity version kernel
-        // Get non parallel baseline
-        resultStream = evaluateWithIdentity(false);
-
-        resultOffload = evaluateWithIdentity(true);
-        assertTrue(resultStream == resultOffload);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceMinTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * 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.lambda;
-
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-
-import java.util.*;
-import java.util.stream.*;
-
-import org.junit.*;
-
-import com.amd.okra.*;
-import com.oracle.graal.hotspot.*;
-
-public class ReduceMinTest {
-    // The length of the input array
-    static int jobSize = 1027 * 1023 * 13;
-    static int loops = 1;
-
-    // The input array to the kernel
-    int[] bigArray = null;
-
-    // result for baseline single threaded stream
-    int resultStream = 0;
-    // result for parallel CPU and offloaded streams
-    int resultOffload = 0;
-
-    int evaluate(boolean doParallelStream) {
-        int result = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                OptionalInt resultParallel = s.parallel().reduce(Integer::min);
-                result = resultParallel.getAsInt();
-            } else {
-                result = s.reduce(Integer::min).getAsInt();
-            }
-        }
-        return result;
-    }
-
-    int evaluateWithIdentity(boolean doParallelStream) {
-        int result = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                result = s.parallel().reduce(0, Integer::min);
-            } else {
-                result = s.reduce(0, Integer::min);
-            }
-        }
-        return result;
-    }
-
-    @Test
-    public void testReduce() {
-
-        // The simulator does not support HSA local memory as of June 2014
-        assumeTrue("The simulator does not support HSA local memory, skipping!", OkraUtil.okraLibExists() && OkraContext.isSimulator() == false);
-
-        // Handmade reduce does not support +UseCompressedOops
-        HotSpotVMConfig config = runtime().getConfig();
-        if (config.useCompressedOops == true || config.useHSAILDeoptimization == true) {
-            return;
-        }
-
-        bigArray = new int[jobSize];
-        for (int i = 0; i < jobSize; i++) {
-            bigArray[i] = -1024 + i + 1;
-        }
-
-        // Get non parallel baseline
-        resultStream = evaluate(false);
-
-        // Get OptionalInt version kernel
-        resultOffload = evaluate(true);
-        assertTrue(resultStream == resultOffload);
-
-        // Do identity version kernel
-        // Get non parallel baseline
-        resultStream = evaluateWithIdentity(false);
-
-        resultOffload = evaluateWithIdentity(true);
-        assertTrue(resultStream == resultOffload);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ReduceSumTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * 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.lambda;
-
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-import static org.junit.Assert.*;
-import static org.junit.Assume.*;
-
-import java.util.*;
-import java.util.stream.*;
-
-import org.junit.*;
-
-import com.amd.okra.*;
-import com.oracle.graal.hotspot.*;
-
-public class ReduceSumTest {
-    // The length of the input array
-    static int jobSize = 1027 * 1023 * 13;
-    static int loops = 1;
-
-    // The array to be summed
-    int[] bigArray = null;
-
-    // sum for baseline single threaded stream
-    int sumStream = 0;
-    // sum for parallel CPU and offloaded streams
-    int sumOffload = 0;
-
-    int evaluate(boolean doParallelStream) {
-        int sum = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                OptionalInt resultParallel = s.parallel().reduce(Integer::sum);
-                sum = resultParallel.getAsInt();
-            } else {
-                OptionalInt resultStream = s.reduce(Integer::sum);
-                sum = resultStream.getAsInt();
-            }
-        }
-        return sum;
-    }
-
-    int evaluateWithIdentity(boolean doParallelStream) {
-        int sum = 0;
-        for (int i = 0; i < loops; i++) {
-            IntStream s = Arrays.stream(bigArray);
-            if (doParallelStream == true) {
-                sum = s.parallel().reduce(0, Integer::sum);
-            } else {
-                sum = s.reduce(0, Integer::sum);
-            }
-        }
-        return sum;
-    }
-
-    @Test
-    public void testReduce() {
-
-        // The simulator does not support HSA local memory as of June 2014
-        assumeTrue("The simulator does not support HSA local memory, skipping!", OkraUtil.okraLibExists() && OkraContext.isSimulator() == false);
-
-        // Handmade reduce does not support +UseCompressedOops
-        HotSpotVMConfig config = runtime().getConfig();
-        if (config.useCompressedOops == true || config.useHSAILDeoptimization == true) {
-            return;
-        }
-
-        bigArray = new int[jobSize];
-        for (int i = 0; i < jobSize; i++) {
-            bigArray[i] = -1024 + i + 1;
-        }
-
-        // Get non parallel baseline
-        sumStream = evaluate(false);
-
-        // Get OptionalInt version kernel
-        sumOffload = evaluate(true);
-        assertTrue(sumStream == sumOffload);
-
-        // Get identity version kernel
-        sumOffload = evaluateWithIdentity(true);
-        assertTrue(sumStream == sumOffload);
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ShortArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticFloatFieldReadTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntField2ReadTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldReadTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldSameClassTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticIntFieldWriteTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StaticNBodyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * 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[] inXyz = new float[bodies * 3]; // positions xy and z of bodies
-
-    @Result float[] outXyz = new float[bodies * 3]; // positions xy and z of bodies
-
-    @Result float[] inVxyz = new float[bodies * 3]; // velocity component of x,y and z of
-    // bodies
-
-    @Result float[] outVxyz = new float[bodies * 3];
-
-    static float[] seedXyz = 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);
-            seedXyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)) + width / 2;
-            seedXyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)) + height / 2;
-            seedXyz[body + 2] = (float) (radius * Math.cos(phi));
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedXyz, 0, inXyz, 0, seedXyz.length);
-        Arrays.fill(outXyz, 0f);
-        Arrays.fill(outVxyz, 0f);
-        Arrays.fill(inVxyz, 0f);
-
-        // local copies for a static lambda
-        float[] inXyz1 = this.inXyz;
-        float[] outXyz1 = this.outXyz;
-        float[] inVxyz1 = this.inVxyz;
-        float[] outVxyz1 = this.outVxyz;
-
-        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 = inXyz1[i + 0] - inXyz1[globalId + 0];
-                final float dy = inXyz1[i + 1] - inXyz1[globalId + 1];
-                final float dz = inXyz1[i + 2] - inXyz1[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;
-            outXyz1[globalId + 0] = inXyz1[globalId + 0] + (inVxyz1[globalId + 0] * delT) + (accx * .5f * delT);
-            outXyz1[globalId + 1] = inXyz1[globalId + 1] + (inVxyz1[globalId + 1] * delT) + (accy * .5f * delT);
-            outXyz1[globalId + 2] = inXyz1[globalId + 2] + (inVxyz1[globalId + 2] * delT) + (accz * .5f * delT);
-
-            outVxyz1[globalId + 0] = inVxyz1[globalId + 0] + accx;
-            outVxyz1[globalId + 1] = inVxyz1[globalId + 1] + accy;
-            outVxyz1[globalId + 2] = inVxyz1[globalId + 2] + accz;
-        });
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringBuilderTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests creating a new String using StringBuilder (relies on {@link System#arraycopy}).
- */
-public class StringBuilderTest extends GraalKernelTester {
-
-    static final int NUM = 20;
-    StringBuilder[] builders = new StringBuilder[NUM];
-    @Result String[] resultString = new String[NUM];
-
-    @Override
-    public void runTest() {
-        for (int i = 0; i < NUM; i++) {
-            builders[i] = new StringBuilder().append(i).append("abc");
-        }
-        dispatchLambdaKernel(NUM, (gid) -> {
-            resultString[gid] = builders[gid].append(gid * 1234).toString();
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleObjectAllocation() && (runningOnSimulator() || runningCQETests()));
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringContainsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringEqualsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringHashTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringLenTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringSubsequenceTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests creating a new {@link CharSequence} using {@link String#subSequence(int, int)}.
- */
-public class StringSubsequenceTest extends GraalKernelTester {
-
-    static final int NUM = 50;
-    String inputString;
-    @Result CharSequence[] resultSequence = new String[NUM];
-
-    @Override
-    public void runTest() {
-        StringBuilder builder = new StringBuilder();
-        for (int i = 0; i < NUM + 10; i++) {
-            builder.append(i);
-        }
-        inputString = builder.toString();
-        dispatchLambdaKernel(NUM, (gid) -> {
-            resultSequence[gid] = inputString.subSequence(gid, gid + 10);
-        });
-
-        // for (int i = 0; i < NUM; i++) {
-        // System.out.println(resultSequence[i]);
-        // }
-    }
-
-    @Ignore("emitDirectCall unimplemented")
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringSubstringTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * 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.lambda;
-
-import com.oracle.graal.compiler.hsail.test.infra.*;
-
-import org.junit.*;
-
-/**
- * Tests creating a new String using {@link String#substring(int, int)}.
- */
-public class StringSubstringTest extends GraalKernelTester {
-
-    static final int NUM = 50;
-    String inputString;
-    @Result String[] resultString = new String[NUM];
-
-    @Override
-    public void runTest() {
-        StringBuilder builder = new StringBuilder();
-        for (int i = 0; i < NUM + 10; i++) {
-            builder.append(i);
-        }
-        inputString = builder.toString();
-        dispatchLambdaKernel(NUM, (gid) -> {
-            resultString[gid] = inputString.substring(gid, gid + 10);
-        });
-    }
-
-    @Ignore("emitDirectCall unimplemented")
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringUtilsCountMatches2Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/StringUtilsCountMatchesTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/SynchronizedMethodTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * 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.compiler.common.GraalInternalError.class)
-    public void test() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsail();
-        }
-    }
-
-    // cannot handle the BeginLockScope node
-    @Test(expected = com.oracle.graal.compiler.common.GraalInternalError.class)
-    public void testUsingLambdaMethod() {
-        try (DebugConfigScope s = disableIntercept()) {
-            testGeneratedHsailUsingLambdaMethod();
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/TooSimpleNewTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/TwoDIntArrayTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VarArgsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamFloatCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamIntCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamIntFloatCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamObjCaptureTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamObjFieldTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/Vec3ObjStreamTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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();
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyDeoptTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * 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 VecmathNBodyDeoptTest 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);
-            this.m = m;
-            this.v = new Vector3f(0, 0, 0);
-        }
-
-        float m;
-        Vector3f v;
-
-        public float getM() {
-            return m;
-        }
-
-        public Vector3f computeAcc(Body[] inBodies, float espSqr1, float delT1) {
-            Vector3f acc = new Vector3f();
-
-            for (Body b : inBodies) {
-                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[] inBodies = new Body[bodies];
-    @Result Body[] outBodies = new Body[bodies];
-
-    static Body[] seedBodies = 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));
-            seedBodies[body] = new Body(x, y, z, mass);
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedBodies, 0, inBodies, 0, seedBodies.length);
-        for (int b = 0; b < bodies; b++) {
-            outBodies[b] = new Body(0, 0, 0, mass);
-        }
-        // no local copies of arrays so we make it an instance lambda
-
-        dispatchLambdaKernel(bodies, (gid) -> {
-            Body inb = inBodies[gid];
-            Body outb = outBodies[gid];
-            Vector3f acc = inb.computeAcc(inBodies, espSqr, delT);
-
-            Vector3f tmpPos = new Vector3f();
-            tmpPos.scaleAdd(delT, inb.v, inb);
-            if (gid == bodies / 2) {
-                tmpPos.x += forceDeopt(gid);
-            }
-            tmpPos.scaleAdd(0.5f * delT, acc, tmpPos);
-            outb.set(tmpPos);
-
-            outb.v.add(inb.v, acc);
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return (canHandleDeoptVirtualObjects() && canDeoptimize());
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * 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);
-            this.m = m;
-            this.v = new Vector3f(0, 0, 0);
-        }
-
-        float m;
-        Vector3f v;
-
-        public float getM() {
-            return m;
-        }
-
-        public Vector3f computeAcc(Body[] inBodies, float espSqr1, float delT1) {
-            Vector3f acc = new Vector3f();
-
-            for (Body b : inBodies) {
-                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[] inBodies = new Body[bodies];
-    @Result Body[] outBodies = new Body[bodies];
-
-    static Body[] seedBodies = 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));
-            seedBodies[body] = new Body(x, y, z, mass);
-        }
-    }
-
-    @Override
-    public void runTest() {
-        System.arraycopy(seedBodies, 0, inBodies, 0, seedBodies.length);
-        for (int b = 0; b < bodies; b++) {
-            outBodies[b] = new Body(0, 0, 0, mass);
-        }
-        // no local copies of arrays so we make it an instance lambda
-
-        dispatchLambdaKernel(bodies, (gid) -> {
-            Body inb = inBodies[gid];
-            Body outb = outBodies[gid];
-            Vector3f acc = inb.computeAcc(inBodies, 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();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VectorStreamTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * 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) {
-            this.x = x;
-            this.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);
-        }
-
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCall3Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * 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 a true virtual method call with 3 targets.
- */
-public class VirtualCall3Test extends VirtualCallBase {
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-            inShapeArray[i] = createShape(i % 3, i + 1);
-        }
-    }
-
-    // although runTest is the same in each class derived from VirtualCallBase
-    // we duplicate the logic in each derived test so as to have different lambda call sites
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchLambdaKernel(NUM, (gid) -> {
-            Shape shape = inShapeArray[gid];
-            outArray[gid] = shape.getArea();
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return typeProfileWidthAtLeast(3);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCall4Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * 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 a true virtual method call with 4 targets.
- */
-public class VirtualCall4Test extends VirtualCallBase {
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-            inShapeArray[i] = createShape(i % 4, i + 1);
-        }
-    }
-
-    // although runTest is the same in each class derived from VirtualCallBase
-    // we duplicate the logic in each derived test so as to have different lambda call sites
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchLambdaKernel(NUM, (gid) -> {
-            Shape shape = inShapeArray[gid];
-            outArray[gid] = shape.getArea();
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return typeProfileWidthAtLeast(4);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCallBase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * 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 testing virtual method calls.
- */
-public abstract class VirtualCallBase extends GraalKernelTester {
-
-    static final int NUM = 20000;
-
-    @Result public float[] outArray = new float[NUM];
-    public Shape[] inShapeArray = new Shape[NUM];
-
-    abstract static class Shape {
-
-        public abstract 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) {
-            this.len = len;
-        }
-
-        @Override
-        public float getArea() {
-            return len * len;
-        }
-    }
-
-    static class Triangle extends Shape {
-
-        private float base;
-        private float height;
-
-        Triangle(float base, float height) {
-            this.base = base;
-            this.height = height;
-        }
-
-        @Override
-        public float getArea() {
-            return (base * height / 2.0f);
-        }
-    }
-
-    static class Rectangle extends Shape {
-
-        private float base;
-        private float height;
-
-        Rectangle(float base, float height) {
-            this.base = base;
-            this.height = height;
-        }
-
-        @Override
-        public float getArea() {
-            return (base * height);
-        }
-    }
-
-    Shape createShape(int kind, int size) {
-        switch (kind) {
-            case 0:
-                return new Circle(size);
-            case 1:
-                return new Square(size);
-            case 2:
-                return new Triangle(size, size + 1);
-            case 3:
-                return new Rectangle(size, size + 1);
-            default:
-                return null;
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VirtualCallTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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 a true virtual method call with 2 targets.
- */
-public class VirtualCallTest extends VirtualCallBase {
-
-    void setupArrays() {
-        for (int i = 0; i < NUM; i++) {
-            outArray[i] = -i;
-            int kind = i % 3 == 0 ? 0 : 1;
-            inShapeArray[i] = createShape(kind, i + 1);
-        }
-    }
-
-    // although runTest is the same in each class derived from VirtualCallBase
-    // we duplicate the logic in each derived test so as to have different lambda call sites
-    @Override
-    public void runTest() {
-        setupArrays();
-
-        dispatchLambdaKernel(NUM, (gid) -> {
-            Shape shape = inShapeArray[gid];
-            outArray[gid] = shape.getArea();
-        });
-    }
-
-    @Override
-    protected boolean supportsRequiredCapabilities() {
-        return typeProfileWidthAtLeast(2);
-    }
-
-    @Test
-    public void test() {
-        testGeneratedHsail();
-    }
-
-    @Test
-    public void testUsingLambdaMethod() {
-        testGeneratedHsailUsingLambdaMethod();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/CompileAndDispatch.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2009, 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.compiler.hsail;
-
-/**
- * Interface for compiling a Java program to HSAIL and dispatching execution to the GPU or an HSAIL
- * simulator.
- */
-public interface CompileAndDispatch {
-
-    Object createKernel(Class<?> consumerClass);
-
-    boolean dispatchKernel(Object kernel, int jobSize, Object[] args);
-
-    Object createKernelFromHsailString(String code, String methodName);
-
-    String getIntegerReduceIntrinsic(String reducerName);
-
-    Integer offloadIntReduceImpl(Object kernel, int identity, int[] streamSource);
-
-    String getIntReduceTargetName(Class<?> opClass);
-}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,874 +0,0 @@
-/*
- * 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.compiler.hsail;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.lir.hsail.HSAILArithmetic.*;
-import static com.oracle.graal.lir.hsail.HSAILBitManipulationOp.IntrinsicOpcode.*;
-import static com.oracle.graal.lir.hsail.HSAILCompare.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.compiler.common.spi.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.JumpOp;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.lir.hsail.HSAILArithmetic.ConvertOp;
-import com.oracle.graal.lir.hsail.HSAILArithmetic.Op1Reg;
-import com.oracle.graal.lir.hsail.HSAILArithmetic.Op2Reg;
-import com.oracle.graal.lir.hsail.HSAILArithmetic.ShiftOp;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.CompareBranchOp;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.FloatCondMoveOp;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.ReturnOp;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.StrategySwitchOp;
-import com.oracle.graal.lir.hsail.HSAILMove.LeaOp;
-import com.oracle.graal.lir.hsail.HSAILMove.MembarOp;
-import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp;
-import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp;
-import com.oracle.graal.phases.util.*;
-
-/**
- * This class implements the HSAIL specific portion of the LIR generator.
- */
-public abstract class HSAILLIRGenerator extends LIRGenerator {
-
-    public class HSAILSpillMoveFactory implements LIR.SpillMoveFactory {
-
-        @Override
-        public LIRInstruction createMove(AllocatableValue dst, Value src) {
-            return HSAILLIRGenerator.this.createMove(dst, src);
-        }
-    }
-
-    public HSAILLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) {
-        super(lirKindTool, providers, cc, lirGenRes);
-        lirGenRes.getLIR().setSpillMoveFactory(new HSAILSpillMoveFactory());
-    }
-
-    @Override
-    public boolean canInlineConstant(JavaConstant c) {
-        switch (c.getKind()) {
-            case Long:
-                return NumUtil.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c);
-            case Object:
-                return c.isNull();
-            default:
-                return true;
-        }
-    }
-
-    protected HSAILLIRInstruction createMove(AllocatableValue dst, Value src) {
-        if (src instanceof HSAILAddressValue) {
-            return new LeaOp(dst, (HSAILAddressValue) src);
-        } else if (isRegister(src) || isStackSlotValue(dst)) {
-            return new MoveFromRegOp(dst.getKind(), dst, src);
-        } else {
-            return new MoveToRegOp(dst.getKind(), dst, src);
-        }
-    }
-
-    @Override
-    public void emitMove(AllocatableValue dst, Value src) {
-        append(createMove(dst, src));
-    }
-
-    public void emitData(AllocatableValue dst, byte[] data) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public HSAILAddressValue asAddressValue(Value address) {
-        if (address instanceof HSAILAddressValue) {
-            return (HSAILAddressValue) address;
-        } else {
-            return emitAddress(address, 0, Value.ILLEGAL, 0);
-        }
-    }
-
-    public HSAILAddressValue emitAddress(Value base, long displacement, Value index, int scale) {
-        AllocatableValue baseRegister;
-        long finalDisp = displacement;
-
-        if (isConstant(base)) {
-            if (asConstant(base).isNull()) {
-                baseRegister = Value.ILLEGAL;
-            } else if (asConstant(base).getKind() != Kind.Object) {
-                finalDisp += asConstant(base).asLong();
-                baseRegister = Value.ILLEGAL;
-            } else {
-                baseRegister = load(base);
-            }
-        } else if (base.equals(Value.ILLEGAL)) {
-            baseRegister = Value.ILLEGAL;
-        } else {
-            baseRegister = asAllocatable(base);
-        }
-        if (!index.equals(Value.ILLEGAL)) {
-            if (isConstant(index)) {
-                finalDisp += asConstant(index).asLong() * scale;
-            } else {
-                Value indexRegister;
-                Value convertedIndex = index.getKind() == Kind.Long ? index : this.emitSignExtend(index, 32, 64);
-                if (scale != 1) {
-                    indexRegister = emitUMul(convertedIndex, JavaConstant.forInt(scale));
-                } else {
-                    indexRegister = convertedIndex;
-                }
-                if (baseRegister.equals(Value.ILLEGAL)) {
-                    baseRegister = asAllocatable(indexRegister);
-                } else {
-                    baseRegister = emitAdd(baseRegister, indexRegister, false);
-                }
-            }
-        }
-
-        LIRKind resultKind = getAddressKind(base, displacement, index);
-        return new HSAILAddressValue(resultKind, baseRegister, finalDisp);
-    }
-
-    @Override
-    public Variable emitAddress(StackSlotValue address) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void emitJump(LabelRef label) {
-        append(new JumpOp(label));
-    }
-
-    public static HSAILCompare mapKindToCompareOp(Kind kind) {
-        switch (kind) {
-            case Int:
-                return ICMP;
-            case Long:
-                return LCMP;
-            case Float:
-                return FCMP;
-            case Double:
-                return DCMP;
-            case Object:
-                return ACMP;
-            default:
-                throw GraalInternalError.shouldNotReachHere("" + kind);
-        }
-    }
-
-    @Override
-    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.getLIRKind());
-        Kind kind = left.getKind().getStackKind();
-        switch (kind) {
-            case Int:
-            case Long:
-            case Object:
-                append(new CompareBranchOp(mapKindToCompareOp(kind), finalCondition, left, right, result, result, trueDestination, falseDestination, false));
-                break;
-            case Float:
-            case Double:
-                append(new CompareBranchOp(mapKindToCompareOp(kind), finalCondition, left, right, result, result, trueDestination, falseDestination, unorderedIsTrue));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("" + left.getKind());
-        }
-    }
-
-    @Override
-    public void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, LIRKind cmpLIRKind, double overflowProbability) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
-        Variable result = emitAnd(left, right);
-        Variable dummyResult = newVariable(left.getLIRKind());
-        append(new CompareBranchOp(mapKindToCompareOp(result.getKind()), Condition.EQ, result, JavaConstant.forInt(0), dummyResult, dummyResult, trueDestination, falseDestination, false));
-    }
-
-    @Override
-    public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
-        Variable result = emitAnd(left, right);
-        append(new CondMoveOp(mapKindToCompareOp(result.getKind()), result, JavaConstant.forInt(0), result, Condition.EQ, load(trueValue), load(falseValue)));
-        return result;
-    }
-
-    @Override
-    public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) {
-        Condition finalCondition = cond;
-        Variable result = newVariable(trueValue.getLIRKind());
-        Kind kind = left.getKind().getStackKind();
-        switch (kind) {
-            case Int:
-            case Long:
-            case Object:
-                append(new CondMoveOp(mapKindToCompareOp(kind), load(left), load(right), result, finalCondition, load(trueValue), load(falseValue)));
-                break;
-            case Float:
-            case Double:
-                append(new FloatCondMoveOp(mapKindToCompareOp(kind), load(left), load(right), result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + left.getKind());
-        }
-        return result;
-    }
-
-    /**
-     * Generates the LIR instruction for a negation operation.
-     *
-     * @param input the value that is being negated
-     * @return Variable that represents the result of the negation
-     */
-    @Override
-    public Variable emitNegate(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        switch (input.getKind()) {
-            case Int:
-                // Note: The Int case also handles the negation of shorts, bytes, and chars because
-                // Java treats these types as ints at the bytecode level.
-                append(new Op1Reg(INEG, result, input));
-                break;
-            case Long:
-                append(new Op1Reg(LNEG, result, input));
-                break;
-            case Double:
-                append(new Op1Reg(DNEG, result, input));
-                break;
-            case Float:
-                append(new Op1Reg(FNEG, result, input));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-
-    }
-
-    /**
-     * Generates the LIR instruction for a bitwise NOT operation.
-     *
-     * @param input the source operand
-     * @return Variable that represents the result of the operation
-     */
-    @Override
-    public Variable emitNot(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        switch (input.getKind()) {
-            case Int:
-                // Note: The Int case also covers other primitive integral types smaller than an int
-                // (char, byte, short) because Java treats these types as ints.
-                append(new Op1Reg(INOT, result, input));
-                break;
-            case Long:
-                append(new Op1Reg(LNOT, result, input));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-
-    }
-
-    public Variable emitTestAddressAdd(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IADD, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LADD, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FADD, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DADD, result, a, loadNonConst(b)));
-                break;
-            case Object:
-                throw GraalInternalError.shouldNotReachHere();
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-
-        return result;
-    }
-
-    @Override
-    public Variable emitAdd(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IADD, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LADD, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FADD, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DADD, result, a, loadNonConst(b)));
-                break;
-            case Object:
-                append(new Op2Reg(OADD, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitSub(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(ISUB, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FSUB, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LSUB, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DSUB, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitMul(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IMUL, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LMUL, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FMUL, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DMUL, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    public Variable emitUMul(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(LUMUL, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LUMUL, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitMulHigh(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitUMulHigh(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitDiv(Value a, Value b, LIRFrameState state) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IDIV, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LDIV, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FDIV, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DDIV, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-
-    }
-
-    @Override
-    public Value emitRem(Value a, Value b, LIRFrameState state) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IREM, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LREM, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Reg(FREM, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Reg(DREM, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitUDiv(Value a, Value b, LIRFrameState state) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Variable emitURem(Value a, Value b, LIRFrameState state) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Variable emitAnd(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IAND, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LAND, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitOr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IOR, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LOR, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitXor(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IXOR, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LXOR, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    /**
-     * Generates the LIR instruction for a shift left operation.
-     *
-     * @param a The value that is being shifted
-     * @param b The shift amount
-     * @return Variable that represents the result of the operation
-     */
-    @Override
-    public Variable emitShl(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                // Note: The Int case also covers the shifting of bytes, shorts and chars because
-                // Java treats these types as ints at the bytecode level.
-                append(new ShiftOp(ISHL, result, a, b));
-                break;
-            case Long:
-                append(new ShiftOp(LSHL, result, a, b));
-                break;
-            default:
-                GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    /**
-     * Generates the LIR instruction for a shift right operation.
-     *
-     * @param a The value that is being shifted
-     * @param b The shift amount
-     * @return Variable that represents the result of the operation
-     */
-    @Override
-    public Variable emitShr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                // Note: The Int case also covers the shifting of bytes, shorts and chars because
-                // Java treats these types as ints at the bytecode level.
-                append(new ShiftOp(ISHR, result, a, b));
-                break;
-            case Long:
-                append(new ShiftOp(LSHR, result, a, b));
-                break;
-            default:
-                GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    /**
-     * Generates the LIR instruction for an unsigned shift right operation.
-     *
-     * @param a The value that is being shifted
-     * @param b The shift amount
-     * @return Variable that represents the result of the operation
-     */
-    @Override
-    public Variable emitUShr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                append(new ShiftOp(IUSHR, result, a, b));
-                break;
-            case Long:
-                append(new ShiftOp(LUSHR, result, a, b));
-                break;
-            default:
-                GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitFloatConvert(FloatConvert op, Value inputVal) {
-        Variable input = load(inputVal);
-
-        String from;
-        switch (op) {
-            case D2F:
-            case D2I:
-            case D2L:
-                from = "f64";
-                break;
-            case F2D:
-            case F2I:
-            case F2L:
-                from = "f32";
-                break;
-            case I2D:
-            case I2F:
-                from = "s32";
-                break;
-            case L2D:
-            case L2F:
-                from = "s64";
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-
-        Variable result;
-        String to;
-        switch (op) {
-            case D2I:
-            case F2I:
-                to = "s32";
-                result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int));
-                break;
-            case D2L:
-            case F2L:
-                to = "s64";
-                result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
-                break;
-            case F2D:
-            case I2D:
-            case L2D:
-                to = "f64";
-                result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Double));
-                break;
-            case D2F:
-            case I2F:
-            case L2F:
-                to = "f32";
-                result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Float));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-
-        append(new ConvertOp(result, input, to, from));
-        return result;
-    }
-
-    @Override
-    public Value emitNarrow(Value inputVal, int bits) {
-        Variable input = load(inputVal);
-        Variable result = newVariable(LIRKind.derive(inputVal).changeType(bits > 32 ? Kind.Long : Kind.Int));
-        append(new ConvertOp(result, input, "s" + bits, input.getKind() == Kind.Long ? "s64" : "s32"));
-        return result;
-    }
-
-    @Override
-    public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
-        Variable input = load(inputVal);
-        Variable result = newVariable(LIRKind.derive(inputVal).changeType(toBits > 32 ? Kind.Long : Kind.Int));
-        append(new ConvertOp(result, input, "s" + toBits, "s" + fromBits));
-        return result;
-    }
-
-    @Override
-    public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
-        Variable input = load(inputVal);
-        Variable result = newVariable(LIRKind.derive(inputVal).changeType(toBits > 32 ? Kind.Long : Kind.Int));
-        append(new ConvertOp(result, input, "u" + toBits, "u" + fromBits));
-        return result;
-    }
-
-    @Override
-    public Value emitReinterpret(LIRKind to, Value inputVal) {
-        Variable result = newVariable(to);
-        emitMove(result, inputVal);
-        return result;
-    }
-
-    @Override
-    public void emitDeoptimize(Value actionAndReason, Value speculation, LIRFrameState state) {
-        append(new ReturnOp(Value.ILLEGAL));
-    }
-
-    @Override
-    public void emitMembar(int barriers) {
-        int necessaryBarriers = target().arch.requiredBarriers(barriers);
-        append(new MembarOp(necessaryBarriers));
-    }
-
-    @Override
-    public Value emitBitCount(Value value) {
-        Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int));
-        if (value.getKind().getStackKind() == Kind.Int) {
-            append(new HSAILBitManipulationOp(IPOPCNT, result, value));
-        } else {
-            append(new HSAILBitManipulationOp(LPOPCNT, result, value));
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitBitScanForward(Value value) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitBitScanReverse(Value value) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    /**
-     * Emits the LIR code for the {@link HSAILArithmetic#ABS} operation.
-     *
-     * @param input the source operand
-     * @return Value representing the result of the operation
-     */
-    @Override
-    public Value emitMathAbs(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        append(new Op1Reg(ABS, result, input));
-        return result;
-    }
-
-    /**
-     * Emits the LIR code for the {@link HSAILArithmetic#CEIL} operation.
-     *
-     * @param input the source operand
-     * @return Value representing the result of the operation
-     */
-    public Value emitMathCeil(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        append(new Op1Reg(CEIL, result, input));
-        return result;
-    }
-
-    /**
-     * Emits the LIR code for the {@link HSAILArithmetic#FLOOR} operation.
-     *
-     * @param input the source operand
-     * @return Value representing the result of the operation
-     */
-    public Value emitMathFloor(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        append(new Op1Reg(FLOOR, result, input));
-        return result;
-    }
-
-    /**
-     * Emits the LIR code for the {@link HSAILArithmetic#RINT} operation.
-     *
-     * @param input the source operand
-     * @return Value representing the result of the operation
-     */
-    public Value emitMathRint(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        append(new Op1Reg(RINT, result, input));
-        return result;
-    }
-
-    /**
-     * Emits the LIR code for the {@link HSAILArithmetic#SQRT} operation.
-     *
-     * @param input the source operand
-     * @return value representing the result of the operation
-     */
-    @Override
-    public Value emitMathSqrt(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        append(new Op1Reg(SQRT, result, input));
-        return result;
-    }
-
-    @Override
-    public Value emitMathLog(Value input, boolean base10) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitMathCos(Value input) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitMathSin(Value input) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitMathTan(Value input) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitByteSwap(Value input) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void emitReturn(Value input) {
-        AllocatableValue operand = Value.ILLEGAL;
-        if (input != null) {
-            operand = resultOperandFor(input.getLIRKind());
-            emitMove(operand, input);
-        }
-        append(new ReturnOp(operand));
-    }
-
-    /**
-     * This routine handles the LIR code generation for switch nodes by calling
-     * emitSequentialSwitch.
-     *
-     * This routine overrides LIRGenerator.emitSwitch( ) which calls emitSequentialSwitch or
-     * emitTableSwitch based on a heuristic.
-     *
-     * The recommended approach in HSAIL for generating performant code for switch statements is to
-     * emit a series of cascading compare and branches. Thus this routines always calls
-     * emitSequentialSwitch, which implements this approach.
-     *
-     * Note: Only IntegerSwitchNodes are currently supported. The IntegerSwitchNode is the node that
-     * Graal generates for any switch construct appearing in Java bytecode.
-     */
-    @Override
-    public void emitStrategySwitch(JavaConstant[] keyConstants, double[] keyProbabilities, LabelRef[] keyTargets, LabelRef defaultTarget, Variable value) {
-        emitStrategySwitch(new SwitchStrategy.SequentialStrategy(keyProbabilities, keyConstants), value, keyTargets, defaultTarget);
-    }
-
-    /**
-     * Generates the LIR instruction for a switch construct that is meant to be assembled into a
-     * series of cascading compare and branch instructions. This is currently the recommended way of
-     * generating performant HSAIL code for switch constructs.
-     *
-     * @param strategy the strategy used for this switch.
-     * @param keyTargets array of branch targets for each of the cases.
-     * @param defaultTarget the branch target for the default case.
-     * @param key the key that is compared against the key constants in the case statements.
-     */
-    @Override
-    public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) {
-        switch (key.getKind()) {
-            case Int:
-            case Long:
-            case Object:
-                // Append the LIR instruction for generating compare and branch instructions.
-                append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key));
-                break;
-            default:
-                // Throw an exception if the key kind is anything else.
-                throw GraalInternalError.unimplemented("Switch statements not supported for keys of type " + key.getKind());
-        }
-    }
-
-    @Override
-    protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void emitUnwind(Value operand) {
-        throw GraalInternalError.unimplemented();
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILNodeLIRBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * 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.compiler.hsail;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.gen.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * This class implements the HSAIL specific portion of the LIR generator.
- */
-public abstract class HSAILNodeLIRBuilder extends NodeLIRBuilder {
-
-    public HSAILNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        super(graph, lirGen);
-    }
-
-    @Override
-    protected boolean peephole(ValueNode valueNode) {
-        // No peephole optimizations for now.
-        return false;
-    }
-
-    @Override
-    protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented(callTarget.targetMethod().format("direct call to %H.%n(%p)"));
-    }
-
-    @Override
-    protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented(callTarget.targetMethod().format("direct call to %H.%n(%p)"));
-    }
-
-    @Override
-    public void visitBreakpointNode(BreakpointNode node) {
-        throw GraalInternalError.unimplemented();
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import static com.oracle.graal.lir.ptx.ThreadDimension.*;
-
-import org.junit.*;
-
-import com.oracle.graal.lir.ptx.*;
-
-public class ArrayPTXTest extends PTXTest {
-
-    @Ignore("PTXHotSpotForeignCallsProvider.lookupForeignCall() is unimplemented")
-    @Test
-    public void test1() {
-        test("testStoreArray1I", new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, 2);
-    }
-
-    @Ignore("PTXHotSpotForeignCallsProvider.lookupForeignCall() is unimplemented")
-    @Test
-    public void test2() {
-        test("testStoreArrayWarp0", new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, 2);
-    }
-
-    @Ignore("PTXHotSpotForeignCallsProvider.lookupForeignCall() is unimplemented")
-    @Test
-    public void test3() {
-        test("testStoreArrayWarp1I", new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, 2);
-    }
-
-    public static void testStoreArray1I(int[] array, int i) {
-        array[i] = 42;
-    }
-
-    public static void testStoreArrayWarp0(int[] array, @Warp(dimension = X) int i) {
-        array[i] = 42;
-    }
-
-    public static void testStoreArrayWarp1I(@ParallelOver(dimension = X) int[] array, @Warp(dimension = X) int i) {
-        array[i] = 42;
-    }
-
-    public static void main(String[] args) {
-        compileAndPrintCode(new ArrayPTXTest());
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/BasicPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-/**
- * Test class for small Java methods compiled to PTX kernels.
- */
-public class BasicPTXTest extends PTXTest {
-
-    @Test
-    public void test() {
-        test("testConstI");
-    }
-
-    public static int testConstI() {
-        return 42;
-    }
-
-    @Test
-    public void testStaticIntKernel() {
-        test("staticIntKernel", 'a', 42);
-    }
-
-    public static int staticIntKernel(char p0, int p1) {
-        return p1 + p0;
-    }
-
-    @Test
-    public void testVirtualIntKernel() {
-        test("virtualIntKernel", 'a', 42);
-    }
-
-    public int virtualIntKernel(char p0, int p1) {
-        return p1 + p0;
-    }
-
-    @Test
-    public void testGetAvailableProcessors() {
-        assertTrue(getPTXBackend().getAvailableProcessors() >= 0);
-    }
-
-    public static void main(String[] args) {
-        compileAndPrintCode(new BasicPTXTest());
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /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.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import org.junit.*;
-
-public class ControlPTXTest extends PTXTest {
-
-    @Test
-    public void testControl1() {
-        test("testLoop", 42);
-        test("testSwitchDefault1I", 3);
-        test("testSwitch1I", 2);
-        test("testIfElse1I", 222);
-        test("testIfElse2I", 19, 64);
-    }
-
-    @Ignore("PTXHotSpotLIRGenerator.emitCompress is unimplemented")
-    @Test
-    public void testControl2() {
-        compileKernel("testStatic");
-        compileKernel("testCall");
-    }
-
-    @Ignore("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options")
-    @Test
-    public void testControl3() {
-        // test("testIntegerTestBranch2I", 0xff00, 0x00ff);
-        compileKernel("testIntegerTestBranch2I");
-        compileKernel("testLookupSwitch1I");
-    }
-
-    public static boolean testIntegerTestBranch2I(int x, int y) {
-        return (x & y) == 0;
-    }
-
-    public static int testLoop(int n) {
-        int sum = 0;
-
-        for (int i = 0; i < n; i++) {
-            sum++;
-        }
-        return sum;
-    }
-
-    public static int testIfElse1I(int n) {
-        if (n > 22) {
-            return 42;
-        } else {
-            return -42;
-        }
-    }
-
-    public static int testIfElse2I(int c, int y) {
-        if (c > 19) {
-            return 'M';    // millenial
-        } else if (y > 84) {
-            return 'Y';    // young
-        } else {
-            return 'O';    // old
-        }
-    }
-
-    public static int testSwitchDefault1I(int a) {
-        switch (a) {
-            default:
-                return 4;
-        }
-    }
-
-    public static int testSwitch1I(int a) {
-        switch (a) {
-            case 1:
-                return 2;
-            case 2:
-                return 3;
-            default:
-                return 4;
-        }
-    }
-
-    public static int testLookupSwitch1I(int a) {
-        switch (a) {
-            case 0:
-                return 10;
-            case 1:
-                return 11;
-            case 2:
-                return 12;
-            case 3:
-                return 13;
-            case 4:
-                return 14;
-            case 5:
-                return 15;
-            case 6:
-                return 16;
-            case 7:
-                return 17;
-            case 8:
-                return 18;
-            case 9:
-                return 19;
-            case 10:
-                return 20;
-            case 11:
-                return 21;
-            default:
-                return 42;
-        }
-    }
-
-    @SuppressWarnings("unused") private static Object foo = null;
-
-    public static boolean testStatic(Object o) {
-        foo = o;
-        return true;
-    }
-
-    private static int method(int a, int b) {
-        return a + b;
-    }
-
-    public static int testCall(int a, int b) {
-        return method(a, b);
-    }
-
-    public static void main(String[] args) {
-        compileAndPrintCode(new ControlPTXTest());
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/FloatPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import org.junit.*;
-
-/* PTX ISA 3.1 - 8.7.3 Floating-Point Instructions */
-public class FloatPTXTest extends PTXTest {
-
-    @Test
-    public void testAdd() {
-        test("testAdd2I", 42, 43);
-        test("testAdd2F", 42.1F, 43.5F);
-        test("testAddFConst", 42.1F);
-        test("testAdd2D", 42.1, 43.5);
-    }
-
-    public static float testAdd2I(int a, int b) {
-        return a + b;
-    }
-
-    public static float testAdd2F(float a, float b) {
-        return (a + b);
-    }
-
-    public static double testAdd2D(double a, double b) {
-        return a + b;
-    }
-
-    public static float testAddFConst(float a) {
-        return a + 32.0F;
-    }
-
-    public static float testAddConstF(float a) {
-        return 32.0F + a;
-    }
-
-    public static double testAddDConst(double a) {
-        return a + 32.0;
-    }
-
-    public static double testAddConstD(double a) {
-        return 32.0 + a;
-    }
-
-    @Test
-    public void testSub() {
-        compileKernel("testSub2F");
-        compileKernel("testSub2D");
-        compileKernel("testSubFConst");
-        compileKernel("testSubConstF");
-        compileKernel("testSubDConst");
-        compileKernel("testSubConstD");
-    }
-
-    public static float testSub2F(float a, float b) {
-        return a - b;
-    }
-
-    public static double testSub2D(double a, double b) {
-        return a - b;
-    }
-
-    public static float testSubFConst(float a) {
-        return a - 32.0F;
-    }
-
-    public static float testSubConstF(float a) {
-        return 32.0F - a;
-    }
-
-    public static double testSubDConst(double a) {
-        return a - 32.0;
-    }
-
-    public static double testSubConstD(double a) {
-        return 32.0 - a;
-    }
-
-    @Ignore("[CUDA] *** Error (209) Failed to load module data with online compiler options for method testMul2F")
-    @Test
-    public void testMul() {
-        compileKernel("testMul2F");
-        compileKernel("testMul2D");
-        compileKernel("testMulFConst");
-        compileKernel("testMulConstF");
-        compileKernel("testMulDConst");
-        compileKernel("testMulConstD");
-    }
-
-    public static float testMul2F(float a, float b) {
-        return a * b;
-    }
-
-    public static double testMul2D(double a, double b) {
-        return a * b;
-    }
-
-    public static float testMulFConst(float a) {
-        return a * 32.0F;
-    }
-
-    public static float testMulConstF(float a) {
-        return 32.0F * a;
-    }
-
-    public static double testMulDConst(double a) {
-        return a * 32.0;
-    }
-
-    public static double testMulConstD(double a) {
-        return 32.0 * a;
-    }
-
-    @Ignore("[CUDA] *** Error (209) Failed to load module data with online compiler options for method testDiv2F")
-    @Test
-    public void testDiv() {
-        compileKernel("testDiv2F");
-        compileKernel("testDiv2D");
-        compileKernel("testDivFConst");
-        compileKernel("testDivConstF");
-        compileKernel("testDivDConst");
-        compileKernel("testDivConstD");
-    }
-
-    public static float testDiv2F(float a, float b) {
-        return a / b;
-    }
-
-    public static double testDiv2D(double a, double b) {
-        return a / b;
-    }
-
-    public static float testDivFConst(float a) {
-        return a / 32.0F;
-    }
-
-    public static float testDivConstF(float a) {
-        return 32.0F / a;
-    }
-
-    public static double testDivDConst(double a) {
-        return a / 32.0;
-    }
-
-    public static double testDivConstD(double a) {
-        return 32.0 / a;
-    }
-
-    @Test
-    public void testNeg() {
-        compileKernel("testNeg2F");
-        compileKernel("testNeg2D");
-    }
-
-    public static float testNeg2F(float a) {
-        return -a;
-    }
-
-    public static double testNeg2D(double a) {
-        return -a;
-    }
-
-    @Ignore("need linkage to PTX remainder")
-    @Test
-    public void testRem() {
-        compileKernel("testRem2F");
-        compileKernel("testRem2D");
-    }
-
-    public static float testRem2F(float a, float b) {
-        return a % b;
-    }
-
-    public static double testRem2D(double a, double b) {
-        return a % b;
-    }
-
-    @Ignore("[CUDA] *** Error (209) Failed to load module data with online compiler options for method testF2I")
-    @Test
-    public void testFloatConversion() {
-        compileKernel("testF2I");
-        compileKernel("testF2L");
-        compileKernel("testF2D");
-        compileKernel("testD2I");
-        compileKernel("testD2L");
-        compileKernel("testD2F");
-    }
-
-    public static int testF2I(float a) {
-        return (int) a;
-    }
-
-    public static long testF2L(float a) {
-        return (long) a;
-    }
-
-    public static double testF2D(float a) {
-        return a;
-    }
-
-    public static int testD2I(double a) {
-        return (int) a;
-    }
-
-    public static long testD2L(double a) {
-        return (long) a;
-    }
-
-    public static float testD2F(double a) {
-        return (float) a;
-    }
-
-    public static void main(String[] args) {
-        compileAndPrintCode(new FloatPTXTest());
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-public class IntegerPTXTest extends PTXTest {
-
-    @Test
-    public void testAdd() {
-        test("testAdd2B", (byte) 6, (byte) 4);
-        test("testAdd2I", 18, 24);
-        test("testAdd2L", (long) 12, (long) 6);
-        test("testAddIConst", 5);
-        test("testAddConstI", 7);
-    }
-
-    public static int testAdd2I(int a, int b) {
-        return a + b;
-    }
-
-    public static long testAdd2L(long a, long b) {
-        return a + b;
-    }
-
-    public static int testAdd2B(byte a, byte b) {
-        return a + b;
-    }
-
-    public static int testAddIConst(int a) {
-        return a + 32;
-    }
-
-    public static int testAddConstI(int a) {
-        return 32 + a;
-    }
-
-    @Test
-    public void testSub() {
-        test("testSub2I", 18, 4);
-        test("testSub2L", (long) 12, (long) 6);
-        test("testSubIConst", 35);
-        test("testSubConstI", 12);
-    }
-
-    public static int testSub2I(int a, int b) {
-        return a - b;
-    }
-
-    public static long testSub2L(long a, long b) {
-        return a - b;
-    }
-
-    public static int testSubIConst(int a) {
-        return a - 32;
-    }
-
-    public static int testSubConstI(int a) {
-        return 32 - a;
-    }
-
-    @Test
-    public void testMul() {
-        test("testMul2I", 8, 4);
-        test("testMul2L", (long) 12, (long) 6);
-        test("testMulIConst", 4);
-        test("testMulConstI", 5);
-    }
-
-    public static int testMul2I(int a, int b) {
-        return a * b;
-    }
-
-    public static long testMul2L(long a, long b) {
-        return a * b;
-    }
-
-    public static int testMulIConst(int a) {
-        return a * 32;
-    }
-
-    public static int testMulConstI(int a) {
-        return 32 * a;
-    }
-
-    @Test
-    public void testDiv() {
-        test("testDiv2I", 8, 4);
-        test("testDiv2L", (long) 12, (long) 6);
-        test("testDivIConst", 64);
-        test("testDivConstI", 8);
-    }
-
-    public static int testDiv2I(int a, int b) {
-        return a / b;
-    }
-
-    public static long testDiv2L(long a, long b) {
-        return a / b;
-    }
-
-    public static int testDivIConst(int a) {
-        return a / 32;
-    }
-
-    public static int testDivConstI(int a) {
-        return 32 / a;
-    }
-
-    @Test
-    public void testRem() {
-        test("testRem2I", 8, 4);
-        test("testRem2L", (long) 12, (long) 6);
-    }
-
-    public static int testRem2I(int a, int b) {
-        return a % b;
-    }
-
-    public static long testRem2L(long a, long b) {
-        return a % b;
-    }
-
-    @Ignore
-    @Test
-    public void testIntConversion() {
-        test("testI2L", 8);
-        test("testL2I", (long) 12);
-        // test("testI2C", 65);
-        // test("testI2B", 9);
-        // test("testI2F", 17);
-        // test("testI2D", 22);
-    }
-
-    public static long testI2L(int a) {
-        return a;
-    }
-
-    public static char testI2C(int a) {
-        return (char) a;
-    }
-
-    public static byte testI2B(int a) {
-        return (byte) a;
-    }
-
-    public static float testI2F(int a) {
-        return a;
-    }
-
-    public static double testI2D(int a) {
-        return a;
-    }
-
-    public static int testL2I(long a) {
-        return (int) a;
-    }
-
-    public static void main(String[] args) {
-        IntegerPTXTest test = new IntegerPTXTest();
-        for (Method m : IntegerPTXTest.class.getMethods()) {
-            String name = m.getName();
-            if (m.getAnnotation(Test.class) == null && name.startsWith("test")) {
-                PrintStream out = System.out;
-                out.println(name + ": \n" + new String(test.compileKernel(name).getTargetCode()));
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/LogicPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import org.junit.*;
-
-/* PTX ISA 3.1 - 8.7.5 Logic and Shift Instructions */
-public class LogicPTXTest extends PTXTest {
-
-    @Test
-    public void testAnd() {
-        compileKernel("testAnd2I");
-        compileKernel("testAnd2L");
-    }
-
-    public static int testAnd2I(int a, int b) {
-        return a & b;
-    }
-
-    public static long testAnd2L(long a, long b) {
-        return a & b;
-    }
-
-    @Test
-    public void testOr() {
-        compileKernel("testOr2I");
-        compileKernel("testOr2L");
-    }
-
-    public static int testOr2I(int a, int b) {
-        return a | b;
-    }
-
-    public static long testOr2L(long a, long b) {
-        return a | b;
-    }
-
-    @Test
-    public void testXor() {
-        compileKernel("testXor2I");
-        compileKernel("testXor2L");
-    }
-
-    public static int testXor2I(int a, int b) {
-        return a ^ b;
-    }
-
-    public static long testXor2L(long a, long b) {
-        return a ^ b;
-    }
-
-    @Test
-    public void testNot() {
-        compileKernel("testNot1I");
-        compileKernel("testNot1L");
-    }
-
-    public static int testNot1I(int a) {
-        return ~a;
-    }
-
-    public static long testNot1L(long a) {
-        return ~a;
-    }
-
-    @Test
-    public void testShiftLeft() {
-        compileKernel("testShiftLeft2I");
-        compileKernel("testShiftLeft2L");
-    }
-
-    public static int testShiftLeft2I(int a, int b) {
-        return a << b;
-    }
-
-    public static long testShiftLeft2L(long a, int b) {
-        return a << b;
-    }
-
-    @Test
-    public void testShiftRight() {
-        compileKernel("testShiftRight2I");
-        compileKernel("testShiftRight2L");
-        compileKernel("testUnsignedShiftRight2I");
-        // compileKernel("testUnsignedShiftRight2L");
-    }
-
-    public static int testShiftRight2I(int a, int b) {
-        return a >> b;
-    }
-
-    public static long testShiftRight2L(long a, int b) {
-        return a >> b;
-    }
-
-    public static int testUnsignedShiftRight2I(int a, int b) {
-        return a >>> b;
-    }
-
-    public static long testUnsignedShiftRight2L(long a, long b) {
-        return a >>> b;
-    }
-
-    public static void main(String[] args) {
-        compileAndPrintCode(new LogicPTXTest());
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ObjectPTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-public class ObjectPTXTest extends PTXTest {
-
-    static class A {
-        boolean z = true;
-        byte b = 17;
-        char c = 'D';
-        short s = 12345;
-        int i = 0x1234565;
-        long l;
-        Object o;
-        float f;
-        double d;
-    }
-
-    @Test
-    public void test0() {
-        for (long l : new long[]{Long.MIN_VALUE, -10, 0, 1, 2, 10, Long.MAX_VALUE}) {
-            A a = new A();
-            a.l = l;
-            test("testLong", l * 2, a);
-        }
-    }
-
-    public static long testLong(long l, A a) {
-        return a.l + l;
-    }
-
-    @Test
-    public void test1() {
-        for (int i : new int[]{Integer.MIN_VALUE, -10, 0, 1, 2, 10, Integer.MAX_VALUE}) {
-            A a = new A();
-            a.i = i;
-            test("testInt", i * 2, a);
-        }
-    }
-
-    public static int testInt(int i, A a) {
-        return a.i + i;
-    }
-
-    @Ignore("com.oracle.graal.graph.GraalInternalError: should not reach here: unhandled register type v3|z")
-    @Test
-    public void test2() {
-        A a = new A();
-        a.z = true;
-        test("testBoolean", a);
-        a.z = false;
-        test("testBoolean", a);
-    }
-
-    public static boolean testBoolean(A a) {
-        return a.z;
-    }
-
-    @Ignore("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options")
-    @Test
-    public void test3() {
-        for (byte b : new byte[]{Byte.MIN_VALUE, -10, 0, 1, 2, 10, Byte.MAX_VALUE}) {
-            A a = new A();
-            a.b = b;
-            test("testByte", b, a);
-        }
-    }
-
-    public static int testByte(byte b, A a) {
-        return a.b + b;
-    }
-
-    @Ignore("com.oracle.graal.graph.GraalInternalError: should not reach here: unhandled register type v5|s")
-    @Test
-    public void test4() {
-        for (short s : new short[]{Short.MIN_VALUE, -10, 0, 1, 2, 10, Short.MAX_VALUE}) {
-            A a = new A();
-            a.s = s;
-            test("testShort", s, a);
-        }
-    }
-
-    public static int testShort(short s, A a) {
-        return a.s + s;
-    }
-
-    @Ignore("java.lang.AssertionError: expected:<65531> but was:<809107451>")
-    @Test
-    public void test5() {
-        for (char c : new char[]{Character.MIN_VALUE, 1, 2, 10, Character.MAX_VALUE}) {
-            A a = new A();
-            a.c = c;
-            test("testChar", (char) (c - 5), a);
-        }
-    }
-
-    public static int testChar(char c, A a) {
-        return a.c + c;
-    }
-
-    @Test
-    public void test6() {
-        for (float f : new float[]{Float.MIN_VALUE, Float.MIN_NORMAL, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NaN, -11.45F, -0.0F, 0.0F, 2, 10, Float.MAX_VALUE}) {
-            A a = new A();
-            a.f = f;
-            test("testFloat", f * 2, a);
-        }
-    }
-
-    public static float testFloat(float f, A a) {
-        return a.f + f;
-    }
-
-    @Test
-    public void test7() {
-        for (double d : new double[]{Double.MIN_VALUE, Double.MIN_NORMAL, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, -11.45D, -0.0D, 0.0D, 2, 10, Double.MAX_VALUE}) {
-            A a = new A();
-            a.d = d;
-            test("testDouble", d * 2, a);
-        }
-    }
-
-    public static double testDouble(double d, A a) {
-        return a.d + d;
-    }
-
-    @Ignore("Object return values not yet supported")
-    @Test
-    public void test9() {
-        for (Object o : new Object[]{null, "object", new Object(), new HashMap<>()}) {
-            A a = new A();
-            a.o = o;
-            test("testObject", a);
-        }
-    }
-
-    public static Object testObject(A a) {
-        return a.o;
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation1Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import org.junit.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.ptx.*;
-
-/**
- * Tests that a {@linkplain PTXWrapperBuilder PTX kernel wrapper} deoptimizes if the kernel is
- * invalid.
- */
-public class PTXMethodInvalidation1Test extends PTXTest {
-
-    @Test
-    public void test() {
-        test("testSnippet", 100);
-    }
-
-    @Override
-    protected HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult ptxCode) {
-        HotSpotNmethod ptxKernel = super.installKernel(method, ptxCode);
-        ptxKernel.invalidate();
-        return ptxKernel;
-    }
-
-    int f = 42;
-
-    public int testSnippet(int delta) {
-        return f + delta;
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXMethodInvalidation2Test.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.ptx.test;
-
-import java.lang.ref.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.ptx.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * A full GC on HotSpot will unload an nmethod that contains an embedded oop which is the only
- * reference to its referent. The nmethod created for a {@linkplain PTXWrapperBuilder PTX kernel
- * wrapper} has an embedded oop referring to a {@link HotSpotNmethod} object associated with the
- * nmethod for the installed PTX kernel. This embedded oop is a weak reference as described above so
- * there must be another strong reference from the wrapper to the {@link HotSpotNmethod} object.
- */
-public class PTXMethodInvalidation2Test extends PTXTest {
-
-    @Test
-    public void test() {
-        test("testSnippet", 100);
-    }
-
-    @Override
-    protected InstalledCode getCode(ResolvedJavaMethod method, StructuredGraph graph) {
-        InstalledCode code = super.getCode(method, graph);
-
-        // Try hard to force a full GC
-        int attempts = 0;
-        WeakReference<Object> ref = new WeakReference<>(new Object());
-        while (ref.get() != null) {
-            System.gc();
-            // Give up after 1000 attempts
-            Assume.assumeTrue("Giving up after too many attempts!", ++attempts < 1000);
-        }
-
-        Assert.assertFalse(code.getStart() == 0L);
-        return code;
-    }
-
-    int f = 42;
-
-    public int testSnippet(int delta) {
-        return f + delta;
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +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.compiler.ptx.test;
-
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.compiler.test.*;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.ptx.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.ptx.*;
-
-/**
- * Base class for PTX tests.
- */
-public abstract class PTXTest extends GraalCompilerTest {
-
-    public static PTXHotSpotBackend getPTXBackend() {
-        Backend backend = runtime().getBackend(PTX.class);
-        Assume.assumeTrue("No PTX backend, skipping test!", backend instanceof PTXHotSpotBackend);
-        return (PTXHotSpotBackend) backend;
-    }
-
-    protected ExternalCompilationResult compileKernel(ResolvedJavaMethod method) {
-        return getPTXBackend().compileKernel(method, getPTXBackend().isDeviceInitialized());
-    }
-
-    protected ExternalCompilationResult compileKernel(String test) {
-        return compileKernel(getResolvedJavaMethod(test));
-    }
-
-    protected HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult ptxCode) {
-        PTXHotSpotBackend ptxBackend = getPTXBackend();
-        return ptxBackend.installKernel(method, ptxCode);
-    }
-
-    @Override
-    protected InstalledCode getCode(ResolvedJavaMethod installedCodeOwner, StructuredGraph graph) {
-        PTXHotSpotBackend ptxBackend = getPTXBackend();
-        ExternalCompilationResult ptxCode = compileKernel(installedCodeOwner);
-        Assume.assumeTrue("Skipping PTX test: device not initialized!", ptxBackend.isDeviceInitialized());
-        HotSpotNmethod installedPTXCode = installKernel(installedCodeOwner, ptxCode);
-        StructuredGraph wrapper = new PTXWrapperBuilder(installedCodeOwner, installedPTXCode, (HotSpotProviders) getProviders()).getGraph();
-
-        // The PTX C++ layer expects a 1:1 relationship between kernel compilation
-        // and kernel execution as it creates a cuContext in the former and
-        // destroys it in the latter. So, each kernel installed requires a unique
-        // wrapper.
-        // TODO: do cuContext management properly
-        boolean forceCompile = true;
-
-        return getCode(installedCodeOwner, wrapper, forceCompile);
-    }
-
-    protected static void compileAndPrintCode(PTXTest test) {
-        for (Method m : test.getClass().getMethods()) {
-            String name = m.getName();
-            if (m.getAnnotation(Test.class) == null && name.startsWith("test")) {
-                PrintStream out = System.out;
-                out.println(name + ": \n" + new String(test.compileKernel(name).getTargetCode()));
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,883 +0,0 @@
-/*
- * 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.compiler.ptx;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.lir.ptx.PTXArithmetic.*;
-import static com.oracle.graal.lir.ptx.PTXBitManipulationOp.IntrinsicOpcode.*;
-import static com.oracle.graal.lir.ptx.PTXCompare.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.compiler.common.spi.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.JumpOp;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.ptx.*;
-import com.oracle.graal.lir.ptx.PTXArithmetic.ConvertOp;
-import com.oracle.graal.lir.ptx.PTXArithmetic.Op1Stack;
-import com.oracle.graal.lir.ptx.PTXArithmetic.Op2Reg;
-import com.oracle.graal.lir.ptx.PTXArithmetic.Op2Stack;
-import com.oracle.graal.lir.ptx.PTXArithmetic.ShiftOp;
-import com.oracle.graal.lir.ptx.PTXCompare.CompareOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.BranchOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.CondMoveOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.FloatCondMoveOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.ReturnNoValOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.ReturnOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.StrategySwitchOp;
-import com.oracle.graal.lir.ptx.PTXControlFlow.TableSwitchOp;
-import com.oracle.graal.lir.ptx.PTXMemOp.LoadOp;
-import com.oracle.graal.lir.ptx.PTXMemOp.LoadParamOp;
-import com.oracle.graal.lir.ptx.PTXMemOp.LoadReturnAddrOp;
-import com.oracle.graal.lir.ptx.PTXMemOp.StoreOp;
-import com.oracle.graal.lir.ptx.PTXMemOp.StoreReturnValOp;
-import com.oracle.graal.lir.ptx.PTXMove.MoveFromRegOp;
-import com.oracle.graal.lir.ptx.PTXMove.MoveToRegOp;
-import com.oracle.graal.phases.util.*;
-
-/**
- * This class implements the PTX specific portion of the LIR generator.
- */
-public class PTXLIRGenerator extends LIRGenerator {
-
-    // Number of the predicate register that can be used when needed.
-    // This value will be recorded and incremented in the LIR instruction
-    // that sets a predicate register. (e.g., CompareOp)
-    private int nextPredRegNum;
-
-    public static final ForeignCallDescriptor ARITHMETIC_FREM = new ForeignCallDescriptor("arithmeticFrem", float.class, float.class, float.class);
-    public static final ForeignCallDescriptor ARITHMETIC_DREM = new ForeignCallDescriptor("arithmeticDrem", double.class, double.class, double.class);
-
-    public static class PTXSpillMoveFactory implements LIR.SpillMoveFactory {
-
-        @Override
-        public LIRInstruction createMove(AllocatableValue result, Value input) {
-            throw GraalInternalError.unimplemented("PTXSpillMoveFactory.createMove()");
-        }
-    }
-
-    public PTXLIRGenerator(LIRKindTool lirKindTool, Providers providers, CallingConvention cc, LIRGenerationResult lirGenRes) {
-        super(lirKindTool, providers, cc, lirGenRes);
-        lirGenRes.getLIR().setSpillMoveFactory(new PTXSpillMoveFactory());
-        int callVariables = cc.getArgumentCount() + (cc.getReturn().equals(Value.ILLEGAL) ? 0 : 1);
-        lirGenRes.getLIR().setFirstVariableNumber(callVariables);
-        nextPredRegNum = 0;
-    }
-
-    public int getNextPredRegNumber() {
-        return nextPredRegNum;
-    }
-
-    @Override
-    public boolean canInlineConstant(JavaConstant c) {
-        switch (c.getKind()) {
-            case Long:
-                return NumUtil.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c);
-            case Object:
-                return c.isNull();
-            default:
-                return true;
-        }
-    }
-
-    public Variable emitWarpParam(Kind kind, Warp annotation) {
-        Variable result = newVariable(target().getLIRKind(kind));
-        Variable tid = newVariable(LIRKind.value(Kind.Char));
-
-        switch (annotation.dimension()) {
-            case X:
-                tid.setName("%tid.x");
-                break;
-            case Y:
-                tid.setName("%tid.y");
-                break;
-            case Z:
-                tid.setName("%tid.y");
-                break;
-        }
-        emitMove(result, tid);
-
-        return result;
-    }
-
-    @Override
-    public void emitMove(AllocatableValue dst, Value src) {
-        if (isRegister(src) || isStackSlotValue(dst)) {
-            append(new MoveFromRegOp(dst, src));
-        } else {
-            append(new MoveToRegOp(dst, src));
-        }
-    }
-
-    @Override
-    public void emitData(AllocatableValue dst, byte[] data) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public PTXAddressValue emitAddress(Value base, long displacement, Value index, int scale) {
-        AllocatableValue baseRegister;
-        long finalDisp = displacement;
-
-        if (isConstant(base)) {
-            if (asConstant(base).isNull()) {
-                baseRegister = Value.ILLEGAL;
-            } else if (asConstant(base).getKind() != Kind.Object && !getCodeCache().needsDataPatch(asConstant(base))) {
-                finalDisp += asConstant(base).asLong();
-                baseRegister = Value.ILLEGAL;
-            } else {
-                baseRegister = load(base);
-            }
-        } else if (base.equals(Value.ILLEGAL)) {
-            baseRegister = Value.ILLEGAL;
-        } else {
-            baseRegister = asAllocatable(base);
-        }
-
-        if (!index.equals(Value.ILLEGAL)) {
-            if (isConstant(index)) {
-                finalDisp += asConstant(index).asLong() * scale;
-            } else {
-                Value convertedIndex;
-                Value indexRegister;
-
-                convertedIndex = emitSignExtend(index, 32, 64);
-                if (scale != 1) {
-                    if (CodeUtil.isPowerOf2(scale)) {
-                        indexRegister = emitShl(convertedIndex, JavaConstant.forInt(CodeUtil.log2(scale)));
-                    } else {
-                        indexRegister = emitMul(convertedIndex, JavaConstant.forInt(scale), false);
-                    }
-                } else {
-                    indexRegister = convertedIndex;
-                }
-                if (baseRegister.equals(Value.ILLEGAL)) {
-                    baseRegister = asAllocatable(indexRegister);
-                } else {
-                    Variable longBaseRegister = newVariable(LIRKind.derivedReference(Kind.Long));
-                    emitMove(longBaseRegister, baseRegister);
-                    baseRegister = emitAdd(longBaseRegister, indexRegister, false);
-                }
-            }
-        }
-
-        LIRKind resultKind = getAddressKind(base, displacement, index);
-        return new PTXAddressValue(resultKind, baseRegister, finalDisp);
-    }
-
-    private PTXAddressValue asAddress(Value address) {
-        assert address != null;
-
-        if (address instanceof PTXAddressValue) {
-            return (PTXAddressValue) address;
-        } else {
-            return emitAddress(address, 0, Value.ILLEGAL, 0);
-        }
-    }
-
-    @Override
-    public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) {
-        PTXAddressValue loadAddress = asAddress(address);
-        Variable result = newVariable(kind);
-        append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state));
-        return result;
-    }
-
-    @Override
-    public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) {
-        PTXAddressValue storeAddress = asAddress(address);
-        Variable input = load(inputVal);
-        append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state));
-    }
-
-    @Override
-    public Variable emitAddress(StackSlotValue address) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitAddress()");
-    }
-
-    @Override
-    public void emitJump(LabelRef label) {
-        append(new JumpOp(label));
-    }
-
-    @Override
-    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));
-                append(new BranchOp(cond, trueDestination, falseDestination, nextPredRegNum++));
-                break;
-            case Long:
-                append(new CompareOp(LCMP, cond, left, right, nextPredRegNum));
-                append(new BranchOp(cond, trueDestination, falseDestination, nextPredRegNum++));
-                break;
-            case Float:
-                append(new CompareOp(FCMP, cond, left, right, nextPredRegNum));
-                append(new BranchOp(cond, trueDestination, falseDestination, nextPredRegNum++));
-                break;
-            case Double:
-                append(new CompareOp(DCMP, cond, left, right, nextPredRegNum));
-                append(new BranchOp(cond, trueDestination, falseDestination, nextPredRegNum++));
-                break;
-            case Object:
-                append(new CompareOp(ACMP, cond, left, right, nextPredRegNum));
-                append(new BranchOp(cond, trueDestination, falseDestination, nextPredRegNum++));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("" + left.getKind());
-        }
-    }
-
-    @Override
-    public void emitOverflowCheckBranch(LabelRef overflow, LabelRef noOverflow, LIRKind cmpLIRKind, double overflowProbability) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitOverflowCheckBranch()");
-    }
-
-    @Override
-    public void emitIntegerTestBranch(Value left, Value right, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) {
-        // / emitIntegerTest(left, right);
-        // append(new BranchOp(negated ? Condition.NE : Condition.EQ, label));
-        throw GraalInternalError.unimplemented("emitIntegerTestBranch()");
-    }
-
-    @Override
-    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;
-
-        emitCompare(finalCondition, left, right);
-
-        Variable result = newVariable(trueValue.getLIRKind());
-        switch (left.getKind().getStackKind()) {
-            case Int:
-            case Long:
-            case Object:
-                append(new CondMoveOp(result, finalCondition, load(trueValue), loadNonConst(falseValue), nextPredRegNum));
-                nextPredRegNum++;
-                break;
-            case Float:
-            case Double:
-                append(new FloatCondMoveOp(result, finalCondition, unorderedIsTrue, load(trueValue), load(falseValue), nextPredRegNum));
-                nextPredRegNum++;
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("" + left.getKind());
-        }
-        return result;
-    }
-
-    /**
-     * This method emits the compare instruction, and may reorder the operands. It returns true if
-     * it did so.
-     *
-     * @param a the left operand of the comparison
-     * @param b the right operand of the comparison
-     * @return true if the left and right operands were switched, false otherwise
-     */
-    private boolean emitCompare(Condition cond, Value a, Value b) {
-        Variable left;
-        Value right;
-        boolean mirrored;
-        if (LIRValueUtil.isVariable(b)) {
-            left = load(b);
-            right = loadNonConst(a);
-            mirrored = true;
-        } else {
-            left = load(a);
-            right = loadNonConst(b);
-            mirrored = false;
-        }
-        switch (left.getKind().getStackKind()) {
-            case Int:
-                append(new CompareOp(ICMP, cond, left, right, nextPredRegNum));
-                break;
-            case Long:
-                append(new CompareOp(LCMP, cond, left, right, nextPredRegNum));
-                break;
-            case Object:
-                append(new CompareOp(ACMP, cond, left, right, nextPredRegNum));
-                break;
-            case Float:
-                append(new CompareOp(FCMP, cond, left, right, nextPredRegNum));
-                break;
-            case Double:
-                append(new CompareOp(DCMP, cond, left, right, nextPredRegNum));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return mirrored;
-    }
-
-    @Override
-    public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Value falseValue) {
-        emitIntegerTest(left, right);
-        Variable result = newVariable(trueValue.getLIRKind());
-        append(new CondMoveOp(result, Condition.EQ, load(trueValue), loadNonConst(falseValue), nextPredRegNum));
-        nextPredRegNum++;
-
-        return result;
-    }
-
-    private void emitIntegerTest(Value a, Value b) {
-        assert a.getKind().isNumericInteger();
-
-        if (LIRValueUtil.isVariable(b)) {
-            append(new PTXTestOp(load(b), loadNonConst(a), nextPredRegNum));
-        } else {
-            append(new PTXTestOp(load(a), loadNonConst(b), nextPredRegNum));
-        }
-    }
-
-    @Override
-    public Variable emitNegate(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        switch (input.getKind()) {
-            case Int:
-                append(new Op1Stack(INEG, result, input));
-                break;
-            case Float:
-                append(new Op1Stack(FNEG, result, input));
-                break;
-            case Double:
-                append(new Op1Stack(DNEG, result, input));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitNot(Value input) {
-        Variable result = newVariable(LIRKind.derive(input));
-        switch (input.getKind()) {
-            case Int:
-                append(new Op1Stack(INOT, result, input));
-                break;
-            case Long:
-                append(new Op1Stack(LNOT, result, input));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitAdd(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(IADD, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LADD, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Stack(FADD, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Stack(DADD, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind() + " prim: " + a.getKind().isPrimitive());
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitSub(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(ISUB, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LSUB, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Stack(FSUB, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Stack(DSUB, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitMul(Value a, Value b, boolean setFlags) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IMUL, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LMUL, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Stack(FMUL, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Stack(DMUL, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitMulHigh(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitUMulHigh(Value a, Value b) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitDiv(Value a, Value b, LIRFrameState state) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IDIV, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LDIV, result, a, loadNonConst(b)));
-                break;
-            case Float:
-                append(new Op2Stack(FDIV, result, a, loadNonConst(b)));
-                break;
-            case Double:
-                append(new Op2Stack(DDIV, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitRem(Value a, Value b, LIRFrameState state) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Reg(IREM, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Reg(LREM, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitUDiv(Value a, Value b, LIRFrameState state) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitUDiv()");
-    }
-
-    @Override
-    public Variable emitURem(Value a, Value b, LIRFrameState state) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitURem()");
-    }
-
-    @Override
-    public Variable emitAnd(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(IAND, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LAND, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitOr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(IOR, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LOR, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + a.getKind());
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitXor(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(IXOR, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LXOR, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitShl(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(ISHL, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LSHL, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitShr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                append(new Op2Stack(ISHR, result, a, loadNonConst(b)));
-                break;
-            case Long:
-                append(new Op2Stack(LSHR, result, a, loadNonConst(b)));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    @Override
-    public Variable emitUShr(Value a, Value b) {
-        Variable result = newVariable(LIRKind.derive(a, b).changeType(a.getPlatformKind()));
-        switch (a.getKind()) {
-            case Int:
-                append(new ShiftOp(IUSHR, result, a, b));
-                break;
-            case Long:
-                append(new ShiftOp(LUSHR, result, a, b));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        return result;
-    }
-
-    public Variable emitConvertOp(Kind from, Kind to, Value inputVal) {
-        Variable input = load(inputVal);
-        Variable result = newVariable(LIRKind.derive(inputVal).changeType(to));
-        append(new ConvertOp(result, input, to, from));
-        return result;
-    }
-
-    @Override
-    public Value emitFloatConvert(FloatConvert op, Value inputVal) {
-        switch (op) {
-            case D2F:
-                return emitConvertOp(Kind.Double, Kind.Float, inputVal);
-            case D2I:
-                return emitConvertOp(Kind.Double, Kind.Int, inputVal);
-            case D2L:
-                return emitConvertOp(Kind.Double, Kind.Long, inputVal);
-            case F2D:
-                return emitConvertOp(Kind.Float, Kind.Double, inputVal);
-            case F2I:
-                return emitConvertOp(Kind.Float, Kind.Int, inputVal);
-            case F2L:
-                return emitConvertOp(Kind.Float, Kind.Long, inputVal);
-            case I2D:
-                return emitConvertOp(Kind.Int, Kind.Double, inputVal);
-            case I2F:
-                return emitConvertOp(Kind.Int, Kind.Float, inputVal);
-            case L2D:
-                return emitConvertOp(Kind.Long, Kind.Double, inputVal);
-            case L2F:
-                return emitConvertOp(Kind.Long, Kind.Float, inputVal);
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    @Override
-    public Value emitNarrow(Value inputVal, int bits) {
-        if (inputVal.getKind() == Kind.Long && bits <= 32) {
-            return emitConvertOp(Kind.Long, Kind.Int, inputVal);
-        } else {
-            return inputVal;
-        }
-    }
-
-    @Override
-    public Value emitSignExtend(Value inputVal, int fromBits, int toBits) {
-        assert fromBits <= toBits && toBits <= 64;
-        if (fromBits == toBits) {
-            return inputVal;
-        } else if (toBits > 32) {
-            // sign extend to 64 bits
-            switch (fromBits) {
-                case 8:
-                    return emitConvertOp(Kind.Byte, Kind.Long, inputVal);
-                case 16:
-                    return emitConvertOp(Kind.Short, Kind.Long, inputVal);
-                case 32:
-                    return emitConvertOp(Kind.Int, Kind.Long, inputVal);
-                case 64:
-                    return inputVal;
-                default:
-                    throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
-            }
-        } else {
-            // sign extend to 32 bits (smaller values are internally represented as 32 bit values)
-            switch (fromBits) {
-                case 8:
-                    return emitConvertOp(Kind.Byte, Kind.Int, inputVal);
-                case 16:
-                    return emitConvertOp(Kind.Short, Kind.Int, inputVal);
-                case 32:
-                    return inputVal;
-                default:
-                    throw GraalInternalError.unimplemented("unsupported sign extension (" + fromBits + " bit -> " + toBits + " bit)");
-            }
-        }
-    }
-
-    @Override
-    public Value emitZeroExtend(Value inputVal, int fromBits, int toBits) {
-        assert fromBits <= toBits && toBits <= 64;
-        if (fromBits == toBits) {
-            return inputVal;
-        } else if (fromBits > 32) {
-            assert inputVal.getKind() == Kind.Long;
-            Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
-            long mask = CodeUtil.mask(fromBits);
-            append(new Op2Stack(LAND, result, inputVal, JavaConstant.forLong(mask)));
-            return result;
-        } else {
-            assert inputVal.getKind() == Kind.Int;
-            Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int));
-            int mask = (int) CodeUtil.mask(fromBits);
-            append(new Op2Stack(IAND, result, inputVal, JavaConstant.forInt(mask)));
-            if (toBits > 32) {
-                Variable longResult = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long));
-                emitMove(longResult, result);
-                return longResult;
-            } else {
-                return result;
-            }
-        }
-    }
-
-    @Override
-    public Value emitReinterpret(LIRKind to, Value inputVal) {
-        Variable result = newVariable(to);
-        emitMove(result, inputVal);
-        return result;
-    }
-
-    @Override
-    public void emitDeoptimize(Value actionAndReason, Value speculation, LIRFrameState state) {
-        append(new ReturnOp(Value.ILLEGAL));
-    }
-
-    @Override
-    public void emitMembar(int barriers) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMembar()");
-    }
-
-    @Override
-    protected void emitForeignCall(ForeignCallLinkage callTarget, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitForeignCall()");
-    }
-
-    @Override
-    public Value emitBitCount(Value value) {
-        Variable result = newVariable(LIRKind.derive(value).changeType(Kind.Int));
-        if (value.getKind().getStackKind() == Kind.Int) {
-            append(new PTXBitManipulationOp(IPOPCNT, result, value));
-        } else {
-            append(new PTXBitManipulationOp(LPOPCNT, result, value));
-        }
-        return result;
-    }
-
-    @Override
-    public Value emitBitScanForward(Value value) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitBitScanForward()");
-    }
-
-    @Override
-    public Value emitBitScanReverse(Value value) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitBitScanReverse()");
-    }
-
-    @Override
-    public Value emitMathAbs(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathAbs()");
-    }
-
-    @Override
-    public Value emitMathSqrt(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathSqrt()");
-    }
-
-    @Override
-    public Value emitMathLog(Value input, boolean base10) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathLog()");
-    }
-
-    @Override
-    public Value emitMathCos(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathCos()");
-    }
-
-    @Override
-    public Value emitMathSin(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathSin()");
-    }
-
-    @Override
-    public Value emitMathTan(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitMathTan()");
-    }
-
-    @Override
-    public Value emitByteSwap(Value input) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitByteSwap()");
-    }
-
-    @Override
-    public Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public void emitReturn(Value input) {
-        if (input != null) {
-            AllocatableValue operand = resultOperandFor(input.getLIRKind());
-            // Load the global memory address from return parameter
-            Variable loadVar = emitLoadReturnAddress(operand.getKind(), operand, null);
-            // Store input in global memory whose location is loadVar
-            emitStoreReturnValue(operand.getKind(), loadVar, input, null);
-        }
-        emitReturnNoVal();
-    }
-
-    void emitReturnNoVal() {
-        append(new ReturnNoValOp());
-    }
-
-    @Override
-    public void emitStrategySwitch(SwitchStrategy strategy, Variable key, LabelRef[] keyTargets, LabelRef defaultTarget) {
-        boolean needsTemp = key.getKind() == Kind.Object;
-        append(new StrategySwitchOp(strategy, keyTargets, defaultTarget, key, needsTemp ? newVariable(key.getLIRKind()) : Value.ILLEGAL, nextPredRegNum++));
-    }
-
-    @Override
-    protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key) {
-        // Making a copy of the switch value is necessary because jump table destroys the input
-        // value
-        Variable tmp = emitMove(key);
-        append(new TableSwitchOp(lowKey, defaultTarget, targets, tmp, newVariable(LIRKind.value(target().wordKind)), nextPredRegNum++));
-    }
-
-    @Override
-    public void emitUnwind(Value operand) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitUnwind()");
-    }
-
-    public Variable emitLoadParam(Kind kind, Value address, LIRFrameState state) {
-
-        PTXAddressValue loadAddress = asAddress(address);
-        Variable result = newVariable(target().getLIRKind(kind));
-        append(new LoadParamOp(kind, result, loadAddress, state));
-
-        return result;
-    }
-
-    public Variable emitLoadReturnAddress(Kind kind, Value address, LIRFrameState state) {
-        PTXAddressValue loadAddress = asAddress(address);
-        Variable result;
-        switch (kind) {
-            case Float:
-                result = newVariable(LIRKind.value(Kind.Int));
-                break;
-            case Double:
-                result = newVariable(LIRKind.value(Kind.Long));
-                break;
-            default:
-                result = newVariable(target().getLIRKind(kind));
-        }
-        append(new LoadReturnAddrOp(kind, result, loadAddress, state));
-
-        return result;
-    }
-
-    public void emitStoreReturnValue(Kind kind, Value address, Value inputVal, LIRFrameState state) {
-        PTXAddressValue storeAddress = asAddress(address);
-        Variable input = load(inputVal);
-        append(new StoreReturnValOp(kind, storeAddress, input, state));
-    }
-
-    @Override
-    public AllocatableValue resultOperandFor(LIRKind kind) {
-        return (new Variable(kind, 0));
-    }
-
-    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void emitNullCheck(Value address, LIRFrameState state) {
-        assert address.getKind() == Kind.Object : address + " - " + address.getKind() + " not an object!";
-        append(new PTXMove.NullCheckOp(load(address), state));
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXNodeLIRBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * 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.compiler.ptx;
-
-import java.lang.reflect.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.gen.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.ptx.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * This class implements the PTX specific portion of the LIR generator.
- */
-public class PTXNodeLIRBuilder extends NodeLIRBuilder {
-
-    public static final ForeignCallDescriptor ARITHMETIC_FREM = new ForeignCallDescriptor("arithmeticFrem", float.class, float.class, float.class);
-    public static final ForeignCallDescriptor ARITHMETIC_DREM = new ForeignCallDescriptor("arithmeticDrem", double.class, double.class, double.class);
-
-    public static class PTXSpillMoveFactory implements LIR.SpillMoveFactory {
-
-        @Override
-        public LIRInstruction createMove(AllocatableValue result, Value input) {
-            throw GraalInternalError.unimplemented("PTXSpillMoveFactory.createMove()");
-        }
-    }
-
-    public PTXNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        super(graph, lirGen);
-    }
-
-    @Override
-    public void emitPrologue(StructuredGraph graph) {
-        // Need to emit .param directives based on incoming arguments and return value
-        CallingConvention incomingArguments = gen.getCallingConvention();
-        Object returnObject = incomingArguments.getReturn();
-        AllocatableValue[] params = incomingArguments.getArguments();
-        int argCount = incomingArguments.getArgumentCount();
-
-        if (returnObject.equals(Value.ILLEGAL)) {
-            params = incomingArguments.getArguments();
-            append(new PTXParameterOp(params, false));
-        } else {
-            argCount = incomingArguments.getArgumentCount();
-            params = new Variable[argCount + 1];
-            for (int i = 0; i < argCount; i++) {
-                params[i] = incomingArguments.getArgument(i);
-            }
-            params[argCount] = (Variable) returnObject;
-            append(new PTXParameterOp(params, true));
-        }
-
-        for (ParameterNode param : graph.getNodes(ParameterNode.class)) {
-            int localIndex = param.index();
-            Value paramValue = params[param.index()];
-            int parameterIndex = localIndex;
-            if (!Modifier.isStatic(graph.method().getModifiers())) {
-                parameterIndex--;
-            }
-            Warp warpAnnotation = parameterIndex >= 0 ? graph.method().getParameterAnnotation(Warp.class, parameterIndex) : null;
-            if (warpAnnotation != null) {
-                setResult(param, getGen().emitWarpParam(paramValue.getKind().getStackKind(), warpAnnotation));
-            } else {
-                setResult(param, getGen().emitLoadParam(paramValue.getKind().getStackKind(), paramValue, null));
-            }
-        }
-    }
-
-    private PTXLIRGenerator getGen() {
-        return (PTXLIRGenerator) gen;
-    }
-
-    @Override
-    protected boolean peephole(ValueNode valueNode) {
-        // No peephole optimizations for now
-        return false;
-    }
-
-    @Override
-    protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitDirectCall()");
-    }
-
-    @Override
-    protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.emitIndirectCall()");
-    }
-
-    @Override
-    public void visitBreakpointNode(BreakpointNode node) {
-        throw GraalInternalError.unimplemented("PTXLIRGenerator.visitBreakpointNode()");
-    }
-
-    @Override
-    public void visitSafepointNode(SafepointNode i) {
-        // LIRFrameState info = state(i);
-        // append(new PTXSafepointOp(info, runtime().config, this));
-        Debug.log("visitSafePointNode unimplemented");
-    }
-}
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -399,7 +399,7 @@
     }
 
     @Override
-    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
+    protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
         long maxOffset = linkage.getMaxCallTargetOffset();
         if (SPARCAssembler.isWordDisp30(maxOffset)) {
             append(new SPARCCall.DirectNearForeignCallOp(linkage, result, arguments, temps, info));
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Jan 28 19:32:47 2015 +0100
@@ -188,9 +188,6 @@
      */
     private static void checkClass(Class<?> c, MetaAccessProvider metaAccess) {
         if (Node.class.isAssignableFrom(c)) {
-            if (Modifier.isFinal(c.getModifiers())) {
-                throw new AssertionError(String.format("Node subclass %s must not be final", c.getName()));
-            }
             if (c.getAnnotation(NodeInfo.class) == null) {
                 throw new AssertionError(String.format("Node subclass %s requires %s annotation", c.getName(), NodeClass.class.getSimpleName()));
             }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSenReduTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,392 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.test;
-
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.internal.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.util.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
-import com.oracle.graal.phases.tiers.*;
-
-/**
- * Tests whether {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase} actually
- * performs some graph rewritings that it's supposed to perform.
- */
-public class FlowSenReduTest extends GraalCompilerTest {
-
-    /*
-     * A previous instanceof makes redundant a follow-up checkcast.
-     */
-    public Object redundantCheckCastSnippet(Number o) {
-        Integer z = null;
-        if (o instanceof Integer) {
-            z = (Integer) o; // this CheckCastNode will be removed
-        }
-        return z;
-    }
-
-    static final Integer i7 = new Integer(7);
-
-    @Test
-    public void redundantCheckCastTest() {
-        assertDeepEquals(i7, redundantCheckCastSnippet(i7));
-        StructuredGraph result = afterFlowSensitiveReduce("redundantCheckCastSnippet");
-        nodeCountEquals(result, CheckCastNode.class, 0);
-        nodeCountEquals(result, InstanceOfNode.class, 1);
-    }
-
-    @SuppressWarnings("unused")
-    public boolean redundantInstanceOfSnippet01(Object o) {
-        if (o != null) {
-            Integer x = (Integer) o;
-            return (o instanceof Number); // this InstanceOfNode will be removed
-        }
-        return false;
-    }
-
-    @Test
-    public void redundantInstanceOfTest01() {
-        String snippet = "redundantInstanceOfSnippet01";
-        assertDeepEquals(true, redundantInstanceOfSnippet01(i7));
-        nodeCountEquals(afterFlowSensitiveReduce(snippet), InstanceOfNode.class, 1);
-    }
-
-    /*
-     * The combination of (previous) non-null-check and checkcast make redundant an instanceof.
-     */
-    @SuppressWarnings("unused")
-    public Object redundantInstanceOfSnippet02(Object o) {
-        Integer x = (Integer) o;
-        if (o != null) {
-            if (o instanceof Number) { // this InstanceOfNode will be removed
-                return o;
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void redundantInstanceOfTest02() {
-        String snippet = "redundantInstanceOfSnippet02";
-        assertDeepEquals(i7, redundantInstanceOfSnippet02(i7));
-        int ioAfter = getNodes(afterFlowSensitiveReduce(snippet), InstanceOfNode.class).size();
-        assertDeepEquals(ioAfter, 1);
-    }
-
-    /*
-     * Once an exact-type has been inferred (due to instanceof final-class) a callsite is
-     * devirtualized.
-     */
-    public int devirtualizationSnippet(Object x, Object y) {
-        boolean c = x instanceof Integer;
-        if (c && x == y) {
-            Number z = (Number) y; // this CheckCastNode will be removed
-            return z.intValue(); // devirtualized into InvokeSpecial on Integer.intValue()
-        }
-        return 0;
-    }
-
-    @Test
-    public void devirtualizationTest() {
-        String snippet = "devirtualizationSnippet";
-        assertDeepEquals(i7, devirtualizationSnippet(i7, i7));
-        nodeCountEquals(afterFlowSensitiveReduce(snippet), CheckCastNode.class, 0);
-
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        assertDeepEquals(0, graph.getNodes().filter(CheckCastNode.class).count());
-
-        List<InvokeNode> invokeNodes = getNodes(afterFlowSensitiveReduce(snippet), InvokeNode.class);
-        assertDeepEquals(1, invokeNodes.size());
-
-        MethodCallTargetNode target = (MethodCallTargetNode) invokeNodes.get(0).callTarget();
-        assertDeepEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind());
-        assertDeepEquals("HotSpotMethod<Integer.intValue()>", target.targetMethod().toString());
-    }
-
-    /*
-     * At the return statement, the returned value has been inferred to have type j.l.Number. The
-     * instanceof is deemed to always evaluate to false. The interplay with tail-duplication is also
-     * taken into account (resulting in two return statements, each with "false" as input).
-     */
-    @SuppressWarnings("unused")
-    public boolean t5Snippet(Object o, boolean b) {
-        Number z;
-        if (b) {
-            z = (Number) o; // tail duplication of return stmt, which becomes "return false"
-        } else {
-            z = (Integer) o; // tail duplication of return stmt, which becomes "return false"
-        }
-        return o instanceof String; // unreachable
-    }
-
-    @Test
-    public void t5a() {
-        String snippet = "t5Snippet";
-        assertDeepEquals(false, t5Snippet(null, true));
-        StructuredGraph resultGraph = canonicalize(afterFlowSensitiveReduce(snippet));
-        nodeCountEquals(resultGraph, ReturnNode.class, 2);
-
-        List<ReturnNode> returnNodes = getNodes(resultGraph, ReturnNode.class);
-        Iterator<ReturnNode> iter = returnNodes.iterator();
-
-        ConstantNode c1 = (ConstantNode) iter.next().result();
-        ConstantNode c2 = (ConstantNode) iter.next().result();
-
-        assertDeepEquals(c1, c2);
-        assertDeepEquals(0, c1.asJavaConstant().asInt());
-    }
-
-    @Test
-    public void t5b() {
-        String snippet = "t5Snippet";
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        canonicalize(graph);
-        nodeCountEquals(graph, InstanceOfNode.class, 2);
-    }
-
-    public boolean t6Snippet(Object x, Object y) {
-        if (!(x instanceof String)) {
-            return false;
-        }
-        if (!(y instanceof Number)) {
-            return false;
-        }
-        return x == y; // two known-not-to-conform reference values can't be ==
-    }
-
-    // TODO: two known-not-to-conform reference values can't be ==
-    // but baseCaseObjectEqualsNode doesn't check that as of now.
-    public void t6() {
-        String snippet = "t6Snippet";
-        // visualize(snippet);
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        canonicalize(graph);
-        nodeCountEquals(graph, ObjectEqualsNode.class, 0);
-    }
-
-    /*
-     * A previous instanceof check causes a follow-up instanceof to be deemed unsatisfiable,
-     * resulting in constant-substitution at that usage.
-     */
-    public Object t7Snippet(Object o) {
-        if (o instanceof Number) {
-            if (o instanceof String) { // condition amounts to false
-                return o; // made unreachable
-            }
-        }
-        return null;
-    }
-
-    @Test
-    public void t7() {
-        String snippet = "t7Snippet";
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        graph = dce(canonicalize(graph));
-        // TODO how to simplify IfNode(false)
-        assertDeepEquals(1, getNodes(graph, InstanceOfNode.class).size());
-
-        List<ReturnNode> returnNodes = getNodes(graph, ReturnNode.class);
-        assertDeepEquals(2, returnNodes.size());
-        Iterator<ReturnNode> iter = returnNodes.iterator();
-
-        ConstantNode c1 = (ConstantNode) iter.next().result();
-        ConstantNode c2 = (ConstantNode) iter.next().result();
-
-        assertDeepEquals(c1, c2);
-        Assert.assertTrue(c1.isNullConstant());
-    }
-
-    /*
-     * During FlowSensitiveReduction, an unreachable branch doesn't contribute to the merged state.
-     * The resulting ("non-polluted") more precise inferred type after the merge allows
-     * devirtualizing a callsite.
-     */
-    public int devirtualizationSnippet02(Number o) {
-        if (o instanceof Integer) {
-            Number z = o;
-            if (o instanceof Long) {
-                z = o;
-            }
-            /*
-             * devirtualized into InvokeSpecial on Integer.intValue() ie the inferred-type is not
-             * polluted with values from the unreachable branch.
-             */
-            return z.intValue();
-        }
-        return 0;
-    }
-
-    @Test
-    public void devirtualizationTest02() {
-        String snippet = "devirtualizationSnippet02";
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-
-        assertDeepEquals(1, getNodes(graph, InvokeNode.class).size());
-
-        List<InvokeNode> invokeNodes = getNodes(graph, InvokeNode.class);
-        assertDeepEquals(1, invokeNodes.size());
-
-        MethodCallTargetNode target = (MethodCallTargetNode) invokeNodes.get(0).callTarget();
-        assertDeepEquals(MethodCallTargetNode.InvokeKind.Special, target.invokeKind());
-        assertDeepEquals("HotSpotMethod<Integer.intValue()>", target.targetMethod().toString());
-    }
-
-    /*
-     * TODO ClassCastException known to fail --- either Deopt or throw ObjectGetClassNode The latter
-     * might lead to direct jump to EH if present.
-     */
-    @SuppressWarnings("unused")
-    public int t9Snippet(Object o) {
-        try {
-            if (o instanceof Number) {
-                String s = (String) o;
-                /*
-                 * make a long story short: replace the above with throw new ClassCastException (ok,
-                 * actual type of o unknown).
-                 */
-                return 1;
-            }
-        } catch (ClassCastException e) {
-            return 2;
-        }
-        return 3;
-    }
-
-    /*
-     * "Partial evaluation" via canonicalization of an expression (in the last return statement) one
-     * of whose leaf sub-expressions was determined to be constant.
-     */
-    @SuppressWarnings("unused")
-    public Object partialEvalSnippet01(Object o, boolean b) {
-        if (o == null) {
-            return o; // turned into "return null;"
-        } else {
-            Number z;
-            if (b) {
-                z = (Number) o;
-            } else {
-                z = (Integer) o;
-            }
-            return o instanceof String ? this : null; // turned into "return null;"
-        }
-    }
-
-    @Test
-    public void partialEvalTest01() {
-        String snippet = "partialEvalSnippet01";
-
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        canonicalize(graph);
-        dce(graph);
-
-        List<ReturnNode> returnNodes = getNodes(graph, ReturnNode.class);
-        assertDeepEquals(2, returnNodes.size());
-        Iterator<ReturnNode> iter = returnNodes.iterator();
-
-        ValueNode c1 = GraphUtil.unproxify(iter.next().result());
-        ValueNode c2 = GraphUtil.unproxify(iter.next().result());
-        assert !iter.hasNext();
-
-        Assert.assertTrue(c1.isNullConstant());
-        Assert.assertTrue(c2.isNullConstant());
-    }
-
-    public static class C {
-        public int f;
-    }
-
-    /*
-     * A previous (assumed successful) instanceof check is reused later on to remove a checkcast.
-     */
-    public void deduplicateInstanceOfSnippet(Object o) {
-        ((C) o).f = ((C) o).f; // boils down to a single instanceof test
-    }
-
-    @Test
-    public void deduplicateInstanceOfTest() {
-        String snippet = "deduplicateInstanceOfSnippet";
-        StructuredGraph graph = afterFlowSensitiveReduce(snippet);
-        List<InstanceOfNode> ioNodes = getNodes(graph, InstanceOfNode.class);
-        assertDeepEquals(1, ioNodes.size());
-
-    }
-
-    // ---------------------------------------------
-    // ----------------- UTILITIES -----------------
-    // ---------------------------------------------
-
-    private PhaseContext getPhaseContext() {
-        return new PhaseContext(getProviders(), null);
-    }
-
-    private static StructuredGraph dce(StructuredGraph graph) {
-        new DeadCodeEliminationPhase().apply(graph);
-        return graph;
-    }
-
-    private StructuredGraph canonicalize(StructuredGraph graph) {
-        new CanonicalizerPhase(true).apply(graph, getPhaseContext());
-        return graph;
-    }
-
-    private StructuredGraph flowSensitiveReduce(StructuredGraph graph) {
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, getPhaseContext());
-        return graph;
-    }
-
-    public static <N extends Node> List<N> getNodes(StructuredGraph graph, Class<N> nodeClass) {
-        return graph.getNodes().filter(nodeClass).snapshot();
-    }
-
-    public <N extends Node> void nodeCountEquals(StructuredGraph graph, Class<N> nodeClass, int expected) {
-        assertDeepEquals(expected, getNodes(graph, nodeClass).size());
-    }
-
-    public StructuredGraph afterFlowSensitiveReduce(String snippet) {
-        StructuredGraph before = canonicalize(parseEager(snippet));
-        // visualize(before, snippet + "-before");
-        StructuredGraph result = flowSensitiveReduce(before);
-        // visualize(result, snippet + "-after");
-        return result;
-    }
-
-    public StructuredGraph visualize(StructuredGraph graph, String title) {
-        DebugConfig debugConfig = DebugScope.getConfig();
-        DebugConfig fixedConfig = Debug.fixedConfig(0, Debug.DEFAULT_LOG_LEVEL, false, false, false, false, debugConfig.dumpHandlers(), debugConfig.verifyHandlers(), debugConfig.output());
-        try (DebugConfigScope s = Debug.setConfig(fixedConfig)) {
-            Debug.dump(graph, title);
-
-            return graph;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FlowSensitiveReductionTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,289 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.compiler.test;
-
-import static com.oracle.graal.nodes.ConstantNode.*;
-import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
-import com.oracle.graal.phases.tiers.*;
-
-/**
- * Collection of tests for {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase}
- * including those that triggered bugs in this phase.
- */
-public class FlowSensitiveReductionTest extends GraalCompilerTest {
-
-    public static Object field;
-
-    static class Entry {
-
-        final String name;
-
-        public Entry(String name) {
-            this.name = name;
-        }
-    }
-
-    static class EntryWithNext extends Entry {
-
-        public EntryWithNext(String name, Entry next) {
-            super(name);
-            this.next = next;
-        }
-
-        final Entry next;
-    }
-
-    public static Entry search(Entry start, String name, Entry alternative) {
-        Entry current = start;
-        do {
-            while (current instanceof EntryWithNext) {
-                if (name != null && current.name == name) {
-                    current = null;
-                } else {
-                    Entry next = ((EntryWithNext) current).next;
-                    current = next;
-                }
-            }
-
-            if (current != null) {
-                if (current.name.equals(name)) {
-                    return current;
-                }
-            }
-            if (current == alternative) {
-                return null;
-            }
-            current = alternative;
-
-        } while (true);
-    }
-
-    /**
-     * This test presents a code pattern that triggered a bug where a (non-eliminated) checkcast
-     * caused an enclosing instanceof (for the same object and target type) to be incorrectly
-     * eliminated.
-     */
-    @Test
-    public void testReanchoringIssue() {
-        Entry end = new Entry("end");
-        EntryWithNext e1 = new EntryWithNext("e1", end);
-        EntryWithNext e2 = new EntryWithNext("e2", e1);
-
-        test("search", e2, "e3", new Entry("e4"));
-    }
-
-    @SuppressWarnings("unused")
-    public static int testNullnessSnippet(Object a, Object b) {
-        if (a == null) {
-            if (a == b) {
-                if (b == null) {
-                    return 1;
-                } else {
-                    return -2;
-                }
-            } else {
-                if (b == null) {
-                    return -3;
-                } else {
-                    return 4;
-                }
-            }
-        } else {
-            if (a == b) {
-                if (b == null) {
-                    return -5;
-                } else {
-                    return 6;
-                }
-            } else {
-                if (b == null) {
-                    return 7;
-                } else {
-                    return 8;
-                }
-            }
-        }
-    }
-
-    @Test
-    public void testNullness() {
-        test("testNullnessSnippet", null, null);
-        test("testNullnessSnippet", null, new Object());
-        test("testNullnessSnippet", new Object(), null);
-        test("testNullnessSnippet", new Object(), new Object());
-
-        StructuredGraph graph = parseEager("testNullnessSnippet");
-        PhaseContext context = new PhaseContext(getProviders(), null);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
-        new CanonicalizerPhase(true).apply(graph, context);
-        for (ConstantNode constant : getConstantNodes(graph)) {
-            assertTrue("unexpected constant: " + constant, constant.isNullConstant() || constant.asJavaConstant().asInt() > 0);
-        }
-    }
-
-    @SuppressWarnings("unused")
-    public static int testDisjunctionSnippet(Object a) {
-        try {
-            if (a instanceof Integer) {
-                if (a == null) {
-                    return -1;
-                } else {
-                    return 2;
-                }
-            } else {
-                return 3;
-            }
-        } finally {
-            field = null;
-        }
-    }
-
-    @Test
-    public void testDisjunction() {
-        StructuredGraph graph = parseEager("testDisjunctionSnippet");
-        new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
-        IfNode ifNode = (IfNode) graph.start().next();
-        InstanceOfNode instanceOf = (InstanceOfNode) ifNode.condition();
-        IsNullNode x = graph.unique(new IsNullNode(graph.getParameter(0)));
-        InstanceOfNode y = instanceOf;
-        ShortCircuitOrNode disjunction = graph.unique(new ShortCircuitOrNode(x, false, y, false, NOT_FREQUENT_PROBABILITY));
-        LogicNegationNode negation = graph.unique(new LogicNegationNode(disjunction));
-        ifNode.setCondition(negation);
-        new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, new PhaseContext(getProviders(), null));
-        new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
-        for (ConstantNode constant : getConstantNodes(graph)) {
-            assertTrue("unexpected constant: " + constant, constant.isNullConstant() || constant.asJavaConstant().asInt() > 0);
-        }
-    }
-
-    public static int testInvokeSnippet(Number n) {
-        if (n instanceof Integer) {
-            return n.intValue();
-        } else {
-            return 1;
-        }
-    }
-
-    @Test
-    public void testInvoke() {
-        test("testInvokeSnippet", new Integer(16));
-        StructuredGraph graph = parseEager("testInvokeSnippet");
-        PhaseContext context = new PhaseContext(getProviders(), null);
-        new CanonicalizerPhase(true).apply(graph, context);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
-
-        InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first();
-        assertDeepEquals(InvokeKind.Special, ((MethodCallTargetNode) invoke.callTarget()).invokeKind());
-    }
-
-    public static void testTypeMergingSnippet(Object o, boolean b) {
-        if (b) {
-            if (!(o instanceof Double)) {
-                return;
-            }
-        } else {
-            if (!(o instanceof Integer)) {
-                return;
-            }
-        }
-
-        /*
-         * For this test the conditional elimination has to correctly merge the type information it
-         * has about o, so that it can remove the check on Number.
-         */
-        if (!(o instanceof Number)) {
-            field = o;
-        }
-    }
-
-    @Test
-    public void testTypeMerging() {
-        StructuredGraph graph = parseEager("testTypeMergingSnippet");
-        PhaseContext context = new PhaseContext(getProviders(), null);
-        new CanonicalizerPhase(true).apply(graph, context);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
-        new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
-
-        assertDeepEquals(0, graph.getNodes().filter(StoreFieldNode.class).count());
-    }
-
-    public static String testInstanceOfCheckCastSnippet(Object e) {
-        if (e instanceof Entry) {
-            return ((Entry) e).name;
-        }
-        return null;
-    }
-
-    @Test
-    public void testInstanceOfCheckCast() {
-        StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet");
-        PhaseContext context = new PhaseContext(getProviders(), null);
-        new CanonicalizerPhase(true).apply(graph, context);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
-        new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
-
-        assertDeepEquals(0, graph.getNodes().filter(CheckCastNode.class).count());
-    }
-
-    public static int testDuplicateNullChecksSnippet(Object a) {
-        if (a == null) {
-            return 2;
-        }
-        try {
-            return ((Integer) a).intValue();
-        } catch (ClassCastException e) {
-            return 0;
-        }
-    }
-
-    @Test
-    @Ignore
-    public void testDuplicateNullChecks() {
-        // This tests whether explicit null checks properly eliminate later null guards. Currently
-        // it's failing.
-        StructuredGraph graph = parseEager("testDuplicateNullChecksSnippet");
-        CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
-        PhaseContext context = new PhaseContext(getProviders(), null);
-
-        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
-        canonicalizer.apply(graph, context);
-        new FloatingReadPhase().apply(graph);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
-        canonicalizer.apply(graph, context);
-
-        assertDeepEquals(1, graph.getNodes().filter(GuardNode.class).count());
-    }
-
-}
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -142,21 +142,21 @@
 
             @Override
             protected void run(StructuredGraph graph) {
-                assert checkHighTierGraph(graph);
+                assert checkHighTierGraph(graph) : "failed HighTier graph check";
             }
         });
         ret.getMidTier().appendPhase(new Phase("CheckGraphPhase") {
 
             @Override
             protected void run(StructuredGraph graph) {
-                assert checkMidTierGraph(graph);
+                assert checkMidTierGraph(graph) : "failed MidTier graph check";
             }
         });
         ret.getLowTier().appendPhase(new Phase("CheckGraphPhase") {
 
             @Override
             protected void run(StructuredGraph graph) {
-                assert checkLowTierGraph(graph);
+                assert checkLowTierGraph(graph) : "failed LowTier graph check";
             }
         });
         return ret;
@@ -217,7 +217,7 @@
     protected int countUnusedConstants(StructuredGraph graph) {
         int total = 0;
         for (ConstantNode node : getConstantNodes(graph)) {
-            if (node.usages().isEmpty()) {
+            if (node.hasNoUsages()) {
                 total++;
             }
         }
@@ -319,7 +319,7 @@
                             canonicalId.set(node, id);
                         }
                         String name = node instanceof ConstantNode && checkConstants ? node.toString(Verbosity.Name) : node.getClass().getSimpleName();
-                        result.append("  " + id + "|" + name + (excludeVirtual ? "\n" : "    (" + node.usages().count() + ")\n"));
+                        result.append("  " + id + "|" + name + (excludeVirtual ? "\n" : "    (" + node.getUsageCount() + ")\n"));
                     }
                 }
             }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraphScheduleTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraphScheduleTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
 public class GraphScheduleTest extends GraalCompilerTest {
 
     protected void assertOrderedAfterSchedule(StructuredGraph graph, Node a, Node b) {
-        SchedulePhase ibp = new SchedulePhase();
+        SchedulePhase ibp = new SchedulePhase(SchedulePhase.SchedulingStrategy.LATEST);
         ibp.apply(graph);
         assertOrderedAfterSchedule(ibp, a, b);
     }
@@ -45,7 +45,7 @@
         Block aBlock = nodeToBlock.get(a);
 
         if (bBlock == aBlock) {
-            List<ScheduledNode> instructions = ibp.nodesFor(bBlock);
+            List<ValueNode> instructions = ibp.nodesFor(bBlock);
             Assert.assertTrue(instructions.indexOf(b) > instructions.indexOf(a));
         } else {
             Block block = bBlock;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -45,7 +45,6 @@
 import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.common.inlining.*;
 import com.oracle.graal.phases.schedule.*;
-import com.oracle.graal.phases.schedule.SchedulePhase.MemoryScheduling;
 import com.oracle.graal.phases.schedule.SchedulePhase.SchedulingStrategy;
 import com.oracle.graal.phases.tiers.*;
 
@@ -459,7 +458,7 @@
 
     @Test
     public void testBlockSchedule2() {
-        SchedulePhase schedule = getFinalSchedule("testBlockSchedule2Snippet", TestMode.WITHOUT_FRAMESTATES, MemoryScheduling.OPTIMAL, SchedulingStrategy.LATEST);
+        SchedulePhase schedule = getFinalSchedule("testBlockSchedule2Snippet", TestMode.WITHOUT_FRAMESTATES, SchedulingStrategy.LATEST);
         assertReadWithinStartBlock(schedule, false);
         assertReadWithinAllReturnBlocks(schedule, false);
         assertReadAndWriteInSameBlock(schedule, false);
@@ -593,14 +592,10 @@
     }
 
     private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode) {
-        return getFinalSchedule(snippet, mode, MemoryScheduling.OPTIMAL);
+        return getFinalSchedule(snippet, mode, SchedulingStrategy.LATEST_OUT_OF_LOOPS);
     }
 
-    private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode, final MemoryScheduling memsched) {
-        return getFinalSchedule(snippet, mode, memsched, SchedulingStrategy.LATEST_OUT_OF_LOOPS);
-    }
-
-    private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode, final MemoryScheduling memsched, final SchedulingStrategy schedulingStrategy) {
+    private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
         final StructuredGraph graph = parseEager(snippet);
         try (Scope d = Debug.scope("FloatingReadTest", graph)) {
             try (OverrideScope s = OptionValue.override(OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false)) {
@@ -633,7 +628,7 @@
                 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
                 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
 
-                SchedulePhase schedule = new SchedulePhase(schedulingStrategy, memsched);
+                SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
                 schedule.apply(graph);
                 assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
                 return schedule;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NodePosIteratorTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NodePosIteratorTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
 public class NodePosIteratorTest extends GraalCompilerTest {
 
     @NodeInfo
-    static class TestNode extends Node {
+    static final class TestNode extends Node {
         @Successor Node s1;
         @Successor Node s2;
         @Successor NodeSuccessorList<Node> stail;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -73,7 +73,7 @@
                 if (rn.location() instanceof ConstantLocationNode && rn.object().stamp() instanceof ObjectStamp) {
                     long disp = ((ConstantLocationNode) rn.location()).getDisplacement();
                     ResolvedJavaType receiverType = StampTool.typeOrNull(rn.object());
-                    ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(disp);
+                    ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(disp, rn.getKind());
 
                     assert field != null : "Node " + rn + " tries to access a field which doesn't exists for this type";
                     if (field.getName().equals("x")) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,7 +28,6 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
 import com.oracle.graal.phases.tiers.*;
 
 /**
@@ -104,28 +103,6 @@
         }
     }
 
-    @Test
-    public void test4() {
-        test("test4Snippet", "referenceSnippet2");
-    }
-
-    public static int test4Snippet(int a, int b) {
-        if (a > b) {
-            if (a <= b) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
-    @Test
-    public void test5() {
-        test("test5Snippet", "referenceSnippet3");
-    }
-
     public static int referenceSnippet3(int a, int b) {
         if (a == b) {
             return 1;
@@ -134,18 +111,6 @@
         }
     }
 
-    public static int test5Snippet(int a, int b) {
-        if (a == b) {
-            if (a != b) {
-                return 3;
-            } else {
-                return 1;
-            }
-        } else {
-            return 2;
-        }
-    }
-
     @Test(expected = AssertionError.class)
     public void test6() {
         test("test6Snippet", "referenceSnippet3");
@@ -169,7 +134,6 @@
         Debug.dump(graph, "Graph");
         Assumptions assumptions = new Assumptions(false);
         PhaseContext context = new PhaseContext(getProviders(), assumptions);
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, context);
         new CanonicalizerPhase(true).apply(graph, context);
         StructuredGraph referenceGraph = parseEager(referenceSnippet);
         assertEquals(referenceGraph, graph);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -45,15 +45,15 @@
         AbstractEndNode trueEnd = graph.add(new EndNode());
         AbstractEndNode falseEnd = graph.add(new EndNode());
 
-        BeginNode trueBegin = graph.add(new BeginNode());
+        AbstractBeginNode trueBegin = graph.add(new BeginNode());
         trueBegin.setNext(trueEnd);
-        BeginNode falseBegin = graph.add(new BeginNode());
+        AbstractBeginNode falseBegin = graph.add(new BeginNode());
         falseBegin.setNext(falseEnd);
 
         IfNode ifNode = graph.add(new IfNode(null, trueBegin, falseBegin, 0.5));
         graph.start().setNext(ifNode);
 
-        MergeNode merge = graph.add(new MergeNode());
+        AbstractMergeNode merge = graph.add(new MergeNode());
         merge.addForwardEnd(trueEnd);
         merge.addForwardEnd(falseEnd);
         ReturnNode returnNode = graph.add(new ReturnNode(null));
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,6 @@
 import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
 import com.oracle.graal.phases.schedule.*;
 import com.oracle.graal.phases.tiers.*;
 
@@ -45,30 +44,6 @@
 public class TypeSystemTest extends GraalCompilerTest {
 
     @Test
-    public void test1() {
-        testHelper("test1Snippet", CheckCastNode.class);
-    }
-
-    public static int test1Snippet(Object a) {
-        if (a instanceof Boolean) {
-            return ((Boolean) a).booleanValue() ? 0 : 1;
-        }
-        return 1;
-    }
-
-    @Test
-    public void test2() {
-        testHelper("test2Snippet", CheckCastNode.class);
-    }
-
-    public static int test2Snippet(Object a) {
-        if (a instanceof Integer) {
-            return ((Number) a).intValue();
-        }
-        return 1;
-    }
-
-    @Test
     public void test3() {
         test("test3Snippet", "referenceSnippet3");
     }
@@ -242,13 +217,13 @@
     }
 
     private static void outputNode(Node node) {
-        TTY.print("  " + node + "    (usage count: " + node.usages().count() + ") (inputs:");
+        TTY.print("  " + node + "    (usage count: " + node.getUsageCount() + ") (inputs:");
         for (Node input : node.inputs()) {
             TTY.print(" " + input.toString(Verbosity.Id));
         }
         TTY.println(")");
-        if (node instanceof MergeNode) {
-            for (PhiNode phi : ((MergeNode) node).phis()) {
+        if (node instanceof AbstractMergeNode) {
+            for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
                 outputNode(phi);
             }
         }
@@ -258,7 +233,6 @@
         StructuredGraph graph = parseEager(snippet);
         Assumptions assumptions = new Assumptions(false);
         new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
-        new FlowSensitiveReductionPhase(getMetaAccess()).apply(graph, new PhaseContext(getProviders(), assumptions));
         new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
         Debug.dump(graph, "Graph " + snippet);
         Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -177,7 +177,7 @@
     @SafeVarargs
     protected final void testPartialEscapeAnalysis(final String snippet, double expectedProbability, int expectedCount, Class<? extends Node>... invalidNodeClasses) {
         prepareGraph(snippet, false);
-        for (MergeNode merge : graph.getNodes(MergeNode.class)) {
+        for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.class)) {
             merge.setStateAfter(null);
         }
         new DeadCodeEliminationPhase().apply(graph);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Jan 28 19:32:47 2015 +0100
@@ -289,7 +289,7 @@
         }
     }
 
-    private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
+    private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<ValueNode>> blockMap) {
         if (lirGenRes.getLIR().getLIRforBlock(b) == null) {
             for (Block pred : b.getPredecessors()) {
                 if (!b.isLoopHeader() || !pred.isLoopEnd()) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Wed Jan 28 19:32:47 2015 +0100
@@ -52,6 +52,9 @@
     public static final OptionValue<String> Log = new OptionValue<>(null);
     @Option(help = "Pattern for filtering debug scope output based on method context (see MethodFilter)", type = OptionType.Debug)
     public static final OptionValue<String> MethodFilter = new OptionValue<>(null);
+    @Option(help = "Only check MethodFilter against the root method in the context if true, otherwise check all methods", type = OptionType.Debug)
+    public static final OptionValue<Boolean> MethodFilterRootOnly = new OptionValue<>(false);
+
     @Option(help = "How to print metric and timing values:%n" +
                    "Name - aggregate by unqualified name%n" +
                    "Partial - aggregate by partially qualified name (e.g., A.B.C.D.Counter and X.Y.Z.D.Counter will be merged to D.Counter)%n" +
@@ -205,18 +208,31 @@
         if (methodFilter == null && extraFilters.isEmpty()) {
             return true;
         } else {
+            JavaMethod lastMethod = null;
             for (Object o : Debug.context()) {
                 if (extraFilters.contains(o)) {
                     return true;
                 } else if (methodFilter != null) {
                     JavaMethod method = asJavaMethod(o);
                     if (method != null) {
-                        if (com.oracle.graal.compiler.MethodFilter.matches(methodFilter, method)) {
-                            return true;
+                        if (!MethodFilterRootOnly.getValue()) {
+                            if (com.oracle.graal.compiler.MethodFilter.matches(methodFilter, method)) {
+                                return true;
+                            }
+                        } else {
+                            /*
+                             * The context values operate as a stack so if we want MethodFilter to
+                             * only apply to the root method we have to check only the last method
+                             * seen.
+                             */
+                            lastMethod = method;
                         }
                     }
                 }
             }
+            if (lastMethod != null && com.oracle.graal.compiler.MethodFilter.matches(methodFilter, lastMethod)) {
+                return true;
+            }
             return false;
         }
     }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/MethodFilter.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/MethodFilter.java	Wed Jan 28 19:32:47 2015 +0100
@@ -166,6 +166,13 @@
         }
     }
 
+    /**
+     * Determines if the class part of this filter matches a given class name.
+     */
+    public boolean matchesClassName(String className) {
+        return clazz == null || clazz.matcher(className).matches();
+    }
+
     public boolean matches(JavaMethod o) {
         // check method name first, since MetaUtil.toJavaName is expensive
         if (methodName != null && !methodName.matcher(o.getName()).matches()) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -57,10 +57,12 @@
         // collect all VirtualObjectField instances:
         FrameState current = topState;
         do {
-            for (EscapeObjectState state : current.virtualObjectMappings()) {
-                if (!objectStates.containsKey(state.object())) {
-                    if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) {
-                        objectStates.put(state.object(), state);
+            if (current.virtualObjectMappingCount() > 0) {
+                for (EscapeObjectState state : current.virtualObjectMappings()) {
+                    if (!objectStates.containsKey(state.object())) {
+                        if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) {
+                            objectStates.put(state.object(), state);
+                        }
                     }
                 }
             }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -158,7 +158,7 @@
      */
     public void setMatchResult(ValueNode x, Value operand) {
         assert operand.equals(ComplexMatchValue.INTERIOR_MATCH) || operand instanceof ComplexMatchValue;
-        assert operand instanceof ComplexMatchValue || x.usages().count() == 1 : "interior matches must be single user";
+        assert operand instanceof ComplexMatchValue || x.getUsageCount() == 1 : "interior matches must be single user";
         assert nodeOperands != null && nodeOperands.get(x) == null : "operand cannot be set twice";
         assert !(x instanceof VirtualObjectNode);
         nodeOperands.set(x, operand);
@@ -185,7 +185,7 @@
         gen.append(op);
     }
 
-    public void doBlock(Block block, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
+    public void doBlock(Block block, StructuredGraph graph, BlockMap<List<ValueNode>> blockMap) {
         gen.doBlockStart(block);
 
         if (block == gen.getResult().getLIR().getControlFlowGraph().getStartBlock()) {
@@ -195,44 +195,41 @@
             assert block.getPredecessorCount() > 0;
         }
 
-        List<ScheduledNode> nodes = blockMap.get(block);
+        List<ValueNode> nodes = blockMap.get(block);
 
         // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
         // of instructions
         matchComplexExpressions(nodes);
 
         for (int i = 0; i < nodes.size(); i++) {
-            Node instr = nodes.get(i);
+            ValueNode valueNode = nodes.get(i);
             if (Options.TraceLIRGeneratorLevel.getValue() >= 3) {
-                TTY.println("LIRGen for " + instr);
+                TTY.println("LIRGen for " + valueNode);
             }
-            if (instr instanceof ValueNode) {
-                ValueNode valueNode = (ValueNode) instr;
-                Value operand = getOperand(valueNode);
-                if (operand == null) {
-                    if (!peephole(valueNode)) {
-                        try {
-                            doRoot((ValueNode) instr);
-                        } catch (GraalInternalError e) {
-                            throw GraalGraphInternalError.transformAndAddContext(e, instr);
-                        } catch (Throwable e) {
-                            throw new GraalGraphInternalError(e).addContext(instr);
-                        }
+            Value operand = getOperand(valueNode);
+            if (operand == null) {
+                if (!peephole(valueNode)) {
+                    try {
+                        doRoot(valueNode);
+                    } catch (GraalInternalError e) {
+                        throw GraalGraphInternalError.transformAndAddContext(e, valueNode);
+                    } catch (Throwable e) {
+                        throw new GraalGraphInternalError(e).addContext(valueNode);
                     }
-                } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
-                    // Doesn't need to be evaluated
-                    Debug.log("interior match for %s", valueNode);
-                } else if (operand instanceof ComplexMatchValue) {
-                    Debug.log("complex match for %s", valueNode);
-                    ComplexMatchValue match = (ComplexMatchValue) operand;
-                    operand = match.evaluate(this);
-                    if (operand != null) {
-                        setResult(valueNode, operand);
-                    }
-                } else {
-                    // There can be cases in which the result of an instruction is already set
-                    // before by other instructions.
                 }
+            } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
+                // Doesn't need to be evaluated
+                Debug.log("interior match for %s", valueNode);
+            } else if (operand instanceof ComplexMatchValue) {
+                Debug.log("complex match for %s", valueNode);
+                ComplexMatchValue match = (ComplexMatchValue) operand;
+                operand = match.evaluate(this);
+                if (operand != null) {
+                    setResult(valueNode, operand);
+                }
+            } else {
+                // There can be cases in which the result of an instruction is already set
+                // before by other instructions.
             }
         }
 
@@ -253,23 +250,19 @@
         gen.doBlockEnd(block);
     }
 
-    protected void matchComplexExpressions(List<ScheduledNode> nodes) {
+    protected void matchComplexExpressions(List<ValueNode> nodes) {
         if (matchRules != null) {
             try (Scope s = Debug.scope("MatchComplexExpressions")) {
                 if (LogVerbose.getValue()) {
                     int i = 0;
-                    for (ScheduledNode node : nodes) {
-                        Debug.log("%d: (%s) %1S", i++, node.usages().count(), node);
+                    for (ValueNode node : nodes) {
+                        Debug.log("%d: (%s) %1S", i++, node.getUsageCount(), node);
                     }
                 }
 
                 // Match the nodes in backwards order to encourage longer matches.
                 for (int index = nodes.size() - 1; index >= 0; index--) {
-                    ScheduledNode snode = nodes.get(index);
-                    if (!(snode instanceof ValueNode)) {
-                        continue;
-                    }
-                    ValueNode node = (ValueNode) snode;
+                    ValueNode node = nodes.get(index);
                     if (getOperand(node) != null) {
                         continue;
                     }
@@ -338,7 +331,7 @@
     }
 
     @Override
-    public void visitMerge(MergeNode x) {
+    public void visitMerge(AbstractMergeNode x) {
     }
 
     @Override
@@ -353,7 +346,7 @@
     public void visitLoopEnd(LoopEndNode x) {
     }
 
-    private void moveToPhi(MergeNode merge, AbstractEndNode pred) {
+    private void moveToPhi(AbstractMergeNode merge, AbstractEndNode pred) {
         if (Options.TraceLIRGeneratorLevel.getValue() >= 1) {
             TTY.println("MOVE TO PHI from " + pred + " to " + merge);
         }
@@ -599,7 +592,7 @@
     }
 
     @Override
-    public void emitOverflowCheckBranch(BeginNode overflowSuccessor, BeginNode next, Stamp stamp, double probability) {
+    public void emitOverflowCheckBranch(AbstractBeginNode overflowSuccessor, AbstractBeginNode next, Stamp stamp, double probability) {
         LIRKind cmpKind = getLIRGeneratorTool().getLIRKind(stamp);
         gen.emitOverflowCheckBranch(getLIRBlock(overflowSuccessor), getLIRBlock(next), cmpKind, probability);
     }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchContext.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchContext.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,7 +41,7 @@
 
     private final ValueNode root;
 
-    private final List<ScheduledNode> nodes;
+    private final List<ValueNode> nodes;
 
     private final MatchStatement rule;
 
@@ -65,7 +65,7 @@
         }
     }
 
-    public MatchContext(NodeLIRBuilder builder, MatchStatement rule, int index, ValueNode node, List<ScheduledNode> nodes) {
+    public MatchContext(NodeLIRBuilder builder, MatchStatement rule, int index, ValueNode node, List<ValueNode> nodes) {
         this.builder = builder;
         this.rule = rule;
         this.root = node;
@@ -99,7 +99,7 @@
     public Result validate() {
         // Ensure that there's no unsafe work in between these operations.
         for (int i = startIndex; i <= endIndex; i++) {
-            ScheduledNode node = nodes.get(i);
+            ValueNode node = nodes.get(i);
             if (node instanceof VirtualObjectNode || node instanceof FloatingNode) {
                 // The order of evaluation of these nodes controlled by data dependence so they
                 // don't interfere with this match.
@@ -108,8 +108,8 @@
                 if (LogVerbose.getValue()) {
                     Debug.log("unexpected node %s", node);
                     for (int j = startIndex; j <= endIndex; j++) {
-                        ScheduledNode theNode = nodes.get(j);
-                        Debug.log("%s(%s) %1s", (consumed != null && consumed.contains(theNode) || theNode == root) ? "*" : " ", theNode.usages().count(), theNode);
+                        ValueNode theNode = nodes.get(j);
+                        Debug.log("%s(%s) %1s", (consumed != null && consumed.contains(theNode) || theNode == root) ? "*" : " ", theNode.getUsageCount(), theNode);
                     }
                 }
                 return Result.notSafe(node, rule.getPattern());
@@ -147,7 +147,7 @@
      * @return Result.OK if the node can be safely consumed.
      */
     public Result consume(ValueNode node) {
-        assert node.usages().count() <= 1 : "should have already been checked";
+        assert node.getUsageCount() <= 1 : "should have already been checked";
 
         // Check NOT_IN_BLOCK first since that usually implies ALREADY_USED
         int index = nodes.indexOf(node);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchPattern.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchPattern.java	Wed Jan 28 19:32:47 2015 +0100
@@ -50,11 +50,11 @@
     static class Result {
         final MatchResultCode code;
 
-        final ScheduledNode node;
+        final ValueNode node;
 
         final MatchPattern matcher;
 
-        Result(MatchResultCode result, ScheduledNode node, MatchPattern matcher) {
+        Result(MatchResultCode result, ValueNode node, MatchPattern matcher) {
             this.code = result;
             this.node = node;
             this.matcher = matcher;
@@ -90,12 +90,12 @@
             return Debug.isEnabled() ? new Result(MatchResultCode.TOO_MANY_USERS, node, matcher) : CACHED_TOO_MANY_USERS;
         }
 
-        static Result notInBlock(ScheduledNode node, MatchPattern matcher) {
+        static Result notInBlock(ValueNode node, MatchPattern matcher) {
             MatchResult_NOT_IN_BLOCK.increment();
             return Debug.isEnabled() ? new Result(MatchResultCode.NOT_IN_BLOCK, node, matcher) : CACHED_NOT_IN_BLOCK;
         }
 
-        static Result notSafe(ScheduledNode node, MatchPattern matcher) {
+        static Result notSafe(ValueNode node, MatchPattern matcher) {
             MatchResult_NOT_SAFE.increment();
             return Debug.isEnabled() ? new Result(MatchResultCode.NOT_SAFE, node, matcher) : CACHED_NOT_SAFE;
         }
@@ -251,7 +251,7 @@
         }
 
         if (singleUser && !atRoot) {
-            if (node.usages().count() > 1) {
+            if (node.getUsageCount() > 1) {
                 return Result.tooManyUsers(node, statement.getPattern());
             }
         }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchStatement.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchStatement.java	Wed Jan 28 19:32:47 2015 +0100
@@ -80,7 +80,7 @@
      * @return true if the statement matched something and set a {@link ComplexMatchResult} to be
      *         evaluated by the NodeLIRBuilder.
      */
-    public boolean generate(NodeLIRBuilder builder, int index, ValueNode node, List<ScheduledNode> nodes) {
+    public boolean generate(NodeLIRBuilder builder, int index, ValueNode node, List<ValueNode> nodes) {
         assert index == nodes.indexOf(node);
         // Check that the basic shape matches
         Result result = pattern.matchShape(node, this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/GraphChangeMonitoringPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.compiler.phases;
+
+import static com.oracle.graal.graph.Graph.NodeEvent.*;
+
+import java.util.stream.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
+import com.oracle.graal.graph.Graph.NodeEventScope;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.common.util.*;
+import com.oracle.graal.phases.tiers.*;
+
+/**
+ * A utility phase for detecting when a phase would change the graph and reporting extra information
+ * about the effects. The phase is first run on a copy of the graph and if a change in that graph is
+ * detected then it's rerun on the original graph inside a new debug scope under
+ * GraphChangeMonitoringPhase. The message argument can be used to distinguish between the same
+ * phase run at different points.
+ *
+ * @param <C>
+ */
+public class GraphChangeMonitoringPhase<C extends PhaseContext> extends PhaseSuite<C> {
+
+    private final String message;
+
+    public GraphChangeMonitoringPhase(String message, BasePhase<C> phase) {
+        super();
+        this.message = message;
+        appendPhase(phase);
+    }
+
+    public GraphChangeMonitoringPhase(String message) {
+        super();
+        this.message = message;
+    }
+
+    @Override
+    protected void run(StructuredGraph graph, C context) {
+        HashSetNodeEventListener listener = new HashSetNodeEventListener().exclude(INPUT_CHANGED);
+        try (NodeEventScope s = graph.trackNodeEvents(listener)) {
+            StructuredGraph graphCopy = graph.copy();
+            try (Scope s2 = Debug.sandbox("WithoutMonitoring", null)) {
+                super.run(graphCopy, context);
+            } catch (Throwable t) {
+                Debug.handle(t);
+            }
+        }
+        if (!listener.getNodes().isEmpty()) {
+            // rerun it on the real graph in a new Debug scope so Dump and Log can find it.
+            listener = new HashSetNodeEventListener().exclude(INPUT_CHANGED);
+            try (NodeEventScope s = graph.trackNodeEvents(listener)) {
+                try (Scope s2 = Debug.scope("GraphChangeMonitoring." + getName() + "-" + message)) {
+                    if (Debug.isDumpEnabled(BasePhase.PHASE_DUMP_LEVEL)) {
+                        Debug.dump(BasePhase.PHASE_DUMP_LEVEL, graph, "*** Before phase %s", getName());
+                    }
+                    super.run(graph, context);
+                    if (Debug.isDumpEnabled(BasePhase.PHASE_DUMP_LEVEL)) {
+                        Debug.dump(BasePhase.PHASE_DUMP_LEVEL, graph, "*** After phase %s", getName());
+                    }
+                }
+                Debug.log("*** %s %s %s\n", message, graph, listener.getNodes().stream().filter(e -> !e.isAlive()).collect(Collectors.toSet()));
+            }
+        } else {
+            // Go ahead and run it normally even though it should have no effect
+            super.run(graph, context);
+        }
+    }
+}
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,6 @@
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
 import com.oracle.graal.phases.common.inlining.*;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.virtual.phases.ea.*;
@@ -60,14 +59,9 @@
                 appendPhase(new InliningPhase(canonicalizer));
                 appendPhase(new DeadCodeEliminationPhase(Optional));
 
-                boolean reduceOrEliminate = FlowSensitiveReduction.getValue() || ConditionalElimination.getValue();
-                if (reduceOrEliminate && OptCanonicalizer.getValue()) {
+                if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) {
                     appendPhase(canonicalizer);
-                    if (FlowSensitiveReduction.getValue()) {
-                        appendPhase(new IterativeFlowSensitiveReductionPhase(canonicalizer));
-                    } else {
-                        appendPhase(new IterativeConditionalEliminationPhase(canonicalizer));
-                    }
+                    appendPhase(new IterativeConditionalEliminationPhase(canonicalizer));
                 }
             }
         }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Jan 28 19:32:47 2015 +0100
@@ -463,6 +463,19 @@
         }
     }
 
+    public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) {
+        log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+    }
+
+    /**
+     * @see #log(int, String, Object)
+     */
+    public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) {
+        if (ENABLED) {
+            DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+        }
+    }
+
     public static void logv(String format, Object... args) {
         logv(DEFAULT_LOG_LEVEL, format, args);
     }
@@ -700,6 +713,48 @@
         return null;
     }
 
+    public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4) {
+        return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4);
+    }
+
+    /**
+     * @see #logAndIndent(int, String, Object)
+     */
+    public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4) {
+        if (ENABLED) {
+            return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4);
+        }
+        return null;
+    }
+
+    public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
+        return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5);
+    }
+
+    /**
+     * @see #logAndIndent(int, String, Object)
+     */
+    public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
+        if (ENABLED) {
+            return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4, arg5);
+        }
+        return null;
+    }
+
+    public static Indent logAndIndent(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
+        return logAndIndent(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6);
+    }
+
+    /**
+     * @see #logAndIndent(int, String, Object)
+     */
+    public static Indent logAndIndent(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) {
+        if (ENABLED) {
+            return logvAndIndent(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6);
+        }
+        return null;
+    }
+
     /**
      * A convenience function which combines {@link #logv(int, String, Object...)} and
      * {@link #indent()}.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Fingerprint.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2015, 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.debug;
+
+import java.util.*;
+import java.util.stream.*;
+
+/**
+ * Facility for fingerprinting execution.
+ */
+public class Fingerprint implements AutoCloseable {
+
+    public static final String ENABLED_PROPERTY_NAME = "graal.fingerprint";
+
+    /**
+     * Determines whether fingerprinting is enabled. This is set by the
+     * {@value #ENABLED_PROPERTY_NAME} system property when this class is initialized.
+     */
+    public static final boolean ENABLED = Boolean.getBoolean(ENABLED_PROPERTY_NAME);
+
+    private static final ThreadLocal<Fingerprint> current = ENABLED ? new ThreadLocal<>() : null;
+
+    private final List<String> events;
+    private int index;
+
+    /**
+     * Creates an object to record a fingerprint.
+     */
+    public Fingerprint() {
+        events = new ArrayList<>();
+        index = -1;
+    }
+
+    /**
+     * Creates an object to verify execution matches a given fingerprint.
+     *
+     * @param toVerifyAgainst the fingerprint events to verify against
+     */
+    public Fingerprint(List<String> toVerifyAgainst) {
+        this.events = toVerifyAgainst;
+        index = 0;
+    }
+
+    /**
+     * Creates an object to verify execution matches a given fingerprint.
+     *
+     * @param toVerifyAgainst the fingerprint to verify against
+     */
+    public Fingerprint(Fingerprint toVerifyAgainst) {
+        this(toVerifyAgainst.events);
+    }
+
+    public Collection<String> getEvents() {
+        return Collections.unmodifiableCollection(events);
+    }
+
+    /**
+     * Starts fingerprint recording or verification for the current thread. At most one fingerprint
+     * object can be active for any thread.
+     */
+    public Fingerprint open() {
+        if (ENABLED) {
+            assert current.get() == null;
+            current.set(this);
+            return this;
+        }
+        return null;
+    }
+
+    /**
+     * Finishes fingerprint recording or verification for the current thread.
+     */
+    public void close() {
+        if (ENABLED) {
+            assert current.get() == this;
+            current.set(null);
+        }
+    }
+
+    private static final int BREAKPOINT_EVENT = Integer.getInteger(ENABLED_PROPERTY_NAME + ".breakpointEvent", -1);
+
+    /**
+     * Submits an execution event for the purpose of recording or verifying a fingerprint. This must
+     * only be called if {@link #ENABLED} is {@code true}.
+     */
+    public static void submit(String format, Object... args) {
+        assert ENABLED : "fingerprinting must be enabled (-D" + ENABLED_PROPERTY_NAME + "=true)";
+        Fingerprint fingerprint = current.get();
+        if (fingerprint != null) {
+            int eventId = fingerprint.nextEventId();
+            if (eventId == BREAKPOINT_EVENT) {
+                // Set IDE breakpoint on the following line and set the relevant
+                // system property to debug a fingerprint verification error.
+                System.console();
+            }
+            fingerprint.event(String.format(eventId + ": " + format, args));
+        }
+    }
+
+    private int nextEventId() {
+        return index == -1 ? events.size() : index;
+    }
+
+    private static final int MAX_EVENT_TAIL_IN_ERROR_MESSAGE = Integer.getInteger("graal.fingerprint.errorEventTailLength", 50);
+
+    private String tail() {
+        int start = Math.max(index - MAX_EVENT_TAIL_IN_ERROR_MESSAGE, 0);
+        return events.subList(start, index).stream().collect(Collectors.joining(String.format("%n")));
+    }
+
+    private void event(String entry) {
+        if (index == -1) {
+            events.add(entry);
+        } else {
+            if (index > events.size()) {
+                throw new InternalError(String.format("%s%nOriginal fingerprint limit reached", tail()));
+            }
+            String l = events.get(index);
+            if (!l.equals(entry)) {
+                throw new InternalError(String.format("%s%nFingerprint differs at event %d%nexpected: %s%n  actual: %s", tail(), index, l, entry));
+            }
+            index++;
+        }
+    }
+}
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Jan 28 19:32:47 2015 +0100
@@ -57,12 +57,10 @@
                 StringBuilder str = new StringBuilder();
                 printScopeName(str);
                 str.append(indent);
-                if (args.length == 0) {
-                    str.append(msg);
-                } else {
-                    str.append(String.format(msg, args));
-                }
-                str.append(System.lineSeparator());
+                String result = args.length == 0 ? msg : String.format(msg, args);
+                String lineSep = System.lineSeparator();
+                str.append(result.replace(lineSep, lineSep.concat(indent)));
+                str.append(lineSep);
                 output.append(str);
                 lastUsedIndent = this;
             }
@@ -211,11 +209,10 @@
         if (config instanceof TopLevelDebugConfig) {
             return (TopLevelDebugConfig) config;
         } else {
-            PrintStream out = System.out;
             if (config == null) {
-                out.printf("DebugScope.%s ignored because debugging is disabled%n", msg);
+                TTY.println("DebugScope.%s ignored because debugging is disabled", msg);
             } else {
-                out.printf("DebugScope.%s ignored because top level delegate config missing%n", msg);
+                TTY.println("DebugScope.%s ignored because top level delegate config missing", msg);
             }
             return null;
         }
@@ -268,8 +265,7 @@
                 dumpHandler.dump(object, message);
             }
         } else {
-            PrintStream out = System.out;
-            out.println("Forced dump ignored because debugging is disabled - use -G:Dump=xxx option");
+            TTY.println("Forced dump ignored because debugging is disabled - use -G:Dump=xxx option");
         }
     }
 
--- a/graal/com.oracle.graal.gpu/src/com/oracle/graal/gpu/ExternalCompilationResult.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.gpu;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * Represents the output from compiling a method generated by Graal, but executing in a memory and
- * computational subsystem outside the Graal host system.
- * 
- * Output may include the compiled machine code, associated data and references, relocation
- * information, deoptimization information, as this result is generated from a structure graph on
- * the Graal host system.
- */
-public class ExternalCompilationResult extends CompilationResult {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * Address of the point of entry to the external compilation result.
-     */
-    private long entryPoint;
-    private StructuredGraph hostGraph;
-
-    private int[] oopMapArray;
-    private boolean usesAllocation;
-
-    /**
-     * Set the address for the point of entry to the external compilation result.
-     * 
-     * @param addr the address of the entry point
-     */
-    public void setEntryPoint(long addr) {
-        entryPoint = addr;
-    }
-
-    /**
-     * Return the address for the point of entry to the external compilation result.
-     * 
-     * @return address value
-     */
-    public long getEntryPoint() {
-        return entryPoint;
-    }
-
-    /**
-     * Gets the {@linkplain #getTargetCode() code} in this compilation result as a string.
-     */
-    public String getCodeString() {
-        return new String(getTargetCode(), 0, getTargetCodeSize());
-    }
-
-    public void setHostGraph(StructuredGraph hostGraph) {
-        this.hostGraph = hostGraph;
-    }
-
-    public StructuredGraph getHostGraph() {
-        return hostGraph;
-    }
-
-    public void setOopMapArray(int[] arr) {
-        oopMapArray = arr;
-    }
-
-    public int[] getOopMapArray() {
-        return oopMapArray;
-    }
-
-    public void setUsesAllocationFlag(boolean val) {
-        usesAllocation = val;
-    }
-
-    public boolean getUsesAllocationFlag() {
-        return usesAllocation;
-    }
-
-}
--- a/graal/com.oracle.graal.graph.test/src/com/oracle/graal/graph/test/NodeMapTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph.test/src/com/oracle/graal/graph/test/NodeMapTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 public class NodeMapTest {
 
     @NodeInfo
-    static class TestNode extends Node {
+    static final class TestNode extends Node {
         protected TestNode() {
         }
     }
--- a/graal/com.oracle.graal.graph.test/src/com/oracle/graal/graph/test/NodeUsagesTests.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph.test/src/com/oracle/graal/graph/test/NodeUsagesTests.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,13 +34,13 @@
 public class NodeUsagesTests {
 
     @NodeInfo
-    static class Def extends Node {
+    static final class Def extends Node {
         protected Def() {
         }
     }
 
     @NodeInfo
-    static class Use extends Node {
+    static final class Use extends Node {
         @Input Def in0;
         @Input Def in1;
         @Input Def in2;
@@ -62,7 +62,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -74,7 +74,7 @@
 
         assertThat(def0.usages(), isEmpty());
 
-        assertEquals(3, def1.usages().count());
+        assertEquals(3, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use1));
         assertThat(def1.usages(), contains(use2));
@@ -91,7 +91,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -103,7 +103,7 @@
 
         assertThat(def0.usages(), isEmpty());
 
-        assertEquals(3, def1.usages().count());
+        assertEquals(3, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use1));
         assertThat(def1.usages(), contains(use2));
@@ -120,7 +120,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -132,7 +132,7 @@
 
         assertThat(def1.usages(), isEmpty());
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -149,7 +149,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -159,12 +159,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u == use1);
 
-        assertEquals(1, def1.usages().count());
+        assertEquals(1, def1.getUsageCount());
         assertThat(def1.usages(), contains(use1));
 
         assertThat(def1.usages(), isNotEmpty());
 
-        assertEquals(2, def0.usages().count());
+        assertEquals(2, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use2));
 
@@ -180,7 +180,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -190,12 +190,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u == use2);
 
-        assertEquals(1, def1.usages().count());
+        assertEquals(1, def1.getUsageCount());
         assertThat(def1.usages(), contains(use2));
 
         assertThat(def1.usages(), isNotEmpty());
 
-        assertEquals(2, def0.usages().count());
+        assertEquals(2, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
 
@@ -211,7 +211,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -221,12 +221,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u == use0);
 
-        assertEquals(1, def1.usages().count());
+        assertEquals(1, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
 
         assertThat(def1.usages(), isNotEmpty());
 
-        assertEquals(2, def0.usages().count());
+        assertEquals(2, def0.getUsageCount());
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
 
@@ -242,7 +242,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -252,12 +252,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u != use1);
 
-        assertEquals(1, def0.usages().count());
+        assertEquals(1, def0.getUsageCount());
         assertThat(def0.usages(), contains(use1));
 
         assertThat(def0.usages(), isNotEmpty());
 
-        assertEquals(2, def1.usages().count());
+        assertEquals(2, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use2));
 
@@ -274,7 +274,7 @@
         Use use2 = graph.add(new Use(null, null, def0));
         Use use3 = graph.add(new Use(null, null, def0));
 
-        assertEquals(4, def0.usages().count());
+        assertEquals(4, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -285,12 +285,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u != use1);
 
-        assertEquals(1, def0.usages().count());
+        assertEquals(1, def0.getUsageCount());
         assertThat(def0.usages(), contains(use1));
 
         assertThat(def0.usages(), isNotEmpty());
 
-        assertEquals(3, def1.usages().count());
+        assertEquals(3, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use2));
         assertThat(def1.usages(), contains(use3));
@@ -308,7 +308,7 @@
         Use use2 = graph.add(new Use(null, null, def0));
         Use use3 = graph.add(new Use(null, null, def0));
 
-        assertEquals(4, def0.usages().count());
+        assertEquals(4, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -319,12 +319,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u != use2);
 
-        assertEquals(1, def0.usages().count());
+        assertEquals(1, def0.getUsageCount());
         assertThat(def0.usages(), contains(use2));
 
         assertThat(def0.usages(), isNotEmpty());
 
-        assertEquals(3, def1.usages().count());
+        assertEquals(3, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use1));
         assertThat(def1.usages(), contains(use3));
@@ -342,7 +342,7 @@
         Use use2 = graph.add(new Use(null, null, def0));
         Use use3 = graph.add(new Use(null, null, def0));
 
-        assertEquals(4, def0.usages().count());
+        assertEquals(4, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -353,12 +353,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u == use2);
 
-        assertEquals(1, def1.usages().count());
+        assertEquals(1, def1.getUsageCount());
         assertThat(def1.usages(), contains(use2));
 
         assertThat(def1.usages(), isNotEmpty());
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use3));
@@ -375,7 +375,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -385,12 +385,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u != use2);
 
-        assertEquals(1, def0.usages().count());
+        assertEquals(1, def0.getUsageCount());
         assertThat(def0.usages(), contains(use2));
 
         assertThat(def0.usages(), isNotEmpty());
 
-        assertEquals(2, def1.usages().count());
+        assertEquals(2, def1.getUsageCount());
         assertThat(def1.usages(), contains(use0));
         assertThat(def1.usages(), contains(use1));
 
@@ -406,7 +406,7 @@
         Use use1 = graph.add(new Use(null, def0, null));
         Use use2 = graph.add(new Use(null, null, def0));
 
-        assertEquals(3, def0.usages().count());
+        assertEquals(3, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
         assertThat(def0.usages(), contains(use1));
         assertThat(def0.usages(), contains(use2));
@@ -416,12 +416,12 @@
 
         def0.replaceAtMatchingUsages(def1, u -> u != use0);
 
-        assertEquals(1, def0.usages().count());
+        assertEquals(1, def0.getUsageCount());
         assertThat(def0.usages(), contains(use0));
 
         assertThat(def0.usages(), isNotEmpty());
 
-        assertEquals(2, def1.usages().count());
+        assertEquals(2, def1.getUsageCount());
         assertThat(def1.usages(), contains(use1));
         assertThat(def1.usages(), contains(use2));
 
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Edges.java	Wed Jan 28 19:32:47 2015 +0100
@@ -124,11 +124,13 @@
         }
         while (index < getCount()) {
             NodeList<Node> list = getNodeList(node, index);
-            int size = list.initialSize;
-            NodeList<Node> newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size);
+            if (list != null) {
+                int size = list.initialSize;
+                NodeList<Node> newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size);
 
-            // replacing with a new list object is the expected behavior!
-            initializeList(node, index, newList);
+                // replacing with a new list object is the expected behavior!
+                initializeList(node, index, newList);
+            }
             index++;
         }
     }
@@ -144,9 +146,11 @@
         int index = getDirectCount();
         while (index < getCount()) {
             NodeList<Node> list = getNodeList(prototype, index);
-            int size = list.initialSize;
-            NodeList<Node> newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size);
-            initializeList(node, index, newList);
+            if (list != null) {
+                int size = list.initialSize;
+                NodeList<Node> newList = type == Edges.Type.Inputs ? new NodeInputList<>(node, size) : new NodeSuccessorList<>(node, size);
+                initializeList(node, index, newList);
+            }
             index++;
         }
     }
@@ -201,9 +205,10 @@
         }
         while (index < getCount()) {
             NodeList<Node> list = getNodeList(node, index);
-            assert list != null : this;
-            if (list.replaceFirst(key, replacement)) {
-                return true;
+            if (list != null) {
+                if (list.replaceFirst(key, replacement)) {
+                    return true;
+                }
             }
             index++;
         }
@@ -256,7 +261,8 @@
             }
         }
         for (int i = directCount; i < getCount(); i++) {
-            if (getNodeList(node, i).contains(value)) {
+            NodeList<?> curList = getNodeList(node, i);
+            if (curList != null && curList.contains(value)) {
                 return true;
             }
         }
@@ -277,7 +283,7 @@
         }
         while (index < getCount()) {
             NodeList<Node> list = getNodeList(other, index);
-            if (!list.equals(getNodeList(node, index))) {
+            if (!Objects.equals(list, getNodeList(node, index))) {
                 return false;
             }
             index++;
@@ -329,12 +335,14 @@
                 if (subIndex == 0) {
                     list = edges.getNodeList(node, index);
                 }
-                while (subIndex < list.size()) {
-                    nextElement = list.get(subIndex);
-                    if (nextElement != null) {
-                        return;
+                if (list != null) {
+                    while (subIndex < list.size()) {
+                        nextElement = list.get(subIndex);
+                        if (nextElement != null) {
+                            return;
+                        }
+                        subIndex++;
                     }
-                    subIndex++;
                 }
                 subIndex = 0;
                 index++;
@@ -404,9 +412,11 @@
                 if (subIndex == 0) {
                     list = edges.getNodeList(node, index);
                 }
-                if (subIndex < list.size()) {
-                    nextElement = list.get(subIndex);
-                    return;
+                if (list != null) {
+                    if (subIndex < list.size()) {
+                        nextElement = list.get(subIndex);
+                        return;
+                    }
                 }
                 subIndex = 0;
                 index++;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Wed Jan 28 19:32:47 2015 +0100
@@ -123,6 +123,11 @@
             }
             return false;
         }
+
+        @Override
+        public String toString() {
+            return node.toString();
+        }
     }
 
     /**
@@ -500,7 +505,7 @@
             Node minCountNode = null;
             for (Node input : node.inputs()) {
                 if (input != null) {
-                    int estimate = input.getUsageCountUpperBound();
+                    int estimate = input.getUsageCount();
                     if (estimate == 0) {
                         return null;
                     } else if (estimate < minCount) {
@@ -619,7 +624,7 @@
 
     // Fully qualified annotation name is required to satisfy javac
     @com.oracle.graal.nodeinfo.NodeInfo
-    static class PlaceHolderNode extends Node {
+    static final class PlaceHolderNode extends Node {
         public PlaceHolderNode() {
         }
 
@@ -745,6 +750,9 @@
         if (nodeEventListener != null) {
             nodeEventListener.nodeAdded(node);
         }
+        if (Fingerprint.ENABLED) {
+            Fingerprint.submit("%s: %s", NodeEvent.NODE_ADDED, node);
+        }
     }
 
     @SuppressWarnings("unused")
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,6 +31,8 @@
 import sun.misc.*;
 
 import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.Graph.NodeEvent;
 import com.oracle.graal.graph.Graph.NodeEventListener;
 import com.oracle.graal.graph.iterators.*;
 import com.oracle.graal.graph.spi.*;
@@ -188,6 +190,7 @@
     Node usage0;
     Node usage1;
     Node[] extraUsages;
+    int extraUsagesCount;
 
     private Node predecessor;
     private NodeClass nodeClass;
@@ -289,14 +292,14 @@
     /**
      * Gets the maximum number of usages this node has had at any point in time.
      */
-    int getUsageCountUpperBound() {
+    public int getUsageCount() {
         if (usage0 == null) {
             return 0;
         }
         if (usage1 == null) {
             return 1;
         }
-        return 2 + extraUsages.length;
+        return 2 + extraUsagesCount;
     }
 
     /**
@@ -307,37 +310,10 @@
     }
 
     /**
-     * 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
+     * Checks whether this node has no usages.
      */
-    private static int indexOfLastNonNull(Node[] nodes) {
-        if (nodes.length == 0 || nodes[0] == null) {
-            return -1;
-        }
-        if (nodes[nodes.length - 1] != null) {
-            return nodes.length - 1;
-        }
-
-        // binary search
-        int low = 0;
-        int high = nodes.length - 1;
-        while (true) {
-            int mid = (low + high) >>> 1;
-            if (nodes[mid] == null) {
-                if (nodes[mid - 1] != null) {
-                    return mid - 1;
-                }
-                high = mid - 1;
-            } else {
-                if (mid == nodes.length - 1 || nodes[mid + 1] == null) {
-                    return mid;
-                }
-                low = mid + 1;
-            }
-        }
+    public final boolean hasNoUsages() {
+        return this.usage0 == null;
     }
 
     /**
@@ -355,94 +331,38 @@
             int length = extraUsages.length;
             if (length == 0) {
                 extraUsages = new Node[4];
-                extraUsages[0] = node;
-            } else {
-                int lastNonNull = indexOfLastNonNull(extraUsages);
-                if (lastNonNull == length - 1) {
-                    extraUsages = Arrays.copyOf(extraUsages, length * 2 + 1);
-                    extraUsages[length] = node;
-                } else if (lastNonNull == -1) {
-                    extraUsages[0] = node;
-                } else {
-                    extraUsages[lastNonNull + 1] = node;
-                }
+            } else if (extraUsagesCount == length) {
+                extraUsages = Arrays.copyOf(extraUsages, length * 2 + 1);
             }
+            extraUsages[extraUsagesCount++] = node;
         }
     }
 
-    int usageCount() {
-        if (usage0 == null) {
-            return 0;
-        }
-        if (usage1 == null) {
-            return 1;
-        }
-        return 2 + indexOfLastNonNull(extraUsages) + 1;
-    }
-
-    /**
-     * Remove all usages between {@code fromIndex} and {@code toIndex} (exclusive), also, if
-     * {@code toIndex} is a valid usage, it is moved to {@code fromIndex}.
-     *
-     * <p>
-     * Visually,
-     *
-     * <pre>
-     * {@code
-     * [1, 2, 3, 4, 5, 6, 7].removeUsagesAndShiftFirst(1, 2) == [1, 4, 6, 7, 5, null, null]}
-     * </pre>
-     *
-     *
-     * @param fromIndex the index of the first element to be removed
-     * @param toIndex the index after the last element to be removed
-     */
-    private void removeUsagesAndShiftFirst(int fromIndex, int toIndex) {
-        assert fromIndex < toIndex;
-        int firstNullIndex = usageCount();
-        assert toIndex <= firstNullIndex;
-        int i = fromIndex;
-        int limit = toIndex;
-        if (toIndex < firstNullIndex) {
-            // move usage at toIndex to fromIndex(!)
-            movUsageTo(toIndex, fromIndex);
-            limit++;
-            i++;
-        }
-        while (i < limit && firstNullIndex > limit) {
-            movUsageTo(firstNullIndex - 1, i);
-            firstNullIndex--;
-            i++;
-        }
-        while (i < limit) {
-            if (i == 0) {
+    private void movUsageFromEndTo(int destIndex) {
+        int lastIndex = this.getUsageCount() - 1;
+        if (destIndex == 0) {
+            if (lastIndex == 0) {
                 usage0 = null;
-            } else if (i == 1) {
-                usage1 = null;
-            } else {
-                extraUsages[i - INLINE_USAGE_COUNT] = null;
-            }
-            i++;
-        }
-
-    }
-
-    private void movUsageTo(int usageIndex, int toIndex) {
-        assert usageIndex > toIndex;
-        if (toIndex == 0) {
-            if (usageIndex == 1) {
+                return;
+            } else if (lastIndex == 1) {
                 usage0 = usage1;
                 usage1 = null;
+                return;
             } else {
-                usage0 = extraUsages[usageIndex - INLINE_USAGE_COUNT];
-                extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
+                usage0 = extraUsages[lastIndex - INLINE_USAGE_COUNT];
             }
-        } else if (toIndex == 1) {
-            usage1 = extraUsages[usageIndex - INLINE_USAGE_COUNT];
-            extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
+        } else if (destIndex == 1) {
+            if (lastIndex == 1) {
+                usage1 = null;
+                return;
+            }
+            usage1 = extraUsages[lastIndex - INLINE_USAGE_COUNT];
         } else {
-            extraUsages[toIndex - INLINE_USAGE_COUNT] = extraUsages[usageIndex - INLINE_USAGE_COUNT];
-            extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
+            Node n = extraUsages[lastIndex - INLINE_USAGE_COUNT];
+            extraUsages[destIndex - INLINE_USAGE_COUNT] = n;
         }
+        extraUsages[lastIndex - INLINE_USAGE_COUNT] = null;
+        this.extraUsagesCount--;
     }
 
     /**
@@ -457,46 +377,18 @@
         // the usage list has no null element preceding a non-null element
         incUsageModCount();
         if (usage0 == node) {
-            if (usage1 != null) {
-                int lastNonNull = indexOfLastNonNull(extraUsages);
-                if (lastNonNull >= 0) {
-                    usage0 = extraUsages[lastNonNull];
-                    extraUsages[lastNonNull] = null;
-                } else {
-                    // usage1 is the last element
-                    usage0 = usage1;
-                    usage1 = null;
-                }
-            } else {
-                // usage0 is the last element
-                usage0 = null;
-            }
+            this.movUsageFromEndTo(0);
             return true;
         }
         if (usage1 == node) {
-            int lastNonNull = indexOfLastNonNull(extraUsages);
-            if (lastNonNull >= 0) {
-                usage1 = extraUsages[lastNonNull];
-                extraUsages[lastNonNull] = null;
-            } else {
-                // usage1 is the last element
-                usage1 = null;
-            }
+            this.movUsageFromEndTo(1);
             return true;
         }
-        int matchIndex = -1;
-        int i = 0;
-        Node n;
-        while (i < extraUsages.length && (n = extraUsages[i]) != null) {
-            if (n == node) {
-                matchIndex = i;
+        for (int i = 0; i < this.extraUsagesCount; ++i) {
+            if (extraUsages[i] == node) {
+                this.movUsageFromEndTo(i + INLINE_USAGE_COUNT);
+                return true;
             }
-            i++;
-        }
-        if (matchIndex >= 0) {
-            extraUsages[matchIndex] = extraUsages[i - 1];
-            extraUsages[i - 1] = null;
-            return true;
         }
         return false;
     }
@@ -506,6 +398,7 @@
         usage0 = null;
         usage1 = null;
         extraUsages = NO_NODES;
+        extraUsagesCount = 0;
     }
 
     public final Node predecessor() {
@@ -562,7 +455,7 @@
             if (newInput != null) {
                 newInput.addUsage(this);
             }
-            if (oldInput != null && oldInput.usages().isEmpty()) {
+            if (oldInput != null && oldInput.hasNoUsages()) {
                 maybeNotifyZeroUsages(oldInput);
             }
         }
@@ -633,36 +526,33 @@
         clearUsages();
     }
 
+    public Node getUsageAt(int index) {
+        if (index == 0) {
+            return this.usage0;
+        } else if (index == 1) {
+            return this.usage1;
+        } else {
+            return this.extraUsages[index - INLINE_USAGE_COUNT];
+        }
+    }
+
     public void replaceAtMatchingUsages(Node other, NodePredicate usagePredicate) {
         assert checkReplaceWith(other);
-        NodeUsageIterator it = (NodeUsageIterator) usages().iterator();
-        int removeStart = -1;
-        while (it.hasNext()) {
-            Node usage = it.next();
+        int index = 0;
+        while (index < this.getUsageCount()) {
+            Node usage = getUsageAt(index);
             if (usagePredicate.apply(usage)) {
-                if (removeStart < 0) {
-                    removeStart = it.index - 1;
-                }
                 boolean result = usage.getNodeClass().getEdges(Inputs).replaceFirst(usage, this, other);
                 assert assertTrue(result, "not found in inputs, usage: %s", usage);
                 if (other != null) {
                     maybeNotifyInputChanged(usage);
                     other.addUsage(usage);
                 }
+                this.movUsageFromEndTo(index);
             } else {
-                if (removeStart >= 0) {
-                    int removeEndIndex = it.index - 1;
-                    removeUsagesAndShiftFirst(removeStart, removeEndIndex);
-                    it.index = removeStart;
-                    it.advance();
-                    removeStart = -1;
-                }
+                index++;
             }
         }
-        if (removeStart >= 0) {
-            int removeEndIndex = it.index;
-            removeUsagesAndShiftFirst(removeStart, removeEndIndex);
-        }
     }
 
     public void replaceAtUsages(InputType type, Node other) {
@@ -685,6 +575,9 @@
             if (listener != null) {
                 listener.inputChanged(node);
             }
+            if (Fingerprint.ENABLED) {
+                Fingerprint.submit("%s: %s", NodeEvent.INPUT_CHANGED, node);
+            }
         }
     }
 
@@ -695,6 +588,9 @@
             if (listener != null) {
                 listener.usagesDroppedToZero(node);
             }
+            if (Fingerprint.ENABLED) {
+                Fingerprint.submit("%s: %s", NodeEvent.ZERO_USAGES, node);
+            }
         }
     }
 
@@ -732,7 +628,7 @@
     private void unregisterInputs() {
         for (Node input : inputs()) {
             removeThisFromUsages(input);
-            if (input.usages().isEmpty()) {
+            if (input.hasNoUsages()) {
                 maybeNotifyZeroUsages(input);
             }
         }
@@ -764,7 +660,7 @@
     }
 
     private boolean checkDeletion() {
-        assertTrue(usages().isEmpty(), "cannot delete node %s because of usages: %s", this, usages());
+        assertTrue(hasNoUsages(), "cannot delete node %s because of usages: %s", this, usages());
         assertTrue(predecessor == null, "cannot delete node %s because of predecessor: %s", this, predecessor);
         return true;
     }
@@ -869,6 +765,7 @@
                 newNode.usage0 = null;
                 newNode.usage1 = null;
                 newNode.predecessor = null;
+                newNode.extraUsagesCount = 0;
                 copyOrClearEdgesForClone(newNode, Inputs, edgesToCopy);
                 copyOrClearEdgesForClone(newNode, Successors, edgesToCopy);
             }
@@ -1074,7 +971,7 @@
         }
 
         if (precision > 0) {
-            if (!usages().isEmpty()) {
+            if (!hasNoUsages()) {
                 formatter.format(" usages={");
                 int z = 0;
                 for (Node usage : usages()) {
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Wed Jan 28 19:32:47 2015 +0100
@@ -166,7 +166,7 @@
         isLeafNode = inputs.getCount() + successors.getCount() == 0;
 
         canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
-        startGVNNumber = clazz.hashCode();
+        startGVNNumber = clazz.getName().hashCode();
 
         NodeInfo info = getAnnotationTimed(clazz, NodeInfo.class);
         assert info != null : "Missing NodeInfo annotation on " + clazz;
@@ -597,8 +597,9 @@
 
         while (index < edges.getCount()) {
             NodeList<Node> list = edges.getNodeList(node, index);
-            assert list != null : edges;
-            edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type()));
+            if (list != null) {
+                edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type()));
+            }
             index++;
         }
     }
@@ -721,11 +722,17 @@
                     replacement = replacements.replacement(node);
                 }
                 if (replacement != node) {
+                    if (Fingerprint.ENABLED) {
+                        Fingerprint.submit("replacing %s with %s", node, replacement);
+                    }
                     assert replacement != null;
                     newNodes.put(node, replacement);
                 } else {
+                    if (Fingerprint.ENABLED) {
+                        Fingerprint.submit("duplicating %s", node);
+                    }
                     Node newNode = node.clone(graph, WithAllEdges);
-                    assert newNode.inputs().isEmpty() || newNode.usages().isEmpty();
+                    assert newNode.inputs().isEmpty() || newNode.hasNoUsages();
                     assert newNode.getClass() == node.getClass();
                     newNodes.put(node, newNode);
                 }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInputList.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeInputList.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,17 +40,17 @@
 
     public NodeInputList(Node self, T[] elements) {
         super(self, elements);
-        assert self.usages().isEmpty();
+        assert self.hasNoUsages();
     }
 
     public NodeInputList(Node self, List<? extends T> elements) {
         super(self, elements);
-        assert self.usages().isEmpty();
+        assert self.hasNoUsages();
     }
 
     public NodeInputList(Node self, Collection<? extends NodeInterface> elements) {
         super(self, elements);
-        assert self.usages().isEmpty();
+        assert self.hasNoUsages();
     }
 
     @Override
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeList.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeList.java	Wed Jan 28 19:32:47 2015 +0100
@@ -139,7 +139,10 @@
         assert node == null || !node.isDeleted();
         self.incModCount();
         incModCount();
-        if (size == nodes.length) {
+        int length = nodes.length;
+        if (length == 0) {
+            nodes = new Node[2];
+        } else if (size == length) {
             nodes = Arrays.copyOf(nodes, nodes.length * 2 + 1);
         }
         nodes[size++] = node;
@@ -150,8 +153,13 @@
     @Override
     @SuppressWarnings("unchecked")
     public T get(int index) {
+        assert assertInRange(index);
+        return (T) nodes[index];
+    }
+
+    private boolean assertInRange(int index) {
         assert index < size() : index + " < " + size();
-        return (T) nodes[index];
+        return true;
     }
 
     public T last() {
@@ -163,7 +171,7 @@
     public T set(int index, Node node) {
         incModCount();
         T oldValue = (T) nodes[index];
-        assert index < size();
+        assert assertInRange(index);
         update((T) nodes[index], (T) node);
         nodes[index] = node;
         return oldValue;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeSuccessorList.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeSuccessorList.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,12 +40,12 @@
 
     public NodeSuccessorList(Node self, T[] elements) {
         super(self, elements);
-        assert self.usages().isEmpty();
+        assert self.hasNoUsages();
     }
 
     public NodeSuccessorList(Node self, List<? extends T> elements) {
         super(self, elements);
-        assert self.usages().isEmpty();
+        assert self.hasNoUsages();
     }
 
     @Override
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterable.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterable.java	Wed Jan 28 19:32:47 2015 +0100
@@ -54,6 +54,6 @@
 
     @Override
     public int count() {
-        return node.usageCount();
+        return node.getUsageCount();
     }
 }
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUsageIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,8 +38,9 @@
         } else if (index == 1) {
             current = node.usage1;
         } else {
-            if (index - Node.INLINE_USAGE_COUNT < node.extraUsages.length) {
-                current = node.extraUsages[index - Node.INLINE_USAGE_COUNT];
+            int relativeIndex = index - Node.INLINE_USAGE_COUNT;
+            if (relativeIndex < node.extraUsagesCount) {
+                current = node.extraUsages[relativeIndex];
             }
         }
     }
--- a/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/DataPatchInConstantsTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -153,7 +153,7 @@
     }
 
     @NodeInfo
-    private static class LoadThroughPatchNode extends FixedWithNextNode implements LIRLowerable {
+    private static final class LoadThroughPatchNode extends FixedWithNextNode implements LIRLowerable {
 
         @Input protected ValueNode input;
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -51,7 +51,6 @@
 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
 import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.phases.util.*;
 
 /**
  * LIR generator specialized for AMD64 HotSpot.
@@ -182,9 +181,9 @@
     private LIRFrameState currentRuntimeCallInfo;
 
     @Override
-    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
+    protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
         currentRuntimeCallInfo = info;
-        super.emitForeignCall(linkage, result, arguments, temps, info);
+        super.emitForeignCallOp(linkage, result, arguments, temps, info);
     }
 
     public void emitLeaveCurrentStackFrame(SaveRegistersOp saveRegisterOp) {
@@ -463,28 +462,6 @@
         return result;
     }
 
-    /**
-     * Checks whether the supplied constant can be used without loading it into a register for store
-     * operations, i.e., on the right hand side of a memory access.
-     *
-     * @param c The constant to check.
-     * @return True if the constant can be used directly, false if the constant needs to be in a
-     *         register.
-     */
-    protected boolean canStoreConstant(JavaConstant c) {
-        // there is no immediate move of 64-bit constants on Intel
-        switch (c.getKind()) {
-            case Long:
-                return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c);
-            case Double:
-                return false;
-            case Object:
-                return c.isNull();
-            default:
-                return true;
-        }
-    }
-
     @Override
     public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) {
         AMD64AddressValue storeAddress = asAddressValue(address);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Wed Jan 28 19:32:47 2015 +0100
@@ -52,7 +52,7 @@
 
     private final boolean allAllocatableAreCallerSaved;
 
-    private final Map<PlatformKind, Register[]> categorized = new ConcurrentHashMap<>();
+    private final Map<PlatformKind.Key, Register[]> categorized = new ConcurrentHashMap<>();
 
     private final RegisterAttributes[] attributesMap;
 
@@ -66,8 +66,10 @@
     }
 
     public Register[] getAllocatableRegisters(PlatformKind kind) {
-        if (categorized.containsKey(kind)) {
-            return categorized.get(kind);
+        PlatformKind.Key key = kind.getKey();
+        if (categorized.containsKey(key)) {
+            Register[] val = categorized.get(key);
+            return val;
         }
 
         ArrayList<Register> list = new ArrayList<>();
@@ -78,7 +80,7 @@
         }
 
         Register[] ret = list.toArray(new Register[list.size()]);
-        categorized.put(kind, ret);
+        categorized.put(key, ret);
         return ret;
     }
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64RawNativeCallNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64RawNativeCallNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class AMD64RawNativeCallNode extends FixedWithNextNode implements LIRLowerable {
+public final class AMD64RawNativeCallNode extends FixedWithNextNode implements LIRLowerable {
 
     protected final JavaConstant functionPointer;
     @Input NodeInputList<ValueNode> args;
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,462 +0,0 @@
-/*
- * Copyright (c) 2009, 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;
-
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.function.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.hsail.*;
-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.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hsail.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.util.*;
-import com.oracle.graal.printer.*;
-
-/**
- * Implements compile and dispatch of Java code containing lambda constructs. Currently only used by
- * JDK interception code that offloads to the GPU.
- */
-public class ForEachToGraal implements CompileAndDispatch {
-
-    private static HSAILHotSpotBackend getHSAILBackend() {
-        Backend backend = runtime().getBackend(HSAIL.class);
-        return (HSAILHotSpotBackend) backend;
-    }
-
-    ConcurrentHashMap<Class<?>, String> resolvedConsumerTargetMethods = new ConcurrentHashMap<>();
-
-    /**
-     * Returns the name of the reduction method given a class implementing {@link IntConsumer}.
-     *
-     * @param opClass a class implementing {@link IntConsumer}.
-     * @return the name of the reduction method
-     */
-    public String getIntReduceTargetName(Class<?> opClass) {
-        String cachedMethodName = resolvedConsumerTargetMethods.get(Objects.requireNonNull(opClass));
-        if (cachedMethodName != null) {
-            return cachedMethodName;
-        } else {
-            Method acceptMethod = null;
-            for (Method m : opClass.getMethods()) {
-                if (m.getName().equals("applyAsInt")) {
-                    assert acceptMethod == null : "found more than one implementation of applyAsInt in " + opClass;
-                    acceptMethod = m;
-                }
-            }
-            // Ensure a debug configuration for this thread is initialized
-            if (DebugScope.getConfig() == null) {
-                DebugEnvironment.initialize(System.out);
-            }
-
-            HSAILHotSpotBackend backend = getHSAILBackend();
-            Providers providers = backend.getProviders();
-            StructuredGraph graph = new StructuredGraph(((HotSpotMetaAccessProvider) providers.getMetaAccess()).lookupJavaMethod(acceptMethod));
-            new GraphBuilderPhase.Instance(providers.getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL).apply(graph);
-            NodeIterable<MethodCallTargetNode> calls = graph.getNodes(MethodCallTargetNode.class);
-            assert calls.count() == 1;
-            ResolvedJavaMethod lambdaMethod = calls.first().targetMethod();
-            Debug.log("target ... %s", lambdaMethod);
-
-            String className = lambdaMethod.getDeclaringClass().getName();
-            if (!className.equals("Ljava/lang/Integer;")) {
-                return null;
-            }
-            resolvedConsumerTargetMethods.put(opClass, lambdaMethod.getName());
-            return lambdaMethod.getName().intern();
-        }
-    }
-
-    /**
-     * Gets a compiled and installed kernel for the lambda called by the
-     * {@link IntConsumer#accept(int)} method in a class implementing {@link IntConsumer}.
-     *
-     * @param intConsumerClass a class implementing {@link IntConsumer}
-     * @return a {@link HotSpotNmethod} handle to the compiled and installed kernel
-     */
-    private static HotSpotNmethod getCompiledLambda(Class<?> intConsumerClass) {
-        Method acceptMethod = null;
-        for (Method m : intConsumerClass.getMethods()) {
-            if (m.getName().equals("accept")) {
-                assert acceptMethod == null : "found more than one implementation of accept(int) in " + intConsumerClass;
-                acceptMethod = m;
-            }
-        }
-
-        // Ensure a debug configuration for this thread is initialized
-        if (DebugScope.getConfig() == null) {
-            DebugEnvironment.initialize(System.out);
-        }
-
-        HSAILHotSpotBackend backend = getHSAILBackend();
-        Providers providers = backend.getProviders();
-        StructuredGraph graph = new StructuredGraph(((HotSpotMetaAccessProvider) providers.getMetaAccess()).lookupJavaMethod(acceptMethod));
-        new GraphBuilderPhase.Instance(providers.getMetaAccess(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL).apply(graph);
-        NodeIterable<MethodCallTargetNode> calls = graph.getNodes(MethodCallTargetNode.class);
-        assert calls.count() == 1;
-        ResolvedJavaMethod lambdaMethod = calls.first().targetMethod();
-        Debug.log("target ... %s", lambdaMethod);
-
-        if (lambdaMethod == null) {
-            Debug.log("Did not find call in accept()");
-            return null;
-        }
-        assert lambdaMethod.getName().startsWith("lambda$");
-
-        ExternalCompilationResult hsailCode = backend.compileKernel(lambdaMethod, true);
-        return backend.installKernel(lambdaMethod, hsailCode);
-    }
-
-    @Override
-    public Object createKernel(Class<?> consumerClass) {
-        try {
-            return getCompiledLambda(consumerClass);
-        } catch (Throwable e) {
-            // If Graal compilation throws an exception, we want to revert to regular Java
-            Debug.log("WARNING: Graal compilation failed");
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    @Override
-    public Object createKernelFromHsailString(String code, String methodName) {
-        ExternalCompilationResult hsailCode = new ExternalCompilationResult();
-        try (Debug.Scope ds = Debug.scope("GeneratingKernelBinary")) {
-
-            HSAILHotSpotBackend backend = getHSAILBackend();
-            Providers providers = backend.getProviders();
-            Method integerOffloadMethod = null;
-
-            for (Method m : Integer.class.getMethods()) {
-                if (m.getName().equals(methodName)) {
-                    integerOffloadMethod = m;
-                    break;
-                }
-            }
-            if (integerOffloadMethod != null) {
-                ResolvedJavaMethod rm = ((HotSpotMetaAccessProvider) providers.getMetaAccess()).lookupJavaMethod(integerOffloadMethod);
-
-                long kernel = HSAILHotSpotBackend.generateKernel(code.getBytes(), "Integer::" + methodName);
-                if (kernel == 0) {
-                    throw new GraalInternalError("Failed to compile HSAIL kernel from String");
-                }
-                hsailCode.setEntryPoint(kernel);
-                return backend.installKernel(rm, hsailCode); // is a HotSpotNmethod
-            } else {
-                return null;
-            }
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-    }
-
-    @Override
-    public boolean dispatchKernel(Object kernel, int jobSize, Object[] args) {
-        HotSpotNmethod code = (HotSpotNmethod) kernel;
-        if (code != null) {
-            try {
-                // No return value from HSAIL kernels
-                getHSAILBackend().executeKernel(code, jobSize, args);
-                return true;
-            } catch (InvalidInstalledCodeException iice) {
-                Debug.log("WARNING: Invalid installed code at exec time: %s", iice);
-                iice.printStackTrace();
-                return false;
-            }
-        } else {
-            // Should throw something sensible here
-            return false;
-        }
-    }
-
-    /**
-     * Running with a larger global size seems to increase the performance for sum, but it might be
-     * different for other reductions so it is a knob.
-     */
-    private static final int GlobalSize = 1024 * Integer.getInteger("com.amd.sumatra.reduce.globalsize.multiple", 1);
-
-    @Override
-    public Integer offloadIntReduceImpl(Object okraKernel, int identity, int[] streamSource) {
-        // NOTE - this reduce requires local size of 64 which is the SumatraUtils default
-
-        // Handmade reduce does not support +UseCompressedOops
-        HotSpotVMConfig config = runtime().getConfig();
-        if (config.useCompressedOops == true || config.useHSAILDeoptimization == true) {
-            throw new GraalInternalError("Reduce offload not compatible with +UseCompressedOops or +UseHSAILDeoptimization");
-        }
-
-        try {
-            assert streamSource.length >= GlobalSize : "Input array length=" + streamSource.length + " smaller than requested global_size=" + GlobalSize;
-
-            int[] result = {identity};
-            Object[] args = {streamSource, result, streamSource.length};
-            args[0] = streamSource;
-
-            dispatchKernel(okraKernel, GlobalSize, args);
-
-            // kernel result is result[0].
-            return result[0];
-        } catch (Exception e) {
-            System.err.println(e);
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    @Override
-    public String getIntegerReduceIntrinsic(String reducerName) {
-
-        // Note all of these depend on group size of 256
-
-        String reduceOp = "/* Invalid */ ";
-        String atomicResultProduction = "/* Invalid */ ";
-        if (reducerName.equals("sum")) {
-            reduceOp = "add_u32 ";
-            atomicResultProduction = "atomicnoret_add_global_u32 ";
-        } else if (reducerName.equals("max")) {
-            reduceOp = "max_s32 ";
-            atomicResultProduction = "atomicnoret_max_global_s32 ";
-        } else if (reducerName.equals("min")) {
-            reduceOp = "min_s32 ";
-            atomicResultProduction = "atomicnoret_min_global_s32 ";
-        } else {
-            return "/* Invalid */ ";
-        }
-
-        // @formatter:off
-        return new String(
-                "version 0:95:$full:$large; // BRIG Object Format Version 0:4" + "\n"
-                + "" + "\n"
-                + "kernel &run(" + "\n"
-                + " align 8 kernarg_u64 %arg_p3," + "\n"
-                + " align 8 kernarg_u64 %arg_p4," + "\n"
-                + " align 4 kernarg_u32 %arg_p5)" + "\n"
-                + "{" + "\n"
-                + "" + "\n"
-                + " align 4 group_u32 %reduce_cllocal_scratch[256];" + "\n"
-                + "" + "\n"
-                + " workitemabsid_u32 $s2, 0;" + "\n"
-                + "" + "\n"
-                + " ld_kernarg_u32 $s1, [%arg_p5];" + "\n"
-                + " ld_kernarg_u64 $d0, [%arg_p4];" + "\n"
-                + " ld_kernarg_u64 $d1, [%arg_p3];" + "\n"
-                + "" + "\n"
-                + " add_u64 $d0, $d0, 24;             // adjust over obj array headers" + "\n"
-                + " add_u64 $d1, $d1, 24;" + "\n"
-                + " cmp_ge_b1_s32 $c0, $s2, $s1; // if(gloId < length){" + "\n"
-                + " cbr $c0, @BB0_1;" + "\n"
-                + " gridsize_u32 $s0, 0;        // s0 is globalsize" + "\n"
-                + " add_u32 $s0, $s0, $s2;         // gx += globalsize" + "\n"
-                + " cvt_s64_s32 $d2, $s2;      // s2 is global id" + "\n"
-                + " shl_u64 $d2, $d2, 2;" + "\n"
-                + " add_u64 $d2, $d1, $d2;" + "\n"
-                + " ld_global_u32 $s3, [$d2];    // load this element from input" + "\n"
-                + " brn @BB0_3;" + "\n"
-                + "" + "\n"
-                + "@BB0_1:" + "\n"
-                + " mov_b32 $s0, $s2;" + "\n"                                  + "" + "\n"
-                + "@BB0_3:" + "\n"
-                + " cmp_ge_b1_s32 $c1, $s0, $s1; // while (gx < length)" + "\n"
-                + " cbr $c1, @BB0_6;" + "\n"
-                + " gridsize_u32 $s2, 0;" + "\n"
-                + "" + "\n"
-                + "@BB0_5:" + "\n"
-                + " cvt_s64_s32 $d2, $s0;" + "\n"
-                + " shl_u64 $d2, $d2, 2;" + "\n"
-                + " add_u64 $d2, $d1, $d2;" + "\n"
-                + " ld_global_u32 $s4, [$d2];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " add_u32 $s0, $s0, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c1, $s0, $s1;" + "\n"
-                + " cbr $c1, @BB0_5;" + "\n"
-                + "" + "\n"
-                + "@BB0_6:" + "\n"
-                + " workgroupid_u32 $s0, 0;" + "\n"
-                + " workgroupsize_u32 $s2, 0;" + "\n"
-                + " mul_u32 $s2, $s2, $s0;" + "\n"
-                + " sub_u32 $s2, $s1, $s2;" + "\n"
-                + " workitemid_u32 $s1, 0;" + "\n"
-                + " add_u32 $s4, $s1, 128;"
-                + "\n"
-                + " cmp_lt_b1_u32 $c1, $s4, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 128;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " cvt_s64_s32 $d1, $s1;" + "\n"
-                + " shl_u64 $d1, $d1, 2;" + "\n"
-                + " lda_group_u64 $d2, [%reduce_cllocal_scratch];" + "\n"
-                + " add_u64 $d1, $d2, $d1;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_8;" + "\n"
-                + " ld_group_u32 $s3, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s4;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s4, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_8:" + "\n"
-                + " add_u32 $s3, $s1, 64;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 64;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_10;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;"
-                + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_10:" + "\n"
-                + " add_u32 $s3, $s1, 32;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 32;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_12;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_12:" + "\n"
-                + " add_u32 $s3, $s1, 16;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 16;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_14;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_14:" + "\n"
-                + " add_u32 $s3, $s1, 8;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 8;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_16;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_16:" + "\n"
-                + " add_u32 $s3, $s1, 4;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 4;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_18;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_18:" + "\n"
-                + " add_u32 $s3, $s1, 2;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 2;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_20;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d3, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d3];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_20:" + "\n"
-                + " add_u32 $s3, $s1, 1;" + "\n"
-                + " cmp_lt_b1_u32 $c1, $s3, $s2;" + "\n"
-                + " cmp_lt_b1_s32 $c2, $s1, 1;" + "\n"
-                + " and_b1 $c1, $c2, $c1;" + "\n"
-                + " barrier_fgroup;" + "\n"
-                + " not_b1 $c1, $c1;" + "\n"
-                + " cbr $c1, @BB0_22;" + "\n"
-                + " ld_group_u32 $s4, [$d1];" + "\n"
-                + " cvt_s64_s32 $d3, $s3;" + "\n"
-                + " shl_u64 $d3, $d3, 2;" + "\n"
-                + " add_u64 $d2, $d2, $d3;" + "\n"
-                + " ld_group_u32 $s3, [$d2];" + "\n"
-                +       reduceOp + "  $s3, $s3, $s4;" + "\n"
-                + " st_group_u32 $s3, [$d1];" + "\n"
-                + "" + "\n"
-                + "@BB0_22:" + "\n"
-                + " cmp_gt_b1_u32 $c0, $s1, 0;  // s1 is local id, done if > 0" + "\n"
-                + " cbr $c0, @BB0_24;" + "\n"
-                + "" + "\n"
-                + " ld_group_u32 $s2, [%reduce_cllocal_scratch];  // s2 is result[get_group_id(0)];" + "\n"
-                +       atomicResultProduction + " [$d0], $s2; // build global result from local results" + "\n"
-                + "" + "\n"
-                + "@BB0_24:" + "\n"
-                + " ret;" + "\n"
-                + "};" + "\n");
-        //@formatter:on
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotAssembler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * 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.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.compiler.common.*;
-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);
-    }
-
-    // This means the HSAIL backend cannot (currently) be executed
-    // in remote/replay compilation mode.
-    private static Field objectField;
-
-    private static Object getObject(JavaConstant src) {
-        try {
-            if (objectField == null) {
-                objectField = HotSpotObjectConstantImpl.class.getDeclaredField("object");
-                objectField.setAccessible(true);
-            }
-            return objectField.get(src);
-        } catch (Exception e) {
-            throw new GraalInternalError(e);
-        }
-
-    }
-
-    @Override
-    public final void mov(Register a, JavaConstant 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 {
-            assert src instanceof HotSpotObjectConstantImpl;
-            Object obj = getObject(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	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1256 +0,0 @@
-/*
- * 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.hsail;
-
-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.hotspot.HotSpotGraalRuntime.*;
-import static com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options.*;
-import static com.oracle.graal.hotspot.hsail.replacements.HSAILNewObjectSnippets.Options.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.function.*;
-import java.util.stream.*;
-
-import com.amd.okra.*;
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.Assumptions.Assumption;
-import com.oracle.graal.api.code.CallingConvention.Type;
-import com.oracle.graal.api.code.CompilationResult.Call;
-import com.oracle.graal.api.code.CompilationResult.CodeAnnotation;
-import com.oracle.graal.api.code.CompilationResult.DataPatch;
-import com.oracle.graal.api.code.CompilationResult.DataSectionReference;
-import com.oracle.graal.api.code.CompilationResult.ExceptionHandler;
-import com.oracle.graal.api.code.CompilationResult.Infopoint;
-import com.oracle.graal.api.code.CompilationResult.Mark;
-import com.oracle.graal.api.code.DataSection.Data;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.asm.hsail.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.hsail.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.lir.framemap.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizingOp;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.virtual.*;
-import com.oracle.graal.options.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.virtual.nodes.*;
-
-/**
- * HSAIL specific backend.
- */
-public class HSAILHotSpotBackend extends HotSpotBackend {
-
-    public static class Options {
-
-        // @formatter:off
-        @Option(help = "Number of TLABs used for HSAIL kernels which allocate", type = OptionType.Debug)
-        public static  final OptionValue<Integer> HsailKernelTlabs = new OptionValue<>(4);
-        // @formatter:on
-    }
-
-    private Map<String, String> paramTypeMap = new HashMap<>();
-    private final boolean deviceInitialized;
-    // TODO: get maximum Concurrency from okra
-    private int maxDeoptIndex = 8 * 40 * 64;   // see gpu_hsail.hpp
-
-    public HSAILHotSpotBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
-        super(runtime, providers);
-        paramTypeMap.put("HotSpotResolvedPrimitiveType<int>", "s32");
-        paramTypeMap.put("HotSpotResolvedPrimitiveType<float>", "f32");
-        paramTypeMap.put("HotSpotResolvedPrimitiveType<double>", "f64");
-        paramTypeMap.put("HotSpotResolvedPrimitiveType<long>", "s64");
-
-        /*
-         * The order of the conjunction below is important: the OkraUtil call may provision the
-         * native library required by the initialize() call
-         */
-        deviceInitialized = OkraUtil.okraLibExists() && initialize();
-    }
-
-    @Override
-    public boolean shouldAllocateRegisters() {
-        return true;
-    }
-
-    /**
-     * Initializes the GPU device.
-     *
-     * @return whether or not initialization was successful
-     */
-    private static native boolean initialize();
-
-    /**
-     * Determines if the GPU device (or simulator) is available and initialized.
-     */
-    public boolean isDeviceInitialized() {
-        return deviceInitialized;
-    }
-
-    /**
-     * Completes the initialization of the HSAIL backend. This includes initializing the providers
-     * and registering any method substitutions specified by the HSAIL backend.
-     */
-    @Override
-    public void completeInitialization() {
-        final HotSpotProviders providers = getProviders();
-        HotSpotVMConfig config = getRuntime().getConfig();
-        // Initialize the lowering provider.
-        final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
-        lowerer.initialize(providers, config);
-
-        // Register the replacements used by the HSAIL backend.
-        HSAILHotSpotReplacementsImpl replacements = (HSAILHotSpotReplacementsImpl) providers.getReplacements();
-        replacements.completeInitialization();
-    }
-
-    /**
-     * Compiles and installs a given method to a GPU binary.
-     */
-    public HotSpotNmethod compileAndInstallKernel(Method method) {
-        ResolvedJavaMethod javaMethod = getProviders().getMetaAccess().lookupJavaMethod(method);
-        HotSpotNmethod nm = installKernel(javaMethod, compileKernel(javaMethod, true));
-        try (Scope s = Debug.scope("HostCodeGen")) {
-            if (Debug.isLogEnabled()) {
-                DisassemblerProvider dis = getRuntime().getHostBackend().getDisassembler();
-                if (dis != null) {
-                    String disasm = dis.disassemble(nm);
-                    Debug.log("host code generated for %s%n%s", javaMethod, disasm);
-                } else {
-                    Debug.log("host code disassembler is null");
-                }
-            }
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-        return nm;
-    }
-
-    /**
-     * Compiles a given method to HSAIL code.
-     *
-     * @param makeBinary specifies whether a GPU binary should also be generated for the HSAIL code.
-     *            If true, the returned value is guaranteed to have a non-zero
-     *            {@linkplain ExternalCompilationResult#getEntryPoint() entry point}.
-     * @return the HSAIL code compiled from {@code method}'s bytecode
-     */
-    public ExternalCompilationResult compileKernel(ResolvedJavaMethod method, boolean makeBinary) {
-        StructuredGraph graph = new StructuredGraph(method);
-        HotSpotProviders providers = getProviders();
-        MetaAccessProvider metaAccess = getProviders().getMetaAccess();
-
-        // changed this from default to help us generate deopts when needed
-        OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL;
-        optimisticOpts.remove(OptimisticOptimizations.Optimization.UseExceptionProbabilityForOperations);
-        new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), optimisticOpts).apply(graph);
-        PhaseSuite<HighTierContext> graphBuilderSuite = providers.getSuites().getDefaultGraphBuilderSuite();
-        CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
-
-        // append special HSAILNonNullParametersPhase
-        int numArgs = cc.getArguments().length;
-        graphBuilderSuite.appendPhase(new HSAILNonNullParametersPhase(numArgs));
-
-        Suites suites = providers.getSuites().getDefaultSuites();
-        ExternalCompilationResult hsailCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, optimisticOpts, getProfilingInfo(graph), null, suites,
-                        new ExternalCompilationResult(), CompilationResultBuilderFactory.Default);
-
-        // this code added to dump infopoints
-        try (Scope s = Debug.scope("CodeGen")) {
-            if (Debug.isLogEnabled()) {
-                // show infopoints
-                List<Infopoint> infoList = hsailCode.getInfopoints();
-                Debug.log("%d HSAIL infopoints", infoList.size());
-                for (Infopoint info : infoList) {
-                    Debug.log(info.toString());
-                    Debug.log(info.debugInfo.frame().toString());
-                }
-            }
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-
-        if (makeBinary) {
-            if (!deviceInitialized) {
-                throw new GraalInternalError("Cannot generate GPU kernel if device is not initialized");
-            }
-            try (Scope ds = Debug.scope("GeneratingKernelBinary")) {
-                long kernel = generateKernel(hsailCode.getTargetCode(), method.getName());
-                if (kernel == 0) {
-                    throw new GraalInternalError("Failed to compile HSAIL kernel");
-                }
-                hsailCode.setEntryPoint(kernel);
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-        }
-        return hsailCode;
-    }
-
-    private static class HSAILNonNullParametersPhase extends Phase {
-        // we use this to limit the stamping to exclude the final argument in an obj stream method
-        private int numArgs;
-
-        public HSAILNonNullParametersPhase(int numArgs) {
-            this.numArgs = numArgs;
-        }
-
-        @Override
-        protected void run(StructuredGraph graph) {
-            int argCount = 0;
-            Stamp nonNull = StampFactory.objectNonNull();
-            for (ParameterNode param : graph.getNodes(ParameterNode.class)) {
-                argCount++;
-                if (argCount < numArgs && param.stamp() instanceof ObjectStamp) {
-                    ObjectStamp paramStamp = (ObjectStamp) param.stamp();
-                    param.setStamp(paramStamp.join(nonNull));
-                }
-            }
-        }
-    }
-
-    /**
-     * Generates a GPU binary from HSAIL code.
-     */
-    static native long generateKernel(byte[] hsailCode, String name);
-
-    /**
-     * Installs the {@linkplain ExternalCompilationResult#getEntryPoint() GPU binary} associated
-     * with some given HSAIL code in the code cache and returns a {@link HotSpotNmethod} handle to
-     * the installed code.
-     *
-     * @param hsailCode HSAIL compilation result for which a GPU binary has been generated
-     * @return a handle to the binary as installed in the HotSpot code cache
-     */
-    public final HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult hsailCode) {
-        assert hsailCode.getEntryPoint() != 0L;
-        // Code here based on HotSpotCodeCacheProvider.addExternalMethod().
-        HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method;
-        if (hsailCode.getId() == -1) {
-            hsailCode.setId(javaMethod.allocateCompileId(hsailCode.getEntryBCI()));
-        }
-        CompilationResult compilationResult = hsailCode;
-        StructuredGraph hostGraph = hsailCode.getHostGraph();
-        if (hostGraph != null) {
-            // TODO get rid of the unverified entry point in the host code
-            try (Scope ds = Debug.scope("GeneratingHostGraph", new DebugDumpScope("HostGraph"))) {
-                HotSpotBackend hostBackend = getRuntime().getHostBackend();
-                JavaType[] parameterTypes = new JavaType[hostGraph.getNodes(ParameterNode.class).count()];
-                Debug.log("Param count: %d", parameterTypes.length);
-                for (int i = 0; i < parameterTypes.length; i++) {
-                    ParameterNode parameter = hostGraph.getParameter(i);
-                    Debug.log("Param [%d]=%s", i, parameter);
-                    parameterTypes[i] = parameter.stamp().javaType(hostBackend.getProviders().getMetaAccess());
-                    Debug.log(" %s", parameterTypes[i]);
-                }
-                CallingConvention cc = hostBackend.getProviders().getCodeCache().getRegisterConfig().getCallingConvention(Type.JavaCallee, method.getSignature().getReturnType(null), parameterTypes,
-                                hostBackend.getTarget(), false);
-                CompilationResult hostCode = compileGraph(hostGraph, null, cc, method, hostBackend.getProviders(), hostBackend, this.getTarget(), null,
-                                hostBackend.getProviders().getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE, null, null,
-                                hostBackend.getProviders().getSuites().getDefaultSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
-                compilationResult = merge(hostCode, hsailCode);
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-        }
-
-        HSAILHotSpotNmethod code = new HSAILHotSpotNmethod(javaMethod, hsailCode.getName(), false, true);
-        code.setOopMapArray(hsailCode.getOopMapArray());
-        code.setUsesAllocationFlag(hsailCode.getUsesAllocationFlag());
-        HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compilationResult);
-        CodeInstallResult result = getRuntime().getCompilerToVM().installCode(compiled, code, null);
-        if (result != CodeInstallResult.OK) {
-            return null;
-        }
-        return code;
-    }
-
-    private static ExternalCompilationResult merge(CompilationResult hostCode, ExternalCompilationResult hsailCode) {
-        ExternalCompilationResult result = new ExternalCompilationResult();
-
-        // from hsail code
-        result.setEntryPoint(hsailCode.getEntryPoint());
-        result.setId(hsailCode.getId());
-        result.setEntryBCI(hsailCode.getEntryBCI());
-        assert hsailCode.getMarks().isEmpty();
-        assert hsailCode.getExceptionHandlers().isEmpty();
-        assert hsailCode.getDataPatches().isEmpty();
-
-        // from host code
-        result.setTotalFrameSize(hostCode.getTotalFrameSize());
-        result.setCustomStackAreaOffset(hostCode.getCustomStackAreaOffset());
-        result.setTargetCode(hostCode.getTargetCode(), hostCode.getTargetCodeSize());
-        for (CodeAnnotation annotation : hostCode.getAnnotations()) {
-            result.addAnnotation(annotation);
-        }
-        for (Mark mark : hostCode.getMarks()) {
-            result.recordMark(mark.pcOffset, mark.id);
-        }
-        for (ExceptionHandler handler : hostCode.getExceptionHandlers()) {
-            result.recordExceptionHandler(handler.pcOffset, handler.handlerPos);
-        }
-        for (DataPatch patch : hostCode.getDataPatches()) {
-            if (patch.reference instanceof DataSectionReference) {
-                Data hostData = hostCode.getDataSection().findData((DataSectionReference) patch.reference);
-                Data resultData = new Data(hostData.getAlignment(), hostData.getSize(), hostData.getBuilder());
-                patch.reference = result.getDataSection().insertData(resultData);
-            }
-            result.recordDataPatch(patch.pcOffset, patch.reference);
-        }
-        for (Infopoint infopoint : hostCode.getInfopoints()) {
-            if (infopoint instanceof Call) {
-                Call call = (Call) infopoint;
-                result.recordCall(call.pcOffset, call.size, call.target, call.debugInfo, call.direct);
-            } else {
-                result.recordInfopoint(infopoint.pcOffset, infopoint.debugInfo, infopoint.reason);
-            }
-        }
-
-        // merged
-        Assumptions mergedAssumptions = new Assumptions(true);
-        if (hostCode.getAssumptions() != null) {
-            for (Assumption assumption : hostCode.getAssumptions().getAssumptions()) {
-                if (assumption != null) {
-                    mergedAssumptions.record(assumption);
-                }
-            }
-        }
-        if (hsailCode.getAssumptions() != null) {
-            for (Assumption assumption : hsailCode.getAssumptions().getAssumptions()) {
-                if (assumption != null) {
-                    mergedAssumptions.record(assumption);
-                }
-            }
-        }
-        if (!mergedAssumptions.isEmpty()) {
-            result.setAssumptions(mergedAssumptions);
-        }
-        return result;
-    }
-
-    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");
-        }
-        int[] oopMapArray = ((HSAILHotSpotNmethod) kernel).getOopMapArray();
-
-        // Pass HsailKernelTlabs number if this kernel uses allocation, otherwise 0
-        int numTlabs = ((HSAILHotSpotNmethod) kernel).getUsesAllocationFlag() ? HsailKernelTlabs.getValue() : 0;
-        return executeKernel0(kernel, jobSize, args, numTlabs, HsailAllocBytesPerWorkitem.getValue(), oopMapArray);
-    }
-
-    private static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args, int numTlabs, int allocBytesPerWorkitem, int[] oopMapArray)
-                    throws InvalidInstalledCodeException;
-
-    @Override
-    public FrameMapBuilder newFrameMapBuilder(RegisterConfig registerConfig) {
-        RegisterConfig registerConfigNonNull = registerConfig == null ? getCodeCache().getRegisterConfig() : registerConfig;
-        return new FrameMapBuilderImpl(newFrameMap(registerConfigNonNull), getCodeCache(), registerConfigNonNull);
-    }
-
-    /**
-     * Use the HSAIL register set when the compilation target is HSAIL.
-     */
-    @Override
-    public FrameMap newFrameMap(RegisterConfig registerConfig) {
-        return new HSAILFrameMap(getCodeCache(), registerConfig);
-    }
-
-    @Override
-    public LIRGeneratorTool newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes) {
-        return new HSAILHotSpotLIRGenerator(getProviders(), getRuntime().getConfig(), cc, lirGenRes);
-    }
-
-    @Override
-    public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMapBuilder frameMapBuilder, ResolvedJavaMethod method, Object stub) {
-        return new HSAILHotSpotLIRGenerationResult(lir, frameMapBuilder);
-    }
-
-    @Override
-    public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        return new HSAILHotSpotNodeLIRBuilder(graph, lirGen);
-    }
-
-    class HotSpotFrameContext implements FrameContext {
-
-        public boolean hasFrame() {
-            return true;
-        }
-
-        @Override
-        public void enter(CompilationResultBuilder crb) {
-            Debug.log("Nothing to do here");
-        }
-
-        @Override
-        public void leave(CompilationResultBuilder crb) {
-            Debug.log("Nothing to do here");
-        }
-    }
-
-    /**
-     * a class to allow us to save lirGen.
-     */
-    static class HSAILCompilationResultBuilder extends CompilationResultBuilder {
-        public HSAILHotSpotLIRGenerationResult lirGenRes;
-
-        public HSAILCompilationResultBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, FrameContext frameContext,
-                        CompilationResult compilationResult, HSAILHotSpotLIRGenerationResult lirGenRes) {
-            super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult);
-            this.lirGenRes = lirGenRes;
-        }
-    }
-
-    static class HSAILHotSpotNmethod extends HotSpotNmethod {
-        private int[] oopMapArray;
-        private boolean usesAllocation;
-
-        HSAILHotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault, boolean isExternal) {
-            super(method, name, isDefault, isExternal);
-        }
-
-        void setOopMapArray(int[] array) {
-            oopMapArray = array;
-        }
-
-        int[] getOopMapArray() {
-            return oopMapArray;
-        }
-
-        public void setUsesAllocationFlag(boolean val) {
-            usesAllocation = val;
-        }
-
-        public boolean getUsesAllocationFlag() {
-            return usesAllocation;
-        }
-    }
-
-    @Override
-    protected Assembler createAssembler(FrameMap frameMap) {
-        return new HSAILHotSpotAssembler(getTarget());
-    }
-
-    @Override
-    public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
-        Assembler masm = createAssembler(frameMap);
-        HotSpotFrameContext frameContext = new HotSpotFrameContext();
-        // save lirGen for later use by setHostGraph
-        CompilationResultBuilder crb = new HSAILCompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult,
-                        (HSAILHotSpotLIRGenerationResult) lirGenRes);
-        crb.setTotalFrameSize(frameMap.totalFrameSize());
-        return crb;
-    }
-
-    @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;
-        LIRKind wordLIRKind = LIRKind.value(wordKind);
-
-        HotSpotVMConfig config = getRuntime().getConfig();
-        boolean useHSAILDeoptimization = config.useHSAILDeoptimization;
-        boolean useHSAILSafepoints = config.useHSAILSafepoints;
-
-        if ((useHSAILSafepoints == true) && (useHSAILDeoptimization == false)) {
-            Debug.log("+UseHSAILSafepoints requires +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 it up. Maybe there is a better way to do this?
-         */
-        boolean usesAllocation = false;
-        search: for (AbstractBlock<?> b : lir.linearScanOrder()) {
-            for (LIRInstruction op : lir.getLIRforBlock(b)) {
-                if ((op instanceof HSAILMove.LoadOp) && ((HSAILMove.LoadOp) op).usesThreadRegister()) {
-                    usesAllocation = true;
-                    assert useHSAILDeoptimization : "cannot use thread register if HSAIL deopt support is disabled";
-                    break search;
-                }
-            }
-        }
-        // save usesAllocation flag in ExternalCompilationResult
-        ((ExternalCompilationResult) crb.compilationResult).setUsesAllocationFlag(usesAllocation);
-
-        // Emit the prologue.
-        HSAILAssembler asm = (HSAILAssembler) crb.asm;
-        asm.emitString0("version 0:95: $full : $large;\n");
-
-        Signature signature = method.getSignature();
-        int sigParamCount = signature.getParameterCount(false);
-        // We're subtracting 1 because we're not making the final gid as a parameter.
-
-        int nonConstantParamCount = sigParamCount - 1;
-        boolean isStatic = (method.isStatic());
-        // Determine if this is an object lambda.
-        boolean isObjectLambda = true;
-
-        if (signature.getParameterType(nonConstantParamCount, null).getKind() == Kind.Int) {
-            isObjectLambda = false;
-        } else {
-            // Add space for gid int reg.
-            nonConstantParamCount++;
-        }
-
-        // If this is an instance method, include the "this" parameter
-        if (!isStatic) {
-            nonConstantParamCount++;
-        }
-        // Add in any "constant" parameters (currently none).
-        int totalParamCount = nonConstantParamCount;
-        JavaType[] paramtypes = new JavaType[totalParamCount];
-        String[] paramNames = new String[totalParamCount];
-        int pidx = 0;
-        MetaAccessProvider metaAccess = getProviders().getMetaAccess();
-        for (int i = 0; i < totalParamCount; i++) {
-            if (i == 0 && !isStatic) {
-                paramtypes[i] = metaAccess.lookupJavaType(Object.class);
-                paramNames[i] = "%_this";
-            } else if (i < nonConstantParamCount) {
-                if (isObjectLambda && (i == (nonConstantParamCount))) {
-                    // Set up the gid register mapping.
-                    paramtypes[i] = metaAccess.lookupJavaType(int.class);
-                    paramNames[i] = "%_gid";
-                } else {
-                    paramtypes[i] = signature.getParameterType(pidx++, null);
-                    paramNames[i] = "%_arg" + i;
-                }
-            }
-        }
-
-        asm.emitString0("// " + (isStatic ? "static" : "instance") + " method " + method + "\n");
-        asm.emitString0("kernel &run ( \n");
-
-        FrameMap frameMap = crb.frameMap;
-        RegisterConfig regConfig = frameMap.getRegisterConfig();
-        // Build list of param types which does include the gid (for cc register mapping query).
-        JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1];
-        // Include the gid.
-        System.arraycopy(paramtypes, 0, ccParamTypes, 0, nonConstantParamCount);
-
-        /*
-         * Last entry is always int (its register gets used in the workitemabsid instruction). This
-         * is true even for object stream lambdas.
-         */
-        if (sigParamCount > 0) {
-            ccParamTypes[ccParamTypes.length - 1] = metaAccess.lookupJavaType(int.class);
-        }
-        CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, ccParamTypes, getTarget(), false);
-
-        /**
-         * Compute the hsail size mappings up to but not including the last non-constant parameter
-         * (which is the gid).
-         *
-         */
-        String[] paramHsailSizes = new String[totalParamCount];
-        for (int i = 0; i < totalParamCount; i++) {
-            String paramtypeStr = paramtypes[i].toString();
-            String sizeStr = paramTypeMap.get(paramtypeStr);
-            // Catch all for any unmapped paramtype that is u64 (address of an object).
-            paramHsailSizes[i] = (sizeStr != null ? sizeStr : "u64");
-        }
-        // Emit the kernel function parameters.
-        for (int i = 0; i < totalParamCount; i++) {
-            String str = "align 8 kernarg_" + paramHsailSizes[i] + " " + paramNames[i];
-
-            if (useHSAILDeoptimization || (i != totalParamCount - 1)) {
-                str += ",";
-            }
-            asm.emitString(str);
-        }
-
-        if (useHSAILDeoptimization) {
-            // add in the deoptInfo parameter
-            asm.emitString("kernarg_u64 " + asm.getDeoptInfoName());
-        }
-
-        asm.emitString(") {");
-
-        /*
-         * End of parameters start of prolog code. Emit the load instructions for loading of the
-         * kernel non-constant parameters into registers. The constant class parameters will not be
-         * loaded up front but will be loaded as needed.
-         */
-        for (int i = 0; i < nonConstantParamCount; i++) {
-            asm.emitString("ld_kernarg_" + paramHsailSizes[i] + "  " + HSAIL.mapRegister(cc.getArgument(i)) + ", [" + paramNames[i] + "];");
-        }
-
-        /*
-         * Emit the workitemaid instruction for loading the hidden gid parameter. This is assigned
-         * the register as if it were the last of the nonConstant parameters.
-         */
-        String workItemReg = "$s" + Integer.toString(asRegister(cc.getArgument(nonConstantParamCount)).encoding());
-        asm.emitString("workitemabsid_u32 " + workItemReg + ", 0;");
-
-        final String deoptInProgressLabel = "@LHandleDeoptInProgress";
-
-        if (useHSAILDeoptimization) {
-            // Aliases for d16
-            RegisterValue d16DeoptInfo = HSAIL.d16.asValue(wordLIRKind);
-
-            // Aliases for d17
-            RegisterValue d17TlabIndex = HSAIL.d17.asValue(wordLIRKind);
-            RegisterValue d17SafepointFlagAddrIndex = d17TlabIndex;
-
-            // Aliases for s34
-            RegisterValue s34DeoptOccurred = HSAIL.s34.asValue(LIRKind.value(Kind.Int));
-            RegisterValue s34TlabIndex = s34DeoptOccurred;
-
-            asm.emitLoadKernelArg(d16DeoptInfo, asm.getDeoptInfoName(), "u64");
-            asm.emitComment("// Check if a deopt or safepoint has occurred and abort if true before doing any work");
-
-            if (useHSAILSafepoints) {
-                // Load address of _notice_safepoints field
-                asm.emitLoad(wordKind, d17SafepointFlagAddrIndex, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailNoticeSafepointsOffset).toAddress());
-                // Load int value from that field
-                asm.emitLoadAcquire(s34DeoptOccurred, new HSAILAddressValue(wordLIRKind, d17SafepointFlagAddrIndex, 0).toAddress());
-                asm.emitCompare(Kind.Int, s34DeoptOccurred, JavaConstant.forInt(0), "ne", false, false);
-                asm.cbr(deoptInProgressLabel);
-            }
-            asm.emitLoadAcquire(s34DeoptOccurred, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailDeoptOccurredOffset).toAddress());
-            asm.emitCompare(Kind.Int, s34DeoptOccurred, JavaConstant.forInt(0), "ne", false, false);
-            asm.cbr(deoptInProgressLabel);
-            // load thread register if this kernel performs allocation
-            if (usesAllocation) {
-                RegisterValue threadReg = getProviders().getRegisters().getThreadRegister().asValue(wordLIRKind);
-                assert HsailKernelTlabs.getValue() > 0;
-                asm.emitLoad(wordKind, threadReg, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailCurTlabInfoOffset).toAddress());
-                if (HsailKernelTlabs.getValue() != 1) {
-                    asm.emitComment("// map workitem to a tlab");
-                    asm.emitString(String.format("rem_u32  $%s, %s, %d;", s34TlabIndex.getRegister(), workItemReg, HsailKernelTlabs.getValue()));
-                    asm.emitConvert(d17TlabIndex, s34TlabIndex, wordKind, Kind.Int);
-                    asm.emit("mad", threadReg, d17TlabIndex, JavaConstant.forInt(8), threadReg);
-                } else {
-                    // workitem is already mapped to solitary tlab
-                }
-                asm.emitComment("// $" + getProviders().getRegisters().getThreadRegister() + " will point to holder of tlab thread info for this workitem");
-            }
-        }
-
-        /*
-         * Note the logic used for this spillseg size is to leave space and then go back and patch
-         * in the correct size once we have generated all the instructions. This should probably be
-         * done in a more robust way by implementing something like asm.insertString.
-         */
-        int spillsegDeclarationPosition = asm.position() + 1;
-        String spillsegTemplate = "align 4 spill_u8 %spillseg[123456];";
-        asm.emitString(spillsegTemplate);
-        // Emit object array load prologue here.
-        if (isObjectLambda) {
-            boolean useCompressedOops = config.useCompressedOops;
-            final int arrayElementsOffset = runtime().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. As of 1.0 spec, we cannot use
-             * ld_global_u32 $dxx, [addr]; so we need a temporary $s register. We can use
-             * workItemReg+1;
-             */
-            String tmpReg = "$d" + (asRegister(cc.getArgument(nonConstantParamCount - 1)).encoding() + 1);
-            // Convert gid to long.
-            asm.emitString("cvt_u64_s32 " + tmpReg + ", " + workItemReg + "; // Convert gid to long");
-            // Adjust index for sizeof ref. Where to pull this size from?
-            asm.emitString("mul_u64 " + tmpReg + ", " + tmpReg + ", " + (useCompressedOops ? 4 : 8) + "; // Adjust index for sizeof ref");
-            // Adjust for actual data start.
-            asm.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + arrayElementsOffset + "; // Adjust for actual elements data start");
-            // Add to array ref ptr.
-            asm.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + iterationObjArgReg + "; // Add to array ref ptr");
-            // Load the object into the parameter reg.
-            if (useCompressedOops) {
-                int workItemRegEncoding = asRegister(cc.getArgument(nonConstantParamCount)).encoding();
-                String tmpReg32 = "$s" + Integer.toString(workItemRegEncoding + 1);
-
-                // Load u32 into the temporary $s reg since it will become an object address
-
-                asm.emitString("ld_global_u32 " + tmpReg32 + ", " + "[" + tmpReg + "]" + "; // Load compressed ptr from array");
-                asm.emitString("cvt_u64_u32 " + tmpReg + ", " + tmpReg32 + ";      // cvt to 64 bits");
-
-                long narrowOopBase = config.narrowOopBase;
-                long narrowOopShift = config.narrowOopShift;
-
-                if (narrowOopBase == 0 && narrowOopShift == 0) {
-                    // No more calculation to do, mov to target register
-                    asm.emitString("mov_b64 " + iterationObjArgReg + ", " + tmpReg + "; // no shift or base addition");
-                } else {
-                    if (narrowOopBase == 0) {
-                        asm.emitString("shl_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopShift + "; // do narrowOopShift");
-                    } else if (narrowOopShift == 0) {
-                        // not sure if we ever get add with 0 shift but just in case
-                        asm.emitString("cmp_eq_b1_u64  $c0, " + tmpReg + ", 0x0; // avoid add if compressed is null");
-                        asm.emitString("add_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopBase + "; // add narrowOopBase");
-                        asm.emitString("cmov_b64 " + iterationObjArgReg + ", $c0, 0x0, " + iterationObjArgReg + "; // avoid add if compressed is null");
-                    } else {
-                        asm.emitString("cmp_eq_b1_u64  $c0, " + tmpReg + ", 0x0; // avoid shift-add if compressed is null");
-                        asm.emitString("mad_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + (1 << narrowOopShift) + ", " + narrowOopBase + "; // shift and add narrowOopBase");
-                        asm.emitString("cmov_b64 " + iterationObjArgReg + ", $c0, 0x0, " + iterationObjArgReg + "; // avoid shift-add if compressed is null");
-                    }
-                }
-
-            } else {
-                asm.emitString("ld_global_u64 " + iterationObjArgReg + ", " + "[" + tmpReg + "]" + "; // Load from array element into parameter reg");
-            }
-        }
-        // Prologue done, Emit code for the LIR.
-        crb.emit(lir);
-        // Now that code is emitted go back and figure out what the upper Bound stack size was.
-        long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize();
-        String spillsegStringFinal;
-        if (maxStackSize == 0) {
-            // If no spilling, get rid of spillseg declaration.
-            char[] array = new char[spillsegTemplate.length()];
-            Arrays.fill(array, ' ');
-            spillsegStringFinal = new String(array);
-        } else {
-            spillsegStringFinal = spillsegTemplate.replace("123456", String.format("%6d", maxStackSize));
-        }
-        asm.emitString(spillsegStringFinal, spillsegDeclarationPosition);
-        // Emit the epilogue.
-
-        HSAILHotSpotLIRGenerationResult lirGenRes = ((HSAILCompilationResultBuilder) crb).lirGenRes;
-
-        int numSRegs = 0;
-        int numDRegs = 0;
-        int numStackSlotBytes = 0;
-        if (useHSAILDeoptimization) {
-            /*
-             * Get the union of registers and stack slots needed to be saved at the infopoints.
-             * While doing this compute the highest register in each category.
-             */
-            HSAILHotSpotRegisterConfig hsailRegConfig = (HSAILHotSpotRegisterConfig) regConfig;
-            Set<Register> infoUsedRegs = new TreeSet<>();
-            Set<StackSlot> infoUsedStackSlots = new HashSet<>();
-            List<Infopoint> infoList = crb.compilationResult.getInfopoints();
-            Queue<JavaValue[]> workList = new LinkedList<>();
-            for (Infopoint info : infoList) {
-                BytecodeFrame frame = info.debugInfo.frame();
-                while (frame != null) {
-                    workList.add(frame.values);
-                    frame = frame.caller();
-                }
-            }
-            while (!workList.isEmpty()) {
-                JavaValue[] values = workList.poll();
-                for (JavaValue val : values) {
-                    if (!Value.ILLEGAL.equals(val)) {
-                        if (val instanceof RegisterValue) {
-                            Register reg = ((RegisterValue) val).getRegister();
-                            infoUsedRegs.add(reg);
-                            if (hsailRegConfig.isAllocatableSReg(reg)) {
-                                numSRegs = Math.max(numSRegs, reg.encoding + 1);
-                            } else if (hsailRegConfig.isAllocatableDReg(reg)) {
-                                numDRegs = Math.max(numDRegs, reg.encoding + 1);
-                            }
-                        } else if (val instanceof StackSlot) {
-                            StackSlot slot = (StackSlot) val;
-                            Kind slotKind = slot.getKind();
-                            int slotSizeBytes = (slotKind.isObject() ? 8 : slotKind.getByteCount());
-                            int slotOffsetMax = HSAIL.getStackOffsetStart(slot, slotSizeBytes * 8) + slotSizeBytes;
-                            numStackSlotBytes = Math.max(numStackSlotBytes, slotOffsetMax);
-                            infoUsedStackSlots.add(slot);
-                        } else if (val instanceof VirtualObject) {
-                            workList.add(((VirtualObject) val).getValues());
-                        } else {
-                            assert val instanceof JavaConstant : "Unsupported value: " + val;
-                        }
-                    }
-                }
-            }
-
-            // round up numSRegs to even number so dregs start on aligned boundary
-            numSRegs += (numSRegs & 1);
-
-            // numStackSlots is the number of 8-byte locations used for stack variables
-            int numStackSlots = (numStackSlotBytes + 7) / 8;
-
-            final int offsetToDeoptSaveStates = config.hsailDeoptimizationInfoHeaderSize;
-            final int bytesPerSaveArea = 4 * numSRegs + 8 * numDRegs + 8 * numStackSlots;
-            final int sizeofKernelDeopt = config.hsailKernelDeoptimizationHeaderSize + config.hsailFrameHeaderSize + bytesPerSaveArea;
-            final int offsetToNeverRanArray = config.hsailNeverRanArrayOffset;
-            final int offsetToDeoptNextIndex = config.hsailDeoptNextIndexOffset;
-            final int offsetToDeoptimizationWorkItem = config.hsailDeoptimizationWorkItem;
-            final int offsetToDeoptimizationReason = config.hsailDeoptimizationReason;
-            final int offsetToDeoptimizationFrame = config.hsailKernelDeoptimizationHeaderSize;
-            final int offsetToFramePc = config.hsailFramePcOffset;
-            final int offsetToNumSaves = config.hsailFrameNumSRegOffset;
-            final int offsetToSaveArea = config.hsailFrameHeaderSize;
-
-            AllocatableValue scratch64 = HSAIL.d16.asValue(wordLIRKind);
-            AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(wordLIRKind);
-            AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(wordLIRKind);
-            AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordLIRKind);
-
-            AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int));
-            AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int));
-            AllocatableValue scratch32 = HSAIL.s34.asValue(LIRKind.value(Kind.Int));
-            AllocatableValue workidreg = HSAIL.s35.asValue(LIRKind.value(Kind.Int));
-
-            HSAILAddress deoptNextIndexAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptNextIndex).toAddress();
-            HSAILAddress neverRanArrayAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToNeverRanArray).toAddress();
-
-            // The just-started lanes that see the deopt flag will jump here
-            asm.emitString0(deoptInProgressLabel + ":\n");
-            asm.emitLoad(wordKind, waveMathScratch1, neverRanArrayAddr);
-            asm.emitWorkItemAbsId(workidreg);
-            asm.emitConvert(waveMathScratch2, workidreg, wordKind, Kind.Int);
-            asm.emit("add", waveMathScratch1, waveMathScratch1, waveMathScratch2);
-            HSAILAddress neverRanStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, 0).toAddress();
-            asm.emitStore(Kind.Byte, JavaConstant.forInt(1), neverRanStoreAddr);
-            asm.emitString("ret;");
-
-            // The deoptimizing lanes will jump here
-            asm.emitString0(asm.getDeoptLabelName() + ":\n");
-            String labelExit = asm.getDeoptLabelName() + "_Exit";
-
-            HSAILAddress deoptInfoAddr = new HSAILAddressValue(wordLIRKind, scratch64, config.hsailDeoptOccurredOffset).toAddress();
-            asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64");
-
-            // Set deopt occurred flag
-            asm.emitMov(Kind.Int, scratch32, JavaConstant.forInt(1));
-            asm.emitStoreRelease(scratch32, deoptInfoAddr);
-
-            asm.emitComment("// Determine next deopt save slot");
-            asm.emitAtomicAdd(scratch32, deoptNextIndexAddr, JavaConstant.forInt(1));
-            /*
-             * 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(Kind.Int, scratch32, JavaConstant.forInt(maxDeoptIndex), "lt", false, false);
-            asm.cbr("@L_StoreDeopt");
-            /*
-             * if assert fails, store a guaranteed negative workitemid in top level deopt occurred
-             * flag
-             */
-            asm.emitWorkItemAbsId(scratch32);
-            asm.emit("mad", scratch32, scratch32, JavaConstant.forInt(-1), JavaConstant.forInt(-1));
-            asm.emitStore(scratch32, deoptInfoAddr);
-            asm.emitString("ret;");
-
-            asm.emitString0("@L_StoreDeopt" + ":\n");
-
-            // Store deopt for this workitem into its slot in the HSAILComputeUnitSaveStates array
-
-            asm.emitComment("// Convert id's for ptr math");
-            asm.emitConvert(cuSaveAreaPtr, scratch32, wordKind, Kind.Int);
-            asm.emitComment("// multiply by sizeof KernelDeoptArea");
-            asm.emit("mul", cuSaveAreaPtr, cuSaveAreaPtr, JavaConstant.forInt(sizeofKernelDeopt));
-            asm.emitComment("// Add computed offset to deoptInfoPtr base");
-            asm.emit("add", cuSaveAreaPtr, cuSaveAreaPtr, scratch64);
-            // Add offset to _deopt_save_states[0]
-            asm.emit("add", scratch64, cuSaveAreaPtr, JavaConstant.forInt(offsetToDeoptSaveStates));
-
-            HSAILAddress workItemAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationWorkItem).toAddress();
-            HSAILAddress actionReasonStoreAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationReason).toAddress();
-
-            asm.emitComment("// Get _deopt_info._first_frame");
-            asm.emit("add", waveMathScratch1, scratch64, JavaConstant.forInt(offsetToDeoptimizationFrame));
-            // Now scratch64 is the _deopt_info._first_frame
-            HSAILAddress pcStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToFramePc).toAddress();
-            HSAILAddress regCountsAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToNumSaves).toAddress();
-            asm.emitComment("// store deopting workitem");
-            asm.emitWorkItemAbsId(scratch32);
-            asm.emitStore(Kind.Int, scratch32, workItemAddr);
-            asm.emitComment("// store actionAndReason");
-            asm.emitStore(Kind.Int, actionAndReasonReg, actionReasonStoreAddr);
-            asm.emitComment("// store PC");
-            asm.emitStore(Kind.Int, codeBufferOffsetReg, pcStoreAddr);
-
-            asm.emitComment("// store regCounts (" + numSRegs + " $s registers, " + numDRegs + " $d registers, " + numStackSlots + " stack slots)");
-            asm.emitStore(Kind.Int, JavaConstant.forInt(numSRegs + (numDRegs << 8) + (numStackSlots << 16)), regCountsAddr);
-
-            /*
-             * Loop thru the usedValues storing each of the registers that are used. We always store
-             * in a fixed location, even if some registers are skipped.
-             */
-            asm.emitComment("// store used regs");
-            for (Register reg : infoUsedRegs) {
-                if (hsailRegConfig.isAllocatableSReg(reg)) {
-                    // 32 bit registers
-                    Kind kind = Kind.Int;
-                    int ofst = offsetToSaveArea + reg.encoding * 4;
-                    HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress();
-                    AllocatableValue regValue = reg.asValue(LIRKind.value(kind));
-                    asm.emitStore(kind, regValue, addr);
-                } else if (hsailRegConfig.isAllocatableDReg(reg)) {
-                    // 64 bit registers
-                    Kind kind = Kind.Long;
-                    // d reg ofst starts past the 32 sregs
-                    int ofst = offsetToSaveArea + (numSRegs * 4) + reg.encoding * 8;
-                    HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress();
-                    AllocatableValue regValue = reg.asValue(LIRKind.value(kind));
-                    asm.emitStore(kind, regValue, addr);
-                } else {
-                    throw GraalInternalError.unimplemented();
-                }
-            }
-
-            // loop thru the usedStackSlots creating instructions to save in the save area
-            if (numStackSlotBytes > 0) {
-                asm.emitComment("// store stack slots (uses " + numStackSlotBytes + " bytes)");
-                for (StackSlot slot : infoUsedStackSlots) {
-                    asm.emitComment("// store " + slot);
-                    Kind kind = slot.getKind();
-                    int sizeInBits = (kind.isObject() || kind.getByteCount() == 8 ? 64 : 32);
-                    int ofst = offsetToSaveArea + (numSRegs * 4) + (numDRegs * 8) + HSAIL.getStackOffsetStart(slot, sizeInBits);
-                    HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress();
-                    if (sizeInBits == 64) {
-                        asm.emitSpillLoad(kind, scratch64, slot);
-                        asm.emitStore(kind, scratch64, addr);
-                    } else {
-                        asm.emitSpillLoad(kind, scratch32, slot);
-                        asm.emitStore(kind, scratch32, addr);
-                    }
-                }
-            }
-
-            asm.emitString0(labelExit + ":\n");
-
-            // and emit the return
-            crb.frameContext.leave(crb);
-            asm.exit();
-            // build the oopMap Array
-            int[] oopMapArray = new OopMapArrayBuilder().build(infoList, numSRegs, numDRegs, numStackSlots, hsailRegConfig);
-            ((ExternalCompilationResult) crb.compilationResult).setOopMapArray(oopMapArray);
-        } 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;
-        if (useHSAILDeoptimization) {
-            compilationResult.setHostGraph(prepareHostGraph(method, lirGenRes.getDeopts(), getProviders(), config, numSRegs, numDRegs));
-        }
-    }
-
-    private static class OopMapArrayBuilder {
-        // oopMapArray struct
-        // int bytesPerSaveArea; (not strictly part of oopsmap but convenient to put here)
-        // int intsPerInfopoint;
-        static final int SAVEAREACOUNTS_OFST = 0;
-        static final int INTSPERINFOPOINT_OFST = 1;
-        static final int HEADERSIZE = 2;
-        // for each infopoint:
-        // int deoptId
-        // one or more ints of bits for the oopmap
-
-        private int[] array;
-        private int intsPerInfopoint;
-
-        int[] build(List<Infopoint> infoList, int numSRegs, int numDRegs, int numStackSlots, HSAILHotSpotRegisterConfig hsailRegConfig) {
-            /*
-             * We are told that infoList is always sorted. Each infoPoint can have a different
-             * oopMap. Since numStackSlots is the number of 8-byte stack slots used, it is an upper
-             * limit on the number of oop stack slots
-             */
-            int bitsPerInfopoint = numDRegs + numStackSlots;
-            int intsForBits = (bitsPerInfopoint + 31) / 32;
-            int numInfopoints = infoList.size();
-            intsPerInfopoint = intsForBits + 1;  // +1 for the pcoffset
-            int arraySize = HEADERSIZE + (numInfopoints * intsPerInfopoint);
-            array = new int[arraySize];
-            array[INTSPERINFOPOINT_OFST] = intsPerInfopoint;
-            // compute saveAreaCounts
-            int saveAreaCounts = (numSRegs & 0xff) + (numDRegs << 8) + (numStackSlots << 16);
-            array[SAVEAREACOUNTS_OFST] = saveAreaCounts;
-
-            // loop thru the infoList
-            int infoIndex = 0;
-            for (Infopoint info : infoList) {
-                setOopMapPcOffset(infoIndex, info.pcOffset);
-                BytecodeFrame frame = info.debugInfo.frame();
-                while (frame != null) {
-                    for (int i = 0; i < frame.numLocals + frame.numStack; i++) {
-                        JavaValue val = frame.values[i];
-                        if (val instanceof RegisterValue) {
-                            Register reg = ((RegisterValue) val).getRegister();
-                            if (val.getKind().isObject()) {
-                                assert (hsailRegConfig.isAllocatableDReg(reg));
-                                int bitIndex = reg.encoding();
-                                setOopMapBit(infoIndex, bitIndex);
-                            }
-                        } else if (val instanceof StackSlot) {
-                            StackSlot slot = (StackSlot) val;
-                            if (val.getKind().isObject()) {
-                                assert (HSAIL.getStackOffsetStart(slot, 64) % 8 == 0);
-                                int bitIndex = numDRegs + HSAIL.getStackOffsetStart(slot, 64) / 8;
-                                setOopMapBit(infoIndex, bitIndex);
-                            }
-                        }
-                    }
-                    frame = frame.caller();
-                }
-                infoIndex++;
-            }
-            try (Scope s = Debug.scope("CodeGen")) {
-                if (Debug.isLogEnabled()) {
-                    Debug.log("numSRegs=%d, numDRegs=%d, numStackSlots=%d", numSRegs, numDRegs, numStackSlots);
-                    // show infopoint oopmap details
-                    for (infoIndex = 0; infoIndex < infoList.size(); infoIndex++) {
-                        String infoString = "Infopoint " + infoIndex + ", pcOffset=" + getOopMapPcOffset(infoIndex) + ",   oopmap=";
-                        for (int i = 0; i < intsForBits; i++) {
-                            infoString += (i != 0 ? ", " : "") + Integer.toHexString(getOopMapBitsAsInt(infoIndex, i));
-                        }
-                        Debug.log(infoString);
-                    }
-                }
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-
-            return array;
-        }
-
-        private void setOopMapPcOffset(int infoIndex, int pcOffset) {
-            int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint;
-            array[arrIndex] = pcOffset;
-        }
-
-        private int getOopMapPcOffset(int infoIndex) {
-            int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint;
-            return array[arrIndex];
-        }
-
-        private void setOopMapBit(int infoIndex, int bitIndex) {
-            int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint + 1 + bitIndex / 32;
-            array[arrIndex] |= (1 << (bitIndex % 32));
-        }
-
-        private int getOopMapBitsAsInt(int infoIndex, int intIndex) {
-            int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint + 1 + intIndex;
-            return array[arrIndex];
-        }
-    }
-
-    private static StructuredGraph prepareHostGraph(ResolvedJavaMethod method, List<DeoptimizingOp> deopts, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs) {
-        if (deopts.isEmpty()) {
-            return null;
-        }
-        StructuredGraph hostGraph = new StructuredGraph(method, -2);
-        ParameterNode deoptId = hostGraph.unique(new ParameterNode(0, StampFactory.intValue()));
-        ParameterNode hsailFrame = hostGraph.unique(new ParameterNode(1, StampFactory.forKind(providers.getCodeCache().getTarget().wordKind)));
-        ParameterNode reasonAndAction = hostGraph.unique(new ParameterNode(2, StampFactory.intValue()));
-        ParameterNode speculation = hostGraph.unique(new ParameterNode(3, StampFactory.object()));
-        BeginNode[] branches = new BeginNode[deopts.size() + 1];
-        int[] keys = new int[deopts.size()];
-        int[] keySuccessors = new int[deopts.size() + 1];
-        double[] keyProbabilities = new double[deopts.size() + 1];
-        int i = 0;
-        Collections.sort(deopts, new Comparator<DeoptimizingOp>() {
-            public int compare(DeoptimizingOp o1, DeoptimizingOp o2) {
-                return o1.getCodeBufferPos() - o2.getCodeBufferPos();
-            }
-        });
-        for (DeoptimizingOp deopt : deopts) {
-            keySuccessors[i] = i;
-            keyProbabilities[i] = 1.0 / deopts.size();
-            keys[i] = deopt.getCodeBufferPos();
-            assert keys[i] >= 0;
-            branches[i] = createHostDeoptBranch(deopt, hsailFrame, reasonAndAction, speculation, providers, config, numSRegs, numDRegs);
-
-            i++;
-        }
-        keyProbabilities[deopts.size()] = 0; // default
-        keySuccessors[deopts.size()] = deopts.size();
-        branches[deopts.size()] = createHostCrashBranch(hostGraph, deoptId);
-        IntegerSwitchNode switchNode = hostGraph.add(new IntegerSwitchNode(deoptId, branches, keys, keyProbabilities, keySuccessors));
-        StartNode start = hostGraph.start();
-        start.setNext(switchNode);
-        /*
-         * printf.setNext(printf2); printf2.setNext(switchNode);
-         */
-        hostGraph.setGuardsStage(GuardsStage.AFTER_FSA);
-        return hostGraph;
-    }
-
-    private static BeginNode createHostCrashBranch(StructuredGraph hostGraph, ValueNode deoptId) {
-        VMErrorNode vmError = hostGraph.add(new VMErrorNode("Error in HSAIL deopt. DeoptId=%d", deoptId));
-        // ConvertNode.convert(hostGraph, Kind.Long, deoptId)));
-        vmError.setNext(hostGraph.add(new ReturnNode(ConstantNode.defaultForKind(hostGraph.method().getSignature().getReturnKind(), hostGraph))));
-        return BeginNode.begin(vmError);
-    }
-
-    private static BeginNode createHostDeoptBranch(DeoptimizingOp deopt, ParameterNode hsailFrame, ValueNode reasonAndAction, ValueNode speculation, HotSpotProviders providers,
-                    HotSpotVMConfig config, int numSRegs, int numDRegs) {
-        BeginNode branch = hsailFrame.graph().add(new BeginNode());
-        DynamicDeoptimizeNode deoptimization = hsailFrame.graph().add(new DynamicDeoptimizeNode(reasonAndAction, speculation));
-        deoptimization.setStateBefore(createFrameState(deopt.getFrameState().topFrame, hsailFrame, providers, config, numSRegs, numDRegs));
-        branch.setNext(deoptimization);
-        return branch;
-    }
-
-    private static FrameState createFrameState(BytecodeFrame lowLevelFrame, ParameterNode hsailFrame, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs) {
-        return createFrameState(lowLevelFrame, hsailFrame, providers, config, numSRegs, numDRegs, new HashMap<VirtualObject, VirtualObjectNode>());
-    }
-
-    private static FrameState createFrameState(BytecodeFrame lowLevelFrame, ParameterNode hsailFrame, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs,
-                    Map<VirtualObject, VirtualObjectNode> virtualObjects) {
-        FrameState outterFrameState = null;
-        if (lowLevelFrame.caller() != null) {
-            outterFrameState = createFrameState(lowLevelFrame.caller(), hsailFrame, providers, config, numSRegs, numDRegs, virtualObjects);
-        }
-        StructuredGraph hostGraph = hsailFrame.graph();
-        Function<? super JavaValue, ? extends ValueNode> lirValueToHirNode = v -> getNodeForValueFromFrame(v, hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects);
-        ValueNode[] locals = new ValueNode[lowLevelFrame.numLocals];
-        for (int i = 0; i < lowLevelFrame.numLocals; i++) {
-            locals[i] = lirValueToHirNode.apply(lowLevelFrame.getLocalValue(i));
-        }
-        List<ValueNode> stack = new ArrayList<>(lowLevelFrame.numStack);
-        for (int i = 0; i < lowLevelFrame.numStack; i++) {
-            stack.add(lirValueToHirNode.apply(lowLevelFrame.getStackValue(i)));
-        }
-        ValueNode[] locks = new ValueNode[lowLevelFrame.numLocks];
-        MonitorIdNode[] monitorIds = new MonitorIdNode[lowLevelFrame.numLocks];
-        for (int i = 0; i < lowLevelFrame.numLocks; i++) {
-            HotSpotMonitorValue lockValue = (HotSpotMonitorValue) lowLevelFrame.getLockValue(i);
-            locks[i] = lirValueToHirNode.apply(lockValue);
-            monitorIds[i] = getMonitorIdForHotSpotMonitorValueFromFrame(lockValue, hsailFrame, hostGraph);
-        }
-        FrameState frameState = hostGraph.add(new FrameState(lowLevelFrame.getMethod(), lowLevelFrame.getBCI(), locals, stack, locks, monitorIds, lowLevelFrame.rethrowException, false));
-        if (outterFrameState != null) {
-            frameState.setOuterFrameState(outterFrameState);
-        }
-        Map<VirtualObject, VirtualObjectNode> virtualObjectsCopy;
-        // TODO this could be implemented more efficiently with a mark into the map
-        // unfortunately LinkedHashMap doesn't seem to provide that.
-        List<VirtualObjectState> virtualStates = new ArrayList<>(virtualObjects.size());
-        do {
-            virtualObjectsCopy = new HashMap<>(virtualObjects);
-            virtualStates.clear();
-            for (Entry<VirtualObject, VirtualObjectNode> entry : virtualObjectsCopy.entrySet()) {
-                VirtualObject virtualObject = entry.getKey();
-                VirtualObjectNode virtualObjectNode = entry.getValue();
-                List<ValueNode> fieldValues = Arrays.stream(virtualObject.getValues()).map(lirValueToHirNode).collect(Collectors.toList());
-                virtualStates.add(new VirtualObjectState(virtualObjectNode, fieldValues));
-            }
-            // New virtual objects may have been discovered while processing the previous set.
-            // Wait until a fixed point is reached
-        } while (virtualObjectsCopy.size() < virtualObjects.size());
-        virtualStates.forEach(vos -> frameState.addVirtualObjectMapping(hostGraph.unique(vos)));
-        return frameState;
-    }
-
-    @SuppressWarnings("unused")
-    private static MonitorIdNode getMonitorIdForHotSpotMonitorValueFromFrame(HotSpotMonitorValue lockValue, ParameterNode hsailFrame, StructuredGraph hsailGraph) {
-        if (lockValue.isEliminated()) {
-            return null;
-        }
-        throw GraalInternalError.unimplemented();
-    }
-
-    private static ValueNode getNodeForValueFromFrame(JavaValue localValue, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs,
-                    int numDRegs, Map<VirtualObject, VirtualObjectNode> virtualObjects) {
-        ValueNode valueNode;
-        if (localValue instanceof JavaConstant) {
-            valueNode = ConstantNode.forConstant((JavaConstant) localValue, providers.getMetaAccess(), hostGraph);
-        } else if (localValue instanceof VirtualObject) {
-            valueNode = getNodeForVirtualObjectFromFrame((VirtualObject) localValue, virtualObjects, hostGraph);
-        } else if (localValue instanceof StackSlot) {
-            StackSlot slot = (StackSlot) localValue;
-            valueNode = getNodeForStackSlotFromFrame(slot, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs);
-        } else if (localValue instanceof HotSpotMonitorValue) {
-            HotSpotMonitorValue hotSpotMonitorValue = (HotSpotMonitorValue) localValue;
-            return getNodeForValueFromFrame(hotSpotMonitorValue.getOwner(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects);
-        } else if (localValue instanceof RegisterValue) {
-            RegisterValue registerValue = (RegisterValue) localValue;
-            int regNumber = registerValue.getRegister().number;
-            valueNode = getNodeForRegisterFromFrame(regNumber, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs);
-        } else if (Value.ILLEGAL.equals(localValue)) {
-            valueNode = null;
-        } else {
-            throw GraalInternalError.shouldNotReachHere();
-        }
-        return valueNode;
-    }
-
-    private static ValueNode getNodeForVirtualObjectFromFrame(VirtualObject virtualObject, Map<VirtualObject, VirtualObjectNode> virtualObjects, StructuredGraph hostGraph) {
-        return virtualObjects.computeIfAbsent(virtualObject, vo -> {
-            if (vo.getType().isArray()) {
-                return hostGraph.add(new VirtualArrayNode(vo.getType().getComponentType(), vo.getValues().length));
-            } else {
-                return hostGraph.add(new VirtualInstanceNode(vo.getType(), true));
-            }
-        });
-    }
-
-    private static ValueNode getNodeForRegisterFromFrame(int regNumber, Kind valueKind, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config,
-                    int numSRegs) {
-        ValueNode valueNode;
-        LocationNode location;
-        int longSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Long);
-        int intSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Int);
-        if (regNumber >= HSAIL.s0.number && regNumber <= HSAIL.s31.number) {
-            long offset = config.hsailFrameHeaderSize + intSize * (regNumber - HSAIL.s0.number);
-            location = hostGraph.unique(new ConstantLocationNode(FINAL_LOCATION, offset));
-        } else if (regNumber >= HSAIL.d0.number && regNumber <= HSAIL.d15.number) {
-            long offset = config.hsailFrameHeaderSize + intSize * numSRegs + longSize * (regNumber - HSAIL.d0.number);
-            location = hostGraph.unique(new ConstantLocationNode(FINAL_LOCATION, offset));
-        } else {
-            throw GraalInternalError.shouldNotReachHere("unknown hsail register: " + regNumber);
-        }
-        valueNode = hostGraph.unique(new FloatingReadNode(hsailFrame, location, null, StampFactory.forKind(valueKind)));
-        return valueNode;
-    }
-
-    private static ValueNode getNodeForStackSlotFromFrame(StackSlot slot, Kind valueKind, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config,
-                    int numSRegs, int numDRegs) {
-        int slotSizeInBits = (valueKind == Kind.Object ? 64 : valueKind.getByteCount() * 8);
-        if ((slotSizeInBits == 32) || (slotSizeInBits == 64)) {
-            int longSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Long);
-            int intSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Int);
-            long offset = config.hsailFrameHeaderSize + (intSize * numSRegs) + (longSize * numDRegs) + HSAIL.getStackOffsetStart(slot, slotSizeInBits);
-            LocationNode location = hostGraph.unique(new ConstantLocationNode(FINAL_LOCATION, offset));
-            ValueNode valueNode = hostGraph.unique(new FloatingReadNode(hsailFrame, location, null, StampFactory.forKind(valueKind)));
-            return valueNode;
-        } else {
-            throw GraalInternalError.shouldNotReachHere("unsupported stack slot kind: " + valueKind);
-        }
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +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.hotspot.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.hsail.replacements.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hsail.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.phases.util.*;
-
-@ServiceProvider(HotSpotBackendFactory.class)
-public class HSAILHotSpotBackendFactory implements HotSpotBackendFactory {
-
-    protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers,
-                    TargetDescription target) {
-        return new HSAILHotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers, target);
-    }
-
-    @Override
-    public HSAILHotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotBackend hostBackend) {
-        HotSpotProviders host = hostBackend.getProviders();
-
-        HotSpotRegisters registers = new HotSpotRegisters(HSAIL.threadRegister, Register.None, Register.None);
-        MetaAccessProvider metaAccess = host.getMetaAccess();
-        TargetDescription target = createTarget();
-        HSAILHotSpotCodeCacheProvider codeCache = new HSAILHotSpotCodeCacheProvider(runtime, target);
-        ConstantReflectionProvider constantReflection = host.getConstantReflection();
-        HotSpotForeignCallsProvider foreignCalls = new HSAILHotSpotForeignCallsProvider(runtime, metaAccess, codeCache);
-        HotSpotLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, target);
-        // Replacements cannot have speculative optimizations since they have
-        // 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, new HotSpotStampProvider());
-        Replacements replacements = new HSAILHotSpotReplacementsImpl(p, host.getSnippetReflection(), assumptions, codeCache.getTarget(), host.getReplacements());
-        HotSpotDisassemblerProvider disassembler = host.getDisassembler();
-        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);
-    }
-
-    protected TargetDescription createTarget() {
-        final int stackFrameAlignment = 8;
-        final int implicitNullCheckLimit = 0;
-        final boolean inlineObjects = true;
-        return new HotSpotTargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
-    }
-
-    public String getArchitecture() {
-        return "HSAIL";
-    }
-
-    public String getGraalRuntimeName() {
-        return "basic";
-    }
-
-    @Override
-    public String toString() {
-        return getGraalRuntimeName() + ":" + getArchitecture();
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotCodeCacheProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /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.hotspot.hsail;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-
-public class HSAILHotSpotCodeCacheProvider extends HotSpotCodeCacheProvider {
-
-    public HSAILHotSpotCodeCacheProvider(HotSpotGraalRuntimeProvider runtime, TargetDescription target) {
-        super(runtime, target, new HSAILHotSpotRegisterConfig());
-
-    }
-
-    @Override
-    public String disassemble(CompilationResult compResult, InstalledCode installedCode) {
-        byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
-        return new String(code);
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotForeignCallsProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +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.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-
-public class HSAILHotSpotForeignCallsProvider extends HotSpotForeignCallsProviderImpl {
-
-    public HSAILHotSpotForeignCallsProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, CodeCacheProvider codeCache) {
-        super(runtime, metaAccess, codeCache);
-    }
-
-    @Override
-    public HotSpotForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
-        // we don't really support foreign calls yet, but we do want to generate dummy code for them
-        // so we lazily create dummy linkages here.
-        if (foreignCalls.get(descriptor) == null) {
-            return register(new HotSpotForeignCallLinkageImpl(descriptor, 0x12345678, null, null, null, null, false, new LocationIdentity[0]));
-        } else {
-            return super.lookupForeignCall(descriptor);
-        }
-    }
-
-    @Override
-    public boolean isReexecutable(ForeignCallDescriptor descriptor) {
-        return lookupForeignCall(descriptor).isReexecutable();
-    }
-
-    @Override
-    public LocationIdentity[] getKilledLocations(ForeignCallDescriptor descriptor) {
-        return lookupForeignCall(descriptor).getKilledLocations();
-    }
-
-    @Override
-    public boolean canDeoptimize(ForeignCallDescriptor descriptor) {
-        return lookupForeignCall(descriptor).canDeoptimize();
-    }
-
-    public Value[] getNativeABICallerSaveRegisters() {
-        // TODO is this correct?
-        return new Value[0];
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerationResult.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.hsail;
-
-import java.util.*;
-
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.framemap.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizingOp;
-
-public class HSAILHotSpotLIRGenerationResult extends LIRGenerationResultBase {
-
-    private List<DeoptimizingOp> deopts = new ArrayList<>();
-
-    public HSAILHotSpotLIRGenerationResult(LIR lir, FrameMapBuilder frameMapBuilder) {
-        super(lir, frameMapBuilder);
-    }
-
-    public List<DeoptimizingOp> getDeopts() {
-        return deopts;
-    }
-
-    public void addDeopt(DeoptimizingOp deopt) {
-        deopts.add(deopt);
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,300 +0,0 @@
-/*
- * 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.hsail;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.compiler.hsail.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.SaveRegistersOp;
-import com.oracle.graal.lir.gen.*;
-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.LoadAcquireOp;
-import com.oracle.graal.lir.hsail.HSAILMove.LoadOp;
-import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp;
-import com.oracle.graal.lir.hsail.HSAILMove.StoreConstantOp;
-import com.oracle.graal.lir.hsail.HSAILMove.StoreOp;
-import com.oracle.graal.lir.hsail.HSAILMove.StoreReleaseOp;
-import com.oracle.graal.lir.hsail.HSAILMove.WorkItemAbsIdOp;
-import com.oracle.graal.phases.util.*;
-
-/**
- * The HotSpot specific portion of the HSAIL LIR generator.
- */
-public class HSAILHotSpotLIRGenerator extends HSAILLIRGenerator implements HotSpotLIRGenerator {
-
-    final HotSpotVMConfig config;
-
-    public HSAILHotSpotLIRGenerator(Providers providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) {
-        super(new DefaultLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes);
-        this.config = config;
-    }
-
-    @Override
-    public HotSpotProviders getProviders() {
-        return (HotSpotProviders) super.getProviders();
-    }
-
-    int getLogMinObjectAlignment() {
-        return config.logMinObjAlignment();
-    }
-
-    int getNarrowOopShift() {
-        return config.narrowOopShift;
-    }
-
-    long getNarrowOopBase() {
-        return config.narrowOopBase;
-    }
-
-    int getLogKlassAlignment() {
-        return config.logKlassAlignment;
-    }
-
-    int getNarrowKlassShift() {
-        return config.narrowKlassShift;
-    }
-
-    long getNarrowKlassBase() {
-        return config.narrowKlassBase;
-    }
-
-    private static boolean canStoreConstant(JavaConstant c) {
-        return !(c instanceof HotSpotObjectConstant);
-    }
-
-    @Override
-    public boolean canInlineConstant(JavaConstant c) {
-        if (c instanceof HotSpotObjectConstant) {
-            return c.isNull();
-        } else {
-            return super.canInlineConstant(c);
-        }
-    }
-
-    @Override
-    public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) {
-        HSAILAddressValue loadAddress = asAddressValue(address);
-        Variable result = newVariable(kind);
-        append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state));
-        return result;
-    }
-
-    public Variable emitLoadAcquire(LIRKind kind, Value address, LIRFrameState state) {
-        HSAILAddressValue loadAddress = asAddressValue(address);
-        Variable result = newVariable(kind);
-        append(new LoadAcquireOp((Kind) kind.getPlatformKind(), result, loadAddress, state));
-        return result;
-    }
-
-    @Override
-    public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) {
-        HSAILAddressValue storeAddress = asAddressValue(address);
-        if (isConstant(inputVal)) {
-            JavaConstant c = asConstant(inputVal);
-            if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) {
-                c = JavaConstant.INT_0;
-            }
-            if (canStoreConstant(c)) {
-                append(new StoreConstantOp((Kind) kind.getPlatformKind(), storeAddress, c, state));
-                return;
-            }
-        }
-        Variable input = load(inputVal);
-        append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state));
-    }
-
-    public void emitStoreRelease(LIRKind kind, Value address, Value inputVal, LIRFrameState state) {
-        HSAILAddressValue storeAddress = asAddressValue(address);
-        // TODO: handle Constants here
-        Variable input = load(inputVal);
-        append(new StoreReleaseOp((Kind) kind.getPlatformKind(), storeAddress, input, state));
-    }
-
-    public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
-        LIRKind kind = newValue.getLIRKind();
-        assert kind.equals(expectedValue.getLIRKind());
-        Kind memKind = (Kind) kind.getPlatformKind();
-
-        HSAILAddressValue addressValue = asAddressValue(address);
-        Variable expected = emitMove(expectedValue);
-        Variable casResult = newVariable(kind);
-        append(new CompareAndSwapOp(memKind, casResult, addressValue, expected, asAllocatable(newValue)));
-
-        assert trueValue.getLIRKind().equals(falseValue.getLIRKind());
-        Variable nodeResult = newVariable(trueValue.getLIRKind());
-        append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(memKind), casResult, expected, nodeResult, Condition.EQ, trueValue, falseValue));
-        return nodeResult;
-    }
-
-    @Override
-    public Value emitAtomicReadAndAdd(Value address, Value delta) {
-        LIRKind kind = delta.getLIRKind();
-        Kind memKind = (Kind) kind.getPlatformKind();
-        Variable result = newVariable(kind);
-        HSAILAddressValue addressValue = asAddressValue(address);
-        append(new HSAILMove.AtomicReadAndAddOp(memKind, result, addressValue, asAllocatable(delta)));
-        return result;
-    }
-
-    @Override
-    public Value emitAtomicReadAndWrite(Value address, Value newValue) {
-        LIRKind kind = newValue.getLIRKind();
-        Kind memKind = (Kind) kind.getPlatformKind();
-        Variable result = newVariable(kind);
-        HSAILAddressValue addressValue = asAddressValue(address);
-        append(new HSAILMove.AtomicReadAndWriteOp(memKind, result, addressValue, asAllocatable(newValue)));
-        return result;
-    }
-
-    @Override
-    public void emitDeoptimize(Value actionAndReason, Value failedSpeculation, LIRFrameState state) {
-        emitDeoptimizeInner(actionAndReason, state, "emitDeoptimize");
-    }
-
-    /***
-     * We need 64-bit and 32-bit scratch registers for the codegen $s0 can be live at this block.
-     */
-    private void emitDeoptimizeInner(Value actionAndReason, LIRFrameState lirFrameState, String emitName) {
-        DeoptimizeOp deopt = new DeoptimizeOp(actionAndReason, lirFrameState, emitName, config.useHSAILDeoptimization, getMetaAccess());
-        ((HSAILHotSpotLIRGenerationResult) getResult()).addDeopt(deopt);
-        append(deopt);
-    }
-
-    /***
-     * This is a very temporary solution to emitForeignCall. We don't really support foreign calls
-     * yet, but we do want to generate dummy code for them. The ForeignCallXXXOps just end up
-     * emitting a comment as to what Foreign call they would have made.
-     */
-    @Override
-    public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, Value... args) {
-        Variable result = newVariable(LIRKind.reference(Kind.Object));  // linkage.getDescriptor().getResultType());
-
-        // to make the LIRVerifier happy, we move any constants into registers
-        Value[] argLocations = new Value[args.length];
-        for (int i = 0; i < args.length; i++) {
-            Value arg = args[i];
-            AllocatableValue loc = newVariable(arg.getLIRKind());
-            emitMove(loc, arg);
-            argLocations[i] = loc;
-        }
-
-        // here we could check the callName if we wanted to only handle certain callnames
-        String callName = linkage.getDescriptor().getName();
-        switch (argLocations.length) {
-            case 0:
-                append(new ForeignCallNoArgOp(callName, result));
-                break;
-            case 1:
-                append(new ForeignCall1ArgOp(callName, result, argLocations[0]));
-                break;
-            case 2:
-                append(new ForeignCall2ArgOp(callName, result, argLocations[0], argLocations[1]));
-                break;
-            default:
-                throw new InternalError("NYI emitForeignCall " + callName + ", " + argLocations.length + ", " + linkage);
-        }
-        return result;
-    }
-
-    @Override
-    protected HSAILLIRInstruction createMove(AllocatableValue dst, Value src) {
-        if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(src)) {
-            return new MoveToRegOp(Kind.Int, dst, JavaConstant.INT_0);
-        } else if (src instanceof HotSpotObjectConstant && ((HotSpotObjectConstant) src).isCompressed()) {
-            Variable uncompressed = newVariable(LIRKind.reference(Kind.Object));
-            append(new MoveToRegOp(Kind.Object, uncompressed, src));
-            CompressEncoding oopEncoding = config.getOopEncoding();
-            return new HSAILMove.CompressPointer(dst, newVariable(LIRKind.reference(Kind.Object)), uncompressed, oopEncoding.base, oopEncoding.shift, oopEncoding.alignment, true);
-        } else {
-            return super.createMove(dst, src);
-        }
-    }
-
-    @Override
-    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
-        // this version of emitForeignCall not used for now
-    }
-
-    public void emitTailcall(Value[] args, Value address) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public StackSlot getLockSlot(int lockDepth) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
-        Variable result = newVariable(pointer.getLIRKind().changeType(Kind.Int));
-        append(new HSAILMove.CompressPointer(result, newVariable(pointer.getLIRKind()), asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull));
-        return result;
-    }
-
-    @Override
-    public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
-        Variable result;
-        if (pointer.getLIRKind().isReference(0)) {
-            result = newVariable(LIRKind.reference(Kind.Object));
-        } else {
-            result = newVariable(LIRKind.value(Kind.Long));
-        }
-        append(new HSAILMove.UncompressPointer(result, asAllocatable(pointer), encoding.base, encoding.shift, encoding.alignment, nonNull));
-        return result;
-    }
-
-    public SaveRegistersOp emitSaveAllRegisters() {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void emitNullCheck(Value address, LIRFrameState state) {
-        assert address.getKind() == Kind.Object : address + " - " + address.getKind() + " not an object!";
-        Variable obj = newVariable(LIRKind.reference(Kind.Object));
-        emitMove(obj, address);
-        append(new HSAILMove.NullCheckOp(obj, state));
-    }
-
-    public Variable emitWorkItemAbsId() {
-        Variable result = newVariable(LIRKind.value(Kind.Int));
-        append(new WorkItemAbsIdOp(result));
-        return result;
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLoweringProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +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.hsail;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.hsail.replacements.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-
-public class HSAILHotSpotLoweringProvider extends DefaultHotSpotLoweringProvider {
-
-    private HSAILNewObjectSnippets.Templates hsailNewObjectSnippets;
-
-    abstract class LoweringStrategy {
-        abstract void lower(Node n, LoweringTool tool);
-    }
-
-    final LoweringStrategy passThruStrategy = new LoweringStrategy() {
-        @Override
-        void lower(Node n, LoweringTool tool) {
-            return;
-        }
-    };
-
-    final LoweringStrategy rejectStrategy = new LoweringStrategy() {
-        @Override
-        void lower(Node n, LoweringTool tool) {
-            throw new GraalInternalError("Node implementing Lowerable not handled in HSAIL Backend: " + n);
-        }
-    };
-
-    final 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, runtime, tool);
-                }
-            }
-        }
-    };
-
-    // strategy to replace an UnwindNode with a DeoptNode
-    final LoweringStrategy unwindNodeStrategy = new LoweringStrategy() {
-        @Override
-        void lower(Node n, LoweringTool tool) {
-            StructuredGraph graph = (StructuredGraph) n.graph();
-            UnwindNode unwind = (UnwindNode) n;
-            ValueNode exception = unwind.exception();
-            if (exception instanceof ForeignCallNode) {
-                // build up action and reason
-                String callName = ((ForeignCallNode) exception).getDescriptor().getName();
-                DeoptimizationReason reason;
-                switch (callName) {
-                    case "createOutOfBoundsException":
-                        reason = DeoptimizationReason.BoundsCheckException;
-                        break;
-                    case "createNullPointerException":
-                        reason = DeoptimizationReason.NullCheckException;
-                        break;
-                    default:
-                        reason = DeoptimizationReason.None;
-                }
-                unwind.replaceAtPredecessor(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, reason)));
-                unwind.safeDelete();
-            } else {
-                // unwind whose exception is not an instance of ForeignCallNode
-                throw new GraalInternalError("UnwindNode seen without ForeignCallNode: " + exception);
-            }
-        }
-    };
-
-    private HashMap<NodeClass, LoweringStrategy> strategyMap = new HashMap<>();
-
-    void initStrategyMap() {
-        strategyMap.put(NodeClass.get(IntegerConvertNode.class), passThruStrategy);
-        strategyMap.put(NodeClass.get(FloatConvertNode.class), passThruStrategy);
-        strategyMap.put(NodeClass.get(NewInstanceNode.class), newObjectStrategy);
-        strategyMap.put(NodeClass.get(NewArrayNode.class), newObjectStrategy);
-        strategyMap.put(NodeClass.get(NewMultiArrayNode.class), rejectStrategy);
-        strategyMap.put(NodeClass.get(DynamicNewArrayNode.class), rejectStrategy);
-        strategyMap.put(NodeClass.get(MonitorEnterNode.class), rejectStrategy);
-        strategyMap.put(NodeClass.get(MonitorExitNode.class), rejectStrategy);
-        strategyMap.put(NodeClass.get(UnwindNode.class), unwindNodeStrategy);
-    }
-
-    private LoweringStrategy getStrategy(Node n) {
-        return strategyMap.get(n.getNodeClass());
-    }
-
-    public HSAILHotSpotLoweringProvider(HotSpotGraalRuntimeProvider runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers,
-                    TargetDescription target) {
-        super(runtime, metaAccess, foreignCalls, registers, target);
-        initStrategyMap();
-    }
-
-    @Override
-    public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
-        super.initialize(providers, config);
-        hsailNewObjectSnippets = new HSAILNewObjectSnippets.Templates(providers, target);
-    }
-
-    @Override
-    public void lower(Node n, LoweringTool tool) {
-        LoweringStrategy strategy = getStrategy(n);
-        // if not in map, let superclass handle it
-        if (strategy == null) {
-            super.lower(n, tool);
-        } else {
-            strategy.lower(n, tool);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * 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.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.hsail.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp;
-import com.oracle.graal.nodes.*;
-
-/**
- * The HotSpot specific portion of the HSAIL LIR generator.
- */
-public class HSAILHotSpotNodeLIRBuilder extends HSAILNodeLIRBuilder implements HotSpotNodeLIRBuilder {
-
-    public HSAILHotSpotNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        super(graph, lirGen);
-    }
-
-    @Override
-    protected void emitNode(ValueNode node) {
-        if (node instanceof CurrentJavaThreadNode) {
-            throw new GraalInternalError("HSAILHotSpotLIRGenerator cannot handle node: " + node);
-        } else {
-            super.emitNode(node);
-        }
-    }
-
-    private HSAILHotSpotLIRGenerator getGen() {
-        return (HSAILHotSpotLIRGenerator) gen;
-    }
-
-    public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
-        Variable expected = getGen().load(operand(x.expectedValue()));
-        Variable newVal = getGen().load(operand(x.newValue()));
-
-        LIRKind kind = newVal.getLIRKind();
-        assert kind.equals(expected.getLIRKind());
-
-        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 = gen.newVariable(kind);
-        append(new CompareAndSwapOp((Kind) kind.getPlatformKind(), casResult, address, expected, newVal));
-
-        setResult(x, casResult);
-    }
-
-    @Override
-    public void visitSafepointNode(SafepointNode i) {
-        HotSpotVMConfig config = getGen().config;
-        if ((config.useHSAILSafepoints == true) && (config.useHSAILDeoptimization == true)) {
-            LIRFrameState info = state(i);
-            HSAILHotSpotSafepointOp safepoint = new HSAILHotSpotSafepointOp(info, config, this);
-            ((HSAILHotSpotLIRGenerationResult) getGen().getResult()).addDeopt(safepoint);
-            append(safepoint);
-        } else {
-            Debug.log("HSAIL safepoints turned off");
-        }
-    }
-
-    @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/HSAILHotSpotRegisterConfig.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +0,0 @@
-/*
- * 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.hotspot.hsail;
-
-import static com.oracle.graal.hsail.HSAIL.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.CallingConvention.Type;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.hsail.*;
-
-/**
- * This class defines a higher level interface for the register allocator to be able to access info
- * about the {@link HSAIL} register set.
- *
- * Note: In HSAIL, the number of registers of each type is actually a variable number that must
- * satisfy the equation: Total num of registers = No. of S registers + 2 * (No. of D registers) + 4
- * * (No. of Q registers) = 128 In other words we can have up to 128S or 64 D or 32Q or a blend.
- *
- * For now we haven't implemented support for a variable sized register file. Instead we've fixed
- * the number of registers of each type so that they satisfy the above equation. See {@link HSAIL}
- * for more details.
- */
-public class HSAILHotSpotRegisterConfig implements RegisterConfig {
-
-    private final Register[] allocatable = {s0, s1, s2, s3, s4, s5, s6, /* s7, */s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30, s31,
-                    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};
-
-    private final Register[] regBitness32 = {s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30, s31};
-    private final Register[] regBitness64 = {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15};
-    private final RegisterAttributes[] attributesMap = RegisterAttributes.createMap(this, HSAIL.allRegisters);
-
-    @Override
-    public Register getReturnRegister(Kind kind) {
-        switch (kind) {
-            case Boolean:
-            case Byte:
-            case Char:
-            case Short:
-            case Int:
-            case Long:
-            case Object:
-                return s0;
-            case Float:
-            case Double:
-                return d0;
-            case Void:
-            case Illegal:
-                return null;
-            default:
-                throw new UnsupportedOperationException("no return register for type " + kind);
-        }
-    }
-
-    @Override
-    public Register getFrameRegister() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
-        return callingConvention(regBitness32, regBitness64, returnType, parameterTypes, type, target, stackOnly);
-    }
-
-    private CallingConvention callingConvention(Register[] generalParameterRegisters, Register[] longParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type,
-                    TargetDescription target, boolean stackOnly) {
-        AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
-
-        int currentRegs32 = 0;
-        int currentRegs64 = 0;
-        int currentStackOffset = 0;
-
-        for (int i = 0; i < parameterTypes.length; i++) {
-            final Kind kind = parameterTypes[i].getKind();
-
-            switch (kind) {
-                case Byte:
-                case Boolean:
-                case Short:
-                case Char:
-                case Int:
-                case Float:
-
-                    if (!stackOnly && currentRegs32 < generalParameterRegisters.length) {
-                        Register register = generalParameterRegisters[currentRegs32++];
-                        locations[i] = register.asValue(target.getLIRKind(kind));
-                    }
-                    break;
-                case Long:
-                case Object:
-                case Double:
-                    if (!stackOnly && currentRegs64 < longParameterRegisters.length) {
-                        Register register = longParameterRegisters[currentRegs64++];
-                        locations[i] = register.asValue(target.getLIRKind(kind));
-                    }
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-
-            if (locations[i] == null) {
-                locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out);
-                currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize);
-            }
-        }
-
-        Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
-        AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(target.getLIRKind(returnKind));
-        return new CallingConvention(currentStackOffset, returnLocation, locations);
-    }
-
-    @Override
-    public Register[] getCallingConventionRegisters(Type type, Kind kind) {
-        throw new GraalInternalError("getCallingConventinoRegisters unimplemented");
-    }
-
-    @Override
-    public Register[] getAllocatableRegisters() {
-        return allocatable.clone();
-    }
-
-    @Override
-    public Register[] getAllocatableRegisters(PlatformKind kind) {
-        switch ((Kind) kind) {
-            case Int:
-            case Short:
-            case Byte:
-            case Float:
-                return regBitness32.clone();
-            case Long:
-            case Double:
-            case Object:
-                return regBitness64.clone();
-
-            default:
-                throw new GraalInternalError("unknown register allocation");
-        }
-    }
-
-    @Override
-    public Register[] getCallerSaveRegisters() {
-        // TODO Auto-generated method stub
-        return new Register[0];
-    }
-
-    @Override
-    public boolean areAllAllocatableRegistersCallerSaved() {
-        return false;
-    }
-
-    @Override
-    public CalleeSaveLayout getCalleeSaveLayout() {
-        return null;
-    }
-
-    @Override
-    public RegisterAttributes[] getAttributesMap() {
-        return attributesMap.clone();
-    }
-
-    @Override
-    public Register getRegisterForRole(int id) {
-        throw new UnsupportedOperationException();
-    }
-
-    public boolean isAllocatableSReg(Register reg) {
-        return (reg.number >= HSAIL.s0.number && reg.number <= HSAIL.s31.number);
-    }
-
-    public boolean isAllocatableDReg(Register reg) {
-        return (reg.number >= HSAIL.d0.number && reg.number <= HSAIL.d15.number);
-    }
-
-    public HSAILHotSpotRegisterConfig() {
-
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotReplacementsImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +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.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.hotspot.replacements.arraycopy.*;
-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.*;
-
-/**
- * The substitutions and snippets supported by HSAIL.
- */
-public class HSAILHotSpotReplacementsImpl extends ReplacementsImpl {
-
-    private final Replacements host;
-    private HashSet<ResolvedJavaMethod> ignoredResolvedMethods = new HashSet<>();
-    private HashMap<ResolvedJavaMethod, ResolvedJavaMethod> arrayCopyRedirectMethods = new HashMap<>();
-
-    public HSAILHotSpotReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target, Replacements host) {
-        super(providers, snippetReflection, assumptions, target);
-        this.host = host;
-    }
-
-    public void addIgnoredResolvedMethod(Class<?> cls, String methName, Class<?>... params) {
-        try {
-            Method m = cls.getMethod(methName, params);
-            ResolvedJavaMethod rjm = providers.getMetaAccess().lookupJavaMethod(m);
-            ignoredResolvedMethods.add(rjm);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public void completeInitialization() {
-        // Register the substitutions for java.lang.Math routines.
-        registerSubstitutions(Math.class, HSAILMathSubstitutions.class);
-
-        // Register the ignored substitutions
-        addIgnoredResolvedMethod(String.class, "equals", Object.class);
-
-        /*
-         * Register the special arraycopy snippet handling This basically ignores the sense of the
-         * CallArrayCopy flag and always directs to the snippets from UnsafeArrayCopyNode
-         */
-        redirectArraycopySnippetMethod(Kind.Byte);
-        redirectArraycopySnippetMethod(Kind.Boolean);
-        redirectArraycopySnippetMethod(Kind.Char);
-        redirectArraycopySnippetMethod(Kind.Short);
-        redirectArraycopySnippetMethod(Kind.Int);
-        redirectArraycopySnippetMethod(Kind.Long);
-        redirectArraycopySnippetMethod(Kind.Float);
-        redirectArraycopySnippetMethod(Kind.Double);
-        redirectArraycopySnippetMethod(Kind.Object);
-    }
-
-    private void redirectArraycopySnippetMethod(Kind kind) {
-        ResolvedJavaMethod foreignCallMethod = providers.getMetaAccess().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(kind, false, true));
-        ResolvedJavaMethod nonForeignCallMethod = providers.getMetaAccess().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(kind, false, false));
-        if (!foreignCallMethod.equals(nonForeignCallMethod)) {
-            arrayCopyRedirectMethods.put(foreignCallMethod, nonForeignCallMethod);
-        }
-    }
-
-    @Override
-    protected ResolvedJavaMethod registerMethodSubstitution(ClassReplacements cr, Executable originalMethod, Method substituteMethod) {
-        // TODO: decide if we want to override this in any way
-        return super.registerMethodSubstitution(cr, originalMethod, substituteMethod);
-    }
-
-    @Override
-    public Class<? extends FixedWithNextNode> getMacroSubstitution(ResolvedJavaMethod method) {
-        Class<? extends FixedWithNextNode> klass = super.getMacroSubstitution(method);
-        if (klass == null) {
-            /*
-             * Eventually we want to only defer certain macro substitutions to the host, but for now
-             * we will do everything.
-             */
-            return host.getMacroSubstitution(method);
-        }
-        return klass;
-    }
-
-    @Override
-    public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry) {
-        /*
-         * Must work in cooperation with HSAILHotSpotLoweringProvider. Before asking for the host
-         * snippet, see if it is one of the arraycopy methods which we want to redirect to the
-         * non-foreign-call version, regardless of the sense of CallArrayCopy option
-         */
-        ResolvedJavaMethod snippetMethod = method;
-        ResolvedJavaMethod snippetRecursiveEntry = recursiveEntry;
-        ResolvedJavaMethod redirect = arrayCopyRedirectMethods.get(method);
-        if (redirect != null) {
-            snippetMethod = redirect;
-            if (recursiveEntry != null && recursiveEntry.equals(method)) {
-                snippetRecursiveEntry = redirect;
-            }
-        }
-        return host.getSnippet(snippetMethod, snippetRecursiveEntry);
-    }
-
-    @Override
-    public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) {
-        StructuredGraph m = super.getMethodSubstitution(original);
-        if (m == null) {
-            /*
-             * We check for a few special cases we do NOT want to defer here but basically we defer
-             * everything else to the host.
-             */
-            if (ignoredResolvedMethods.contains(original)) {
-                return null;
-            } else {
-                return host.getMethodSubstitution(original);
-            }
-        }
-        return m;
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * 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.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.hsail.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hsail.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.nodes.spi.*;
-
-/**
- * Emits a safepoint deoptimization from HSA back to CPU.
- */
-@Opcode("SAFEPOINT")
-public class HSAILHotSpotSafepointOp extends HSAILLIRInstruction implements HSAILControlFlow.DeoptimizingOp {
-    private JavaConstant actionAndReason;
-    @State protected LIRFrameState frameState;
-    protected int codeBufferPos = -1;
-    final int offsetToNoticeSafepoints;
-    final HotSpotVMConfig config;
-
-    public HSAILHotSpotSafepointOp(LIRFrameState state, HotSpotVMConfig config, NodeLIRBuilderTool tool) {
-        actionAndReason = tool.getLIRGeneratorTool().getMetaAccess().encodeDeoptActionAndReason(DeoptimizationAction.None, DeoptimizationReason.None, 0);
-        frameState = state;
-        offsetToNoticeSafepoints = config.hsailNoticeSafepointsOffset;
-        this.config = config;
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-        if (config.useHSAILDeoptimization) {
-            // get a unique codeBuffer position
-            // when we save our state, we will save this as well (it can be used as a key to get the
-            // debugInfo)
-            codeBufferPos = masm.position();
-
-            masm.emitComment(" /* HSAIL safepoint bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */");
-            String afterSafepointLabel = "@LAfterSafepoint_at_pos_" + codeBufferPos;
-
-            AllocatableValue scratch64 = HSAIL.d16.asValue(LIRKind.reference(Kind.Object));
-            AllocatableValue spAddrReg = HSAIL.d17.asValue(LIRKind.reference(Kind.Object));
-            AllocatableValue scratch32 = HSAIL.s34.asValue(LIRKind.value(Kind.Int));
-            masm.emitLoadKernelArg(scratch64, masm.getDeoptInfoName(), "u64");
-
-            // Build address of noticeSafepoints field
-            HSAILAddress noticeSafepointsAddr = new HSAILAddressValue(LIRKind.value(Kind.Long), scratch64, offsetToNoticeSafepoints).toAddress();
-            masm.emitLoad(Kind.Object, spAddrReg, noticeSafepointsAddr);
-
-            // Load int value from that field
-            HSAILAddress noticeSafepointsIntAddr = new HSAILAddressValue(LIRKind.value(Kind.Long), spAddrReg, 0).toAddress();
-            masm.emitLoadAcquire(scratch32, noticeSafepointsIntAddr);
-            masm.emitCompare(Kind.Int, scratch32, JavaConstant.forInt(0), "eq", false, false);
-            masm.cbr(afterSafepointLabel);
-
-            AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int));
-            AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int));
-            masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason);
-            masm.emitMov(Kind.Int, codeBufferOffsetReg, JavaConstant.forInt(codeBufferPos));
-            masm.emitJumpToLabelName(masm.getDeoptLabelName());
-
-            masm.emitString0(afterSafepointLabel + ":\n");
-
-            // now record the debuginfo
-            crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.SAFEPOINT);
-        } else {
-            masm.emitComment("/* HSAIL safepoint would have been here. */");
-        }
-    }
-
-    public LIRFrameState getFrameState() {
-        return frameState;
-    }
-
-    public int getCodeBufferPos() {
-        return codeBufferPos;
-    }
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectLoadAcquireNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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.hsail.replacements;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.hsail.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.replacements.nodes.*;
-import com.oracle.graal.word.*;
-
-// JaCoCo Exclude
-@NodeInfo
-public class HSAILDirectLoadAcquireNode extends DirectReadNode {
-
-    public HSAILDirectLoadAcquireNode(ValueNode address, Kind readKind) {
-        super(address, readKind);
-    }
-
-    @Override
-    public void generate(NodeLIRBuilderTool gen) {
-        HSAILHotSpotLIRGenerator hsailgen = (HSAILHotSpotLIRGenerator) (gen.getLIRGeneratorTool());
-        LIRKind kind = hsailgen.getLIRKind(stamp());
-        Value result = hsailgen.emitLoadAcquire(kind, gen.operand(getAddress()), null);
-        gen.setResult(this, result);
-    }
-
-    @NodeIntrinsic
-    public static native long loadAcquire(long address, @ConstantNodeParameter Kind kind);
-
-    public static long loadAcquireLong(Word address) {
-        return loadAcquire(address.rawValue(), Kind.Long);
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILDirectStoreReleaseNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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.hsail.replacements;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.hotspot.hsail.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.replacements.nodes.*;
-import com.oracle.graal.word.*;
-
-// JaCoCo Exclude
-@NodeInfo
-public class HSAILDirectStoreReleaseNode extends DirectStoreNode {
-
-    public HSAILDirectStoreReleaseNode(ValueNode address, ValueNode value, Kind kind) {
-        super(address, value, kind);
-    }
-
-    @Override
-    public void generate(NodeLIRBuilderTool gen) {
-        HSAILHotSpotLIRGenerator hsailgen = (HSAILHotSpotLIRGenerator) (gen.getLIRGeneratorTool());
-        Value v = gen.operand(getValue());
-        LIRKind lirKind = hsailgen.getLIRKind(getValue().stamp());
-        hsailgen.emitStoreRelease(lirKind, gen.operand(getAddress()), v, null);
-    }
-
-    @NodeIntrinsic
-    public static native void storeRelease(long address, long value, @ConstantNodeParameter Kind kind);
-
-    public static void storeReleaseLong(Word address, long value) {
-        storeRelease(address.rawValue(), value, Kind.Long);
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILHotSpotReplacementsUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +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.hotspot.hsail.replacements;
-
-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.java.*;
-import com.oracle.graal.word.*;
-
-//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;
-    }
-
-    public static final LocationIdentity TLAB_INFO_LOCATION = NamedLocationIdentity.mutable("TlabInfo");
-    public static final LocationIdentity TLABINFO_LASTGOODTOP_LOCATION = NamedLocationIdentity.mutable("TlabInfoLastGoodTop");
-    public static final LocationIdentity TLABINFO_END_LOCATION = NamedLocationIdentity.mutable("TlabInfoEnd");
-    public static final LocationIdentity TLABINFO_TOP_LOCATION = NamedLocationIdentity.mutable("TlabInfoTop");
-    public static final LocationIdentity TLABINFO_START_LOCATION = NamedLocationIdentity.mutable("TlabInfoStart");
-    public static final LocationIdentity TLABINFO_ALLOCINFO_LOCATION = NamedLocationIdentity.mutable("TlabInfoAllocInfo");
-    public static final LocationIdentity TLABINFO_ORIGINALTOP_LOCATION = NamedLocationIdentity.mutable("TlabInfoOriginalTop");
-    public static final LocationIdentity TLABINFO_TLAB_LOCATION = NamedLocationIdentity.mutable("TlabInfoTlab");
-
-    public static final LocationIdentity ALLOCINFO_TLABINFOSPOOLNEXT_LOCATION = NamedLocationIdentity.mutable("AllocInfoTlabInfosPoolNext");
-    public static final LocationIdentity ALLOCINFO_TLABINFOSPOOLEND_LOCATION = NamedLocationIdentity.mutable("AllocInfoTlabInfosPoolEnd");
-    public static final LocationIdentity ALLOCINFO_TLABALIGNRESERVEBYTES_LOCATION = NamedLocationIdentity.mutable("AllocInfoTlabAlignreservebytes");
-
-    /**
-     * Gets the value of the thread register as a Word. There is a level of indirection here. Thread
-     * register actually points to a holder for tlab info.
-     */
-    public static Word getTlabInfoPtr() {
-        Word threadRegAsWord = registerAsWord(threadRegister(), true, false);
-        return threadRegAsWord.readWord(0, TLAB_INFO_LOCATION);
-    }
-
-    public static Word getTlabInfoPtrLoadAcquire() {
-        Word threadRegAsWord = registerAsWord(threadRegister(), true, false);
-        return Word.unsigned(HSAILDirectLoadAcquireNode.loadAcquireLong(threadRegAsWord));
-    }
-
-    public static void writeTlabInfoPtrStoreRelease(Word val) {
-        // this only gets done in the waiting loop so we will always use Store Release
-        Word threadRegAsWord = registerAsWord(threadRegister(), true, false);
-        HSAILDirectStoreReleaseNode.storeReleaseLong(threadRegAsWord, val.rawValue());
-    }
-
-    @Fold
-    public static Register threadRegister() {
-        return hsailRegisters.getThreadRegister();
-    }
-
-    public static Word atomicGetAndAddTlabInfoTop(Word tlabInfo, int delta) {
-        return Word.unsigned(AtomicReadAndAddNode.getAndAddLong(null, tlabInfo.rawValue() + config().hsailTlabInfoTopOffset, delta, TLABINFO_TOP_LOCATION));
-    }
-
-    public static Word readTlabInfoEnd(Word tlabInfo) {
-        return tlabInfo.readWord(config().hsailTlabInfoEndOffset, TLABINFO_END_LOCATION);
-    }
-
-    public static Word readTlabInfoStart(Word tlabInfo) {
-        return tlabInfo.readWord(config().hsailTlabInfoStartOffset, TLABINFO_START_LOCATION);
-    }
-
-    public static void writeTlabInfoLastGoodTop(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoLastGoodTopOffset, val, TLABINFO_LASTGOODTOP_LOCATION);
-    }
-
-    public static void writeTlabInfoStart(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoStartOffset, val, TLABINFO_START_LOCATION);
-    }
-
-    public static void writeTlabInfoTop(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoTopOffset, val, TLABINFO_TOP_LOCATION);
-    }
-
-    public static void writeTlabInfoEnd(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoEndOffset, val, TLABINFO_END_LOCATION);
-    }
-
-    public static Word readTlabInfoAllocInfo(Word tlabInfo) {
-        return tlabInfo.readWord(config().hsailTlabInfoAllocInfoOffset, TLABINFO_ALLOCINFO_LOCATION);
-    }
-
-    public static void writeTlabInfoAllocInfo(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoAllocInfoOffset, val, TLABINFO_ALLOCINFO_LOCATION);
-    }
-
-    public static void writeTlabInfoOriginalTop(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoOriginalTopOffset, val, TLABINFO_ORIGINALTOP_LOCATION);
-    }
-
-    public static void writeTlabInfoTlab(Word tlabInfo, Word val) {
-        tlabInfo.writeWord(config().hsailTlabInfoTlabOffset, val, TLABINFO_TLAB_LOCATION);
-    }
-
-    public static Word readTlabInfoTlab(Word tlabInfo) {
-        return tlabInfo.readWord(config().hsailTlabInfoTlabOffset, TLABINFO_TLAB_LOCATION);
-    }
-
-    public static Word readAllocInfoTlabInfosPoolEnd(Word allocInfo) {
-        return allocInfo.readWord(config().hsailAllocInfoTlabInfosPoolEndOffset, ALLOCINFO_TLABINFOSPOOLEND_LOCATION);
-    }
-
-    public static Word readAllocInfoTlabAlignReserveBytes(Word allocInfo) {
-        return allocInfo.readWord(config().hsailAllocInfoTlabAlignReserveBytesOffset, ALLOCINFO_TLABALIGNRESERVEBYTES_LOCATION);
-    }
-
-    public static Word atomicGetAndAddAllocInfoTlabInfosPoolNext(Word allocInfo, int delta) {
-        return Word.unsigned(AtomicReadAndAddNode.getAndAddLong(null, allocInfo.rawValue() + config().hsailAllocInfoTlabInfosPoolNextOffset, delta, ALLOCINFO_TLABINFOSPOOLNEXT_LOCATION));
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILNewObjectSnippets.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,348 +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.hotspot.hsail.replacements;
-
-import static com.oracle.graal.api.code.UnsignedMath.*;
-import static com.oracle.graal.compiler.common.GraalOptions.*;
-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.replacements.SnippetTemplate.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.nodes.type.*;
-import com.oracle.graal.hotspot.replacements.*;
-import com.oracle.graal.hotspot.stubs.*;
-import com.oracle.graal.hotspot.word.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-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 {
-
-    public static class Options {
-
-        // @formatter:off
-        @Option(help = "In HSAIL allocation, allow allocation from eden as fallback if TLAB is full", type = OptionType.Debug)
-        static final OptionValue<Boolean> HsailUseEdenAllocate = new OptionValue<>(false);
-
-        @Option(help = "In HSAIL allocation, allow GPU to allocate a new tlab if TLAB is full", type = OptionType.Debug)
-        static final OptionValue<Boolean> HsailNewTlabAllocate = new OptionValue<>(true);
-
-        @Option(help = "Estimate of number of bytes allocated by each HSAIL workitem, used to size TLABs", type = OptionType.Debug)
-        public  static  final OptionValue<Integer> HsailAllocBytesPerWorkitem = new OptionValue<>(64);
-
-        // @formatter:on
-    }
-
-    private static final boolean hsailUseEdenAllocate = HsailUseEdenAllocate.getValue();
-    private static final boolean hsailNewTlabAllocate = HsailNewTlabAllocate.getValue();
-
-    protected static Word fillNewTlabInfoWithTlab(Word oldTlabInfo) {
-        Word allocInfo = readTlabInfoAllocInfo(oldTlabInfo);
-        Word newTlabInfo = atomicGetAndAddAllocInfoTlabInfosPoolNext(allocInfo, config().hsailTlabInfoSize);
-        Word tlabInfosPoolEnd = readAllocInfoTlabInfosPoolEnd(allocInfo);
-        if (newTlabInfo.aboveOrEqual(tlabInfosPoolEnd)) {
-            // could not get a new tlab info, mark zero and we will later deoptimize
-            return (Word.zero());
-        }
-
-        // make new size depend on old tlab size
-        Word newTlabSize = readTlabInfoEnd(oldTlabInfo).subtract(readTlabInfoStart(oldTlabInfo));
-        // try to allocate a new tlab
-        Word tlabStart = NewInstanceStub.edenAllocate(newTlabSize, false);
-        writeTlabInfoStart(newTlabInfo, tlabStart);  // write this field even if zero
-        if (tlabStart.equal(0)) {
-            // could not get a new tlab, mark zero and we will later deoptimize
-            return (Word.zero());
-        }
-        // here we have a new tlab and a tlabInfo, we can fill it in
-        writeTlabInfoTop(newTlabInfo, tlabStart);
-        writeTlabInfoOriginalTop(newTlabInfo, tlabStart);
-        // set end so that we leave space for the tlab "alignment reserve"
-        Word alignReserveBytes = readAllocInfoTlabAlignReserveBytes(allocInfo);
-        writeTlabInfoEnd(newTlabInfo, tlabStart.add(newTlabSize.subtract(alignReserveBytes)));
-        writeTlabInfoAllocInfo(newTlabInfo, allocInfo);
-        writeTlabInfoTlab(newTlabInfo, readTlabInfoTlab(oldTlabInfo));
-        return (newTlabInfo);
-    }
-
-    protected static Word allocateFromTlabSlowPath(Word fastPathTlabInfo, int size, Word fastPathTop, Word fastPathEnd) {
-        // eventually this will be a separate call, not inlined
-
-        // we come here from the fastpath allocation
-        // here we know that the tlab has overflowed (top + size > end)
-        // find out if we are the first overflower
-        Word tlabInfo = fastPathTlabInfo;
-        Word top = fastPathTop;
-        Word end = fastPathEnd;
-
-        // start a loop where we try to get a new tlab and then try to allocate from it
-        // keep doing this until we run out of tlabs or tlabInfo structures
-        // initialize result with error return value
-        Word result = Word.zero();
-        while (result.equal(Word.zero()) && tlabInfo.notEqual(Word.zero())) {
-            boolean firstOverflower = top.belowOrEqual(end);
-            if (firstOverflower) {
-                // store the last good top before overflow into last_good_top field
-                // we will move it back into top later when back in the VM
-                writeTlabInfoLastGoodTop(tlabInfo, top);
-            }
-
-            // if all this allocate tlab from gpu logic is disabled,
-            // just immediately set tlabInfo to 0 here
-            if (!hsailNewTlabAllocate) {
-                tlabInfo = Word.zero();
-            } else {
-                // loop here waiting for the first overflower to get a new tlab
-                // note that on an hsa device we must be careful how we loop in order to ensure
-                // "forward progress". For example we must not break out of the loop.
-                Word oldTlabInfo = tlabInfo;
-                do {
-                    if (firstOverflower) {
-                        // allocate new tlabInfo and new tlab to fill it, returning 0 if any
-                        // problems
-                        // this will get all spinners out of this loop.
-                        tlabInfo = fillNewTlabInfoWithTlab(oldTlabInfo);
-                        writeTlabInfoPtrStoreRelease(tlabInfo);
-                    } else {
-                        tlabInfo = getTlabInfoPtrLoadAcquire();
-                    }
-                } while (tlabInfo.equal(oldTlabInfo));
-                // when we get out of the loop if tlabInfoPtr contains 0, it means we
-                // can't get any more tlabs and will have to deoptimize
-                // otherwise, we have a valid new tlabInfo/tlab and can try to allocate again.
-                if (tlabInfo.notEqual(0)) {
-                    top = atomicGetAndAddTlabInfoTop(tlabInfo, size);
-                    end = readTlabInfoEnd(tlabInfo);
-                    Word newTop = top.add(size);
-                    if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
-                        result = top;
-                    }
-                }
-            }
-        } // while (result == 0) && (tlabInfo != 0))
-        return result;
-    }
-
-    protected static Object addressToFormattedObject(Word addr, @ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents,
-                    @ConstantParameter String typeContext) {
-        Object result = formatObject(hub, size, addr, prototypeMarkWord, fillContents, true, true);
-        profileAllocation("instance", size, typeContext);
-        return piCast(verifyOop(result), StampFactory.forNodeIntrinsic());
-    }
-
-    @Snippet
-    public static Object allocateInstanceAtomic(@ConstantParameter int size, KlassPointer hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) {
-        boolean haveResult = false;
-        if (useTLAB()) {
-            // inlining this manually here because it resulted in better fastpath codegen
-            Word tlabInfo = getTlabInfoPtr();
-            if (probability(FAST_PATH_PROBABILITY, tlabInfo.notEqual(0))) {
-                Word top = atomicGetAndAddTlabInfoTop(tlabInfo, size);
-                Word end = readTlabInfoEnd(tlabInfo);
-                Word newTop = top.add(size);
-                if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
-                    return addressToFormattedObject(top, size, hub, prototypeMarkWord, fillContents, typeContext);
-                } else {
-                    Word addr = allocateFromTlabSlowPath(tlabInfo, size, top, end);
-                    if (addr.notEqual(0)) {
-                        return addressToFormattedObject(addr, size, hub, prototypeMarkWord, fillContents, typeContext);
-                    }
-                }
-            }
-        }
-
-        // we could not allocate from tlab, try allocating directly from eden
-        if (hsailUseEdenAllocate) {
-            // false for no logging
-            Word addr = NewInstanceStub.edenAllocate(Word.unsigned(size), false);
-            if (addr.notEqual(0)) {
-                new_eden.inc();
-                return addressToFormattedObject(addr, size, hub, prototypeMarkWord, fillContents, typeContext);
-            }
-        }
-        // 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(KlassPointer 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);
-    }
-
-    protected static Object addressToFormattedArray(Word addr, int allocationSize, int length, int headerSize, KlassPointer hub, Word prototypeMarkWord, boolean fillContents, boolean maybeUnroll,
-                    @ConstantParameter String typeContext) {
-        // we are not in a stub so we can set useSnippetCounters to true
-        Object result = formatArray(hub, allocationSize, length, headerSize, addr, prototypeMarkWord, fillContents, maybeUnroll, true);
-        profileAllocation("array", allocationSize, typeContext);
-        return piArrayCast(verifyOop(result), length, StampFactory.forNodeIntrinsic());
-    }
-
-    private static Object allocateArrayAtomicImpl(KlassPointer 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);
-        boolean haveResult = false;
-        if (useTLAB()) {
-            // inlining this manually here because it resulted in better fastpath codegen
-            Word tlabInfo = getTlabInfoPtr();
-            if (probability(FAST_PATH_PROBABILITY, tlabInfo.notEqual(0))) {
-                Word top = atomicGetAndAddTlabInfoTop(tlabInfo, allocationSize);
-                Word end = readTlabInfoEnd(tlabInfo);
-                Word newTop = top.add(allocationSize);
-                if (probability(FAST_PATH_PROBABILITY, newTop.belowOrEqual(end))) {
-                    return addressToFormattedArray(top, allocationSize, length, headerSize, hub, prototypeMarkWord, fillContents, maybeUnroll, typeContext);
-                } else {
-                    Word addr = allocateFromTlabSlowPath(tlabInfo, allocationSize, top, end);
-                    if (addr.notEqual(0)) {
-                        return addressToFormattedArray(addr, allocationSize, length, headerSize, hub, prototypeMarkWord, fillContents, maybeUnroll, typeContext);
-                    }
-                }
-            }
-        }
-
-        // we could not allocate from tlab, try allocating directly from eden
-        if (hsailUseEdenAllocate) {
-            // false for no logging
-            Word addr = NewInstanceStub.edenAllocate(Word.unsigned(allocationSize), false);
-            if (addr.notEqual(0)) {
-                newarray_eden.inc();
-                return addressToFormattedArray(addr, allocationSize, length, headerSize, hub, prototypeMarkWord, fillContents, maybeUnroll, typeContext);
-            }
-        }
-        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(KlassPointerStamp.klassNonNull(), 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", type.toJavaName(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, HotSpotGraalRuntimeProvider runtime, LoweringTool tool) {
-            StructuredGraph graph = newArrayNode.graph();
-            ResolvedJavaType elementType = newArrayNode.elementType();
-            HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass();
-            Kind elementKind = elementType.getKind();
-            ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), arrayType.klass(), providers.getMetaAccess(), graph);
-            final int headerSize = runtime.getArrayBaseOffset(elementKind);
-            // lowerer extends HotSpotLoweringProvider so we can just use that
-            HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
-            int log2ElementSize = CodeUtil.log2(lowerer.arrayScalingFactor(elementKind));
-
-            Arguments args = new Arguments(allocateArray, graph.getGuardsStage(), tool.getLoweringStage());
-            args.add("hub", hub);
-            ValueNode length = newArrayNode.length();
-            args.add("length", length.isAlive() ? length : graph.addOrUniqueWithInputs(length));
-            args.add("prototypeMarkWord", arrayType.prototypeMarkWord());
-            args.addConst("headerSize", headerSize);
-            args.addConst("log2ElementSize", log2ElementSize);
-            args.addConst("fillContents", newArrayNode.fillContents());
-            args.addConst("maybeUnroll", length.isConstant());
-            args.addConst("typeContext", arrayType.toJavaName(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.hsail/src/com/oracle/graal/hotspot/hsail/replacements/HSAILWorkItemAbsIdNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.hsail.replacements;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.hotspot.hsail.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-
-@NodeInfo
-public class HSAILWorkItemAbsIdNode extends FixedWithNextNode implements LIRLowerable {
-
-    public HSAILWorkItemAbsIdNode() {
-        super(StampFactory.forKind(Kind.Int));
-    }
-
-    @Override
-    public void generate(NodeLIRBuilderTool gen) {
-        HSAILHotSpotLIRGenerator hsailgen = (HSAILHotSpotLIRGenerator) (gen.getLIRGeneratorTool());
-        Value result = hsailgen.emitWorkItemAbsId();
-        gen.setResult(this, result);
-    }
-
-    @NodeIntrinsic
-    public static native int getWorkItemAbsId();
-
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,495 +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.ptx;
-
-import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.api.meta.LocationIdentity.*;
-import static com.oracle.graal.compiler.GraalCompiler.*;
-import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*;
-import static com.oracle.graal.hotspot.meta.HotSpotForeignCallsProviderImpl.*;
-import static com.oracle.graal.lir.LIRValueUtil.*;
-
-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.asm.*;
-import com.oracle.graal.asm.ptx.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.gpu.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.LIRInstruction.OperandFlag;
-import com.oracle.graal.lir.LIRInstruction.OperandMode;
-import com.oracle.graal.lir.StandardOp.LabelOp;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.lir.framemap.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.ptx.PTXControlFlow.PTXPredicatedLIRInstruction;
-import com.oracle.graal.lir.ptx.*;
-import com.oracle.graal.lir.ptx.PTXMemOp.LoadReturnAddrOp;
-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.word.*;
-
-/**
- * HotSpot PTX specific backend.
- */
-public class PTXHotSpotBackend extends HotSpotBackend {
-
-    private final boolean deviceInitialized;
-
-    /**
-     * Descriptor for the PTX runtime method for calling a kernel. The C++ signature is:
-     *
-     * <pre>
-     *     jlong (JavaThread* thread,
-     *            jlong kernel,
-     *            jint dimX,
-     *            jint dimY,
-     *            jint dimZ,
-     *            jlong parametersAndReturnValueBuffer,
-     *            jint parametersAndReturnValueBufferSize,
-     *            jint objectParametersCount,
-     *            jlong objectParametersOffsets,
-     *            jlong pinnedObjects,
-     *            jint encodedReturnTypeSize)
-     * </pre>
-     */
-    // @formatter:off
-    public static final ForeignCallDescriptor CALL_KERNEL = new ForeignCallDescriptor("execute_kernel_from_vm", long.class,
-                    Word.class, // thread
-                    long.class, // kernel
-                    int.class,  // dimX
-                    int.class,  // dimY
-                    int.class,  // dimZ
-                    long.class, // parametersAndReturnValueBuffer
-                    int.class,  // parametersAndReturnValueBufferSize
-                    int.class,  // objectParameterCount
-                    long.class, // objectParameterOffsets
-                    long.class, // pinnedObjects
-                    int.class); // encodedReturnTypeSize
-
-    // @formatter:on
-
-    public PTXHotSpotBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) {
-        super(runtime, providers);
-        if (OmitDeviceInit) {
-            deviceInitialized = true;
-        } else {
-            boolean init = false;
-            try {
-                init = initialize();
-            } catch (UnsatisfiedLinkError e) {
-            }
-            deviceInitialized = init;
-        }
-    }
-
-    /**
-     * Initializes the GPU device.
-     *
-     * @return whether or not initialization was successful
-     */
-    private static native boolean initialize();
-
-    @Override
-    public boolean shouldAllocateRegisters() {
-        return false;
-    }
-
-    /**
-     * Used to omit {@linkplain #initialize() device initialization}.
-     */
-    private static final boolean OmitDeviceInit = Boolean.getBoolean("graal.ptx.omitDeviceInit");
-
-    @Override
-    public void completeInitialization() {
-        HotSpotProviders hostProviders = getRuntime().getHostProviders();
-        HotSpotHostForeignCallsProvider hostForeignCalls = (HotSpotHostForeignCallsProvider) hostProviders.getForeignCalls();
-        if (deviceInitialized) {
-            long launchKernel = getLaunchKernelAddress();
-            hostForeignCalls.linkForeignCall(hostProviders, CALL_KERNEL, launchKernel, false, NOT_LEAF, NOT_REEXECUTABLE, ANY_LOCATION);
-        }
-        /* Add a shutdown hook to destroy CUDA context(s) */
-        Runtime.getRuntime().addShutdownHook(new Thread("PTXShutdown") {
-            @Override
-            public void run() {
-                destroyContext();
-            }
-        });
-        super.completeInitialization();
-    }
-
-    private static native void destroyContext();
-
-    /**
-     * Gets the address of {@code Ptx::execute_kernel_from_vm()}.
-     */
-    private static native long getLaunchKernelAddress();
-
-    @Override
-    public FrameMapBuilder newFrameMapBuilder(RegisterConfig registerConfig) {
-        RegisterConfig registerConfigNonNull = registerConfig == null ? getCodeCache().getRegisterConfig() : registerConfig;
-        return new FrameMapBuilderImpl(newFrameMap(registerConfigNonNull), getCodeCache(), registerConfigNonNull);
-    }
-
-    @Override
-    public FrameMap newFrameMap(RegisterConfig registerConfig) {
-        return new PTXFrameMap(getCodeCache(), registerConfig);
-    }
-
-    /**
-     * Determines if the GPU device (or simulator) is available and initialized.
-     */
-    public boolean isDeviceInitialized() {
-        return deviceInitialized;
-    }
-
-    /**
-     * Compiles a given method to PTX code.
-     *
-     * @param makeBinary specifies whether a GPU binary should also be generated for the PTX code.
-     *            If true, the returned value is guaranteed to have a non-zero
-     *            {@linkplain ExternalCompilationResult#getEntryPoint() entry point}.
-     * @return the PTX code compiled from {@code method}'s bytecode
-     */
-    public ExternalCompilationResult compileKernel(ResolvedJavaMethod method, boolean makeBinary) {
-        StructuredGraph graph = new StructuredGraph(method);
-        HotSpotProviders providers = getProviders();
-        CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, method, false);
-        PhaseSuite<HighTierContext> graphBuilderSuite = providers.getSuites().getDefaultGraphBuilderSuite();
-        graphBuilderSuite.appendPhase(new NonNullParametersPhase());
-        Suites suites = providers.getSuites().getDefaultSuites();
-        ExternalCompilationResult ptxCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph),
-                        null, suites, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default);
-        if (makeBinary) {
-            try (Scope ds = Debug.scope("GeneratingKernelBinary")) {
-                assert ptxCode.getTargetCode() != null;
-                long kernel = generateKernel(ptxCode.getTargetCode(), method.getName());
-                ptxCode.setEntryPoint(kernel);
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-        }
-        return ptxCode;
-    }
-
-    /**
-     * Generates a GPU binary from PTX code.
-     */
-    private static native long generateKernel(byte[] targetCode, String name);
-
-    /**
-     * A list of the {@linkplain #installKernel(ResolvedJavaMethod, ExternalCompilationResult)
-     * installed} kernels. This is required so that there is a strong reference to each installed
-     * kernel as long as it is {@linkplain HotSpotNmethod#isValid() valid}. The list is pruned of
-     * invalid kernels every time a new kernel is installed.
-     */
-    private List<HotSpotNmethod> installedKernels = new LinkedList<>();
-
-    public final HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult ptxCode) {
-        assert OmitDeviceInit || ptxCode.getEntryPoint() != 0L;
-        HotSpotNmethod kernel = getProviders().getCodeCache().addExternalMethod(method, ptxCode);
-        synchronized (installedKernels) {
-            for (Iterator<HotSpotNmethod> i = installedKernels.iterator(); i.hasNext();) {
-                HotSpotNmethod entry = i.next();
-                if (!entry.isValid()) {
-                    i.remove();
-                }
-            }
-            installedKernels.add(kernel);
-        }
-        return kernel;
-    }
-
-    static final class RegisterAnalysis implements ValueConsumer {
-        private final SortedSet<Integer> signed32 = new TreeSet<>();
-        private final SortedSet<Integer> signed64 = new TreeSet<>();
-
-        // unsigned8 is only for ld, st and cbt
-        private final SortedSet<Integer> unsigned8 = new TreeSet<>();
-        private final SortedSet<Integer> unsigned64 = new TreeSet<>();
-
-        // private final SortedSet<Integer> float16 = new TreeSet<>();
-        private final SortedSet<Integer> float32 = new TreeSet<>();
-        private final SortedSet<Integer> float64 = new TreeSet<>();
-
-        LIRInstruction op;
-
-        void emitDeclarations(Assembler asm) {
-            for (Integer i : unsigned8) {
-                asm.emitString(".reg .u8 %r" + i.intValue() + ";");
-            }
-            for (Integer i : signed32) {
-                asm.emitString(".reg .s32 %r" + i.intValue() + ";");
-            }
-            for (Integer i : signed64) {
-                asm.emitString(".reg .s64 %r" + i.intValue() + ";");
-            }
-            for (Integer i : unsigned64) {
-                asm.emitString(".reg .u64 %r" + i.intValue() + ";");
-            }
-            for (Integer i : float32) {
-                asm.emitString(".reg .f32 %r" + i.intValue() + ";");
-            }
-            for (Integer i : float64) {
-                asm.emitString(".reg .f64 %r" + i.intValue() + ";");
-            }
-        }
-
-        @Override
-        public void visitValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags) {
-            if (isVariable(value)) {
-                Variable regVal = (Variable) value;
-                Kind regKind = regVal.getKind();
-                if ((op instanceof LoadReturnAddrOp) && (mode == OperandMode.DEF)) {
-                    unsigned64.add(regVal.index);
-                } else {
-                    switch (regKind) {
-                        case Int:
-                            // If the register was used as a wider signed type
-                            // do not add it here
-                            if (!signed64.contains(regVal.index)) {
-                                signed32.add(regVal.index);
-                            }
-                            break;
-                        case Long:
-                            // If the register was used as a narrower signed type
-                            // remove it from there and add it to wider type.
-                            if (signed32.contains(regVal.index)) {
-                                signed32.remove(regVal.index);
-                            }
-                            signed64.add(regVal.index);
-                            break;
-                        case Float:
-                            // If the register was used as a wider signed type
-                            // do not add it here
-                            if (!float64.contains(regVal.index)) {
-                                float32.add(regVal.index);
-                            }
-                            break;
-                        case Double:
-                            // If the register was used as a narrower signed type
-                            // remove it from there and add it to wider type.
-                            if (float32.contains(regVal.index)) {
-                                float32.remove(regVal.index);
-                            }
-                            float64.add(regVal.index);
-                            break;
-                        case Object:
-                            unsigned64.add(regVal.index);
-                            break;
-                        case Byte:
-                            unsigned8.add(regVal.index);
-                            break;
-                        default:
-                            throw GraalInternalError.shouldNotReachHere("unhandled register type " + value.toString());
-                    }
-                }
-            }
-        }
-    }
-
-    class PTXFrameContext implements FrameContext {
-
-        @Override
-        public void enter(CompilationResultBuilder crb) {
-            // codeBuffer.emitString(".address_size 32"); // PTX ISA version 2.3
-        }
-
-        @Override
-        public void leave(CompilationResultBuilder crb) {
-        }
-
-        public boolean hasFrame() {
-            return true;
-        }
-    }
-
-    @Override
-    public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
-        // Omit the frame of the method:
-        // - has no spill slots or other slots allocated during register allocation
-        // - has no callee-saved registers
-        // - has no incoming arguments passed on the stack
-        // - has no instructions with debug info
-        Assembler masm = createAssembler(frameMap);
-        PTXFrameContext frameContext = new PTXFrameContext();
-        CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult);
-        crb.setTotalFrameSize(0);
-        return crb;
-    }
-
-    @Override
-    public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMapBuilder frameMapBuilder, ResolvedJavaMethod method, Object stub) {
-        return new LIRGenerationResultBase(lir, frameMapBuilder);
-    }
-
-    @Override
-    protected Assembler createAssembler(FrameMap frameMap) {
-        return new PTXMacroAssembler(getTarget(), frameMap.getRegisterConfig());
-    }
-
-    @Override
-    public LIRGeneratorTool newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes) {
-        return new PTXHotSpotLIRGenerator(getProviders(), getRuntime().getConfig(), cc, lirGenRes);
-    }
-
-    @Override
-    public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        return new PTXHotSpotNodeLIRBuilder(graph, lirGen);
-    }
-
-    private static void emitKernelEntry(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod codeCacheOwner) {
-        // Emit PTX kernel entry text based on PTXParameterOp
-        // instructions in the start block. Remove the instructions
-        // once kernel entry text and directives are emitted to
-        // facilitate seemless PTX code generation subsequently.
-        assert codeCacheOwner != null : lir + " is not associated with a method";
-        final String name = codeCacheOwner.getName();
-        Assembler asm = crb.asm;
-
-        // Emit initial boiler-plate directives.
-        asm.emitString(".version 3.0");
-        asm.emitString(".target sm_30");
-        asm.emitString0(".entry " + name + " (");
-        asm.emitString("");
-
-        // Get the start block
-        AbstractBlock<?> startBlock = lir.getControlFlowGraph().getStartBlock();
-        // Keep a list of ParameterOp instructions to delete from the
-        // list of instructions in the block.
-        ArrayList<LIRInstruction> deleteOps = new ArrayList<>();
-
-        // Emit .param arguments to kernel entry based on ParameterOp
-        // instruction.
-        for (LIRInstruction op : lir.getLIRforBlock(startBlock)) {
-            if (op instanceof PTXParameterOp) {
-                op.emitCode(crb);
-                deleteOps.add(op);
-            }
-        }
-
-        // Delete ParameterOp instructions.
-        for (LIRInstruction op : deleteOps) {
-            lir.getLIRforBlock(startBlock).remove(op);
-        }
-
-        // Start emiting body of the PTX kernel.
-        asm.emitString0(") {");
-        asm.emitString("");
-    }
-
-    // Emit .reg space declarations
-    private static void emitRegisterDecl(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod codeCacheOwner) {
-
-        assert codeCacheOwner != null : lir + " is not associated with a method";
-
-        RegisterAnalysis registerAnalysis = new RegisterAnalysis();
-        // Assume no predicate registers are used
-        int maxPredRegNum = -1;
-
-        for (AbstractBlock<?> b : lir.codeEmittingOrder()) {
-            for (LIRInstruction op : lir.getLIRforBlock(b)) {
-                if (op instanceof LabelOp) {
-                    // Don't consider this as a definition
-                } else {
-                    if (op instanceof PTXPredicatedLIRInstruction) {
-                        // Update maximum predicate register number if op uses a larger number
-                        int opPredRegNum = ((PTXPredicatedLIRInstruction) op).getPredRegNum();
-                        maxPredRegNum = (opPredRegNum > maxPredRegNum) ? opPredRegNum : maxPredRegNum;
-                    }
-                    // Record registers used in the kernel
-                    registerAnalysis.op = op;
-                    op.visitEachTemp(registerAnalysis);
-                    op.visitEachOutput(registerAnalysis);
-                }
-            }
-        }
-
-        // Emit register declarations
-        Assembler asm = crb.asm;
-        registerAnalysis.emitDeclarations(asm);
-
-        // emit predicate register declaration
-        if (maxPredRegNum > -1) {
-            asm.emitString(".reg .pred %p<" + ++maxPredRegNum + ">;");
-        }
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod codeCacheOwner) {
-        assert codeCacheOwner != null : lir + " is not associated with a method";
-        Assembler asm = crb.asm;
-
-        // Emit the prologue
-        emitKernelEntry(crb, lir, codeCacheOwner);
-
-        // Emit register declarations
-        try {
-            emitRegisterDecl(crb, lir, codeCacheOwner);
-        } catch (GraalInternalError e) {
-            e.printStackTrace();
-            // TODO : Better error handling needs to be done once
-            // all types of parameters are handled.
-            asm.close(false);
-            return;
-        }
-        // Emit code for the LIR
-        try {
-            crb.emit(lir);
-        } catch (GraalInternalError e) {
-            e.printStackTrace();
-            // TODO : Better error handling needs to be done once
-            // all types of parameters are handled.
-            asm.close(false);
-            return;
-        }
-
-        // Emit the epilogue
-        asm.emitString0("}");
-        asm.emitString("");
-    }
-
-    /**
-     * Gets the total number of available CUDA cores.
-     */
-    public int getAvailableProcessors() {
-        if (!deviceInitialized) {
-            return 0;
-        }
-        return getAvailableProcessors0();
-    }
-
-    private static native int getAvailableProcessors0();
-
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +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.hotspot.ptx;
-
-import static com.oracle.graal.hotspot.InitTimer.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.ptx.*;
-
-@ServiceProvider(HotSpotBackendFactory.class)
-public class PTXHotSpotBackendFactory implements HotSpotBackendFactory {
-
-    public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotBackend hostBackend) {
-        HotSpotProviders host = hostBackend.getProviders();
-        MetaAccessProvider metaAccess;
-        PTXHotSpotCodeCacheProvider codeCache;
-        ConstantReflectionProvider constantReflection;
-        HotSpotForeignCallsProvider foreignCalls;
-        LoweringProvider lowerer;
-        Replacements replacements;
-        HotSpotDisassemblerProvider disassembler;
-        SuitesProvider suites;
-        HotSpotRegistersProvider registers;
-        HotSpotProviders providers;
-        try (InitTimer t = timer("create providers")) {
-            try (InitTimer rt = timer("create MetaAccess provider")) {
-                metaAccess = host.getMetaAccess();
-            }
-            try (InitTimer rt = timer("create CodeCache provider")) {
-                codeCache = new PTXHotSpotCodeCacheProvider(runtime, createTarget());
-            }
-            try (InitTimer rt = timer("create ConstantReflection provider")) {
-                constantReflection = host.getConstantReflection();
-            }
-            try (InitTimer rt = timer("create ForeignCalls provider")) {
-                foreignCalls = new PTXHotSpotForeignCallsProvider();
-            }
-            try (InitTimer rt = timer("create Lowerer provider")) {
-                lowerer = new PTXHotSpotLoweringProvider(host.getLowerer());
-            }
-            try (InitTimer rt = timer("create Replacements provider")) {
-                replacements = host.getReplacements();
-            }
-            try (InitTimer rt = timer("create Disassembler provider")) {
-                disassembler = host.getDisassembler();
-            }
-            try (InitTimer rt = timer("create Suites provider")) {
-                suites = new DefaultSuitesProvider();
-            }
-            try (InitTimer rt = timer("create HotSpotRegisters provider")) {
-                registers = new HotSpotRegisters(PTX.tid, Register.None, Register.None);
-            }
-            providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, host.getSnippetReflection());
-        }
-        try (InitTimer rt = timer("instantiate backend")) {
-            return new PTXHotSpotBackend(runtime, providers);
-        }
-    }
-
-    protected Architecture createArchitecture() {
-        return new PTX();
-    }
-
-    protected TargetDescription createTarget() {
-        final int stackFrameAlignment = 1;
-        final int implicitNullCheckLimit = 0;
-        final boolean inlineObjects = true;
-        return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
-    }
-
-    public String getArchitecture() {
-        return "PTX";
-    }
-
-    public String getGraalRuntimeName() {
-        return "basic";
-    }
-
-    @Override
-    public String toString() {
-        return getGraalRuntimeName() + ":" + getArchitecture();
-    }
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotCodeCacheProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /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.hotspot.ptx;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
-
-public class PTXHotSpotCodeCacheProvider extends HotSpotCodeCacheProvider {
-
-    public PTXHotSpotCodeCacheProvider(HotSpotGraalRuntimeProvider runtime, TargetDescription target) {
-        super(runtime, target, new PTXHotSpotRegisterConfig());
-    }
-
-    @Override
-    public String disassemble(CompilationResult compResult, InstalledCode installedCode) {
-        byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
-        return new String(code);
-    }
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotForeignCallsProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +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.ptx;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.hotspot.meta.*;
-
-public class PTXHotSpotForeignCallsProvider implements HotSpotForeignCallsProvider {
-
-    public boolean isReexecutable(ForeignCallDescriptor descriptor) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public LocationIdentity[] getKilledLocations(ForeignCallDescriptor descriptor) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public boolean canDeoptimize(ForeignCallDescriptor descriptor) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public ForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public Value[] getNativeABICallerSaveRegisters() {
-        throw GraalInternalError.unimplemented();
-    }
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * 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.ptx;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.ptx.*;
-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;
-import com.oracle.graal.lir.gen.*;
-
-/**
- * LIR generator specialized for PTX HotSpot.
- */
-public class PTXHotSpotLIRGenerator extends PTXLIRGenerator implements HotSpotLIRGenerator {
-
-    protected PTXHotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) {
-        super(new DefaultLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, cc, lirGenRes);
-        assert config.basicLockSize == 8;
-    }
-
-    public void emitTailcall(Value[] args, Value address) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public StackSlot getLockSlot(int lockDepth) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public HotSpotProviders getProviders() {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @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 SaveRegistersOp emitSaveAllRegisters() {
-        throw GraalInternalError.unimplemented();
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotLoweringProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +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.ptx;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-
-public class PTXHotSpotLoweringProvider implements LoweringProvider {
-
-    private final LoweringProvider host;
-
-    public PTXHotSpotLoweringProvider(LoweringProvider host) {
-        this.host = host;
-    }
-
-    @Override
-    public void lower(Node n, LoweringTool tool) {
-        if (n instanceof ConvertNode) {
-            // PTX has a cvt instruction that "takes a variety of
-            // operand types and sizes, as its job is to convert from
-            // nearly any data type to any other data type (and
-            // size)." [Section 6.2 of PTX ISA manual]
-            // So, there is no need to lower the operation.
-            return;
-        } else {
-            host.lower(n, tool);
-        }
-    }
-
-    public ValueNode reconstructArrayIndex(Kind elementKind, LocationNode location) {
-        throw GraalInternalError.unimplemented();
-    }
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotNodeLIRBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * 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.ptx;
-
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.ptx.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.nodes.*;
-
-/**
- * LIR generator specialized for PTX HotSpot.
- */
-public class PTXHotSpotNodeLIRBuilder extends PTXNodeLIRBuilder implements HotSpotNodeLIRBuilder {
-
-    protected PTXHotSpotNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
-        super(graph, lirGen);
-    }
-
-    public void emitPrefetchAllocate(ValueNode address, ValueNode distance) {
-        // nop
-    }
-
-    public void emitPatchReturnAddress(ValueNode address) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) {
-        throw GraalInternalError.unimplemented();
-    }
-
-    public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
-        throw GraalInternalError.unimplemented();
-    }
-
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
- * 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
- * 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.ptx;
-
-import static com.oracle.graal.ptx.PTX.*;
-
-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.compiler.common.*;
-import com.oracle.graal.lir.*;
-
-public class PTXHotSpotRegisterConfig implements RegisterConfig {
-
-    private final Register[] allocatable;
-
-    @Override
-    public Register[] getAllocatableRegisters() {
-        return allocatable.clone();
-    }
-
-    @Override
-    public Register[] getAllocatableRegisters(PlatformKind kind) {
-        throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getAllocatableRegisters()");
-    }
-
-    @Override
-    public RegisterAttributes[] getAttributesMap() {
-        throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getAttributesMap()");
-    }
-
-    private final Register[] javaGeneralParameterRegisters;
-    private final Register[] nativeGeneralParameterRegisters;
-
-    private static Register[] initAllocatable() {
-        Register[] registers = new Register[]{r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15};
-
-        return registers;
-    }
-
-    public PTXHotSpotRegisterConfig() {
-        javaGeneralParameterRegisters = paramRegisters;
-        nativeGeneralParameterRegisters = gprRegisters;
-
-        allocatable = initAllocatable();
-    }
-
-    @Override
-    public Register[] getCallerSaveRegisters() {
-        // No caller save registers; return empty array
-        return new Register[]{};
-    }
-
-    @Override
-    public boolean areAllAllocatableRegistersCallerSaved() {
-        throw GraalInternalError.unimplemented();
-    }
-
-    @Override
-    public Register getRegisterForRole(int index) {
-        throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getRegisterForRole()");
-    }
-
-    @Override
-    public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, TargetDescription target, boolean stackOnly) {
-        if (type == Type.NativeCall) {
-            return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
-        }
-        return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, type, target, stackOnly);
-    }
-
-    @Override
-    public Register[] getCallingConventionRegisters(Type type, Kind kind) {
-        throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getRegisterForRole()");
-    }
-
-    private static CallingConvention callingConvention(@SuppressWarnings("unused") Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type,
-                    TargetDescription target, boolean stackOnly) {
-
-        assert stackOnly == false;
-
-        int currentGeneral = 0;
-        int currentStackOffset = 0;
-
-        Kind returnKind = returnType == null ? Kind.Void : returnType.getKind();
-
-        AllocatableValue returnLocation;
-        if (returnKind == Kind.Void) {
-            returnLocation = Value.ILLEGAL;
-        } else {
-            returnLocation = new Variable(target.getLIRKind(returnKind), currentGeneral++);
-        }
-
-        AllocatableValue[] locations = new AllocatableValue[parameterTypes.length];
-
-        for (int i = 0; i < parameterTypes.length; i++) {
-            final Kind kind = parameterTypes[i].getKind();
-
-            switch (kind) {
-                case Byte:
-                case Boolean:
-                case Short:
-                case Char:
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                case Object:
-                    if (!stackOnly) {
-                        locations[i] = new Variable(target.getLIRKind(kind), currentGeneral++);
-                    }
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-
-            if (locations[i] == null) {
-                locations[i] = StackSlot.get(target.getLIRKind(kind.getStackKind()), currentStackOffset, !type.out);
-                currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize);
-            }
-        }
-
-        return new CallingConvention(currentStackOffset, returnLocation, locations);
-    }
-
-    @Override
-    public Register getReturnRegister(Kind kind) {
-        throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getRegisterForRole()");
-    }
-
-    @Override
-    public Register getFrameRegister() {
-        // No frame register
-        return null;
-    }
-
-    public CalleeSaveLayout getCalleeSaveLayout() {
-        return null;
-    }
-
-    @Override
-    public String toString() {
-        return String.format("Allocatable: " + Arrays.toString(getAllocatableRegisters()) + "%n" + "CallerSave:  " + Arrays.toString(getCallerSaveRegisters()) + "%n");
-    }
-}
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXWrapperBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,360 +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.ptx;
-
-import static com.oracle.graal.api.meta.DeoptimizationAction.*;
-import static com.oracle.graal.api.meta.DeoptimizationReason.*;
-import static com.oracle.graal.api.meta.LocationIdentity.*;
-import static com.oracle.graal.asm.NumUtil.*;
-import static com.oracle.graal.hotspot.ptx.PTXHotSpotBackend.*;
-import static com.oracle.graal.hotspot.ptx.PTXWrapperBuilder.LaunchArg.*;
-import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
-import static com.oracle.graal.nodes.ConstantNode.*;
-
-import java.util.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.hotspot.nodes.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.lir.ptx.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.HeapAccess.BarrierType;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.replacements.*;
-import com.oracle.graal.replacements.nodes.*;
-import com.oracle.graal.word.*;
-
-/**
- * Utility for building a graph that "wraps" a compiled PTX kernel. Such a wrapper handles the
- * transition from the host CPU to the GPU and back. The wrapper allocate 3 on-stack buffers:
- * <ul>
- * <li>PARAMS: a buffer for the kernel parameters and one word for the on-device address of the
- * return value (if any).</li>
- * <li>PINNED: a buffer into which the address of pinned objects is saved.</li>
- * <li>OBJECT_OFFSETS: the offsets of the object values in PARAMS.</li>
- * </ul>
- *
- *
- * The PARAMS buffer is the {@code CU_LAUNCH_PARAM_BUFFER_POINTER} buffer passed in the
- * {@code extra} argument to the {@code cuLaunchKernel} function. This buffer contains the
- * parameters to the call. The buffer is word aligned and each parameter is aligned in the buffer
- * according to its data size. The wrapper copies the incoming arguments into the buffer as is. The
- * native {@link PTXHotSpotBackend#CALL_KERNEL callKernel} function will pin the memory for each
- * object parameter (using {@code cuMemHostRegister}) and then replace the object pointer in PARAMS
- * with an on-device pointer to the object's memory (see {@code cuMemHostGetDevicePointer}). The
- * function saves pinned object pointer into PINNED so that it can unpinned once the kernel returns.
- * The object pointers in PARAMS are specified by OBJECT_OFFSETS.
- * <p>
- * As a concrete example, for a kernel whose Java method signature is:
- *
- * <pre>
- *     static int kernel(int p1, short p2, Object p3, long p4)
- * </pre>
- *
- * the graph created is shown below as psuedo-code:
- *
- * <pre>
- *     int kernel_wrapper(int p1, short p2, oop p3, long p4) {
- *         address kernelAddr = kernel.start;
- *         if (kernelAddr == 0) {
- *             deopt(InvalidateRecompile, RuntimeConstraint);
- *         }
- *         byte PARAMS[32];
- *         word PINNED[1]; // note: no refmap
- *         int OBJECT_OFFSETS[1] = {8};
- *         ((int*) PARAMS)[0] = p1;
- *         ((short*) PARAMS)[2] = p2;
- *         ((word*) PARAMS)[1] = p3;
- *         ((long*) PARAMS)[2] = p4;
- *         int result = CALL_KERNEL(THREAD_REGISTER, KERNEL_ENTRY_POINT, 1, 1, 1, PARAMS, 32, 1, OBJECT_OFFSETS, PINNED, 4);
- *         if (clearPendingException(thread)) {
- *             deopt(None, RuntimeConstraint);
- *         }
- *         return result;
- *     }
- * </pre>
- * <p>
- * The generated graph includes a reference to the {@link HotSpotNmethod} for the kernel. There must
- * be another reference to the same {@link HotSpotNmethod} object to ensure that the nmethod is not
- * unloaded by the next full GC. Currently, these extra "keep-alive" references are maintained by
- * {@link PTXHotSpotBackend}.
- * <p>
- * The PTX runtime code called by the wrapper blocks GC while the kernel is executing (cf
- * GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical JNI functions). This ensures objects can
- * be safely passed to kernels but should be replaced with a lighter weight mechanism at some point.
- */
-public class PTXWrapperBuilder extends GraphKit {
-
-    /**
-     * The incoming Java arguments to the method.
-     */
-    ParameterNode[] javaParameters;
-
-    /**
-     * The size of the buffer holding the kernel parameters and the extra word for storing the
-     * pointer to device memory for the return value.
-     *
-     * @see LaunchArg#ParametersAndReturnValueBufferSize
-     */
-    int bufSize;
-
-    /**
-     * Offset of each Java argument in the kernel parameters buffer.
-     */
-    int[] javaParameterOffsetsInKernelParametersBuffer;
-
-    /**
-     * Constants denoting the arguments to {@link PTXHotSpotBackend#CALL_KERNEL}.
-     */
-    // @formatter:off
-    enum LaunchArg {
-        Thread,
-        Kernel,
-        DimX,
-        DimY,
-        DimZ,
-        ParametersAndReturnValueBuffer,
-        ParametersAndReturnValueBufferSize,
-        ObjectParametersCount,
-        ObjectParametersOffsets,
-        PinnedObjects,
-        EncodedReturnTypeSize
-    }
-    // @formatter:on
-
-    /**
-     * Creates the graph implementing the CPU to GPU transition.
-     *
-     * @param method a method that has been compiled to GPU binary code
-     * @param kernel the installed GPU binary for {@code method}
-     * @see PTXWrapperBuilder
-     */
-    public PTXWrapperBuilder(ResolvedJavaMethod method, HotSpotNmethod kernel, HotSpotProviders providers) {
-        super(new StructuredGraph(method), providers);
-        int wordSize = providers.getCodeCache().getTarget().wordSize;
-        int intSize = Integer.SIZE / Byte.SIZE;
-        Kind wordKind = providers.getCodeCache().getTarget().wordKind;
-        Signature sig = method.getSignature();
-        boolean isStatic = method.isStatic();
-        int sigCount = sig.getParameterCount(false);
-        javaParameters = new ParameterNode[(!isStatic ? 1 : 0) + sigCount];
-        javaParameterOffsetsInKernelParametersBuffer = new int[javaParameters.length];
-        int javaParametersIndex = 0;
-        Kind returnKind = sig.getReturnKind();
-
-        List<Integer> objectSlots = new ArrayList<>(javaParameters.length);
-        if (!isStatic) {
-            allocateParameter(Kind.Object, javaParametersIndex++, objectSlots, wordSize);
-        }
-        for (int sigIndex = 0; sigIndex < sigCount; sigIndex++) {
-            Kind kind = sig.getParameterKind(sigIndex);
-            allocateParameter(kind, javaParametersIndex++, objectSlots, wordSize);
-        }
-        bufSize = roundUp(bufSize, wordSize);
-
-        // Add slot for the device memory pointer. The kernel writes a
-        // pointer in this slot that points to the return value.
-        int encodedReturnTypeSize = 0;
-        if (returnKind != Kind.Void) {
-            bufSize += wordSize;
-            if (returnKind == Kind.Object) {
-                encodedReturnTypeSize = -wordSize;
-            } else {
-                encodedReturnTypeSize = returnKind.getBitCount() / Byte.SIZE;
-            }
-        }
-
-        InvokeNode kernelStart = createInvoke(getClass(), "getKernelStart", ConstantNode.forConstant(kernel.asConstant(), providers.getMetaAccess(), getGraph()));
-
-        AllocaNode buf = append(new AllocaNode(bufSize / wordSize, wordKind, new BitSet()));
-        ValueNode objectParametersOffsets;
-        ValueNode pinnedObjects;
-        ConstantNode nullWord = ConstantNode.forIntegerKind(wordKind, 0L, getGraph());
-        if (objectSlots.isEmpty()) {
-            objectParametersOffsets = ConstantNode.forLong(0, getGraph());
-            pinnedObjects = ConstantNode.forLong(0, getGraph());
-        } else {
-            int intsPerWord = wordSize / intSize;
-            int slots = roundUp(objectSlots.size(), intsPerWord);
-            objectParametersOffsets = append(new AllocaNode(slots, wordKind, new BitSet()));
-            // No refmap for pinned objects list since kernel execution is (currently) GC unsafe
-            pinnedObjects = append(new AllocaNode(objectSlots.size(), wordKind, new BitSet()));
-
-            // Initialize the object parameter offsets array
-            int index = 0;
-            for (int slot : objectSlots) {
-                int offset = slot * wordSize;
-                LocationNode location = getGraph().unique(new ConstantLocationNode(FINAL_LOCATION, index * intSize));
-                append(new WriteNode(objectParametersOffsets, ConstantNode.forInt(offset, getGraph()), location, BarrierType.NONE, false));
-                index++;
-            }
-        }
-
-        Map<LaunchArg, ValueNode> args = new EnumMap<>(LaunchArg.class);
-        args.put(Thread, append(new ReadRegisterNode(providers.getRegisters().getThreadRegister(), true, false)));
-        args.put(Kernel, kernelStart);
-        args.put(DimX, forInt(1, getGraph()));
-        args.put(DimY, forInt(1, getGraph()));
-        args.put(DimZ, forInt(1, getGraph()));
-        args.put(ParametersAndReturnValueBuffer, buf);
-        args.put(ParametersAndReturnValueBufferSize, forInt(bufSize, getGraph()));
-        args.put(ObjectParametersCount, forInt(objectSlots.size(), getGraph()));
-        args.put(ObjectParametersOffsets, objectParametersOffsets);
-        args.put(PinnedObjects, pinnedObjects);
-        args.put(EncodedReturnTypeSize, forInt(encodedReturnTypeSize, getGraph()));
-
-        int sigIndex = isStatic ? 0 : -1;
-        for (javaParametersIndex = 0; javaParametersIndex < javaParameters.length; javaParametersIndex++) {
-            ParameterNode javaParameter = javaParameters[javaParametersIndex];
-            int javaParameterOffset = javaParameterOffsetsInKernelParametersBuffer[javaParametersIndex];
-            LocationNode location = getGraph().unique(new ConstantLocationNode(FINAL_LOCATION, javaParameterOffset));
-            append(new WriteNode(buf, javaParameter, location, BarrierType.NONE, false));
-            updateDimArg(method, sig, sigIndex++, args, javaParameter);
-        }
-        if (returnKind != Kind.Void) {
-            LocationNode location = getGraph().unique(new ConstantLocationNode(FINAL_LOCATION, bufSize - wordSize));
-            append(new WriteNode(buf, nullWord, location, BarrierType.NONE, false));
-        }
-
-        HIRFrameStateBuilder fsb = new HIRFrameStateBuilder(method, getGraph(), true);
-        FrameState fs = fsb.create(0);
-        getGraph().start().setStateAfter(fs);
-
-        ValueNode[] launchArgsArray = args.values().toArray(new ValueNode[args.size()]);
-        ForeignCallNode result = append(new ForeignCallNode(providers.getForeignCalls(), CALL_KERNEL, launchArgsArray));
-        result.setStateAfter(fs);
-
-        InvokeNode getObjectResult = null;
-        ValueNode returnValue;
-        switch (returnKind) {
-            case Void:
-                returnValue = null;
-                break;
-            case Boolean:
-            case Byte:
-            case Short:
-            case Char:
-            case Int:
-                returnValue = unique(new NarrowNode(result, 32));
-                break;
-            case Long:
-                returnValue = result;
-                break;
-            case Float: {
-                ValueNode asInt = unique(new NarrowNode(result, 32));
-                returnValue = ReinterpretNode.reinterpret(Kind.Float, asInt);
-                break;
-            }
-            case Double:
-                returnValue = ReinterpretNode.reinterpret(Kind.Double, result);
-                break;
-            case Object:
-                getObjectResult = createInvoke(getClass(), "getObjectResult", args.get(Thread));
-                returnValue = append(getObjectResult);
-                break;
-            default:
-                throw new GraalInternalError("%s return kind not supported", returnKind);
-        }
-
-        append(new ReturnNode(returnValue));
-
-        if (Debug.isDumpEnabled()) {
-            Debug.dump(getGraph(), "Initial kernel launch graph");
-        }
-
-        rewriteWordTypes(providers.getSnippetReflection());
-        inlineInvokes(providers.getSnippetReflection());
-
-        if (Debug.isDumpEnabled()) {
-            Debug.dump(getGraph(), "Kernel launch graph before compilation");
-        }
-    }
-
-    /**
-     * Computes offset and size of space in PARAMS for a Java parameter.
-     *
-     * @param kind the kind of the parameter
-     * @param javaParametersIndex the index of the Java parameter
-     */
-    private void allocateParameter(Kind kind, int javaParametersIndex, List<Integer> objectSlots, int wordSize) {
-        int kindByteSize = kind == Kind.Object ? wordSize : kind.getBitCount() / Byte.SIZE;
-        bufSize = roundUp(bufSize, kindByteSize);
-        javaParameterOffsetsInKernelParametersBuffer[javaParametersIndex] = bufSize;
-        Stamp stamp;
-        if (kind == Kind.Object) {
-            stamp = StampFactory.object();
-            int slot = bufSize / wordSize;
-            objectSlots.add(slot);
-        } else {
-            stamp = StampFactory.forKind(kind);
-        }
-        javaParameters[javaParametersIndex] = unique(new ParameterNode(javaParametersIndex, stamp));
-        bufSize += kindByteSize;
-    }
-
-    /**
-     * Updates the {@code dimX}, {@code dimY} or {@code dimZ} argument passed to the kernel if
-     * {@code javaParameter} is annotated with {@link ParallelOver}.
-     */
-    private void updateDimArg(ResolvedJavaMethod method, Signature sig, int sigIndex, Map<LaunchArg, ValueNode> launchArgs, ParameterNode javaParameter) {
-        if (sigIndex >= 0) {
-            ParallelOver parallelOver = method.getParameterAnnotation(ParallelOver.class, sigIndex);
-            if (parallelOver != null && sig.getParameterType(sigIndex, method.getDeclaringClass()).equals(providers.getMetaAccess().lookupJavaType(int[].class))) {
-                ArrayLengthNode dimension = append(new ArrayLengthNode(javaParameter));
-                LaunchArg argKey = LaunchArg.valueOf(LaunchArg.class, "Dim" + parallelOver.dimension());
-                ValueNode existing = launchArgs.put(argKey, dimension);
-                if (existing != null && existing instanceof ArrayLengthNode) {
-                    throw new GraalInternalError("@" + ParallelOver.class.getSimpleName() + " with dimension=" + parallelOver.dimension() + " applied to multiple parameters");
-                }
-            }
-        }
-    }
-
-    /**
-     * Snippet invoked to get the {@linkplain HotSpotNmethod#getStart() entry point} of the kernel,
-     * deoptimizing if the kernel is invalid.
-     */
-    @Snippet
-    private static long getKernelStart(HotSpotNmethod ptxKernel) {
-        long start = ptxKernel.getStart();
-        if (start == 0L) {
-            DeoptimizeNode.deopt(InvalidateRecompile, RuntimeConstraint);
-        }
-        return start;
-    }
-
-    /**
-     * Snippet invoked upon return from the kernel to retrieve an object return value from the
-     * thread local used for communicating object return values from VM calls.
-     */
-    @Snippet
-    private static Object getObjectResult(Word thread) {
-        return getAndClearObjectResult(thread);
-    }
-}
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -106,9 +106,9 @@
     }
 
     @Override
-    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
+    protected void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
         currentRuntimeCallInfo = info;
-        super.emitForeignCall(linkage, result, arguments, temps, info);
+        super.emitForeignCallOp(linkage, result, arguments, temps, info);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -92,7 +92,7 @@
     }
 
     @NodeInfo
-    private static class ConstantFoldBarrier extends FloatingNode implements LIRLowerable {
+    private static final class ConstantFoldBarrier extends FloatingNode implements LIRLowerable {
 
         @Input protected ValueNode input;
 
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -693,12 +693,12 @@
                 }
 
                 @Override
-                protected Boolean merge(MergeNode merge, List<Boolean> states) {
+                protected Boolean merge(AbstractMergeNode merge, List<Boolean> states) {
                     return false;
                 }
 
                 @Override
-                protected Boolean afterSplit(BeginNode node, Boolean oldState) {
+                protected Boolean afterSplit(AbstractBeginNode node, Boolean oldState) {
                     return false;
                 }
             };
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Jan 28 19:32:47 2015 +0100
@@ -58,6 +58,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.OptimisticOptimizations.Optimization;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.printer.*;
 
@@ -224,6 +225,11 @@
                     Suites suites = getSuites(providers);
                     ProfilingInfo profilingInfo = getProfilingInfo();
                     OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo);
+                    if (isOSR) {
+                        // In OSR compiles, we cannot rely on never executed code profiles, because
+                        // all code after the OSR loop is never executed.
+                        optimisticOpts.remove(Optimization.RemoveNeverExecutedCode);
+                    }
                     result = compileGraph(graph, null, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo,
                                     method.getSpeculationLog(), suites, new CompilationResult(), CompilationResultBuilderFactory.Default);
                 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
 /**
  * The details required to link a HotSpot runtime or stub call.
  */
-public class HotSpotForeignCallLinkageImpl implements HotSpotForeignCallLinkage, Remote {
+public class HotSpotForeignCallLinkageImpl implements HotSpotForeignCallLinkage, HotSpotProxified {
 
     /**
      * The descriptor of the call.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,6 @@
 
 import java.lang.reflect.*;
 import java.util.*;
-import java.util.function.*;
 
 import sun.misc.*;
 
@@ -61,7 +60,7 @@
 /**
  * Singleton class holding the instance of the {@link GraalRuntime}.
  */
-public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, Remote {
+public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified {
 
     private static final HotSpotGraalRuntime instance;
 
@@ -80,25 +79,11 @@
         }
     }
 
-    private static Predicate<Void> runtimeAccessCheck;
-
-    /**
-     * Sets a predicate which will be used to assert a valid calling context for a call to
-     * {@link #runtime()}. This is useful for verifying execution scopes that should not make a
-     * static access to {@link HotSpotGraalRuntime}. Such scopes are responsible for resetting the
-     * predicate to null.
-     */
-    public static void setRuntimeAccessCheck(Predicate<Void> predicate) {
-        assert runtimeAccessCheck == null || predicate == null : "at most once runtime access check can be active";
-        runtimeAccessCheck = predicate;
-    }
-
     /**
      * Gets the singleton {@link HotSpotGraalRuntime} object.
      */
     public static HotSpotGraalRuntime runtime() {
         assert instance != null;
-        assert runtimeAccessCheck == null || runtimeAccessCheck.test(null);
         return instance;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotProxified.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * Marker interface for classes whose values are proxied during replay compilation capture.
+ */
+public interface HotSpotProxified {
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Jan 28 19:32:47 2015 +0100
@@ -747,7 +747,6 @@
     @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining;
     @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking;
     @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable;
-    @HotSpotVMFlag(name = "GPUOffload") @Stable public boolean gpuOffload;
 
     @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB;
     @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking;
@@ -1056,44 +1055,6 @@
     @HotSpotVMField(name = "ThreadShadow::_pending_failed_speculation", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingFailedSpeculationOffset;
     @HotSpotVMField(name = "ThreadShadow::_pending_transfer_to_interpreter", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int pendingTransferToInterpreterOffset;
 
-    @HotSpotVMFlag(name = "UseHSAILDeoptimization") @Stable public boolean useHSAILDeoptimization;
-    @HotSpotVMFlag(name = "UseHSAILSafepoints") @Stable public boolean useHSAILSafepoints;
-
-    /**
-     * Offsets of Hsail deoptimization fields (defined in gpu_hsail.hpp). Used to propagate
-     * exceptions from Hsail back to C++ runtime.
-     */
-    @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_notice_safepoints", type = "jint*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailNoticeSafepointsOffset;
-    @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::_alloc_info", type = "HSAILAllocationInfo*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailAllocInfoOffset;
-    @HotSpotVMField(name = "Hsail::HSAILDeoptimizationInfo::_cur_tlab_info", type = "HSAILTlabInfo**", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailCurTlabInfoOffset;
-
-    @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;
-
-    @HotSpotVMField(name = "HSAILFrame::_pc_offset", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailFramePcOffset;
-    @HotSpotVMField(name = "HSAILFrame::_num_s_regs", type = "jbyte", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailFrameNumSRegOffset;
-    @HotSpotVMField(name = "HSAILFrame::_num_d_regs", type = "jbyte", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailFrameNumDRegOffset;
-    @HotSpotVMType(name = "HSAILFrame", get = HotSpotVMType.Type.SIZE) @Stable public int hsailFrameHeaderSize;
-    @HotSpotVMType(name = "Hsail::HSAILKernelDeoptimization", get = HotSpotVMType.Type.SIZE) @Stable public int hsailKernelDeoptimizationHeaderSize;
-    @HotSpotVMType(name = "Hsail::HSAILDeoptimizationInfo", get = HotSpotVMType.Type.SIZE) @Stable public int hsailDeoptimizationInfoHeaderSize;
-
-    @HotSpotVMField(name = "HSAILAllocationInfo::_tlab_infos_pool_start", type = "HSAILTlabInfo*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailAllocInfoTlabInfosPoolStartOffset;
-    @HotSpotVMField(name = "HSAILAllocationInfo::_tlab_infos_pool_next", type = "HSAILTlabInfo*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailAllocInfoTlabInfosPoolNextOffset;
-    @HotSpotVMField(name = "HSAILAllocationInfo::_tlab_infos_pool_end", type = "HSAILTlabInfo*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailAllocInfoTlabInfosPoolEndOffset;
-    @HotSpotVMField(name = "HSAILAllocationInfo::_tlab_align_reserve_bytes", type = "size_t", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailAllocInfoTlabAlignReserveBytesOffset;
-
-    @HotSpotVMField(name = "HSAILTlabInfo::_start", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoStartOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoTopOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_end", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoEndOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_last_good_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoLastGoodTopOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_original_top", type = "HeapWord*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoOriginalTopOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_alloc_info", type = "HSAILAllocationInfo*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoAllocInfoOffset;
-    @HotSpotVMField(name = "HSAILTlabInfo::_tlab", type = "ThreadLocalAllocBuffer*", get = HotSpotVMField.Type.OFFSET) @Stable public int hsailTlabInfoTlabOffset;
-    @HotSpotVMType(name = "HSAILTlabInfo", get = HotSpotVMType.Type.SIZE) @Stable public int hsailTlabInfoSize;
-
     /**
      * Mark word right shift to get identity hash code.
      */
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java	Wed Jan 28 19:32:47 2015 +0100
@@ -81,6 +81,13 @@
                         try {
                             final boolean enableAutoflush = true;
                             ps = new PrintStream(new FileOutputStream(getFilename()), enableAutoflush);
+                            /* Add the JVM and Java arguments to the log file to help identity it. */
+                            String inputArguments = String.join(" ", ManagementFactory.getRuntimeMXBean().getInputArguments());
+                            ps.println("VM Arguments: " + inputArguments);
+                            String cmd = System.getProperty("sun.java.command");
+                            if (cmd != null) {
+                                ps.println("sun.java.command=" + cmd);
+                            }
                         } catch (FileNotFoundException e) {
                             throw new RuntimeException("couldn't open file: " + getValue(), e);
                         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -181,7 +181,9 @@
 
     public native int allocateCompileId(long metaspaceMethod, int entryBCI);
 
-    public native String getGPUs();
+    public String getGPUs() {
+        return "";
+    }
 
     public native boolean canInlineMethod(long metaspaceMethod);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,7 +41,6 @@
 import com.oracle.graal.hotspot.nodes.type.*;
 import com.oracle.graal.hotspot.replacements.*;
 import com.oracle.graal.hotspot.replacements.arraycopy.*;
-import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.calc.*;
@@ -121,31 +120,31 @@
                 instanceofSnippets.lower((InstanceOfDynamicNode) n, tool);
             }
         } else if (n instanceof NewInstanceNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((NewInstanceNode) n, registers, tool);
             }
         } else if (n instanceof DynamicNewInstanceNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((DynamicNewInstanceNode) n, registers, tool);
             }
         } else if (n instanceof NewArrayNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((NewArrayNode) n, registers, runtime, tool);
             }
         } else if (n instanceof DynamicNewArrayNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((DynamicNewArrayNode) n, registers, tool);
             }
         } else if (n instanceof VerifyHeapNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((VerifyHeapNode) n, registers, runtime, tool);
             }
         } else if (n instanceof MonitorEnterNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 monitorSnippets.lower((MonitorEnterNode) n, registers, tool);
             }
         } else if (n instanceof MonitorExitNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 monitorSnippets.lower((MonitorExitNode) n, tool);
             }
         } else if (n instanceof G1PreWriteBarrier) {
@@ -163,7 +162,7 @@
         } else if (n instanceof G1ArrayRangePostWriteBarrier) {
             writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, registers, tool);
         } else if (n instanceof NewMultiArrayNode) {
-            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
                 newObjectSnippets.lower((NewMultiArrayNode) n, tool);
             }
         } else if (n instanceof LoadExceptionObjectNode) {
@@ -302,13 +301,13 @@
          * Anchor the read of the element klass to the cfg, because it is only valid when arrayClass
          * is an object class, which might not be the case in other parts of the compiled method.
          */
-        return graph.unique(new FloatingReadNode(arrayHub, location, null, KlassPointerStamp.klassNonNull(), BeginNode.prevBegin(anchor)));
+        return graph.unique(new FloatingReadNode(arrayHub, location, null, KlassPointerStamp.klassNonNull(), AbstractBeginNode.prevBegin(anchor)));
     }
 
     @Override
     protected void lowerUnsafeLoadNode(UnsafeLoadNode load, LoweringTool tool) {
         StructuredGraph graph = load.graph();
-        if (load.getGuardingCondition() == null && graph.getGuardsStage().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal() && addReadBarrier(load)) {
+        if (load.getGuardingCondition() == null && !graph.getGuardsStage().allowsFloatingGuards() && addReadBarrier(load)) {
             unsafeLoadSnippets.lower(load, tool);
         } else {
             super.lowerUnsafeLoadNode(load, tool);
@@ -354,7 +353,7 @@
             // mirroring the calculations in c1_GraphBuilder.cpp (setup_osr_entry_block)
             int localsOffset = (graph.method().getMaxLocals() - 1) * 8;
             for (OSRLocalNode osrLocal : graph.getNodes(OSRLocalNode.class)) {
-                int size = HIRFrameStateBuilder.stackSlots(osrLocal.getKind());
+                int size = osrLocal.getKind().getSlotCount();
                 int offset = localsOffset - (osrLocal.index() + size - 1) * 8;
                 IndexedLocationNode location = graph.unique(new IndexedLocationNode(ANY_LOCATION, offset, ConstantNode.forLong(0, graph), 1));
                 ReadNode load = graph.add(new ReadNode(buffer, location, osrLocal.stamp(), BarrierType.NONE));
@@ -368,7 +367,7 @@
 
     private void lowerDynamicCounterNode(DynamicCounterNode n) {
         StructuredGraph graph = n.graph();
-        if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+        if (graph.getGuardsStage().areFrameStatesAtDeopts()) {
             BenchmarkCounters.lower(n, registers, runtime.getConfig(), runtime.getTarget().wordKind);
         }
     }
@@ -392,7 +391,7 @@
 
     private void lowerBytecodeExceptionNode(BytecodeExceptionNode node) {
         StructuredGraph graph = node.graph();
-        if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
+        if (graph.getGuardsStage().allowsFloatingGuards()) {
             if (OmitHotExceptionStacktrace.getValue()) {
                 Throwable exception;
                 if (node.getExceptionClass() == NullPointerException.class) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
 /**
  * Implementation of {@link ConstantPool} for HotSpot.
  */
-public class HotSpotConstantPool extends CompilerObject implements ConstantPool, Remote {
+public class HotSpotConstantPool extends CompilerObject implements ConstantPool, HotSpotProxified {
 
     private static final long serialVersionUID = -5443206401485234850L;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantReflectionProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,7 +41,7 @@
 /**
  * HotSpot implementation of {@link ConstantReflectionProvider}.
  */
-public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, Remote {
+public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified {
     private static final String SystemClassName = "Ljava/lang/System;";
 
     protected final HotSpotGraalRuntimeProvider runtime;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProviderImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMemoryAccessProviderImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 /**
  * HotSpot implementation of {@link MemoryAccessProvider}.
  */
-public class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Remote {
+public class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified {
 
     protected final HotSpotGraalRuntimeProvider runtime;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
 /**
  * HotSpot implementation of {@link MetaAccessProvider}.
  */
-public class HotSpotMetaAccessProvider implements MetaAccessProvider, Remote {
+public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified {
 
     protected final HotSpotGraalRuntimeProvider runtime;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstantImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -25,9 +25,10 @@
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
 
-public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, Remote {
+public final class HotSpotMetaspaceConstantImpl extends PrimitiveConstant implements HotSpotMetaspaceConstant, VMConstant, HotSpotProxified {
 
     private static final long serialVersionUID = 1003463314013122983L;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodHandleAccessProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.hotspot.*;
 
-public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, Remote {
+public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider, HotSpotProxified {
 
     private final ConstantReflectionProvider constantReflection;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,6 +29,7 @@
 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.*;
 
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -37,7 +38,7 @@
  * Represents a constant non-{@code null} object reference, within the compiler and across the
  * compiler/runtime interface.
  */
-public final class HotSpotObjectConstantImpl extends AbstractValue implements HotSpotObjectConstant, Remote {
+public final class HotSpotObjectConstantImpl extends AbstractValue implements HotSpotObjectConstant, HotSpotProxified {
 
     private static final long serialVersionUID = 3592151693708093496L;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,7 +27,7 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.nodes.*;
 
-public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo, Remote {
+public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo, HotSpotProxified {
 
     private static final long serialVersionUID = -8307682725047864875L;
     private static final DebugMetric metricInsufficentSpace = Debug.metric("InsufficientSpaceForProfilingData");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
 /**
  * Represents a field in a HotSpot type.
  */
-public class HotSpotResolvedJavaFieldImpl extends CompilerObject implements HotSpotResolvedJavaField, Remote {
+public class HotSpotResolvedJavaFieldImpl extends CompilerObject implements HotSpotResolvedJavaField, HotSpotProxified {
 
     private static final long serialVersionUID = 7692985878836955683L;
     private final HotSpotResolvedObjectTypeImpl holder;
@@ -66,7 +66,12 @@
         }
         if (obj instanceof HotSpotResolvedJavaField) {
             HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj;
-            return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type);
+            if (that.offset != this.offset) {
+                return false;
+            } else if (this.holder.equals(that.holder)) {
+                assert this.name.equals(that.name) && this.type.equals(that.type);
+                return true;
+            }
         }
         return false;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethodImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -42,7 +42,7 @@
 /**
  * Implementation of {@link JavaMethod} for resolved HotSpot methods.
  */
-public final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, Remote {
+public final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, HotSpotProxified {
 
     private static final long serialVersionUID = -5486975070147586588L;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectTypeImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,6 +29,7 @@
 import java.lang.annotation.*;
 import java.lang.reflect.*;
 import java.net.*;
+import java.nio.*;
 import java.util.*;
 
 import com.oracle.graal.api.meta.*;
@@ -38,7 +39,7 @@
 /**
  * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes.
  */
-public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, Remote {
+public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified {
 
     private static final long serialVersionUID = 3481514353553840471L;
 
@@ -788,12 +789,24 @@
     }
 
     @Override
-    public ResolvedJavaField findInstanceFieldWithOffset(long offset) {
+    public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedEntryKind) {
         ResolvedJavaField[] declaredFields = getInstanceFields(true);
         for (ResolvedJavaField field : declaredFields) {
-            if (((HotSpotResolvedJavaField) field).offset() == offset) {
+            HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field;
+            long resolvedFieldOffset = resolvedField.offset();
+            // @formatter:off
+            if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN  &&
+                            expectedEntryKind.isPrimitive() &&
+                            !expectedEntryKind.equals(Kind.Void) &&
+                            resolvedField.getKind().isPrimitive()) {
+                resolvedFieldOffset +=
+                                resolvedField.getKind().getByteCount() -
+                                Math.min(resolvedField.getKind().getByteCount(), 4 + expectedEntryKind.getByteCount());
+            }
+            if (resolvedFieldOffset == offset) {
                 return field;
             }
+            // @formatter:on
         }
         return null;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,11 +30,12 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.hotspot.*;
 
 /**
  * Implementation of {@link JavaType} for primitive HotSpot types.
  */
-public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements Remote {
+public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType implements HotSpotProxified {
 
     private static final long serialVersionUID = -6208552348908071473L;
     private final Kind kind;
@@ -224,7 +225,7 @@
     }
 
     @Override
-    public ResolvedJavaField findInstanceFieldWithOffset(long offset) {
+    public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedType) {
         return null;
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -84,6 +84,7 @@
     protected PhaseSuite<HighTierContext> createGraphBuilderSuite() {
         PhaseSuite<HighTierContext> suite = new PhaseSuite<>();
         GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault();
+        config.setInlineTrivial(true);
         suite.appendPhase(new GraphBuilderPhase(config));
         return suite;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -56,8 +56,7 @@
             ParameterNode arg0 = g.unique(new ParameterNode(0, StampFactory.forKind(Kind.Object)));
             ParameterNode arg1 = g.unique(new ParameterNode(1, StampFactory.forKind(Kind.Object)));
             ParameterNode arg2 = g.unique(new ParameterNode(2, StampFactory.forKind(Kind.Object)));
-            FrameState frameState = g.add(new FrameState(null, method, 0, Arrays.asList(new ValueNode[]{arg0, arg1, arg2}), 3, 0, false, false, new ArrayList<MonitorIdNode>(),
-                            new ArrayList<EscapeObjectState>()));
+            FrameState frameState = g.add(new FrameState(null, method, 0, Arrays.asList(new ValueNode[]{arg0, arg1, arg2}), 3, 0, false, false, null, new ArrayList<EscapeObjectState>()));
             g.start().setStateAfter(frameState);
             List<ValueNode> parameters = new ArrayList<>();
             FixedWithNextNode fixedWithNext = getParameters(g, arg0, argumentTypes.length, argumentTypes, parameters, providers);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/AllocaNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/AllocaNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * the entire execution of the associated method.
  */
 @NodeInfo
-public class AllocaNode extends FixedWithNextNode implements LIRLowerable {
+public final class AllocaNode extends FixedWithNextNode implements LIRLowerable {
 
     /**
      * The number of slots in block.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * check on the object.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class BeginLockScopeNode extends AbstractMemoryCheckpoint implements LIRLowerable, MonitorEnter, MemoryCheckpoint.Single {
+public final class BeginLockScopeNode extends AbstractMemoryCheckpoint implements LIRLowerable, MonitorEnter, MemoryCheckpoint.Single {
 
     protected int lockDepth;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CStringNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
  * Converts a compile-time constant Java string into a C string installed with the generated code.
  */
 @NodeInfo
-public class CStringNode extends FloatingNode implements LIRLowerable {
+public final class CStringNode extends FloatingNode implements LIRLowerable {
 
     protected final String string;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassCastNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassCastNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#cast(Class, Object)
  */
 @NodeInfo
-public class ClassCastNode extends MacroStateSplitNode implements Canonicalizable.Binary<ValueNode> {
+public final class ClassCastNode extends MacroStateSplitNode implements Canonicalizable.Binary<ValueNode> {
 
     public ClassCastNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetClassLoader0Node.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetClassLoader0Node.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  */
 @SuppressWarnings("javadoc")
 @NodeInfo
-public class ClassGetClassLoader0Node extends MacroStateSplitNode implements Canonicalizable {
+public final class ClassGetClassLoader0Node extends MacroStateSplitNode implements Canonicalizable {
 
     public ClassGetClassLoader0Node(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetComponentTypeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetComponentTypeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * @see ClassSubstitutions#getComponentType(Class)
  */
 @NodeInfo
-public class ClassGetComponentTypeNode extends MacroNode implements Canonicalizable {
+public final class ClassGetComponentTypeNode extends MacroNode implements Canonicalizable {
 
     public ClassGetComponentTypeNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetModifiersNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetModifiersNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#getModifiers(Class)
  */
 @NodeInfo
-public class ClassGetModifiersNode extends MacroNode implements Canonicalizable {
+public final class ClassGetModifiersNode extends MacroNode implements Canonicalizable {
 
     public ClassGetModifiersNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetSuperclassNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassGetSuperclassNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * @see ClassSubstitutions#getSuperclass(Class)
  */
 @NodeInfo
-public class ClassGetSuperclassNode extends MacroNode implements Canonicalizable {
+public final class ClassGetSuperclassNode extends MacroNode implements Canonicalizable {
 
     public ClassGetSuperclassNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsArrayNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsArrayNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#isArray(Class)
  */
 @NodeInfo
-public class ClassIsArrayNode extends MacroNode implements Canonicalizable {
+public final class ClassIsArrayNode extends MacroNode implements Canonicalizable {
 
     public ClassIsArrayNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsAssignableFromNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsAssignableFromNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#isAssignableFrom(Class, Class)
  */
 @NodeInfo
-public class ClassIsAssignableFromNode extends MacroStateSplitNode implements Canonicalizable {
+public final class ClassIsAssignableFromNode extends MacroStateSplitNode implements Canonicalizable {
     public ClassIsAssignableFromNode(Invoke invoke) {
         super(invoke);
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInstanceNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInstanceNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * @see ClassSubstitutions#isInstance(Class, Object)
  */
 @NodeInfo
-public class ClassIsInstanceNode extends MacroNode implements Canonicalizable {
+public final class ClassIsInstanceNode extends MacroNode implements Canonicalizable {
 
     public ClassIsInstanceNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInterfaceNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsInterfaceNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#isInterface(Class)
  */
 @NodeInfo
-public class ClassIsInterfaceNode extends MacroNode implements Canonicalizable {
+public final class ClassIsInterfaceNode extends MacroNode implements Canonicalizable {
 
     public ClassIsInterfaceNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsPrimitiveNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/ClassIsPrimitiveNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * @see ClassSubstitutions#isPrimitive(Class)
  */
 @NodeInfo
-public class ClassIsPrimitiveNode extends MacroNode implements Canonicalizable {
+public final class ClassIsPrimitiveNode extends MacroNode implements Canonicalizable {
 
     public ClassIsPrimitiveNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,7 +40,7 @@
  * Compress or uncompress an oop or metaspace pointer.
  */
 @NodeInfo(nameTemplate = "{p#op/s}")
-public class CompressionNode extends UnaryNode implements ConvertNode, LIRLowerable {
+public final class CompressionNode extends UnaryNode implements ConvertNode, LIRLowerable {
 
     public enum CompressionOp {
         Compress,
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * Gets the address of the C++ JavaThread object for the current thread.
  */
 @NodeInfo
-public class CurrentJavaThreadNode extends FloatingNode implements LIRLowerable {
+public final class CurrentJavaThreadNode extends FloatingNode implements LIRLowerable {
 
     protected LIRKind wordKind;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * Intrinsic for getting the lock in the current {@linkplain BeginLockScopeNode lock scope}.
  */
 @NodeInfo
-public class CurrentLockNode extends FixedWithNextNode implements LIRLowerable {
+public final class CurrentLockNode extends FixedWithNextNode implements LIRLowerable {
 
     protected int lockDepth;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizationFetchUnrollInfoCallNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizationFetchUnrollInfoCallNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
  * A call to the runtime code {@code Deoptimization::fetch_unroll_info}.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class DeoptimizationFetchUnrollInfoCallNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Multi {
+public final class DeoptimizationFetchUnrollInfoCallNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Multi {
 
     @Input SaveAllRegistersNode registerSaver;
     protected final ForeignCallsProvider foreignCalls;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizeCallerNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DeoptimizeCallerNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * Removes the current frame and tail calls the uncommon trap routine.
  */
 @NodeInfo(shortName = "DeoptCaller", nameTemplate = "DeoptCaller {p#reason/s}")
-public class DeoptimizeCallerNode extends ControlSinkNode implements LIRLowerable {
+public final class DeoptimizeCallerNode extends ControlSinkNode implements LIRLowerable {
 
     protected final DeoptimizationAction action;
     protected final DeoptimizationReason reason;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
  * instruction.
  */
 @NodeInfo
-public class DimensionsNode extends FixedWithNextNode implements LIRLowerable {
+public final class DimensionsNode extends FixedWithNextNode implements LIRLowerable {
 
     protected final int rank;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectCompareAndSwapNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DirectCompareAndSwapNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * expected value or the compared against value instead of a boolean.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class DirectCompareAndSwapNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Single {
+public final class DirectCompareAndSwapNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode object;
     @Input ValueNode offset;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1ArrayRangePreWriteBarrier.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1ArrayRangePreWriteBarrier.java	Wed Jan 28 19:32:47 2015 +0100
@@ -26,7 +26,7 @@
 import com.oracle.graal.nodes.*;
 
 @NodeInfo
-public class G1ArrayRangePreWriteBarrier extends ArrayRangeWriteBarrier {
+public final class G1ArrayRangePreWriteBarrier extends ArrayRangeWriteBarrier {
 
     public G1ArrayRangePreWriteBarrier(ValueNode object, ValueNode startIndex, ValueNode length) {
         super(object, startIndex, length);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1PreWriteBarrier.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1PreWriteBarrier.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,7 +27,7 @@
 import com.oracle.graal.nodes.extended.*;
 
 @NodeInfo
-public class G1PreWriteBarrier extends WriteBarrier implements DeoptimizingNode.DeoptBefore {
+public final class G1PreWriteBarrier extends WriteBarrier implements DeoptimizingNode.DeoptBefore {
 
     @OptionalInput(InputType.State) FrameState stateBefore;
     protected final boolean nullCheck;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1ReferentFieldReadBarrier.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/G1ReferentFieldReadBarrier.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * read barrier and consequently is added to the SATB queue if the concurrent marker is enabled.
  */
 @NodeInfo
-public class G1ReferentFieldReadBarrier extends WriteBarrier {
+public final class G1ReferentFieldReadBarrier extends WriteBarrier {
 
     protected final boolean doLoad;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * this is if the usage is not an attempt to dereference the value.
  */
 @NodeInfo
-public class GetObjectAddressNode extends FixedWithNextNode implements LIRLowerable {
+public final class GetObjectAddressNode extends FixedWithNextNode implements LIRLowerable {
 
     @Input ValueNode object;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotIndirectCallTargetNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotIndirectCallTargetNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
 import com.oracle.graal.nodes.*;
 
 @NodeInfo
-public class HotSpotIndirectCallTargetNode extends IndirectCallTargetNode {
+public final class HotSpotIndirectCallTargetNode extends IndirectCallTargetNode {
 
     @Input ValueNode metaspaceMethod;
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LoadIndexedPointerNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/LoadIndexedPointerNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,7 +29,7 @@
 import com.oracle.graal.nodes.java.*;
 
 @NodeInfo
-public class LoadIndexedPointerNode extends LoadIndexedNode {
+public final class LoadIndexedPointerNode extends LoadIndexedNode {
 
     public LoadIndexedPointerNode(Stamp stamp, ValueNode array, ValueNode index) {
         super(stamp, array, index, Kind.Illegal);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
  * Node that is used to maintain a stack based counter of how many locks are currently held.
  */
 @NodeInfo
-public class MonitorCounterNode extends FloatingNode implements LIRLowerable {
+public final class MonitorCounterNode extends FloatingNode implements LIRLowerable {
 
     public MonitorCounterNode() {
         super(null);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * A call to the {@link NewArrayStub}.
  */
 @NodeInfo
-public class NewArrayStubCall extends DeoptimizingStubCall implements LIRLowerable {
+public final class NewArrayStubCall extends DeoptimizingStubCall implements LIRLowerable {
 
     private static final Stamp defaultStamp = StampFactory.objectNonNull();
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * A call to the {@link NewInstanceStub}.
  */
 @NodeInfo
-public class NewInstanceStubCall extends DeoptimizingStubCall implements LIRLowerable {
+public final class NewInstanceStubCall extends DeoptimizingStubCall implements LIRLowerable {
 
     private static final Stamp defaultStamp = StampFactory.objectNonNull();
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * Node implementing a call to {@code GraalRuntime::new_multi_array}.
  */
 @NodeInfo
-public class NewMultiArrayStubCall extends ForeignCallNode {
+public final class NewMultiArrayStubCall extends ForeignCallNode {
 
     private static final Stamp defaultStamp = StampFactory.objectNonNull();
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetAnchorNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/SnippetAnchorNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,10 +37,10 @@
 
     @Override
     public void simplify(SimplifierTool tool) {
-        BeginNode prevBegin = BeginNode.prevBegin(this);
+        AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(this);
         replaceAtUsages(InputType.Anchor, prevBegin);
         replaceAtUsages(InputType.Guard, prevBegin);
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             graph().removeFixed(this);
         }
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * 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
- * 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 static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.spi.*;
-
-/**
- * Performs a tail call to the specified target compiled method, with the parameter taken from the
- * supplied FrameState.
- */
-@NodeInfo
-public class TailcallNode extends FixedWithNextNode implements LIRLowerable {
-
-    @Input(InputType.State) FrameState frameState;
-    @Input ValueNode target;
-
-    public TailcallNode(ValueNode target, FrameState frameState) {
-        super(StampFactory.forVoid());
-        this.target = target;
-        this.frameState = frameState;
-    }
-
-    public void generate(NodeLIRBuilderTool gen) {
-        HotSpotVMConfig config = runtime().getConfig();
-        LIRGeneratorTool lirGen = gen.getLIRGeneratorTool();
-        ResolvedJavaMethod method = frameState.method();
-        boolean isStatic = method.isStatic();
-
-        JavaType[] signature = method.getSignature().toParameterTypes(isStatic ? null : method.getDeclaringClass());
-        CallingConvention cc = lirGen.getResult().getFrameMapBuilder().getRegisterConfig().getCallingConvention(CallingConvention.Type.JavaCall, null, signature, lirGen.target(), false);
-        List<ValueNode> parameters = new ArrayList<>();
-        for (int i = 0, slot = 0; i < cc.getArgumentCount(); i++, slot += HIRFrameStateBuilder.stackSlots(frameState.localAt(slot).getKind())) {
-            parameters.add(frameState.localAt(slot));
-        }
-        Value[] args = gen.visitInvokeArguments(cc, parameters);
-        Value address = lirGen.emitAddress(gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0);
-        Value entry = lirGen.emitLoad(LIRKind.value(Kind.Long), address, null);
-        HotSpotLIRGenerator hsgen = (HotSpotLIRGenerator) gen;
-        hsgen.emitTailcall(args, entry);
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/WriteBarrier.java	Wed Jan 28 19:32:47 2015 +0100
@@ -62,7 +62,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        assert graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA;
+        assert graph().getGuardsStage().areFrameStatesAtDeopts();
         tool.getLowerer().lower(this, tool);
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 import com.oracle.graal.replacements.nodes.*;
 
 @NodeInfo
-public class CallSiteTargetNode extends MacroStateSplitNode implements Canonicalizable, Lowerable {
+public final class CallSiteTargetNode extends MacroStateSplitNode implements Canonicalizable, Lowerable {
 
     public CallSiteTargetNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CardTableAddressNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CardTableAddressNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class CardTableAddressNode extends FloatingNode implements LIRLowerable {
+public final class CardTableAddressNode extends FloatingNode implements LIRLowerable {
 
     public CardTableAddressNode() {
         super(StampFactory.forKind(Kind.Long));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CardTableShiftNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CardTableShiftNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class CardTableShiftNode extends FloatingNode implements LIRLowerable {
+public final class CardTableShiftNode extends FloatingNode implements LIRLowerable {
 
     public CardTableShiftNode() {
         super(StampFactory.intValue());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ClassGetHubNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -42,7 +42,7 @@
  * {@link ReadNode#canonicalizeRead(ValueNode, LocationNode, ValueNode, CanonicalizerTool)}.
  */
 @NodeInfo
-public class ClassGetHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, ConvertNode {
+public final class ClassGetHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, ConvertNode {
     @Input protected ValueNode clazz;
 
     public ClassGetHubNode(ValueNode clazz) {
@@ -56,7 +56,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         } else {
             if (clazz.isConstant()) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompositeValueClassSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CompositeValueClassSubstitutions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -45,7 +45,7 @@
      * {@link Class} parameter.
      */
     @NodeInfo
-    public static class CompositeValueClassGetNode extends PureFunctionMacroNode {
+    public static final class CompositeValueClassGetNode extends PureFunctionMacroNode {
 
         public CompositeValueClassGetNode(Invoke invoke) {
             super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HubGetClassNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -52,7 +52,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         } else {
             MetaAccessProvider metaAccess = tool.getMetaAccess();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java	Wed Jan 28 19:32:47 2015 +0100
@@ -98,7 +98,7 @@
         for (int i = 0; i < hints.length; i++) {
             KlassPointer hintHub = hints[i];
             boolean positive = hintIsPositive[i];
-            if (probability(NOT_FREQUENT_PROBABILITY, hintHub.equal(objectHub))) {
+            if (probability(LIKELY_PROBABILITY, hintHub.equal(objectHub))) {
                 hintsHit.inc();
                 return positive ? trueValue : falseValue;
             }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/KlassLayoutHelperNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -79,7 +79,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         } else {
             if (klass.isConstant()) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -43,7 +43,7 @@
  * Node for invocation methods defined on the class {@link MethodHandle}.
  */
 @NodeInfo
-public class MethodHandleNode extends MacroStateSplitNode implements Simplifiable {
+public final class MethodHandleNode extends MacroStateSplitNode implements Simplifiable {
 
     // Replacement method data
     protected ResolvedJavaMethod replacementTargetMethod;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java	Wed Jan 28 19:32:47 2015 +0100
@@ -511,8 +511,7 @@
                         ConstantNode errMsg = ConstantNode.forConstant(tool.getConstantReflection().forString(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();
-                        FrameState stateAfter = new FrameState(graph.method(), BytecodeFrame.AFTER_BCI, new ValueNode[0], stack, new ValueNode[0], new MonitorIdNode[0], false, false);
+                        FrameState stateAfter = new FrameState(null, graph.method(), BytecodeFrame.AFTER_BCI, new ValueNode[0], new ValueNode[0], 0, new ValueNode[0], null, false, false);
                         invoke.setStateAfter(graph.add(stateAfter));
                         graph.addBeforeFixed(ret, invoke);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyCallNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyCallNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
 import com.oracle.graal.runtime.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class ArrayCopyCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+public final class ArrayCopyCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode src;
     @Input ValueNode srcPos;
@@ -117,7 +117,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+        if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
             updateAlignedDisjoint();
             ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupArraycopyDescriptor(elementKind, isAligned(), isDisjoint(), isUninitialized());
             StructuredGraph graph = graph();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
 import com.oracle.graal.replacements.nodes.*;
 
 @NodeInfo
-public class ArrayCopyNode extends BasicArrayCopyNode implements Virtualizable, Lowerable {
+public final class ArrayCopyNode extends BasicArrayCopyNode implements Virtualizable, Lowerable {
 
     public ArrayCopyNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/CheckcastArrayCopyCallNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/CheckcastArrayCopyCallNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
 import com.oracle.graal.word.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Memory, InputType.Value})
-public class CheckcastArrayCopyCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+public final class CheckcastArrayCopyCallNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode src;
     @Input ValueNode srcPos;
@@ -99,7 +99,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+        if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
             ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupCheckcastArraycopyDescriptor(isUninit());
             StructuredGraph graph = graph();
             ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/UnsafeArrayCopyNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/UnsafeArrayCopyNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -95,7 +95,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
+        if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
             UnsafeArrayCopySnippets.Templates templates = tool.getReplacements().getSnippetTemplateCache(UnsafeArrayCopySnippets.Templates.class);
             templates.lower(this, tool);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Wed Jan 28 19:32:47 2015 +0100
@@ -54,6 +54,8 @@
  */
 public abstract class Stub {
 
+    private static final List<Stub> stubs = new ArrayList<>();
+
     /**
      * The linkage information for a call to this stub from compiled code.
      */
@@ -107,6 +109,14 @@
     public Stub(HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
         this.linkage = linkage;
         this.providers = providers;
+        stubs.add(this);
+    }
+
+    /**
+     * Gets an immutable view of all stubs that have been created.
+     */
+    public static Collection<Stub> getStubs() {
+        return Collections.unmodifiableList(stubs);
     }
 
     /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypeRewriterPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/word/HotSpotWordTypeRewriterPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -156,7 +156,7 @@
          * The read must not float outside its block otherwise it may float above an explicit zero
          * check on its base address.
          */
-        read.setGuard(BeginNode.prevBegin(invoke.asNode()));
+        read.setGuard(AbstractBeginNode.prevBegin(invoke.asNode()));
         return read;
     }
 
--- a/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,261 +0,0 @@
-/*
- * 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.hsail;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-
-import java.nio.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.Register.RegisterCategory;
-import com.oracle.graal.api.meta.*;
-
-/**
- * Represents the HSAIL architecture.
- */
-public class HSAIL extends Architecture {
-
-    private static final int CPU_CONTROL_OFFSET = 0;
-    private static final int CPU_CONTROL_SHIFT = 0;
-    private static final int CPU_CONTROL_NUM = 8;
-
-    private static final int CPU32_OFFSET = CPU_CONTROL_NUM << CPU_CONTROL_SHIFT;
-    private static final int CPU32_SHIFT = 0;
-    private static final int CPU32_NUM = 40;
-
-    private static final int CPU64_OFFSET = CPU32_OFFSET + CPU32_NUM << CPU32_SHIFT;
-    private static final int CPU64_SHIFT = 0;
-    private static final int CPU64_NUM = 21;
-
-    private static final int CPU128_OFFSET = CPU64_OFFSET + CPU64_NUM << CPU64_SHIFT;
-    private static final int CPU128_SHIFT = 1;
-    private static final int CPU128_NUM = 16;
-
-    public static final RegisterCategory CPU_CONTROL = new RegisterCategory("CPU_CONTROL", CPU_CONTROL_OFFSET, CPU_CONTROL_SHIFT);
-    public static final RegisterCategory CPU32 = new RegisterCategory("CPU32", CPU32_OFFSET, CPU32_SHIFT);
-    public static final RegisterCategory CPU64 = new RegisterCategory("CPU64", CPU64_OFFSET, CPU64_SHIFT);
-    public static final RegisterCategory CPU128 = new RegisterCategory("CPU128", CPU128_OFFSET, CPU128_SHIFT);
-
-    // Control registers.
-    public static final Register c0 = new Register(0, 0, "c0", CPU_CONTROL);
-    public static final Register c1 = new Register(1, 1, "c1", CPU_CONTROL);
-    public static final Register c2 = new Register(2, 2, "c2", CPU_CONTROL);
-    public static final Register c3 = new Register(3, 3, "c3", CPU_CONTROL);
-    public static final Register c4 = new Register(4, 4, "c4", CPU_CONTROL);
-    public static final Register c5 = new Register(5, 5, "c5", CPU_CONTROL);
-    public static final Register c6 = new Register(6, 6, "c6", CPU_CONTROL);
-    public static final Register c7 = new Register(7, 7, "c7", CPU_CONTROL);
-
-    // 32 bit registers.
-    public static final Register s0 = new Register(8, 0, "s0", CPU32);
-    public static final Register s1 = new Register(9, 1, "s1", CPU32);
-    public static final Register s2 = new Register(10, 2, "s2", CPU32);
-    public static final Register s3 = new Register(11, 3, "s3", CPU32);
-    public static final Register s4 = new Register(12, 4, "s4", CPU32);
-    public static final Register s5 = new Register(13, 5, "s5", CPU32);
-    public static final Register s6 = new Register(14, 6, "s6", CPU32);
-    public static final Register s7 = new Register(15, 7, "s7", CPU32);
-    public static final Register s8 = new Register(16, 8, "s8", CPU32);
-    public static final Register s9 = new Register(17, 9, "s9", CPU32);
-    public static final Register s10 = new Register(18, 10, "s10", CPU32);
-    public static final Register s11 = new Register(19, 11, "s11", CPU32);
-    public static final Register s12 = new Register(20, 12, "s12", CPU32);
-    public static final Register s13 = new Register(21, 13, "s13", CPU32);
-    public static final Register s14 = new Register(22, 14, "s14", CPU32);
-    public static final Register s15 = new Register(23, 15, "s15", CPU32);
-    public static final Register s16 = new Register(24, 16, "s16", CPU32);
-    public static final Register s17 = new Register(25, 17, "s17", CPU32);
-    public static final Register s18 = new Register(26, 18, "s18", CPU32);
-    public static final Register s19 = new Register(27, 19, "s19", CPU32);
-    public static final Register s20 = new Register(28, 20, "s20", CPU32);
-    public static final Register s21 = new Register(29, 21, "s21", CPU32);
-    public static final Register s22 = new Register(30, 22, "s22", CPU32);
-    public static final Register s23 = new Register(31, 23, "s23", CPU32);
-    public static final Register s24 = new Register(32, 24, "s24", CPU32);
-    public static final Register s25 = new Register(33, 25, "s25", CPU32);
-    public static final Register s26 = new Register(34, 26, "s26", CPU32);
-    public static final Register s27 = new Register(35, 27, "s27", CPU32);
-    public static final Register s28 = new Register(36, 28, "s28", CPU32);
-    public static final Register s29 = new Register(37, 29, "s29", CPU32);
-    public static final Register s30 = new Register(38, 30, "s30", CPU32);
-    public static final Register s31 = new Register(39, 31, "s31", CPU32);
-
-    // 64 bit registers.
-    public static final Register d0 = new Register(40, 0, "d0", CPU64);
-    public static final Register d1 = new Register(41, 1, "d1", CPU64);
-    public static final Register d2 = new Register(42, 2, "d2", CPU64);
-    public static final Register d3 = new Register(43, 3, "d3", CPU64);
-    public static final Register d4 = new Register(44, 4, "d4", CPU64);
-    public static final Register d5 = new Register(45, 5, "d5", CPU64);
-    public static final Register d6 = new Register(46, 6, "d6", CPU64);
-    public static final Register d7 = new Register(47, 7, "d7", CPU64);
-    public static final Register d8 = new Register(48, 8, "d8", CPU64);
-    public static final Register d9 = new Register(49, 9, "d9", CPU64);
-    public static final Register d10 = new Register(50, 10, "d10", CPU64);
-    public static final Register d11 = new Register(51, 11, "d11", CPU64);
-    public static final Register d12 = new Register(52, 12, "d12", CPU64);
-    public static final Register d13 = new Register(53, 13, "d13", CPU64);
-    public static final Register d14 = new Register(54, 14, "d14", CPU64);
-    public static final Register d15 = new Register(55, 15, "d15", CPU64);
-
-    // 128 bit registers.
-    public static final Register q0 = new Register(56, 0, "q0", CPU128);
-    public static final Register q1 = new Register(57, 1, "q1", CPU128);
-    public static final Register q2 = new Register(58, 2, "q2", CPU128);
-    public static final Register q3 = new Register(59, 3, "q3", CPU128);
-    public static final Register q4 = new Register(60, 4, "q4", CPU128);
-    public static final Register q5 = new Register(61, 5, "q5", CPU128);
-    public static final Register q6 = new Register(62, 6, "q6", CPU128);
-    public static final Register q7 = new Register(63, 7, "q7", CPU128);
-    public static final Register q8 = new Register(64, 8, "q8", CPU128);
-    public static final Register q9 = new Register(65, 9, "q9", CPU128);
-    public static final Register q10 = new Register(66, 10, "q10", CPU128);
-    public static final Register q11 = new Register(67, 11, "q11", CPU128);
-    public static final Register q12 = new Register(68, 12, "q12", CPU128);
-    public static final Register q13 = new Register(69, 13, "q13", CPU128);
-    public static final Register q14 = new Register(70, 14, "q14", CPU128);
-    public static final Register q15 = new Register(71, 15, "q15", CPU128);
-
-    // non-allocatable registers used for deopt
-    public static final Register s32 = new Register(72, 32, "s32", CPU32);
-    public static final Register s33 = new Register(73, 33, "s33", CPU32);
-    public static final Register s34 = new Register(74, 34, "s34", CPU32);
-    public static final Register s35 = new Register(75, 35, "s35", CPU32);
-    public static final Register s36 = new Register(76, 36, "s36", CPU32);
-    public static final Register s37 = new Register(77, 37, "s37", CPU32);
-    public static final Register s38 = new Register(78, 38, "s38", CPU32);
-    public static final Register s39 = new Register(79, 39, "s39", CPU32);
-    public static final Register d16 = new Register(80, 16, "d16", CPU64);
-    public static final Register d17 = new Register(81, 17, "d17", CPU64);
-    public static final Register d18 = new Register(82, 18, "d18", CPU64);
-    public static final Register d19 = new Register(83, 19, "d19", CPU64);
-    public static final Register d20 = new Register(84, 20, "d20", CPU64);
-
-    public static final Register threadRegister = d20;
-    public static final Register actionAndReasonReg = s32;
-    public static final Register codeBufferOffsetReg = s33;
-
-    // @formatter:off
-    public static final Register[] cRegisters = {
-        c0, c1, c2, c3, c4, c5, c6, c7
-    };
-
-    public static final Register[] sRegisters = {
-        s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10,
-        s11, s12, s13, s14, s15, s16, s17, s18, s19,
-        s20, s21, s22, s23, s24, s25, s26, s27, s28,
-        s29, s30, s31
-    };
-
-    public static final Register[] dRegisters = {
-        d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15, threadRegister
-    };
-
-    public static final Register[] qRegisters = {
-        q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15
-    };
-
-    public static final Register[] allRegisters = {
-        c0, c1, c2, c3, c4, c5, c6, c7, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15,
-        s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30, s31,
-        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,
-        s32, s33, s34, s35, s36, s37, s38, s39,
-        d16, d17, d18, d19, threadRegister
-    };
-
-    // @formatter:on
-
-    public HSAIL() {
-        super("HSAIL", 8, ByteOrder.LITTLE_ENDIAN, false, allRegisters, 0, 1, CPU128_OFFSET + CPU128_NUM << CPU128_SHIFT, 8);
-    }
-
-    public static int getStackOffset(Value reg) {
-        return -(((StackSlot) reg).getRawOffset());
-    }
-
-    /**
-     * The mapping to stack slots is always relative to the beginning of the spillseg.
-     * {@link #getStackOffset(Value)} returns the positive version of the originally negative
-     * offset. Then we back up from that by {@code argSize} in bytes. This ensures that slots of
-     * different size do not overlap, even though we have converted from negative to positive
-     * offsets.
-     */
-    public static int getStackOffsetStart(Value reg, int argSize) {
-        int argSizeInBytes = argSize / 8;
-        return getStackOffset(reg) - argSizeInBytes;
-    }
-
-    public static String mapRegister(Value arg) {
-        return "$" + asRegister(arg).name;
-    }
-
-    @Override
-    public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) {
-        if (!(platformKind instanceof Kind)) {
-            return false;
-        }
-        Kind kind = (Kind) platformKind;
-        if (category.equals(CPU32)) {
-            switch (kind) {
-                case Boolean:
-                case Byte:
-                case Char:
-                case Short:
-                case Int:
-                case Float:
-                    return true;
-                case Long:
-                case Double:
-                case Object:
-                    return false;
-            }
-        } else if (category.equals(CPU64) || category.equals(CPU128)) {
-            switch (kind) {
-                case Boolean:
-                case Byte:
-                case Char:
-                case Short:
-                case Int:
-                case Float:
-                case Long:
-                case Double:
-                case Object:
-                    return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public PlatformKind getLargestStorableKind(RegisterCategory category) {
-        if (category.equals(CPU32)) {
-            return Kind.Int;
-        } else if (category.equals(CPU64) || category.equals(CPU128)) {
-            return Kind.Long;
-        } else {
-            return Kind.Illegal;
-        }
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/BootstrapTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.java.decompiler.test;
-
-public class BootstrapTest {
-
-    public static void main(String[] args) {
-
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +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.java.decompiler.test;
-
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.java.decompiler.test.example.*;
-import com.oracle.graal.printer.*;
-import com.oracle.graal.runtime.*;
-
-@Ignore
-public class DecompilerTest {
-
-    public static void doTest(String name) {
-        try {
-            DebugEnvironment.initialize(System.out);
-            MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
-            Method method = Example.class.getDeclaredMethod(name, new Class[]{int.class, int.class});
-            final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method);
-            TestUtil.compileMethod(javaMethod);
-        } catch (NoSuchMethodException e) {
-            Assert.fail();
-        } catch (SecurityException e) {
-            Assert.fail();
-        }
-    }
-
-    @Test
-    public void test01() {
-        doTest("loop7");
-    }
-
-    @Test
-    public void test02() {
-        doTest("loop6");
-    }
-
-    @Test
-    public void test03() {
-        doTest("loop5");
-    }
-
-    @Test
-    public void test04() {
-        doTest("loop4");
-    }
-
-    @Test
-    public void test05() {
-        doTest("loop3");
-    }
-
-    @Test
-    public void test06() {
-        doTest("loop2");
-    }
-
-    @Test
-    public void test07() {
-        doTest("loop");
-    }
-
-    @Test
-    public void test08() {
-        doTest("if0");
-    }
-
-    @Test
-    public void test09() {
-        doTest("if1");
-    }
-
-    @Test
-    public void test10() {
-        doTest("if2");
-    }
-
-    @Test
-    public void test11() {
-        doTest("if3");
-    }
-
-    @Test
-    public void test12() {
-        doTest("if4");
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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.java.decompiler.test;
-
-import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.compiler.GraalCompiler.*;
-
-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.java.*;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.phases.util.*;
-import com.oracle.graal.runtime.*;
-
-public class TestUtil {
-
-    public static void compileMethod(ResolvedJavaMethod method) {
-        Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
-        Providers providers = backend.getProviders();
-        SuitesProvider suitesProvider = backend.getSuites();
-        Suites suites = suitesProvider.getDefaultSuites();
-        StructuredGraph graph = new StructuredGraph(method);
-        MetaAccessProvider metaAccess = providers.getMetaAccess();
-        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);
-        compileGraph(graph, null, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites,
-                        new CompilationResult(), CompilationResultBuilderFactory.Default);
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/example/Example.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +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.java.decompiler.test.example;
-
-public class Example {
-
-    static int if0(int a, int b) {
-        if (a > b) {
-            return a - b;
-        }
-        return 0;
-
-    }
-
-    static int if1(int a, int b) {
-        if (a > b) {
-            return a - b;
-        } else {
-            return a + b;
-        }
-    }
-
-    static int if2(int a, int b) {
-        int c;
-        if (a > b) {
-            c = 1;
-        } else {
-            c = 2;
-        }
-        return c;
-    }
-
-    static int if3(int a, int b) {
-        int c = 0;
-        int s = 3;
-        if (a > b) {
-            if (a == 4) {
-                c = 2 + b;
-            } else {
-                c = 4 + b;
-            }
-            s = a + b;
-        } else {
-            c = 2;
-            s = a - b;
-        }
-        return c + s;
-    }
-
-    static int if4(int a, @SuppressWarnings("unused") int b) {
-        if (a > 10) {
-            if (a > 100) {
-                if (a > 1000) {
-                    return 1;
-                }
-                return 2;
-            }
-            return 3;
-        }
-        return 4;
-    }
-
-    static int loop(int a, int b) {
-        int i = 0;
-        int s = 0;
-
-        while (i < a) {
-            s += b;
-            i++;
-        }
-        return s;
-    }
-
-    static int loop2(int a, int b) {
-        int i = 0;
-        int s = 0;
-
-        while (i < a) {
-            if (a > b) {
-                s += a;
-            } else {
-                s += b;
-            }
-            i++;
-        }
-        return s;
-    }
-
-    static int loop3(int a, int b) {
-        int i = 0;
-        int s = 0;
-
-        while (i < a) {
-            if (a > b) {
-                s += a;
-            } else {
-                s += b;
-            }
-            i++;
-        }
-        if (s > 1000) {
-            return -1;
-        } else {
-            return s;
-        }
-    }
-
-    static int loop4(int a, int b) {
-        int s = 0;
-
-        if (a < 1000) {
-            int i = 0;
-            while (i < 123) {
-                if (a > b) {
-                    s += a;
-                } else {
-                    s += b;
-                }
-                i = i + ret1(i);
-            }
-            return -1;
-        } else {
-            return s;
-        }
-    }
-
-    static int ret1(int i) {
-        if (i % 2 == 0) {
-            return 1;
-        } else {
-            return 3;
-        }
-    }
-
-    static int loop5(int a, int b) {
-        int i = 0;
-        int sum = 0;
-        while (i < 1000) {
-            if (a < b) {
-                sum = sum + a;
-            }
-            sum = sum + i;
-            if (sum < a) {
-                sum = sum + b;
-            }
-            i++;
-        }
-        if (sum < a + b) {
-            sum = sum * 2;
-        }
-        return sum;
-    }
-
-    static int loop6(int a, int b) {
-        int s = 0;
-        for (int i = 0; i < a; i++) {
-            s += b;
-        }
-        return s;
-    }
-
-    static int loop7(int a, int b) {
-        int s = 0;
-        for (int i = 0; i < a; i++) {
-            for (int j = 0; j < b; j++) {
-                if (a > 400) {
-                    for (int k = 0; k < a + b; k++) {
-                        s += if4(a, b);
-                    }
-                } else {
-                    for (int k = 0; k < a - b; k++) {
-                        s += b;
-                    }
-                }
-            }
-            s += b;
-        }
-        return s;
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/Decompiler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +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.java.decompiler;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.cfg.*;
-import com.oracle.graal.phases.schedule.*;
-
-public class Decompiler {
-
-    private List<DecompilerBlock> blocks = new ArrayList<>();
-    private List<Block> cfgBlocks = new ArrayList<>();
-    private SchedulePhase schedule;
-    private ControlFlowGraph cfg;
-
-    private final PrintStream stream;
-    private final PrintStream infoStream;
-
-    private static final String IDENT = "  ";
-    private String curIdent = "";
-
-    public final String contexInformation;
-
-    public Decompiler(StructuredGraph graph, SchedulePhase schedulePhase, PrintStream stream, PrintStream infoPrintStream, String contextInformation) {
-        this.stream = stream;
-        this.infoStream = infoPrintStream;
-        this.contexInformation = contextInformation;
-        schedule = schedulePhase;
-        if (schedule == null) {
-            try {
-                schedule = new SchedulePhase();
-                schedule.apply(graph);
-            } catch (Throwable t) {
-                throw new GraalInternalError(t);
-            }
-        }
-        cfg = schedule.getCFG();
-    }
-
-    public void decompile() {
-
-        for (Block b : getCfg().getBlocks()) {
-            cfgBlocks.add(b);
-        }
-
-        for (int i = 0; i < getCfg().getBlocks().size() - 1; i++) {
-            if (cfg.getBlocks().get(i).getId() >= cfg.getBlocks().get(i + 1).getId()) {
-                throw new AssertionError();
-            }
-        }
-
-        blocks = new DecompilerLoopSimplify(this, infoStream).apply(cfgBlocks);
-        blocks = new DecompilerIfSimplify(this, infoStream).apply(blocks);
-
-        DecompilerPhiRemover.apply(cfg, blocks);
-
-        printDebugOutput();
-    }
-
-    private void printDebugOutput() {
-        for (int i = 0; i < blocks.size(); i++) {
-            if (i < blocks.size() - 1) {
-                blocks.get(i).printBlock(stream, blocks.get(i + 1).getBlock());
-            } else {
-                blocks.get(i).printBlock(stream, null);
-            }
-        }
-    }
-
-    public List<DecompilerBlock> getBlocks() {
-        return blocks;
-    }
-
-    public void ident() {
-        curIdent += IDENT;
-    }
-
-    public void undent() {
-        curIdent = curIdent.substring(0, curIdent.length() - IDENT.length());
-    }
-
-    public String getIdent() {
-        return curIdent;
-    }
-
-    public List<Block> getCfgBlocks() {
-        return cfgBlocks;
-    }
-
-    public SchedulePhase getSchedule() {
-        return schedule;
-    }
-
-    public ControlFlowGraph getCfg() {
-        return cfg;
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +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.java.decompiler;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.java.decompiler.lines.*;
-import com.oracle.graal.nodes.cfg.*;
-
-public class DecompilerIfSimplify {
-
-    private final Decompiler decompiler;
-    private final PrintStream infoStream;
-
-    public DecompilerIfSimplify(Decompiler decompiler, PrintStream infoStream) {
-        this.decompiler = decompiler;
-        this.infoStream = infoStream;
-    }
-
-    public List<DecompilerBlock> apply(List<DecompilerBlock> decompilerBlocks) {
-        return detectIfs(decompilerBlocks);
-    }
-
-    private List<DecompilerBlock> detectIfs(List<DecompilerBlock> decompilerBlocks) {
-        List<DecompilerBlock> blocks = new ArrayList<>();
-        while (!decompilerBlocks.isEmpty()) {
-            if (decompilerBlocks.get(0) instanceof DecompilerBasicBlock) {
-                DecompilerBasicBlock block = (DecompilerBasicBlock) decompilerBlocks.remove(0);
-                if (block.getSuccessorCount() <= 1) {
-                    blocks.add(block);
-                } else if (block.getSuccessorCount() == 2 && block.getCode().get(block.getCode().size() - 1) instanceof DecompilerIfLine) {
-                    Block firstThenBlock = block.getBlock().getSuccessors().get(0);
-                    Block firstElseBlock = block.getBlock().getSuccessors().get(1);
-                    List<DecompilerBlock> thenBlocks = getReachableDecompilerBlocks(firstThenBlock, decompilerBlocks);
-                    List<DecompilerBlock> elseBlocks = getReachableDecompilerBlocks(firstElseBlock, decompilerBlocks);
-                    removeIntersection(thenBlocks, elseBlocks);
-                    if (thenBlocks.size() == 0 && elseBlocks.size() == 0) {
-                        blocks.add(block);
-                    } else {
-                        for (DecompilerBlock b : thenBlocks) {
-                            decompilerBlocks.remove(b);
-                        }
-                        for (DecompilerBlock b : elseBlocks) {
-                            decompilerBlocks.remove(b);
-                        }
-                        // TODO(mg)
-                        // thenBlocks and elseBlocks can be both empty --> causes an AssertionError
-                        DecompilerIfBlock ifBlock = new DecompilerIfBlock(block.getBlock(), decompiler, thenBlocks, elseBlocks, infoStream);
-                        if (thenBlocks.contains(block) || elseBlocks.contains(block)) {
-                            throw new AssertionError();
-                        }
-                        blocks.add(ifBlock);
-                        ifBlock.detectIfs();
-                    }
-                } else {
-                    blocks.add(block);
-                }
-            } else {
-                if (decompilerBlocks.get(0) instanceof DecompilerLoopBlock) {
-                    DecompilerLoopBlock loop = (DecompilerLoopBlock) decompilerBlocks.get(0);
-                    loop.detectIfs();
-                }
-                blocks.add(decompilerBlocks.remove(0));
-            }
-        }
-
-        return blocks;
-    }
-
-    private static List<DecompilerBlock> getReachableDecompilerBlocks(Block b, List<DecompilerBlock> decompilerBlocks) {
-        List<DecompilerBlock> result = new ArrayList<>();
-        for (DecompilerBlock block : decompilerBlocks) {
-            if (isReachable(b, block.getBlock(), new ArrayList<Block>())) {
-                result.add(block);
-            }
-        }
-        return result;
-    }
-
-    private static boolean isReachable(Block from, Block to, ArrayList<Block> visited) {
-        if (from == to) {
-            return true;
-        }
-        for (Block b : from.getSuccessors()) {
-            if (b != from && visited.contains(b) == false && b.getId() > from.getId()) {
-                visited.add(b);
-                if (isReachable(b, to, visited)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    private static void removeIntersection(List<DecompilerBlock> list1, List<DecompilerBlock> list2) {
-        List<DecompilerBlock> list1Copy = new ArrayList<>(list1);
-        List<DecompilerBlock> list2Copy = new ArrayList<>(list2);
-
-        list1.removeAll(list2Copy);
-        list2.removeAll(list1Copy);
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerLoopSimplify.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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.java.decompiler;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodes.cfg.*;
-
-public class DecompilerLoopSimplify {
-
-    private final Decompiler decompiler;
-    private final PrintStream infoStream;
-
-    public DecompilerLoopSimplify(Decompiler decompiler, PrintStream infoStream) {
-        this.decompiler = decompiler;
-        this.infoStream = infoStream;
-    }
-
-    public List<DecompilerBlock> apply(List<Block> cfgBlocks) {
-        List<DecompilerBlock> blocks = new ArrayList<>();
-
-        while (!cfgBlocks.isEmpty()) {
-            Block firstBlock = cfgBlocks.get(0);
-            cfgBlocks.remove(0);
-            if (firstBlock.isLoopHeader()) {
-                DecompilerLoopBlock loopBlock = new DecompilerLoopBlock(firstBlock, decompiler, decompiler.getSchedule(), infoStream);
-                Loop<Block> loop = firstBlock.getLoop();
-
-                for (int i = 0; i < cfgBlocks.size(); i++) {
-                    if (loop.getBlocks().contains(cfgBlocks.get(i)) && cfgBlocks.get(i) != firstBlock) {
-                        loopBlock.addBodyBlock(cfgBlocks.get(i));
-                    }
-                }
-
-                // Asserting:
-                for (Block b : loopBlock.getBody()) {
-                    if (!loop.getBlocks().contains(b)) {
-                        throw new AssertionError();
-                    }
-                }
-                for (Block b : loop.getBlocks()) {
-                    if (b != firstBlock && !loopBlock.getBody().contains(b)) {
-                        throw new AssertionError();
-                    }
-                }
-
-                for (Block b : loopBlock.getBody()) {
-                    cfgBlocks.remove(b);
-                }
-
-                blocks.add(loopBlock);
-                loopBlock.detectLoops();
-            } else {
-                DecompilerBasicBlock wrappedBlock = new DecompilerBasicBlock(firstBlock, decompiler, decompiler.getSchedule());
-                blocks.add(wrappedBlock);
-            }
-        }
-        return blocks;
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerPhiRemover.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +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.java.decompiler;
-
-import java.util.*;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.java.decompiler.lines.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.cfg.*;
-
-public class DecompilerPhiRemover {
-
-    public static void apply(ControlFlowGraph cfg, List<DecompilerBlock> decompilerBlocks) {
-        List<DecompilerBasicBlock> blocks = collectAllBasicBlocks(decompilerBlocks);
-        for (DecompilerBasicBlock b : blocks) {
-            List<DecompilerSyntaxLine> removedLines = new ArrayList<>();
-            Map<DecompilerSyntaxLine, DecompilerBasicBlock> addedLines = new HashMap<>();
-            for (DecompilerSyntaxLine l : b.getCode()) {
-                if (l instanceof DecompilerPhiLine) {
-                    DecompilerPhiLine phi = (DecompilerPhiLine) l;
-                    removedLines.add(phi);
-                    PhiNode phiNode = (PhiNode) phi.getNode();
-                    for (int i = 0; i < phiNode.merge().phiPredecessorCount(); i++) {
-                        Node n = phiNode.merge().phiPredecessorAt(i);
-                        DecompilerBasicBlock targetBlock = getBlock(n, cfg, blocks);
-                        DecompilerPhiResolveLine assignment = new DecompilerPhiResolveLine(targetBlock, phiNode, n);
-                        addedLines.put(assignment, targetBlock);
-                    }
-                }
-            }
-            for (DecompilerSyntaxLine l : addedLines.keySet()) {
-                addAssignment(addedLines.get(l), l);
-            }
-            b.getCode().removeAll(removedLines);
-        }
-    }
-
-    private static List<DecompilerBasicBlock> collectAllBasicBlocks(List<DecompilerBlock> blocks) {
-        List<DecompilerBasicBlock> allBasicBlocks = new ArrayList<>();
-        for (DecompilerBlock b : blocks) {
-            allBasicBlocks.addAll(b.getAllBasicBlocks());
-        }
-        return allBasicBlocks;
-    }
-
-    private static DecompilerBasicBlock getBlock(Node n, ControlFlowGraph cfg, List<DecompilerBasicBlock> blocks) {
-        Block b = cfg.blockFor(n);
-        for (DecompilerBasicBlock basicBlock : blocks) {
-            if (basicBlock.getBlock() == b) {
-                return basicBlock;
-            }
-        }
-        throw new IllegalStateException("Block not found");
-    }
-
-    private static void addAssignment(DecompilerBasicBlock block, DecompilerSyntaxLine line) {
-        if (block.getCode().isEmpty()) {
-            block.getCode().add(line);
-            return;
-        }
-        DecompilerSyntaxLine lastLine = block.getCode().get(block.getCode().size() - 1);
-        if (lastLine instanceof DecompilerIfLine || lastLine instanceof DecompilerControlSplitLine) {
-            block.getCode().remove(lastLine);
-            block.getCode().add(line);
-            block.getCode().add(lastLine);
-        } else {
-            block.getCode().add(line);
-        }
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerBasicBlock.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +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.java.decompiler.block;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.java.decompiler.*;
-import com.oracle.graal.java.decompiler.lines.*;
-import com.oracle.graal.nodes.cfg.*;
-import com.oracle.graal.phases.schedule.*;
-
-public class DecompilerBasicBlock extends DecompilerBlock {
-
-    public DecompilerBasicBlock(Block block, Decompiler decompiler, SchedulePhase schedule) {
-        super(block, decompiler);
-        initCode(schedule);
-    }
-
-    @Override
-    public void printBlock(PrintStream stream, Block codeSuccessor) {
-        stream.println(decompiler.getIdent() + block);
-        for (DecompilerSyntaxLine l : code) {
-            if (l != null) {
-                String line = l.getAsString();
-                stream.println(decompiler.getIdent() + line);
-            }
-        }
-        if (!(block.getSuccessorCount() == 0 || (block.getSuccessorCount() == 1 && block.getFirstSuccessor() == codeSuccessor))) {
-            stream.println(decompiler.getIdent() + "GOTO " + Arrays.toString(block.getSuccessors().toArray()));
-        }
-    }
-
-    @Override
-    public String toString() {
-        return block.toString();
-    }
-
-    @Override
-    public int getSuccessorCount() {
-        return block.getSuccessorCount();
-    }
-
-    public List<Block> getSuccessors() {
-        return block.getSuccessors();
-    }
-
-    @Override
-    public boolean contains(Block b) {
-        return b == block;
-    }
-
-    public List<DecompilerSyntaxLine> getCode() {
-        return code;
-    }
-
-    @Override
-    public List<DecompilerBasicBlock> getAllBasicBlocks() {
-        return Arrays.asList(new DecompilerBasicBlock[]{this});
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerBlock.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +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.java.decompiler.block;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.java.decompiler.*;
-import com.oracle.graal.java.decompiler.lines.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.cfg.*;
-import com.oracle.graal.phases.schedule.*;
-
-public abstract class DecompilerBlock {
-
-    protected final Block block;
-    protected final Decompiler decompiler;
-    protected final List<DecompilerSyntaxLine> code;
-
-    public DecompilerBlock(Block block, Decompiler decompiler) {
-        this.block = block;
-        this.decompiler = decompiler;
-        this.code = new ArrayList<>();
-    }
-
-    public Block getBlock() {
-        return block;
-    }
-
-    public abstract void printBlock(PrintStream stream, Block codeSuccessor);
-
-    public final int getPredecessorCount() {
-        return block.getPredecessorCount();
-    }
-
-    public abstract int getSuccessorCount();
-
-    public abstract boolean contains(Block b);
-
-    public abstract List<DecompilerBasicBlock> getAllBasicBlocks();
-
-    @Override
-    public abstract String toString();
-
-    protected void initCode(SchedulePhase schedule) {
-        List<ScheduledNode> instructions = schedule.nodesFor(block);
-        for (ScheduledNode n : instructions) {
-            if (n instanceof MergeNode) {
-                MergeNode merge = (MergeNode) n;
-                for (PhiNode phi : merge.phis()) {
-                    addLine(new DecompilerPhiLine(this, phi));
-                }
-            } else if (n instanceof StartNode || n instanceof BeginNode || n instanceof EndNode || n instanceof LoopEndNode || n instanceof LoopExitNode) {
-                // do nothing
-            } else if (n instanceof ConstantNode) {
-                // do nothing
-            } else if (n instanceof IfNode) {
-                assert n.inputs().count() == 1;
-                addLine(new DecompilerIfLine(this, n, ((IfNode) n).condition()));
-            } else if (n instanceof ReturnNode) {
-                addLine(new DecompilerReturnLine(this, n.inputs().first()));
-            } else if (n instanceof ControlSplitNode) {
-                addLine(new DecompilerControlSplitLine(this, n));
-            } else if (n instanceof ProxyNode) {
-                ProxyNode proxy = (ProxyNode) n;
-                addLine(new DecompilerProxyLine(this, proxy, proxy.value()));
-            } else if (n instanceof ValueNode) {
-                addLine(new DecompilerAssignmentLine(this, n));
-            } else {
-                throw new IllegalStateException(n.toString(Verbosity.All) + " " + n.getClass());
-            }
-        }
-        simplifyCode();
-    }
-
-    private void simplifyCode() {
-        for (int i = 0; i < code.size(); i++) {
-            if (code.get(i) instanceof DecompilerAssignmentLine) {
-                if (i + 1 < code.size()) {
-                    if (code.get(i + 1) instanceof DecompilerIfLine) {
-                        if (code.get(i).getNode().usages().count() == 1) {
-                            if (((DecompilerIfLine) code.get(i + 1)).getCondition() == code.get(i).getNode()) {
-                                ((DecompilerIfLine) code.get(i + 1)).setMergedCondition((DecompilerAssignmentLine) code.get(i));
-                                code.set(i, null);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    protected void addLine(DecompilerSyntaxLine line) {
-        code.add(line);
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +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.java.decompiler.block;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.java.decompiler.*;
-import com.oracle.graal.java.decompiler.lines.*;
-import com.oracle.graal.nodes.cfg.*;
-
-public class DecompilerIfBlock extends DecompilerBlock {
-
-    private List<DecompilerBlock> thenBranch;
-    private List<DecompilerBlock> elseBranch;
-    private final DecompilerBasicBlock head;
-    private final PrintStream infoStream;
-
-    public DecompilerIfBlock(Block block, Decompiler decompiler, List<DecompilerBlock> thenBranch, List<DecompilerBlock> elseBranch, PrintStream infoStream) {
-        super(block, decompiler);
-        this.thenBranch = thenBranch;
-        this.elseBranch = elseBranch;
-        this.infoStream = infoStream;
-        this.head = new DecompilerBasicBlock(block, decompiler, decompiler.getSchedule());
-
-        if (!(thenBranch.isEmpty() == false && head.getBlock().getSuccessors().contains(thenBranch.get(0).getBlock()) || (elseBranch.isEmpty() == false && head.getBlock().getSuccessors().contains(
-                        elseBranch.get(0).getBlock())))) {
-            // first block of then / else MUST be a successor of the head!
-            throw new AssertionError(decompiler.contexInformation);
-        }
-    }
-
-    @Override
-    public void printBlock(PrintStream stream, Block codeSuccessor) {
-        List<DecompilerSyntaxLine> lines = head.getCode();
-        for (int i = 0; i < lines.size() - 1; i++) {
-            if (lines.get(i) != null) {
-                String line = lines.get(i).getAsString();
-                stream.println(decompiler.getIdent() + line);
-            }
-        }
-        DecompilerIfLine ifLine = (DecompilerIfLine) lines.get(lines.size() - 1);
-        if (!thenBranch.isEmpty() && block.getSuccessors().contains(thenBranch.get(0).getBlock())) {
-            if (elseBranch.isEmpty()) {
-                // while break:
-                stream.println(decompiler.getIdent() + ifLine.getIfNegStatement());
-                decompiler.ident();
-                stream.println(decompiler.getIdent() + "BREAK TO " + block.getSuccessors().get(1));
-                decompiler.undent();
-                for (int i = 0; i < thenBranch.size(); i++) {
-                    if (i < thenBranch.size() - 1) {
-                        thenBranch.get(i).printBlock(stream, thenBranch.get(i + 1).getBlock());
-                    } else {
-                        thenBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-            } else {
-                stream.println(decompiler.getIdent() + ifLine.getIfStatement() + " {");
-                decompiler.ident();
-                for (int i = 0; i < thenBranch.size(); i++) {
-                    if (i < thenBranch.size() - 1) {
-                        thenBranch.get(i).printBlock(stream, thenBranch.get(i + 1).getBlock());
-                    } else {
-                        thenBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-                decompiler.undent();
-                stream.println(decompiler.getIdent() + "} ELSE {");
-                decompiler.ident();
-                for (int i = 0; i < elseBranch.size(); i++) {
-                    if (i < elseBranch.size() - 1) {
-                        elseBranch.get(i).printBlock(stream, elseBranch.get(i + 1).getBlock());
-                    } else {
-                        elseBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-                decompiler.undent();
-                stream.println(decompiler.getIdent() + "}");
-            }
-        } else if (!elseBranch.isEmpty() && block.getSuccessors().contains(elseBranch.get(0).getBlock())) {
-            if (thenBranch.isEmpty()) {
-                // while break:
-                stream.println(decompiler.getIdent() + ifLine.getIfStatement());
-                decompiler.ident();
-                stream.println(decompiler.getIdent() + "BREAK TO " + block.getSuccessors().get(0));
-                decompiler.undent();
-                for (int i = 0; i < elseBranch.size(); i++) {
-                    if (i < elseBranch.size() - 1) {
-                        elseBranch.get(i).printBlock(stream, elseBranch.get(i + 1).getBlock());
-                    } else {
-                        elseBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-            } else {
-                stream.println(decompiler.getIdent() + ifLine.getIfNegStatement() + " {");
-                decompiler.ident();
-                for (int i = 0; i < elseBranch.size(); i++) {
-                    if (i < elseBranch.size() - 1) {
-                        elseBranch.get(i).printBlock(stream, elseBranch.get(i + 1).getBlock());
-                    } else {
-                        elseBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-                decompiler.undent();
-                stream.println(decompiler.getIdent() + "} ELSE {");
-                decompiler.ident();
-
-                for (int i = 0; i < thenBranch.size(); i++) {
-                    if (i < thenBranch.size() - 1) {
-                        thenBranch.get(i).printBlock(stream, thenBranch.get(i + 1).getBlock());
-                    } else {
-                        thenBranch.get(i).printBlock(stream, codeSuccessor);
-                    }
-                }
-
-                decompiler.undent();
-                stream.println(decompiler.getIdent() + "}");
-            }
-        } else {
-            throw new AssertionError();
-        }
-    }
-
-    public void detectIfs() {
-        thenBranch = new DecompilerIfSimplify(decompiler, infoStream).apply(thenBranch);
-        elseBranch = new DecompilerIfSimplify(decompiler, infoStream).apply(elseBranch);
-    }
-
-    @Override
-    public int getSuccessorCount() {
-        return 1;
-    }
-
-    @Override
-    public String toString() {
-        return "IF" + block.toString();
-    }
-
-    @Override
-    public boolean contains(Block b) {
-        if (b == block) {
-            return true;
-        }
-        for (DecompilerBlock i : thenBranch) {
-            if (i.block == b) {
-                return true;
-            }
-        }
-        for (DecompilerBlock i : elseBranch) {
-            if (i.block == b) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public List<DecompilerBasicBlock> getAllBasicBlocks() {
-        List<DecompilerBasicBlock> blocks = new ArrayList<>();
-        blocks.add(head);
-        for (DecompilerBlock b : thenBranch) {
-            blocks.addAll(b.getAllBasicBlocks());
-        }
-        for (DecompilerBlock b : elseBranch) {
-            blocks.addAll(b.getAllBasicBlocks());
-        }
-        return blocks;
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerLoopBlock.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +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.java.decompiler.block;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.graal.java.decompiler.*;
-import com.oracle.graal.nodes.cfg.*;
-import com.oracle.graal.phases.schedule.*;
-
-public class DecompilerLoopBlock extends DecompilerBlock {
-
-    private final List<Block> body;
-    private List<DecompilerBlock> decompilerBlockBody;
-    private final PrintStream infoStream;
-
-    public DecompilerLoopBlock(Block block, Decompiler decompiler, SchedulePhase schedule, PrintStream infoStream) {
-        super(block, decompiler);
-        this.infoStream = infoStream;
-        this.body = new ArrayList<>();
-        decompilerBlockBody = new ArrayList<>();
-        decompilerBlockBody.add(new DecompilerBasicBlock(block, decompiler, schedule));
-    }
-
-    public void addBodyBlock(Block bodyBlock) {
-        body.add(bodyBlock);
-    }
-
-    public List<Block> getBody() {
-        return body;
-    }
-
-    public void detectLoops() {
-        decompilerBlockBody.addAll(new DecompilerLoopSimplify(decompiler, infoStream).apply(body));
-    }
-
-    public void detectIfs() {
-        decompilerBlockBody = new DecompilerIfSimplify(decompiler, infoStream).apply(decompilerBlockBody);
-    }
-
-    @Override
-    public void printBlock(PrintStream stream, Block codeSuccessor) {
-        stream.println(decompiler.getIdent() + block);
-        stream.println(decompiler.getIdent() + "while {");
-        decompiler.ident();
-        for (int i = 0; i < decompilerBlockBody.size(); i++) {
-            if (i < decompilerBlockBody.size() - 1) {
-                decompilerBlockBody.get(i).printBlock(stream, decompilerBlockBody.get(i + 1).getBlock());
-            } else {
-                decompilerBlockBody.get(i).printBlock(stream, block);
-            }
-        }
-        decompiler.undent();
-        stream.println(decompiler.getIdent() + "}");
-    }
-
-    @Override
-    public String toString() {
-        return "LOOP " + block.toString();
-    }
-
-    @Override
-    public int getSuccessorCount() {
-        return block.getLoop().getExits().size();
-    }
-
-    @Override
-    public boolean contains(Block b) {
-        if (b == block) {
-            return true;
-        }
-        for (Block bodyBlock : body) {
-            if (bodyBlock == b) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public List<DecompilerBasicBlock> getAllBasicBlocks() {
-        List<DecompilerBasicBlock> blocks = new ArrayList<>();
-        for (DecompilerBlock b : decompilerBlockBody) {
-            blocks.addAll(b.getAllBasicBlocks());
-        }
-        return blocks;
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerAssignmentLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-
-public class DecompilerAssignmentLine extends DecompilerSyntaxLine {
-
-    private final NodeClassIterable inputs;
-
-    public DecompilerAssignmentLine(DecompilerBlock block, Node node) {
-        super(block, node);
-        this.inputs = node.inputs();
-    }
-
-    @Override
-    public String getAsString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getStringRepresentation(node));
-        sb.append(" = ");
-        sb.append(getStatement());
-        return sb.toString();
-    }
-
-    public String getStatement() {
-        StringBuilder sb = new StringBuilder();
-        if (node instanceof CallTargetNode) {
-            CallTargetNode callTarget = (CallTargetNode) node;
-            sb.append(callTarget.targetName());
-        } else {
-            sb.append(node.toString(Verbosity.Name));
-            sb.append(" ");
-            for (Node n : inputs) {
-                sb.append(getStringRepresentation(n));
-                sb.append(", ");
-            }
-        }
-        return sb.toString();
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerControlSplitLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.cfg.*;
-
-public class DecompilerControlSplitLine extends DecompilerSyntaxLine {
-
-    public DecompilerControlSplitLine(DecompilerBlock block, Node node) {
-        super(block, node);
-    }
-
-    @Override
-    public String getAsString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(node.toString(Verbosity.Name));
-        sb.append(": ");
-        for (Block b : block.getBlock().getSuccessors()) {
-            sb.append(b);
-            sb.append(" ");
-        }
-        return null;
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerIfLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-
-public class DecompilerIfLine extends DecompilerSyntaxLine {
-
-    private final Node condition;
-    private DecompilerAssignmentLine mergedCondition;
-
-    public DecompilerIfLine(DecompilerBlock block, Node node, Node condition) {
-        super(block, node);
-        this.condition = condition;
-    }
-
-    public void setMergedCondition(DecompilerAssignmentLine mergedCondition) {
-        this.mergedCondition = mergedCondition;
-    }
-
-    @Override
-    public String getAsString() {
-        if (mergedCondition == null) {
-            return "IF (" + getStringRepresentation(condition) + ") " + block.getBlock().getSuccessors().get(0) + ":" + block.getBlock().getSuccessors().get(1);
-        } else {
-            return "IF (" + mergedCondition.getStatement() + ") " + block.getBlock().getSuccessors().get(0) + ":" + block.getBlock().getSuccessors().get(1);
-        }
-    }
-
-    public String getIfStatement() {
-        if (mergedCondition == null) {
-            return "IF (" + getStringRepresentation(condition) + ")";
-        } else {
-            return "IF (" + mergedCondition.getStatement() + ")";
-        }
-
-    }
-
-    public String getIfNegStatement() {
-        if (mergedCondition == null) {
-            return "IF (!(" + getStringRepresentation(condition) + "))";
-        } else {
-            return "IF (!(" + mergedCondition.getStatement() + "))";
-        }
-    }
-
-    public Node getCondition() {
-        return condition;
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerPhiLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodes.*;
-
-public class DecompilerPhiLine extends DecompilerSyntaxLine {
-
-    public DecompilerPhiLine(DecompilerBlock block, Node node) {
-        super(block, node);
-    }
-
-    @Override
-    public String getAsString() {
-        PhiNode phi = (PhiNode) node;
-        StringBuilder sb = new StringBuilder();
-        sb.append(getStringRepresentation(phi));
-        sb.append(" = Phi {");
-        for (Node n : phi.values()) {
-            sb.append(getStringRepresentation(n));
-            sb.append(",");
-        }
-        sb.append("}");
-
-        return sb.toString();
-    }
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerPhiResolveLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-
-public class DecompilerPhiResolveLine extends DecompilerSyntaxLine {
-
-    private final Node value;
-
-    public DecompilerPhiResolveLine(DecompilerBlock block, Node node, Node value) {
-        super(block, node);
-        this.value = value;
-    }
-
-    @Override
-    public String getAsString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getStringRepresentation(node));
-        sb.append(" = ");
-        sb.append(getStringRepresentation(value));
-        return sb.toString();
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerProxyLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-
-public class DecompilerProxyLine extends DecompilerSyntaxLine {
-
-    private final Node proxy;
-
-    public DecompilerProxyLine(DecompilerBlock block, Node node, Node proxy) {
-        super(block, node);
-        this.proxy = proxy;
-    }
-
-    @Override
-    public String getAsString() {
-        return getVariable(node) + " = " + getStringRepresentation(proxy);
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerReturnLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-
-public class DecompilerReturnLine extends DecompilerSyntaxLine {
-
-    public DecompilerReturnLine(DecompilerBlock block, Node node) {
-        super(block, node);
-    }
-
-    @Override
-    public String getAsString() {
-        return "return " + getStringRepresentation(node);
-    }
-
-}
--- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/lines/DecompilerSyntaxLine.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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.java.decompiler.lines;
-
-import com.oracle.graal.graph.*;
-import com.oracle.graal.java.decompiler.block.*;
-import com.oracle.graal.nodes.*;
-
-public abstract class DecompilerSyntaxLine {
-
-    protected final Node node;
-    protected final DecompilerBlock block;
-
-    protected DecompilerSyntaxLine(DecompilerBlock block, Node node) {
-        this.node = node;
-        this.block = block;
-    }
-
-    public Node getNode() {
-        return node;
-    }
-
-    public abstract String getAsString();
-
-    public DecompilerBlock getBlock() {
-        return block;
-    }
-
-    protected static String getStringRepresentation(Node node) {
-        if (node instanceof ConstantNode) {
-            return ((ConstantNode) node).asConstant().toValueString();
-        } else if (node instanceof ParameterNode) {
-            return "param_" + ((ParameterNode) node).index();
-        } else {
-            return getVariable(node);
-        }
-    }
-
-    @SuppressWarnings("deprecation")
-    protected static String getVariable(Node node) {
-        if (node != null) {
-            return "var_" + node.getId();
-        } else {
-            return "null";
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,6 @@
 import com.oracle.graal.compiler.common.calc.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.java.BciBlockMapping.BciBlock;
-import com.oracle.graal.nodes.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 
@@ -62,48 +61,36 @@
     public static final int TRACELEVEL_STATE = 2;
 
     protected F frameState;
-    protected BytecodeStream stream;
-    protected GraphBuilderConfiguration graphBuilderConfig;
-    protected ResolvedJavaMethod method;
     protected BciBlock currentBlock;
-    protected ProfilingInfo profilingInfo;
-    protected OptimisticOptimizations optimisticOpts;
-    protected ConstantPool constantPool;
-    private final MetaAccessProvider metaAccess;
-    protected int entryBCI;
+
+    protected final BytecodeStream stream;
+    protected final GraphBuilderConfiguration graphBuilderConfig;
+    protected final ResolvedJavaMethod method;
+    protected final ProfilingInfo profilingInfo;
+    protected final OptimisticOptimizations optimisticOpts;
+    protected final ConstantPool constantPool;
+    protected final MetaAccessProvider metaAccess;
 
     /**
      * Meters the number of actual bytecodes parsed.
      */
     public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed");
 
-    public AbstractBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, F frameState,
-                    BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI) {
-        this.frameState = frameState;
+    public AbstractBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) {
         this.graphBuilderConfig = graphBuilderConfig;
         this.optimisticOpts = optimisticOpts;
         this.metaAccess = metaAccess;
-        this.stream = stream;
-        this.profilingInfo = profilingInfo;
-        this.constantPool = constantPool;
-        this.entryBCI = entryBCI;
+        this.stream = new BytecodeStream(method.getCode());
+        this.profilingInfo = method.getProfilingInfo();
+        this.constantPool = method.getConstantPool();
         this.method = method;
         assert metaAccess != null;
     }
 
-    /**
-     * Start the bytecode parser.
-     */
-    protected abstract void build();
-
     public void setCurrentFrameState(F frameState) {
         this.frameState = frameState;
     }
 
-    public final void setStream(BytecodeStream stream) {
-        this.stream = stream;
-    }
-
     protected final BytecodeStream getStream() {
         return stream;
     }
@@ -892,7 +879,7 @@
     protected abstract T append(T v);
 
     protected boolean isNeverExecutedCode(double probability) {
-        return probability == 0 && optimisticOpts.removeNeverExecutedCode() && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI;
+        return probability == 0 && optimisticOpts.removeNeverExecutedCode();
     }
 
     protected double branchProbability() {
@@ -903,7 +890,7 @@
             probability = 0.5;
         }
 
-        if (!removeNeverExecutedCode()) {
+        if (!optimisticOpts.removeNeverExecutedCode()) {
             if (probability == 0) {
                 probability = 0.0000001;
             } else if (probability == 1) {
@@ -913,12 +900,6 @@
         return probability;
     }
 
-    protected boolean removeNeverExecutedCode() {
-        return optimisticOpts.removeNeverExecutedCode() && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI;
-    }
-
-    protected abstract void processBlock(BciBlock block);
-
     protected abstract void iterateBytecodesForBlock(BciBlock block);
 
     public final void processBytecode(int bci, int opcode) {
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -171,8 +171,9 @@
      */
     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());
+        assert x != null : i;
+        assert x.getKind().getSlotCount() == 1 || locals[i + 1] == null;
+        assert i == 0 || locals[i - 1] == null || locals[i - 1].getKind().getSlotCount() == 1;
         return x;
     }
 
@@ -186,13 +187,13 @@
     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 (x != null && x.getKind().needsTwoSlots()) {
             // 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 (p != null && p.getKind().needsTwoSlots()) {
                 // if there was a double word at i - 1, then kill it
                 locals[i - 1] = null;
             }
@@ -213,7 +214,7 @@
     public void push(Kind kind, T x) {
         assert x.getKind() != Kind.Void && x.getKind() != Kind.Illegal;
         xpush(assertKind(kind, x));
-        if (isTwoSlot(kind)) {
+        if (kind.needsTwoSlots()) {
             xpush(null);
         }
     }
@@ -289,7 +290,7 @@
      */
     public T pop(Kind kind) {
         assert kind != Kind.Void;
-        if (isTwoSlot(kind)) {
+        if (kind.needsTwoSlots()) {
             xpop();
         }
         return assertKind(kind, xpop());
@@ -366,9 +367,9 @@
             if (stack[newStackSize] == null) {
                 /* Two-slot value. */
                 newStackSize--;
-                assert stackSlots(stack[newStackSize].getKind()) == 2;
+                assert stack[newStackSize].getKind().needsTwoSlots();
             } else {
-                assert stackSlots(stack[newStackSize].getKind()) == 1;
+                assert stack[newStackSize].getKind().getSlotCount() == 1;
             }
             result[i] = stack[newStackSize];
         }
@@ -389,17 +390,13 @@
         for (int i = 0; i < argumentNumber; i++) {
             if (stackAt(idx) == null) {
                 idx--;
-                assert isTwoSlot(stackAt(idx).getKind());
+                assert stackAt(idx).getKind().needsTwoSlots();
             }
             idx--;
         }
         return stackAt(idx);
     }
 
-    public static int stackSlots(Kind kind) {
-        return isTwoSlot(kind) ? 2 : 1;
-    }
-
     /**
      * Clears all values on this stack.
      */
@@ -407,11 +404,6 @@
         stackSize = 0;
     }
 
-    protected static boolean isTwoSlot(Kind kind) {
-        assert kind != Kind.Void && kind != Kind.Illegal;
-        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;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/ComputeLoopFrequenciesClosure.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/ComputeLoopFrequenciesClosure.java	Wed Jan 28 19:32:47 2015 +0100
@@ -45,13 +45,13 @@
     }
 
     @Override
-    protected Double merge(MergeNode merge, List<Double> states) {
+    protected Double merge(AbstractMergeNode merge, List<Double> states) {
         // a merge has the sum of all predecessor probabilities
         return states.stream().collect(Collectors.summingDouble(d -> d));
     }
 
     @Override
-    protected Double afterSplit(BeginNode node, Double oldState) {
+    protected Double afterSplit(AbstractBeginNode node, Double oldState) {
         // a control split splits up the probability
         ControlSplitNode split = (ControlSplitNode) node.predecessor();
         return oldState * split.probability(node);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderConfiguration.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,6 +36,7 @@
     private final ResolvedJavaType[] skippedExceptionTypes;
     private final DebugInfoMode debugInfoMode;
     private final boolean doLivenessAnalysis;
+    private boolean inlineTrivial;
 
     public static enum DebugInfoMode {
         SafePointsOnly,
@@ -130,4 +131,12 @@
     public boolean unresolvedIsError() {
         return eagerResolving;
     }
+
+    public boolean shouldInlineTrivial() {
+        return inlineTrivial;
+    }
+
+    public void setInlineTrivial(boolean inlineTrivial) {
+        this.inlineTrivial = inlineTrivial;
+    }
 }
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -74,32 +74,16 @@
 
     public static class Instance extends Phase {
 
-        private LineNumberTable lnt;
-        private int previousLineNumber;
-        private int currentLineNumber;
-
         protected StructuredGraph currentGraph;
 
         private final MetaAccessProvider metaAccess;
 
-        private BytecodeParser parser;
-
-        private ValueNode methodSynchronizedObject;
-        private ExceptionDispatchBlock unwindBlock;
-
-        private FixedWithNextNode lastInstr;                 // the last instruction added
+        private ResolvedJavaMethod rootMethod;
 
         private final GraphBuilderConfiguration graphBuilderConfig;
         private final OptimisticOptimizations optimisticOpts;
 
         /**
-         * Gets the current frame state being processed by this builder.
-         */
-        protected HIRFrameStateBuilder getCurrentFrameState() {
-            return parser.getFrameState();
-        }
-
-        /**
          * Gets the graph being processed by this builder.
          */
         protected StructuredGraph getGraph() {
@@ -116,39 +100,36 @@
         @Override
         protected void run(StructuredGraph graph) {
             ResolvedJavaMethod method = graph.method();
-            if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
-                lnt = method.getLineNumberTable();
-                previousLineNumber = -1;
-            }
+            this.rootMethod = method;
             int entryBCI = graph.getEntryBCI();
-            ProfilingInfo profilingInfo = method.getProfilingInfo();
             assert method.getCode() != null : "method must contain bytecodes: " + method;
-            unwindBlock = null;
-            methodSynchronizedObject = null;
             this.currentGraph = graph;
-            HIRFrameStateBuilder frameState = new HIRFrameStateBuilder(method, graph, graphBuilderConfig.eagerResolving());
-            this.parser = createBytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, new BytecodeStream(method.getCode()), profilingInfo, method.getConstantPool(),
-                            entryBCI);
+            HIRFrameStateBuilder frameState = new HIRFrameStateBuilder(method, graph, null);
+            frameState.initializeForMethodStart(graphBuilderConfig.eagerResolving());
             TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method);
             try {
-                parser.build();
+                BytecodeParser parser = new BytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, entryBCI);
+                parser.build(0, graph.start(), frameState);
+
+                parser.connectLoopEndToBegin();
+
+                // remove dead parameters
+                for (ParameterNode param : currentGraph.getNodes(ParameterNode.class)) {
+                    if (param.hasNoUsages()) {
+                        assert param.inputs().isEmpty();
+                        param.safeDelete();
+                    }
+                }
             } finally {
                 filter.remove();
             }
-            parser = null;
 
             ComputeLoopFrequenciesClosure.compute(graph);
         }
 
-        @SuppressWarnings("hiding")
-        protected BytecodeParser createBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
-                        HIRFrameStateBuilder frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI) {
-            return new BytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI);
-        }
-
         @Override
         protected String getDetailedName() {
-            return getName() + " " + parser.getMethod().format("%H.%n(%p):%r");
+            return getName() + " " + rootMethod.format("%H.%n(%p):%r");
         }
 
         private static class Target {
@@ -166,14 +147,52 @@
 
             private BciBlock[] loopHeaders;
             private LocalLiveness liveness;
+            protected final int entryBCI;
+            private int currentDepth;
 
-            public BytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
-                            HIRFrameStateBuilder frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI) {
-                super(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI);
+            private LineNumberTable lnt;
+            private int previousLineNumber;
+            private int currentLineNumber;
+
+            private ValueNode methodSynchronizedObject;
+            private ExceptionDispatchBlock unwindBlock;
+            private BciBlock returnBlock;
+
+            private ValueNode returnValue;
+            private FixedWithNextNode beforeReturnNode;
+            private ValueNode unwindValue;
+            private FixedWithNextNode beforeUnwindNode;
+
+            private FixedWithNextNode lastInstr;                 // the last instruction added
+
+            public BytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, int entryBCI) {
+                super(metaAccess, method, graphBuilderConfig, optimisticOpts);
+                this.entryBCI = entryBCI;
+
+                if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
+                    lnt = method.getLineNumberTable();
+                    previousLineNumber = -1;
+                }
             }
 
-            @Override
-            protected void build() {
+            public ValueNode getReturnValue() {
+                return returnValue;
+            }
+
+            public FixedWithNextNode getBeforeReturnNode() {
+                return this.beforeReturnNode;
+            }
+
+            public ValueNode getUnwindValue() {
+                return unwindValue;
+            }
+
+            public FixedWithNextNode getBeforeUnwindNode() {
+                return this.beforeUnwindNode;
+            }
+
+            protected void build(int depth, FixedWithNextNode startInstruction, HIRFrameStateBuilder startFrameState) {
+                this.currentDepth = depth;
                 if (PrintProfilingInformation.getValue()) {
                     TTY.println("Profiling info for " + method.format("%H.%n(%p)"));
                     TTY.println(MetaUtil.indent(profilingInfo.toString(method, CodeUtil.NEW_LINE), "  "));
@@ -186,64 +205,60 @@
                     loopHeaders = blockMap.getLoopHeaders();
                     liveness = blockMap.liveness;
 
-                    lastInstr = currentGraph.start();
+                    lastInstr = startInstruction;
+                    this.setCurrentFrameState(startFrameState);
+
+                    if (startInstruction == currentGraph.start()) {
+                        StartNode startNode = currentGraph.start();
+                        if (method.isSynchronized()) {
+                            startNode.setStateAfter(frameState.create(BytecodeFrame.BEFORE_BCI));
+                        } else {
+                            frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
+                            assert bci() == 0;
+                            startNode.setStateAfter(frameState.create(bci()));
+                        }
+                    }
+
                     if (method.isSynchronized()) {
                         // add a monitor enter to the start block
-                        currentGraph.start().setStateAfter(frameState.create(BytecodeFrame.BEFORE_BCI));
                         methodSynchronizedObject = synchronizedObject(frameState, method);
-                        lastInstr = genMonitorEnter(methodSynchronizedObject);
+                        MonitorEnterNode monitorEnter = genMonitorEnter(methodSynchronizedObject);
+                        frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
+                        assert bci() == 0;
+                        monitorEnter.setStateAfter(frameState.create(bci()));
                     }
-                    frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true);
-                    assert bci() == 0;
-                    ((StateSplit) lastInstr).setStateAfter(frameState.create(bci()));
-                    finishPrepare(lastInstr);
 
                     if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
-                        InfopointNode ipn = currentGraph.add(createInfoPointNode(InfopointReason.METHOD_START));
-                        lastInstr.setNext(ipn);
-                        lastInstr = ipn;
+                        append(createInfoPointNode(InfopointReason.METHOD_START));
                     }
 
                     currentBlock = blockMap.startBlock;
                     blockMap.startBlock.entryState = frameState;
                     if (blockMap.startBlock.isLoopHeader) {
-                        /*
-                         * TODO(lstadler,gduboscq) createTarget might not be safe at this position,
-                         * since it expects currentBlock, etc. to be set up correctly. A better
-                         * solution to this problem of start blocks that are loop headers would be
-                         * to create a dummy block in BciBlockMapping.
-                         */
                         appendGoto(createTarget(blockMap.startBlock, frameState));
                     } else {
                         blockMap.startBlock.firstInstruction = lastInstr;
                     }
 
                     for (BciBlock block : blockMap.getBlocks()) {
-                        processBlock(block);
+                        processBlock(this, block);
                     }
-                    processBlock(unwindBlock);
+                    processBlock(this, returnBlock);
+                    processBlock(this, unwindBlock);
 
                     Debug.dump(currentGraph, "After bytecode parsing");
 
-                    connectLoopEndToBegin();
-
-                    // remove dead parameters
-                    for (ParameterNode param : currentGraph.getNodes(ParameterNode.class)) {
-                        if (param.usages().isEmpty()) {
-                            assert param.inputs().isEmpty();
-                            param.safeDelete();
-                        }
-                    }
                 }
             }
 
-            /**
-             * A hook for derived classes to modify the graph start instruction or append new
-             * instructions to it.
-             *
-             * @param startInstr The start instruction of the graph.
-             */
-            protected void finishPrepare(FixedWithNextNode startInstr) {
+            private BciBlock returnBlock(int bci) {
+                if (returnBlock == null) {
+                    returnBlock = new BciBlock();
+                    returnBlock.startBci = bci;
+                    returnBlock.endBci = bci;
+                    returnBlock.setId(Integer.MAX_VALUE);
+                }
+                return returnBlock;
             }
 
             private BciBlock unwindBlock() {
@@ -284,7 +299,7 @@
             @Override
             protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) {
                 assert !graphBuilderConfig.eagerResolving();
-                BeginNode successor = currentGraph.add(new BeginNode());
+                AbstractBeginNode successor = currentGraph.add(new BeginNode());
                 DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(InvalidateRecompile, Unresolved));
                 append(new IfNode(currentGraph.unique(new IsNullNode(object)), successor, deopt, 1));
                 lastInstr = successor;
@@ -390,8 +405,8 @@
                     dispatchBegin.setStateAfter(dispatchState.create(bci));
                     dispatchState.setRethrowException(true);
                 }
+                FixedNode target = createTarget(dispatchBlock, dispatchState);
                 FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState);
-                FixedNode target = createTarget(dispatchBlock, dispatchState);
                 finishedDispatch.setNext(target);
                 return dispatchBegin;
             }
@@ -594,7 +609,7 @@
                     return;
                 }
                 BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, NullPointerException.class));
-                BeginNode falseSucc = currentGraph.add(new BeginNode());
+                AbstractBeginNode falseSucc = currentGraph.add(new BeginNode());
                 append(new IfNode(currentGraph.unique(new IsNullNode(receiver)), exception, falseSucc, 0.01));
                 lastInstr = falseSucc;
 
@@ -604,7 +619,7 @@
 
             @Override
             protected void emitBoundsCheck(ValueNode index, ValueNode length) {
-                BeginNode trueSucc = currentGraph.add(new BeginNode());
+                AbstractBeginNode trueSucc = currentGraph.add(new BeginNode());
                 BytecodeExceptionNode exception = currentGraph.add(new BytecodeExceptionNode(metaAccess, ArrayIndexOutOfBoundsException.class, index));
                 append(new IfNode(currentGraph.unique(new IntegerBelowNode(index, length)), trueSucc, exception, 0.99));
                 lastInstr = trueSucc;
@@ -738,6 +753,40 @@
                     }
                 }
 
+                if (GraalOptions.InlineDuringParsing.getValue() && invokeKind.isDirect() && targetMethod.canBeInlined() && targetMethod.hasBytecodes()) {
+                    if (targetMethod.getCode().length <= GraalOptions.TrivialInliningSize.getValue() && currentDepth < GraalOptions.InlineDuringParsingMaxDepth.getValue() &&
+                                    graphBuilderConfig.shouldInlineTrivial()) {
+                        BytecodeParser parser = new BytecodeParser(metaAccess, targetMethod, graphBuilderConfig, optimisticOpts, StructuredGraph.INVOCATION_ENTRY_BCI);
+                        final FrameState[] lazyFrameState = new FrameState[1];
+                        HIRFrameStateBuilder startFrameState = new HIRFrameStateBuilder(targetMethod, currentGraph, () -> {
+                            if (lazyFrameState[0] == null) {
+                                lazyFrameState[0] = frameState.create(bci());
+                            }
+                            return lazyFrameState[0];
+                        });
+                        startFrameState.initializeFromArgumentsArray(args);
+                        parser.build(currentDepth + 1, this.lastInstr, startFrameState);
+
+                        FixedWithNextNode calleeBeforeReturnNode = parser.getBeforeReturnNode();
+                        this.lastInstr = calleeBeforeReturnNode;
+                        if (calleeBeforeReturnNode != null) {
+                            ValueNode calleeReturnValue = parser.getReturnValue();
+                            if (calleeReturnValue != null) {
+                                frameState.push(calleeReturnValue.getKind().getStackKind(), calleeReturnValue);
+                            }
+                        }
+
+                        FixedWithNextNode calleeBeforeUnwindNode = parser.getBeforeUnwindNode();
+                        if (calleeBeforeUnwindNode != null) {
+                            ValueNode calleeUnwindValue = parser.getUnwindValue();
+                            assert calleeUnwindValue != null;
+                            calleeBeforeUnwindNode.setNext(handleException(calleeUnwindValue, bci()));
+                        }
+
+                        return;
+                    }
+                }
+
                 MethodCallTargetNode callTarget = currentGraph.add(createMethodCallTarget(invokeKind, targetMethod, args, returnType));
 
                 // be conservative if information was not recorded (could result in endless
@@ -746,7 +795,7 @@
                     createInvoke(callTarget, resultType);
                 } else {
                     InvokeWithExceptionNode invoke = createInvokeWithException(callTarget, resultType);
-                    BeginNode beginNode = currentGraph.add(new KillingBeginNode(LocationIdentity.ANY_LOCATION));
+                    AbstractBeginNode beginNode = currentGraph.add(new KillingBeginNode(LocationIdentity.ANY_LOCATION));
                     invoke.setNext(beginNode);
                     lastInstr = beginNode;
                 }
@@ -774,6 +823,19 @@
             protected void genReturn(ValueNode x) {
                 frameState.setRethrowException(false);
                 frameState.clearStack();
+
+                if (this.currentDepth == 0) {
+                    beforeReturn(x);
+                    append(new ReturnNode(x));
+                } else {
+                    if (x != null) {
+                        frameState.push(x.getKind(), x);
+                    }
+                    appendGoto(createTarget(returnBlock(bci()), frameState));
+                }
+            }
+
+            private void beforeReturn(ValueNode x) {
                 if (graphBuilderConfig.insertNonSafepointDebugInfo()) {
                     append(createInfoPointNode(InfopointReason.METHOD_END));
                 }
@@ -782,8 +844,6 @@
                 if (frameState.lockDepth() != 0) {
                     throw new BailoutException("unbalanced monitors");
                 }
-
-                append(new ReturnNode(x));
             }
 
             @Override
@@ -795,13 +855,13 @@
             }
 
             @Override
-            protected MonitorExitNode genMonitorExit(ValueNode x, ValueNode returnValue) {
+            protected MonitorExitNode genMonitorExit(ValueNode x, ValueNode escapedReturnValue) {
                 MonitorIdNode monitorId = frameState.peekMonitorId();
                 ValueNode lockedObject = frameState.popLock();
                 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) {
                     throw new BailoutException("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject));
                 }
-                MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, returnValue));
+                MonitorExitNode monitorExit = append(new MonitorExitNode(x, monitorId, escapedReturnValue));
                 return monitorExit;
             }
 
@@ -1017,18 +1077,18 @@
                 assert currentBlock == null || currentBlock.getId() < block.getId() : "must not be backward branch";
                 assert block.firstInstruction.next() == null : "bytecodes already parsed for block";
 
-                if (block.firstInstruction instanceof BeginNode && !(block.firstInstruction instanceof MergeNode)) {
+                if (block.firstInstruction instanceof AbstractBeginNode && !(block.firstInstruction instanceof AbstractMergeNode)) {
                     /*
                      * 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.
                      */
-                    BeginNode placeholder = (BeginNode) block.firstInstruction;
+                    AbstractBeginNode placeholder = (AbstractBeginNode) block.firstInstruction;
 
                     // The EndNode for the already existing edge.
                     AbstractEndNode end = currentGraph.add(new EndNode());
                     // The MergeNode that replaces the placeholder.
-                    MergeNode mergeNode = currentGraph.add(new MergeNode());
+                    AbstractMergeNode mergeNode = currentGraph.add(new MergeNode());
                     FixedNode next = placeholder.next();
 
                     if (placeholder.predecessor() instanceof ControlSplitNode) {
@@ -1044,7 +1104,7 @@
                     block.firstInstruction = mergeNode;
                 }
 
-                MergeNode mergeNode = (MergeNode) block.firstInstruction;
+                AbstractMergeNode mergeNode = (AbstractMergeNode) block.firstInstruction;
 
                 // The EndNode for the newly merged edge.
                 AbstractEndNode newEnd = currentGraph.add(new EndNode());
@@ -1061,9 +1121,9 @@
              * Returns a block begin node with the specified state. If the specified probability is
              * 0, the block deoptimizes immediately.
              */
-            private BeginNode createBlockTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
+            private AbstractBeginNode createBlockTarget(double probability, BciBlock block, HIRFrameStateBuilder stateAfter) {
                 FixedNode target = createTarget(probability, block, stateAfter);
-                BeginNode begin = BeginNode.begin(target);
+                AbstractBeginNode begin = BeginNode.begin(target);
 
                 assert !(target instanceof DeoptimizeNode && begin instanceof BeginStateSplitNode && ((BeginStateSplitNode) begin).stateAfter() != null) : "We are not allowed to set the stateAfter of the begin node, because we have to deoptimize "
                                 + "to a bci _before_ the actual if, so that the interpreter can update the profiling information.";
@@ -1078,8 +1138,7 @@
                 }
             }
 
-            @Override
-            protected void processBlock(BciBlock block) {
+            protected void processBlock(BytecodeParser parser, BciBlock block) {
                 // Ignore blocks that have no predecessors by the time their bytecodes are parsed
                 if (block == null || block.firstInstruction == null) {
                     Debug.log("Ignoring block %s", block);
@@ -1092,18 +1151,30 @@
                     parser.setCurrentFrameState(frameState);
                     currentBlock = block;
 
-                    frameState.cleanupDeletedPhis();
-                    if (lastInstr instanceof MergeNode) {
+                    if (lastInstr instanceof AbstractMergeNode) {
                         int bci = block.startBci;
                         if (block instanceof ExceptionDispatchBlock) {
                             bci = ((ExceptionDispatchBlock) block).deoptBci;
                         }
-                        ((MergeNode) lastInstr).setStateAfter(frameState.create(bci));
+                        ((AbstractMergeNode) lastInstr).setStateAfter(frameState.create(bci));
                     }
 
-                    if (block == unwindBlock) {
-                        frameState.setRethrowException(false);
-                        createUnwind();
+                    if (block == returnBlock) {
+                        Kind returnKind = method.getSignature().getReturnKind().getStackKind();
+                        ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
+                        assert frameState.stackSize() == 0;
+                        beforeReturn(x);
+                        this.returnValue = x;
+                        this.beforeReturnNode = this.lastInstr;
+                    } else if (block == unwindBlock) {
+                        if (currentDepth == 0) {
+                            frameState.setRethrowException(false);
+                            createUnwind();
+                        } else {
+                            ValueNode exception = frameState.apop();
+                            this.unwindValue = exception;
+                            this.beforeUnwindNode = this.lastInstr;
+                        }
                     } else if (block instanceof ExceptionDispatchBlock) {
                         createExceptionDispatch((ExceptionDispatchBlock) block);
                     } else {
@@ -1113,19 +1184,22 @@
                 }
             }
 
+            /**
+             * Remove loop header without loop ends. This can happen with degenerated loops like
+             * this one:
+             *
+             * <pre>
+             * for (;;) {
+             *     try {
+             *         break;
+             *     } catch (UnresolvedException iioe) {
+             *     }
+             * }
+             * </pre>
+             */
             private void connectLoopEndToBegin() {
                 for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.class)) {
                     if (begin.loopEnds().isEmpty()) {
-                        // @formatter:off
-                // Remove loop header without loop ends.
-                // This can happen with degenerated loops like this one:
-                // for (;;) {
-                //     try {
-                //         break;
-                //     } catch (UnresolvedException iioe) {
-                //     }
-                // }
-                // @formatter:on
                         assert begin.forwardEndCount() == 1;
                         currentGraph.reduceDegenerateLoopBegin(begin);
                     } else {
@@ -1141,11 +1215,11 @@
                 append(new UnwindNode(exception));
             }
 
-            private void synchronizedEpilogue(int bci, ValueNode returnValue) {
+            private void synchronizedEpilogue(int bci, ValueNode currentReturnValue) {
                 if (method.isSynchronized()) {
-                    MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject, returnValue);
-                    if (returnValue != null) {
-                        frameState.push(returnValue.getKind(), returnValue);
+                    MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject, currentReturnValue);
+                    if (currentReturnValue != null) {
+                        frameState.push(currentReturnValue.getKind(), currentReturnValue);
                     }
                     monitorExit.setStateAfter(frameState.create(bci));
                     assert !frameState.rethrowException();
@@ -1210,8 +1284,7 @@
             protected void iterateBytecodesForBlock(BciBlock block) {
                 if (block.isLoopHeader) {
                     // Create the loop header block, which later will merge the backward branches of
-                    // the
-                    // loop.
+                    // the loop.
                     AbstractEndNode preLoopEnd = currentGraph.add(new EndNode());
                     LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode());
                     lastInstr.setNext(preLoopEnd);
@@ -1261,7 +1334,7 @@
                     int opcode = stream.currentBC();
                     traceState();
                     traceInstruction(bci, opcode, bci == block.startBci);
-                    if (bci == entryBCI) {
+                    if (currentDepth == 0 && bci == entryBCI) {
                         if (block.getJsrScope() != JsrScope.EMPTY_SCOPE) {
                             throw new BailoutException("OSR into a JSR scope is not supported");
                         }
@@ -1282,7 +1355,7 @@
                         frameState.clearNonLiveLocals(currentBlock, liveness, false);
                     }
                     if (lastInstr instanceof StateSplit) {
-                        if (lastInstr.getClass() == BeginNode.class) {
+                        if (lastInstr instanceof BeginNode) {
                             // BeginNodes do not need a frame state
                         } else {
                             StateSplit stateSplit = (StateSplit) lastInstr;
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -25,6 +25,7 @@
 import static com.oracle.graal.graph.iterators.NodePredicates.*;
 
 import java.util.*;
+import java.util.function.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
@@ -43,14 +44,44 @@
 
     private MonitorIdNode[] monitorIds;
     private final StructuredGraph graph;
+    private final Supplier<FrameState> outerFrameStateSupplier;
 
-    public HIRFrameStateBuilder(ResolvedJavaMethod method, StructuredGraph graph, boolean eagerResolve) {
+    /**
+     * Creates a new frame state builder for the given method and the given target graph.
+     *
+     * @param method the method whose frame is simulated
+     * @param graph the target graph of Graal nodes created by the builder
+     */
+    public HIRFrameStateBuilder(ResolvedJavaMethod method, StructuredGraph graph, Supplier<FrameState> outerFrameStateSupplier) {
         super(method);
 
         assert graph != null;
 
         this.monitorIds = EMPTY_MONITOR_ARRAY;
         this.graph = graph;
+        this.outerFrameStateSupplier = outerFrameStateSupplier;
+    }
+
+    public final void initializeFromArgumentsArray(ValueNode[] arguments) {
+
+        int javaIndex = 0;
+        int index = 0;
+        if (!method.isStatic()) {
+            // set the receiver
+            storeLocal(javaIndex, arguments[index]);
+            javaIndex = 1;
+            index = 1;
+        }
+        Signature sig = method.getSignature();
+        int max = sig.getParameterCount(false);
+        for (int i = 0; i < max; i++) {
+            storeLocal(javaIndex, arguments[index]);
+            javaIndex += arguments[index].getKind().getSlotCount();
+            index++;
+        }
+    }
+
+    public final void initializeForMethodStart(boolean eagerResolve) {
 
         int javaIndex = 0;
         int index = 0;
@@ -78,7 +109,7 @@
             }
             ParameterNode param = graph.unique(new ParameterNode(index, stamp));
             storeLocal(javaIndex, param);
-            javaIndex += stackSlots(kind);
+            javaIndex += kind.getSlotCount();
             index++;
         }
     }
@@ -88,6 +119,7 @@
         assert other.graph != null;
         graph = other.graph;
         monitorIds = other.monitorIds.length == 0 ? other.monitorIds : other.monitorIds.clone();
+        this.outerFrameStateSupplier = other.outerFrameStateSupplier;
 
         assert locals.length == method.getMaxLocals();
         assert stack.length == Math.max(1, method.getMaxStackSize());
@@ -123,7 +155,11 @@
     }
 
     public FrameState create(int bci) {
-        return graph.add(new FrameState(method, bci, locals, Arrays.asList(stack).subList(0, stackSize), lockedObjects, monitorIds, rethrowException, false));
+        FrameState outerFrameState = null;
+        if (outerFrameStateSupplier != null) {
+            outerFrameState = outerFrameStateSupplier.get();
+        }
+        return graph.add(new FrameState(outerFrameState, method, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, false));
     }
 
     @Override
@@ -157,7 +193,7 @@
         return true;
     }
 
-    public void merge(MergeNode block, HIRFrameStateBuilder other) {
+    public void merge(AbstractMergeNode block, HIRFrameStateBuilder other) {
         assert isCompatibleWith(other);
 
         for (int i = 0; i < localsSize(); i++) {
@@ -172,7 +208,7 @@
         }
     }
 
-    private ValueNode merge(ValueNode currentValue, ValueNode otherValue, MergeNode block) {
+    private ValueNode merge(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
         if (currentValue == null || currentValue.isDeleted()) {
             return null;
 
@@ -258,7 +294,7 @@
         }
     }
 
-    public void insertProxies(BeginNode begin) {
+    public void insertProxies(AbstractBeginNode begin) {
         for (int i = 0; i < localsSize(); i++) {
             ValueNode value = localAt(i);
             if (value != null) {
@@ -282,7 +318,7 @@
         }
     }
 
-    private ValuePhiNode createLoopPhi(MergeNode block, ValueNode value) {
+    private ValuePhiNode createLoopPhi(AbstractMergeNode block, ValueNode value) {
         if (value == null) {
             return null;
         }
@@ -293,15 +329,6 @@
         return phi;
     }
 
-    public void cleanupDeletedPhis() {
-        for (int i = 0; i < localsSize(); i++) {
-            if (localAt(i) != null && localAt(i).isDeleted()) {
-                assert localAt(i) instanceof ValuePhiNode || localAt(i) instanceof ProxyNode : "Only phi and value proxies can be deleted during parsing: " + localAt(i);
-                storeLocal(i, null);
-            }
-        }
-    }
-
     /**
      * Adds a locked monitor to this frame state.
      *
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAccess01.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/UnsafeAccess01.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,16 +34,28 @@
  */
 public class UnsafeAccess01 extends JTTTest {
 
-    private static class TestClass {
-        @SuppressWarnings("unused") private int field = 42;
+    private static int randomValue = 100;
+    private static final Unsafe unsafe;
+    private static final long offset;
+    private static Object staticObject = new TestClass();
+
+    static {
+        unsafe = getUnsafe();
+        Field field = null;
+        try {
+            field = TestClass.class.getDeclaredField("field");
+        } catch (NoSuchFieldException e) {
+        } catch (SecurityException e) {
+        }
+        offset = unsafe.objectFieldOffset(field);
     }
 
-    public static int test() throws SecurityException, NoSuchFieldException {
-        final Unsafe unsafe = getUnsafe();
+    private static class TestClass {
+        private int field = 42;
+    }
 
+    public static int test() {
         final TestClass object = new TestClass();
-        final Field field = TestClass.class.getDeclaredField("field");
-        final long offset = unsafe.objectFieldOffset(field);
         final int value = unsafe.getInt(object, offset);
         return value;
     }
@@ -63,4 +75,22 @@
         runTest("test");
     }
 
+    @Test
+    public void runDiamond() throws Throwable {
+        runTest("testDiamond");
+    }
+
+    public static int testDiamond() {
+
+        final Object object = staticObject;
+        final int oldValue = ((TestClass) object).field;
+
+        if (randomValue == 100) {
+            unsafe.putInt(object, offset, 41);
+        } else {
+            unsafe.putInt(object, offset, 40);
+        }
+        unsafe.putInt(object, offset, 42);
+        return oldValue;
+    }
 }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILAddressValue.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * 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.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.hsail.*;
-import com.oracle.graal.lir.*;
-
-/**
- * Represents an address value used in HSAIL code.
- */
-public final class HSAILAddressValue extends CompositeValue {
-
-    private static final long serialVersionUID = 1802222435353022623L;
-    @Component({REG, LIRInstruction.OperandFlag.ILLEGAL}) private AllocatableValue base;
-    private final long displacement;
-
-    /**
-     * Creates an {@link HSAILAddressValue} with given base register and no displacement.
-     *
-     * @param kind the kind of the value being addressed
-     * @param base the base register
-     */
-    public HSAILAddressValue(LIRKind kind, AllocatableValue base) {
-        this(kind, base, 0);
-    }
-
-    /**
-     * Creates an {@link HSAILAddressValue} with given base register and a displacement. This is the
-     * most general constructor.
-     *
-     * @param kind the kind of the value being addressed
-     * @param base the base register
-     * @param displacement the displacement
-     */
-    public HSAILAddressValue(LIRKind kind, AllocatableValue base, long displacement) {
-        super(kind);
-        this.base = base;
-        this.displacement = displacement;
-        assert !isStackSlotValue(base);
-    }
-
-    public HSAILAddress toAddress() {
-        Register baseReg = base.equals(Value.ILLEGAL) ? Register.None : asRegister(base);
-        return new HSAILAddress(baseReg, displacement);
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder s = new StringBuilder();
-        s.append(getKind().getJavaName()).append("[");
-        String sep = "";
-        if (isLegal(base)) {
-            s.append(base);
-            sep = " + ";
-        }
-        if (displacement < 0) {
-            s.append(" - ").append(-displacement);
-        } else if (displacement > 0) {
-            s.append(sep).append(displacement);
-        }
-        s.append("]");
-        return s.toString();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof HSAILAddressValue) {
-            HSAILAddressValue addr = (HSAILAddressValue) obj;
-            return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base);
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return base.hashCode() ^ ((int) displacement << 4) ^ (getKind().ordinal() << 12);
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +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.lir.hsail;
-
-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.hsail.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-/**
- * Defines arithmetic instruction nodes.
- */
-public enum HSAILArithmetic {
-    ABS,
-    CALL,
-    CEIL,
-    FDIV,
-    FLOOR,
-    FREM,
-    DADD,
-    DDIV,
-    DMUL,
-    DNEG,
-    DREM,
-    DSUB,
-    FADD,
-    FMUL,
-    FNEG,
-    FSUB,
-    IADD,
-    IAND,
-    ICARRY,
-    IDIV,
-    IMAX,
-    IMIN,
-    IMUL,
-    INEG,
-    INOT,
-    IOR,
-    IREM,
-    ISHL,
-    ISHR,
-    ISUB,
-    IUADD,
-    IUCARRY,
-    IUDIV,
-    IUMAX,
-    IUMIN,
-    IUMUL,
-    IUREM,
-    IUSHR,
-    IUSUB,
-    IXOR,
-    LADD,
-    LAND,
-    LCARRY,
-    LDIV,
-    LMAX,
-    LMIN,
-    LMUL,
-    LNEG,
-    LNOT,
-    LOR,
-    LREM,
-    LSHL,
-    LSHR,
-    LSUB,
-    LUADD,
-    LUCARRY,
-    LUDIV,
-    LUMAX,
-    LUMIN,
-    LUMUL,
-    LUREM,
-    LUSHR,
-    LUSUB,
-    LXOR,
-    OADD,
-    RINT,
-    SQRT,
-    UNDEF;
-
-    public static class ConvertOp extends HSAILLIRInstruction {
-        private final String from;
-        private final String to;
-        @Def({REG}) protected AllocatableValue result;
-        @Use({REG}) protected AllocatableValue x;
-
-        public ConvertOp(AllocatableValue result, AllocatableValue x, String to, String from) {
-            this.from = from;
-            this.to = to;
-            this.result = result;
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitConvert(result, x, to, from);
-        }
-    }
-
-    public static class Op1Reg extends HSAILLIRInstruction {
-        @Opcode private final HSAILArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, CONST}) protected Value x;
-
-        public Op1Reg(HSAILArithmetic opcode, Value result, Value x) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, opcode, result, x, null);
-        }
-    }
-
-    public static class Op2Reg extends HSAILLIRInstruction {
-        @Opcode private final HSAILArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, CONST}) protected Value x;
-        @Alive({REG, CONST}) protected Value y;
-
-        public Op2Reg(HSAILArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, opcode, result, x, y, null);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    public static class ShiftOp extends HSAILLIRInstruction {
-        @Opcode private final HSAILArithmetic opcode;
-        @Def({REG}) protected Value result;
-        @Use({REG, CONST}) protected Value x;
-        @Alive({REG, CONST}) protected Value y;
-
-        public ShiftOp(HSAILArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, opcode, result, x, y, null);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, x);
-            assert y.getKind().getStackKind() == Kind.Int;
-        }
-    }
-
-    public static class DivOp extends HSAILLIRInstruction {
-        @Opcode private final HSAILArithmetic opcode;
-        @Def protected Value result;
-        @Use protected Value x;
-        @Alive protected Value y;
-        @State protected LIRFrameState state;
-
-        public DivOp(HSAILArithmetic opcode, Value result, Value x, Value y, LIRFrameState state) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, opcode, result, y, state);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    @SuppressWarnings("unused")
-    protected static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value result) {
-        switch (opcode) {
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    /**
-     * Emits the HSAIL code for an arithmetic operation taking one input parameter.
-     *
-     * @param crb the CompilationResultBuilder
-     * @param masm the HSAIL assembler
-     * @param opcode the opcode of the arithmetic operation
-     * @param dst the destination
-     * @param src the source parameter
-     * @param info structure that stores the LIRFrameState. Used for exception handling.
-     */
-
-    public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src, LIRFrameState info) {
-        int exceptionOffset = -1;
-        if (isRegister(src)) {
-            switch (opcode) {
-                case ABS:
-                    masm.emit("abs", dst, src);
-                    break;
-                case CEIL:
-                    masm.emit("ceil", dst, src);
-                    break;
-                case FLOOR:
-                    masm.emit("floor", dst, src);
-                    break;
-                case RINT:
-                    masm.emit("rint", dst, src);
-                    break;
-                case SQRT:
-                    masm.emit("sqrt", dst, src);
-                    break;
-                case UNDEF:
-                    masm.undefined("undefined node");
-                    break;
-                case CALL:
-                    masm.undefined("undefined node CALL");
-                    break;
-                case INOT:
-                case LNOT:
-                    masm.emitForceBitwise("not", dst, src);
-                    break;
-                case INEG:
-                case LNEG:
-                case FNEG:
-                case DNEG:
-                    masm.emit("neg", dst, src);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        } else {
-            throw GraalInternalError.shouldNotReachHere();
-        }
-        if (info != null) {
-            assert exceptionOffset != -1;
-            crb.recordImplicitException(exceptionOffset, info);
-        }
-    }
-
-    public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) {
-        /**
-         * First check if one of src1 or src2 is an AddressValue. If it is, convert the address to a
-         * register using an lda instruction. We can just reuse the eventual dst register for this.
-         */
-        if (src1 instanceof HSAILAddressValue) {
-            assert (!(src2 instanceof HSAILAddressValue));
-            masm.emitLda(dst, ((HSAILAddressValue) src1).toAddress());
-            emit(crb, masm, opcode, dst, dst, src2, info);
-            return;
-        } else if (src2 instanceof HSAILAddressValue) {
-            assert (!(src1 instanceof HSAILAddressValue));
-            masm.emitLda(dst, ((HSAILAddressValue) src2).toAddress());
-            emit(crb, masm, opcode, dst, src1, dst, info);
-            return;
-        }
-        int exceptionOffset = -1;
-        switch (opcode) {
-            case IADD:
-            case LADD:
-            case DADD:
-            case FADD:
-            case OADD:
-                masm.emit("add", dst, src1, src2);
-                break;
-            case ISUB:
-            case LSUB:
-            case DSUB:
-            case FSUB:
-                masm.emit("sub", dst, src1, src2);
-                break;
-            case IMUL:
-            case LMUL:
-            case FMUL:
-            case DMUL:
-            case LUMUL:
-                masm.emit("mul", dst, src1, src2);
-                break;
-            case IDIV:
-            case LDIV:
-            case FDIV:
-            case DDIV:
-                masm.emit("div", dst, src1, src2);
-                break;
-            case IMAX:
-            case LMAX:
-                masm.emit("max", dst, src1, src2);
-                break;
-            case IMIN:
-            case LMIN:
-                masm.emit("min", dst, src1, src2);
-                break;
-            case ISHL:
-            case LSHL:
-                masm.emit("shl", dst, src1, src2);
-                break;
-            case ISHR:
-            case LSHR:
-                masm.emit("shr", dst, src1, src2);
-                break;
-            case IUSHR:
-            case LUSHR:
-                masm.emitForceUnsigned("shr", dst, src1, src2);
-                break;
-            case IAND:
-            case LAND:
-                masm.emitForceBitwise("and", dst, src1, src2);
-                break;
-            case IXOR:
-            case LXOR:
-                masm.emitForceBitwise("xor", dst, src1, src2);
-                break;
-            case IOR:
-            case LOR:
-                masm.emitForceBitwise("or", dst, src1, src2);
-                break;
-            case IREM:
-            case LREM:
-                masm.emit("rem", dst, src1, src2);
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        if (info != null) {
-            assert exceptionOffset != -1;
-            crb.recordImplicitException(exceptionOffset, info);
-        }
-    }
-
-    private static void verifyKind(HSAILArithmetic opcode, Value result, Value x, Value y) {
-        assert (opcode.name().startsWith("I") && result.getKind() == Kind.Int && x.getKind().getStackKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) ||
-                        (opcode.name().startsWith("L") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Long) ||
-                        (opcode.name().startsWith("LU") && result.getKind() == Kind.Long && x.getKind() == Kind.Long && y.getKind() == Kind.Int) ||
-                        (opcode.name().startsWith("F") && result.getKind() == Kind.Float && x.getKind() == Kind.Float && y.getKind() == Kind.Float) ||
-                        (opcode.name().startsWith("D") && result.getKind() == Kind.Double && x.getKind() == Kind.Double && y.getKind() == Kind.Double) ||
-                        (opcode.name().startsWith("O") && result.getKind() == Kind.Object && x.getKind() == Kind.Object && (y.getKind() == Kind.Int || y.getKind() == Kind.Long));
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +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.lir.hsail;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.hsail.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-/**
- * Defines bit manipulation operations.
- */
-public class HSAILBitManipulationOp extends HSAILLIRInstruction {
-
-    public enum IntrinsicOpcode {
-        IPOPCNT,
-        LPOPCNT,
-        IBSR,
-        LBSR,
-        BSF;
-    }
-
-    @Opcode private final IntrinsicOpcode opcode;
-    @Def protected Value result;
-    @Use({OperandFlag.REG}) protected Value input;
-
-    public HSAILBitManipulationOp(IntrinsicOpcode opcode, Value result, Value input) {
-        this.opcode = opcode;
-        this.result = result;
-        this.input = input;
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-        switch (opcode) {
-            case IPOPCNT:
-                throw GraalInternalError.shouldNotReachHere();
-            case LPOPCNT:
-                throw GraalInternalError.shouldNotReachHere();
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.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.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-/**
- * Implementation of compare operations.
- */
-public enum HSAILCompare {
-    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 {
-
-        @Opcode private final HSAILCompare opcode;
-        @Use({REG, CONST}) protected Value x;
-        @Use({REG, CONST}) protected Value y;
-        @Def({REG}) protected Value z;
-        private final Condition condition;
-        public boolean unordered = false;
-
-        public CompareOp(HSAILCompare opcode, Condition condition, Value x, Value y, Value z) {
-            this.opcode = opcode;
-            this.condition = condition;
-            this.x = x;
-            this.y = y;
-            this.z = z;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            emit(crb, masm, opcode, condition, x, y, z, unordered);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            assert (x.getKind() == y.getKind() && ((name().startsWith("I") && x.getKind() == Kind.Int) || (name().startsWith("L") && x.getKind() == Kind.Long) ||
-                            (name().startsWith("A") && x.getKind() == Kind.Object) || (name().startsWith("F") && x.getKind() == Kind.Float) || (name().startsWith("D") && x.getKind() == Kind.Double)));
-        }
-    }
-
-    @SuppressWarnings("unused")
-    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) {
-        switch (condition) {
-            case EQ:
-                return "eq";
-            case NE:
-                return "ne";
-            case LT:
-            case BT:
-                return "lt";
-            case LE:
-            case BE:
-                return "le";
-            case GT:
-            case AT:
-                return "gt";
-            case GE:
-            case AE:
-                return "ge";
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    private static boolean isUnsignedCompare(Condition condition) {
-        switch (condition) {
-            case BT:
-            case BE:
-            case AT:
-            case AE:
-                return true;
-            default:
-                return false;
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,359 +0,0 @@
-/*
- * 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.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.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-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.*;
-
-/**
- * Implementation of control flow instructions.
- */
-public class HSAILControlFlow {
-
-    /**
-     * This class represents the LIR instruction that the HSAIL backend generates for a switch
-     * construct in Java.
-     *
-     * The HSAIL backend compiles switch statements into a series of cascading compare and branch
-     * instructions because this is the currently the recommended way to generate optimally
-     * performing HSAIL code. Thus the execution path for both the TABLESWITCH and LOOKUPSWITCH
-     * bytecodes go through this op.
-     */
-    public static class StrategySwitchOp extends HSAILLIRInstruction implements BlockEndOp {
-        /**
-         * The array of key constants used for the cases of this switch statement.
-         */
-        @Use({CONST}) protected JavaConstant[] keyConstants;
-        /**
-         * The branch target labels that correspond to each case.
-         */
-        private final LabelRef[] keyTargets;
-        private LabelRef defaultTarget;
-        /**
-         * The key of the switch. This will be compared with each of the keyConstants.
-         */
-        @Alive({REG}) protected Value key;
-
-        private final SwitchStrategy strategy;
-
-        /**
-         * Constructor. Called from the HSAILLIRGenerator.emitStrategySwitch routine.
-         */
-        public StrategySwitchOp(SwitchStrategy strategy, LabelRef[] keyTargets, LabelRef defaultTarget, Value key) {
-            this.strategy = strategy;
-            this.keyConstants = strategy.keyConstants;
-            this.keyTargets = keyTargets;
-            this.defaultTarget = defaultTarget;
-            this.key = key;
-            assert keyConstants.length == keyTargets.length;
-            assert keyConstants.length == strategy.keyProbabilities.length;
-        }
-
-        /**
-         * Generates the code for this switch op.
-         *
-         * @param crb the CompilationResultBuilder
-         * @param masm the HSAIL assembler
-         */
-        @Override
-        public void emitCode(CompilationResultBuilder crb, final HSAILAssembler masm) {
-            BaseSwitchClosure closure = new BaseSwitchClosure(crb, masm, keyTargets, defaultTarget) {
-                @Override
-                protected void conditionalJump(int index, Condition condition, Label target) {
-                    switch (key.getKind()) {
-                        case Int:
-                        case Long:
-                        case Object:
-                            // Generate cascading compare and branches for each case.
-                            masm.emitCompare(key.getKind(), key, keyConstants[index], HSAILCompare.conditionToString(condition), false, false);
-                            masm.cbr(masm.nameOf(target));
-                            break;
-                        default:
-                            throw new GraalInternalError("switch not supported for kind " + key.getKind());
-                    }
-                }
-            };
-            strategy.run(closure);
-        }
-    }
-
-    public static class ReturnOp extends HSAILLIRInstruction implements BlockEndOp {
-
-        @Use({REG, ILLEGAL}) protected Value x;
-
-        public ReturnOp(Value x) {
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            crb.frameContext.leave(crb);
-            masm.exit();
-        }
-    }
-
-    public interface DeoptimizingOp {
-        LIRFrameState getFrameState();
-
-        int getCodeBufferPos();
-    }
-
-    /***
-     * The ALIVE annotation is so we can get a scratch32 register that does not clobber
-     * actionAndReason.
-     */
-    public static class DeoptimizeOp extends ReturnOp implements DeoptimizingOp {
-
-        @Alive({REG, CONST}) protected Value actionAndReason;
-        @State protected LIRFrameState frameState;
-        protected MetaAccessProvider metaAccessProvider;
-        protected String emitName;
-        protected int codeBufferPos = -1;
-        private final boolean emitInfopoint;
-
-        public DeoptimizeOp(Value actionAndReason, LIRFrameState frameState, String emitName, boolean emitInfopoint, MetaAccessProvider metaAccessProvider) {
-            super(Value.ILLEGAL);   // return with no ret value
-            this.actionAndReason = actionAndReason;
-            this.frameState = frameState;
-            this.emitName = emitName;
-            this.metaAccessProvider = metaAccessProvider;
-            this.emitInfopoint = emitInfopoint;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            String reasonString;
-            if (isConstant(actionAndReason)) {
-                DeoptimizationReason reason = metaAccessProvider.decodeDeoptReason((JavaConstant) actionAndReason);
-                reasonString = reason.toString();
-            } else {
-                reasonString = "Variable Reason";
-            }
-
-            masm.emitComment("// " + emitName + ", Deoptimization for " + reasonString);
-
-            if (frameState == null) {
-                masm.emitComment("// frameState == null");
-                // and emit the return
-                super.emitCode(crb, masm);
-                return;
-            }
-            // get a unique codeBuffer position
-            // when we save our state, we will save this as well (it can be used as a key to get the
-            // debugInfo)
-            codeBufferPos = masm.position();
-
-            masm.emitComment("/* HSAIL Deoptimization pos=" + codeBufferPos + ", bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */");
-
-            AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int));
-            AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int));
-            masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason);
-            masm.emitMov(Kind.Int, codeBufferOffsetReg, JavaConstant.forInt(codeBufferPos));
-            masm.emitJumpToLabelName(masm.getDeoptLabelName());
-
-            // Now record the debuginfo. If HSAIL deoptimization is off,
-            // no debuginfo is emitted and the kernel will return without
-            // a deoptimization.
-            if (emitInfopoint) {
-                crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.IMPLICIT_EXCEPTION);
-            }
-        }
-
-        public LIRFrameState getFrameState() {
-            return frameState;
-        }
-
-        public int getCodeBufferPos() {
-            return codeBufferPos;
-        }
-    }
-
-    public static class UnwindOp extends ReturnOp {
-
-        protected String commentMessage;
-
-        public UnwindOp(String commentMessage) {
-            super(Value.ILLEGAL);   // return with no ret value
-            this.commentMessage = commentMessage;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitComment("// " + commentMessage);
-            super.emitCode(crb, masm);
-        }
-    }
-
-    public static class ForeignCallNoArgOp extends HSAILLIRInstruction {
-
-        @Def({REG}) protected Value out;
-        String callName;
-
-        public ForeignCallNoArgOp(String callName, Value out) {
-            this.out = out;
-            this.callName = callName;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitComment("//ForeignCall to " + callName + " would have gone here");
-        }
-    }
-
-    public static class ForeignCall1ArgOp extends ForeignCallNoArgOp {
-
-        @Use({REG, ILLEGAL}) protected Value arg1;
-
-        public ForeignCall1ArgOp(String callName, Value out, Value arg1) {
-            super(callName, out);
-            this.arg1 = arg1;
-        }
-    }
-
-    public static class ForeignCall2ArgOp extends ForeignCall1ArgOp {
-
-        @Use({REG, ILLEGAL}) protected Value arg2;
-
-        public ForeignCall2ArgOp(String callName, Value out, Value arg1, Value arg2) {
-            super(callName, out, arg1);
-            this.arg2 = arg2;
-        }
-    }
-
-    public static class CompareBranchOp extends HSAILLIRInstruction implements StandardOp.BranchOp {
-
-        @Opcode protected final HSAILCompare opcode;
-        @Use({REG, CONST}) protected Value x;
-        @Use({REG, CONST}) protected Value y;
-        @Def({REG}) protected Value z;
-        protected final Condition condition;
-        protected final LabelRef trueDestination;
-        protected final LabelRef falseDestination;
-        @Def({REG}) protected Value result;
-        protected final boolean unordered;
-
-        public CompareBranchOp(HSAILCompare opcode, Condition condition, Value x, Value y, Value z, Value result, LabelRef trueDestination, LabelRef falseDestination, boolean unordered) {
-            this.condition = condition;
-            this.opcode = opcode;
-            this.x = x;
-            this.y = y;
-            this.z = z;
-            this.result = result;
-            this.trueDestination = trueDestination;
-            this.falseDestination = falseDestination;
-            this.unordered = unordered;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            if (crb.isSuccessorEdge(trueDestination)) {
-                HSAILCompare.emit(crb, masm, opcode, condition.negate(), x, y, z, !unordered);
-                masm.cbr(masm.nameOf(falseDestination.label()));
-            } else {
-                HSAILCompare.emit(crb, masm, opcode, condition, x, y, z, unordered);
-                masm.cbr(masm.nameOf(trueDestination.label()));
-                if (!crb.isSuccessorEdge(falseDestination)) {
-                    masm.jmp(falseDestination.label());
-                }
-            }
-        }
-    }
-
-    public static class CondMoveOp extends HSAILLIRInstruction {
-
-        @Opcode protected final HSAILCompare opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, CONST}) protected Value trueValue;
-        @Use({REG, CONST}) protected Value falseValue;
-        @Use({REG, CONST}) protected Value left;
-        @Use({REG, CONST}) protected Value right;
-        protected final Condition condition;
-
-        public CondMoveOp(HSAILCompare opcode, Variable left, Value right, Variable result, Condition condition, Value trueValue, Value falseValue) {
-            this.opcode = opcode;
-            this.result = result;
-            this.left = left;
-            this.right = right;
-            this.condition = condition;
-            this.trueValue = trueValue;
-            this.falseValue = falseValue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            HSAILCompare.emit(crb, masm, opcode, condition, left, right, right, false);
-            cmove(masm, result, trueValue, falseValue);
-        }
-    }
-
-    public static class FloatCondMoveOp extends CondMoveOp {
-
-        private final boolean unorderedIsTrue;
-
-        public FloatCondMoveOp(HSAILCompare opcode, Variable left, Variable right, Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Value falseValue) {
-            super(opcode, left, right, result, condition, trueValue, falseValue);
-            this.unorderedIsTrue = unorderedIsTrue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            HSAILCompare.emit(crb, masm, opcode, condition, left, right, right, unorderedIsTrue);
-            cmove(masm, result, trueValue, falseValue);
-        }
-    }
-
-    private static void cmove(HSAILAssembler masm, Value result, Value trueValue, Value falseValue) {
-        // Check that we don't overwrite an input operand before it is used.
-        assert (result.getKind() == trueValue.getKind() && result.getKind() == falseValue.getKind());
-        int width;
-        switch (result.getKind()) {
-        /**
-         * We don't need to pass the cond to the assembler. We will always use $c0 as the control
-         * register.
-         */
-            case Float:
-            case Int:
-                width = 32;
-                break;
-            case Double:
-            case Long:
-                width = 64;
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        masm.emitConditionalMove(result, trueValue, falseValue, width);
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.lir.hsail;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.lir.framemap.*;
-
-/**
- * HSAIL specific frame map.
- *
- * This is the format of a HSAIL stack frame:
- *
- * <pre>
- * TODO stack frame layout
- * </pre>
- */
-public final class HSAILFrameMap extends FrameMap {
-
-    public HSAILFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
-        super(codeCache, registerConfig);
-    }
-
-    @Override
-    public int totalFrameSize() {
-        // FIXME return some sane values
-        return frameSize();
-    }
-
-    @Override
-    public int currentFrameSize() {
-        // FIXME return some sane values
-        return alignFrameSize(outgoingSize + spillSize);
-    }
-
-    @Override
-    protected int alignFrameSize(int size) {
-        // FIXME return some sane values
-        int x = size + (getTarget().stackAlignment - 1);
-        return (x / getTarget().stackAlignment) * getTarget().stackAlignment;
-    }
-
-    @Override
-    public int offsetToCalleeSaveArea() {
-        return frameSize() - calleeSaveAreaSize();
-    }
-
-    @Override
-    protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
-        return StackSlot.get(kind, -spillSize + additionalOffset, true);
-    }
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +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.lir.hsail;
-
-import com.oracle.graal.asm.hsail.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-/**
- * Convenience class to provide HSAILAssembler for the {@link #emitCode} method.
- */
-public abstract class HSAILLIRInstruction extends LIRInstructionBase {
-
-    @Override
-    public final void emitCode(CompilationResultBuilder crb) {
-        emitCode(crb, (HSAILAssembler) crb.asm);
-    }
-
-    public abstract void emitCode(CompilationResultBuilder crb, HSAILAssembler masm);
-}
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,518 +0,0 @@
-/*
- * 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.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.hsail.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.MoveOp;
-import com.oracle.graal.lir.asm.*;
-import com.oracle.graal.hsail.*;
-
-/**
- * Implementation of move instructions.
- */
-public class HSAILMove {
-
-    // Stack size in bytes (used to keep track of spilling).
-    static int maxDatatypeSize;
-    // Maximum stack offset used by a store operation.
-    static long maxStackOffset = 0;
-
-    public static long upperBoundStackSize() {
-        return maxStackOffset + maxDatatypeSize;
-    }
-
-    private abstract static class AbstractMoveOp extends HSAILLIRInstruction implements MoveOp {
-
-        private Kind moveKind;
-
-        public AbstractMoveOp(Kind moveKind) {
-            this.moveKind = moveKind;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            move(moveKind, crb, masm, getResult(), getInput());
-        }
-    }
-
-    @Opcode("MOVE")
-    public static class MoveToRegOp extends AbstractMoveOp {
-
-        @Def({REG, HINT}) protected AllocatableValue result;
-        @Use({REG, STACK, CONST}) protected Value input;
-
-        public MoveToRegOp(Kind moveKind, AllocatableValue result, Value input) {
-            super(moveKind);
-            this.result = result;
-            this.input = input;
-            checkForNullObjectInput();
-        }
-
-        private void checkForNullObjectInput() {
-            if (result.getKind() == Kind.Object && isConstant(input) && input.getKind() == Kind.Long && ((JavaConstant) input).asLong() == 0) {
-                input = JavaConstant.NULL_POINTER;
-            }
-        }
-
-        @Override
-        public Value getInput() {
-            return input;
-        }
-
-        @Override
-        public AllocatableValue getResult() {
-            return result;
-        }
-    }
-
-    @Opcode("MOVE")
-    public static class MoveFromRegOp extends AbstractMoveOp {
-
-        @Def({REG, STACK}) protected AllocatableValue result;
-        @Use({REG, CONST, HINT}) protected Value input;
-
-        public MoveFromRegOp(Kind moveKind, AllocatableValue result, Value input) {
-            super(moveKind);
-            this.result = result;
-            this.input = input;
-        }
-
-        @Override
-        public Value getInput() {
-            return input;
-        }
-
-        @Override
-        public AllocatableValue getResult() {
-            return result;
-        }
-    }
-
-    public abstract static class MemOp extends HSAILLIRInstruction {
-
-        protected final Kind kind;
-        @Use({COMPOSITE}) protected HSAILAddressValue address;
-        @State protected LIRFrameState state;
-
-        public MemOp(Kind kind, HSAILAddressValue address, LIRFrameState state) {
-            this.kind = kind;
-            this.address = address;
-            this.state = state;
-        }
-
-        protected abstract void emitMemAccess(HSAILAssembler masm);
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            if (state != null) {
-                // crb.recordImplicitException(masm.position(), state);
-                throw new InternalError("NYI");
-            }
-            emitMemAccess(masm);
-        }
-    }
-
-    public static class MembarOp extends HSAILLIRInstruction {
-
-        private final int barriers;
-
-        public MembarOp(final int barriers) {
-            this.barriers = barriers;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitMembar(barriers);
-        }
-    }
-
-    public static class LoadOp extends MemOp {
-
-        @Def({REG}) protected AllocatableValue result;
-
-        public LoadOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
-            super(kind, address, state);
-            this.result = result;
-        }
-
-        @Override
-        public void emitMemAccess(HSAILAssembler masm) {
-            HSAILAddress addr = address.toAddress();
-            masm.emitLoad(kind, result, addr);
-        }
-
-        public boolean usesThreadRegister() {
-            return (address.toAddress().getBase().equals(HSAIL.threadRegister));
-        }
-    }
-
-    /**
-     * A LoadOp that uses the HSAIL ld_acq instruction.
-     */
-    public static class LoadAcquireOp extends LoadOp {
-        public LoadAcquireOp(Kind kind, AllocatableValue result, HSAILAddressValue address, LIRFrameState state) {
-            super(kind, result, address, state);
-        }
-
-        @Override
-        public void emitMemAccess(HSAILAssembler masm) {
-            HSAILAddress addr = address.toAddress();
-            masm.emitLoadAcquire(result, addr);
-        }
-    }
-
-    public static class StoreOp extends MemOp {
-
-        @Use({REG}) protected AllocatableValue input;
-
-        public StoreOp(Kind kind, HSAILAddressValue address, AllocatableValue input, LIRFrameState state) {
-            super(kind, address, state);
-            this.input = input;
-        }
-
-        @Override
-        public void emitMemAccess(HSAILAssembler masm) {
-            assert isRegister(input);
-            HSAILAddress addr = address.toAddress();
-            masm.emitStore(kind, input, addr);
-        }
-    }
-
-    /**
-     * A StoreOp that uses the HSAIL st_rel instruction.
-     */
-    public static class StoreReleaseOp extends StoreOp {
-        public StoreReleaseOp(Kind kind, HSAILAddressValue address, AllocatableValue input, LIRFrameState state) {
-            super(kind, address, input, state);
-        }
-
-        @Override
-        public void emitMemAccess(HSAILAssembler masm) {
-            assert isRegister(input);
-            HSAILAddress addr = address.toAddress();
-            masm.emitStoreRelease(input, addr);
-        }
-    }
-
-    public static class StoreConstantOp extends MemOp {
-
-        protected final JavaConstant input;
-
-        public StoreConstantOp(Kind kind, HSAILAddressValue address, JavaConstant input, LIRFrameState state) {
-            super(kind, address, state);
-            this.input = input;
-        }
-
-        @Override
-        public void emitMemAccess(HSAILAssembler masm) {
-            switch (kind) {
-                case Boolean:
-                case Byte:
-                    masm.emitStoreImmediate(kind, input.asLong() & 0xFF, address.toAddress());
-                    break;
-                case Char:
-                case Short:
-                    masm.emitStoreImmediate(kind, input.asLong() & 0xFFFF, address.toAddress());
-                    break;
-                case Int:
-                case Long:
-                    masm.emitStoreImmediate(kind, input.asLong(), address.toAddress());
-                    break;
-                case Float:
-                    masm.emitStoreImmediate(input.asFloat(), address.toAddress());
-                    break;
-                case Double:
-                    masm.emitStoreImmediate(input.asDouble(), address.toAddress());
-                    break;
-                case Object:
-                    if (input.isNull()) {
-                        masm.emitStoreImmediate(kind, 0L, address.toAddress());
-                    } else {
-                        throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to object ref");
-                    }
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    public static class CompressPointer extends HSAILLIRInstruction {
-
-        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, 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 = !nonNull;
-            encodePointer(masm, scratch, base, shift, alignment, testForNull);
-            masm.emitConvert(result, scratch, "u32", "u64");
-        }
-    }
-
-    public static class UncompressPointer extends HSAILLIRInstruction {
-
-        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, 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 = !nonNull;
-            decodePointer(masm, result, base, shift, alignment, testForNull);
-        }
-    }
-
-    private static void encodePointer(HSAILAssembler masm, Value scratch, long base, int shift, int alignment, boolean testForNull) {
-        if (base == 0 && shift == 0) {
-            return;
-        }
-        if (shift != 0) {
-            assert alignment == shift : "Encode algorithm is wrong";
-        }
-        masm.emitCompressedOopEncode(scratch, base, shift, testForNull);
-    }
-
-    private static void decodePointer(HSAILAssembler masm, Value result, long base, int shift, int alignment, boolean testForNull) {
-        if (base == 0 && shift == 0) {
-            return;
-        }
-        if (shift != 0) {
-            assert alignment == shift : "Decode algorithm is wrong";
-        }
-        masm.emitCompressedOopDecode(result, base, shift, testForNull);
-    }
-
-    public static class LeaOp extends HSAILLIRInstruction {
-
-        @Def({REG}) protected AllocatableValue result;
-        @Use({COMPOSITE, UNINITIALIZED}) protected HSAILAddressValue address;
-
-        public LeaOp(AllocatableValue result, HSAILAddressValue address) {
-            this.result = result;
-            this.address = address;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            HSAILAddress addr = address.toAddress();
-            masm.emitLea(result, addr);
-        }
-    }
-
-    public static class StackLeaOp extends HSAILLIRInstruction {
-
-        @Def({REG}) protected AllocatableValue result;
-        @Use({STACK, UNINITIALIZED}) protected StackSlot slot;
-
-        public StackLeaOp(AllocatableValue result, StackSlot slot) {
-            this.result = result;
-            this.slot = slot;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            throw new InternalError("NYI");
-        }
-    }
-
-    @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(Kind accessKind, AllocatableValue result, HSAILAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
-            this.accessKind = accessKind;
-            this.result = result;
-            this.address = address;
-            this.cmpValue = cmpValue;
-            this.newValue = newValue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitAtomicCas(accessKind, result, address.toAddress(), cmpValue, newValue);
-        }
-    }
-
-    @Opcode("ATOMIC_READ_AND_ADD")
-    public static class AtomicReadAndAddOp extends HSAILLIRInstruction {
-
-        private final Kind accessKind;
-
-        @Def protected AllocatableValue result;
-        @Use({COMPOSITE}) protected HSAILAddressValue address;
-        @Use({REG, CONST}) protected Value delta;
-
-        public AtomicReadAndAddOp(Kind accessKind, AllocatableValue result, HSAILAddressValue address, Value delta) {
-            this.accessKind = accessKind;
-            this.result = result;
-            this.address = address;
-            this.delta = delta;
-        }
-
-        public HSAILAddressValue getAddress() {
-            return address;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            switch (accessKind) {
-                case Int:
-                case Long:
-                    masm.emitAtomicAdd(result, address.toAddress(), delta);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    @Opcode("ATOMIC_READ_AND_WRITE")
-    public static class AtomicReadAndWriteOp extends HSAILLIRInstruction {
-
-        private final Kind accessKind;
-
-        @Def protected AllocatableValue result;
-        @Use({COMPOSITE}) protected HSAILAddressValue address;
-        @Use({REG, CONST}) protected Value newValue;
-
-        public AtomicReadAndWriteOp(Kind accessKind, AllocatableValue result, HSAILAddressValue address, Value newValue) {
-            this.accessKind = accessKind;
-            this.result = result;
-            this.address = address;
-            this.newValue = newValue;
-        }
-
-        public HSAILAddressValue getAddress() {
-            return address;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitAtomicExch(accessKind, result, address.toAddress(), newValue);
-        }
-    }
-
-    public static class NullCheckOp extends HSAILLIRInstruction {
-
-        @Use protected Value input;
-        @State protected LIRFrameState state;
-
-        public NullCheckOp(Variable input, LIRFrameState state) {
-            this.input = input;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            Debug.log("NullCheckOp unimplemented");
-        }
-    }
-
-    @SuppressWarnings("unused")
-    public static void move(Kind kind, CompilationResultBuilder crb, HSAILAssembler masm, Value result, Value input) {
-        if (isRegister(input)) {
-            if (isRegister(result)) {
-                masm.emitMov(kind, result, input);
-            } else if (isStackSlot(result)) {
-                masm.emitSpillStore(kind, input, result);
-            } else {
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        } else if (isStackSlot(input)) {
-            if (isRegister(result)) {
-                masm.emitSpillLoad(kind, result, input);
-            } else {
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        } else if (isConstant(input)) {
-            if (isRegister(result)) {
-                masm.emitMov(kind, result, input);
-            } else {
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        } else {
-            throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    public static class WorkItemAbsIdOp extends HSAILLIRInstruction {
-
-        @Def({REG}) protected AllocatableValue result;
-
-        public WorkItemAbsIdOp(AllocatableValue result) {
-            this.result = result;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) {
-            masm.emitWorkItemAbsId(result);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * 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.lir.ptx;
-
-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.lir.*;
-import com.oracle.graal.lir.LIRInstruction.OperandFlag;
-
-/**
- * Represents an address in target machine memory, specified via some combination of a base register
- * and a displacement.
- */
-public final class PTXAddressValue extends CompositeValue {
-
-    private static final long serialVersionUID = 1802222435353022623L;
-
-    @Component({REG, OperandFlag.ILLEGAL}) private AllocatableValue base;
-    private final long displacement;
-
-    /**
-     * Creates an {@link PTXAddressValue} with given base register and no displacement.
-     *
-     * @param kind the kind of the value being addressed
-     * @param base the base register
-     */
-    public PTXAddressValue(LIRKind kind, AllocatableValue base) {
-        this(kind, base, 0);
-    }
-
-    /**
-     * Creates an {@link PTXAddressValue} with given base register and a displacement. This is the
-     * most general constructor.
-     *
-     * @param kind the kind of the value being addressed
-     * @param base the base register
-     * @param displacement the displacement
-     */
-    public PTXAddressValue(LIRKind kind, AllocatableValue base, long displacement) {
-        super(kind);
-        this.base = base;
-        this.displacement = displacement;
-
-        assert !isStackSlotValue(base);
-    }
-
-    public PTXAddress toAddress() {
-        // Register baseReg = base.equals( == Value.ILLEGAL) ? Register.None : asRegister(base);
-        return new PTXAddress((Variable) base, displacement);
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder s = new StringBuilder();
-        s.append(getKind().getJavaName()).append("[");
-        String sep = "";
-        if (isLegal(base)) {
-            s.append(base);
-            sep = " + ";
-        }
-        if (displacement < 0) {
-            s.append(" - ").append(-displacement);
-        } else if (displacement > 0) {
-            s.append(sep).append(displacement);
-        }
-        s.append("]");
-        return s.toString();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof PTXAddressValue) {
-            PTXAddressValue addr = (PTXAddressValue) obj;
-            return getLIRKind().equals(addr.getLIRKind()) && displacement == addr.displacement && base.equals(addr.base);
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return base.hashCode() ^ ((int) displacement << 4) ^ getLIRKind().hashCode();
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,427 +0,0 @@
-/*
- * 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.lir.ptx;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
-import static com.oracle.graal.lir.LIRValueUtil.*;
-
-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.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-// @formatter:off
-public enum PTXArithmetic {
-    IADD, ISUB, IMUL, IDIV, IDIVREM, IREM, IUDIV, IUREM, IAND, IOR, IXOR, ISHL, ISHR, IUSHR,
-    LADD, LSUB, LMUL, LDIV, LDIVREM, LREM, LUDIV, LUREM, LAND, LOR, LXOR, LSHL, LSHR, LUSHR,
-    FADD, FSUB, FMUL, FDIV, FREM, FAND, FOR, FXOR,
-    DADD, DSUB, DMUL, DDIV, DREM, DAND, DOR, DXOR,
-    INEG, LNEG, FNEG, DNEG, INOT, LNOT;
-
-
-    public static class ConvertOp extends PTXLIRInstruction {
-        private final Kind from;
-        private final Kind to;
-        @Def({REG}) protected AllocatableValue result;
-        @Use({REG, STACK}) protected AllocatableValue x;
-
-        public ConvertOp(AllocatableValue result, AllocatableValue x, Kind to, Kind from) {
-            this.from = from;
-            this.to = to;
-            this.result = result;
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            Variable dst = (Variable) result;
-            Variable src = (Variable) x;
-            if (from == Kind.Long && to == Kind.Int) {
-                new And(dst, src, JavaConstant.forLong(0xFFFFFFFF)).emit(masm);
-            } else if ((from == Kind.Int || from == Kind.Long) && to == Kind.Short) {
-                new And(dst, src, JavaConstant.forInt((short) 0xFFFF)).emit(masm);
-            } else {
-                new Cvt((Variable) result, (Variable) x, to, from).emit(masm);
-            }
-        }
-    }
-
-    public static class Op1Stack extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, STACK, CONST}) protected Value x;
-
-        public Op1Stack(PTXArithmetic opcode, Value result, Value x) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(crb, masm, opcode, result, x, null);
-        }
-    }
-
-    public static class Op2Stack extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, STACK, CONST}) protected Value x;
-        @Alive({REG, STACK, CONST}) protected Value y;
-
-        public Op2Stack(PTXArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(crb, masm, opcode, result, x, y, null);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    public static class Op2Reg extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, STACK, CONST}) protected Value x;
-        @Alive({REG, CONST}) protected Value y;
-
-        public Op2Reg(PTXArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(crb, masm, opcode, result, x, y, null);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    public static class Op2RegCommutative extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, STACK, CONST}) protected Value x;
-        @Use({REG, CONST}) protected Value y;
-
-        public Op2RegCommutative(PTXArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            if (sameRegister(result, y)) {
-                emit(crb, masm, opcode, result, x, null);
-            } else {
-                PTXMove.move(crb, masm, result, x);
-                emit(crb, masm, opcode, result, y, null);
-            }
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    public static class ShiftOp extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def({REG, HINT}) protected Value result;
-        @Use({REG, STACK, CONST}) protected Value x;
-        @Alive({REG, CONST}) protected Value y;
-
-        public ShiftOp(PTXArithmetic opcode, Value result, Value x, Value y) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(crb, masm, opcode, result, x, y, null);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, x);
-            assert y.getKind().getStackKind() == Kind.Int;
-        }
-    }
-
-    public static class DivOp extends PTXLIRInstruction {
-        @Opcode private final PTXArithmetic opcode;
-        @Def protected Value result;
-        @Use protected Value x;
-        @Alive protected Value y;
-        @State protected LIRFrameState state;
-
-        public DivOp(PTXArithmetic opcode, Value result, Value x, Value y, LIRFrameState state) {
-            this.opcode = opcode;
-            this.result = result;
-            this.x = x;
-            this.y = y;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(crb, masm, opcode, result, y, state);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            verifyKind(opcode, result, x, y);
-        }
-    }
-
-    public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src, LIRFrameState info) {
-        int exceptionOffset = -1;
-        Variable dest = (Variable) dst;
-
-        if (isVariable(src)) {
-            Variable source = (Variable) src;
-            switch (opcode) {
-                case INEG:
-                case FNEG:
-                case DNEG:
-                    new Neg(dest, source).emit(masm);
-                    break;
-                case INOT:
-                case LNOT:
-                    new Not(dest, source).emit(masm);
-                    break;
-                case LSHL:
-                    new Shl(dest, dest, src).emit(masm);
-                    break;
-                case LSHR:
-                    new Shr(dest, dest, src).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere("missing: "  + opcode);
-            }
-        } else if (isConstant(src)) {
-            switch (opcode) {
-                case ISUB:
-                    new Sub(dest, dest, src).emit(masm);
-                    break;
-                case IAND:
-                    new And(dest, dest, src).emit(masm);
-                    break;
-                case LSHL:
-                    new Shl(dest, dest, src).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        } else {
-            switch (opcode) {
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-
-        if (info != null) {
-            assert exceptionOffset != -1;
-            crb.recordImplicitException(exceptionOffset, info);
-        }
-    }
-
-    public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode,
-                            Value dst, Value src1, Value src2, LIRFrameState info) {
-        int exceptionOffset = -1;
-        Variable dest = (Variable) dst;
-
-        switch (opcode) {
-            case IADD:
-            case LADD:
-            case FADD:
-            case DADD:
-                new Add(dest, src1, src2).emit(masm);
-                break;
-            case IAND:
-            case LAND:
-                new And(dest, src1, src2).emit(masm);
-                break;
-            case ISUB:
-            case LSUB:
-            case FSUB:
-            case DSUB:
-                new Sub(dest, src1, src2).emit(masm);
-                break;
-            case IMUL:
-            case LMUL:
-            case FMUL:
-            case DMUL:
-                new Mul(dest, src1, src2).emit(masm);
-                break;
-            case IDIV:
-            case LDIV:
-            case FDIV:
-            case DDIV:
-                new Div(dest, src1, src2).emit(masm);
-                break;
-            case IOR:
-            case LOR:
-                new Or(dest, src1, src2).emit(masm);
-                break;
-            case IXOR:
-            case LXOR:
-                new Xor(dest, src1, src2).emit(masm);
-                break;
-            case ISHL:
-            case LSHL:
-                new Shl(dest, src1, src2).emit(masm);
-                break;
-            case ISHR:
-            case LSHR:
-                new Shr(dest, src1, src2).emit(masm);
-                break;
-            case IUSHR:
-            case LUSHR:
-                new Ushr(dest, src1, src2).emit(masm);
-                break;
-            case IREM:
-            case LREM:
-            case FREM:
-            case DREM:
-                new Rem(dest, src1, src2).emit(masm);
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: "  + opcode);
-        }
-
-        if (info != null) {
-            assert exceptionOffset != -1;
-            crb.recordImplicitException(exceptionOffset, info);
-        }
-    }
-
-    private static void verifyKind(PTXArithmetic opcode, Value result, Value x, Value y) {
-        Kind rk;
-        Kind xk;
-        Kind yk;
-        Kind xsk;
-        Kind ysk;
-
-        switch (opcode) {
-            case IADD:
-            case ISUB:
-            case IMUL:
-            case IDIV:
-            case IREM:
-            case IAND:
-            case IOR:
-            case IXOR:
-            case ISHL:
-            case ISHR:
-            case IUSHR:
-                rk = result.getKind();
-                xsk = x.getKind().getStackKind();
-                ysk = y.getKind().getStackKind();
-                assert rk == Kind.Int && xsk == Kind.Int && ysk == Kind.Int;
-                break;
-            case LADD:
-            case LSUB:
-            case LMUL:
-            case LDIV:
-            case LREM:
-            case LAND:
-            case LOR:
-            case LXOR:
-                rk = result.getKind();
-                xk = x.getKind();
-                yk = y.getKind();
-                assert rk == Kind.Long && xk == Kind.Long && yk == Kind.Long;
-                break;
-            case LSHL:
-            case LSHR:
-            case LUSHR:
-                rk = result.getKind();
-                xk = x.getKind();
-                yk = y.getKind();
-                assert rk == Kind.Long && xk == Kind.Long && (yk == Kind.Int || yk == Kind.Long);
-                break;
-            case FADD:
-            case FSUB:
-            case FMUL:
-            case FDIV:
-            case FREM:
-                rk = result.getKind();
-                xk = x.getKind();
-                yk = y.getKind();
-                assert rk == Kind.Float && xk == Kind.Float && yk == Kind.Float;
-                break;
-            case DADD:
-            case DSUB:
-            case DMUL:
-            case DDIV:
-            case DREM:
-                rk = result.getKind();
-                xk = x.getKind();
-                yk = y.getKind();
-                assert rk == Kind.Double && xk == Kind.Double && yk == Kind.Double :
-                    "opcode=" + opcode + ", result kind=" + rk + ", x kind=" + xk + ", y kind=" + yk;
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + opcode);
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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.lir.ptx;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.ptx.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-public class PTXBitManipulationOp extends PTXLIRInstruction {
-
-    public enum IntrinsicOpcode {
-        IPOPCNT,
-        LPOPCNT,
-        IBSR,
-        LBSR,
-        BSF;
-    }
-
-    @Opcode private final IntrinsicOpcode opcode;
-    @Def protected Value result;
-    @Use({OperandFlag.REG}) protected Value input;
-
-    public PTXBitManipulationOp(IntrinsicOpcode opcode, Value result, Value input) {
-        this.opcode = opcode;
-        this.result = result;
-        this.input = input;
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-        Register dst = ValueUtil.asIntReg(result);
-        Register src = ValueUtil.asRegister(input);
-        switch (opcode) {
-            case IPOPCNT:
-                masm.popc_b32(dst, src);
-                break;
-            case LPOPCNT:
-                masm.popc_b64(dst, src);
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * 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
- * 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.lir.ptx;
-
-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.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-public enum PTXCompare {
-    ICMP,
-    LCMP,
-    ACMP,
-    FCMP,
-    DCMP;
-
-    public static class CompareOp extends PTXLIRInstruction {
-
-        @Opcode private final PTXCompare opcode;
-        @Use({REG, STACK, CONST}) protected Value x;
-        @Use({REG, STACK, CONST}) protected Value y;
-        // Number of predicate register that would be set by this instruction.
-        protected int predRegNum;
-        private final Condition condition;
-
-        public CompareOp(PTXCompare opcode, Condition condition, Value x, Value y, int predReg) {
-            this.opcode = opcode;
-            this.condition = condition;
-            this.x = x;
-            this.y = y;
-            predRegNum = predReg;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            emit(masm, opcode, condition, x, y, predRegNum);
-        }
-
-        @Override
-        public void verify() {
-            super.verify();
-            assert (name().startsWith("I") && x.getKind() == 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);
-        }
-    }
-
-    public static void emit(PTXAssembler masm, PTXCompare opcode, Condition condition, Value x, Value y, int p) {
-        if (isConstant(x)) {
-            new Setp(condition, x, y, p).emit(masm);
-        } else if (isConstant(y)) {
-            switch (opcode) {
-                case ICMP:
-                    new Setp(condition, x, y, p).emit(masm);
-                    break;
-                case ACMP:
-                    if (((JavaConstant) y).isNull()) {
-                        new Setp(condition, x, y, p).emit(masm);
-                    } else {
-                        throw GraalInternalError.shouldNotReachHere("Only null object constants are allowed in comparisons");
-                    }
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        } else {
-            new Setp(condition, x, y, p).emit(masm);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/*
- * 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.lir.ptx;
-
-import static com.oracle.graal.compiler.common.calc.Condition.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
-import static com.oracle.graal.lir.LIRValueUtil.*;
-
-import com.oracle.graal.api.code.CompilationResult.JumpTable;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.asm.*;
-import com.oracle.graal.asm.ptx.PTXAssembler.Global;
-import com.oracle.graal.asm.ptx.PTXAssembler.Setp;
-import com.oracle.graal.asm.ptx.*;
-import com.oracle.graal.asm.ptx.PTXMacroAssembler.Mov;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.calc.*;
-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.*;
-
-public class PTXControlFlow {
-
-    public abstract static class PTXPredicatedLIRInstruction extends PTXLIRInstruction {
-        private int predRegNum;
-
-        PTXPredicatedLIRInstruction(int regNum) {
-            predRegNum = regNum;
-        }
-
-        public int getPredRegNum() {
-            return predRegNum;
-        }
-    }
-
-    public static class ReturnOp extends PTXLIRInstruction {
-
-        @Use({REG, ILLEGAL}) protected Value x;
-
-        public ReturnOp(Value x) {
-            this.x = x;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            crb.frameContext.leave(crb);
-            masm.exit();
-        }
-    }
-
-    public static class ReturnNoValOp extends PTXLIRInstruction implements BlockEndOp {
-
-        public ReturnNoValOp() {
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            crb.frameContext.leave(crb);
-            masm.ret();
-        }
-    }
-
-    public static class BranchOp extends PTXPredicatedLIRInstruction implements StandardOp.BranchOp {
-
-        protected final Condition condition;
-        protected final LabelRef trueDestination;
-        protected final LabelRef falseDestination;
-
-        public BranchOp(Condition condition, LabelRef trueDestination, LabelRef falseDestination, int predReg) {
-            super(predReg);
-            this.condition = condition;
-            this.trueDestination = trueDestination;
-            this.falseDestination = falseDestination;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            if (crb.isSuccessorEdge(trueDestination)) {
-                masm.bra(masm.nameOf(falseDestination.label()), getPredRegNum(), false);
-            } else {
-                masm.bra(masm.nameOf(trueDestination.label()), getPredRegNum(), true);
-                if (!crb.isSuccessorEdge(falseDestination)) {
-                    masm.jmp(falseDestination.label());
-                }
-            }
-        }
-    }
-
-    public static class CondMoveOp extends PTXPredicatedLIRInstruction {
-
-        @Def({REG, HINT}) protected Value result;
-        @Alive({REG}) protected Value trueValue;
-        @Use({REG, STACK, CONST}) protected Value falseValue;
-        private final Condition condition;
-
-        public CondMoveOp(Variable result, Condition condition, Variable trueValue, Value falseValue, int predicateRegister) {
-            super(predicateRegister);
-            this.result = result;
-            this.condition = condition;
-            this.trueValue = trueValue;
-            this.falseValue = falseValue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            cmove(crb, masm, result, false, condition, false, trueValue, falseValue, getPredRegNum());
-        }
-    }
-
-    public static class FloatCondMoveOp extends PTXPredicatedLIRInstruction {
-
-        @Def({REG}) protected Value result;
-        @Alive({REG}) protected Value trueValue;
-        @Alive({REG}) protected Value falseValue;
-        private final Condition condition;
-        private final boolean unorderedIsTrue;
-
-        public FloatCondMoveOp(Variable result, Condition condition, boolean unorderedIsTrue, Variable trueValue, Variable falseValue, int predicateRegister) {
-            super(predicateRegister);
-            this.result = result;
-            this.condition = condition;
-            this.unorderedIsTrue = unorderedIsTrue;
-            this.trueValue = trueValue;
-            this.falseValue = falseValue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, getPredRegNum());
-        }
-    }
-
-    private static void cmove(CompilationResultBuilder crb, PTXMacroAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue,
-                    int predicateRegister) {
-        // check that we don't overwrite an input operand before it is used.
-        assert !result.equals(trueValue);
-
-        PTXMove.move(crb, asm, result, falseValue);
-        cmove(asm, result, trueValue, predicateRegister);
-
-        if (isFloat) {
-            if (unorderedIsTrue && !trueOnUnordered(condition)) {
-                // cmove(crb, masm, result, ConditionFlag.Parity, trueValue);
-                throw GraalInternalError.unimplemented();
-            } else if (!unorderedIsTrue && trueOnUnordered(condition)) {
-                // cmove(crb, masm, result, ConditionFlag.Parity, falseValue);
-                throw GraalInternalError.unimplemented();
-            }
-        }
-    }
-
-    private static boolean trueOnUnordered(Condition condition) {
-        switch (condition) {
-            case NE:
-            case EQ:
-                return false;
-            case LT:
-            case GE:
-                return true;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    private static void cmove(PTXMacroAssembler asm, Value result, Value other, int predicateRegister) {
-        if (isVariable(other)) {
-            assert !asVariable(other).equals(asVariable(result)) : "other already overwritten by previous move";
-
-            switch (other.getKind()) {
-                case Int:
-                    new Mov(asVariable(result), other, predicateRegister).emit(asm);
-                    break;
-                case Long:
-                    new Mov(asVariable(result), other, predicateRegister).emit(asm);
-                    break;
-                default:
-                    throw new InternalError("unhandled: " + other.getKind());
-            }
-        } else {
-            throw GraalInternalError.shouldNotReachHere("cmove: not register");
-        }
-    }
-
-    public static class StrategySwitchOp extends PTXPredicatedLIRInstruction implements BlockEndOp {
-
-        @Use({CONST}) protected JavaConstant[] keyConstants;
-        private final LabelRef[] keyTargets;
-        private LabelRef defaultTarget;
-        @Alive({REG}) protected Value key;
-        @Temp({REG, ILLEGAL}) protected Value scratch;
-        private final SwitchStrategy strategy;
-
-        public StrategySwitchOp(SwitchStrategy strategy, LabelRef[] keyTargets, LabelRef defaultTarget, Value key, Value scratch, int predReg) {
-            super(predReg);
-            this.strategy = strategy;
-            this.keyConstants = strategy.keyConstants;
-            this.keyTargets = keyTargets;
-            this.defaultTarget = defaultTarget;
-            this.key = key;
-            this.scratch = scratch;
-            assert keyConstants.length == keyTargets.length;
-            assert keyConstants.length == strategy.keyProbabilities.length;
-            assert (scratch.getKind() == Kind.Illegal) == (key.getKind() == Kind.Int || key.getKind() == Kind.Long);
-        }
-
-        @Override
-        public void emitCode(final CompilationResultBuilder crb, final PTXMacroAssembler masm) {
-            BaseSwitchClosure closure = new BaseSwitchClosure(crb, masm, keyTargets, defaultTarget) {
-                @Override
-                protected void conditionalJump(int index, Condition condition, Label target) {
-                    switch (key.getKind()) {
-                        case Int:
-                        case Long:
-                            if (crb.codeCache.needsDataPatch(keyConstants[index])) {
-                                crb.recordInlineDataInCode(keyConstants[index]);
-                            }
-                            new Setp(EQ, keyConstants[index], key, getPredRegNum()).emit(masm);
-                            break;
-                        case Object:
-                            assert condition == Condition.EQ || condition == Condition.NE;
-                            PTXMove.move(crb, masm, scratch, keyConstants[index]);
-                            new Setp(condition, scratch, key, getPredRegNum()).emit(masm);
-                            break;
-                        default:
-                            throw new GraalInternalError("switch only supported for int, long and object");
-                    }
-                    masm.bra(masm.nameOf(target), getPredRegNum(), true);
-                }
-            };
-            strategy.run(closure);
-        }
-    }
-
-    public static class TableSwitchOp extends PTXPredicatedLIRInstruction implements BlockEndOp {
-
-        private final int lowKey;
-        private final LabelRef defaultTarget;
-        private final LabelRef[] targets;
-        @Alive protected Value index;
-        @Temp protected Value scratch;
-
-        public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch, int predReg) {
-            super(predReg);
-            this.lowKey = lowKey;
-            this.defaultTarget = defaultTarget;
-            this.targets = targets;
-            this.index = index;
-            this.scratch = scratch;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            // Compare index against jump table bounds
-
-            int highKey = lowKey + targets.length - 1;
-            if (lowKey != 0) {
-                // subtract the low value from the switch value
-                // new Sub(value, value, lowKey).emit(masm);
-                new Setp(GT, index, JavaConstant.forInt(highKey - lowKey), getPredRegNum()).emit(masm);
-            } else {
-                new Setp(GT, index, JavaConstant.forInt(highKey), getPredRegNum()).emit(masm);
-            }
-
-            // Jump to default target if index is not within the jump table
-            if (defaultTarget != null) {
-                masm.bra(masm.nameOf(defaultTarget.label()), getPredRegNum(), true);
-            }
-
-            // address of jump table
-            int tablePos = masm.position();
-
-            JumpTable jt = new JumpTable(tablePos, lowKey, highKey, 4);
-            String name = "jumptable" + jt.position;
-
-            new Global(index, name, targets).emit(masm);
-
-            // bra(Value, name);
-
-            crb.compilationResult.addAnnotation(jt);
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.lir.ptx;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.lir.framemap.*;
-
-/**
- * PTX specific frame map.
- *
- * This is the format of a PTX stack frame:
- *
- * <pre>
- * TODO stack frame layout
- * </pre>
- */
-public final class PTXFrameMap extends FrameMap {
-
-    public PTXFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
-        super(codeCache, registerConfig);
-    }
-
-    @Override
-    public int totalFrameSize() {
-        // FIXME return some sane values
-        return frameSize();
-    }
-
-    @Override
-    public int currentFrameSize() {
-        // FIXME return some sane values
-        return alignFrameSize(outgoingSize + spillSize);
-    }
-
-    @Override
-    protected int alignFrameSize(int size) {
-        // FIXME return some sane values
-        int x = size + (getTarget().stackAlignment - 1);
-        return (x / getTarget().stackAlignment) * getTarget().stackAlignment;
-    }
-
-    @Override
-    public int offsetToCalleeSaveArea() {
-        return frameSize() - calleeSaveAreaSize();
-    }
-
-    @Override
-    protected StackSlot allocateNewSpillSlot(LIRKind kind, int additionalOffset) {
-        return StackSlot.get(kind, -spillSize + additionalOffset, true);
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +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.lir.ptx;
-
-import com.oracle.graal.asm.ptx.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-/**
- * Convenience class to provide PTXAssembler for the {@link #emitCode} method.
- */
-public abstract class PTXLIRInstruction extends LIRInstructionBase {
-
-    @Override
-    public final void emitCode(CompilationResultBuilder crb) {
-        emitCode(crb, (PTXMacroAssembler) crb.asm);
-    }
-
-    public abstract void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm);
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
- * 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.lir.ptx;
-
-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.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.asm.*;
-
-public class PTXMemOp {
-
-    // Load operation from .global state space
-    @Opcode("LOAD_REGBASE_DISP")
-    public static class LoadOp extends PTXLIRInstruction {
-
-        private final Kind kind;
-        @Def({REG}) protected Variable result;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @State protected LIRFrameState state;
-
-        public LoadOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
-            this.kind = kind;
-            this.result = result;
-            this.address = address;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            PTXAddress addr = address.toAddress();
-            switch (kind) {
-                case Boolean:
-                case Byte:
-                case Short:
-                case Char:
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                case Object:
-                    new Ld(Global, result, addr.getBase(), JavaConstant.forLong(addr.getDisplacement())).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    // Store operation from .global state space
-    @Opcode("STORE")
-    public static class StoreOp extends PTXLIRInstruction {
-
-        private final Kind kind;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @Use({REG}) protected Variable input;
-        @State protected LIRFrameState state;
-
-        public StoreOp(Kind kind, PTXAddressValue address, Variable input, LIRFrameState state) {
-            this.kind = kind;
-            this.address = address;
-            this.input = input;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            PTXAddress addr = address.toAddress();
-            switch (kind) {
-                case Byte:
-                case Short:
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                case Object:
-                    new St(Global, input, addr.getBase(), JavaConstant.forLong(addr.getDisplacement())).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind());
-            }
-        }
-    }
-
-    // Load operation from .param state space
-    @Opcode("LOAD_PARAM")
-    public static class LoadParamOp extends PTXLIRInstruction {
-
-        private final Kind kind;
-        @Def({REG}) protected Variable result;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @State protected LIRFrameState state;
-
-        public LoadParamOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
-            this.kind = kind;
-            this.result = result;
-            this.address = address;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            PTXAddress addr = address.toAddress();
-            switch (kind) {
-                case Byte:
-                case Short:
-                case Char:
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                case Object:
-                    new LoadParam(Parameter, result, addr.getBase(), JavaConstant.forLong(addr.getDisplacement())).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    // Load contents of return value pointer from return argument in
-    // .param state space
-    @Opcode("LOAD_RET_ADDR")
-    public static class LoadReturnAddrOp extends PTXLIRInstruction {
-
-        private final Kind kind;
-        @Def({REG}) protected Variable result;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @State protected LIRFrameState state;
-
-        public LoadReturnAddrOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
-            this.kind = kind;
-            this.result = result;
-            this.address = address;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            PTXAddress addr = address.toAddress();
-            switch (kind) {
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                    new LoadAddr(Parameter, result, addr.getBase(), JavaConstant.forLong(addr.getDisplacement())).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere();
-            }
-        }
-    }
-
-    // Store operation from .global state space
-    @Opcode("STORE_RETURN_VALUE")
-    public static class StoreReturnValOp extends PTXLIRInstruction {
-
-        private final Kind kind;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @Use({REG}) protected Variable input;
-        @State protected LIRFrameState state;
-
-        public StoreReturnValOp(Kind kind, PTXAddressValue address, Variable input, LIRFrameState state) {
-            this.kind = kind;
-            this.address = address;
-            this.input = input;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            PTXAddress addr = address.toAddress();
-
-            switch (kind) {
-                case Byte:
-                case Short:
-                case Int:
-                case Long:
-                case Float:
-                case Double:
-                case Object:
-                    new St(Global, input, addr.getBase(), JavaConstant.forLong(addr.getDisplacement())).emit(masm);
-                    break;
-                default:
-                    throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind());
-            }
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,268 +0,0 @@
-/*
- * 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.lir.ptx;
-
-import static com.oracle.graal.api.code.ValueUtil.*;
-import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
-import static com.oracle.graal.lir.LIRValueUtil.*;
-
-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.compiler.common.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.StandardOp.MoveOp;
-import com.oracle.graal.lir.StandardOp.NullCheck;
-import com.oracle.graal.lir.asm.*;
-
-public class PTXMove {
-
-    @Opcode("MOVE")
-    public static class SpillMoveOp extends PTXLIRInstruction implements MoveOp {
-
-        @Def({REG, STACK}) protected AllocatableValue result;
-        @Use({REG, STACK, CONST}) protected Value input;
-
-        public SpillMoveOp(AllocatableValue result, Value input) {
-            this.result = result;
-            this.input = input;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            move(crb, masm, getResult(), getInput());
-        }
-
-        @Override
-        public Value getInput() {
-            return input;
-        }
-
-        @Override
-        public AllocatableValue getResult() {
-            return result;
-        }
-    }
-
-    @Opcode("MOVE")
-    public static class MoveToRegOp extends PTXLIRInstruction implements MoveOp {
-
-        @Def({REG, HINT}) protected AllocatableValue result;
-        @Use({REG, STACK, CONST}) protected Value input;
-
-        public MoveToRegOp(AllocatableValue result, Value input) {
-            this.result = result;
-            this.input = input;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            move(crb, masm, getResult(), getInput());
-        }
-
-        @Override
-        public Value getInput() {
-            return input;
-        }
-
-        @Override
-        public AllocatableValue getResult() {
-            return result;
-        }
-    }
-
-    @Opcode("MOVE")
-    public static class MoveFromRegOp extends PTXLIRInstruction implements MoveOp {
-
-        @Def({REG, STACK}) protected AllocatableValue result;
-        @Use({REG, CONST, HINT}) protected Value input;
-
-        public MoveFromRegOp(AllocatableValue result, Value input) {
-            this.result = result;
-            this.input = input;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            move(crb, masm, getResult(), getInput());
-        }
-
-        @Override
-        public Value getInput() {
-            return input;
-        }
-
-        @Override
-        public AllocatableValue getResult() {
-            return result;
-        }
-    }
-
-    public static class LeaOp extends PTXLIRInstruction {
-
-        @Def({REG}) protected AllocatableValue result;
-        @Use({COMPOSITE, UNINITIALIZED}) protected PTXAddressValue address;
-
-        public LeaOp(AllocatableValue result, PTXAddressValue address) {
-            this.result = result;
-            this.address = address;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            throw new InternalError("NYI");
-        }
-    }
-
-    public static class StackLeaOp extends PTXLIRInstruction {
-
-        @Def({REG}) protected AllocatableValue result;
-        @Use({STACK, UNINITIALIZED}) protected StackSlot slot;
-
-        public StackLeaOp(AllocatableValue result, StackSlot slot) {
-            this.result = result;
-            this.slot = slot;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            throw new InternalError("NYI");
-        }
-    }
-
-    @Opcode("CAS")
-    public static class CompareAndSwapOp extends PTXLIRInstruction {
-
-        @Def protected AllocatableValue result;
-        @Use({COMPOSITE}) protected PTXAddressValue address;
-        @Use protected AllocatableValue cmpValue;
-        @Use protected AllocatableValue newValue;
-
-        public CompareAndSwapOp(AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
-            this.result = result;
-            this.address = address;
-            this.cmpValue = cmpValue;
-            this.newValue = newValue;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            compareAndSwap(crb, masm, result, address, cmpValue, newValue);
-        }
-    }
-
-    public static void move(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Value input) {
-        if (isVariable(input)) {
-            if (isVariable(result)) {
-                reg2reg(masm, result, input);
-            } else {
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        } else if (isConstant(input)) {
-            if (isVariable(result)) {
-                const2reg(crb, masm, result, (JavaConstant) input);
-            } else {
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        } else {
-            throw GraalInternalError.shouldNotReachHere();
-        }
-    }
-
-    private static void reg2reg(PTXMacroAssembler masm, Value result, Value input) {
-        Variable dest = (Variable) result;
-        Variable source = (Variable) input;
-
-        if (dest.index == source.index) {
-            return;
-        }
-        switch (input.getKind()) {
-            case Int:
-            case Long:
-            case Float:
-            case Double:
-            case Object:
-                new Mov(dest, source).emit(masm);
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + input.getKind());
-        }
-    }
-
-    private static void const2reg(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, JavaConstant input) {
-        Variable dest = (Variable) result;
-
-        switch (input.getKind().getStackKind()) {
-            case Int:
-            case Long:
-                if (crb.codeCache.needsDataPatch(input)) {
-                    crb.recordInlineDataInCode(input);
-                }
-                new Mov(dest, input).emit(masm);
-                break;
-            case Object:
-                if (input.isNull()) {
-                    new Mov(dest, JavaConstant.forLong(0x0L)).emit(masm);
-                } else if (crb.target.inlineObjects) {
-                    crb.recordInlineDataInCode(input);
-                    new Mov(dest, JavaConstant.forLong(0xDEADDEADDEADDEADL)).emit(masm);
-                } else {
-                    // new Mov(dest, crb.recordDataReferenceInCode(input, 0, false));
-                }
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere("missing: " + input.getKind());
-        }
-    }
-
-    @SuppressWarnings("unused")
-    protected static void compareAndSwap(CompilationResultBuilder crb, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) {
-        throw new InternalError("NYI");
-    }
-
-    public static class NullCheckOp extends PTXLIRInstruction implements NullCheck {
-
-        @Use({REG}) protected AllocatableValue input;
-        @State protected LIRFrameState state;
-
-        public NullCheckOp(Variable input, LIRFrameState state) {
-            this.input = input;
-            this.state = state;
-        }
-
-        @Override
-        public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-            crb.recordImplicitException(masm.position(), state);
-            masm.nullCheck(asRegister(input));
-        }
-
-        public Value getCheckedValue() {
-            return input;
-        }
-
-        public LIRFrameState getState() {
-            return state;
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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.lir.ptx;
-
-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.*;
-
-public class PTXParameterOp extends LIRInstructionBase {
-
-    @Def({REG}) protected Value[] params;
-    // True if the parameter list has return argument as the last
-    // item of the array params.
-    private boolean hasReturnParam;
-
-    public PTXParameterOp(Value[] params, boolean hasReturn) {
-        this.params = params;
-        hasReturnParam = hasReturn;
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb) {
-        PTXMacroAssembler masm = (PTXMacroAssembler) crb.asm;
-        // Emit parameter directives for arguments
-        int argCount = params.length;
-        for (int i = 0; i < argCount; i++) {
-            boolean isReturnParam = (hasReturnParam && (i == (argCount - 1)));
-            new Param((Variable) params[i], isReturnParam).emit(masm, (i == (argCount - 1)));
-        }
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.ptx;
-
-import static com.oracle.graal.asm.ptx.PTXAssembler.BooleanOperator.*;
-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.compiler.common.calc.*;
-import com.oracle.graal.lir.asm.*;
-
-public class PTXTestOp extends PTXLIRInstruction {
-
-    @Use({REG}) protected Value x;
-    @Use({REG, STACK, CONST}) protected Value y;
-    int predicate;
-
-    public PTXTestOp(Value x, Value y, int predicate) {
-        this.x = x;
-        this.y = y;
-        this.predicate = predicate;
-    }
-
-    @Override
-    public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) {
-        emit(masm, x, y, predicate);
-    }
-
-    @Override
-    public void verify() {
-        super.verify();
-        assert (x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (x.getKind() == Kind.Long && y.getKind() == Kind.Long) : x + " " + y;
-    }
-
-    public static void emit(PTXAssembler masm, Value x, Value y, int predicate) {
-        /*
-         * This is not yet quite right - as the result for the equivalent in
-         * ControlPTXText.testIntegerTestBranch2I is wrong.
-         */
-        new Setp(Condition.EQ, AND, x, y, predicate).emit(masm);
-    }
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ParallelOver.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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.lir.ptx;
-
-import static com.oracle.graal.lir.ptx.ThreadDimension.*;
-
-import java.lang.annotation.*;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.PARAMETER})
-public @interface ParallelOver {
-
-    String value() default "";
-
-    ThreadDimension dimension() default X;
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ThreadDimension.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +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.lir.ptx;
-
-public enum ThreadDimension {
-    X,
-    Y,
-    Z
-}
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/Warp.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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.lir.ptx;
-
-import static com.oracle.graal.lir.ptx.ThreadDimension.*;
-
-import java.lang.annotation.*;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.PARAMETER})
-public @interface Warp {
-
-    String value() default "";
-
-    ThreadDimension dimension() default X;
-}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FullInfopointOp.java	Wed Jan 28 19:32:47 2015 +0100
@@ -42,6 +42,7 @@
 
     @Override
     public void emitCode(CompilationResultBuilder crb) {
+        crb.asm.ensureUniquePC();
         crb.recordInfopoint(crb.asm.position(), state, reason);
     }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java	Wed Jan 28 19:32:47 2015 +0100
@@ -206,4 +206,19 @@
             }
         }
     }
+
+    @Opcode("BLACKHOLE")
+    public static class BlackholeOp extends LIRInstructionBase {
+
+        @Use({REG, STACK}) private Value value;
+
+        public BlackholeOp(Value value) {
+            this.value = value;
+        }
+
+        @Override
+        public void emitCode(CompilationResultBuilder crb) {
+            // do nothing, just keep value alive until at least here
+        }
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGenerator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -249,7 +249,11 @@
 
     public abstract Variable emitIntegerTestMove(Value leftVal, Value right, Value trueValue, Value falseValue);
 
-    protected abstract void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info);
+    /**
+     * Emits the single call operation at the heart of generating LIR for a
+     * {@linkplain #emitForeignCall(ForeignCallLinkage, LIRFrameState, Value...) foreign call}.
+     */
+    protected abstract void emitForeignCallOp(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info);
 
     public static AllocatableValue toStackKind(AllocatableValue value) {
         if (value.getKind().getStackKind() != value.getKind()) {
@@ -291,7 +295,7 @@
             argLocations[i] = loc;
         }
         res.setForeignCall(true);
-        emitForeignCall(linkage, linkageCc.getReturn(), argLocations, linkage.getTemporaries(), state);
+        emitForeignCallOp(linkage, linkageCc.getReturn(), argLocations, linkage.getTemporaries(), state);
 
         if (isLegal(linkageCc.getReturn())) {
             return emitMove(linkageCc.getReturn());
@@ -393,4 +397,8 @@
     public LIRGenerationResult getResult() {
         return res;
     }
+
+    public void emitBlackhole(Value operand) {
+        append(new StandardOp.BlackholeOp(operand));
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/gen/LIRGeneratorTool.java	Wed Jan 28 19:32:47 2015 +0100
@@ -189,6 +189,8 @@
 
     Value emitArrayEquals(Kind kind, Value array1, Value array2, Value length);
 
+    void emitBlackhole(Value operand);
+
     @SuppressWarnings("unused")
     default Value emitCountLeadingZeros(Value value) {
         throw GraalInternalError.unimplemented();
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/BasicInductionVariable.java	Wed Jan 28 19:32:47 2015 +0100
@@ -47,6 +47,10 @@
         return phi.graph();
     }
 
+    public BinaryArithmeticNode<?> getOp() {
+        return op;
+    }
+
     @Override
     public Direction direction() {
         Stamp stamp = rawStride.stamp();
@@ -157,4 +161,9 @@
     @Override
     public void deleteUnusedNodes() {
     }
+
+    @Override
+    public String toString() {
+        return String.format("BasicInductionVariable %s %s %s %s", initNode(), phi, op.getNodeClass().shortName(), strideNode());
+    }
 }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/CountedLoopInfo.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,9 +38,9 @@
     private InductionVariable iv;
     private ValueNode end;
     private boolean oneOff;
-    private BeginNode body;
+    private AbstractBeginNode body;
 
-    CountedLoopInfo(LoopEx loop, InductionVariable iv, ValueNode end, boolean oneOff, BeginNode body) {
+    CountedLoopInfo(LoopEx loop, InductionVariable iv, ValueNode end, boolean oneOff, AbstractBeginNode body) {
         this.loop = loop;
         this.iv = iv;
         this.end = end;
@@ -118,7 +118,7 @@
         return oneOff;
     }
 
-    public BeginNode getBody() {
+    public AbstractBeginNode getBody() {
         return body;
     }
 
@@ -157,7 +157,7 @@
             }
             cond = graph.unique(new IntegerLessThanNode(end, v1));
         }
-        overflowGuard = graph.unique(new GuardNode(cond, BeginNode.prevBegin(loop.entryPoint()), DeoptimizationReason.LoopLimitCheck, DeoptimizationAction.InvalidateRecompile, true,
+        overflowGuard = graph.unique(new GuardNode(cond, AbstractBeginNode.prevBegin(loop.entryPoint()), DeoptimizationReason.LoopLimitCheck, DeoptimizationAction.InvalidateRecompile, true,
                         JavaConstant.NULL_POINTER)); // TODO gd: use speculation
         loop.loopBegin().setOverflowGuard(overflowGuard);
         return overflowGuard;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedOffsetInductionVariable.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,6 +40,14 @@
         this.value = value;
     }
 
+    public InductionVariable getBase() {
+        return base;
+    }
+
+    public ValueNode getOffset() {
+        return offset;
+    }
+
     @Override
     public StructuredGraph graph() {
         return base.graph();
@@ -144,4 +152,9 @@
     @Override
     public void deleteUnusedNodes() {
     }
+
+    @Override
+    public String toString() {
+        return String.format("DerivedOffsetInductionVariable base (%s) %s %s", base, value.getNodeClass().shortName(), offset);
+    }
 }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/DerivedScaledInductionVariable.java	Wed Jan 28 19:32:47 2015 +0100
@@ -123,8 +123,13 @@
 
     @Override
     public void deleteUnusedNodes() {
-        if (scale.isAlive() && scale.usages().isEmpty()) {
+        if (scale.isAlive() && scale.hasNoUsages()) {
             GraphUtil.killWithUnusedFloatingInputs(scale);
         }
     }
+
+    @Override
+    public String toString() {
+        return String.format("DerivedScaleInductionVariable base (%s) %s %s", base, value.getNodeClass().shortName(), scale);
+    }
 }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java	Wed Jan 28 19:32:47 2015 +0100
@@ -230,8 +230,8 @@
         return data;
     }
 
-    public NodeBitMap nodesInLoopFrom(BeginNode point, BeginNode until) {
-        Collection<BeginNode> blocks = new LinkedList<>();
+    public NodeBitMap nodesInLoopFrom(AbstractBeginNode point, AbstractBeginNode until) {
+        Collection<AbstractBeginNode> blocks = new LinkedList<>();
         Collection<LoopExitNode> exits = new LinkedList<>();
         Queue<Block> work = new LinkedList<>();
         ControlFlowGraph cfg = loopsData().controlFlowGraph();
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java	Wed Jan 28 19:32:47 2015 +0100
@@ -150,13 +150,13 @@
         }
     }
 
-    protected static NodeBitMap computeNodes(Graph graph, Iterable<BeginNode> blocks) {
+    protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks) {
         return computeNodes(graph, blocks, Collections.emptyList());
     }
 
-    protected static NodeBitMap computeNodes(Graph graph, Iterable<BeginNode> blocks, Iterable<LoopExitNode> earlyExits) {
+    protected static NodeBitMap computeNodes(Graph graph, Iterable<AbstractBeginNode> blocks, Iterable<LoopExitNode> earlyExits) {
         final NodeBitMap nodes = graph.createNodeBitMap();
-        for (BeginNode b : blocks) {
+        for (AbstractBeginNode b : blocks) {
             if (b.isDeleted()) {
                 continue;
             }
@@ -188,7 +188,7 @@
         }
 
         final NodeBitMap notloopNodes = graph.createNodeBitMap();
-        for (BeginNode b : blocks) {
+        for (AbstractBeginNode b : blocks) {
             if (b.isDeleted()) {
                 continue;
             }
@@ -245,19 +245,19 @@
         return false;
     }
 
-    public static NodeIterable<BeginNode> toHirBlocks(final Iterable<Block> blocks) {
-        return new NodeIterable<BeginNode>() {
+    public static NodeIterable<AbstractBeginNode> toHirBlocks(final Iterable<Block> blocks) {
+        return new NodeIterable<AbstractBeginNode>() {
 
-            public Iterator<BeginNode> iterator() {
+            public Iterator<AbstractBeginNode> iterator() {
                 final Iterator<Block> it = blocks.iterator();
-                return new Iterator<BeginNode>() {
+                return new Iterator<AbstractBeginNode>() {
 
                     @Override
                     public void remove() {
                         throw new UnsupportedOperationException();
                     }
 
-                    public BeginNode next() {
+                    public AbstractBeginNode next() {
                         return it.next().getBeginNode();
                     }
 
@@ -302,17 +302,17 @@
     protected void mergeEarlyExits() {
         assert isDuplicate();
         StructuredGraph graph = graph();
-        for (BeginNode earlyExit : LoopFragment.toHirBlocks(original().loop().loop().getExits())) {
+        for (AbstractBeginNode earlyExit : LoopFragment.toHirBlocks(original().loop().loop().getExits())) {
             LoopExitNode loopEarlyExit = (LoopExitNode) earlyExit;
             FixedNode next = loopEarlyExit.next();
             if (loopEarlyExit.isDeleted() || !this.original().contains(loopEarlyExit)) {
                 continue;
             }
-            BeginNode newEarlyExit = getDuplicatedNode(loopEarlyExit);
+            AbstractBeginNode newEarlyExit = getDuplicatedNode(loopEarlyExit);
             if (newEarlyExit == null) {
                 continue;
             }
-            MergeNode merge = graph.add(new MergeNode());
+            AbstractMergeNode merge = graph.add(new MergeNode());
             AbstractEndNode originalEnd = graph.add(new EndNode());
             AbstractEndNode newEnd = graph.add(new EndNode());
             merge.addForwardEnd(originalEnd);
@@ -346,7 +346,7 @@
 
             boolean newEarlyExitIsLoopExit = newEarlyExit instanceof LoopExitNode;
             for (ProxyNode vpn : loopEarlyExit.proxies().snapshot()) {
-                if (vpn.usages().isEmpty()) {
+                if (vpn.hasNoUsages()) {
                     continue;
                 }
                 final ValueNode replaceWith;
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java	Wed Jan 28 19:32:47 2015 +0100
@@ -89,13 +89,13 @@
 
         patchNodes(dataFixBefore);
 
-        BeginNode end = mergeEnds();
+        AbstractBeginNode end = mergeEnds();
 
         mergeEarlyExits();
 
         original().patchPeeling(this);
 
-        BeginNode entry = getDuplicatedNode(loop.loopBegin());
+        AbstractBeginNode entry = getDuplicatedNode(loop.loopBegin());
         loop.entryPoint().replaceAtPredecessor(entry);
         end.setNext(loop.entryPoint());
     }
@@ -152,7 +152,7 @@
                     if (value != null) {
                         return value;
                     }
-                    BeginNode newValue = graph.add(new BeginNode());
+                    AbstractBeginNode newValue = graph.add(new BeginNode());
                     seenNode.put(original, newValue);
                     return newValue;
                 }
@@ -161,7 +161,7 @@
                     if (value != null) {
                         return value;
                     }
-                    BeginNode newValue = graph.add(new BeginNode());
+                    AbstractBeginNode newValue = graph.add(new BeginNode());
                     seenNode.put(original, newValue);
                     return newValue;
                 }
@@ -184,7 +184,7 @@
         // TODO (gd) ?
     }
 
-    private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, MergeNode merge) {
+    private static PhiNode patchPhi(StructuredGraph graph, PhiNode phi, AbstractMergeNode merge) {
         PhiNode ret;
         if (phi instanceof ValuePhiNode) {
             ret = new ValuePhiNode(phi.stamp(), merge);
@@ -213,7 +213,7 @@
         markStateNodes(loopBegin, usagesToPatch);
 
         for (PhiNode phi : loopBegin.phis().snapshot()) {
-            if (phi.usages().isEmpty()) {
+            if (phi.hasNoUsages()) {
                 continue;
             }
             ValueNode first;
@@ -253,7 +253,7 @@
             }
         }
 
-        for (PhiNode deadPhi : loopBegin.phis().filter(n -> n.usages().isEmpty()).snapshot()) {
+        for (PhiNode deadPhi : loopBegin.phis().filter(n -> n.hasNoUsages()).snapshot()) {
             if (deadPhi.isAlive()) {
                 GraphUtil.killWithUnusedFloatingInputs(deadPhi);
             }
@@ -291,7 +291,7 @@
         }
     }
 
-    private BeginNode mergeEnds() {
+    private AbstractBeginNode mergeEnds() {
         assert isDuplicate();
         List<AbstractEndNode> endsToMerge = new LinkedList<>();
         // map peel exits to the corresponding loop exits
@@ -305,17 +305,17 @@
             }
         }
         mergedInitializers = Node.newIdentityMap();
-        BeginNode newExit;
+        AbstractBeginNode newExit;
         StructuredGraph graph = graph();
         if (endsToMerge.size() == 1) {
             AbstractEndNode end = endsToMerge.get(0);
-            assert end.usages().isEmpty();
+            assert end.hasNoUsages();
             newExit = graph.add(new BeginNode());
             end.replaceAtPredecessor(newExit);
             end.safeDelete();
         } else {
             assert endsToMerge.size() > 1;
-            MergeNode newExitMerge = graph.add(new MergeNode());
+            AbstractMergeNode newExitMerge = graph.add(new MergeNode());
             newExit = newExitMerge;
             FrameState state = loopBegin.stateAfter();
             FrameState duplicateState = null;
@@ -328,7 +328,7 @@
             }
 
             for (final PhiNode phi : loopBegin.phis().snapshot()) {
-                if (phi.usages().isEmpty()) {
+                if (phi.hasNoUsages()) {
                     continue;
                 }
                 final PhiNode firstPhi = patchPhi(graph, phi, newExitMerge);
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopPolicies.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopPolicies.java	Wed Jan 28 19:32:47 2015 +0100
@@ -70,9 +70,9 @@
         double maxProbability = 0;
         for (ControlSplitNode controlSplit : controlSplits) {
             Block postDomBlock = loop.loopsData().controlFlowGraph().blockFor(controlSplit).getPostdominator();
-            BeginNode postDom = postDomBlock != null ? postDomBlock.getBeginNode() : null;
+            AbstractBeginNode postDom = postDomBlock != null ? postDomBlock.getBeginNode() : null;
             for (Node successor : controlSplit.successors()) {
-                BeginNode branch = (BeginNode) successor;
+                AbstractBeginNode branch = (AbstractBeginNode) successor;
                 // this may count twice because of fall-through in switches
                 inBranchTotal += loop.nodesInLoopFrom(branch, postDom).count();
                 double probability = controlSplit.probability(branch);
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java	Wed Jan 28 19:32:47 2015 +0100
@@ -89,21 +89,21 @@
         assert successors.hasNext();
         // original loop is used as first successor
         Position firstPosition = successors.nextPosition();
-        BeginNode originalLoopBegin = BeginNode.begin(originalLoop.entryPoint());
+        AbstractBeginNode originalLoopBegin = BeginNode.begin(originalLoop.entryPoint());
         firstPosition.set(newControlSplit, originalLoopBegin);
 
         while (successors.hasNext()) {
             Position position = successors.nextPosition();
             // create a new loop duplicate and connect it.
             LoopFragmentWhole duplicateLoop = originalLoop.duplicate();
-            BeginNode newBegin = BeginNode.begin(duplicateLoop.entryPoint());
+            AbstractBeginNode newBegin = BeginNode.begin(duplicateLoop.entryPoint());
             position.set(newControlSplit, newBegin);
 
             // For each cloned ControlSplitNode, simplify the proper path
             for (ControlSplitNode controlSplitNode : controlSplitNodeSet) {
                 ControlSplitNode duplicatedControlSplit = duplicateLoop.getDuplicatedNode(controlSplitNode);
                 if (duplicatedControlSplit.isAlive()) {
-                    BeginNode survivingSuccessor = (BeginNode) position.get(duplicatedControlSplit);
+                    AbstractBeginNode survivingSuccessor = (AbstractBeginNode) position.get(duplicatedControlSplit);
                     survivingSuccessor.replaceAtUsages(InputType.Guard, newBegin);
                     graph.removeSplitPropagate(duplicatedControlSplit, survivingSuccessor);
                 }
@@ -112,7 +112,7 @@
         // original loop is simplified last to avoid deleting controlSplitNode too early
         for (ControlSplitNode controlSplitNode : controlSplitNodeSet) {
             if (controlSplitNode.isAlive()) {
-                BeginNode survivingSuccessor = (BeginNode) firstPosition.get(controlSplitNode);
+                AbstractBeginNode survivingSuccessor = (AbstractBeginNode) firstPosition.get(controlSplitNode);
                 survivingSuccessor.replaceAtUsages(InputType.Guard, originalLoopBegin);
                 graph.removeSplitPropagate(controlSplitNode, survivingSuccessor);
             }
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopTransformLowPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopTransformLowPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -86,7 +86,7 @@
             sb.append(controlSplit).append(" [");
             NodePosIterator it = controlSplit.successors().iterator();
             while (it.hasNext()) {
-                sb.append(controlSplit.probability((BeginNode) it.next()));
+                sb.append(controlSplit.probability((AbstractBeginNode) it.next()));
                 if (it.hasNext()) {
                     sb.append(", ");
                 }
--- a/graal/com.oracle.graal.nodeinfo.processor/src/com/oracle/graal/nodeinfo/processor/GraphNodeProcessor.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodeinfo.processor/src/com/oracle/graal/nodeinfo/processor/GraphNodeProcessor.java	Wed Jan 28 19:32:47 2015 +0100
@@ -126,12 +126,15 @@
 
                 TypeElement typeElement = (TypeElement) element;
 
-                if (typeElement.getModifiers().contains(Modifier.FINAL)) {
-                    errorMessage(element, "%s annotated class must not be final", NodeInfo.class.getSimpleName());
-                    continue;
+                Set<Modifier> modifiers = typeElement.getModifiers();
+                if (!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)) {
+                    // TODO(thomaswue): Reenable this check.
+                    // errorMessage(element, "%s annotated class must be either final or abstract",
+                    // NodeInfo.class.getSimpleName());
+                    // continue;
                 }
 
-                if (!typeElement.equals(verifier.Node) && !typeElement.getModifiers().contains(Modifier.ABSTRACT)) {
+                if (!typeElement.equals(verifier.Node) && !modifiers.contains(Modifier.ABSTRACT)) {
                     verifier.verify(typeElement);
                 }
             } catch (ElementException ee) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractBeginNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import static com.oracle.graal.graph.iterators.NodePredicates.*;
+
+import java.util.*;
+
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.iterators.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.util.*;
+
+@NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor})
+public abstract class AbstractBeginNode extends FixedWithNextNode implements LIRLowerable, Simplifiable, GuardingNode, AnchoringNode, IterableNodeType {
+
+    public AbstractBeginNode() {
+        super(StampFactory.forVoid());
+    }
+
+    public AbstractBeginNode(Stamp stamp) {
+        super(stamp);
+    }
+
+    @Override
+    public void simplify(SimplifierTool tool) {
+        FixedNode prev = (FixedNode) this.predecessor();
+        if (prev == null) {
+            // This is the start node.
+        } else if (prev instanceof ControlSplitNode) {
+            // This begin node is necessary.
+        } else {
+            // This begin node can be removed and all guards moved up to the preceding begin node.
+            prepareDelete();
+            tool.addToWorkList(next());
+            graph().removeFixed(this);
+        }
+    }
+
+    public static AbstractBeginNode prevBegin(FixedNode from) {
+        for (AbstractBeginNode begin : GraphUtil.predecessorIterable(from).filter(AbstractBeginNode.class)) {
+            return begin;
+        }
+        return null;
+    }
+
+    private void evacuateGuards(FixedNode evacuateFrom) {
+        if (!hasNoUsages()) {
+            AbstractBeginNode prevBegin = prevBegin(evacuateFrom);
+            assert prevBegin != null;
+            for (Node anchored : anchored().snapshot()) {
+                anchored.replaceFirstInput(this, prevBegin);
+            }
+        }
+    }
+
+    public void prepareDelete() {
+        prepareDelete((FixedNode) predecessor());
+    }
+
+    public void prepareDelete(FixedNode evacuateFrom) {
+        removeProxies();
+        evacuateGuards(evacuateFrom);
+    }
+
+    public void removeProxies() {
+        for (ProxyNode vpn : proxies().snapshot()) {
+            // can not use graph.replaceFloating because vpn.value may be null during killCFG
+            vpn.replaceAtUsages(vpn.value());
+            vpn.safeDelete();
+        }
+    }
+
+    @Override
+    public boolean verify() {
+        assertTrue(predecessor() != null || this == graph().start() || this instanceof AbstractMergeNode, "begin nodes must be connected");
+        return super.verify();
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        // nop
+    }
+
+    public NodeIterable<GuardNode> guards() {
+        return usages().filter(GuardNode.class);
+    }
+
+    public NodeIterable<Node> anchored() {
+        return usages().filter(isNotA(ProxyNode.class));
+    }
+
+    public NodeIterable<ProxyNode> proxies() {
+        return usages().filter(ProxyNode.class);
+    }
+
+    public NodeIterable<FixedNode> getBlockNodes() {
+        return new NodeIterable<FixedNode>() {
+
+            @Override
+            public Iterator<FixedNode> iterator() {
+                return new BlockNodeIterator(AbstractBeginNode.this);
+            }
+        };
+    }
+
+    private class BlockNodeIterator implements Iterator<FixedNode> {
+
+        private FixedNode current;
+
+        public BlockNodeIterator(FixedNode next) {
+            this.current = next;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return current != null;
+        }
+
+        @Override
+        public FixedNode next() {
+            FixedNode ret = current;
+            if (ret == null) {
+                throw new NoSuchElementException();
+            }
+            if (!(current instanceof FixedWithNextNode) || (current instanceof AbstractBeginNode && current != AbstractBeginNode.this)) {
+                current = null;
+            } else {
+                current = ((FixedWithNextNode) current).next();
+            }
+            return ret;
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractEndNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractEndNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,13 +41,13 @@
         gen.visitEndNode(this);
     }
 
-    public MergeNode merge() {
-        return (MergeNode) usages().first();
+    public AbstractMergeNode merge() {
+        return (AbstractMergeNode) usages().first();
     }
 
     @Override
     public boolean verify() {
-        assertTrue(usages().count() <= 1, "at most one usage");
+        assertTrue(getUsageCount() <= 1, "at most one usage");
         return super.verify();
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractFixedGuardNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -90,7 +90,7 @@
         DeoptimizeNode deopt = graph().add(new DeoptimizeNode(action, reason));
         deopt.setStateBefore(stateBefore());
         IfNode ifNode;
-        BeginNode noDeoptSuccessor;
+        AbstractBeginNode noDeoptSuccessor;
         if (negated) {
             ifNode = graph().add(new IfNode(condition, deopt, currentNext, 0));
             noDeoptSuccessor = ifNode.falseSuccessor();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/AbstractMergeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2009, 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;
+
+import static com.oracle.graal.graph.iterators.NodePredicates.*;
+
+import java.util.*;
+
+import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.iterators.*;
+import com.oracle.graal.graph.spi.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.util.*;
+
+/**
+ * Denotes the merging of multiple control-flow paths.
+ */
+@NodeInfo(allowedUsageTypes = {InputType.Association})
+public abstract class AbstractMergeNode extends BeginStateSplitNode implements IterableNodeType, LIRLowerable {
+    protected AbstractMergeNode() {
+    }
+
+    @Input(InputType.Association) protected NodeInputList<AbstractEndNode> ends = new NodeInputList<>(this);
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        gen.visitMerge(this);
+    }
+
+    public int forwardEndIndex(AbstractEndNode end) {
+        return ends.indexOf(end);
+    }
+
+    public void addForwardEnd(AbstractEndNode end) {
+        ends.add(end);
+    }
+
+    public int forwardEndCount() {
+        return ends.size();
+    }
+
+    public AbstractEndNode forwardEndAt(int index) {
+        return ends.get(index);
+    }
+
+    @Override
+    public NodeIterable<AbstractEndNode> cfgPredecessors() {
+        return ends;
+    }
+
+    /**
+     * 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}
+     */
+    public boolean isPhiAtMerge(Node value) {
+        return value instanceof PhiNode && ((PhiNode) value).merge() == this;
+    }
+
+    /**
+     * 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) {
+        int predIndex = phiPredecessorIndex(pred);
+        assert predIndex != -1;
+        deleteEnd(pred);
+        for (PhiNode phi : phis().snapshot()) {
+            if (phi.isDeleted()) {
+                continue;
+            }
+            ValueNode removedValue = phi.valueAt(predIndex);
+            phi.removeInput(predIndex);
+            if (removedValue != null && removedValue.isAlive() && removedValue.hasNoUsages() && GraphUtil.isFloatingNode().apply(removedValue)) {
+                GraphUtil.killWithUnusedFloatingInputs(removedValue);
+            }
+        }
+    }
+
+    protected void deleteEnd(AbstractEndNode end) {
+        ends.remove(end);
+    }
+
+    public void clearEnds() {
+        ends.clear();
+    }
+
+    public NodeInputList<AbstractEndNode> forwardEnds() {
+        return ends;
+    }
+
+    public int phiPredecessorCount() {
+        return forwardEndCount();
+    }
+
+    public int phiPredecessorIndex(AbstractEndNode pred) {
+        return forwardEndIndex(pred);
+    }
+
+    public AbstractEndNode phiPredecessorAt(int index) {
+        return forwardEndAt(index);
+    }
+
+    public NodeIterable<PhiNode> phis() {
+        return this.usages().filter(PhiNode.class).filter(this::isPhiAtMerge);
+    }
+
+    @Override
+    public NodeIterable<Node> anchored() {
+        return super.anchored().filter(n -> !isPhiAtMerge(n));
+    }
+
+    /**
+     * This simplify method can deal with a null value for tool, so that it can be used outside of
+     * canonicalization.
+     */
+    @Override
+    public void simplify(SimplifierTool tool) {
+        FixedNode currentNext = next();
+        if (currentNext instanceof AbstractEndNode) {
+            AbstractEndNode origLoopEnd = (AbstractEndNode) currentNext;
+            AbstractMergeNode merge = origLoopEnd.merge();
+            if (merge instanceof LoopBeginNode && !(origLoopEnd instanceof LoopEndNode)) {
+                return;
+            }
+            // in order to move anchored values to the other merge we would need to check if the
+            // anchors are used by phis of the other merge
+            if (this.anchored().isNotEmpty()) {
+                return;
+            }
+            if (merge.stateAfter() == null && this.stateAfter() != null) {
+                // We hold a state, but the succeeding merge does not => do not combine.
+                return;
+            }
+            for (PhiNode phi : phis()) {
+                if (phi.usages().filter(isNotA(VirtualState.class)).and(node -> !merge.isPhiAtMerge(node)).isNotEmpty()) {
+                    return;
+                }
+            }
+            Debug.log("Split %s into ends for %s.", this, merge);
+            int numEnds = this.forwardEndCount();
+            for (int i = 0; i < numEnds - 1; i++) {
+                AbstractEndNode end = forwardEndAt(numEnds - 1 - i);
+                if (tool != null) {
+                    tool.addToWorkList(end);
+                }
+                AbstractEndNode newEnd;
+                if (merge instanceof LoopBeginNode) {
+                    newEnd = graph().add(new LoopEndNode((LoopBeginNode) merge));
+                } else {
+                    newEnd = graph().add(new EndNode());
+                    merge.addForwardEnd(newEnd);
+                }
+                for (PhiNode phi : merge.phis()) {
+                    ValueNode v = phi.valueAt(origLoopEnd);
+                    ValueNode newInput;
+                    if (isPhiAtMerge(v)) {
+                        PhiNode endPhi = (PhiNode) v;
+                        newInput = endPhi.valueAt(end);
+                    } else {
+                        newInput = v;
+                    }
+                    phi.addInput(newInput);
+                }
+                this.removeEnd(end);
+                end.replaceAtPredecessor(newEnd);
+                end.safeDelete();
+                if (tool != null) {
+                    tool.addToWorkList(newEnd.predecessor());
+                }
+            }
+            graph().reduceTrivialMerge(this);
+        } else if (currentNext instanceof ReturnNode) {
+            ReturnNode returnNode = (ReturnNode) currentNext;
+            if (anchored().isNotEmpty() || returnNode.getMemoryMap() != null) {
+                return;
+            }
+            List<PhiNode> phis = phis().snapshot();
+            for (PhiNode phi : phis) {
+                for (Node usage : phi.usages().filter(isNotA(FrameState.class))) {
+                    if (usage != returnNode) {
+                        return;
+                    }
+                }
+            }
+
+            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)));
+                if (tool != null) {
+                    tool.addToWorkList(end.predecessor());
+                }
+                end.replaceAtPredecessor(newReturn);
+            }
+            GraphUtil.killCFG(this);
+            for (AbstractEndNode end : endNodes) {
+                end.safeDelete();
+            }
+            for (PhiNode phi : phis) {
+                if (phi.isAlive() && phi.hasNoUsages()) {
+                    GraphUtil.killWithUnusedFloatingInputs(phi);
+                }
+            }
+        }
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,21 +22,11 @@
  */
 package com.oracle.graal.nodes;
 
-import static com.oracle.graal.graph.iterators.NodePredicates.*;
-
-import java.util.*;
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.nodeinfo.*;
 
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.iterators.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.util.*;
-
-@NodeInfo(allowedUsageTypes = {InputType.Guard, InputType.Anchor})
-public class BeginNode extends FixedWithNextNode implements LIRLowerable, Simplifiable, GuardingNode, AnchoringNode, IterableNodeType {
+@NodeInfo
+public final class BeginNode extends AbstractBeginNode {
 
     public BeginNode() {
         super(StampFactory.forVoid());
@@ -46,127 +36,12 @@
         super(stamp);
     }
 
-    public static BeginNode begin(FixedNode with) {
-        if (with instanceof BeginNode) {
-            return (BeginNode) with;
+    public static AbstractBeginNode begin(FixedNode with) {
+        if (with instanceof AbstractBeginNode) {
+            return (AbstractBeginNode) with;
         }
         BeginNode begin = with.graph().add(new BeginNode());
         begin.setNext(with);
         return begin;
     }
-
-    @Override
-    public void simplify(SimplifierTool tool) {
-        FixedNode prev = (FixedNode) this.predecessor();
-        if (prev == null) {
-            // This is the start node.
-        } else if (prev instanceof ControlSplitNode) {
-            // This begin node is necessary.
-        } else {
-            // This begin node can be removed and all guards moved up to the preceding begin node.
-            prepareDelete();
-            tool.addToWorkList(next());
-            graph().removeFixed(this);
-        }
-    }
-
-    public static BeginNode prevBegin(FixedNode from) {
-        for (BeginNode begin : GraphUtil.predecessorIterable(from).filter(BeginNode.class)) {
-            return begin;
-        }
-        return null;
-    }
-
-    private void evacuateGuards(FixedNode evacuateFrom) {
-        if (!usages().isEmpty()) {
-            BeginNode prevBegin = prevBegin(evacuateFrom);
-            assert prevBegin != null;
-            for (Node anchored : anchored().snapshot()) {
-                anchored.replaceFirstInput(this, prevBegin);
-            }
-        }
-    }
-
-    public void prepareDelete() {
-        prepareDelete((FixedNode) predecessor());
-    }
-
-    public void prepareDelete(FixedNode evacuateFrom) {
-        removeProxies();
-        evacuateGuards(evacuateFrom);
-    }
-
-    public void removeProxies() {
-        for (ProxyNode vpn : proxies().snapshot()) {
-            // can not use graph.replaceFloating because vpn.value may be null during killCFG
-            vpn.replaceAtUsages(vpn.value());
-            vpn.safeDelete();
-        }
-    }
-
-    @Override
-    public boolean verify() {
-        assertTrue(predecessor() != null || this == graph().start() || this instanceof MergeNode, "begin nodes must be connected");
-        return super.verify();
-    }
-
-    @Override
-    public void generate(NodeLIRBuilderTool gen) {
-        // nop
-    }
-
-    public NodeIterable<GuardNode> guards() {
-        return usages().filter(GuardNode.class);
-    }
-
-    public NodeIterable<Node> anchored() {
-        return usages().filter(isNotA(ProxyNode.class));
-    }
-
-    public NodeIterable<ProxyNode> proxies() {
-        return usages().filter(ProxyNode.class);
-    }
-
-    public NodeIterable<FixedNode> getBlockNodes() {
-        return new NodeIterable<FixedNode>() {
-
-            @Override
-            public Iterator<FixedNode> iterator() {
-                return new BlockNodeIterator(BeginNode.this);
-            }
-        };
-    }
-
-    private class BlockNodeIterator implements Iterator<FixedNode> {
-
-        private FixedNode current;
-
-        public BlockNodeIterator(FixedNode next) {
-            this.current = next;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return current != null;
-        }
-
-        @Override
-        public FixedNode next() {
-            FixedNode ret = current;
-            if (ret == null) {
-                throw new NoSuchElementException();
-            }
-            if (!(current instanceof FixedWithNextNode) || (current instanceof BeginNode && current != BeginNode.this)) {
-                current = null;
-            } else {
-                current = ((FixedWithNextNode) current).next();
-            }
-            return ret;
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -26,14 +26,14 @@
 import com.oracle.graal.nodeinfo.*;
 
 /**
- * Base class for {@link BeginNode}s that are associated with a frame state.
+ * Base class for {@link AbstractBeginNode}s that are associated with a frame state.
  *
- * TODO (dnsimon) this not needed until {@link BeginNode} no longer implements {@link StateSplit}
- * which is not possible until loop peeling works without requiring begin nodes to have frames
- * states.
+ * TODO (dnsimon) this not needed until {@link AbstractBeginNode} no longer implements
+ * {@link StateSplit} which is not possible until loop peeling works without requiring begin nodes
+ * to have frames states.
  */
 @NodeInfo
-public abstract class BeginStateSplitNode extends BeginNode implements StateSplit {
+public abstract class BeginStateSplitNode extends AbstractBeginNode implements StateSplit {
 
     @OptionalInput(InputType.State) protected FrameState stateAfter;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BreakpointNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BreakpointNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -46,7 +46,7 @@
  * inspect in the native debugger when the breakpoint is hit.
  */
 @NodeInfo
-public class BreakpointNode extends FixedWithNextNode implements LIRLowerable {
+public final class BreakpointNode extends FixedWithNextNode implements LIRLowerable {
 
     @Input NodeInputList<ValueNode> arguments;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConditionAnchorNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConditionAnchorNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(nameTemplate = "ConditionAnchor(!={p#negated})", allowedUsageTypes = {InputType.Guard})
-public class ConditionAnchorNode extends FixedWithNextNode implements Canonicalizable.Unary<Node>, Lowerable, GuardingNode {
+public final class ConditionAnchorNode extends FixedWithNextNode implements Canonicalizable.Unary<Node>, Lowerable, GuardingNode {
 
     @Input(InputType.Condition) LogicNode condition;
     protected boolean negated;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ConstantNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
  * The {@code ConstantNode} represents a {@link Constant constant}.
  */
 @NodeInfo(shortName = "Const", nameTemplate = "Const({p#rawvalue})")
-public class ConstantNode extends FloatingNode implements LIRLowerable {
+public final class ConstantNode extends FloatingNode implements LIRLowerable {
 
     private static final DebugMetric ConstantNodes = Debug.metric("ConstantNodes");
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ControlSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ControlSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,5 +37,5 @@
         super(stamp);
     }
 
-    public abstract double probability(BeginNode successor);
+    public abstract double probability(AbstractBeginNode successor);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,7 +27,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(shortName = "Deopt", nameTemplate = "Deopt {p#reason/s}")
-public class DeoptimizeNode extends AbstractDeoptimizeNode implements Lowerable, LIRLowerable {
+public final class DeoptimizeNode extends AbstractDeoptimizeNode implements Lowerable, LIRLowerable {
 
     protected final DeoptimizationAction action;
     protected final DeoptimizationReason reason;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DynamicDeoptimizeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DynamicDeoptimizeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,7 +29,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class DynamicDeoptimizeNode extends AbstractDeoptimizeNode implements LIRLowerable, Lowerable, Canonicalizable {
+public final class DynamicDeoptimizeNode extends AbstractDeoptimizeNode implements LIRLowerable, Lowerable, Canonicalizable {
     @Input ValueNode actionAndReason;
     @Input ValueNode speculation;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EntryMarkerNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/EntryMarkerNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * by the graph builder.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Association})
-public class EntryMarkerNode extends BeginStateSplitNode implements IterableNodeType, Simplifiable, LIRLowerable {
+public final class EntryMarkerNode extends BeginStateSplitNode implements IterableNodeType, Simplifiable, LIRLowerable {
 
     public EntryMarkerNode() {
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(nameTemplate = "FixedGuard(!={p#negated}) {p#reason/s}", allowedUsageTypes = {InputType.Guard})
-public class FixedGuardNode extends AbstractFixedGuardNode implements Lowerable, IterableNodeType {
+public final class FixedGuardNode extends AbstractFixedGuardNode implements Lowerable, IterableNodeType {
 
     public FixedGuardNode(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action) {
         this(condition, deoptReason, action, false);
@@ -60,7 +60,7 @@
             graph().removeFixed(this);
         } else if (condition() instanceof ShortCircuitOrNode) {
             ShortCircuitOrNode shortCircuitOr = (ShortCircuitOrNode) condition();
-            if (isNegated() && usages().isEmpty()) {
+            if (isNegated() && hasNoUsages()) {
                 graph().addAfterFixed(this, graph().add(new FixedGuardNode(shortCircuitOr.getY(), getReason(), getAction(), !shortCircuitOr.isYNegated())));
                 graph().replaceFixedWithFixed(this, graph().add(new FixedGuardNode(shortCircuitOr.getX(), getReason(), getAction(), !shortCircuitOr.isXNegated())));
             }
@@ -69,7 +69,14 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
+        /*
+         * Don't allow guards with action None to float. In cases where 2 guards are testing
+         * equivalent conditions they might be lowered at the same location. If the guard with the
+         * None action is lowered before the the other guard then the code will be stuck repeatedly
+         * deoptimizing without invalidating the code. Conditional elimination will eliminate the
+         * guard if it's truly redundant in this case.
+         */
+        if (graph().getGuardsStage().allowsFloatingGuards() && getAction() != DeoptimizationAction.None) {
             ValueNode guard = tool.createGuard(this, condition(), getReason(), getAction(), isNegated()).asNode();
             this.replaceAtUsages(guard);
             ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode()));
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FrameState.java	Wed Jan 28 19:32:47 2015 +0100
@@ -65,7 +65,7 @@
 
     @OptionalInput(InputType.Association) NodeInputList<MonitorIdNode> monitorIds;
 
-    @Input(InputType.State) NodeInputList<EscapeObjectState> virtualObjectMappings;
+    @OptionalInput(InputType.State) NodeInputList<EscapeObjectState> virtualObjectMappings;
 
     /**
      * The bytecode index to which this frame state applies.
@@ -74,7 +74,7 @@
 
     protected final ResolvedJavaMethod method;
 
-    public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, List<ValueNode> values, int localsSize, int stackSize, boolean rethrowException, boolean duringCall,
+    public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, int localsSize, int stackSize, int lockSize, boolean rethrowException, boolean duringCall,
                     List<MonitorIdNode> monitorIds, List<EscapeObjectState> virtualObjectMappings) {
         assert stackSize >= 0;
         this.outerFrameState = outerFrameState;
@@ -82,41 +82,54 @@
         this.bci = bci;
         this.localsSize = localsSize;
         this.stackSize = stackSize;
-        this.values = new NodeInputList<>(this, values);
-        this.monitorIds = new NodeInputList<>(this, monitorIds);
-        this.virtualObjectMappings = new NodeInputList<>(this, virtualObjectMappings);
+        this.values = new NodeInputList<>(this, localsSize + stackSize + lockSize);
+
+        if (monitorIds != null && monitorIds.size() > 0) {
+            this.monitorIds = new NodeInputList<>(this, monitorIds);
+        }
+
+        if (virtualObjectMappings != null && virtualObjectMappings.size() > 0) {
+            this.virtualObjectMappings = new NodeInputList<>(this, virtualObjectMappings);
+        }
+
         this.rethrowException = rethrowException;
         this.duringCall = duringCall;
         assert !this.rethrowException || this.stackSize == 1 : "must have exception on top of the stack";
-        assert this.locksSize() == this.monitorIds.size();
+        assert this.locksSize() == this.monitorIdCount();
         METRIC_FRAMESTATE_COUNT.increment();
     }
 
+    public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, List<ValueNode> values, int localsSize, int stackSize, boolean rethrowException, boolean duringCall,
+                    List<MonitorIdNode> monitorIds, List<EscapeObjectState> virtualObjectMappings) {
+        this(outerFrameState, method, bci, localsSize, stackSize, values.size() - localsSize - stackSize, rethrowException, duringCall, monitorIds, virtualObjectMappings);
+        for (int i = 0; i < values.size(); ++i) {
+            this.values.initialize(i, values.get(i));
+        }
+    }
+
     public FrameState(int bci) {
-        this(null, null, bci, Collections.<ValueNode> emptyList(), 0, 0, false, false, Collections.<MonitorIdNode> emptyList(), Collections.<EscapeObjectState> emptyList());
+        this(null, null, bci, 0, 0, 0, false, false, null, Collections.<EscapeObjectState> emptyList());
         assert bci == BytecodeFrame.BEFORE_BCI || bci == BytecodeFrame.AFTER_BCI || bci == BytecodeFrame.AFTER_EXCEPTION_BCI || bci == BytecodeFrame.UNKNOWN_BCI ||
                         bci == BytecodeFrame.INVALID_FRAMESTATE_BCI;
     }
 
-    public FrameState(ResolvedJavaMethod method, int bci, ValueNode[] locals, List<ValueNode> stack, ValueNode[] locks, MonitorIdNode[] monitorIds, boolean rethrowException, boolean duringCall) {
-        this(null, method, bci, createValues(locals, stack, locks), locals.length, stack.size(), rethrowException, duringCall, Arrays.asList(monitorIds), Collections.<EscapeObjectState> emptyList());
+    public FrameState(FrameState outerFrameState, ResolvedJavaMethod method, int bci, ValueNode[] locals, ValueNode[] stack, int stackSize, ValueNode[] locks, List<MonitorIdNode> monitorIds,
+                    boolean rethrowException, boolean duringCall) {
+        this(outerFrameState, method, bci, locals.length, stackSize, locks.length, rethrowException, duringCall, monitorIds, Collections.<EscapeObjectState> emptyList());
+        createValues(locals, stack, locks);
     }
 
-    private static List<ValueNode> createValues(ValueNode[] locals, List<ValueNode> stack, ValueNode[] locks) {
-        List<ValueNode> newValues = new ArrayList<>(locals.length + stack.size() + locks.length);
-        for (ValueNode value : locals) {
-            newValues.add(value);
-            assert value == null || value.isAlive();
+    private void createValues(ValueNode[] locals, ValueNode[] stack, ValueNode[] locks) {
+        int index = 0;
+        for (int i = 0; i < locals.length; ++i) {
+            this.values.initialize(index++, locals[i]);
         }
-        for (ValueNode value : stack) {
-            newValues.add(value);
-            assert value == null || value.isAlive();
+        for (int i = 0; i < stackSize; ++i) {
+            this.values.initialize(index++, stack[i]);
         }
-        for (ValueNode value : locks) {
-            newValues.add(value);
-            assert value == null || value.isAlive();
+        for (int i = 0; i < locks.length; ++i) {
+            this.values.initialize(index++, locks[i]);
         }
-        return newValues;
     }
 
     public NodeInputList<ValueNode> values() {
@@ -152,10 +165,16 @@
     }
 
     public void addVirtualObjectMapping(EscapeObjectState virtualObject) {
+        if (virtualObjectMappings == null) {
+            virtualObjectMappings = new NodeInputList<>(this);
+        }
         virtualObjectMappings.add(virtualObject);
     }
 
     public int virtualObjectMappingCount() {
+        if (virtualObjectMappings == null) {
+            return 0;
+        }
         return virtualObjectMappings.size();
     }
 
@@ -191,9 +210,12 @@
         if (newOuterFrameState != null) {
             newOuterFrameState = newOuterFrameState.duplicateWithVirtualState();
         }
-        ArrayList<EscapeObjectState> newVirtualMappings = new ArrayList<>(virtualObjectMappings.size());
-        for (EscapeObjectState state : virtualObjectMappings) {
-            newVirtualMappings.add(state.duplicateWithVirtualState());
+        ArrayList<EscapeObjectState> newVirtualMappings = null;
+        if (virtualObjectMappings != null) {
+            newVirtualMappings = new ArrayList<>(virtualObjectMappings.size());
+            for (EscapeObjectState state : virtualObjectMappings) {
+                newVirtualMappings.add(state.duplicateWithVirtualState());
+            }
         }
         return graph().add(new FrameState(newOuterFrameState, method, bci, values, localsSize, stackSize, rethrowException, duringCall, monitorIds, newVirtualMappings));
     }
@@ -203,8 +225,8 @@
      * stack and the values in pushedValues pushed on the stack. The pushedValues will be formatted
      * correctly in slot encoding: a long or double will be followed by a null slot.
      */
-    public FrameState duplicateModifiedDuringCall(int newBci, Kind popKind, ValueNode... pushedValues) {
-        return duplicateModified(newBci, rethrowException, true, popKind, pushedValues);
+    public FrameState duplicateModifiedDuringCall(int newBci, Kind popKind) {
+        return duplicateModified(newBci, rethrowException, true, popKind);
     }
 
     public FrameState duplicateModified(int newBci, boolean newRethrowException, Kind popKind, ValueNode... pushedValues) {
@@ -238,7 +260,7 @@
         }
         for (ValueNode node : pushedValues) {
             copy.add(node);
-            if (node.getKind() == Kind.Long || node.getKind() == Kind.Double) {
+            if (node.getKind().needsTwoSlots()) {
                 copy.add(null);
             }
         }
@@ -260,6 +282,10 @@
          * mistakes.
          */
         byte[] codes = method.getCode();
+        if (codes == null) {
+            /* Graph was constructed manually. */
+            return true;
+        }
         byte newCode = codes[newBci];
         if (oldBci == newBci) {
             assert oldStackSize == newStackSize || oldDuringCall != newDuringCall : "bci is unchanged, stack depth shouldn't change";
@@ -341,10 +367,18 @@
      * Get the MonitorIdNode that corresponds to the locked object at the specified index.
      */
     public MonitorIdNode monitorIdAt(int i) {
-        assert i >= 0 && i < locksSize();
+        assert monitorIds != null && i >= 0 && i < locksSize();
         return monitorIds.get(i);
     }
 
+    public int monitorIdCount() {
+        if (monitorIds == null) {
+            return 0;
+        } else {
+            return monitorIds.size();
+        }
+    }
+
     public NodeIterable<FrameState> innerFrameStates() {
         return usages().filter(FrameState.class);
     }
@@ -414,7 +448,7 @@
 
     @Override
     public boolean verify() {
-        assertTrue(locksSize() == monitorIds.size(), "mismatch in number of locks");
+        assertTrue(locksSize() == monitorIdCount(), "mismatch in number of locks");
         for (ValueNode value : values) {
             assertTrue(value == null || !value.isDeleted(), "frame state must not contain deleted nodes");
             assertTrue(value == null || value instanceof VirtualObjectNode || (value.getKind() != Kind.Void), "unexpected value: %s", value);
@@ -424,17 +458,26 @@
 
     @Override
     public void applyToNonVirtual(NodeClosure<? super ValueNode> closure) {
-        for (ValueNode value : values.nonNull()) {
-            closure.apply(this, value);
-        }
-        for (MonitorIdNode monitorId : monitorIds) {
-            if (monitorId != null) {
-                closure.apply(this, monitorId);
+        for (ValueNode value : values) {
+            if (value != null) {
+                closure.apply(this, value);
             }
         }
-        for (EscapeObjectState state : virtualObjectMappings) {
-            state.applyToNonVirtual(closure);
+
+        if (monitorIds != null) {
+            for (MonitorIdNode monitorId : monitorIds) {
+                if (monitorId != null) {
+                    closure.apply(this, monitorId);
+                }
+            }
         }
+
+        if (virtualObjectMappings != null) {
+            for (EscapeObjectState state : virtualObjectMappings) {
+                state.applyToNonVirtual(closure);
+            }
+        }
+
         if (outerFrameState() != null) {
             outerFrameState().applyToNonVirtual(closure);
         }
@@ -443,8 +486,10 @@
     @Override
     public void applyToVirtual(VirtualClosure closure) {
         closure.apply(this);
-        for (EscapeObjectState state : virtualObjectMappings) {
-            state.applyToVirtual(closure);
+        if (virtualObjectMappings != null) {
+            for (EscapeObjectState state : virtualObjectMappings) {
+                state.applyToVirtual(closure);
+            }
         }
         if (outerFrameState() != null) {
             outerFrameState().applyToVirtual(closure);
@@ -459,9 +504,11 @@
         if (outerFrameState() != null && outerFrameState().isPartOfThisState(state)) {
             return true;
         }
-        for (EscapeObjectState objectState : virtualObjectMappings) {
-            if (objectState.isPartOfThisState(state)) {
-                return true;
+        if (virtualObjectMappings != null) {
+            for (EscapeObjectState objectState : virtualObjectMappings) {
+                if (objectState.isPartOfThisState(state)) {
+                    return true;
+                }
             }
         }
         return false;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardPhiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardPhiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,12 +35,12 @@
 
     @OptionalInput(InputType.Guard) NodeInputList<ValueNode> values;
 
-    public GuardPhiNode(MergeNode merge) {
+    public GuardPhiNode(AbstractMergeNode merge) {
         super(StampFactory.forVoid(), merge);
         this.values = new NodeInputList<>(this);
     }
 
-    public GuardPhiNode(MergeNode merge, ValueNode[] values) {
+    public GuardPhiNode(AbstractMergeNode merge, ValueNode[] values) {
         super(StampFactory.forVoid(), merge);
         this.values = new NodeInputList<>(this, values);
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardProxyNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardProxyNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 
     @Input(InputType.Guard) GuardingNode value;
 
-    public GuardProxyNode(GuardingNode value, BeginNode proxyPoint) {
+    public GuardProxyNode(GuardingNode value, AbstractBeginNode proxyPoint) {
         super(StampFactory.forVoid(), proxyPoint);
         this.value = value;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * 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, Canonicalizable, ValueProxy {
+public final class GuardingPiNode extends FixedWithNextNode implements Lowerable, Virtualizable, Canonicalizable, ValueProxy {
 
     @Input ValueNode object;
     @Input(InputType.Condition) LogicNode condition;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -51,8 +51,8 @@
 
     private static final DebugMetric CORRECTED_PROBABILITIES = Debug.metric("CorrectedProbabilities");
 
-    @Successor BeginNode trueSuccessor;
-    @Successor BeginNode falseSuccessor;
+    @Successor AbstractBeginNode trueSuccessor;
+    @Successor AbstractBeginNode falseSuccessor;
     @Input(InputType.Condition) LogicNode condition;
     protected double trueSuccessorProbability;
 
@@ -69,7 +69,7 @@
         this(condition, BeginNode.begin(trueSuccessor), BeginNode.begin(falseSuccessor), trueSuccessorProbability);
     }
 
-    public IfNode(LogicNode condition, BeginNode trueSuccessor, BeginNode falseSuccessor, double trueSuccessorProbability) {
+    public IfNode(LogicNode condition, AbstractBeginNode trueSuccessor, AbstractBeginNode falseSuccessor, double trueSuccessorProbability) {
         super(StampFactory.forVoid());
         this.condition = condition;
         this.falseSuccessor = falseSuccessor;
@@ -82,7 +82,7 @@
      *
      * @return the true successor
      */
-    public BeginNode trueSuccessor() {
+    public AbstractBeginNode trueSuccessor() {
         return trueSuccessor;
     }
 
@@ -91,16 +91,16 @@
      *
      * @return the false successor
      */
-    public BeginNode falseSuccessor() {
+    public AbstractBeginNode falseSuccessor() {
         return falseSuccessor;
     }
 
-    public void setTrueSuccessor(BeginNode node) {
+    public void setTrueSuccessor(AbstractBeginNode node) {
         updatePredecessor(trueSuccessor, node);
         trueSuccessor = node;
     }
 
-    public void setFalseSuccessor(BeginNode node) {
+    public void setFalseSuccessor(AbstractBeginNode node) {
         updatePredecessor(falseSuccessor, node);
         falseSuccessor = node;
     }
@@ -111,7 +111,7 @@
      * @param istrue {@code true} if the true successor is requested, {@code false} otherwise
      * @return the corresponding successor
      */
-    public BeginNode successor(boolean istrue) {
+    public AbstractBeginNode successor(boolean istrue) {
         return istrue ? trueSuccessor : falseSuccessor;
     }
 
@@ -121,7 +121,7 @@
     }
 
     @Override
-    public double probability(BeginNode successor) {
+    public double probability(AbstractBeginNode successor) {
         return successor == trueSuccessor ? trueSuccessorProbability : 1 - trueSuccessorProbability;
     }
 
@@ -153,8 +153,8 @@
         }
 
         if (condition() instanceof LogicNegationNode) {
-            BeginNode trueSucc = trueSuccessor();
-            BeginNode falseSucc = falseSuccessor();
+            AbstractBeginNode trueSucc = trueSuccessor();
+            AbstractBeginNode falseSucc = falseSuccessor();
             setTrueSuccessor(null);
             setFalseSuccessor(null);
             LogicNegationNode negation = (LogicNegationNode) condition();
@@ -176,7 +176,7 @@
             }
             return;
         }
-        if (trueSuccessor().usages().isEmpty() && falseSuccessor().usages().isEmpty()) {
+        if (trueSuccessor().hasNoUsages() && falseSuccessor().hasNoUsages()) {
 
             pushNodesThroughIf(tool);
 
@@ -189,8 +189,8 @@
             return;
         }
 
-        if (falseSuccessor().usages().isEmpty() && (!(falseSuccessor() instanceof LoopExitNode)) && falseSuccessor().next() instanceof IfNode) {
-            BeginNode intermediateBegin = falseSuccessor();
+        if (falseSuccessor().hasNoUsages() && (!(falseSuccessor() instanceof LoopExitNode)) && falseSuccessor().next() instanceof IfNode) {
+            AbstractBeginNode intermediateBegin = falseSuccessor();
             IfNode nextIf = (IfNode) intermediateBegin.next();
             double probabilityB = (1.0 - this.trueSuccessorProbability) * nextIf.trueSuccessorProbability;
             if (this.trueSuccessorProbability < probabilityB) {
@@ -199,7 +199,7 @@
                 if (prepareForSwap(tool.getConstantReflection(), condition(), nextIf.condition(), this.trueSuccessorProbability, probabilityB)) {
                     // Reordering is allowed from (if1 => begin => if2) to (if2 => begin => if1).
                     assert intermediateBegin.next() == nextIf;
-                    BeginNode bothFalseBegin = nextIf.falseSuccessor();
+                    AbstractBeginNode bothFalseBegin = nextIf.falseSuccessor();
                     nextIf.setFalseSuccessor(null);
                     intermediateBegin.setNext(null);
                     this.setFalseSuccessor(null);
@@ -222,12 +222,12 @@
     }
 
     private void pushNodesThroughIf(SimplifierTool tool) {
-        assert trueSuccessor().usages().isEmpty() && falseSuccessor().usages().isEmpty();
+        assert trueSuccessor().hasNoUsages() && falseSuccessor().hasNoUsages();
         // push similar nodes upwards through the if, thereby deduplicating them
         do {
-            BeginNode trueSucc = trueSuccessor();
-            BeginNode falseSucc = falseSuccessor();
-            if (trueSucc.getClass() == BeginNode.class && falseSucc.getClass() == BeginNode.class && trueSucc.next() instanceof FixedWithNextNode && falseSucc.next() instanceof FixedWithNextNode) {
+            AbstractBeginNode trueSucc = trueSuccessor();
+            AbstractBeginNode falseSucc = falseSuccessor();
+            if (trueSucc instanceof BeginNode && falseSucc instanceof BeginNode && trueSucc.next() instanceof FixedWithNextNode && falseSucc.next() instanceof FixedWithNextNode) {
                 FixedWithNextNode trueNext = (FixedWithNextNode) trueSucc.next();
                 FixedWithNextNode falseNext = (FixedWithNextNode) falseSucc.next();
                 NodeClass nodeClass = trueNext.getNodeClass();
@@ -267,7 +267,7 @@
      * @return true if a replacement was done.
      */
     private boolean checkForUnsignedCompare(SimplifierTool tool) {
-        assert trueSuccessor().usages().isEmpty() && falseSuccessor().usages().isEmpty();
+        assert trueSuccessor().hasNoUsages() && falseSuccessor().hasNoUsages();
         if (condition() instanceof IntegerLessThanNode) {
             IntegerLessThanNode lessThan = (IntegerLessThanNode) condition();
             Constant y = lessThan.getY().stamp().asConstant();
@@ -275,8 +275,8 @@
                 IfNode ifNode2 = (IfNode) falseSuccessor().next();
                 if (ifNode2.condition() instanceof IntegerLessThanNode) {
                     IntegerLessThanNode lessThan2 = (IntegerLessThanNode) ifNode2.condition();
-                    BeginNode falseSucc = ifNode2.falseSuccessor();
-                    BeginNode trueSucc = ifNode2.trueSuccessor();
+                    AbstractBeginNode falseSucc = ifNode2.falseSuccessor();
+                    AbstractBeginNode trueSucc = ifNode2.trueSuccessor();
                     IntegerBelowNode below = null;
                     /*
                      * Convert x >= 0 && x < positive which is represented as !(x < 0) && x <
@@ -286,7 +286,7 @@
                                     sameDestination(trueSuccessor(), ifNode2.falseSuccessor)) {
                         below = graph().unique(new IntegerBelowNode(lessThan2.getX(), lessThan2.getY()));
                         // swap direction
-                        BeginNode tmp = falseSucc;
+                        AbstractBeginNode tmp = falseSucc;
                         falseSucc = trueSucc;
                         trueSucc = tmp;
                     } else if (lessThan2.getY() == lessThan.getX() && sameDestination(trueSuccessor(), ifNode2.trueSuccessor)) {
@@ -326,7 +326,7 @@
      * Check it these two blocks end up at the same place. Meeting at the same merge, or
      * deoptimizing in the same way.
      */
-    private static boolean sameDestination(BeginNode succ1, BeginNode succ2) {
+    private static boolean sameDestination(AbstractBeginNode succ1, AbstractBeginNode succ2) {
         Node next1 = succ1.next();
         Node next2 = succ2.next();
         if (next1 instanceof EndNode && next2 instanceof EndNode) {
@@ -491,11 +491,11 @@
      * @return true if a transformation was made, false otherwise
      */
     private boolean removeOrMaterializeIf(SimplifierTool tool) {
-        assert trueSuccessor().usages().isEmpty() && falseSuccessor().usages().isEmpty();
+        assert trueSuccessor().hasNoUsages() && falseSuccessor().hasNoUsages();
         if (trueSuccessor().next() instanceof AbstractEndNode && falseSuccessor().next() instanceof AbstractEndNode) {
             AbstractEndNode trueEnd = (AbstractEndNode) trueSuccessor().next();
             AbstractEndNode falseEnd = (AbstractEndNode) falseSuccessor().next();
-            MergeNode merge = trueEnd.merge();
+            AbstractMergeNode merge = trueEnd.merge();
             if (merge == falseEnd.merge() && trueSuccessor().anchored().isEmpty() && falseSuccessor().anchored().isEmpty()) {
                 PhiNode singlePhi = null;
                 int distinct = 0;
@@ -552,7 +552,7 @@
     }
 
     protected void removeThroughFalseBranch(SimplifierTool tool) {
-        BeginNode trueBegin = trueSuccessor();
+        AbstractBeginNode trueBegin = trueSuccessor();
         graph().removeSplitPropagate(this, trueBegin, tool);
         tool.addToWorkList(trueBegin);
     }
@@ -647,17 +647,17 @@
      * @return true if a transformation was made, false otherwise
      */
     private boolean removeIntermediateMaterialization(SimplifierTool tool) {
-        if (!(predecessor() instanceof MergeNode) || predecessor() instanceof LoopBeginNode) {
+        if (!(predecessor() instanceof AbstractMergeNode) || predecessor() instanceof LoopBeginNode) {
             return false;
         }
-        MergeNode merge = (MergeNode) predecessor();
+        AbstractMergeNode merge = (AbstractMergeNode) predecessor();
 
         if (!(condition() instanceof CompareNode)) {
             return false;
         }
 
         CompareNode compare = (CompareNode) condition();
-        if (compare.usages().count() != 1) {
+        if (compare.getUsageCount() != 1) {
             return false;
         }
 
@@ -702,8 +702,8 @@
         List<AbstractEndNode> trueEnds = new ArrayList<>(mergePredecessors.size());
         Map<AbstractEndNode, ValueNode> phiValues = CollectionsFactory.newMap(mergePredecessors.size());
 
-        BeginNode oldFalseSuccessor = falseSuccessor();
-        BeginNode oldTrueSuccessor = trueSuccessor();
+        AbstractBeginNode oldFalseSuccessor = falseSuccessor();
+        AbstractBeginNode oldTrueSuccessor = trueSuccessor();
 
         setFalseSuccessor(null);
         setTrueSuccessor(null);
@@ -783,8 +783,8 @@
                 } else {
                     throw new GraalInternalError("Illegal state");
                 }
-            } else if (node instanceof MergeNode && !(node instanceof LoopBeginNode)) {
-                for (AbstractEndNode endNode : ((MergeNode) node).cfgPredecessors()) {
+            } else if (node instanceof AbstractMergeNode && !(node instanceof LoopBeginNode)) {
+                for (AbstractEndNode endNode : ((AbstractMergeNode) node).cfgPredecessors()) {
                     propagateZeroProbability(endNode);
                 }
                 return;
@@ -796,8 +796,8 @@
     private static boolean checkFrameState(FixedNode start) {
         FixedNode node = start;
         while (true) {
-            if (node instanceof MergeNode) {
-                MergeNode mergeNode = (MergeNode) node;
+            if (node instanceof AbstractMergeNode) {
+                AbstractMergeNode mergeNode = (AbstractMergeNode) node;
                 if (mergeNode.stateAfter() == null) {
                     return false;
                 } else {
@@ -840,7 +840,7 @@
      * @param oldMerge the merge being removed
      * @param phiValues the values of the phi at the merge, keyed by the merge ends
      */
-    private void connectEnds(List<AbstractEndNode> ends, Map<AbstractEndNode, ValueNode> phiValues, BeginNode successor, MergeNode oldMerge, SimplifierTool tool) {
+    private void connectEnds(List<AbstractEndNode> ends, Map<AbstractEndNode, ValueNode> phiValues, AbstractBeginNode successor, AbstractMergeNode oldMerge, SimplifierTool tool) {
         if (!ends.isEmpty()) {
             if (ends.size() == 1) {
                 AbstractEndNode end = ends.get(0);
@@ -850,7 +850,7 @@
             } else {
                 // Need a new phi in case the frame state is used by more than the merge being
                 // removed
-                MergeNode newMerge = graph().add(new MergeNode());
+                AbstractMergeNode newMerge = graph().add(new MergeNode());
                 PhiNode oldPhi = (PhiNode) oldMerge.usages().first();
                 PhiNode newPhi = graph().addWithoutUnique(new ValuePhiNode(oldPhi.stamp(), newMerge));
 
@@ -880,7 +880,7 @@
      * @return null if {@code node} is neither a {@link ConstantNode} nor a {@link PhiNode} whose
      *         input values are all constants
      */
-    public static Constant[] constantValues(ValueNode node, MergeNode merge, boolean allowNull) {
+    public static Constant[] constantValues(ValueNode node, AbstractMergeNode merge, boolean allowNull) {
         if (node.isConstant()) {
             JavaConstant[] result = new JavaConstant[merge.forwardEndCount()];
             Arrays.fill(result, node.asConstant());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -158,7 +158,7 @@
             graph().replaceFixed(this, node);
         }
         GraphUtil.killWithUnusedFloatingInputs(call);
-        if (currentStateAfter.usages().isEmpty()) {
+        if (currentStateAfter.hasNoUsages()) {
             GraphUtil.killWithUnusedFloatingInputs(currentStateAfter);
         }
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InvokeWithExceptionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,8 +37,8 @@
 
     private static final double EXCEPTION_PROBA = 1e-5;
 
-    @Successor BeginNode next;
-    @Successor BeginNode exceptionEdge;
+    @Successor AbstractBeginNode next;
+    @Successor AbstractBeginNode exceptionEdge;
     @Input(InputType.Extension) CallTargetNode callTarget;
     @OptionalInput(InputType.State) FrameState stateDuring;
     @OptionalInput(InputType.State) FrameState stateAfter;
@@ -48,7 +48,7 @@
     protected boolean useForInlining;
     protected double exceptionProbability;
 
-    public InvokeWithExceptionNode(CallTargetNode callTarget, BeginNode exceptionEdge, int bci) {
+    public InvokeWithExceptionNode(CallTargetNode callTarget, AbstractBeginNode exceptionEdge, int bci) {
         super(callTarget.returnStamp());
         this.exceptionEdge = exceptionEdge;
         this.bci = bci;
@@ -58,20 +58,20 @@
         this.exceptionProbability = EXCEPTION_PROBA;
     }
 
-    public BeginNode exceptionEdge() {
+    public AbstractBeginNode exceptionEdge() {
         return exceptionEdge;
     }
 
-    public void setExceptionEdge(BeginNode x) {
+    public void setExceptionEdge(AbstractBeginNode x) {
         updatePredecessor(exceptionEdge, x);
         exceptionEdge = x;
     }
 
-    public BeginNode next() {
+    public AbstractBeginNode next() {
         return next;
     }
 
-    public void setNext(BeginNode x) {
+    public void setNext(AbstractBeginNode x) {
         updatePredecessor(next, x);
         next = x;
     }
@@ -164,7 +164,7 @@
     }
 
     public void killExceptionEdge() {
-        BeginNode edge = exceptionEdge();
+        AbstractBeginNode edge = exceptionEdge();
         setExceptionEdge(null);
         GraphUtil.killCFG(edge);
     }
@@ -179,8 +179,12 @@
             StateSplit stateSplit = (StateSplit) node;
             stateSplit.setStateAfter(state);
         }
+        if (node instanceof ForeignCallNode) {
+            ForeignCallNode foreign = (ForeignCallNode) node;
+            foreign.setBci(bci());
+        }
         if (node == null) {
-            assert getKind() == Kind.Void && usages().isEmpty();
+            assert getKind() == Kind.Void && hasNoUsages();
             graph().removeSplit(this, next());
         } else if (node instanceof ControlSinkNode) {
             this.replaceAtPredecessor(node);
@@ -191,13 +195,13 @@
             graph().replaceSplit(this, node, next());
         }
         GraphUtil.killWithUnusedFloatingInputs(call);
-        if (state.usages().isEmpty()) {
+        if (state.hasNoUsages()) {
             GraphUtil.killWithUnusedFloatingInputs(state);
         }
     }
 
     @Override
-    public double probability(BeginNode successor) {
+    public double probability(AbstractBeginNode successor) {
         return successor == next ? 1 - exceptionProbability : exceptionProbability;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/KillingBeginNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/KillingBeginNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,7 +27,7 @@
 import com.oracle.graal.nodes.extended.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class KillingBeginNode extends BeginNode implements MemoryCheckpoint.Single {
+public class KillingBeginNode extends AbstractBeginNode implements MemoryCheckpoint.Single {
 
     protected LocationIdentity locationIdentity;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
 import com.oracle.graal.nodes.util.*;
 
 @NodeInfo
-public class LoopBeginNode extends MergeNode implements IterableNodeType, LIRLowerable {
+public class LoopBeginNode extends AbstractMergeNode implements IterableNodeType, LIRLowerable {
 
     protected double loopFrequency;
     protected int nextEndIndex;
@@ -183,7 +183,7 @@
         canonicalizePhis(tool);
     }
 
-    public boolean isLoopExit(BeginNode begin) {
+    public boolean isLoopExit(AbstractBeginNode begin) {
         return begin instanceof LoopExitNode && ((LoopExitNode) begin).loopBegin() == this;
     }
 
@@ -192,7 +192,7 @@
             loopexit.removeProxies();
             FrameState loopStateAfter = loopexit.stateAfter();
             graph().replaceFixedWithFixed(loopexit, graph().add(new BeginNode()));
-            if (loopStateAfter != null && loopStateAfter.isAlive() && loopStateAfter.usages().isEmpty()) {
+            if (loopStateAfter != null && loopStateAfter.isAlive() && loopStateAfter.hasNoUsages()) {
                 GraphUtil.killWithUnusedFloatingInputs(loopStateAfter);
             }
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopEndNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -44,7 +44,7 @@
     }
 
     @Override
-    public MergeNode merge() {
+    public AbstractMergeNode merge() {
         return loopBegin();
     }
 
@@ -74,14 +74,14 @@
     @Override
     public boolean verify() {
         assertTrue(loopBegin != null, "must have a loop begin");
-        assertTrue(usages().isEmpty(), "LoopEnds can not be used");
+        assertTrue(hasNoUsages(), "LoopEnds can not be used");
         return super.verify();
     }
 
     /**
      * 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.
+     * values at the loop begin. Use {@link AbstractMergeNode#phiPredecessorIndex(AbstractEndNode)}
+     * for this purpose.
      *
      * @return The 0-based index of this loop end.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopExitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopExitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -43,8 +43,8 @@
     @Override
     public void simplify(SimplifierTool tool) {
         Node prev = this.predecessor();
-        while (prev.getClass() == BeginNode.class && prev.usages().isEmpty()) {
-            BeginNode begin = (BeginNode) prev;
+        while (prev instanceof BeginNode && prev.hasNoUsages()) {
+            AbstractBeginNode begin = (AbstractBeginNode) prev;
             prev = prev.predecessor();
             graph().removeFixed(begin);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryMapNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(allowedUsageTypes = {InputType.Extension})
-public class MemoryMapNode extends FloatingNode implements MemoryMap, LIRLowerable {
+public final class MemoryMapNode extends FloatingNode implements MemoryMap, LIRLowerable {
 
     protected final List<LocationIdentity> locationIdentities;
     @Input(InputType.Memory) NodeInputList<ValueNode> nodes;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MemoryPhiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,18 +32,18 @@
  * Memory {@code PhiNode}s merge memory dependencies at control flow merges.
  */
 @NodeInfo(nameTemplate = "MemoryPhi({i#values}) {p#locationIdentity/s}", allowedUsageTypes = {InputType.Memory})
-public class MemoryPhiNode extends PhiNode implements MemoryNode {
+public final class MemoryPhiNode extends PhiNode implements MemoryNode {
 
     @Input(InputType.Memory) NodeInputList<ValueNode> values;
     protected final LocationIdentity locationIdentity;
 
-    public MemoryPhiNode(MergeNode merge, LocationIdentity locationIdentity) {
+    public MemoryPhiNode(AbstractMergeNode merge, LocationIdentity locationIdentity) {
         super(StampFactory.forVoid(), merge);
         this.locationIdentity = locationIdentity;
         this.values = new NodeInputList<>(this);
     }
 
-    public MemoryPhiNode(MergeNode merge, LocationIdentity locationIdentity, ValueNode[] values) {
+    public MemoryPhiNode(AbstractMergeNode merge, LocationIdentity locationIdentity, ValueNode[] values) {
         super(StampFactory.forVoid(), merge);
         this.locationIdentity = locationIdentity;
         this.values = new NodeInputList<>(this, values);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/MergeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,211 +22,13 @@
  */
 package com.oracle.graal.nodes;
 
-import static com.oracle.graal.graph.iterators.NodePredicates.*;
-
-import java.util.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.iterators.*;
-import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.util.*;
 
 /**
  * Denotes the merging of multiple control-flow paths.
  */
-@NodeInfo(allowedUsageTypes = {InputType.Association})
-public class MergeNode extends BeginStateSplitNode implements IterableNodeType, LIRLowerable {
+@NodeInfo
+public final class MergeNode extends AbstractMergeNode {
     public MergeNode() {
     }
-
-    @Input(InputType.Association) protected NodeInputList<AbstractEndNode> ends = new NodeInputList<>(this);
-
-    @Override
-    public void generate(NodeLIRBuilderTool gen) {
-        gen.visitMerge(this);
-    }
-
-    public int forwardEndIndex(AbstractEndNode end) {
-        return ends.indexOf(end);
-    }
-
-    public void addForwardEnd(AbstractEndNode end) {
-        ends.add(end);
-    }
-
-    public int forwardEndCount() {
-        return ends.size();
-    }
-
-    public AbstractEndNode forwardEndAt(int index) {
-        return ends.get(index);
-    }
-
-    @Override
-    public NodeIterable<AbstractEndNode> cfgPredecessors() {
-        return ends;
-    }
-
-    /**
-     * 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}
-     */
-    public boolean isPhiAtMerge(Node value) {
-        return value instanceof PhiNode && ((PhiNode) value).merge() == this;
-    }
-
-    /**
-     * 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) {
-        int predIndex = phiPredecessorIndex(pred);
-        assert predIndex != -1;
-        deleteEnd(pred);
-        for (PhiNode phi : phis().snapshot()) {
-            if (phi.isDeleted()) {
-                continue;
-            }
-            ValueNode removedValue = phi.valueAt(predIndex);
-            phi.removeInput(predIndex);
-            if (removedValue != null && removedValue.isAlive() && removedValue.usages().isEmpty() && GraphUtil.isFloatingNode().apply(removedValue)) {
-                GraphUtil.killWithUnusedFloatingInputs(removedValue);
-            }
-        }
-    }
-
-    protected void deleteEnd(AbstractEndNode end) {
-        ends.remove(end);
-    }
-
-    public void clearEnds() {
-        ends.clear();
-    }
-
-    public NodeInputList<AbstractEndNode> forwardEnds() {
-        return ends;
-    }
-
-    public int phiPredecessorCount() {
-        return forwardEndCount();
-    }
-
-    public int phiPredecessorIndex(AbstractEndNode pred) {
-        return forwardEndIndex(pred);
-    }
-
-    public AbstractEndNode phiPredecessorAt(int index) {
-        return forwardEndAt(index);
-    }
-
-    public NodeIterable<PhiNode> phis() {
-        return this.usages().filter(PhiNode.class).filter(this::isPhiAtMerge);
-    }
-
-    @Override
-    public NodeIterable<Node> anchored() {
-        return super.anchored().filter(n -> !isPhiAtMerge(n));
-    }
-
-    /**
-     * This simplify method can deal with a null value for tool, so that it can be used outside of
-     * canonicalization.
-     */
-    @Override
-    public void simplify(SimplifierTool tool) {
-        FixedNode currentNext = next();
-        if (currentNext instanceof AbstractEndNode) {
-            AbstractEndNode origLoopEnd = (AbstractEndNode) currentNext;
-            MergeNode merge = origLoopEnd.merge();
-            if (merge instanceof LoopBeginNode && !(origLoopEnd instanceof LoopEndNode)) {
-                return;
-            }
-            // in order to move anchored values to the other merge we would need to check if the
-            // anchors are used by phis of the other merge
-            if (this.anchored().isNotEmpty()) {
-                return;
-            }
-            if (merge.stateAfter() == null && this.stateAfter() != null) {
-                // We hold a state, but the succeeding merge does not => do not combine.
-                return;
-            }
-            for (PhiNode phi : phis()) {
-                if (phi.usages().filter(isNotA(VirtualState.class)).and(node -> !merge.isPhiAtMerge(node)).isNotEmpty()) {
-                    return;
-                }
-            }
-            Debug.log("Split %s into ends for %s.", this, merge);
-            int numEnds = this.forwardEndCount();
-            for (int i = 0; i < numEnds - 1; i++) {
-                AbstractEndNode end = forwardEndAt(numEnds - 1 - i);
-                if (tool != null) {
-                    tool.addToWorkList(end);
-                }
-                AbstractEndNode newEnd;
-                if (merge instanceof LoopBeginNode) {
-                    newEnd = graph().add(new LoopEndNode((LoopBeginNode) merge));
-                } else {
-                    newEnd = graph().add(new EndNode());
-                    merge.addForwardEnd(newEnd);
-                }
-                for (PhiNode phi : merge.phis()) {
-                    ValueNode v = phi.valueAt(origLoopEnd);
-                    ValueNode newInput;
-                    if (isPhiAtMerge(v)) {
-                        PhiNode endPhi = (PhiNode) v;
-                        newInput = endPhi.valueAt(end);
-                    } else {
-                        newInput = v;
-                    }
-                    phi.addInput(newInput);
-                }
-                this.removeEnd(end);
-                end.replaceAtPredecessor(newEnd);
-                end.safeDelete();
-                if (tool != null) {
-                    tool.addToWorkList(newEnd.predecessor());
-                }
-            }
-            graph().reduceTrivialMerge(this);
-        } else if (currentNext instanceof ReturnNode) {
-            ReturnNode returnNode = (ReturnNode) currentNext;
-            if (anchored().isNotEmpty() || returnNode.getMemoryMap() != null) {
-                return;
-            }
-            List<PhiNode> phis = phis().snapshot();
-            for (PhiNode phi : phis) {
-                for (Node usage : phi.usages().filter(isNotA(FrameState.class))) {
-                    if (usage != returnNode) {
-                        return;
-                    }
-                }
-            }
-
-            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)));
-                if (tool != null) {
-                    tool.addToWorkList(end.predecessor());
-                }
-                end.replaceAtPredecessor(newReturn);
-            }
-            GraphUtil.killCFG(this);
-            for (AbstractEndNode end : endNodes) {
-                end.safeDelete();
-            }
-            for (PhiNode phi : phis) {
-                if (phi.isAlive() && phi.usages().isEmpty()) {
-                    GraphUtil.killWithUnusedFloatingInputs(phi);
-                }
-            }
-        }
-    }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,28 +32,29 @@
 import com.oracle.graal.nodes.calc.*;
 
 /**
- * {@code PhiNode}s represent the merging of edges at a control flow merges ({@link MergeNode} or
- * {@link LoopBeginNode}). For a {@link MergeNode}, the order of the values corresponds to the order
- * of the ends. For {@link LoopBeginNode}s, the first value corresponds to the loop's predecessor,
- * while the rest of the values correspond to the {@link LoopEndNode}s.
+ * {@code PhiNode}s represent the merging of edges at a control flow merges (
+ * {@link AbstractMergeNode} or {@link LoopBeginNode}). For a {@link AbstractMergeNode}, the order
+ * of the values corresponds to the order of the ends. For {@link LoopBeginNode}s, the first value
+ * corresponds to the loop's predecessor, while the rest of the values correspond to the
+ * {@link LoopEndNode}s.
  */
 @NodeInfo
 public abstract class PhiNode extends FloatingNode implements Simplifiable {
 
-    @Input(InputType.Association) protected MergeNode merge;
+    @Input(InputType.Association) protected AbstractMergeNode merge;
 
-    protected PhiNode(Stamp stamp, MergeNode merge) {
+    protected PhiNode(Stamp stamp, AbstractMergeNode merge) {
         super(stamp);
         this.merge = merge;
     }
 
     public abstract NodeInputList<ValueNode> values();
 
-    public MergeNode merge() {
+    public AbstractMergeNode merge() {
         return merge;
     }
 
-    public void setMerge(MergeNode x) {
+    public void setMerge(AbstractMergeNode x) {
         updateUsages(merge, x);
         merge = x;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ProxyNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,9 +36,9 @@
 @NodeInfo
 public abstract class ProxyNode extends FloatingNode implements IterableNodeType, ValueNumberable {
 
-    @Input(InputType.Association) BeginNode proxyPoint;
+    @Input(InputType.Association) AbstractBeginNode proxyPoint;
 
-    public ProxyNode(Stamp stamp, BeginNode proxyPoint) {
+    public ProxyNode(Stamp stamp, AbstractBeginNode proxyPoint) {
         super(stamp);
         assert proxyPoint != null;
         this.proxyPoint = proxyPoint;
@@ -46,7 +46,7 @@
 
     public abstract ValueNode value();
 
-    public BeginNode proxyPoint() {
+    public AbstractBeginNode proxyPoint() {
         return proxyPoint;
     }
 
@@ -58,11 +58,11 @@
         return super.verify();
     }
 
-    public static ValueProxyNode forValue(ValueNode value, BeginNode exit, StructuredGraph graph) {
+    public static ValueProxyNode forValue(ValueNode value, AbstractBeginNode exit, StructuredGraph graph) {
         return graph.unique(new ValueProxyNode(value, exit));
     }
 
-    public static GuardProxyNode forGuard(GuardingNode value, BeginNode exit, StructuredGraph graph) {
+    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/ScheduledNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, 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.nodeinfo.*;
-
-@NodeInfo
-public abstract class ScheduledNode extends Node {
-
-    @Override
-    public StructuredGraph graph() {
-        return (StructuredGraph) super.graph();
-    }
-}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Wed Jan 28 19:32:47 2015 +0100
@@ -65,7 +65,19 @@
          * introduced any more. {@link FrameState} nodes are now associated with
          * {@link DeoptimizingNode} nodes.
          */
-        AFTER_FSA
+        AFTER_FSA;
+
+        public boolean allowsFloatingGuards() {
+            return this == FLOATING_GUARDS;
+        }
+
+        public boolean areFrameStatesAtDeopts() {
+            return this == AFTER_FSA;
+        }
+
+        public boolean areFrameStatesAtSideEffects() {
+            return !this.areFrameStatesAtDeopts();
+        }
     }
 
     public static final int INVOCATION_ENTRY_BCI = -1;
@@ -82,14 +94,16 @@
     private boolean hasValueProxies = true;
 
     /**
-     * Creates a new Graph containing a single {@link BeginNode} as the {@link #start() start} node.
+     * Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
+     * start} node.
      */
     public StructuredGraph() {
         this(null, null);
     }
 
     /**
-     * Creates a new Graph containing a single {@link BeginNode} as the {@link #start() start} node.
+     * Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
+     * start} node.
      */
     public StructuredGraph(String name, ResolvedJavaMethod method) {
         this(name, method, uniqueGraphIds.incrementAndGet(), INVOCATION_ENTRY_BCI);
@@ -273,10 +287,10 @@
      */
     public void removeFixed(FixedWithNextNode node) {
         assert node != null;
-        if (node instanceof BeginNode) {
-            ((BeginNode) node).prepareDelete();
+        if (node instanceof AbstractBeginNode) {
+            ((AbstractBeginNode) node).prepareDelete();
         }
-        assert node.usages().isEmpty() : node + " " + node.usages();
+        assert node.hasNoUsages() : node + " " + node.usages();
         GraphUtil.unlinkFixedNode(node);
         node.safeDelete();
     }
@@ -309,22 +323,22 @@
         node.safeDelete();
     }
 
-    public void removeSplit(ControlSplitNode node, BeginNode survivingSuccessor) {
+    public void removeSplit(ControlSplitNode node, AbstractBeginNode survivingSuccessor) {
         assert node != null;
-        assert node.usages().isEmpty();
+        assert node.hasNoUsages();
         assert survivingSuccessor != null;
         node.clearSuccessors();
         node.replaceAtPredecessor(survivingSuccessor);
         node.safeDelete();
     }
 
-    public void removeSplitPropagate(ControlSplitNode node, BeginNode survivingSuccessor) {
+    public void removeSplitPropagate(ControlSplitNode node, AbstractBeginNode survivingSuccessor) {
         removeSplitPropagate(node, survivingSuccessor, null);
     }
 
-    public void removeSplitPropagate(ControlSplitNode node, BeginNode survivingSuccessor, SimplifierTool tool) {
+    public void removeSplitPropagate(ControlSplitNode node, AbstractBeginNode survivingSuccessor, SimplifierTool tool) {
         assert node != null;
-        assert node.usages().isEmpty();
+        assert node.hasNoUsages();
         assert survivingSuccessor != null;
         List<Node> snapshot = node.successors().snapshot();
         node.clearSuccessors();
@@ -339,7 +353,7 @@
         }
     }
 
-    public void replaceSplit(ControlSplitNode node, Node replacement, BeginNode survivingSuccessor) {
+    public void replaceSplit(ControlSplitNode node, Node replacement, AbstractBeginNode survivingSuccessor) {
         if (replacement instanceof FixedWithNextNode) {
             replaceSplitWithFixed(node, (FixedWithNextNode) replacement, survivingSuccessor);
         } else {
@@ -349,7 +363,7 @@
         }
     }
 
-    public void replaceSplitWithFixed(ControlSplitNode node, FixedWithNextNode replacement, BeginNode survivingSuccessor) {
+    public void replaceSplitWithFixed(ControlSplitNode node, FixedWithNextNode replacement, AbstractBeginNode survivingSuccessor) {
         assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement;
         assert survivingSuccessor != null;
         node.clearSuccessors();
@@ -357,7 +371,7 @@
         node.replaceAndDelete(replacement);
     }
 
-    public void replaceSplitWithFloating(ControlSplitNode node, FloatingNode replacement, BeginNode survivingSuccessor) {
+    public void replaceSplitWithFloating(ControlSplitNode node, FloatingNode replacement, AbstractBeginNode survivingSuccessor) {
         assert node != null && replacement != null && node.isAlive() && replacement.isAlive() : "cannot replace " + node + " with " + replacement;
         assert survivingSuccessor != null;
         node.clearSuccessors();
@@ -392,12 +406,12 @@
         if (begin.forwardEndCount() == 1) { // bypass merge and remove
             reduceTrivialMerge(begin);
         } else { // convert to merge
-            MergeNode merge = this.add(new MergeNode());
+            AbstractMergeNode merge = this.add(new MergeNode());
             this.replaceFixedWithFixed(begin, merge);
         }
     }
 
-    public void reduceTrivialMerge(MergeNode merge) {
+    public void reduceTrivialMerge(AbstractMergeNode merge) {
         assert merge.forwardEndCount() == 1;
         assert !(merge instanceof LoopBeginNode) || ((LoopBeginNode) merge).loopEnds().isEmpty();
         for (PhiNode phi : merge.phis().snapshot()) {
@@ -416,7 +430,7 @@
         // evacuateGuards
         merge.prepareDelete((FixedNode) singleEnd.predecessor());
         merge.safeDelete();
-        if (stateAfter != null && stateAfter.isAlive() && stateAfter.usages().isEmpty()) {
+        if (stateAfter != null && stateAfter.isAlive() && stateAfter.hasNoUsages()) {
             GraphUtil.killWithUnusedFloatingInputs(stateAfter);
         }
         if (sux == null) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
  * instructions.
  */
 @NodeInfo
-public abstract class ValueNode extends ScheduledNode implements KindProvider {
+public abstract class ValueNode extends com.oracle.graal.graph.Node implements KindProvider {
 
     /**
      * The kind of this value. This is {@link Kind#Void} for instructions that produce no value.
@@ -48,10 +48,15 @@
         return stamp;
     }
 
-    public void setStamp(Stamp stamp) {
+    public final void setStamp(Stamp stamp) {
         this.stamp = stamp;
     }
 
+    @Override
+    public final StructuredGraph graph() {
+        return (StructuredGraph) super.graph();
+    }
+
     /**
      * 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
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValuePhiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,13 +35,13 @@
 
     @Input protected NodeInputList<ValueNode> values;
 
-    public ValuePhiNode(Stamp stamp, MergeNode merge) {
+    public ValuePhiNode(Stamp stamp, AbstractMergeNode merge) {
         super(stamp, merge);
         assert stamp != StampFactory.forVoid();
         values = new NodeInputList<>(this);
     }
 
-    public ValuePhiNode(Stamp stamp, MergeNode merge, ValueNode[] values) {
+    public ValuePhiNode(Stamp stamp, AbstractMergeNode merge, ValueNode[] values) {
         super(stamp, merge);
         assert stamp != StampFactory.forVoid();
         this.values = new NodeInputList<>(this, values);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/ValueProxyNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
 
     @Input ValueNode value;
 
-    public ValueProxyNode(ValueNode value, BeginNode proxyPoint) {
+    public ValueProxyNode(ValueNode value, AbstractBeginNode proxyPoint) {
         super(value.stamp(), proxyPoint);
         this.value = value;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/VirtualState.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,9 +32,9 @@
 @NodeInfo(allowedUsageTypes = {InputType.State})
 public abstract class VirtualState extends Node {
 
-    public interface NodeClosure<T extends Node> {
+    public abstract static class NodeClosure<T extends Node> {
 
-        void apply(Node usage, T node);
+        public abstract void apply(Node usage, T node);
     }
 
     public interface VirtualClosure {
@@ -54,4 +54,9 @@
 
     public abstract boolean isPartOfThisState(VirtualState state);
 
+    @Override
+    public final StructuredGraph graph() {
+        return (StructuredGraph) super.graph();
+    }
+
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AbsNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AbsNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * Absolute value.
  */
 @NodeInfo
-public class AbsNode extends UnaryArithmeticNode<Abs> implements ArithmeticLIRLowerable, NarrowableArithmeticNode {
+public final class AbsNode extends UnaryArithmeticNode<Abs> implements ArithmeticLIRLowerable, NarrowableArithmeticNode {
 
     public AbsNode(ValueNode x) {
         super(ArithmeticOpTable::getAbs, x);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
 import com.oracle.graal.nodes.util.*;
 
 @NodeInfo(shortName = "&")
-public class AndNode extends BinaryArithmeticNode<And> implements NarrowableArithmeticNode {
+public final class AndNode extends BinaryArithmeticNode<And> implements NarrowableArithmeticNode {
 
     public AndNode(ValueNode x, ValueNode y) {
         super(ArithmeticOpTable::getAnd, x, y);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConditionalNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
  * that these nodes are not built directly from the bytecode but are introduced by canonicalization.
  */
 @NodeInfo
-public class ConditionalNode extends FloatingNode implements Canonicalizable, LIRLowerable {
+public final class ConditionalNode extends FloatingNode implements Canonicalizable, LIRLowerable {
 
     @Input(InputType.Condition) LogicNode condition;
     @Input ValueNode trueValue;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/DivNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/DivNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(shortName = "/")
-public class DivNode extends BinaryArithmeticNode<Div> {
+public final class DivNode extends BinaryArithmeticNode<Div> {
 
     public DivNode(ValueNode x, ValueNode y) {
         super(ArithmeticOpTable::getDiv, x, y);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatConvertNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * semantics.
  */
 @NodeInfo
-public class FloatConvertNode extends UnaryArithmeticNode<FloatConvertOp> implements ConvertNode, Lowerable, ArithmeticLIRLowerable {
+public final class FloatConvertNode extends UnaryArithmeticNode<FloatConvertOp> implements ConvertNode, Lowerable, ArithmeticLIRLowerable {
 
     protected final FloatConvert op;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
  * The {@code NarrowNode} converts an integer to a narrower integer.
  */
 @NodeInfo
-public class NarrowNode extends IntegerConvertNode<Narrow, SignExtend> {
+public final class NarrowNode extends IntegerConvertNode<Narrow, SignExtend> {
 
     public NarrowNode(ValueNode input, int resultBits) {
         this(input, PrimitiveStamp.getBits(input.stamp()), resultBits);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NegateNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * The {@code NegateNode} node negates its operand.
  */
 @NodeInfo
-public class NegateNode extends UnaryArithmeticNode<Neg> implements NarrowableArithmeticNode {
+public final class NegateNode extends UnaryArithmeticNode<Neg> implements NarrowableArithmeticNode {
 
     public NegateNode(ValueNode value) {
         super(ArithmeticOpTable::getNeg, value);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 
 public final class Block extends AbstractBlockBase<Block> {
 
-    protected final BeginNode beginNode;
+    protected final AbstractBeginNode beginNode;
 
     protected FixedNode endNode;
 
@@ -39,11 +39,11 @@
 
     protected Block postdominator;
 
-    protected Block(BeginNode node) {
+    protected Block(AbstractBeginNode node) {
         this.beginNode = node;
     }
 
-    public BeginNode getBeginNode() {
+    public AbstractBeginNode getBeginNode() {
         return beginNode;
     }
 
@@ -122,7 +122,7 @@
             } else {
                 cur = ((FixedWithNextNode) cur).next();
             }
-            assert !(cur instanceof BeginNode);
+            assert !(cur instanceof AbstractBeginNode);
             return result;
         }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java	Wed Jan 28 19:32:47 2015 +0100
@@ -130,7 +130,7 @@
         Node last;
 
         // assign proxies of a loop exit to this block
-        if (cur instanceof BeginNode) {
+        if (cur instanceof AbstractBeginNode) {
             for (Node usage : cur.usages()) {
                 if (usage instanceof ProxyNode) {
                     nodeToBlock.set(usage, block);
@@ -143,15 +143,15 @@
 
             assert nodeToBlock.get(cur) == null;
             nodeToBlock.set(cur, block);
-            if (cur instanceof MergeNode) {
-                for (PhiNode phi : ((MergeNode) cur).phis()) {
+            if (cur instanceof AbstractMergeNode) {
+                for (PhiNode phi : ((AbstractMergeNode) cur).phis()) {
                     nodeToBlock.set(phi, block);
                 }
             }
 
             last = cur;
             cur = cur.successors().first();
-        } while (cur != null && !(cur instanceof BeginNode));
+        } while (cur != null && !(cur instanceof AbstractBeginNode));
 
         block.endNode = (FixedNode) last;
     }
@@ -159,7 +159,7 @@
     private void identifyBlocks() {
         // Find all block headers
         int numBlocks = 0;
-        for (BeginNode begin : graph.getNodes(BeginNode.class)) {
+        for (AbstractBeginNode begin : graph.getNodes(AbstractBeginNode.class)) {
             Block block = new Block(begin);
             numBlocks++;
             identifyBlock(block);
@@ -222,6 +222,7 @@
                 probability *= loopBegin.loopFrequency();
                 for (LoopEndNode predNode : loopBegin.orderedLoopEnds()) {
                     Block predBlock = nodeToBlock.get(predNode);
+                    assert predBlock != null : predNode;
                     if (predBlock.getId() >= 0) {
                         predecessors.add(predBlock);
                     }
@@ -251,7 +252,7 @@
     private void computeLoopInformation() {
         loops = new ArrayList<>();
         for (Block block : reversePostOrder) {
-            Node beginNode = block.getBeginNode();
+            AbstractBeginNode beginNode = block.getBeginNode();
             if (beginNode instanceof LoopBeginNode) {
                 Loop<Block> loop = new HIRLoop(block.getLoop(), loops.size(), block);
                 loops.add(loop);
@@ -272,7 +273,7 @@
                 for (Block b : loop.getBlocks()) {
                     for (Block sux : b.getSuccessors()) {
                         if (sux.loop != loop) {
-                            BeginNode begin = sux.getBeginNode();
+                            AbstractBeginNode begin = sux.getBeginNode();
                             if (!(begin instanceof LoopExitNode && ((LoopExitNode) begin).loopBegin() == loopBegin)) {
                                 Debug.log("Unexpected loop exit with %s, including whole branch in the loop", sux);
                                 unexpected.add(sux);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/WeakCounterNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/debug/WeakCounterNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -45,7 +45,7 @@
 
     @Override
     public void simplify(SimplifierTool tool) {
-        if (checkedValue instanceof FloatingNode && checkedValue.usages().count() == 1) {
+        if (checkedValue instanceof FloatingNode && checkedValue.getUsageCount() == 1) {
             tool.addToWorkList(checkedValue);
             graph().removeFixed(this);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * [(base + x) + y] where base is a node and x and y are location nodes.
  */
 @NodeInfo(nameTemplate = "AddLoc {p#locationIdentity/s}")
-public class AddLocationNode extends LocationNode implements Canonicalizable.Binary<LocationNode> {
+public final class AddLocationNode extends LocationNode implements Canonicalizable.Binary<LocationNode> {
 
     @Input(InputType.Association) ValueNode x;
     @Input(InputType.Association) ValueNode y;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BoxNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,7 +40,7 @@
  * methods in Integer, Long, etc.
  */
 @NodeInfo
-public class BoxNode extends UnaryNode implements VirtualizableAllocation, Lowerable {
+public final class BoxNode extends UnaryNode implements VirtualizableAllocation, Lowerable {
 
     protected final Kind boxingKind;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BranchProbabilityNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * intended primarily for snippets, so that they can define their fast and slow paths.
  */
 @NodeInfo
-public class BranchProbabilityNode extends FloatingNode implements Simplifiable, Lowerable {
+public final class BranchProbabilityNode extends FloatingNode implements Simplifiable, Lowerable {
 
     public static final double LIKELY_PROBABILITY = 0.6;
     public static final double NOT_LIKELY_PROBABILITY = 1 - LIKELY_PROBABILITY;
@@ -75,6 +75,12 @@
                 throw new GraalInternalError("A negative probability of " + probabilityValue + " is not allowed!");
             } else if (probabilityValue > 1.0) {
                 throw new GraalInternalError("A probability of more than 1.0 (" + probabilityValue + ") is not allowed!");
+            } else if (Double.isNaN(probabilityValue)) {
+                /*
+                 * We allow NaN if the node is in unreachable code that will eventually fall away,
+                 * or else an error will be thrown during lowering since we keep the node around.
+                 */
+                return;
             }
             boolean couldSet = false;
             for (IntegerEqualsNode node : this.usages().filter(IntegerEqualsNode.class)) {
@@ -107,7 +113,7 @@
     }
 
     private boolean isSubstitutionGraph() {
-        return usages().count() == 1 && usages().first() instanceof ReturnNode;
+        return getUsageCount() == 1 && usages().first() instanceof ReturnNode;
     }
 
     /**
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BytecodeExceptionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/BytecodeExceptionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * either a {@linkplain ForeignCallDescriptor foreign} call or a pre-allocated exception object.
  */
 @NodeInfo
-public class BytecodeExceptionNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+public final class BytecodeExceptionNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     protected final Class<? extends Throwable> exceptionClass;
     @Input NodeInputList<ValueNode> arguments;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ComputeAddressNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class ComputeAddressNode extends FloatingNode implements LIRLowerable {
+public final class ComputeAddressNode extends FloatingNode implements LIRLowerable {
 
     @Input ValueNode object;
     @Input(InputType.Association) ValueNode location;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * where base is a node and disp is a constant.
  */
 @NodeInfo(nameTemplate = "Loc {p#locationIdentity/s}")
-public class ConstantLocationNode extends LocationNode {
+public final class ConstantLocationNode extends LocationNode {
 
     protected final LocationIdentity locationIdentity;
     protected final long displacement;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,7 +28,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class FixedValueAnchorNode extends FixedWithNextNode implements LIRLowerable, ValueProxy {
+public final class FixedValueAnchorNode extends FixedWithNextNode implements LIRLowerable, ValueProxy {
 
     @Input ValueNode object;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IntegerSwitchNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IntegerSwitchNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,7 +41,7 @@
 
     protected final int[] keys;
 
-    public IntegerSwitchNode(ValueNode value, BeginNode[] successors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
+    public IntegerSwitchNode(ValueNode value, AbstractBeginNode[] successors, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
         super(value, successors, keySuccessors, keyProbabilities);
         assert keySuccessors.length == keys.length + 1;
         assert keySuccessors.length == keyProbabilities.length;
@@ -58,7 +58,7 @@
     }
 
     public IntegerSwitchNode(ValueNode value, int successorCount, int[] keys, double[] keyProbabilities, int[] keySuccessors) {
-        this(value, new BeginNode[successorCount], keys, keyProbabilities, keySuccessors);
+        this(value, new AbstractBeginNode[successorCount], keys, keyProbabilities, keySuccessors);
     }
 
     @Override
@@ -130,7 +130,7 @@
                     tool.addToWorkList(defaultSuccessor());
                     graph().removeSplitPropagate(this, defaultSuccessor());
                 } else if (validKeys != keys.length) {
-                    ArrayList<BeginNode> newSuccessors = new ArrayList<>(blockSuccessorCount());
+                    ArrayList<AbstractBeginNode> newSuccessors = new ArrayList<>(blockSuccessorCount());
                     int[] newKeys = new int[validKeys];
                     int[] newKeySuccessors = new int[validKeys + 1];
                     double[] newKeyProbabilities = new double[validKeys + 1];
@@ -163,14 +163,14 @@
                     }
 
                     for (int i = 0; i < blockSuccessorCount(); i++) {
-                        BeginNode successor = blockSuccessor(i);
+                        AbstractBeginNode successor = blockSuccessor(i);
                         if (!newSuccessors.contains(successor)) {
                             tool.deleteBranch(successor);
                         }
                         setBlockSuccessor(i, null);
                     }
 
-                    BeginNode[] successorsArray = newSuccessors.toArray(new BeginNode[newSuccessors.size()]);
+                    AbstractBeginNode[] successorsArray = newSuccessors.toArray(new AbstractBeginNode[newSuccessors.size()]);
                     IntegerSwitchNode newSwitch = graph().add(new IntegerSwitchNode(value(), successorsArray, newKeys, newKeyProbabilities, newKeySuccessors));
                     ((FixedWithNextNode) predecessor()).setNext(newSwitch);
                     GraphUtil.killWithUnusedFloatingInputs(this);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * Loads an object's hub. The object is not null-checked by this operation.
  */
 @NodeInfo
-public class LoadHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, Virtualizable {
+public final class LoadHubNode extends FloatingGuardedNode implements Lowerable, Canonicalizable, Virtualizable {
 
     @Input ValueNode value;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -69,7 +69,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             if (getGuard() != null && !(getGuard() instanceof FixedNode)) {
                 // The guard is necessary even if the read goes away.
                 return new ValueAnchorNode((ValueNode) getGuard());
@@ -134,8 +134,8 @@
         if (receiverType == null) {
             return false;
         }
-
-        ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(((ConstantLocationNode) location()).getDisplacement());
+        ConstantLocationNode constantLocationNode = (ConstantLocationNode) location();
+        ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(constantLocationNode.getDisplacement(), constantLocationNode.getKind());
         if (field == null) {
             // field was not declared by receiverType
             return false;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/SwitchNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
 @NodeInfo
 public abstract class SwitchNode extends ControlSplitNode {
 
-    @Successor protected NodeSuccessorList<BeginNode> successors;
+    @Successor protected NodeSuccessorList<AbstractBeginNode> successors;
     @Input protected ValueNode value;
 
     // do not change the contents of these arrays:
@@ -50,7 +50,7 @@
      * @param value the instruction that provides the value to be switched over
      * @param successors the list of successors of this switch
      */
-    public SwitchNode(ValueNode value, BeginNode[] successors, int[] keySuccessors, double[] keyProbabilities) {
+    public SwitchNode(ValueNode value, AbstractBeginNode[] successors, int[] keySuccessors, double[] keyProbabilities) {
         super(StampFactory.forVoid());
         assert value.stamp().getStackKind().isNumericInteger() || value.stamp() instanceof AbstractPointerStamp : value.stamp() + " key not supported by SwitchNode";
         assert keySuccessors.length == keyProbabilities.length;
@@ -72,7 +72,7 @@
     }
 
     @Override
-    public double probability(BeginNode successor) {
+    public double probability(AbstractBeginNode successor) {
         double sum = 0;
         for (int i = 0; i < keySuccessors.length; i++) {
             if (successors.get(keySuccessors[i]) == successor) {
@@ -117,7 +117,7 @@
     /**
      * Returns the successor for the key at the given index.
      */
-    public BeginNode keySuccessor(int i) {
+    public AbstractBeginNode keySuccessor(int i) {
         return successors.get(keySuccessors[i]);
     }
 
@@ -135,11 +135,11 @@
         return keySuccessors[keySuccessors.length - 1];
     }
 
-    public BeginNode blockSuccessor(int i) {
+    public AbstractBeginNode blockSuccessor(int i) {
         return successors.get(i);
     }
 
-    public void setBlockSuccessor(int i, BeginNode s) {
+    public void setBlockSuccessor(int i, AbstractBeginNode s) {
         successors.set(i, s);
     }
 
@@ -152,7 +152,7 @@
      *
      * @return the default successor
      */
-    public BeginNode defaultSuccessor() {
+    public AbstractBeginNode defaultSuccessor() {
         if (defaultSuccessorIndex() == -1) {
             throw new GraalInternalError("unexpected");
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeAccessNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -71,7 +71,7 @@
             // Try to canonicalize to a field access.
             ResolvedJavaType receiverType = StampTool.typeOrNull(object());
             if (receiverType != null) {
-                ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(constantOffset);
+                ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(constantOffset, accessKind());
                 // No need for checking that the receiver is non-null. The field access includes
                 // the null check and if a field is found, the offset is so small that this is
                 // never a valid access of an arbitrary address.
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeLoadNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -24,8 +24,6 @@
 
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
 
-import java.nio.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.nodeinfo.*;
@@ -66,12 +64,12 @@
             ValueNode offsetValue = tool.getReplacedValue(offset());
             if (offsetValue.isConstant()) {
                 long off = offsetValue.asJavaConstant().asLong();
-                int entryIndex = state.getVirtualObject().entryIndexForOffset(off);
+                int entryIndex = state.getVirtualObject().entryIndexForOffset(off, accessKind());
 
                 if (entryIndex != -1) {
                     ValueNode entry = state.getEntry(entryIndex);
-                    boolean isLoadSafe = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN || accessKind() == entry.getKind();
-                    if (isLoadSafe && (entry.getKind() == getKind() || state.getVirtualObject().entryKind(entryIndex) == accessKind())) {
+                    Kind entryKind = state.getVirtualObject().entryKind(entryIndex);
+                    if (entry.getKind() == getKind() || entryKind == accessKind()) {
                         tool.replaceWith(entry);
                     }
                 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeStoreNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -24,8 +24,6 @@
 
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
 
-import java.nio.*;
-
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.nodeinfo.*;
@@ -84,25 +82,22 @@
             ValueNode indexValue = tool.getReplacedValue(offset());
             if (indexValue.isConstant()) {
                 long off = indexValue.asJavaConstant().asLong();
-                int entryIndex = state.getVirtualObject().entryIndexForOffset(off);
+                int entryIndex = state.getVirtualObject().entryIndexForOffset(off, accessKind());
                 if (entryIndex != -1) {
                     Kind entryKind = state.getVirtualObject().entryKind(entryIndex);
                     ValueNode entry = state.getEntry(entryIndex);
-                    boolean isLoadSafe = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN || accessKind() == entry.getKind();
-                    if (isLoadSafe) {
-                        if (entry.getKind() == value.getKind() || entryKind == accessKind()) {
-                            tool.setVirtualEntry(state, entryIndex, value(), true);
-                            tool.delete();
-                        } else {
-                            if ((accessKind() == Kind.Long || accessKind() == Kind.Double) && entryKind == Kind.Int) {
-                                int nextIndex = state.getVirtualObject().entryIndexForOffset(off + 4);
-                                if (nextIndex != -1) {
-                                    Kind nextKind = state.getVirtualObject().entryKind(nextIndex);
-                                    if (nextKind == Kind.Int) {
-                                        tool.setVirtualEntry(state, entryIndex, value(), true);
-                                        tool.setVirtualEntry(state, nextIndex, ConstantNode.forConstant(JavaConstant.forIllegal(), tool.getMetaAccessProvider(), graph()), true);
-                                        tool.delete();
-                                    }
+                    if (entry.getKind() == value.getKind() || entryKind == accessKind()) {
+                        tool.setVirtualEntry(state, entryIndex, value(), true);
+                        tool.delete();
+                    } else {
+                        if ((accessKind() == Kind.Long || accessKind() == Kind.Double) && entryKind == Kind.Int) {
+                            int nextIndex = state.getVirtualObject().entryIndexForOffset(off + 4, entryKind);
+                            if (nextIndex != -1) {
+                                Kind nextKind = state.getVirtualObject().entryKind(nextIndex);
+                                if (nextKind == Kind.Int) {
+                                    tool.setVirtualEntry(state, entryIndex, value(), true);
+                                    tool.setVirtualEntry(state, nextIndex, ConstantNode.forConstant(JavaConstant.forIllegal(), tool.getMetaAccessProvider(), graph()), true);
+                                    tool.delete();
                                 }
                             }
                         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ValueAnchorNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -65,7 +65,7 @@
                 break;
             }
         }
-        if (usages().isEmpty() && next() instanceof FixedAccessNode) {
+        if (hasNoUsages() && next() instanceof FixedAccessNode) {
             FixedAccessNode currentNext = (FixedAccessNode) next();
             if (currentNext.getGuard() == anchored) {
                 GraphUtil.removeFixedWithUnusedInputs(this);
@@ -83,7 +83,7 @@
             removeAnchoredNode();
         }
 
-        if (anchored == null && usages().isEmpty()) {
+        if (anchored == null && hasNoUsages()) {
             // anchor is not necessary any more => remove.
             GraphUtil.removeFixedWithUnusedInputs(this);
         }
@@ -91,7 +91,7 @@
 
     @Override
     public void virtualize(VirtualizerTool tool) {
-        if (anchored != null && !(anchored instanceof BeginNode)) {
+        if (anchored != null && !(anchored instanceof AbstractBeginNode)) {
             State state = tool.getObjectState(anchored);
             if (state == null || state.getState() != EscapeState.Virtual) {
                 return;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewArrayNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
  * The {@code AbstractNewArrayNode} is used for all 1-dimensional array allocations.
  */
 @NodeInfo
-public class AbstractNewArrayNode extends AbstractNewObjectNode implements ArrayLengthProvider {
+public abstract class AbstractNewArrayNode extends AbstractNewObjectNode implements ArrayLengthProvider {
 
     @Input protected ValueNode length;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AbstractNewObjectNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * The {@code AbstractNewObjectNode} is the base class for the new instance and new array nodes.
  */
 @NodeInfo
-public class AbstractNewObjectNode extends DeoptimizingFixedWithNextNode implements Simplifiable, Lowerable {
+public abstract class AbstractNewObjectNode extends DeoptimizingFixedWithNextNode implements Simplifiable, Lowerable {
 
     protected final boolean fillContents;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ArrayLengthNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * The {@code ArrayLength} instruction gets the length of an array.
  */
 @NodeInfo
-public class ArrayLengthNode extends FixedWithNextNode implements Canonicalizable.Unary<ValueNode>, Lowerable, Virtualizable {
+public final class ArrayLengthNode extends FixedWithNextNode implements Canonicalizable.Unary<ValueNode>, Lowerable, Virtualizable {
 
     @Input ValueNode array;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AtomicReadAndAddNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AtomicReadAndAddNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * Represents an atomic read-and-add operation like {@link Unsafe#getAndAddInt(Object, long, int)}.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class AtomicReadAndAddNode extends AbstractMemoryCheckpoint implements LIRLowerable, MemoryCheckpoint.Single {
+public final class AtomicReadAndAddNode extends AbstractMemoryCheckpoint implements LIRLowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode object;
     @Input ValueNode offset;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AtomicReadAndWriteNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/AtomicReadAndWriteNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * .
  */
 @NodeInfo
-public class AtomicReadAndWriteNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+public final class AtomicReadAndWriteNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode object;
     @Input ValueNode offset;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastDynamicNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * instance, to implement an object array store check.
  */
 @NodeInfo
-public class CheckCastDynamicNode extends FixedWithNextNode implements Canonicalizable.Binary<ValueNode>, Lowerable {
+public final class CheckCastDynamicNode extends FixedWithNextNode implements Canonicalizable.Binary<ValueNode>, Lowerable {
 
     @Input ValueNode object;
     @Input ValueNode hub;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,7 +41,7 @@
  * Implements a type check against a compile-time known type.
  */
 @NodeInfo
-public class CheckCastNode extends FixedWithNextNode implements Canonicalizable, Simplifiable, Lowerable, Virtualizable, ValueProxy {
+public final class CheckCastNode extends FixedWithNextNode implements Canonicalizable, Simplifiable, Lowerable, Virtualizable, ValueProxy {
 
     @Input protected ValueNode object;
     protected final ResolvedJavaType type;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CompareAndSwapNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * value matched the expected value.
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class CompareAndSwapNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
+public final class CompareAndSwapNode extends AbstractMemoryCheckpoint implements Lowerable, MemoryCheckpoint.Single {
 
     @Input ValueNode object;
     @Input ValueNode offset;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewInstanceNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.*;
 
 @NodeInfo
-public class DynamicNewInstanceNode extends AbstractNewObjectNode implements Canonicalizable {
+public final class DynamicNewInstanceNode extends AbstractNewObjectNode implements Canonicalizable {
 
     @Input ValueNode clazz;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ExceptionObjectNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
  * throw instruction or implicit exception).
  */
 @NodeInfo(allowedUsageTypes = {InputType.Memory})
-public class ExceptionObjectNode extends DispatchBeginNode implements Lowerable, MemoryCheckpoint.Single {
+public final class ExceptionObjectNode extends DispatchBeginNode implements Lowerable, MemoryCheckpoint.Single {
 
     public ExceptionObjectNode(MetaAccessProvider metaAccess) {
         super(StampFactory.declaredNonNull(metaAccess.lookupJavaType(Throwable.class)));
@@ -53,7 +53,7 @@
              * deopts can float in between the begin node and the load exception node.
              */
             LocationIdentity locationsKilledByInvoke = ((InvokeWithExceptionNode) predecessor()).getLocationIdentity();
-            BeginNode entry = graph().add(new KillingBeginNode(locationsKilledByInvoke));
+            AbstractBeginNode entry = graph().add(new KillingBeginNode(locationsKilledByInvoke));
             LoadExceptionObjectNode loadException = graph().add(new LoadExceptionObjectNode(stamp()));
 
             loadException.setStateAfter(stateAfter());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/LoadFieldNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * The {@code LoadFieldNode} represents a read of a static or instance field.
  */
 @NodeInfo(nameTemplate = "LoadField#{p#field/s}")
-public class LoadFieldNode extends AccessFieldNode implements Canonicalizable.Unary<ValueNode>, VirtualizableRoot, UncheckedInterfaceProvider {
+public final class LoadFieldNode extends AccessFieldNode implements Canonicalizable.Unary<ValueNode>, VirtualizableRoot, UncheckedInterfaceProvider {
 
     public LoadFieldNode(ValueNode object, ResolvedJavaField field) {
         super(createStamp(field), object, field);
@@ -57,7 +57,7 @@
     }
 
     public ValueNode canonical(CanonicalizerTool tool, ValueNode forObject) {
-        if (usages().isEmpty() && !isVolatile() && (isStatic() || StampTool.isPointerNonNull(forObject.stamp()))) {
+        if (hasNoUsages() && !isVolatile() && (isStatic() || StampTool.isPointerNonNull(forObject.stamp()))) {
             return null;
         }
         MetaAccessProvider metaAccess = tool.getMetaAccess();
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -69,7 +69,7 @@
 
     @Override
     public boolean verify() {
-        assert usages().count() <= 1 : "call target may only be used by a single invoke";
+        assert getUsageCount() <= 1 : "call target may only be used by a single invoke";
         for (Node n : usages()) {
             assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n);
         }
@@ -171,7 +171,7 @@
         if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) {
             ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType(), true);
             if (singleImplementorMethod != null) {
-                assert graph().getGuardsStage().ordinal() < StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal() : "Graph already fixed!";
+                assert graph().getGuardsStage().allowsFloatingGuards() : "Graph already fixed!";
                 /**
                  * We have an invoke on an interface with a single implementor. We can replace this
                  * with an invoke virtual.
@@ -185,8 +185,8 @@
                  */
                 LogicNode condition = graph().unique(new InstanceOfNode(singleImplementor, receiver, getProfile()));
                 GuardNode guard = graph().unique(
-                                new GuardNode(condition, BeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, false,
-                                                JavaConstant.NULL_POINTER));
+                                new GuardNode(condition, AbstractBeginNode.prevBegin(invoke().asNode()), DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile,
+                                                false, JavaConstant.NULL_POINTER));
                 PiNode piNode = graph().unique(new PiNode(receiver, StampFactory.declaredNonNull(singleImplementor), guard));
                 arguments().set(0, piNode);
                 setInvokeKind(InvokeKind.Virtual);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorEnterNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorEnterNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * The {@code MonitorEnterNode} represents the acquisition of a monitor.
  */
 @NodeInfo
-public class MonitorEnterNode extends AccessMonitorNode implements Virtualizable, Lowerable, IterableNodeType, MonitorEnter, MemoryCheckpoint.Single {
+public final class MonitorEnterNode extends AccessMonitorNode implements Virtualizable, Lowerable, IterableNodeType, MonitorEnter, MemoryCheckpoint.Single {
 
     public MonitorEnterNode(ValueNode object, MonitorIdNode monitorId) {
         super(object, monitorId);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MonitorExitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * materialized before releasing the monitor.
  */
 @NodeInfo
-public class MonitorExitNode extends AccessMonitorNode implements Virtualizable, Simplifiable, Lowerable, IterableNodeType, MonitorExit, MemoryCheckpoint.Single {
+public final class MonitorExitNode extends AccessMonitorNode implements Virtualizable, Simplifiable, Lowerable, IterableNodeType, MonitorExit, MemoryCheckpoint.Single {
 
     @OptionalInput ValueNode escapedReturnValue;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewInstanceNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * The {@code NewInstanceNode} represents the allocation of an instance class object.
  */
 @NodeInfo(nameTemplate = "New {p#instanceClass/s}")
-public class NewInstanceNode extends AbstractNewObjectNode implements VirtualizableAllocation {
+public final class NewInstanceNode extends AbstractNewObjectNode implements VirtualizableAllocation {
 
     protected final ResolvedJavaType instanceClass;
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/NewMultiArrayNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * The {@code NewMultiArrayNode} represents an allocation of a multi-dimensional object array.
  */
 @NodeInfo
-public class NewMultiArrayNode extends DeoptimizingFixedWithNextNode implements Lowerable, ArrayLengthProvider {
+public final class NewMultiArrayNode extends DeoptimizingFixedWithNextNode implements Lowerable, ArrayLengthProvider {
 
     @Input protected NodeInputList<ValueNode> dimensions;
     protected final ResolvedJavaType type;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/TypeSwitchNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -42,7 +42,7 @@
 
     protected final ResolvedJavaType[] keys;
 
-    public TypeSwitchNode(ValueNode value, BeginNode[] successors, ResolvedJavaType[] keys, double[] keyProbabilities, int[] keySuccessors) {
+    public TypeSwitchNode(ValueNode value, AbstractBeginNode[] successors, ResolvedJavaType[] keys, double[] keyProbabilities, int[] keySuccessors) {
         super(value, successors, keySuccessors, keyProbabilities);
         assert successors.length <= keys.length + 1;
         assert keySuccessors.length == keyProbabilities.length;
@@ -150,7 +150,7 @@
                     tool.addToWorkList(defaultSuccessor());
                     graph().removeSplitPropagate(this, defaultSuccessor());
                 } else if (validKeys != keys.length) {
-                    ArrayList<BeginNode> newSuccessors = new ArrayList<>(blockSuccessorCount());
+                    ArrayList<AbstractBeginNode> newSuccessors = new ArrayList<>(blockSuccessorCount());
                     ResolvedJavaType[] newKeys = new ResolvedJavaType[validKeys];
                     int[] newKeySuccessors = new int[validKeys + 1];
                     double[] newKeyProbabilities = new double[validKeys + 1];
@@ -183,14 +183,14 @@
                     }
 
                     for (int i = 0; i < blockSuccessorCount(); i++) {
-                        BeginNode successor = blockSuccessor(i);
+                        AbstractBeginNode successor = blockSuccessor(i);
                         if (!newSuccessors.contains(successor)) {
                             tool.deleteBranch(successor);
                         }
                         setBlockSuccessor(i, null);
                     }
 
-                    BeginNode[] successorsArray = newSuccessors.toArray(new BeginNode[newSuccessors.size()]);
+                    AbstractBeginNode[] successorsArray = newSuccessors.toArray(new AbstractBeginNode[newSuccessors.size()]);
                     TypeSwitchNode newSwitch = graph().add(new TypeSwitchNode(value(), successorsArray, newKeys, newKeyProbabilities, newKeySuccessors));
                     ((FixedWithNextNode) predecessor()).setNext(newSwitch);
                     GraphUtil.killWithUnusedFloatingInputs(this);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Wed Jan 28 19:32:47 2015 +0100
@@ -24,9 +24,7 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.extended.*;
 
 public interface LoweringTool {
@@ -47,8 +45,6 @@
 
     Assumptions assumptions();
 
-    Block getBlockFor(Node node);
-
     /**
      * Gets the closest fixed node preceding the node currently being lowered.
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/NodeLIRBuilderTool.java	Wed Jan 28 19:32:47 2015 +0100
@@ -49,7 +49,7 @@
     void emitInvoke(Invoke i);
 
     // Handling of block-end nodes still needs to be unified in the LIRGenerator.
-    void visitMerge(MergeNode i);
+    void visitMerge(AbstractMergeNode i);
 
     void visitEndNode(AbstractEndNode i);
 
@@ -67,9 +67,9 @@
 
     LIRGeneratorTool getLIRGeneratorTool();
 
-    void emitOverflowCheckBranch(BeginNode overflowSuccessor, BeginNode next, Stamp compareStamp, double probability);
+    void emitOverflowCheckBranch(AbstractBeginNode overflowSuccessor, AbstractBeginNode next, Stamp compareStamp, double probability);
 
     Value[] visitInvokeArguments(CallingConvention cc, Collection<ValueNode> arguments);
 
-    void doBlock(Block block, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap);
+    void doBlock(Block block, StructuredGraph graph, BlockMap<List<ValueNode>> blockMap);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/UncheckedInterfaceProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/UncheckedInterfaceProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,7 @@
     Stamp uncheckedStamp();
 
     static Stamp uncheckedOrNull(JavaType type, Stamp originalStamp) {
-        if (type instanceof ResolvedJavaType) {
+        if (type instanceof ResolvedJavaType && type.getKind() == Kind.Object) {
             Stamp unchecked = StampFactory.declaredTrusted((ResolvedJavaType) type);
             if (!unchecked.equals(originalStamp)) {
                 return unchecked;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java	Wed Jan 28 19:32:47 2015 +0100
@@ -71,7 +71,7 @@
     }
 
     private static void killEnd(AbstractEndNode end, SimplifierTool tool) {
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         if (merge != null) {
             merge.removeEnd(end);
             StructuredGraph graph = end.graph();
@@ -139,7 +139,7 @@
         node.safeDelete();
 
         for (Node in : floatingInputs) {
-            if (in.isAlive() && in.usages().isEmpty()) {
+            if (in.isAlive() && in.hasNoUsages()) {
                 killWithUnusedFloatingInputs(in);
             }
         }
@@ -149,7 +149,7 @@
         if (fixed instanceof StateSplit) {
             FrameState stateAfter = ((StateSplit) fixed).stateAfter();
             ((StateSplit) fixed).setStateAfter(null);
-            if (stateAfter.usages().isEmpty()) {
+            if (stateAfter.hasNoUsages()) {
                 killWithUnusedFloatingInputs(stateAfter);
             }
         }
@@ -158,7 +158,7 @@
     }
 
     public static void unlinkFixedNode(FixedWithNextNode fixed) {
-        assert fixed.next() != null && fixed.predecessor() != null && fixed.isAlive();
+        assert fixed.next() != null && fixed.predecessor() != null && fixed.isAlive() : fixed;
         FixedNode next = fixed.next();
         fixed.setNext(null);
         fixed.replaceAtPredecessor(next);
@@ -187,7 +187,7 @@
         if (vpn.isDeleted()) {
             return;
         }
-        BeginNode proxyPoint = vpn.proxyPoint();
+        AbstractBeginNode proxyPoint = vpn.proxyPoint();
         if (proxyPoint instanceof LoopExitNode) {
             LoopExitNode exit = (LoopExitNode) proxyPoint;
             LoopBeginNode loopBegin = exit.loopBegin();
@@ -379,7 +379,7 @@
     }
 
     public static boolean tryKillUnused(Node node) {
-        if (node.isAlive() && isFloatingNode().apply(node) && node.usages().isEmpty()) {
+        if (node.isAlive() && isFloatingNode().apply(node) && node.hasNoUsages()) {
             killWithUnusedFloatingInputs(node);
             return true;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/AllocatedObjectNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
  * {@link VirtualObjectNode}.
  */
 @NodeInfo
-public class AllocatedObjectNode extends FloatingNode implements Virtualizable, ArrayLengthProvider {
+public final class AllocatedObjectNode extends FloatingNode implements Virtualizable, ArrayLengthProvider {
 
     @Input VirtualObjectNode virtualObject;
     @Input(InputType.Extension) CommitAllocationNode commit;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/CommitAllocationNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo(nameTemplate = "Alloc {i#virtualObjects}", allowedUsageTypes = {InputType.Extension})
-public class CommitAllocationNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable, Simplifiable {
+public final class CommitAllocationNode extends FixedWithNextNode implements VirtualizableAllocation, Lowerable, Simplifiable {
 
     @Input NodeInputList<VirtualObjectNode> virtualObjects = new NodeInputList<>(this);
     @Input NodeInputList<ValueNode> values = new NodeInputList<>(this);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualArrayNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.nodes.virtual;
 
+import java.nio.*;
+
 import sun.misc.*;
 
 import com.oracle.graal.api.meta.*;
@@ -75,7 +77,7 @@
     }
 
     @Override
-    public int entryIndexForOffset(long constantOffset) {
+    public int entryIndexForOffset(long constantOffset, Kind expectedEntryKind) {
         int baseOffset;
         int indexScale;
         switch (componentType.getKind()) {
@@ -118,7 +120,14 @@
             default:
                 return -1;
         }
-        long index = constantOffset - baseOffset;
+        long offset;
+        if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && componentType.isPrimitive()) {
+            // On big endian, we do just get expect the type be right aligned in this memory slot
+            offset = constantOffset - (componentType.getKind().getByteCount() - Math.min(componentType.getKind().getByteCount(), 4 + expectedEntryKind.getByteCount()));
+        } else {
+            offset = constantOffset;
+        }
+        long index = offset - baseOffset;
         if (index % indexScale != 0) {
             return -1;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -85,8 +85,8 @@
     }
 
     @Override
-    public int entryIndexForOffset(long constantOffset) {
-        return fieldIndex(type.findInstanceFieldWithOffset(constantOffset));
+    public int entryIndexForOffset(long constantOffset, Kind expectedEntryKind) {
+        return fieldIndex(type.findInstanceFieldWithOffset(constantOffset, expectedEntryKind));
     }
 
     @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualObjectNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -59,8 +59,12 @@
     /**
      * If the given index denotes an entry in this virtual object, the index of this entry is
      * returned. If no such entry can be found, this method returns -1.
+     *
+     * @param constantOffset offset, where the value is placed.
+     * @param expectedEntryKind Specifies which type is expected at this offset (Is important when
+     *            doing implicit casts, especially on big endian systems.
      */
-    public abstract int entryIndexForOffset(long constantOffset);
+    public abstract int entryIndexForOffset(long constantOffset, Kind expectedEntryKind);
 
     /**
      * Returns the {@link Kind} of the entry at the given index.
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,12 +36,12 @@
 
     public DerivedOptionValue(Supplier<T> supplier) {
         this.supplier = supplier;
-        assert OptionValue.overrideScopes.get() == null : "derived option value should be initialized outside any override scope";
+        assert OptionValue.getOverrideScope() == null : "derived option value should be initialized outside any override scope";
         this.initialValue = createValue();
     }
 
     public T getValue() {
-        OverrideScope overrideScope = OptionValue.overrideScopes.get();
+        OverrideScope overrideScope = OptionValue.getOverrideScope();
         if (overrideScope != null) {
             return overrideScope.getDerived(this);
         } else {
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java	Wed Jan 28 19:32:47 2015 +0100
@@ -46,7 +46,7 @@
      * </pre>
      */
     public static OverrideScope override(OptionValue<?> option, Object value) {
-        OverrideScope current = overrideScopes.get();
+        OverrideScope current = getOverrideScope();
         if (current == null) {
             if (!value.equals(option.getValue())) {
                 return new SingleOverrideScope(option, value);
@@ -76,7 +76,7 @@
      * </pre>
      */
     public static OverrideScope override(Map<OptionValue<?>, Object> overrides) {
-        OverrideScope current = overrideScopes.get();
+        OverrideScope current = getOverrideScope();
         if (current == null && overrides.size() == 1) {
             Entry<OptionValue<?>, Object> single = overrides.entrySet().iterator().next();
             OptionValue<?> option = single.getKey();
@@ -106,7 +106,7 @@
      * @param overrides overrides in the form {@code [option1, override1, option2, override2, ...]}
      */
     public static OverrideScope override(Object... overrides) {
-        OverrideScope current = overrideScopes.get();
+        OverrideScope current = getOverrideScope();
         if (current == null && overrides.length == 2) {
             OptionValue<?> option = (OptionValue<?>) overrides[0];
             Object overrideValue = overrides[1];
@@ -128,7 +128,15 @@
         return new MultipleOverridesScope(current, map);
     }
 
-    static final ThreadLocal<OverrideScope> overrideScopes = new ThreadLocal<>();
+    private static final ThreadLocal<OverrideScope> overrideScopeTL = new ThreadLocal<>();
+
+    protected static OverrideScope getOverrideScope() {
+        return overrideScopeTL.get();
+    }
+
+    protected static void setOverrideScope(OverrideScope overrideScope) {
+        overrideScopeTL.set(overrideScope);
+    }
 
     private T initialValue;
 
@@ -227,7 +235,7 @@
      */
     public boolean hasInitialValue() {
         if (!(this instanceof StableOptionValue)) {
-            OverrideScope overrideScope = overrideScopes.get();
+            OverrideScope overrideScope = getOverrideScope();
             if (overrideScope != null) {
                 T override = overrideScope.getOverride(this);
                 if (override != null) {
@@ -246,7 +254,7 @@
             reads++;
         }
         if (!(this instanceof StableOptionValue)) {
-            OverrideScope overrideScope = overrideScopes.get();
+            OverrideScope overrideScope = getOverrideScope();
             if (overrideScope != null) {
                 T override = overrideScope.getOverride(this);
                 if (override != null) {
@@ -272,7 +280,7 @@
     public Collection<T> getValues(Collection<T> c) {
         Collection<T> values = c == null ? new ArrayList<>() : c;
         if (!(this instanceof StableOptionValue)) {
-            OverrideScope overrideScope = overrideScopes.get();
+            OverrideScope overrideScope = getOverrideScope();
             if (overrideScope != null) {
                 overrideScope.getOverrides(this, (Collection<Object>) values);
             }
@@ -334,7 +342,7 @@
             }
             this.option = option;
             this.value = value;
-            overrideScopes.set(this);
+            setOverrideScope(this);
         }
 
         @Override
@@ -360,7 +368,7 @@
 
         @Override
         public void close() {
-            overrideScopes.set(null);
+            setOverrideScope(null);
         }
     }
 
@@ -381,7 +389,7 @@
                 this.overrides.put(option, value);
             }
             if (!overrides.isEmpty()) {
-                overrideScopes.set(this);
+                setOverrideScope(this);
             }
         }
 
@@ -405,7 +413,7 @@
                 }
             }
             if (!this.overrides.isEmpty()) {
-                overrideScopes.set(this);
+                setOverrideScope(this);
             }
         }
 
@@ -437,7 +445,7 @@
         @Override
         public void close() {
             if (!overrides.isEmpty()) {
-                overrideScopes.set(parent);
+                setOverrideScope(parent);
             }
         }
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -321,8 +321,8 @@
                         graph.removeFloating((FloatingNode) node);
                     } else {
                         // case 2
-                        assert !(canonical instanceof FixedNode) || (canonical.predecessor() != null || canonical instanceof StartNode || canonical instanceof MergeNode) : node + " -> " + canonical +
-                                        " : replacement should be floating or fixed and connected";
+                        assert !(canonical instanceof FixedNode) || (canonical.predecessor() != null || canonical instanceof StartNode || canonical instanceof AbstractMergeNode) : node + " -> " +
+                                        canonical + " : replacement should be floating or fixed and connected";
                         graph.replaceFloating((FloatingNode) node, canonical);
                     }
                 } else {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -124,7 +124,7 @@
         }
 
         @Override
-        public boolean merge(MergeNode merge, List<State> withStates) {
+        public boolean merge(AbstractMergeNode merge, List<State> withStates) {
             Map<ValueNode, ResolvedJavaType> newKnownTypes = Node.newIdentityMap();
             Map<LogicNode, GuardingNode> newTrueConditions = Node.newIdentityMap();
             Map<LogicNode, GuardingNode> newFalseConditions = Node.newIdentityMap();
@@ -340,10 +340,10 @@
 
         @Override
         public void finished() {
-            if (trueConstant.usages().isEmpty()) {
+            if (trueConstant.hasNoUsages()) {
                 graph.removeFloating(trueConstant);
             }
-            if (falseConstant.usages().isEmpty()) {
+            if (falseConstant.hasNoUsages()) {
                 graph.removeFloating(falseConstant);
             }
             super.finished();
@@ -405,7 +405,7 @@
             }
         }
 
-        private void registerControlSplitInfo(Node pred, BeginNode begin) {
+        private void registerControlSplitInfo(Node pred, AbstractBeginNode begin) {
             assert pred != null && begin != null;
             /*
              * We does not create value proxies for values it may connect accross loop exit node so
@@ -640,8 +640,8 @@
 
         @Override
         protected void node(FixedNode node) {
-            if (node instanceof BeginNode) {
-                BeginNode begin = (BeginNode) node;
+            if (node instanceof AbstractBeginNode) {
+                AbstractBeginNode begin = (AbstractBeginNode) node;
                 Node pred = node.predecessor();
 
                 if (pred != null) {
@@ -694,7 +694,7 @@
                         replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type);
                     }
                     if (replacementAnchor == null) {
-                        replacementAnchor = BeginNode.prevBegin(checkCast);
+                        replacementAnchor = AbstractBeginNode.prevBegin(checkCast);
                     }
                     PiNode piNode;
                     if (isNull) {
@@ -730,7 +730,7 @@
 
                 LogicNode replacement = null;
                 GuardingNode replacementAnchor = null;
-                BeginNode survivingSuccessor = null;
+                AbstractBeginNode survivingSuccessor = null;
                 if (state.trueConditions.containsKey(compare)) {
                     replacement = trueConstant;
                     replacementAnchor = state.trueConditions.get(compare);
@@ -752,7 +752,7 @@
                 }
 
                 if (replacement != null) {
-                    if (replacementAnchor != null && !(replacementAnchor instanceof BeginNode)) {
+                    if (replacementAnchor != null && !(replacementAnchor instanceof AbstractBeginNode)) {
                         ValueAnchorNode anchor = graph.add(new ValueAnchorNode(replacementAnchor.asNode()));
                         graph.addBeforeFixed(ifNode, anchor);
                     }
@@ -770,7 +770,7 @@
                     }
 
                     ifNode.setCondition(replacement);
-                    if (compare.usages().isEmpty()) {
+                    if (compare.hasNoUsages()) {
                         GraphUtil.killWithUnusedFloatingInputs(compare);
                     }
                 }
@@ -786,7 +786,7 @@
 
                         if (replacement != null) {
                             phi.setValueAt(index, replacement);
-                            if (materialize.usages().isEmpty()) {
+                            if (materialize.hasNoUsages()) {
                                 GraphUtil.killWithUnusedFloatingInputs(materialize);
                             }
                         }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -51,8 +51,8 @@
 public class ConvertDeoptimizeToGuardPhase extends Phase {
     private SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, null, false);
 
-    private static BeginNode findBeginNode(FixedNode startNode) {
-        return GraphUtil.predecessorIterable(startNode).filter(BeginNode.class).first();
+    private static AbstractBeginNode findBeginNode(FixedNode startNode) {
+        return GraphUtil.predecessorIterable(startNode).filter(AbstractBeginNode.class).first();
     }
 
     @Override
@@ -63,14 +63,14 @@
         }
         for (DeoptimizeNode d : graph.getNodes(DeoptimizeNode.class)) {
             assert d.isAlive();
-            visitDeoptBegin(BeginNode.prevBegin(d), d.action(), d.reason(), graph);
+            visitDeoptBegin(AbstractBeginNode.prevBegin(d), d.action(), d.reason(), graph);
         }
 
         for (FixedGuardNode fixedGuard : graph.getNodes(FixedGuardNode.class)) {
 
-            BeginNode pred = BeginNode.prevBegin(fixedGuard);
-            if (pred instanceof MergeNode) {
-                MergeNode merge = (MergeNode) pred;
+            AbstractBeginNode pred = AbstractBeginNode.prevBegin(fixedGuard);
+            if (pred instanceof AbstractMergeNode) {
+                AbstractMergeNode merge = (AbstractMergeNode) pred;
                 if (fixedGuard.condition() instanceof CompareNode) {
                     CompareNode compare = (CompareNode) fixedGuard.condition();
                     List<AbstractEndNode> mergePredecessors = merge.cfgPredecessors().snapshot();
@@ -96,7 +96,7 @@
                         }
                         if (xs[i] instanceof PrimitiveConstant && ys[i] instanceof PrimitiveConstant &&
                                         compare.condition().foldCondition(xs[i], ys[i], null, compare.unorderedIsTrue()) == fixedGuard.isNegated()) {
-                            visitDeoptBegin(BeginNode.prevBegin(mergePredecessor), fixedGuard.getAction(), fixedGuard.getReason(), graph);
+                            visitDeoptBegin(AbstractBeginNode.prevBegin(mergePredecessor), fixedGuard.getAction(), fixedGuard.getReason(), graph);
                         }
                     }
                 }
@@ -106,27 +106,27 @@
         new DeadCodeEliminationPhase(Optional).apply(graph);
     }
 
-    private void visitDeoptBegin(BeginNode deoptBegin, DeoptimizationAction deoptAction, DeoptimizationReason deoptReason, StructuredGraph graph) {
-        if (deoptBegin instanceof MergeNode) {
-            MergeNode mergeNode = (MergeNode) deoptBegin;
+    private void visitDeoptBegin(AbstractBeginNode deoptBegin, DeoptimizationAction deoptAction, DeoptimizationReason deoptReason, StructuredGraph graph) {
+        if (deoptBegin instanceof AbstractMergeNode) {
+            AbstractMergeNode mergeNode = (AbstractMergeNode) deoptBegin;
             Debug.log("Visiting %s", mergeNode);
             FixedNode next = mergeNode.next();
             while (mergeNode.isAlive()) {
                 AbstractEndNode end = mergeNode.forwardEnds().first();
-                BeginNode newBeginNode = findBeginNode(end);
+                AbstractBeginNode newBeginNode = findBeginNode(end);
                 visitDeoptBegin(newBeginNode, deoptAction, deoptReason, graph);
             }
             assert next.isAlive();
-            BeginNode newBeginNode = findBeginNode(next);
+            AbstractBeginNode newBeginNode = findBeginNode(next);
             visitDeoptBegin(newBeginNode, deoptAction, deoptReason, graph);
             return;
         } else if (deoptBegin.predecessor() instanceof IfNode) {
             IfNode ifNode = (IfNode) deoptBegin.predecessor();
-            BeginNode otherBegin = ifNode.trueSuccessor();
+            AbstractBeginNode otherBegin = ifNode.trueSuccessor();
             LogicNode conditionNode = ifNode.condition();
             FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deoptReason, deoptAction, deoptBegin == ifNode.trueSuccessor()));
             FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor();
-            BeginNode survivingSuccessor;
+            AbstractBeginNode survivingSuccessor;
             if (deoptBegin == ifNode.trueSuccessor()) {
                 survivingSuccessor = ifNode.falseSuccessor();
             } else {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeadCodeEliminationPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeadCodeEliminationPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -79,7 +79,7 @@
         deleteNodes(flood, graph);
 
         // remove chained Merges
-        for (MergeNode merge : graph.getNodes(MergeNode.class)) {
+        for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.class)) {
             if (merge.forwardEndCount() == 1 && !(merge instanceof LoopBeginNode)) {
                 graph.reduceTrivialMerge(merge);
             }
@@ -102,7 +102,7 @@
     private static void disconnectCFGNodes(NodeFlood flood, StructuredGraph graph) {
         for (AbstractEndNode node : graph.getNodes(AbstractEndNode.class)) {
             if (!flood.isMarked(node)) {
-                MergeNode merge = node.merge();
+                AbstractMergeNode merge = node.merge();
                 if (merge != null && flood.isMarked(merge)) {
                     // We are a dead end node leading to a live merge.
                     merge.removeEnd(node);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -52,7 +52,7 @@
                     if (cfg == null) {
                         cfg = ControlFlowGraph.compute(graph, true, true, false, false);
                     }
-                    MergeNode merge;
+                    AbstractMergeNode merge;
                     if (target instanceof AbstractDeoptimizeNode) {
                         merge = graph.add(new MergeNode());
                         EndNode firstEnd = graph.add(new EndNode());
@@ -72,7 +72,7 @@
                         obsoletes.add((AbstractDeoptimizeNode) target);
                         target = merge;
                     } else {
-                        merge = (MergeNode) target;
+                        merge = (AbstractMergeNode) target;
                     }
                     EndNode newEnd = graph.add(new EndNode());
                     merge.addForwardEnd(newEnd);
@@ -84,7 +84,7 @@
                 }
             }
             if (obsoletes != null) {
-                ((DynamicDeoptimizeNode) ((MergeNode) target).next()).setStateBefore(fs);
+                ((DynamicDeoptimizeNode) ((AbstractMergeNode) target).next()).setStateBefore(fs);
                 for (AbstractDeoptimizeNode obsolete : obsoletes) {
                     obsolete.safeDelete();
                 }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ExpandLogicPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ExpandLogicPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -55,14 +55,14 @@
     }
 
     private static void processIf(LogicNode x, boolean xNegated, LogicNode y, boolean yNegated, IfNode ifNode, double shortCircuitProbability) {
-        BeginNode trueTarget = ifNode.trueSuccessor();
-        BeginNode falseTarget = ifNode.falseSuccessor();
+        AbstractBeginNode trueTarget = ifNode.trueSuccessor();
+        AbstractBeginNode falseTarget = ifNode.falseSuccessor();
         double firstIfProbability = shortCircuitProbability;
         /*
          * P(Y | not(X)) = P(Y inter not(X)) / P(not(X)) = (P(X union Y) - P(X)) / (1 - P(X))
-         * 
+         *
          * P(X) = shortCircuitProbability
-         * 
+         *
          * P(X union Y) = ifNode.probability(trueTarget)
          */
         double secondIfProbability = (ifNode.probability(trueTarget) - shortCircuitProbability) / (1 - shortCircuitProbability);
@@ -72,15 +72,15 @@
         }
         ifNode.clearSuccessors();
         Graph graph = ifNode.graph();
-        MergeNode trueTargetMerge = graph.add(new MergeNode());
+        AbstractMergeNode trueTargetMerge = graph.add(new MergeNode());
         trueTargetMerge.setNext(trueTarget);
         EndNode firstTrueEnd = graph.add(new EndNode());
         EndNode secondTrueEnd = graph.add(new EndNode());
         trueTargetMerge.addForwardEnd(firstTrueEnd);
         trueTargetMerge.addForwardEnd(secondTrueEnd);
-        BeginNode firstTrueTarget = BeginNode.begin(firstTrueEnd);
-        BeginNode secondTrueTarget = BeginNode.begin(secondTrueEnd);
-        BeginNode secondIf = BeginNode.begin(graph.add(new IfNode(y, yNegated ? falseTarget : secondTrueTarget, yNegated ? secondTrueTarget : falseTarget, secondIfProbability)));
+        AbstractBeginNode firstTrueTarget = BeginNode.begin(firstTrueEnd);
+        AbstractBeginNode secondTrueTarget = BeginNode.begin(secondTrueEnd);
+        AbstractBeginNode secondIf = BeginNode.begin(graph.add(new IfNode(y, yNegated ? falseTarget : secondTrueTarget, yNegated ? secondTrueTarget : falseTarget, secondIfProbability)));
         IfNode firstIf = graph.add(new IfNode(x, xNegated ? secondIf : firstTrueTarget, xNegated ? firstTrueTarget : secondIf, firstIfProbability));
         ifNode.replaceAtPredecessor(firstIf);
         ifNode.safeDelete();
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -150,7 +150,7 @@
         }
     }
 
-    public static MemoryMapImpl mergeMemoryMaps(MergeNode merge, List<? extends MemoryMap> states, boolean updateExistingPhis) {
+    public static MemoryMapImpl mergeMemoryMaps(AbstractMergeNode merge, List<? extends MemoryMap> states, boolean updateExistingPhis) {
         MemoryMapImpl newState = new MemoryMapImpl();
 
         Set<LocationIdentity> keys = CollectionsFactory.newSet();
@@ -237,7 +237,7 @@
         }
 
         @Override
-        protected Set<LocationIdentity> merge(MergeNode merge, List<Set<LocationIdentity>> states) {
+        protected Set<LocationIdentity> merge(AbstractMergeNode merge, List<Set<LocationIdentity>> states) {
             Set<LocationIdentity> result = CollectionsFactory.newSet();
             for (Set<LocationIdentity> other : states) {
                 result.addAll(other);
@@ -246,7 +246,7 @@
         }
 
         @Override
-        protected Set<LocationIdentity> afterSplit(BeginNode node, Set<LocationIdentity> oldState) {
+        protected Set<LocationIdentity> afterSplit(AbstractBeginNode node, Set<LocationIdentity> oldState) {
             return CollectionsFactory.newSet(oldState);
         }
 
@@ -346,12 +346,12 @@
         }
 
         @Override
-        protected MemoryMapImpl merge(MergeNode merge, List<MemoryMapImpl> states) {
+        protected MemoryMapImpl merge(AbstractMergeNode merge, List<MemoryMapImpl> states) {
             return mergeMemoryMaps(merge, states, updateExistingPhis);
         }
 
         @Override
-        protected MemoryMapImpl afterSplit(BeginNode node, MemoryMapImpl oldState) {
+        protected MemoryMapImpl afterSplit(AbstractBeginNode node, MemoryMapImpl oldState) {
             MemoryMapImpl result = new MemoryMapImpl(oldState);
             if (node.predecessor() instanceof InvokeWithExceptionNode) {
                 /*
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -88,13 +88,13 @@
         }
 
         @Override
-        protected FrameState merge(MergeNode merge, List<FrameState> states) {
+        protected FrameState merge(AbstractMergeNode merge, List<FrameState> states) {
             FrameState singleFrameState = singleFrameState(states);
             return singleFrameState == null ? merge.stateAfter() : singleFrameState;
         }
 
         @Override
-        protected FrameState afterSplit(BeginNode node, FrameState oldState) {
+        protected FrameState afterSplit(AbstractBeginNode node, FrameState oldState) {
             return oldState;
         }
 
@@ -106,11 +106,11 @@
 
     @Override
     protected void run(StructuredGraph graph) {
-        assert graph.getGuardsStage().ordinal() >= GuardsStage.FIXED_DEOPTS.ordinal() && checkFixedDeopts(graph);
-        if (graph.getGuardsStage().ordinal() < GuardsStage.AFTER_FSA.ordinal()) {
+        assert !graph.getGuardsStage().allowsFloatingGuards() && checkFixedDeopts(graph);
+        if (graph.getGuardsStage().areFrameStatesAtSideEffects()) {
             ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null);
             graph.setGuardsStage(GuardsStage.AFTER_FSA);
-            graph.getNodes(FrameState.class).filter(state -> state.usages().isEmpty()).forEach(GraphUtil::killWithUnusedFloatingInputs);
+            graph.getNodes(FrameState.class).filter(state -> state.hasNoUsages()).forEach(GraphUtil::killWithUnusedFloatingInputs);
         }
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -111,7 +111,7 @@
                     fixedAccess.setNullCheck(true);
                     LogicNode condition = guard.condition();
                     guard.replaceAndDelete(fixedAccess);
-                    if (condition.usages().isEmpty()) {
+                    if (condition.hasNoUsages()) {
                         GraphUtil.killWithUnusedFloatingInputs(condition);
                     }
                     nullGuarded.remove(fixedAccess.object());
@@ -161,12 +161,12 @@
 
         private void lowerToIf(GuardNode guard) {
             StructuredGraph graph = guard.graph();
-            BeginNode fastPath = graph.add(new BeginNode());
+            AbstractBeginNode fastPath = graph.add(new BeginNode());
             @SuppressWarnings("deprecation")
             DeoptimizeNode deopt = graph.add(new DeoptimizeNode(guard.action(), guard.reason(), useGuardIdAsDebugId ? guard.getId() : 0, guard.getSpeculation(), null));
-            BeginNode deoptBranch = BeginNode.begin(deopt);
-            BeginNode trueSuccessor;
-            BeginNode falseSuccessor;
+            AbstractBeginNode deoptBranch = BeginNode.begin(deopt);
+            AbstractBeginNode trueSuccessor;
+            AbstractBeginNode falseSuccessor;
             insertLoopExits(deopt);
             if (guard.isNegated()) {
                 trueSuccessor = deoptBranch;
@@ -193,7 +193,7 @@
 
     @Override
     protected void run(StructuredGraph graph, MidTierContext context) {
-        if (graph.getGuardsStage().ordinal() < GuardsStage.FIXED_DEOPTS.ordinal()) {
+        if (graph.getGuardsStage().allowsFloatingGuards()) {
             SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.EARLIEST);
             schedule.apply(graph);
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -77,14 +77,12 @@
         private final NodeBitMap activeGuards;
         private AnchoringNode guardAnchor;
         private FixedWithNextNode lastFixedNode;
-        private ControlFlowGraph cfg;
 
-        public LoweringToolImpl(PhaseContext context, AnchoringNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode, ControlFlowGraph cfg) {
+        public LoweringToolImpl(PhaseContext context, AnchoringNode guardAnchor, NodeBitMap activeGuards, FixedWithNextNode lastFixedNode) {
             this.context = context;
             this.guardAnchor = guardAnchor;
             this.activeGuards = activeGuards;
             this.lastFixedNode = lastFixedNode;
-            this.cfg = cfg;
         }
 
         @Override
@@ -141,7 +139,7 @@
                 }
             }
             StructuredGraph graph = before.graph();
-            if (condition.graph().getGuardsStage().ordinal() >= StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal()) {
+            if (!condition.graph().getGuardsStage().allowsFloatingGuards()) {
                 FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(condition, deoptReason, action, negated));
                 graph.addBeforeFixed(before, fixedGuard);
                 DummyGuardHandle handle = graph.add(new DummyGuardHandle(fixedGuard));
@@ -158,11 +156,6 @@
             }
         }
 
-        @Override
-        public Block getBlockFor(Node node) {
-            return cfg.blockFor(node);
-        }
-
         public FixedWithNextNode lastFixedNode() {
             return lastFixedNode;
         }
@@ -298,10 +291,10 @@
 
         private AnchoringNode process(final Block b, final NodeBitMap activeGuards, final AnchoringNode startAnchor) {
 
-            final LoweringToolImpl loweringTool = new LoweringToolImpl(context, startAnchor, activeGuards, b.getBeginNode(), schedule.getCFG());
+            final LoweringToolImpl loweringTool = new LoweringToolImpl(context, startAnchor, activeGuards, b.getBeginNode());
 
             // Lower the instructions of this block.
-            List<ScheduledNode> nodes = schedule.nodesFor(b);
+            List<ValueNode> nodes = schedule.nodesFor(b);
             for (Node node : nodes) {
 
                 if (node.isDeleted()) {
@@ -326,7 +319,7 @@
                     if (loweringTool.guardAnchor.asNode().isDeleted()) {
                         // TODO nextNode could be deleted but this is not currently supported
                         assert nextNode.isAlive();
-                        loweringTool.guardAnchor = BeginNode.prevBegin(nextNode);
+                        loweringTool.guardAnchor = AbstractBeginNode.prevBegin(nextNode);
                     }
                     assert checkPostNodeLowering(node, loweringTool, preLoweringMark, unscheduledUsages);
                 }
@@ -343,7 +336,7 @@
                         // FixedWithNextNode is followed by some kind of BeginNode.
                         // For example the when a FixedGuard followed by a loop exit is lowered to a
                         // control-split + deopt.
-                        BeginNode begin = node.graph().add(new BeginNode());
+                        AbstractBeginNode begin = node.graph().add(new BeginNode());
                         nextLastFixed.replaceFirstSuccessor(nextNode, begin);
                         begin.setNext(nextNode);
                         nextLastFixed = begin;
@@ -368,7 +361,7 @@
             List<Node> unscheduledUsages = new ArrayList<>();
             if (node instanceof FloatingNode) {
                 for (Node usage : node.usages()) {
-                    if (usage instanceof ScheduledNode) {
+                    if (usage instanceof ValueNode) {
                         Block usageBlock = schedule.getCFG().blockFor(usage);
                         if (usageBlock == null) {
                             unscheduledUsages.add(usage);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchorsPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -55,11 +55,11 @@
     @Override
     protected void run(StructuredGraph graph) {
         LazyCFG cfg = new LazyCFG(graph);
-        for (BeginNode begin : graph.getNodes(BeginNode.class)) {
+        for (AbstractBeginNode begin : graph.getNodes(AbstractBeginNode.class)) {
             if (!(begin instanceof StartNode || begin.predecessor() instanceof ControlSplitNode)) {
                 NodeIterable<GuardNode> guards = begin.guards();
                 if (guards.isNotEmpty()) {
-                    BeginNode newAnchor = computeOptimalAnchor(cfg.get(), begin);
+                    AbstractBeginNode newAnchor = computeOptimalAnchor(cfg.get(), begin);
                     // newAnchor == begin is possible because postdominator computation assumes that
                     // loops never end
                     if (newAnchor != begin) {
@@ -76,14 +76,14 @@
         }
     }
 
-    public static BeginNode getOptimalAnchor(LazyCFG cfg, BeginNode begin) {
+    public static AbstractBeginNode getOptimalAnchor(LazyCFG cfg, AbstractBeginNode begin) {
         if (begin instanceof StartNode || begin.predecessor() instanceof ControlSplitNode) {
             return begin;
         }
         return computeOptimalAnchor(cfg.get(), begin);
     }
 
-    private static BeginNode computeOptimalAnchor(ControlFlowGraph cfg, BeginNode begin) {
+    private static AbstractBeginNode computeOptimalAnchor(ControlFlowGraph cfg, AbstractBeginNode begin) {
         Block anchor = cfg.blockFor(begin);
         while (anchor.getDominator() != null && anchor.getDominator().getPostdominator() == anchor) {
             anchor = anchor.getDominator();
@@ -92,11 +92,11 @@
     }
 
     private static void optimizeAtControlSplit(ControlSplitNode controlSplit, LazyCFG cfg) {
-        BeginNode successor = findMinimumUsagesSuccessor(controlSplit);
+        AbstractBeginNode successor = findMinimumUsagesSuccessor(controlSplit);
         int successorCount = controlSplit.successors().count();
         List<GuardNode> otherGuards = new ArrayList<>(successorCount - 1);
         for (GuardNode guard : successor.guards().snapshot()) {
-            if (guard.isDeleted() || guard.condition().usages().count() < successorCount) {
+            if (guard.isDeleted() || guard.condition().getUsageCount() < successorCount) {
                 continue;
             }
             for (GuardNode conditonGuard : guard.condition().usages().filter(GuardNode.class)) {
@@ -109,7 +109,7 @@
             }
 
             if (otherGuards.size() == successorCount - 1) {
-                BeginNode anchor = computeOptimalAnchor(cfg.get(), BeginNode.prevBegin(controlSplit));
+                AbstractBeginNode anchor = computeOptimalAnchor(cfg.get(), AbstractBeginNode.prevBegin(controlSplit));
                 GuardNode newGuard = controlSplit.graph().unique(new GuardNode(guard.condition(), anchor, guard.reason(), guard.action(), guard.isNegated(), guard.getSpeculation()));
                 for (GuardNode otherGuard : otherGuards) {
                     otherGuard.replaceAndDelete(newGuard);
@@ -126,13 +126,13 @@
                         conditonGuard.getSpeculation().equals(guard.getSpeculation());
     }
 
-    private static BeginNode findMinimumUsagesSuccessor(ControlSplitNode controlSplit) {
+    private static AbstractBeginNode findMinimumUsagesSuccessor(ControlSplitNode controlSplit) {
         NodePosIterator successors = controlSplit.successors().iterator();
-        BeginNode min = (BeginNode) successors.next();
-        int minUsages = min.usages().count();
+        AbstractBeginNode min = (AbstractBeginNode) successors.next();
+        int minUsages = min.getUsageCount();
         while (successors.hasNext()) {
-            BeginNode successor = (BeginNode) successors.next();
-            int count = successor.usages().count();
+            AbstractBeginNode successor = (AbstractBeginNode) successors.next();
+            int count = successor.getUsageCount();
             if (count < minUsages) {
                 minUsages = count;
                 min = successor;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ProfileCompiledMethodsPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ProfileCompiledMethodsPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -46,8 +46,8 @@
  * 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.
+ * is determined heuristically in the {@link ProfileCompiledMethodsPhase#getNodeWeight(ValueNode)}
+ * method.
  *
  * Additionally, there's a second counter that's only increased for code sections without invokes.
  */
@@ -117,17 +117,17 @@
         double count = 0;
         for (Block block : blocks) {
             double blockProbability = probabilities.applyAsDouble(block.getBeginNode());
-            for (ScheduledNode node : schedule.getBlockToNodesMap().get(block)) {
+            for (ValueNode node : schedule.getBlockToNodesMap().get(block)) {
                 count += blockProbability * getNodeWeight(node);
             }
         }
         return count;
     }
 
-    private static double getNodeWeight(ScheduledNode node) {
-        if (node instanceof MergeNode) {
-            return ((MergeNode) node).phiPredecessorCount();
-        } else if (node instanceof BeginNode || node instanceof AbstractEndNode || node instanceof MonitorIdNode || node instanceof ConstantNode || node instanceof ParameterNode ||
+    private static double getNodeWeight(ValueNode node) {
+        if (node instanceof AbstractMergeNode) {
+            return ((AbstractMergeNode) node).phiPredecessorCount();
+        } else if (node instanceof AbstractBeginNode || node instanceof AbstractEndNode || node instanceof MonitorIdNode || node instanceof ConstantNode || node instanceof ParameterNode ||
                         node instanceof CallTargetNode || node instanceof ValueProxy || node instanceof VirtualObjectNode || node instanceof ReinterpretNode) {
             return 0;
         } else if (node instanceof AccessMonitorNode) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/RemoveValueProxyPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
             FrameState stateAfter = exit.stateAfter();
             if (stateAfter != null) {
                 exit.setStateAfter(null);
-                if (stateAfter.usages().isEmpty()) {
+                if (stateAfter.hasNoUsages()) {
                     GraphUtil.killWithUnusedFloatingInputs(stateAfter);
                 }
             }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -47,7 +47,7 @@
 
 /**
  * This class is a phase that looks for opportunities for tail duplication. The static method
- * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List, PhaseContext, CanonicalizerPhase)}
+ * {@link #tailDuplicate(AbstractMergeNode, TailDuplicationDecision, List, PhaseContext, CanonicalizerPhase)}
  * can also be used to drive tail duplication from other places, e.g., inlining.
  */
 public class TailDuplicationPhase extends BasePhase<PhaseContext> {
@@ -84,7 +84,7 @@
          *            duplicated set of nodes.
          * @return true if the tail duplication should be performed, false otherwise.
          */
-        boolean doTransform(MergeNode merge, int fixedNodeCount);
+        boolean doTransform(AbstractMergeNode merge, int fixedNodeCount);
     }
 
     /**
@@ -94,7 +94,7 @@
      */
     public static final TailDuplicationDecision DEFAULT_DECISION = new TailDuplicationDecision() {
 
-        public boolean doTransform(MergeNode merge, int fixedNodeCount) {
+        public boolean doTransform(AbstractMergeNode merge, int fixedNodeCount) {
             if (fixedNodeCount < TailDuplicationTrivialSize.getValue()) {
                 return true;
             }
@@ -144,7 +144,7 @@
     public static final TailDuplicationDecision TRUE_DECISION = new TailDuplicationDecision() {
 
         @Override
-        public boolean doTransform(MergeNode merge, int fixedNodeCount) {
+        public boolean doTransform(AbstractMergeNode merge, int fixedNodeCount) {
             return true;
         }
     };
@@ -155,12 +155,12 @@
 
     @Override
     protected void run(StructuredGraph graph, PhaseContext phaseContext) {
-        if (graph.hasNode(MergeNode.class)) {
+        if (graph.hasNode(AbstractMergeNode.class)) {
             ToDoubleFunction<FixedNode> nodeProbabilities = new FixedNodeProbabilityCache();
 
             // A snapshot is taken here, so that new MergeNode instances aren't considered for tail
             // duplication.
-            for (MergeNode merge : graph.getNodes(MergeNode.class).snapshot()) {
+            for (AbstractMergeNode merge : graph.getNodes(AbstractMergeNode.class).snapshot()) {
                 if (!(merge instanceof LoopBeginNode) && nodeProbabilities.applyAsDouble(merge) >= TailDuplicationProbability.getValue()) {
                     tailDuplicate(merge, DEFAULT_DECISION, null, phaseContext, canonicalizer);
                 }
@@ -172,9 +172,9 @@
      * This method attempts to duplicate the tail of the given merge. The merge must not be a
      * {@link LoopBeginNode}. If the merge is eligible for duplication (at least one fixed node in
      * its tail, no {@link MonitorEnterNode}/ {@link MonitorExitNode}, non-null
-     * {@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.
+     * {@link AbstractMergeNode#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
@@ -185,7 +185,7 @@
      *            {@link PiNode} in the duplicated branch that corresponds to the entry.
      * @param phaseContext
      */
-    public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List<GuardedValueNode> replacements, PhaseContext phaseContext, CanonicalizerPhase canonicalizer) {
+    public static boolean tailDuplicate(AbstractMergeNode merge, TailDuplicationDecision decision, List<GuardedValueNode> replacements, PhaseContext phaseContext, CanonicalizerPhase canonicalizer) {
         assert !(merge instanceof LoopBeginNode);
         assert replacements == null || replacements.size() == merge.forwardEndCount();
         FixedNode fixed = merge;
@@ -209,11 +209,12 @@
     }
 
     /**
-     * This class encapsulates one tail duplication operation on a specific {@link MergeNode}.
+     * This class encapsulates one tail duplication operation on a specific
+     * {@link AbstractMergeNode}.
      */
     private static class DuplicationOperation {
 
-        private final MergeNode merge;
+        private final AbstractMergeNode merge;
         private final StructuredGraph graph;
 
         private final Map<ValueNode, PhiNode> bottomPhis = Node.newMap();
@@ -228,7 +229,7 @@
          * @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.
          */
-        public DuplicationOperation(MergeNode merge, List<GuardedValueNode> replacements, CanonicalizerPhase canonicalizer) {
+        public DuplicationOperation(AbstractMergeNode merge, List<GuardedValueNode> replacements, CanonicalizerPhase canonicalizer) {
             this.merge = merge;
             this.replacements = replacements;
             this.graph = merge.graph();
@@ -270,7 +271,7 @@
             }
 
             AbstractEndNode endAfter = createNewMerge(fixed, stateAfter);
-            MergeNode mergeAfter = endAfter.merge();
+            AbstractMergeNode mergeAfter = endAfter.merge();
             fixedNodes.add(endAfter);
             final Set<Node> duplicatedNodes = buildDuplicatedNodeSet(fixedNodes, stateAfter);
             mergeAfter.clearEnds();
@@ -298,10 +299,10 @@
                 // EndNode
                 FixedWithNextNode anchorDuplicate = (FixedWithNextNode) duplicates.get(anchor);
                 // move dependencies on the ValueAnchorNode to the previous BeginNode
-                BeginNode prevBegin = BeginNode.prevBegin(forwardEnd);
+                AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(forwardEnd);
                 anchorDuplicate.replaceAtUsages(InputType.Guard, prevBegin);
                 anchorDuplicate.replaceAtUsages(InputType.Anchor, prevBegin);
-                assert anchorDuplicate.usages().isEmpty();
+                assert anchorDuplicate.hasNoUsages();
 
                 FixedNode next = anchorDuplicate.next();
                 anchorDuplicate.setNext(null);
@@ -448,7 +449,7 @@
          * @return The newly created end node.
          */
         private AbstractEndNode createNewMerge(FixedNode successor, FrameState stateAfterMerge) {
-            MergeNode newBottomMerge = graph.add(new MergeNode());
+            AbstractMergeNode newBottomMerge = graph.add(new MergeNode());
             AbstractEndNode newBottomEnd = graph.add(new EndNode());
             newBottomMerge.addForwardEnd(newBottomEnd);
             newBottomMerge.setStateAfter(stateAfterMerge);
@@ -477,7 +478,7 @@
          *            for newly created phis and to as a target for dependencies that pointed into
          *            the duplicated set of nodes.
          */
-        private void expandDuplicated(Set<Node> duplicatedNodes, MergeNode newBottomMerge) {
+        private void expandDuplicated(Set<Node> duplicatedNodes, AbstractMergeNode newBottomMerge) {
             Deque<Node> worklist = new ArrayDeque<>(duplicatedNodes);
 
             while (!worklist.isEmpty()) {
@@ -487,7 +488,7 @@
             }
         }
 
-        private void processUsages(Node duplicated, Set<Node> duplicatedNodes, MergeNode newBottomMerge, Deque<Node> worklist) {
+        private void processUsages(Node duplicated, Set<Node> duplicatedNodes, AbstractMergeNode newBottomMerge, Deque<Node> worklist) {
             Set<Node> unique = Node.newSet();
             duplicated.usages().snapshotTo(unique);
             Node newOutsideClone = null;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/UseTrappingNullChecksPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/UseTrappingNullChecksPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,7 +29,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.util.*;
@@ -47,7 +46,7 @@
         if (context.getTarget().implicitNullCheckLimit <= 0) {
             return;
         }
-        assert graph.getGuardsStage().ordinal() >= GuardsStage.AFTER_FSA.ordinal();
+        assert graph.getGuardsStage().areFrameStatesAtDeopts();
 
         for (DeoptimizeNode deopt : graph.getNodes(DeoptimizeNode.class)) {
             tryUseTrappingNullCheck(deopt, deopt.predecessor(), deopt.reason(), deopt.getSpeculation());
@@ -59,8 +58,8 @@
 
     private static void tryUseTrappingNullCheck(MetaAccessProvider metaAccessProvider, DynamicDeoptimizeNode deopt) {
         Node predecessor = deopt.predecessor();
-        if (predecessor instanceof MergeNode) {
-            MergeNode merge = (MergeNode) predecessor;
+        if (predecessor instanceof AbstractMergeNode) {
+            AbstractMergeNode merge = (AbstractMergeNode) predecessor;
 
             // Process each predecessor at the merge, unpacking the reasons and speculations as
             // needed.
@@ -116,23 +115,23 @@
         if (speculation != null && !speculation.equals(JavaConstant.NULL_POINTER)) {
             return;
         }
-        if (predecessor instanceof MergeNode) {
-            MergeNode merge = (MergeNode) predecessor;
+        if (predecessor instanceof AbstractMergeNode) {
+            AbstractMergeNode merge = (AbstractMergeNode) predecessor;
             if (merge.phis().isEmpty()) {
                 for (AbstractEndNode end : merge.cfgPredecessors().snapshot()) {
                     checkPredecessor(deopt, end.predecessor(), deoptimizationReason);
                 }
             }
-        } else if (predecessor instanceof BeginNode) {
+        } else if (predecessor instanceof AbstractBeginNode) {
             checkPredecessor(deopt, predecessor, deoptimizationReason);
         }
     }
 
     private static void checkPredecessor(AbstractDeoptimizeNode deopt, Node predecessor, DeoptimizationReason deoptimizationReason) {
         Node current = predecessor;
-        BeginNode branch = null;
-        while (current instanceof BeginNode) {
-            branch = (BeginNode) current;
+        AbstractBeginNode branch = null;
+        while (current instanceof AbstractBeginNode) {
+            branch = (AbstractBeginNode) current;
             if (branch.anchored().isNotEmpty()) {
                 // some input of the deopt framestate is anchored to this branch
                 return;
@@ -160,8 +159,8 @@
             metricTrappingNullCheckUnreached.increment();
         }
         IsNullNode isNullNode = (IsNullNode) condition;
-        BeginNode nonTrappingContinuation = ifNode.falseSuccessor();
-        BeginNode trappingContinuation = ifNode.trueSuccessor();
+        AbstractBeginNode nonTrappingContinuation = ifNode.falseSuccessor();
+        AbstractBeginNode trappingContinuation = ifNode.trueSuccessor();
         NullCheckNode trappingNullCheck = deopt.graph().add(new NullCheckNode(isNullNode.getValue()));
         trappingNullCheck.setStateBefore(deopt.stateBefore());
         deopt.graph().replaceSplit(ifNode, trappingNullCheck, nonTrappingContinuation);
@@ -172,7 +171,7 @@
          * then remove the Begin from the graph.
          */
         nonTrappingContinuation.replaceAtUsages(InputType.Guard, trappingNullCheck);
-        if (nonTrappingContinuation.getClass() == BeginNode.class) {
+        if (nonTrappingContinuation instanceof BeginNode) {
             FixedNode next = nonTrappingContinuation.next();
             nonTrappingContinuation.clearSuccessors();
             trappingNullCheck.setNext(next);
@@ -182,7 +181,7 @@
         }
 
         GraphUtil.killCFG(trappingContinuation);
-        if (isNullNode.usages().isEmpty()) {
+        if (isNullNode.hasNoUsages()) {
             GraphUtil.killWithUnusedFloatingInputs(isNullNode);
         }
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -50,7 +50,7 @@
         }
 
         @Override
-        public boolean merge(MergeNode merge, List<State> withStates) {
+        public boolean merge(AbstractMergeNode merge, List<State> withStates) {
             for (State other : withStates) {
                 anchoredValues.retainAll(other.anchoredValues);
             }
@@ -81,7 +81,7 @@
                         state.anchoredValues.add(anchored);
                     }
                 }
-                if (anchor.getAnchoredNode() == null && anchor.usages().isEmpty()) {
+                if (anchor.getAnchoredNode() == null && anchor.hasNoUsages()) {
                     node.graph().removeFixed(anchor);
                 }
             }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/BaseReduction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +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.phases.common.cfs;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.graph.*;
-import com.oracle.graal.phases.tiers.*;
-
-/**
- * <p>
- * For readability purposes the code realizing control-flow-sensitive reductions is chopped into
- * several classes in an inheritance hierarchy, this class being their common ancestor. That way,
- * many dependencies can be ruled out immediately (e.g., private members of a class aren't needed by
- * other classes). The whole thing is reminiscent of trait-based patterns, minus their
- * disadvantages.
- * </p>
- *
- * <p>
- * This class makes available little more than a few fields and a few utility methods used
- * throughout the remaining components making up control-flow sensitive reductions.
- * </p>
- *
- * <p>
- * The laundry-list of all flow-sensitive reductions is summarized in
- * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}
- * </p>
- *
- */
-public abstract class BaseReduction extends SinglePassNodeIterator<State> {
-
-    protected static final DebugMetric metricCheckCastRemoved = Debug.metric("FSR-CheckCastRemoved");
-    protected static final DebugMetric metricGuardingPiNodeRemoved = Debug.metric("FSR-GuardingPiNodeRemoved");
-    protected static final DebugMetric metricFixedGuardNodeRemoved = Debug.metric("FSR-FixedGuardNodeRemoved");
-    protected static final DebugMetric metricMethodResolved = Debug.metric("FSR-MethodResolved");
-    protected static final DebugMetric metricUnconditionalDeoptInserted = Debug.metric("FSR-UnconditionalDeoptInserted");
-
-    /**
-     * <p>
-     * Upon visiting a {@link com.oracle.graal.nodes.FixedNode FixedNode} in
-     * {@link #node(com.oracle.graal.nodes.FixedNode)}, an impossible path may be detected. We'd
-     * like to insert an unconditional deoptimizing node as a hint for Dead Code Elimination to kill
-     * that branch. However that can't be made on the go (a
-     * {@link com.oracle.graal.nodes.ControlSinkNode} can't have successors). Thus their insertion
-     * is postponed till the end of a round of
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}.
-     * </p>
-     *
-     * @see State#impossiblePath()
-     * @see com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#finished()
-     */
-    public static class PostponedDeopt {
-
-        private final boolean goesBeforeFixed;
-        private final FixedWithNextNode fixed;
-        private final DeoptimizationReason deoptReason;
-
-        public PostponedDeopt(boolean goesBeforeFixed, FixedWithNextNode fixed, DeoptimizationReason deoptReason) {
-            this.goesBeforeFixed = goesBeforeFixed;
-            this.fixed = fixed;
-            this.deoptReason = deoptReason;
-        }
-
-        /*
-         * TODO Actually, we want to emit instructions to signal "should-not-reach-here". An
-         * imperfect substitute (as done here) is emitting FixedGuard(false).
-         * "should-not-reach-here" would be better for the runtime error it raises, thus pointing to
-         * a bug in FlowSensitiveReduction (the code was reachable, after all).
-         */
-        public void doRewrite(LogicNode falseConstant) {
-            metricUnconditionalDeoptInserted.increment();
-            StructuredGraph graph = fixed.graph();
-            // have to insert a FixedNode other than a ControlSinkNode
-            FixedGuardNode buckStopsHere = graph.add(new FixedGuardNode(falseConstant, deoptReason, DeoptimizationAction.None));
-            if (goesBeforeFixed) {
-                fixed.replaceAtPredecessor(buckStopsHere);
-            } else {
-                graph.addAfterFixed(fixed, buckStopsHere);
-            }
-        }
-
-    }
-
-    protected static class PostponedDeopts extends ArrayList<PostponedDeopt> {
-
-        private static final long serialVersionUID = 7188324432387121238L;
-
-        /**
-         * Enqueue adding a {@link com.oracle.graal.nodes.DeoptimizeNode} right before the fixed
-         * argument, will be done once we're done traversing the graph.
-         *
-         * @see #finished()
-         */
-        void addDeoptBefore(FixedWithNextNode fixed, DeoptimizationReason deoptReason) {
-            add(new PostponedDeopt(true, fixed, deoptReason));
-        }
-
-        /**
-         * Enqueue adding a {@link com.oracle.graal.nodes.DeoptimizeNode} right after the fixed
-         * argument, will be done once we're done traversing the graph.
-         *
-         * @see #finished()
-         */
-        void addDeoptAfter(FixedWithNextNode fixed, DeoptimizationReason deoptReason) {
-            add(new PostponedDeopt(false, fixed, deoptReason));
-        }
-
-    }
-
-    /**
-     * <p>
-     * One of the promises of
-     * {@link com.oracle.graal.phases.common.cfs.EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)}
-     * is that a "maximally reduced" node is returned. That is achieved in part by leveraging
-     * {@link Canonicalizable#canonical(com.oracle.graal.graph.spi.CanonicalizerTool)}. Doing so, in
-     * turn, requires this subclass of {@link com.oracle.graal.graph.spi.CanonicalizerTool}.
-     * </p>
-     */
-    public final class Tool implements CanonicalizerTool {
-
-        private final PhaseContext context;
-
-        public Tool(PhaseContext context) {
-            this.context = context;
-        }
-
-        @Override
-        public Assumptions assumptions() {
-            return context.getAssumptions();
-        }
-
-        @Override
-        public MetaAccessProvider getMetaAccess() {
-            return context.getMetaAccess();
-        }
-
-        @Override
-        public ConstantReflectionProvider getConstantReflection() {
-            return context.getConstantReflection();
-        }
-
-        @Override
-        public boolean canonicalizeReads() {
-            return false;
-        }
-    } // end of class FlowSensitiveReduction.Tool
-
-    protected final LogicConstantNode trueConstant;
-    protected final LogicConstantNode falseConstant;
-    protected final ConstantNode nullConstant;
-
-    protected final CanonicalizerTool tool;
-    protected final StructuredGraph graph;
-
-    protected EquationalReasoner reasoner;
-
-    protected final PostponedDeopts postponedDeopts = new PostponedDeopts();
-
-    protected BaseReduction(StartNode start, State initialState, PhaseContext context) {
-        super(start, initialState);
-        graph = start.graph();
-        trueConstant = LogicConstantNode.tautology(graph);
-        falseConstant = LogicConstantNode.contradiction(graph);
-        nullConstant = ConstantNode.defaultForKind(Kind.Object, graph); // ConstantNode.forObject(null,
-                                                                        // metaAccess, graph);
-        tool = new Tool(context);
-        reasoner = new EquationalReasoner(graph, tool, trueConstant, falseConstant, nullConstant);
-    }
-
-    /**
-     * <p>
-     * Test whether the output's stamp is an upcast of that of the input. For example, upon
-     * replacing a CheckCastNode in
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#lowerCheckCastAnchorFriendlyWay(com.oracle.graal.nodes.java.CheckCastNode, com.oracle.graal.nodes.ValueNode)}
-     * we don't want to be left with an upcast, as it loses precision.
-     * </p>
-     *
-     * <p>
-     * As usual with object stamps, they can be compared along different dimensions (alwaysNull,
-     * etc.) It's enough for one such dimension to show precision loss for the end result to be
-     * reported as such.
-     * </p>
-     *
-     */
-    public static boolean precisionLoss(ValueNode input, ValueNode output) {
-        ObjectStamp inputStamp = (ObjectStamp) input.stamp();
-        ObjectStamp outputStamp = (ObjectStamp) output.stamp();
-        if (FlowUtil.isMorePrecise(inputStamp.type(), outputStamp.type())) {
-            return true;
-        }
-        if (lessThan(outputStamp.alwaysNull(), inputStamp.alwaysNull())) {
-            return true;
-        }
-        if (lessThan(outputStamp.nonNull(), inputStamp.nonNull())) {
-            return true;
-        }
-        if (lessThan(outputStamp.isExactType(), inputStamp.isExactType())) {
-            return true;
-        }
-        return false;
-    }
-
-    private static boolean lessThan(boolean a, boolean b) {
-        return a == false && b == true;
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CastCheckExtractor.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +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.phases.common.cfs;
-
-import com.oracle.graal.api.meta.ResolvedJavaType;
-import com.oracle.graal.nodes.LogicNode;
-import com.oracle.graal.nodes.ShortCircuitOrNode;
-import com.oracle.graal.nodes.ValueNode;
-import com.oracle.graal.nodes.calc.IsNullNode;
-import com.oracle.graal.nodes.java.InstanceOfNode;
-
-/**
- * @see #extract(com.oracle.graal.nodes.LogicNode)
- */
-class CastCheckExtractor {
-
-    public final ResolvedJavaType type;
-    public final ValueNode subject;
-
-    CastCheckExtractor(ResolvedJavaType type, ValueNode subject) {
-        this.type = type;
-        this.subject = subject;
-    }
-
-    private static CastCheckExtractor extractCastCheckInfo(LogicNode x, LogicNode y) {
-        if (x instanceof IsNullNode) {
-            IsNullNode isNull = (IsNullNode) x;
-            ValueNode subject = isNull.getValue();
-            if (isInstanceOfCheckOn(y, subject)) {
-                InstanceOfNode iOf = (InstanceOfNode) y;
-                return new CastCheckExtractor(iOf.type(), subject);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * This method detects whether the argument realizes the CheckCast pattern. If so, distills and
-     * returns the essentials of such check, otherwise returns null.
-     */
-    static CastCheckExtractor extract(LogicNode cond) {
-        if (!(cond instanceof ShortCircuitOrNode)) {
-            return null;
-        }
-        ShortCircuitOrNode orNode = (ShortCircuitOrNode) cond;
-        if (orNode.isXNegated() || orNode.isYNegated()) {
-            return null;
-        }
-        CastCheckExtractor result = extractCastCheckInfo(orNode.getX(), orNode.getY());
-        if (result != null) {
-            return result;
-        }
-        result = extractCastCheckInfo(orNode.getY(), orNode.getX());
-        return result;
-    }
-
-    /**
-     * Porcelain method.
-     */
-    static boolean isInstanceOfCheckOn(LogicNode cond, ValueNode subject) {
-        if (!(cond instanceof InstanceOfNode)) {
-            return false;
-        }
-        InstanceOfNode io = (InstanceOfNode) cond;
-        return io.getValue() == subject;
-    }
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/CheckCastReduction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,364 +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.phases.common.cfs;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.IsNullNode;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.compiler.common.type.ObjectStamp;
-import com.oracle.graal.compiler.common.type.StampFactory;
-import com.oracle.graal.nodes.type.StampTool;
-import com.oracle.graal.phases.tiers.PhaseContext;
-
-import static com.oracle.graal.api.meta.DeoptimizationAction.InvalidateReprofile;
-import static com.oracle.graal.api.meta.DeoptimizationReason.*;
-import static com.oracle.graal.nodes.extended.BranchProbabilityNode.NOT_FREQUENT_PROBABILITY;
-
-/**
- * <p>
- * This class implements control-flow sensitive reductions for
- * {@link com.oracle.graal.nodes.java.CheckCastNode}.
- * </p>
- *
- * <p>
- * The laundry-list of all flow-sensitive reductions is summarized in
- * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}
- * </p>
- *
- * @see #visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
- */
-public abstract class CheckCastReduction extends GuardingPiReduction {
-
-    public CheckCastReduction(StartNode start, State initialState, PhaseContext context) {
-        super(start, initialState, context);
-    }
-
-    /**
-     * <p>
-     * Upon visiting a {@link com.oracle.graal.nodes.java.CheckCastNode}, based on flow-sensitive
-     * conditions, we need to determine whether:
-     * <ul>
-     * <li>it is redundant (in which case it should be simplified), or</li>
-     * <li>flow-sensitive information can be gained from it. "Gain information from it" requires
-     * lowering the {@link com.oracle.graal.nodes.java.CheckCastNode} such that a
-     * {@link com.oracle.graal.nodes.extended.GuardingNode GuardingNode} becomes available.</li>
-     * </ul>
-     * </p>
-     *
-     * <p>
-     * This method realizes the above by testing first for situations that require less work:
-     * <ol>
-     * <li>the stamp of the subject deems the check-cast redundant or unsatisfiable (ie,
-     * always-succeeds or always-fails). A previous round of canonicalization takes care of this
-     * situation, however it can also arise due to consecutive runs of
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase} without intervening
-     * {@link com.oracle.graal.phases.common.CanonicalizerPhase canonicalization}.</li>
-     * <li>
-     * flow-sensitive information reveals the subject to be null, trivially fulfilling the
-     * check-cast.</li>
-     * <li>
-     * flow-sensitive information reveals the subject to be narrower than it stamp says. If the
-     * narrower ("downcasted") value fulfills the check-cast, the check-cast is removed.</li>
-     * <li>
-     * otherwise the check-cast provides additional flow-sensitive information. For that, a
-     * {@link com.oracle.graal.nodes.FixedGuardNode} is needed, as described in
-     * {@link #lowerCheckCastAnchorFriendlyWay(com.oracle.graal.nodes.java.CheckCastNode, com.oracle.graal.nodes.ValueNode)}
-     * . Please notice this lowering is currently performed unconditionally: it might occur no
-     * flow-sensitive reduction is enabled down the road.</li>
-     * </ol>
-     * </p>
-     *
-     * <p>
-     * Precondition: the inputs (ie, object) hasn't been deverbosified yet.
-     * </p>
-     */
-    protected final void visitCheckCastNode(CheckCastNode checkCast) {
-
-        /*
-         * checkCast.object() hasn't been deverbosified yet.
-         */
-
-        if (!FlowUtil.hasLegalObjectStamp(checkCast)) {
-            // This situation is exercised by test Class_cast01
-            return;
-        }
-
-        final ValueNode subject = checkCast.object();
-        final ResolvedJavaType toType = checkCast.type();
-        ObjectStamp subjectStamp = (ObjectStamp) subject.stamp();
-        ResolvedJavaType subjectType = subjectStamp.type();
-
-        // --------- checkCast deemed redundant by subject-stamp alone ---------
-        // --------- in particular due to stamp informing always null ----------
-        boolean isRedundantPerStamp = StampTool.isPointerAlwaysNull(subject) || (subjectType != null && toType.isAssignableFrom(subjectType));
-        if (isRedundantPerStamp) {
-            metricCheckCastRemoved.increment();
-            checkCast.replaceAtUsages(subject);
-            graph.removeFixed(checkCast);
-            return;
-        }
-
-        assert !StampTool.isPointerAlwaysNull(subject) : "Null as per stamp subjects should have been handled above";
-
-        // --------- checkCast deemed unsatisfiable by subject-stamp alone ---------
-        if (state.knownNotToPassCheckCast(subject, toType)) {
-            postponedDeopts.addDeoptBefore(checkCast, checkCast.isForStoreCheck() ? ArrayStoreException : ClassCastException);
-            state.impossiblePath();
-            // let FixedGuardNode(false).simplify() prune the dead-code control-path
-            return;
-        }
-
-        /*
-         * Remark: subject may be TypeProxyNode, GuardedValueNode, ProxyNode, GuardingPiNode, among
-         * others.
-         */
-
-        PiNode untrivialNull = reasoner.nonTrivialNull(subject);
-        if (untrivialNull != null) {
-            metricCheckCastRemoved.increment();
-            checkCast.replaceAtUsages(untrivialNull);
-            graph.removeFixed(checkCast);
-            return;
-        }
-
-        Witness w = state.typeInfo(subject);
-
-        if (w == null) {
-            /*
-             * If there's no witness, attempting `downcast(subject)` is futile.
-             */
-            visitCheckCastNodeLackingWitness(checkCast);
-            return;
-        }
-
-        visitCheckCastNodeWithWitness(checkCast);
-
-    }
-
-    /**
-     * Given that no witness is available for the {@link com.oracle.graal.nodes.java.CheckCastNode}
-     * 's subject there's no point in downcasting such subject, ie no
-     * {@link com.oracle.graal.nodes.PiNode} can be fabricated for the subject.
-     *
-     * @see #lowerCheckCastAnchorFriendlyWay(com.oracle.graal.nodes.java.CheckCastNode,
-     *      com.oracle.graal.nodes.ValueNode)
-     *
-     */
-    private void visitCheckCastNodeLackingWitness(CheckCastNode checkCast) {
-        final ValueNode subject = checkCast.object();
-        final ResolvedJavaType toType = checkCast.type();
-        if (toType.isInterface()) {
-            return;
-        }
-        assert reasoner.downcast(subject) == subject;
-        lowerCheckCastAnchorFriendlyWay(checkCast, subject);
-    }
-
-    /**
-     * Porcelain method.
-     *
-     * <p>
-     * Rather than tracking the CheckCastNode via {@link com.oracle.graal.phases.common.cfs.State
-     * State} (doing so would add a special case because a
-     * {@link com.oracle.graal.nodes.java.CheckCastNode} isn't a
-     * {@link com.oracle.graal.nodes.extended.GuardingNode guarding node}) this method creates an
-     * anchor by lowering the CheckCastNode into a FixedGuardNode. Not the same as the
-     * {@link com.oracle.graal.nodes.java.CheckCastNode#lower(com.oracle.graal.nodes.spi.LoweringTool)
-     * lowering of a CheckCastNode} which results in a {@link com.oracle.graal.nodes.GuardingPiNode}
-     * (which is not a {@link com.oracle.graal.nodes.extended.GuardingNode guarding node}).
-     * </p>
-     *
-     * <p>
-     * With that, state tracking can proceed as usual.
-     * </p>
-     *
-     * <p>
-     * TODO This lowering is currently performed unconditionally: it might occur no flow-sensitive
-     * reduction is enabled down the road
-     * </p>
-     *
-     * @see #visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
-     *
-     */
-    public void lowerCheckCastAnchorFriendlyWay(CheckCastNode checkCast, ValueNode subject) {
-        ValueNode originalCheckCastObject = checkCast.object();
-
-        ObjectStamp subjectStamp = (ObjectStamp) subject.stamp();
-        final ResolvedJavaType toType = checkCast.type();
-        ObjectStamp resultStamp = (ObjectStamp) StampFactory.declaredTrusted(toType);
-        JavaTypeProfile profile = checkCast.profile();
-
-        assert FlowUtil.isLegalObjectStamp(subjectStamp);
-        assert subjectStamp.type() == null || !toType.isAssignableFrom(subjectStamp.type()) : "No need to lower in an anchor-friendly way in the first place";
-
-        /*
-         * Depending on what is known about the subject:
-         * 
-         * (a) definitely-non-null
-         * 
-         * (b) null-not-seen-in-profiling
-         * 
-         * (c) runtime-null-check-needed
-         * 
-         * the condition (of the cast-guard to be emitted) and the stamp (of the PiNode to be
-         * emitted) are going to be different. Each of the three branches below deals with one of
-         * the cases above.
-         */
-        LogicNode condition;
-        if (subjectStamp.nonNull()) {
-            /*
-             * (1 of 3) definitely-non-null
-             */
-            // addWithoutUnique for the same reason as in CheckCastNode.lower()
-            condition = graph.addWithoutUnique(new InstanceOfNode(toType, subject, profile));
-            reasoner.added.add(condition);
-            resultStamp = FlowUtil.asNonNullStamp(resultStamp);
-            // TODO fix in CheckCastNode.lower()
-        } else {
-            if (profile != null && profile.getNullSeen() == ProfilingInfo.TriState.FALSE) {
-                /*
-                 * (2 of 3) null-not-seen-in-profiling
-                 */
-                IsNullNode isNN = graph.unique(new IsNullNode(subject));
-                reasoner.added.add(isNN);
-                FixedGuardNode nullCheck = graph.add(new FixedGuardNode(isNN, UnreachedCode, InvalidateReprofile, true));
-                graph.addBeforeFixed(checkCast, nullCheck);
-                // not calling wrapInPiNode() because we don't want to rememberSubstitution()
-                PiNode nonNullGuarded = graph.unique(new PiNode(subject, FlowUtil.asNonNullStamp(subjectStamp), nullCheck));
-                reasoner.added.add(nonNullGuarded);
-                // addWithoutUnique for the same reason as in CheckCastNode.lower()
-                condition = graph.addWithoutUnique(new InstanceOfNode(toType, nonNullGuarded, profile));
-                reasoner.added.add(condition);
-                resultStamp = FlowUtil.asNonNullStamp(resultStamp);
-            } else {
-                /*
-                 * (3 of 3) runtime-null-check-needed
-                 */
-                // addWithoutUnique for the same reason as in CheckCastNode.lower()
-                InstanceOfNode typeTest = graph.addWithoutUnique(new InstanceOfNode(toType, subject, profile));
-                reasoner.added.add(typeTest);
-                LogicNode nullTest = graph.unique(new IsNullNode(subject));
-                reasoner.added.add(nullTest);
-                // TODO (ds) replace with probability of null-seen when available
-                final double shortCircuitProbability = NOT_FREQUENT_PROBABILITY;
-                condition = LogicNode.or(nullTest, typeTest, shortCircuitProbability);
-                reasoner.added.add(condition);
-            }
-        }
-
-        /*
-         * Add a cast-guard (checking only what needs to be checked) and a PiNode (to be used in
-         * place of the CheckCastNode).
-         */
-        FixedGuardNode castGuard = graph.add(new FixedGuardNode(condition, checkCast.isForStoreCheck() ? ArrayStoreException : ClassCastException, InvalidateReprofile));
-        graph.addBeforeFixed(checkCast, castGuard);
-
-        assert FlowUtil.isLegalObjectStamp(resultStamp);
-        Witness w = state.typeInfo(subject);
-        assert !isTypeOfWitnessBetter(w, resultStamp);
-
-        if (!FlowUtil.lacksUsages(checkCast)) {
-            // not calling wrapInPiNode() because we don't want to rememberSubstitution()
-            PiNode checkedObject = graph.unique(new PiNode(subject, resultStamp, castGuard));
-            reasoner.added.add(checkedObject);
-            assert !precisionLoss(originalCheckCastObject, checkedObject);
-            assert !precisionLoss(subject, checkedObject);
-            checkCast.replaceAtUsages(checkedObject);
-        }
-
-        graph.removeFixed(checkCast);
-
-        if (resultStamp.nonNull()) {
-            state.trackIO(subject, toType, castGuard);
-        } else {
-            state.trackCC(subject, toType, castGuard);
-        }
-    }
-
-    /**
-     * Porcelain method.
-     */
-    public static boolean isTypeOfWitnessBetter(Witness w, ObjectStamp stamp) {
-        if (w == null) {
-            return false;
-        }
-        return FlowUtil.isMorePrecise(w.type(), stamp.type());
-    }
-
-    /**
-     *
-     * Please note in this method "subject" refers to the downcasted input to the checkCast.
-     *
-     * @see #visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
-     */
-    private void visitCheckCastNodeWithWitness(CheckCastNode checkCast) {
-
-        final ResolvedJavaType toType = checkCast.type();
-
-        ValueNode subject;
-        if (checkCast.object() instanceof CheckCastNode) {
-            subject = reasoner.downcast(checkCast);
-            if (subject == checkCast) {
-                subject = reasoner.downcast(checkCast.object());
-            }
-        } else {
-            subject = reasoner.downcast(checkCast.object());
-        }
-
-        ObjectStamp subjectStamp = (ObjectStamp) subject.stamp();
-        ResolvedJavaType subjectType = subjectStamp.type();
-
-        /*
-         * At this point, two sources of (partial) information: the witness and the stamp of
-         * subject. The latter might be more precise than the witness (eg, subject might be
-         * GuardedValueNode)
-         */
-
-        // --------- checkCast made redundant by downcasting its input ---------
-        if (subjectType != null && toType.isAssignableFrom(subjectType)) {
-            checkCast.replaceAtUsages(subject);
-            graph.removeFixed(checkCast);
-            return;
-        }
-
-        /*
-         * At this point, `downcast()` might or might not have delivered a more precise value. If
-         * more precise, it wasn't precise enough to conform to `toType`. Even so, for the
-         * `toType.isInterface()` case (dealt with below) we'll replace the checkCast's input with
-         * that value (its class-stamp being more precise than the original).
-         */
-
-        if (toType.isInterface()) {
-            boolean wasDowncasted = (subject != checkCast.object());
-            if (wasDowncasted) {
-                FlowUtil.replaceInPlace(checkCast, checkCast.object(), subject);
-            }
-            return;
-        }
-
-        lowerCheckCastAnchorFriendlyWay(checkCast, subject);
-
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/EquationalReasoner.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,960 +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.phases.common.cfs;
-
-import java.util.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-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.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.nodes.util.*;
-
-/**
- * <p>
- * This class implements a simple partial evaluator that recursively reduces a given
- * {@link com.oracle.graal.nodes.calc.FloatingNode} into a simpler one based on the current state.
- * Such evaluator comes handy when visiting a {@link com.oracle.graal.nodes.FixedNode} N, just
- * before updating the state for N. At the pre-state, an {@link EquationalReasoner} can be used to
- * reduce N's inputs (actually only those inputs of Value and Condition
- * {@link com.oracle.graal.nodeinfo.InputType InputType}). For an explanation of where it's
- * warranted to replace "old input" with "reduced input", see the inline comments in method
- * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node n) deverbosify(Node n)}
- * </p>
- *
- * <p>
- * The name {@link EquationalReasoner EquationalReasoner} was chosen because it conveys what it
- * does.
- * </p>
- */
-public final class EquationalReasoner {
-
-    private static final DebugMetric metricInstanceOfRemoved = Debug.metric("FSR-InstanceOfRemoved");
-    private static final DebugMetric metricNullCheckRemoved = Debug.metric("FSR-NullCheckRemoved");
-    private static final DebugMetric metricObjectEqualsRemoved = Debug.metric("FSR-ObjectEqualsRemoved");
-    private static final DebugMetric metricEquationalReasoning = Debug.metric("FSR-EquationalReasoning");
-    private static final DebugMetric metricDowncasting = Debug.metric("FSR-Downcasting");
-    private static final DebugMetric metricNullInserted = Debug.metric("FSR-NullInserted");
-
-    private final StructuredGraph graph;
-    private final CanonicalizerTool tool;
-    private final LogicConstantNode trueConstant;
-    private final LogicConstantNode falseConstant;
-    private final ConstantNode nullConstant;
-
-    private State state;
-    private NodeBitMap visited;
-
-    /**
-     * The reduction of a {@link com.oracle.graal.nodes.calc.FloatingNode} performed by
-     * {@link EquationalReasoner EquationalReasoner} may result in a FloatingNode being added to the
-     * graph. Those nodes aren't tracked in the {@link EquationalReasoner#visited visited}
-     * {@link com.oracle.graal.graph.NodeBitMap NodeBitMap} but in this set instead (those nodes are
-     * added after the {@link com.oracle.graal.graph.NodeBitMap} was obtained).
-     */
-    final Set<ValueNode> added = Node.newSet();
-
-    /**
-     * The reduction of a FloatingNode performed by {@link EquationalReasoner EquationalReasoner}
-     * may result in a FloatingNode being added to the graph. Those nodes are tracked in this map,
-     * to avoid recomputing them.
-     *
-     * The substitutions tracked in this field become invalid as described in
-     * {@link #updateState(com.oracle.graal.phases.common.cfs.State) updateState(State)}
-     */
-    private final Map<ValueNode, ValueNode> substs = Node.newIdentityMap();
-
-    public EquationalReasoner(StructuredGraph graph, CanonicalizerTool tool, LogicConstantNode trueConstant, LogicConstantNode falseConstant, ConstantNode nullConstant) {
-        this.graph = graph;
-        this.tool = tool;
-        this.trueConstant = trueConstant;
-        this.falseConstant = falseConstant;
-        this.nullConstant = nullConstant;
-    }
-
-    /**
-     * {@link #added} grows during a run of
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase
-     * FlowSensitiveReductionPhase}, and doesn't survive across runs.
-     */
-    public void forceState(State s) {
-        state = s;
-        assert state.repOK();
-        substs.clear();
-        added.clear();
-        visited = null;
-        versionNrAsofLastForce = s.versionNr;
-    }
-
-    /**
-     * <p>
-     * Gaining more precise type information about an SSA value doesn't "invalidate" as such any of
-     * the substitutions tracked in {@link EquationalReasoner#substs substs}, at least not in the
-     * sense of making the value tracked by one such entry "wrong". However, clearing the
-     * {@link EquationalReasoner#substs substs} is still justified because next time they are
-     * computed, the newly computed reduction could (in principle) be more effective (due to the
-     * more precise type information).
-     * </p>
-     *
-     * <p>
-     * Between clearings of cached substitutions, it is expected they get applied a number of times
-     * to justify the bookkeeping cost.
-     * </p>
-     *
-     */
-    public void updateState(State s) {
-        assert s != null;
-        if (state == null || state != s || state.versionNr != versionNrAsofLastForce) {
-            forceState(s);
-        }
-    }
-
-    private int versionNrAsofLastForce = 0;
-
-    /**
-     * Reduce the argument based on the state at the program point where the argument is consumed.
-     * For most FixedNodes, that's how their inputs can be reduced. Two exceptions:
-     * <ul>
-     * <li>
-     * the condition of a {@link com.oracle.graal.nodes.GuardingPiNode}, see
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)}
-     * </li>
-     * <li>
-     * the condition of a {@link com.oracle.graal.nodes.FixedGuardNode}, see
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitFixedGuardNode(com.oracle.graal.nodes.FixedGuardNode)}
-     * </li>
-     *
-     * </ul>
-     *
-     *
-     * <p>
-     * Part of the reduction work is delegated to baseCase-style reducers, whose contract explicitly
-     * requires them not to deverbosify the argument's inputs --- the decision is made based on the
-     * argument only (thus "base case"). Returning the unmodified argument is how a baseCase-style
-     * tells this method to fall to the default case (for a floating node only: walk into the
-     * argument's inputs, canonicalize followed by
-     * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)
-     * rememberSubstitution()} if any input changed).
-     * </p>
-     *
-     * <p>
-     * This method must behave as a function (idempotent query method), ie refrain from mutating the
-     * state other than updating caches:
-     * <ul>
-     * <li>{@link EquationalReasoner#added EquationalReasoner#added},</li>
-     * <li>{@link EquationalReasoner#visited EquationalReasoner#visited} and</li>
-     * <li>the cache updated via
-     * {@link EquationalReasoner#rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)
-     * EquationalReasoner#rememberSubstitution(ValueNode, FloatingNode)}.</li>
-     * </ul>
-     * </p>
-     *
-     * <p>
-     * In turn, baseCase-style reducers are even more constrained: besides behaving as functions,
-     * their contract prevents them from updating any caches (basically because they already grab
-     * the answer from caches, if the answer isn't there they should just return their unmodified
-     * argument).
-     * </p>
-     *
-     * <p>
-     * This method returns:
-     * <ul>
-     * <li>
-     * the original argument, in case no reduction possible.</li>
-     * <li>
-     * a {@link com.oracle.graal.nodes.ValueNode ValueNode} different from the argument, in case the
-     * conditions for a reduction were met. The node being returned might be already in the graph.
-     * In any case it's canonicalized already, the caller need not perform that again.</li>
-     * <li>
-     * the unmodified argument, in case no reduction was made. Otherwise, a maximally reduced
-     * {@link com.oracle.graal.nodes.ValueNode}.</li>
-     * </ul>
-     * </p>
-     *
-     * @see com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#deverbosifyInputsInPlace(com.oracle.graal.nodes.ValueNode)
-     *
-     * @see com.oracle.graal.phases.common.cfs.BaseReduction.Tool
-     *
-     */
-    public Node deverbosify(final Node n) {
-
-        // --------------------------------------------------------------------
-        // cases that don't initiate any call-chain that may enter this method
-        // --------------------------------------------------------------------
-
-        if (n == null) {
-            return null;
-        }
-        assert !(n instanceof GuardNode) : "This phase not intended to run during MidTier";
-        if (!(n instanceof ValueNode)) {
-            return n;
-        }
-        ValueNode v = (ValueNode) n;
-        if (v.stamp() instanceof IllegalStamp) {
-            return v;
-        }
-        if (FlowUtil.isLiteralNode(v)) {
-            return v;
-        }
-        ValueNode result = substs.get(v);
-        if (result != null) {
-            // picked cached substitution
-            return result;
-        }
-        if (FlowUtil.hasLegalObjectStamp(v) && state.isNull(v)) {
-            // it's ok to return nullConstant in deverbosify unlike in downcast
-            metricNullInserted.increment();
-            return nullConstant;
-        }
-        if (v instanceof ValueProxy) {
-            return v;
-        }
-        if (!(n instanceof FloatingNode)) {
-            return n;
-        }
-        if ((visited != null && visited.contains(n)) || added.contains(v)) {
-            return v;
-        }
-
-        // --------------------------------------------------------------------
-        // stack overflow prevention via added, visited
-        // --------------------------------------------------------------------
-
-        if (visited == null) {
-            visited = graph.createNodeBitMap();
-        }
-        visited.mark(n);
-
-        /*
-         * Past this point, if we ever want `n` to be deverbosified, it must be looked-up by one of
-         * the cases above. One sure way to achieve that is with `rememberSubstitution(old, new)`
-         */
-
-        /*
-         * `deverbosifyFloatingNode()` will drill down over floating inputs, when that not possible
-         * anymore it resorts to calling `downcast()`. Thus it's ok to take the
-         * `deverbosifyFloatingNode()` route first, as no downcasting opportunity will be missed.
-         */
-        return deverbosifyFloatingNode((FloatingNode) n);
-    }
-
-    /**
-     * This method:
-     *
-     * <ul>
-     * <li>
-     * Recurses only over floating inputs to attempt reductions, leave anything else as is.</li>
-     * <li>
-     * Performs copy-on-write aka lazy-DAG-copying as described in source comments, in-line.</li>
-     * <li>
-     * Usage: must be called only from {@link #deverbosify(com.oracle.graal.graph.Node)
-     * deverbosify(Node)}.</li>
-     * </ul>
-     */
-    public Node deverbosifyFloatingNode(final FloatingNode n) {
-
-        assert n != null : "Should have been caught in deverbosify()";
-        assert !(n instanceof ValueProxy) : "Should have been caught in deverbosify()";
-        assert !FlowUtil.isLiteralNode(n) : "Should have been caught in deverbosify()";
-
-        if (n instanceof PhiNode) {
-            /*
-             * Each input to a PhiNode should be deverbosified with the state applicable to the path
-             * providing such input, as done in visitAbstractEndNode()
-             */
-            return n;
-        }
-
-        final FloatingNode f = baseCaseFloating(n);
-        if (f != n) {
-            return f;
-        }
-
-        FloatingNode changed = null;
-        for (ValueNode i : FlowUtil.distinctValueAndConditionInputs(f)) {
-            /*
-             * Although deverbosify() is invoked below, it's only for floating inputs. That way, the
-             * state can't be used to make invalid conclusions.
-             */
-            Node j = (i instanceof FloatingNode) ? deverbosify(i) : i;
-            if (i != j) {
-                assert j != f;
-                if (changed == null) {
-                    changed = (FloatingNode) f.copyWithInputs();
-                    added.add(changed);
-                    // copyWithInputs() implies graph.unique(changed)
-                    assert changed.isAlive();
-                    assert FlowUtil.lacksUsages(changed);
-                }
-                /*
-                 * Note: we don't trade i for j at each usage of i (doing so would change meaning)
-                 * but only at those usages consumed by `changed`. In turn, `changed` won't replace
-                 * `n` at arbitrary usages, but only where such substitution is valid as per the
-                 * state holding there. In practice, this means the buck stops at the "root"
-                 * FixedNode on whose inputs deverbosify() is invoked for the first time, via
-                 * deverbosifyInputsInPlace().
-                 */
-                FlowUtil.replaceInPlace(changed, i, j);
-            }
-        }
-        if (changed == null) {
-            assert visited.contains(f) || added.contains(f);
-            return f;
-        }
-        FlowUtil.inferStampAndCheck(changed);
-        added.add(changed);
-
-        if (changed instanceof Canonicalizable) {
-            ValueNode canon = (ValueNode) ((Canonicalizable) changed).canonical(tool);
-            if (canon != null && !canon.isAlive()) {
-                assert !canon.isDeleted();
-                canon = graph.addOrUniqueWithInputs(canon);
-            }
-            // might be already in `added`, no problem adding it again.
-            added.add(canon);
-            rememberSubstitution(f, canon);
-            return canon;
-        } else {
-            return changed;
-        }
-    }
-
-    /**
-     * In case of doubt (on whether a reduction actually triggered) it's always ok to invoke "
-     * <code>rememberSubstitution(f, downcast(f))</code>": this method records a map entry only if
-     * pre-image and image differ.
-     *
-     * @return the image of the substitution (ie, the second argument) unmodified.
-     */
-    private <M extends ValueNode> M rememberSubstitution(ValueNode from, M to) {
-        assert from != null && to != null;
-        if (from == to) {
-            return to;
-        }
-        // we don't track literals because they map to themselves
-        if (FlowUtil.isLiteralNode(from)) {
-            assert from == to;
-            return to;
-        }
-        /*
-         * It's ok for different keys (which were not unique in the graph after all) to map to the
-         * same value. However any given key can't map to different values.
-         */
-        ValueNode image = substs.get(from);
-        if (image != null) {
-            assert image == to;
-            return to;
-        }
-        substs.put(from, to);
-        return to;
-    }
-
-    /**
-     * The contract for this baseCase-style method is covered in
-     * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)
-     * EquationalReasoner#deverbosify()}.
-     *
-     * @return a {@link com.oracle.graal.nodes.calc.FloatingNode} different from the argument, in
-     *         case a reduction was made. The node being returned might be already in the graph. In
-     *         any case it's canonicalized already, the caller need not perform that again. In case
-     *         no reduction was made, this method returns the unmodified argument.
-     */
-    private FloatingNode baseCaseFloating(final FloatingNode f) {
-        if (f instanceof LogicNode) {
-            FloatingNode result = baseCaseLogicNode((LogicNode) f);
-            return rememberSubstitution(f, result);
-        }
-        return f;
-    }
-
-    /**
-     * <p>
-     * Reduce the argument based on the state at the program point for it (ie, based on
-     * "valid facts" only, without relying on any floating-guard-assumption).
-     * </p>
-     *
-     * <p>
-     * The inputs of the argument aren't traversed into, for that
-     * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)
-     * EquationalReasoner#deverbosify()} should be used instead.
-     * </p>
-     * <p>
-     * This method must behave as a function (idempotent query method): it should refrain from
-     * changing the state, as well as from updating caches (other than DebugMetric-s).
-     * </p>
-     *
-     * @return a {@link com.oracle.graal.nodes.LogicNode} different from the argument, in case a
-     *         reduction was made. The node being returned might be already in the graph. In any
-     *         case it's canonicalized already, the caller need not perform that again. In case no
-     *         reduction was made, this method returns the unmodified argument.
-     *
-     */
-    public FloatingNode baseCaseLogicNode(LogicNode condition) {
-        assert condition != null;
-        if (condition instanceof LogicConstantNode) {
-            return condition;
-        } else if (state.trueFacts.containsKey(condition)) {
-            metricEquationalReasoning.increment();
-            return trueConstant;
-        } else if (state.falseFacts.containsKey(condition)) {
-            metricEquationalReasoning.increment();
-            return falseConstant;
-        } else {
-            if (condition instanceof InstanceOfNode) {
-                return baseCaseInstanceOfNode((InstanceOfNode) condition);
-            } else if (condition instanceof IsNullNode) {
-                return baseCaseIsNullNode((IsNullNode) condition);
-            } else if (condition instanceof ObjectEqualsNode) {
-                return baseCaseObjectEqualsNode((ObjectEqualsNode) condition);
-            } else if (condition instanceof ShortCircuitOrNode) {
-                return baseCaseShortCircuitOrNode((ShortCircuitOrNode) condition);
-            }
-        }
-        return condition;
-    }
-
-    /**
-     * Actually the same result delivered by this method could be obtained by just letting
-     * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)
-     * EquationalReasoner#deverbosify()} handle the argument in the default case for floating nodes
-     * (ie, deverbosify inputs followed by canonicalize). However it's done here for metrics
-     * purposes.
-     *
-     * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made;
-     *         otherwise the unmodified argument.
-     *
-     */
-    private LogicNode baseCaseInstanceOfNode(InstanceOfNode instanceOf) {
-        ValueNode scrutinee = GraphUtil.unproxify(instanceOf.getValue());
-        if (!FlowUtil.hasLegalObjectStamp(scrutinee)) {
-            return instanceOf;
-        }
-        if (state.isNull(scrutinee)) {
-            metricInstanceOfRemoved.increment();
-            return falseConstant;
-        } else if (state.knownNotToPassInstanceOf(scrutinee, instanceOf.type())) {
-            // scrutinee turns out to be null -> falseConstant right answer
-            // scrutinee not null, but known-not-to-conform -> falseConstant
-            metricInstanceOfRemoved.increment();
-            return falseConstant;
-        } else if (state.isNonNull(scrutinee) && state.knownToConform(scrutinee, instanceOf.type())) {
-            metricInstanceOfRemoved.increment();
-            return trueConstant;
-        }
-        return instanceOf;
-    }
-
-    /**
-     * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was
-     *         performed; otherwise the unmodified argument.
-     *
-     */
-    private FloatingNode baseCaseIsNullNode(IsNullNode isNu) {
-        ValueNode object = isNu.getValue();
-        if (!FlowUtil.hasLegalObjectStamp(object)) {
-            return isNu;
-        }
-        if (state.isNull(object)) {
-            metricNullCheckRemoved.increment();
-            return trueConstant;
-        } else if (state.isNonNull(object)) {
-            metricNullCheckRemoved.increment();
-            return falseConstant;
-        }
-        return isNu;
-    }
-
-    /**
-     * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made;
-     *         otherwise the unmodified argument.
-     */
-    private LogicNode baseCaseObjectEqualsNode(ObjectEqualsNode equals) {
-        if (!FlowUtil.hasLegalObjectStamp(equals.getX()) || !FlowUtil.hasLegalObjectStamp(equals.getY())) {
-            return equals;
-        }
-        ValueNode x = GraphUtil.unproxify(equals.getX());
-        ValueNode y = GraphUtil.unproxify(equals.getY());
-        if (state.isNull(x) && state.isNonNull(y) || state.isNonNull(x) && state.isNull(y)) {
-            metricObjectEqualsRemoved.increment();
-            return falseConstant;
-        } else if (state.isNull(x) && state.isNull(y)) {
-            metricObjectEqualsRemoved.increment();
-            return trueConstant;
-        }
-        return equals;
-    }
-
-    /**
-     * The following is tried:
-     *
-     * <ol>
-     * <li>
-     * A {@link com.oracle.graal.phases.common.cfs.Witness} that is at check-cast level level
-     * doesn't entail {@link com.oracle.graal.nodes.calc.IsNullNode} (on its own) nor
-     * {@link com.oracle.graal.nodes.java.InstanceOfNode} (also on its own) but of course it entails
-     * <code>(IsNull || IsInstanceOf)</code>. Good thing
-     * {@link com.oracle.graal.phases.common.cfs.CastCheckExtractor} detects that very pattern.</li>
-     * <li>
-     * Otherwise return the unmodified argument (later on,
-     * {@link #deverbosifyFloatingNode(com.oracle.graal.nodes.calc.FloatingNode)} will attempt to
-     * simplify the {@link com.oracle.graal.nodes.ShortCircuitOrNode}).</li>
-     * </ol>
-     *
-     * @return a {@link com.oracle.graal.nodes.LogicConstantNode}, in case a reduction was made;
-     *         otherwise the unmodified argument.
-     */
-    private LogicNode baseCaseShortCircuitOrNode(ShortCircuitOrNode orNode) {
-        CastCheckExtractor cast = CastCheckExtractor.extract(orNode);
-        if (cast != null) {
-            if (state.knownToConform(cast.subject, cast.type)) {
-                return trueConstant;
-            } else if (state.knownNotToPassCheckCast(cast.subject, cast.type)) {
-                return falseConstant;
-            }
-            return orNode;
-        }
-        return orNode;
-    }
-
-    /**
-     * It's always ok to use "<code>downcast(object)</code>" instead of " <code>object</code>"
-     * because this method re-wraps the argument in a {@link com.oracle.graal.nodes.PiNode} only if
-     * the new stamp is strictly more refined than the original.
-     *
-     * <p>
-     * This method does not
-     * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)}
-     * .
-     * </p>
-     *
-     * @return One of:
-     *         <ul>
-     *         <li>a {@link com.oracle.graal.nodes.PiNode} with more precise stamp than the input if
-     *         the state warrants such downcasting</li>
-     *         <li>a {@link com.oracle.graal.nodes.java.CheckCastNode CheckCastNode} for the same
-     *         scrutinee in question</li>
-     *         <li>the unmodified argument otherwise.</li>
-     *         </ul>
-     */
-    ValueNode downcast(final ValueNode object) {
-
-        // -------------------------------------------------
-        // actions based only on the stamp of the input node
-        // -------------------------------------------------
-
-        if (!FlowUtil.hasLegalObjectStamp(object)) {
-            return object;
-        }
-        if (FlowUtil.isLiteralNode(object)) {
-            return object;
-        }
-        if (StampTool.isPointerAlwaysNull(object.stamp())) {
-            return object;
-        }
-
-        // ------------------------------------------
-        // actions based on the stamp and the witness
-        // ------------------------------------------
-
-        ValueNode scrutinee = GraphUtil.unproxify(object);
-
-        PiNode untrivialNull = nonTrivialNull(scrutinee);
-        if (untrivialNull != null) {
-            metricNullInserted.increment();
-            return untrivialNull;
-        }
-
-        Witness w = state.typeInfo(scrutinee);
-        if (w == null) {
-            // no additional hints being tracked for the scrutinee
-            return object;
-        }
-
-        assert !w.clueless();
-
-        ObjectStamp inputStamp = (ObjectStamp) object.stamp();
-        ObjectStamp witnessStamp = w.asStamp();
-        if (inputStamp.equals(witnessStamp) || !FlowUtil.isMorePrecise(witnessStamp, inputStamp)) {
-            // the witness offers no additional precision over current one
-            fixupTypeProfileStamp(object);
-            return object;
-        }
-
-        assert !FlowUtil.isMorePrecise(inputStamp.type(), w.type());
-
-        ValueNode result;
-        if (object instanceof ValueProxy) {
-            result = downcastValueProxy((ValueProxy) object, w);
-        } else {
-            result = downcastedUtil(object, w);
-        }
-
-        assert !BaseReduction.precisionLoss(object, result);
-
-        return result;
-    }
-
-    /**
-     * TODO TypeProfileProxyNode.inferStamp doesn't infer non-null from non-null payload
-     *
-     * <p>
-     * And there's a bunch of asserts in
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase} that assert no
-     * type-precision gets lost. Thus the need to fix-up on our own, as done here.
-     * </p>
-     */
-    private static void fixupTypeProfileStamp(ValueNode object) {
-        if (!(object instanceof TypeProfileProxyNode)) {
-            return;
-        }
-        TypeProfileProxyNode profile = (TypeProfileProxyNode) object;
-        ObjectStamp outgoinStamp = (ObjectStamp) profile.stamp();
-        ObjectStamp payloadStamp = (ObjectStamp) profile.getValue().stamp();
-        if (payloadStamp.nonNull() && !outgoinStamp.nonNull()) {
-            profile.setStamp(FlowUtil.asNonNullStamp(outgoinStamp));
-        }
-    }
-
-    /**
-     * <p>
-     * Porcelain method.
-     * </p>
-     *
-     * <p>
-     * Utility to create, add to the graph,
-     * {@link EquationalReasoner#rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)}
-     * , and return a {@link com.oracle.graal.nodes.PiNode} that narrows into the given stamp,
-     * anchoring the payload.
-     * </p>
-     *
-     * <p>
-     * The resulting node might not have been in the graph already.
-     * </p>
-     */
-    private PiNode wrapInPiNode(ValueNode payload, GuardingNode anchor, ObjectStamp newStamp, boolean remember) {
-        try (Debug.Scope s = Debug.scope("Downcast", payload)) {
-            assert payload != anchor : payload.graph().toString();
-            metricDowncasting.increment();
-            PiNode result = graph.unique(new PiNode(payload, newStamp, anchor.asNode()));
-            // we've possibly got a new node in the graph --- bookkeeping is in order.
-            added.add(result);
-            if (remember) {
-                rememberSubstitution(payload, result);
-            }
-            Debug.log("Downcasting from %s to %s", payload, result);
-            return result;
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-    }
-
-    /**
-     *
-     * This method returns:
-     * <ul>
-     * <li><b>null</b>, if the argument is known null due to its stamp. Otherwise,</li>
-     * <li><b>a PiNode</b> wrapping the null constant and an anchor offering evidence as to why the
-     * argument is known null, if such anchor is available. Otherwise,</li>
-     * <li><b>null</b></li>
-     * </ul>
-     * <p>
-     * This method does not
-     * {@link #rememberSubstitution(com.oracle.graal.nodes.ValueNode, com.oracle.graal.nodes.ValueNode)}
-     * .
-     * </p>
-     */
-    public PiNode nonTrivialNull(ValueNode object) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        GuardingNode anchor = state.nonTrivialNullAnchor(object);
-        if (anchor == null) {
-            return null;
-        }
-        if (object instanceof GuardedNode && StampTool.isPointerAlwaysNull(object.stamp())) {
-            return (PiNode) object;
-        }
-        // notice nullConstant is wrapped, not object
-        PiNode result = wrapInPiNode(nullConstant, anchor, (ObjectStamp) StampFactory.alwaysNull(), false);
-        return result;
-    }
-
-    // @formatter:off
-    /**
-     * <p>ValueProxys can be classified along two dimensions,
-     * in addition to the fixed-floating dichotomy.</p>
-     *
-     * <p>
-     *     First, we might be interested in separating those ValueProxys
-     *     that are entitled to change (usually narrow) their stamp from those that aren't.
-     *     In the first category are:
-     *       PiNode, PiArrayNode, GuardingPiNode,
-     *       CheckCastNode, UnsafeCastNode, and
-     *       GuardedValueNode.
-     * </p>
-     *
-     * <p>
-     *     A note on stamp-narrowing ValueProxys:
-     *     our state abstraction tracks only the type refinements induced by CheckCastNode and GuardingPiNode
-     *     (which are fixed nodes, unlike the other stamp-narrowing ValueProxys;
-     *     the reason being that the state abstraction can be updated only at fixed nodes).
-     *     As a result, the witness for a (PiNode, PiArrayNode, UnsafeCastNode, or GuardedValueNode)
-     *     may be less precise than the proxy's stamp. We don't want to lose such precision,
-     *     thus <code>downcast(proxy) == proxy</code> in such cases.
-     * </p>
-     *
-     * <p>
-     *     The second classification focuses on
-     *     the additional information that travels with the proxy
-     *     (in addition to its "payload", ie getOriginalValue(), and any narrowing-stamp).
-     *     Such additional information boils down to:
-     *
-     *   (a) type profile (TypeProfileProxyNode)
-     *   (b) type profile (CheckCastNode)
-     *   (c) anchor (GuardedValueNode)
-     *   (d) anchor (PiNode)
-     *   (e) anchor and array length (PiArrayNode)
-     *   (f) optional anchor (UnsafeCastNode)
-     *   (g) deopt-condition (GuardingPiNode)
-     *   (h) LocationIdentity (MemoryProxyNOde)
-     *   (i) control-flow dependency (FixedValueAnchorNode)
-     *   (j) proxyPoint (ProxyNode -- think loops)
-     *</p>
-     */
-    // @formatter:on
-    private ValueNode downcastValueProxy(ValueProxy proxy, Witness w) {
-        assert FlowUtil.hasLegalObjectStamp((ValueNode) proxy);
-        assert FlowUtil.hasLegalObjectStamp((proxy).getOriginalNode());
-        assert GraphUtil.unproxify((ValueNode) proxy) == GraphUtil.unproxify(proxy.getOriginalNode());
-
-        assert GraphUtil.unproxify((ValueNode) proxy) == GraphUtil.unproxify((proxy).getOriginalNode());
-
-        if (proxy instanceof PiNode) {
-            return downcastPiNodeOrPiArrayNode((PiNode) proxy, w);
-        } else if (proxy instanceof GuardingPiNode) {
-            return downcastGuardingPiNode((GuardingPiNode) proxy, w);
-        } else if (proxy instanceof TypeProfileProxyNode) {
-            return downcastTypeProfileProxyNode((TypeProfileProxyNode) proxy);
-        } else if (proxy instanceof CheckCastNode) {
-            return downcastCheckCastNode((CheckCastNode) proxy, w);
-        } else if (proxy instanceof ProxyNode || proxy instanceof GuardedValueNode) {
-            // TODO scaladacapo return downcastedUtil((ValueNode) proxy, w);
-            return (ValueNode) proxy;
-        }
-
-        assert false : "TODO case not yet handled";
-
-        // TODO complete the missing implementation for the cases not yet handled
-
-        return ((ValueNode) proxy);
-    }
-
-    /**
-     * <p>
-     * Why would we want to downcast a GuardingPiNode? Is it even possible? Like, for example, a
-     * GuardingPiNode originating in the lowering of a CheckCastNode (carried out by
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
-     * visitCheckCastNode()}).
-     * </p>
-     *
-     * <p>
-     * It's both possible and desirable. Example: <code>
-     *         Number n = (Number) o;
-     *         if (n instanceof Integer) {
-     *            return n.intValue();
-     *         }
-     *     </code>
-     *
-     * The receiver of intValue() is a usage of a previous checkCast, for which the current witness
-     * provides a more refined type (and an anchor). In this case, the advantage of downcasting a
-     * GuardingPiNode is clear: devirtualizing the `intValue()` callsite.
-     * </p>
-     *
-     * @see #downcastValueProxy
-     */
-    public ValueNode downcastGuardingPiNode(GuardingPiNode envelope, Witness w) {
-        assert envelope != w.guard().asNode() : "The stamp of " + envelope + " would lead to downcasting with that very same GuardingPiNode as guard.";
-        return downcastedUtil(envelope, w);
-    }
-
-    /**
-     * <p>
-     * This method accepts both {@link com.oracle.graal.nodes.PiNode} and
-     * {@link com.oracle.graal.nodes.PiArrayNode} argument.
-     * </p>
-     *
-     * <p>
-     * In case a witness reveals a strictly more precise type than the
-     * {@link com.oracle.graal.nodes.PiNode}'s stamp, this method wraps the argument in a new
-     * {@link com.oracle.graal.nodes.PiNode} with updated stamp, and returns it.
-     * </p>
-     *
-     * <p>
-     * A {@link com.oracle.graal.nodes.PiArrayNode} argument ends up wrapped in a
-     * {@link com.oracle.graal.nodes.PiNode}. Thus, the
-     * {@link com.oracle.graal.nodes.PiArrayNode#length} information doesn't get lost.
-     * </p>
-     *
-     * <p>
-     * Note: {@link com.oracle.graal.nodes.PiNode}'s semantics allow un-packing its payload as soon
-     * as it type conforms to that of the {@link com.oracle.graal.nodes.PiNode} (that's what
-     * {@link com.oracle.graal.nodes.PiNode#canonical(com.oracle.graal.graph.spi.CanonicalizerTool)
-     * PiNode.canonical()} does). Not clear the benefits of duplicating that logic here.
-     * </p>
-     *
-     * @see #downcastValueProxy
-     */
-    private ValueNode downcastPiNodeOrPiArrayNode(PiNode envelope, Witness w) {
-        return downcastedUtil(envelope, w);
-    }
-
-    /**
-     * <p>
-     * In a case the payload of the {@link com.oracle.graal.nodes.TypeProfileProxyNode} can be
-     * downcasted, this method returns a copy-on-write version with the downcasted payload.
-     * </p>
-     *
-     * <p>
-     * Otherwise returns the unmodified argument.
-     * </p>
-     *
-     * @see #downcastValueProxy
-     */
-    private ValueNode downcastTypeProfileProxyNode(TypeProfileProxyNode envelope) {
-        ValueNode payload = envelope.getOriginalNode();
-        ValueNode d = downcast(payload);
-        if (payload != d) {
-            TypeProfileProxyNode changed = (TypeProfileProxyNode) envelope.copyWithInputs();
-            added.add(changed);
-            // copyWithInputs() implies graph.unique(changed)
-            FlowUtil.replaceInPlace(changed, payload, d);
-            FlowUtil.inferStampAndCheck(changed);
-            fixupTypeProfileStamp(changed);
-            /*
-             * It's not prudent to (1) obtain the canonical() of the (changed) TypeProfileProxyNode
-             * to (2) replace its usages; because we're potentially walking a DAG (after all,
-             * TypeProfileProxyNode is a floating-node). Those steps, which admittedly are needed,
-             * are better performed upon replacing in-place the inputs of a FixedNode, or during
-             * Canonicalize.
-             */
-            return changed;
-        }
-        fixupTypeProfileStamp(envelope);
-        return envelope;
-    }
-
-    /**
-     * <p>
-     * Re-wrap the checkCast in a type-refining {@link com.oracle.graal.nodes.PiNode PiNode} only if
-     * the downcasted scrutinee does not conform to the checkCast's target-type.
-     * </p>
-     */
-    private ValueNode downcastCheckCastNode(CheckCastNode checkCast, Witness w) {
-
-        final ResolvedJavaType toType = checkCast.type();
-
-        if (checkCast.object() instanceof CheckCastNode) {
-            ValueNode innerMost = checkCast;
-            while (innerMost instanceof CheckCastNode) {
-                innerMost = ((CheckCastNode) innerMost).object();
-            }
-            ValueNode deepest = downcast(innerMost);
-            ResolvedJavaType deepestType = ((ObjectStamp) deepest.stamp()).type();
-            if ((deepestType != null && deepestType.equals(toType)) || FlowUtil.isMorePrecise(deepestType, toType)) {
-                assert !w.knowsBetterThan(deepest);
-                return deepest;
-            }
-        }
-
-        ValueNode subject = downcast(checkCast.object());
-        ObjectStamp subjectStamp = (ObjectStamp) subject.stamp();
-        ResolvedJavaType subjectType = subjectStamp.type();
-
-        if (subjectType != null && toType.isAssignableFrom(subjectType)) {
-            assert !w.knowsBetterThan(subject);
-            return subject;
-        }
-
-        return downcastedUtil(checkCast, w);
-    }
-
-    /**
-     * <p>
-     * Porcelain method.
-     * </p>
-     *
-     * <p>
-     * This method wraps the argument in a new {@link com.oracle.graal.nodes.PiNode PiNode} (created
-     * to hold an updated stamp) provided the argument's stamp can be strictly refined, and returns
-     * it.
-     * </p>
-     */
-    private ValueNode downcastedUtil(ValueNode subject, Witness w) {
-
-        ObjectStamp originalStamp = (ObjectStamp) subject.stamp();
-        ObjectStamp outgoingStamp = originalStamp;
-
-        if (w.isNonNull() && !outgoingStamp.nonNull()) {
-            outgoingStamp = FlowUtil.asNonNullStamp(outgoingStamp);
-        }
-        if (FlowUtil.isMorePrecise(w.type(), outgoingStamp.type())) {
-            outgoingStamp = FlowUtil.asRefinedStamp(outgoingStamp, w.type());
-        }
-
-        if (outgoingStamp != originalStamp) {
-            assert FlowUtil.isMorePrecise(outgoingStamp, originalStamp);
-
-            boolean isWitnessGuardAnAliasForScrutinee = false;
-            if (w.guard() instanceof GuardingPiNode || w.guard() instanceof PiNode) {
-                /*
-                 * The guard offered by the witness canonicalizes into its subject (a possibly
-                 * type-refined scrutinee) provided its subject conforms as per stamp.
-                 */
-                if (w.guard().asNode().stamp().equals(outgoingStamp)) {
-                    isWitnessGuardAnAliasForScrutinee = true;
-                }
-            }
-
-            ValueNode result;
-            if (isWitnessGuardAnAliasForScrutinee) {
-                result = w.guard().asNode();
-                assert !w.knowsBetterThan(result);
-                return result; // TODO this works. explain why.
-            } else {
-                result = wrapInPiNode(subject, w.guard(), outgoingStamp, true);
-                assert !w.knowsBetterThan(result);
-                return result;
-            }
-
-        } else {
-            assert !w.knowsBetterThan(subject);
-            return subject;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Evidence.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.phases.common.cfs;
-
-import com.oracle.graal.nodes.extended.GuardingNode;
-
-public class Evidence {
-
-    public final GuardingNode success;
-    public final boolean failure;
-
-    public Evidence(GuardingNode success, boolean failure) {
-        this.success = success;
-        this.failure = failure;
-        assert repOK();
-    }
-
-    public Evidence(GuardingNode success) {
-        this(success, false);
-    }
-
-    private Evidence(boolean failure) {
-        this(null, failure);
-    }
-
-    public boolean isPositive() {
-        return success != null;
-    }
-
-    public boolean isNegative() {
-        return failure;
-    }
-
-    private boolean repOK() {
-        // either success or failure, ie boolean-XOR
-        return (success != null) != failure;
-    }
-
-    public static Evidence COUNTEREXAMPLE = new Evidence(true);
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FixedGuardReduction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +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.phases.common.cfs;
-
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.GuardingNode;
-import com.oracle.graal.phases.tiers.PhaseContext;
-
-/**
- * <p>
- * This class implements control-flow sensitive reductions for
- * {@link com.oracle.graal.nodes.FixedGuardNode}.
- * </p>
- * 
- * <p>
- * The laundry-list of all flow-sensitive reductions is summarized in
- * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}
- * </p>
- * 
- * @see #visitFixedGuardNode(com.oracle.graal.nodes.FixedGuardNode)
- */
-public abstract class FixedGuardReduction extends CheckCastReduction {
-
-    public FixedGuardReduction(StartNode start, State initialState, PhaseContext context) {
-        super(start, initialState, context);
-    }
-
-    /**
-     * <p>
-     * Upon visiting a {@link com.oracle.graal.nodes.FixedGuardNode}, based on flow-sensitive
-     * conditions, we need to determine whether:
-     * <ul>
-     * <li>it is redundant (in which case it should be simplified), or</li>
-     * <li>flow-sensitive information can be gained from it.</li>
-     * </ul>
-     * </p>
-     * 
-     * <p>
-     * This method realizes the above by inspecting the
-     * {@link com.oracle.graal.nodes.FixedGuardNode}'s condition:
-     * <ol>
-     * <li>a constant condition signals the node won't be reduced here</li>
-     * <li>the outcome of the condition can be predicted:</li>
-     * <ul>
-     * <li>
-     * "always succeeds", after finding an equivalent (or stronger)
-     * {@link com.oracle.graal.nodes.extended.GuardingNode} in scope. The
-     * {@link com.oracle.graal.nodes.FixedGuardNode} is removed after replacing its usages with the
-     * existing guarding node</li>
-     * <li>
-     * "always fails", which warrants making that explicit by making the condition constant, see
-     * {@link #markFixedGuardNodeAlwaysFails(com.oracle.graal.nodes.FixedGuardNode)}</li>
-     * </ul>
-     * <li>otherwise the condition is tracked flow-sensitively</li>
-     * </ol>
-     * </p>
-     * 
-     * <p>
-     * Precondition: the condition hasn't been deverbosified yet.
-     * </p>
-     */
-    protected final void visitFixedGuardNode(FixedGuardNode f) {
-
-        /*
-         * A FixedGuardNode with LogicConstantNode condition is left untouched.
-         * `FixedGuardNode.simplify()` will eventually remove the FixedGuardNode (in case it
-         * "always succeeds") or kill code ("always fails").
-         */
-
-        if (f.condition() instanceof LogicConstantNode) {
-            if (FlowUtil.alwaysFails(f.isNegated(), f.condition())) {
-                state.impossiblePath();
-                // let FixedGuardNode(false).simplify() prune the dead-code control-path
-                return;
-            }
-            assert FlowUtil.alwaysSucceeds(f.isNegated(), f.condition());
-            return;
-        }
-
-        final boolean isTrue = !f.isNegated();
-        final Evidence evidence = state.outcome(isTrue, f.condition());
-
-        // can't produce evidence, must be information gain
-        if (evidence == null) {
-            state.addFact(isTrue, f.condition(), f);
-            return;
-        }
-
-        if (evidence.isPositive()) {
-            /*
-             * A FixedGuardNode can only be removed provided a replacement anchor is found (so
-             * called "evidence"), ie an anchor that amounts to the same combination of (negated,
-             * condition) as for the FixedGuardNode at hand. Just deverbosifying the condition in
-             * place isn't semantics-preserving.
-             * 
-             * Eliminate the current FixedGuardNode by using another GuardingNode already in scope,
-             * a GuardingNode that guards a condition that is at least as strong as that of the
-             * FixedGuardNode.
-             */
-            removeFixedGuardNode(f, evidence.success);
-            return;
-        }
-
-        assert evidence.isNegative();
-        markFixedGuardNodeAlwaysFails(f);
-
-    }
-
-    /**
-     * Porcelain method.
-     */
-    private void markFixedGuardNodeAlwaysFails(FixedGuardNode f) {
-        metricFixedGuardNodeRemoved.increment();
-        state.impossiblePath();
-        f.setCondition(f.isNegated() ? trueConstant : falseConstant);
-        // `f.condition()` if unused will be removed in finished()
-    }
-
-    /**
-     * Porcelain method.
-     * 
-     * <p>
-     * The `replacement` guard must be such that it implies the `old` guard. Moreover, rhe
-     * `replacement` guard must be in scope.
-     * </p>
-     */
-    private void removeFixedGuardNode(FixedGuardNode old, GuardingNode replacement) {
-        assert replacement != null;
-        metricFixedGuardNodeRemoved.increment();
-        old.replaceAtUsages(replacement.asNode());
-        graph.removeFixed(old);
-        // `old.condition()` if unused will be removed in finished()
-    }
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReduction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,605 +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.phases.common.cfs;
-
-import static com.oracle.graal.api.meta.DeoptimizationAction.*;
-import static com.oracle.graal.api.meta.DeoptimizationReason.*;
-import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*;
-
-import java.lang.reflect.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.nodes.util.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.tiers.*;
-
-/**
- * <p>
- * In a nutshell, {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReductionPhase} makes a
- * single pass in dominator-based order over the graph:
- * <ol>
- * <li>collecting properties of interest at control-splits; as well as for check-casts,
- * guarding-pis, null-checks, and fixed-guards. Such flow-sensitive information is tracked via a
- * dedicated {@link com.oracle.graal.phases.common.cfs.State state instance} for each control-flow
- * path.</li>
- * <li>performing rewritings that are safe at specific program-points. This comprises:
- * <ul>
- * <li>simplification of side-effects free expressions, via
- * {@link com.oracle.graal.phases.common.cfs.EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)}
- * <ul>
- * <li>
- * at certain {@link com.oracle.graal.nodes.FixedNode}, see
- * {@link #deverbosifyInputsInPlace(com.oracle.graal.nodes.ValueNode)}</li>
- * <li>
- * including for devirtualization, see
- * {@link #deverbosifyInputsCopyOnWrite(com.oracle.graal.nodes.java.MethodCallTargetNode)}</li>
- * </ul>
- * </li>
- * <li>simplification of control-flow:
- * <ul>
- * <li>
- * by simplifying the input-condition to an {@link com.oracle.graal.nodes.IfNode}</li>
- * <li>
- * by eliminating redundant check-casts, guarding-pis, null-checks, and fixed-guards; where
- * "redundancy" is determined using flow-sensitive information. In these cases, redundancy can be
- * due to:
- * <ul>
- * <li>an equivalent, existing, guarding node is already in scope (thus, use it as replacement and
- * remove the redundant one)</li>
- * <li>"always fails" (thus, replace the node in question with <code>FixedGuardNode(false)</code>)</li>
- * </ul>
- * </li>
- * </ul>
- * </li>
- * </ul>
- * </li>
- * </ol>
- * </p>
- *
- * <p>
- * Metrics for this phase are displayed starting with <code>FSR-</code>prefix, their counters are
- * hosted in {@link com.oracle.graal.phases.common.cfs.BaseReduction},
- * {@link com.oracle.graal.phases.common.cfs.EquationalReasoner} and
- * {@link com.oracle.graal.phases.common.cfs.State}.
- * </p>
- *
- * @see com.oracle.graal.phases.common.cfs.CheckCastReduction
- * @see com.oracle.graal.phases.common.cfs.GuardingPiReduction
- * @see com.oracle.graal.phases.common.cfs.FixedGuardReduction
- *
- */
-public class FlowSensitiveReduction extends FixedGuardReduction {
-
-    public FlowSensitiveReduction(StartNode start, State initialState, PhaseContext context) {
-        super(start, initialState, context);
-    }
-
-    /**
-     * <p>
-     * This method performs two kinds of cleanup:
-     * <ol>
-     * <li>
-     * marking as unreachable certain code-paths, as described in
-     * {@link com.oracle.graal.phases.common.cfs.BaseReduction.PostponedDeopt}</li>
-     * <li>
-     * Removing nodes not in use that were added during this phase, as described next.</li>
-     * </ol>
-     * </p>
-     *
-     *
-     * <p>
-     * Methods like
-     * {@link com.oracle.graal.phases.common.cfs.FlowUtil#replaceInPlace(com.oracle.graal.graph.Node, com.oracle.graal.graph.Node, com.oracle.graal.graph.Node)}
-     * may result in old inputs becoming disconnected from the graph. It's not advisable to
-     * {@link com.oracle.graal.nodes.util.GraphUtil#tryKillUnused(com.oracle.graal.graph.Node)} at
-     * that moment, because one of the inputs that might get killed is one of {@link #nullConstant},
-     * {@link #falseConstant}, or {@link #trueConstant}; which thus could get killed too early,
-     * before another invocation of
-     * {@link com.oracle.graal.phases.common.cfs.EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)}
-     * needs them. To recap,
-     * {@link com.oracle.graal.nodes.util.GraphUtil#tryKillUnused(com.oracle.graal.graph.Node)} also
-     * recursively visits the inputs of the its argument.
-     * </p>
-     *
-     * <p>
-     * This method goes over all of the nodes that deverbosification might have added, which are
-     * either:
-     * <ul>
-     * <li>
-     * {@link com.oracle.graal.nodes.calc.FloatingNode}, added by
-     * {@link com.oracle.graal.phases.common.cfs.EquationalReasoner#deverbosifyFloatingNode(com.oracle.graal.nodes.calc.FloatingNode)}
-     * ; or</li>
-     * <li>
-     * {@link com.oracle.graal.nodes.java.MethodCallTargetNode}, added by
-     * {@link #deverbosifyInputsCopyOnWrite(com.oracle.graal.nodes.java.MethodCallTargetNode)}</li>
-     * </ul>
-     *
-     * Checking if they aren't in use, proceeding to remove them in that case.
-     * </p>
-     *
-     */
-    @Override
-    public void finished() {
-        if (!postponedDeopts.isEmpty()) {
-            for (PostponedDeopt postponed : postponedDeopts) {
-                postponed.doRewrite(falseConstant);
-            }
-            new DeadCodeEliminationPhase(Optional).apply(graph);
-        }
-        for (MethodCallTargetNode mcn : graph.getNodes().filter(MethodCallTargetNode.class)) {
-            if (mcn.isAlive() && FlowUtil.lacksUsages(mcn)) {
-                mcn.safeDelete();
-            }
-        }
-        for (Node n : graph.getNodes().filter(FloatingNode.class)) {
-            GraphUtil.tryKillUnused(n);
-        }
-        assert !isAliveWithoutUsages(trueConstant);
-        assert !isAliveWithoutUsages(falseConstant);
-        assert !isAliveWithoutUsages(nullConstant);
-        super.finished();
-    }
-
-    private static boolean isAliveWithoutUsages(FloatingNode node) {
-        return node.isAlive() && FlowUtil.lacksUsages(node);
-    }
-
-    private void registerControlSplit(Node pred, BeginNode begin) {
-        assert pred != null && begin != null;
-        assert !state.isUnreachable;
-
-        if (begin instanceof LoopExitNode) {
-            state.clear();
-            /*
-             * TODO return or not? (by not returning we agree it's ok to update the state as below)
-             */
-        }
-
-        if (pred instanceof IfNode) {
-            registerIfNode((IfNode) pred, begin);
-        } else if (pred instanceof TypeSwitchNode) {
-            registerTypeSwitchNode((TypeSwitchNode) pred, begin);
-        }
-    }
-
-    private void registerIfNode(IfNode ifNode, BeginNode begin) {
-        final boolean isThenBranch = (begin == ifNode.trueSuccessor());
-
-        if (ifNode.condition() instanceof LogicConstantNode) {
-            final LogicConstantNode constCond = (LogicConstantNode) ifNode.condition();
-            if (isThenBranch != constCond.getValue()) {
-                state.impossiblePath();
-                // let IfNode(constant) prune the dead-code control-path
-            }
-        }
-
-        if (state.isUnreachable) {
-            if (!(ifNode.condition() instanceof LogicConstantNode)) {
-                // if condition constant, no need to add a Deopt node
-                postponedDeopts.addDeoptAfter(begin, UnreachedCode);
-            }
-        } else {
-            state.addFact(isThenBranch, ifNode.condition(), begin);
-        }
-    }
-
-    /**
-     * TODO When tracking integer-stamps, the state at each successor of a TypeSwitchNode should
-     * track an integer-stamp for the LoadHubNode (meet over the constants leading to that
-     * successor). However, are LoadHubNode-s shared frequently enough?
-     */
-    private void registerTypeSwitchNode(TypeSwitchNode typeSwitch, BeginNode begin) {
-        if (typeSwitch.value() instanceof LoadHubNode) {
-            LoadHubNode loadHub = (LoadHubNode) typeSwitch.value();
-            ResolvedJavaType type = null;
-            for (int i = 0; i < typeSwitch.keyCount(); i++) {
-                if (typeSwitch.keySuccessor(i) == begin) {
-                    if (type == null) {
-                        type = typeSwitch.typeAt(i);
-                    } else {
-                        type = FlowUtil.widen(type, typeSwitch.typeAt(i));
-                    }
-                }
-            }
-            if (type == null) {
-                // `begin` denotes the default case of the TypeSwitchNode
-                return;
-            }
-            // it's unwarranted to assume loadHub.object() to be non-null
-            state.trackCC(loadHub.getValue(), type, begin);
-        }
-    }
-
-    /**
-     *
-     * <p>
-     * Reduce input nodes based on the state at the program point for the argument (ie, based on
-     * "valid facts" only, without relying on any floating-guard-assumption).
-     * </p>
-     *
-     * <p>
-     * For each (direct or indirect) child, a copy-on-write version is made in case any of its
-     * children changed, with the copy accommodating the updated children. If the parent was shared,
-     * copy-on-write prevents the updates from becoming visible to anyone but the invoker of this
-     * method.
-     * </p>
-     *
-     * <p>
-     * <b> Please note the parent node is mutated upon any descendant changing. No copy-on-write is
-     * performed for the parent node itself. </b>
-     * </p>
-     *
-     * <p>
-     * In more detail, for each direct {@link com.oracle.graal.nodes.ValueNode} input of the node at
-     * hand,
-     *
-     * <ol>
-     * <li>
-     * Obtain a lazy-copied version (via spanning tree) of the DAG rooted at the input-usage in
-     * question. Lazy-copying is done by walking a spanning tree of the original DAG, stopping at
-     * non-FloatingNodes but transitively walking FloatingNodes and their inputs. Upon arriving at a
-     * (floating) node N, the state's facts are checked to determine whether a constant C can be
-     * used instead in the resulting lazy-copied DAG. A NodeBitMap is used to realize the spanning
-     * tree.</li>
-     *
-     * <li>
-     * Provided one or more N-to-C node replacements took place, the resulting lazy-copied DAG has a
-     * parent different from the original (ie different object identity) which indicates the
-     * (copied, updated) DAG should replace the original via replaceFirstInput(), and inferStamp()
-     * should be invoked to reflect the updated inputs.</li>
-     *
-     * </ol>
-     * </p>
-     *
-     * @return whether any reduction was performed on the inputs of the arguments.
-     */
-    public boolean deverbosifyInputsInPlace(ValueNode parent) {
-        boolean changed = false;
-        for (ValueNode i : FlowUtil.distinctValueAndConditionInputs(parent)) {
-            assert !(i instanceof GuardNode) : "This phase not intended to run during MidTier";
-            ValueNode j = (ValueNode) reasoner.deverbosify(i);
-            if (i != j) {
-                changed = true;
-                FlowUtil.replaceInPlace(parent, i, j);
-            }
-        }
-        if (changed) {
-            FlowUtil.inferStampAndCheck(parent);
-        }
-        return changed;
-    }
-
-    /**
-     * Similar to {@link #deverbosifyInputsInPlace(com.oracle.graal.nodes.ValueNode)}, except that
-     * not the parent but a fresh clone is updated upon any of its children changing.
-     *
-     * @return the original parent if no updated took place, a copy-on-write version of it
-     *         otherwise.
-     *
-     */
-    private MethodCallTargetNode deverbosifyInputsCopyOnWrite(MethodCallTargetNode parent) {
-        final CallTargetNode.InvokeKind ik = parent.invokeKind();
-        boolean shouldDowncastReceiver = ik.isIndirect();
-        MethodCallTargetNode changed = null;
-        for (ValueNode i : FlowUtil.distinctValueAndConditionInputs(parent)) {
-            ValueNode j = (ValueNode) reasoner.deverbosify(i);
-            if (shouldDowncastReceiver) {
-                shouldDowncastReceiver = false;
-                j = reasoner.downcast(j);
-            }
-            if (i != j) {
-                assert j != parent;
-                if (changed == null) {
-                    changed = (MethodCallTargetNode) parent.copyWithInputs();
-                    reasoner.added.add(changed);
-                    // copyWithInputs() implies graph.unique(changed)
-                    assert changed.isAlive();
-                    assert FlowUtil.lacksUsages(changed);
-                }
-                FlowUtil.replaceInPlace(changed, i, j);
-            }
-        }
-        if (changed == null) {
-            return parent;
-        }
-        FlowUtil.inferStampAndCheck(changed);
-        /*
-         * No need to rememberSubstitution() because not called from deverbosify(). In detail, it's
-         * only deverbosify() that skips visited nodes (thus we'd better have recorded any
-         * substitutions we want for them). Not this case.
-         */
-        return changed;
-    }
-
-    /**
-     * Precondition: This method assumes that either:
-     *
-     * <ul>
-     * <li>the state has already stabilized (ie no more pending iterations in the "iterative"
-     * dataflow algorithm); or</li>
-     * <li>any rewritings made based on the state in its current form are conservative enough to be
-     * safe.</li>
-     * </ul>
-     *
-     * <p>
-     * The overarching goal is to perform just enough rewriting to trigger other phases (
-     * {@link com.oracle.graal.graph.spi.SimplifierTool SimplifierTool},
-     * {@link com.oracle.graal.phases.common.DeadCodeEliminationPhase DeadCodeEliminationPhase},
-     * etc) to perform the bulk of rewriting, thus lowering the maintenance burden.
-     * </p>
-     *
-     */
-    @Override
-    protected void node(FixedNode node) {
-
-        assert node.isAlive();
-
-        /*-------------------------------------------------------------------------------------
-         * Step 1: Unreachable paths are still visited (PostOrderNodeIterator requires all ends
-         * of a merge to have been visited), but time is saved by neither updating the state nor
-         * rewriting anything while on an an unreachable path.
-         *-------------------------------------------------------------------------------------
-         */
-        if (state.isUnreachable) {
-            return;
-        }
-
-        /*-------------------------------------------------------------------------------------
-         * Step 2: For an AbstractBeginNode, determine whether this path is reachable, register
-         * any associated guards.
-         *-------------------------------------------------------------------------------------
-         */
-        if (node instanceof BeginNode) {
-            BeginNode begin = (BeginNode) node;
-            Node pred = node.predecessor();
-
-            if (pred != null) {
-                registerControlSplit(pred, begin);
-            }
-            return;
-        }
-
-        /*-------------------------------------------------------------------------------------
-         * Step 3: Check whether EquationalReasoner caches should be cleared upon state updates.
-         *-------------------------------------------------------------------------------------
-         */
-        reasoner.updateState(state);
-
-        /*-------------------------------------------------------------------------------------
-         * Step 4: Whatever special-case handling makes sense for the FixedNode at hand before
-         * its inputs are reduced.
-         *-------------------------------------------------------------------------------------
-         */
-
-        if (node instanceof AbstractEndNode) {
-            visitAbstractEndNode((AbstractEndNode) node);
-            return;
-        } else if (node instanceof Invoke) {
-            visitInvoke((Invoke) node);
-            return;
-        } else if (node instanceof CheckCastNode) {
-            // it's important not to call deverbosification for visitCheckCastNode()
-            visitCheckCastNode((CheckCastNode) node);
-            return;
-        } else if (node instanceof GuardingPiNode) {
-            visitGuardingPiNode((GuardingPiNode) node);
-            return;
-        } else if (node instanceof NullCheckNode) {
-            visitNullCheckNode((NullCheckNode) node);
-            return;
-        } else if (node instanceof FixedGuardNode) {
-            visitFixedGuardNode((FixedGuardNode) node);
-            return;
-        } else if (node instanceof ConditionAnchorNode) {
-            // ConditionAnchorNode shouldn't occur during HighTier
-            return;
-        }
-
-        /*-------------------------------------------------------------------------------------
-         * Step 5: After special-case handling, we do our best for those FixedNode-s
-         * where the effort to reduce their inputs might pay off.
-         *
-         * Why is this useful? For example, by the time the BeginNode for an If-branch
-         * is visited (in general a ControlSplitNode), the If-condition will have gone already
-         * through simplification (and thus potentially have been reduced to a
-         * LogicConstantNode).
-         *-------------------------------------------------------------------------------------
-         */
-        boolean paysOffToReduce = false;
-        if (node instanceof ControlSplitNode) {
-            // desire to simplify control flow
-            paysOffToReduce = true;
-        } else if (node instanceof ReturnNode) {
-            paysOffToReduce = true;
-        } else if (node instanceof AccessFieldNode || node instanceof AccessArrayNode) {
-            // desire to remove null-checks
-            paysOffToReduce = true;
-        }
-
-        // TODO comb remaining FixedWithNextNode subclasses, pick those with chances of paying-off
-
-        // TODO UnsafeLoadNode takes a condition
-
-        if (paysOffToReduce) {
-            deverbosifyInputsInPlace(node);
-        }
-
-        /*---------------------------------------------------------------------------------------
-         * Step 6: Any additional special-case handling, this time after having inputs reduced.
-         * For example, leverage anchors provided by the FixedNode, to add facts to the factbase.
-         *---------------------------------------------------------------------------------------
-         */
-
-        // TODO some nodes are GuardingNodes (eg, FixedAccessNode) we could use them to track state
-        // TODO other nodes are guarded (eg JavaReadNode), thus *their* guards could be replaced.
-
-    }
-
-    /**
-     * In case the scrutinee:
-     *
-     * <ul>
-     * <li>is known to be null, an unconditional deopt is added.</li>
-     * <li>is known to be non-null, the NullCheckNode is removed.</li>
-     * <li>otherwise, the NullCheckNode is lowered to a FixedGuardNode which then allows using it as
-     * anchor for state-tracking.</li>
-     * </ul>
-     *
-     * <p>
-     * Precondition: the input (ie, object) hasn't been deverbosified yet.
-     * </p>
-     */
-    private void visitNullCheckNode(NullCheckNode ncn) {
-        ValueNode object = ncn.getObject();
-        if (state.isNull(object)) {
-            postponedDeopts.addDeoptBefore(ncn, NullCheckException);
-            state.impossiblePath();
-            return;
-        }
-        if (state.isNonNull(object)) {
-            /*
-             * Redundant NullCheckNode. Unlike GuardingPiNode or FixedGuardNode, NullCheckNode-s
-             * aren't used as GuardingNode-s, thus in this case can be removed without further ado.
-             */
-            assert FlowUtil.lacksUsages(ncn);
-            graph.removeFixed(ncn);
-            return;
-        }
-        /*
-         * Lower the NullCheckNode to a FixedGuardNode which then allows using it as anchor for
-         * state-tracking. TODO the assumption here is that the code emitted for the resulting
-         * FixedGuardNode is as efficient as for NullCheckNode.
-         */
-        IsNullNode isNN = graph.unique(new IsNullNode(object));
-        reasoner.added.add(isNN);
-        FixedGuardNode nullCheck = graph.add(new FixedGuardNode(isNN, UnreachedCode, InvalidateReprofile, true));
-        graph.replaceFixedWithFixed(ncn, nullCheck);
-
-        state.trackNN(object, nullCheck);
-    }
-
-    /**
-     * The {@link com.oracle.graal.nodes.AbstractEndNode} at the end of the current code path
-     * contributes values to {@link com.oracle.graal.nodes.PhiNode}s. Now is a good time to
-     * {@link EquationalReasoner#deverbosify(com.oracle.graal.graph.Node)
-     * EquationalReasoner#deverbosify} those values.
-     *
-     * <p>
-     * Precondition: inputs haven't been deverbosified yet.
-     * </p>
-     */
-    private void visitAbstractEndNode(AbstractEndNode endNode) {
-        MergeNode merge = endNode.merge();
-        for (PhiNode phi : merge.phis()) {
-            if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) {
-                assert phi.verify();
-                int index = merge.phiPredecessorIndex(endNode);
-                ValueNode original = phi.valueAt(index);
-                ValueNode reduced = (ValueNode) reasoner.deverbosify(original);
-                if (reduced != original) {
-                    phi.setValueAt(index, reduced);
-                    // `original` if unused will be removed in finished()
-                }
-            }
-        }
-    }
-
-    /**
-     * <p>
-     * For one or more `invoke` arguments, flow-sensitive information may suggest their narrowing or
-     * simplification. In those cases, a new
-     * {@link com.oracle.graal.nodes.java.MethodCallTargetNode MethodCallTargetNode} is prepared
-     * just for this callsite, consuming reduced arguments.
-     * </p>
-     *
-     * <p>
-     * Specializing the {@link com.oracle.graal.nodes.java.MethodCallTargetNode
-     * MethodCallTargetNode} as described above may enable two optimizations:
-     * <ul>
-     * <li>
-     * devirtualization of an {@link com.oracle.graal.nodes.CallTargetNode.InvokeKind#Interface} or
-     * {@link com.oracle.graal.nodes.CallTargetNode.InvokeKind#Virtual} callsite (devirtualization
-     * made possible after narrowing the type of the receiver)</li>
-     * <li>
-     * (future work) actual-argument-aware inlining, ie, to specialize callees on the types of
-     * arguments other than the receiver (examples: multi-methods, the inlining problem, lambdas as
-     * arguments).</li>
-     *
-     * </ul>
-     * </p>
-     *
-     * <p>
-     * Precondition: inputs haven't been deverbosified yet.
-     * </p>
-     */
-    private void visitInvoke(Invoke invoke) {
-        if (invoke.asNode().stamp() instanceof IllegalStamp) {
-            return; // just to be safe
-        }
-        boolean isMethodCallTarget = invoke.callTarget() instanceof MethodCallTargetNode;
-        if (!isMethodCallTarget) {
-            return;
-        }
-        FlowUtil.replaceInPlace(invoke.asNode(), invoke.callTarget(), deverbosifyInputsCopyOnWrite((MethodCallTargetNode) invoke.callTarget()));
-        MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
-        if (callTarget.invokeKind() != CallTargetNode.InvokeKind.Interface && callTarget.invokeKind() != CallTargetNode.InvokeKind.Virtual) {
-            return;
-        }
-        ValueNode receiver = callTarget.receiver();
-        if (receiver == null) {
-            return;
-        }
-        if (!FlowUtil.hasLegalObjectStamp(receiver)) {
-            return;
-        }
-        Witness w = state.typeInfo(receiver);
-        ResolvedJavaType type;
-        ResolvedJavaType stampType = StampTool.typeOrNull(receiver);
-        if (w == null || w.cluelessAboutType()) {
-            // can't improve on stamp but wil try to devirtualize anyway
-            type = stampType;
-        } else {
-            type = FlowUtil.tighten(w.type(), stampType);
-        }
-        if (type == null) {
-            return;
-        }
-        ResolvedJavaMethod method = type.resolveConcreteMethod(callTarget.targetMethod(), invoke.getContextType());
-        if (method == null) {
-            return;
-        }
-        if (method.canBeStaticallyBound() || Modifier.isFinal(type.getModifiers())) {
-            metricMethodResolved.increment();
-            callTarget.setInvokeKind(CallTargetNode.InvokeKind.Special);
-            callTarget.setTargetMethod(method);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReductionPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +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.phases.common.cfs;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.tiers.PhaseContext;
-
-public class FlowSensitiveReductionPhase extends BasePhase<PhaseContext> {
-
-    private final MetaAccessProvider metaAccess;
-
-    public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
-    }
-
-    public FlowSensitiveReductionPhase(MetaAccessProvider metaAccess) {
-        this.metaAccess = metaAccess;
-    }
-
-    @Override
-    protected final void run(StructuredGraph graph, PhaseContext context) {
-        try (Debug.Scope s = Debug.scope("FlowSensitiveReduction")) {
-            if (graph.isOSR()) {
-                Debug.log("Skipping OSR method %s", graph.method() == null ? "" : graph.method().format("%H.%n"));
-                return;
-            }
-            Debug.dump(graph, "FlowSensitiveReduction initial");
-            new FlowSensitiveReduction(graph.start(), new State(), context).apply();
-            Debug.dump(graph, "FlowSensitiveReduction done");
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,284 +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.phases.common.cfs;
-
-import java.util.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-
-public final class FlowUtil {
-
-    private FlowUtil() {
-        // no instances of this class
-    }
-
-    public static boolean lacksUsages(Node n) {
-        return n.usages().isEmpty();
-    }
-
-    public static ResolvedJavaType widen(ResolvedJavaType a, ResolvedJavaType b) {
-        if (a == null || b == null) {
-            return null;
-        } else if (a.equals(b)) {
-            return a;
-        } else {
-            return a.findLeastCommonAncestor(b);
-        }
-    }
-
-    /**
-     * @return whether the first argument is strictly more precise than the second.
-     */
-    public static boolean isMorePrecise(ResolvedJavaType a, ResolvedJavaType b) {
-        if (a == null) {
-            return false;
-        }
-        if (b == null) {
-            return true;
-        }
-        assert !a.isPrimitive();
-        assert !b.isPrimitive();
-        if (a.equals(b)) {
-            return false;
-        }
-        if (b.isInterface()) {
-            return b.isAssignableFrom(a);
-        }
-        if (a.isInterface()) {
-            return b.isInterface() && b.isAssignableFrom(a);
-        }
-        return b.isAssignableFrom(a);
-    }
-
-    public static ResolvedJavaType tighten(ResolvedJavaType a, ResolvedJavaType b) {
-        if (a == null) {
-            assert b == null || !b.isPrimitive();
-            return b;
-        }
-        if (b == null) {
-            assert !a.isPrimitive();
-            return a;
-        }
-        assert !a.isPrimitive();
-        assert !b.isPrimitive();
-        if (a.equals(b)) {
-            return a;
-        }
-        if (isMorePrecise(a, b)) {
-            return a;
-        } else if (isMorePrecise(b, a)) {
-            return b;
-        } else {
-            /*
-             * Not comparable, two cases:
-             * 
-             * Example 1: 'a' standing for j.l.Number and 'b' for j.l.String We return null for lack
-             * of a value representing NullType, the right answer. Same goes when both arguments are
-             * non-comparable interfaces.
-             * 
-             * Example 2: 'a' standing for sun/nio/ch/DirectBuffer (an interface) and b for
-             * java/nio/Buffer (an abstract class). The class always takes precedence.
-             */
-            if (a.isInterface()) {
-                return b.isInterface() ? null : b;
-            }
-            if (b.isInterface()) {
-                return a.isInterface() ? null : a;
-            }
-            return null; // a and b aren't comparable, can't tighten() them
-        }
-    }
-
-    /**
-     *
-     * There are "illegal" stamps that are not of type IllegalStamp.
-     *
-     * For example, there may be an IntegerStamp with upperBound < lowerBound that returns
-     * !isLegal() but we still know it's an integer and thus not of type IllegalStamp.
-     *
-     * An IllegalStamp should never happen. In contrast, !isLegal() values could happen due to dead
-     * code not yet removed, or upon some non-sideeffecting instructions floating out of a dead
-     * branch.
-     */
-    public static boolean isLegalObjectStamp(Stamp s) {
-        return isObjectStamp(s) && s.isLegal();
-    }
-
-    public static boolean hasLegalObjectStamp(ValueNode v) {
-        return isLegalObjectStamp(v.stamp());
-    }
-
-    public static boolean isObjectStamp(Stamp stamp) {
-        return stamp instanceof ObjectStamp;
-    }
-
-    public static void inferStampAndCheck(ValueNode n) {
-        n.inferStamp();
-        if (n.stamp() instanceof ObjectStamp) {
-            ObjectStamp objectStamp = (ObjectStamp) n.stamp();
-            assert !objectStamp.isExactType() || objectStamp.type() != null;
-        }
-    }
-
-    /**
-     * Compares the arguments along three dimensions (nullness, exactness, and type). For the first
-     * argument to be more precise than the second, it may not score lower in any dimension and must
-     * score higher in at least one dimension.
-     *
-     * When comparing types s and t, sameness counts as 0; while being more precise is awarded with
-     * a score of 1. In all other cases (non-comparable, or supertype) the score is -1.
-     *
-     * @return whether the first argument is strictly more precise than the second.
-     */
-    public static boolean isMorePrecise(ObjectStamp a, ObjectStamp b) {
-        int d0 = minus(a.alwaysNull(), b.alwaysNull());
-        if (d0 == -1) {
-            return false;
-        }
-        int d1 = minus(a.nonNull(), b.nonNull());
-        if (d1 == -1) {
-            return false;
-        }
-        int d2 = minus(a.isExactType(), b.isExactType());
-        if (d2 == -1) {
-            return false;
-        }
-        int d3;
-        ResolvedJavaType ta = a.type();
-        ResolvedJavaType tb = b.type();
-        if (ta == null) {
-            d3 = (tb == null) ? 0 : -1;
-        } else if (tb == null) {
-            d3 = 1;
-        } else if (isMorePrecise(ta, tb)) {
-            d3 = 1;
-        } else if (ta.equals(tb)) {
-            d3 = 0;
-        } else {
-            d3 = -1;
-        }
-        if (d3 == -1) {
-            return false;
-        }
-        int maxScore = Math.max(Math.max(d0, d1), Math.max(d2, d3));
-        return maxScore > 0;
-    }
-
-    private static int minus(boolean a, boolean b) {
-        int aa = a ? 1 : 0;
-        int bb = b ? 1 : 0;
-        return aa - bb;
-    }
-
-    public static LogicConstantNode asLogicConstantNode(LogicNode cond) {
-        return (cond instanceof LogicConstantNode) ? (LogicConstantNode) cond : null;
-    }
-
-    public static boolean isLiteralNode(ValueNode f) {
-        return f instanceof ConstantNode || f instanceof LogicConstantNode;
-    }
-
-    public static boolean isConstantTrue(LogicNode cond) {
-        LogicConstantNode c = asLogicConstantNode(cond);
-        return (c != null) && c.getValue();
-    }
-
-    public static boolean isConstantFalse(LogicNode cond) {
-        LogicConstantNode c = asLogicConstantNode(cond);
-        return (c != null) && !c.getValue();
-    }
-
-    public static boolean alwaysFails(boolean isNegated, LogicNode cond) {
-        LogicConstantNode c = asLogicConstantNode(cond);
-        return (c != null) && (c.getValue() == isNegated);
-    }
-
-    public static boolean alwaysSucceeds(boolean isNegated, LogicNode cond) {
-        LogicConstantNode c = asLogicConstantNode(cond);
-        return (c != null) && (c.getValue() != isNegated);
-    }
-
-    /**
-     * Returns (preserving order) the ValueNodes without duplicates found among the argument's
-     * direct inputs.
-     */
-    @SuppressWarnings("unchecked")
-    public static List<ValueNode> distinctValueAndConditionInputs(Node n) {
-        ArrayList<ValueNode> result = null;
-        NodePosIterator iter = n.inputs().iterator();
-        while (iter.hasNext()) {
-            Position pos = iter.nextPosition();
-            InputType inputType = pos.getInputType();
-            boolean isReducibleInput = (inputType == InputType.Value || inputType == InputType.Condition);
-            if (isReducibleInput) {
-                ValueNode i = (ValueNode) pos.get(n);
-                if (!isLiteralNode(i)) {
-                    if (result == null) {
-                        result = new ArrayList<>();
-                    }
-                    if (!result.contains(i)) {
-                        result.add(i);
-                    }
-                }
-            }
-        }
-        return result == null ? Collections.EMPTY_LIST : result;
-    }
-
-    public static ObjectStamp asNonNullStamp(ObjectStamp stamp) {
-        ObjectStamp result = (ObjectStamp) stamp.join(StampFactory.objectNonNull());
-        assert result.isLegal();
-        return result;
-    }
-
-    public static ObjectStamp asRefinedStamp(ObjectStamp stamp, ResolvedJavaType joinType) {
-        assert !joinType.isInterface();
-        ObjectStamp result = (ObjectStamp) stamp.join(StampFactory.declared(joinType));
-        assert result.isLegal();
-        return result;
-    }
-
-    /**
-     * Start situation: the parent node has <code>oldInput</code> among its (direct) inputs. After
-     * this method has run, all such occurrences have been replaced with <code>newInput</code>. In
-     * case that makes <code>oldInput</code> disconnected, it is removed from the graph.
-     */
-    public static void replaceInPlace(Node parent, Node oldInput, Node newInput) {
-        assert parent != null;
-        assert parent.inputs().contains(oldInput);
-        if (oldInput == newInput) {
-            return;
-        }
-        assert oldInput != null && newInput != null;
-        assert !isLiteralNode((ValueNode) oldInput);
-        do {
-            parent.replaceFirstInput(oldInput, newInput);
-        } while (parent.inputs().contains(oldInput));
-        // `oldInput` if unused wil be removed in finished()
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/GuardingPiReduction.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +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.phases.common.cfs;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.debug.Debug;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.IsNullNode;
-import com.oracle.graal.nodes.extended.GuardingNode;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.compiler.common.type.ObjectStamp;
-import com.oracle.graal.nodes.type.StampTool;
-import com.oracle.graal.phases.tiers.PhaseContext;
-
-/**
- * <p>
- * This class implements control-flow sensitive reductions for
- * {@link com.oracle.graal.nodes.GuardingPiNode}.
- * </p>
- * 
- * <p>
- * The laundry-list of all flow-sensitive reductions is summarized in
- * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction}
- * </p>
- * 
- * @see #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
- */
-public abstract class GuardingPiReduction extends BaseReduction {
-
-    public GuardingPiReduction(StartNode start, State initialState, PhaseContext context) {
-        super(start, initialState, context);
-    }
-
-    /**
-     * <p>
-     * By the time a {@link com.oracle.graal.nodes.GuardingPiNode GuardingPiNode} is visited, the
-     * available type refinements may allow reductions similar to those performed for
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction#visitCheckCastNode(com.oracle.graal.nodes.java.CheckCastNode)
-     * CheckCastNode}.
-     * </p>
-     * 
-     * <ol>
-     * <li>
-     * If the condition needs no reduction (ie, it's already a
-     * {@link com.oracle.graal.nodes.LogicConstantNode LogicConstantNode}), this method basically
-     * gives up (thus letting other phases take care of it).</li>
-     * <li>
-     * Otherwise, an attempt is made to find a {@link com.oracle.graal.nodes.extended.GuardingNode}
-     * that implies the combination of (negated, condition) of the
-     * {@link com.oracle.graal.nodes.GuardingPiNode} being visited. Details in
-     * {@link #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)}. If found, the node
-     * can be removed.</li>
-     * <li>
-     * Otherwise, the node is lowered to a {@link com.oracle.graal.nodes.FixedGuardNode} and its
-     * usages replaced with {@link com.oracle.graal.nodes.PiNode}. Details in
-     * {@link #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)}.</li>
-     * </ol>
-     * 
-     * <p>
-     * Precondition: the condition hasn't been deverbosified yet.
-     * </p>
-     * 
-     */
-    protected final void visitGuardingPiNode(GuardingPiNode envelope) {
-
-        if (!FlowUtil.hasLegalObjectStamp(envelope)) {
-            // this situation exercised by com.oracle.graal.jtt.optimize.NCE_FlowSensitive02
-            return;
-        }
-        if (!FlowUtil.hasLegalObjectStamp(envelope.object())) {
-            return;
-        }
-
-        /*
-         * (1 of 3) Cover the case of GuardingPiNode(LogicConstantNode, ...)
-         */
-
-        if (envelope.condition() instanceof LogicConstantNode) {
-            if (FlowUtil.alwaysFails(envelope.isNegated(), envelope.condition())) {
-                state.impossiblePath();
-                // let GuardingPiNode(false).canonical() prune the dead-code control-path
-                return;
-            }
-            // if not always-fails and condition-constant, then it always-succeeds!
-            assert FlowUtil.alwaysSucceeds(envelope.isNegated(), envelope.condition());
-            // let GuardingPiNode(true).canonical() replaceAtUsages
-            return;
-        }
-
-        /*
-         * The trick used in visitFixedGuardNode to look up an equivalent GuardingNode for the
-         * combination of (negated, condition) at hand doesn't work for GuardingPiNode, because the
-         * condition showing up here (a ShortCircuitOrNode that can be detected by
-         * CastCheckExtractor) doesn't appear as key in trueFacts, falseFacts. Good thing we have
-         * CastCheckExtractor!
-         */
-
-        /*
-         * (2 of 3) Cover the case of the condition known-to-be-false or known-to-be-true, but not
-         * LogicConstantNode.
-         * 
-         * If deverbosify(condition) == falseConstant, it would be safe to set:
-         * `envelope.setCondition(falseConstant)` (only the API won't allow).
-         * 
-         * On the other hand, it's totally unsafe to do something like that for trueConstant. What
-         * we can do about that case is the province of `tryRemoveGuardingPiNode(envelope)`
-         */
-
-        if (tryRemoveGuardingPiNode(envelope)) {
-            return;
-        }
-
-        /*
-         * Experience has shown that an attempt to eliminate the current GuardingPiNode by using a
-         * GuardingNode already in scope and with equivalent condition (grabbed from `trueFacts`
-         * resp. `falseFacts`) proves futile. Therefore we're not even attempting that here.
-         */
-
-        /*
-         * (3 of 3) Neither always-succeeds nor always-fails, ie we don't known. Converting to
-         * FixedGuardNode allows tracking the condition via a GuardingNode, thus potentially
-         * triggering simplifications down the road.
-         */
-        FixedGuardNode fixedGuard = graph.add(new FixedGuardNode(envelope.condition(), envelope.getReason(), envelope.getAction(), envelope.isNegated()));
-        graph.addBeforeFixed(envelope, fixedGuard);
-
-        /*
-         * 
-         * TODO This lowering is currently performed unconditionally: it might occur no
-         * flow-sensitive reduction is enabled down the road
-         */
-
-        if (!FlowUtil.lacksUsages(envelope)) {
-            // not calling wrapInPiNode() because we don't want to rememberSubstitution()
-            PiNode replacement = graph.unique(new PiNode(envelope.object(), envelope.stamp(), fixedGuard));
-            reasoner.added.add(replacement);
-            // before removing the GuardingPiNode replace its usages
-            envelope.replaceAtUsages(replacement);
-        }
-
-        graph.removeFixed(envelope);
-
-        state.addFact(!fixedGuard.isNegated(), fixedGuard.condition(), fixedGuard);
-
-    }
-
-    /**
-     * <p>
-     * Based on flow-sensitive knowledge, two pre-requisites have to be fulfilled in order to remove
-     * a {@link com.oracle.graal.nodes.GuardingPiNode}:
-     * 
-     * <ul>
-     * <li>the condition must refer only to the payload of the
-     * {@link com.oracle.graal.nodes.GuardingPiNode}</li>
-     * <li>the condition must check properties about which the state tracks not only a true/false
-     * answer, but also an anchor witnessing that fact</li>
-     * <li>the condition may not check anything else beyond what's stated in the items above.</li>
-     * </ul>
-     * </p>
-     * 
-     * <p>
-     * Provided a condition as above can be reduced to a constant (and an anchor obtained in the
-     * process), this method replaces all usages of the
-     * {@link com.oracle.graal.nodes.GuardingPiNode} (necessarily of
-     * {@link com.oracle.graal.nodeinfo.InputType#Value}) with a
-     * {@link com.oracle.graal.nodes.PiNode} that wraps the payload and the anchor in question.
-     * </p>
-     * 
-     * <p>
-     * Precondition: the condition hasn't been deverbosified yet.
-     * </p>
-     * 
-     * @see #visitGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
-     * 
-     */
-    private boolean tryRemoveGuardingPiNode(GuardingPiNode envelope) {
-
-        LogicNode cond = envelope.condition();
-        ValueNode payload = envelope.object();
-
-        ObjectStamp outgoingStamp = (ObjectStamp) envelope.stamp();
-        ObjectStamp payloadStamp = (ObjectStamp) payload.stamp();
-
-        if (isNullCheckOn(cond, payload)) {
-            if (envelope.isNegated()) {
-                /*
-                 * GuardingPiNode succeeds if payload non-null
-                 */
-                if (!outgoingStamp.equals(FlowUtil.asNonNullStamp(payloadStamp))) {
-                    warnAboutOutOfTheBlueGuardingPiNode(envelope);
-                }
-                return tryRemoveGuardingPiNodeNonNullCond(envelope);
-            } else {
-                /*
-                 * GuardingPiNode succeeds if payload null
-                 */
-                ValueNode replacement = StampTool.isPointerAlwaysNull(payload) ? payload : reasoner.nonTrivialNull(payload);
-                if (replacement != null) {
-                    // replacement == null means !isKnownNull(payload)
-                    removeGuardingPiNode(envelope, replacement);
-                    return true;
-                }
-                return false;
-            }
-        } else if (CastCheckExtractor.isInstanceOfCheckOn(cond, payload)) {
-            if (envelope.isNegated()) {
-                return false;
-            }
-            /*
-             * GuardingPiNode succeeds if payload instanceof <something>
-             */
-            InstanceOfNode io = (InstanceOfNode) cond;
-            assert io.type() != null;
-            Witness w = state.typeInfo(payload);
-            if (w != null && w.isNonNull() && isEqualOrMorePrecise(w.type(), io.type())) {
-                ValueNode d = reasoner.downcast(payload);
-                removeGuardingPiNode(envelope, d);
-                return true;
-            }
-            return false;
-        } else if (cond instanceof ShortCircuitOrNode) {
-            if (envelope.isNegated()) {
-                return false;
-            }
-            CastCheckExtractor cce = CastCheckExtractor.extract(cond);
-            if (cce == null || cce.subject != payload) {
-                return false;
-            }
-            /*
-             * GuardingPiNode succeeds if payload check-casts toType
-             */
-            return tryRemoveGuardingPiNodeCheckCastCond(envelope, cce.type);
-        }
-
-        return false;
-    }
-
-    /**
-     * Porcelain method.
-     * 
-     * This method handles the case where the GuardingPiNode succeeds if payload known to be
-     * non-null.
-     * 
-     * @see #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
-     */
-    private boolean tryRemoveGuardingPiNodeNonNullCond(GuardingPiNode envelope) {
-
-        ValueNode payload = envelope.object();
-
-        if (state.isNull(payload)) {
-            // the GuardingPiNode fails always
-            postponedDeopts.addDeoptBefore(envelope, envelope.getReason());
-            state.impossiblePath();
-            return true;
-        }
-
-        if (StampTool.isPointerNonNull(payload)) {
-            // payload needs no downcasting, it satisfies as-is the GuardingPiNode's condition.
-            if (precisionLoss(envelope, payload)) {
-                /*
-                 * TODO The GuardingPiNode has an outgoing stamp whose narrowing goes beyond what
-                 * the condition checks. That's suspicious.
-                 */
-                PiNode replacement = graph.unique(new PiNode(payload, envelope.stamp()));
-                reasoner.added.add(replacement);
-                removeGuardingPiNode(envelope, replacement);
-                return true;
-            } else {
-                removeGuardingPiNode(envelope, payload);
-                return true;
-            }
-        }
-        // if a non-null witness available, the GuardingPiNode can be removed
-
-        Witness w = state.typeInfo(payload);
-        GuardingNode nonNullAnchor = (w != null && w.isNonNull()) ? w.guard() : null;
-        if (nonNullAnchor != null) {
-            PiNode replacement = graph.unique(new PiNode(payload, envelope.stamp(), nonNullAnchor.asNode()));
-            reasoner.added.add(replacement);
-            removeGuardingPiNode(envelope, replacement);
-            return true;
-        }
-
-        /*
-         * TODO What about, nodes that always denote non-null values? (Even though their stamp
-         * forgot to make that clear) Candidates: ObjectGetClassNode, Parameter(0) on instance
-         */
-
-        return false;
-    }
-
-    /**
-     * Porcelain method.
-     * 
-     * This method handles the case where the GuardingPiNode succeeds if payload null or its actual
-     * type equal or subtype of `toType`
-     * 
-     * @see #tryRemoveGuardingPiNode(com.oracle.graal.nodes.GuardingPiNode)
-     * 
-     */
-    private boolean tryRemoveGuardingPiNodeCheckCastCond(GuardingPiNode envelope, ResolvedJavaType toType) {
-        assert toType != null;
-        ValueNode payload = envelope.object();
-
-        ObjectStamp outgoingStamp = (ObjectStamp) envelope.stamp();
-        ObjectStamp payloadStamp = (ObjectStamp) payload.stamp();
-
-        if (!outgoingStamp.equals(FlowUtil.asRefinedStamp(payloadStamp, toType))) {
-            warnAboutOutOfTheBlueGuardingPiNode(envelope);
-        }
-
-        ValueNode d = reasoner.downcast(payload);
-        if (d == null) {
-            return false;
-        }
-
-        if (StampTool.isPointerAlwaysNull(d)) {
-            removeGuardingPiNode(envelope, d);
-            return true;
-        }
-        ObjectStamp dStamp = (ObjectStamp) d.stamp();
-        if (isEqualOrMorePrecise(dStamp.type(), toType)) {
-            removeGuardingPiNode(envelope, d);
-            return true;
-        }
-        return false;
-    }
-
-    /*
-     * TODO There should be an assert in GuardingPiNode to detect that as soon as it happens
-     * (constructor, setStamp).
-     */
-    private static void warnAboutOutOfTheBlueGuardingPiNode(GuardingPiNode envelope) {
-        Debug.log(String.format("GuardingPiNode has an outgoing stamp whose narrowing goes beyond what its condition checks: %s", envelope));
-    }
-
-    private static boolean isNullCheckOn(LogicNode cond, ValueNode subject) {
-        if (!(cond instanceof IsNullNode)) {
-            return false;
-        }
-        IsNullNode isNull = (IsNullNode) cond;
-        return isNull.getValue() == subject;
-    }
-
-    /**
-     * Porcelain method.
-     */
-    private void removeGuardingPiNode(GuardingPiNode envelope, ValueNode replacement) {
-        assert !precisionLoss(envelope, replacement);
-        metricGuardingPiNodeRemoved.increment();
-        envelope.replaceAtUsages(replacement);
-        assert FlowUtil.lacksUsages(envelope);
-        graph.removeFixed(envelope);
-    }
-
-    public static boolean isEqualOrMorePrecise(ResolvedJavaType a, ResolvedJavaType b) {
-        return a.equals(b) || FlowUtil.isMorePrecise(a, b);
-    }
-
-    public static boolean isEqualOrMorePrecise(ObjectStamp a, ObjectStamp b) {
-        return a.equals(b) || FlowUtil.isMorePrecise(a, b);
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Histogram.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +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.phases.common.cfs;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-public class Histogram extends TreeMap<Integer, Integer> {
-
-    private static final long serialVersionUID = 7188324319057387738L;
-
-    private final String prefix;
-
-    public Histogram(String prefix) {
-        this.prefix = prefix;
-    }
-
-    public void tick(int bucket) {
-        Integer entry = get(bucket);
-        put(bucket, entry == null ? 1 : entry + 1);
-    }
-
-    public void print() {
-
-        // printing takes time, allow concurrent updates during printing
-        Histogram histogram = clone();
-
-        float casesTotal = 0;
-        for (int i : histogram.values()) {
-            casesTotal += i;
-        }
-        for (Map.Entry<Integer, Integer> entry : histogram.entrySet()) {
-            int numCases = entry.getValue();
-            int percentOut = (int) (numCases / casesTotal * 100);
-            String msg = prefix + String.format("%d iters in %4d cases (%2d %%)", entry.getKey(), numCases, percentOut);
-            if (entry.getKey() > 3) {
-                highlightInRed(msg);
-            } else {
-                System.out.println(msg);
-            }
-        }
-        System.out.println(prefix + "--------------------------");
-    }
-
-    @Override
-    public Histogram clone() {
-        return (Histogram) super.clone();
-    }
-
-    public static final String ANSI_RESET = "\u001B[0m";
-    public static final String ANSI_RED = "\u001B[31m";
-
-    public static void highlightInRed(String msg) {
-        System.out.println(ANSI_RED + msg + ANSI_RESET);
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +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.phases.common.cfs;
-
-import static com.oracle.graal.graph.Graph.NodeEvent.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.graph.Graph.NodeEventScope;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.util.*;
-import com.oracle.graal.phases.tiers.*;
-
-public class IterativeFlowSensitiveReductionPhase extends BasePhase<PhaseContext> {
-
-    private static final int MAX_ITERATIONS = 256;
-
-    private final CanonicalizerPhase canonicalizer;
-
-    public IterativeFlowSensitiveReductionPhase(CanonicalizerPhase canonicalizer) {
-        this.canonicalizer = canonicalizer;
-    }
-
-    // private Histogram histogram = new Histogram("FSR-");
-
-    @Override
-    protected void run(StructuredGraph graph, PhaseContext context) {
-        FlowSensitiveReductionPhase eliminate = new FlowSensitiveReductionPhase(context.getMetaAccess());
-        HashSetNodeEventListener listener = new HashSetNodeEventListener().exclude(NODE_ADDED);
-        int count = 1;
-        while (true) {
-            try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
-                eliminate.apply(graph, context);
-            }
-            if (listener.getNodes().isEmpty()) {
-                // histogram.tick(count);
-                break;
-            }
-            for (Node node : graph.getNodes()) {
-                if (node instanceof Simplifiable) {
-                    listener.getNodes().add(node);
-                }
-            }
-            canonicalizer.applyIncremental(graph, context, listener.getNodes());
-            listener.getNodes().clear();
-            if (++count > MAX_ITERATIONS) {
-                // System.out.println("Bailing out IterativeFlowSensitiveReductionPhase for graph: "
-                // + graph);
-                // FlowUtil.visualize(graph, "Bailout");
-                throw new BailoutException("Number of iterations in FlowSensitiveReductionPhase exceeds %d", MAX_ITERATIONS);
-            }
-        }
-        // histogram.print();
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/State.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1017 +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.phases.common.cfs;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.nodes.type.*;
-import com.oracle.graal.nodes.util.*;
-import com.oracle.graal.phases.graph.*;
-
-/**
- * A State instance is mutated in place as each FixedNode is visited in a basic block of
- * instructions. Basic block: starts with a {@link com.oracle.graal.nodes.BeginNode BeginNode}, ends
- * at an {@link com.oracle.graal.nodes.EndNode EndNode} or
- * {@link com.oracle.graal.nodes.ControlSinkNode ControlSinkNode} and lacks intervening control
- * splits or merges.
- */
-public final class State extends MergeableState<State> implements Cloneable {
-
-    private static final DebugMetric metricTypeRegistered = Debug.metric("FSR-TypeRegistered");
-    private static final DebugMetric metricNullnessRegistered = Debug.metric("FSR-NullnessRegistered");
-    private static final DebugMetric metricObjectEqualsRegistered = Debug.metric("FSR-ObjectEqualsRegistered");
-    private static final DebugMetric metricImpossiblePathDetected = Debug.metric("FSR-ImpossiblePathDetected");
-
-    /**
-     * <p>
-     * Each state update results in a higher {@link State#versionNr versionNr}. The
-     * {@link State#versionNr versionNr} of different State instances can't be meaningfully compared
-     * (ie, same {@link State#versionNr versionNr} just indicates they've gone through the same
-     * number of updates). In particular, the {@link State#versionNr versionNr} of a merged state
-     * doesn't guarantee any more than being different from those of the states being merged.
-     * </p>
-     *
-     * <p>
-     * Still, {@link State#versionNr versionNr} proves useful in two cases:
-     *
-     * <ul>
-     * <li>recording the {@link State#versionNr versionNr} right after {@link State State} cloning,
-     * allows finding out afterwards whether (a) both states have diverged, (b) just one of them, or
-     * (c) none of them.</li>
-     * <li>a {@link State State} may become {@link State#isUnreachable isUnreachable}. In such case,
-     * it may make a difference whether any updates were performed on the state from the time it was
-     * cloned. Those updates indicate information not available in the state is was cloned from. For
-     * the purposes of {@link FlowSensitiveReduction FlowSensitiveReduction} an unreachable state
-     * need not be merged with any other (because control-flow won't reach the merge point over the
-     * path of the unreachable state).</li>
-     * </ul>
-     * </p>
-     *
-     */
-    int versionNr = 0;
-
-    boolean isUnreachable = false;
-
-    /**
-     * Getting here implies an opportunity was detected for dead-code-elimination. A counterpoint
-     * argument goes as follows: perhaps we don't get here that often, in which case the effort to
-     * detect an "impossible path" could be shaved off.
-     *
-     * @see com.oracle.graal.phases.common.cfs.BaseReduction.PostponedDeopt
-     */
-    void impossiblePath() {
-        isUnreachable = true;
-        metricImpossiblePathDetected.increment();
-    }
-
-    /**
-     * <p>
-     * This map tracks properties about reference-values, ie combinations of: definitely-null,
-     * known-to-be-non-null, seen-type.
-     * </p>
-     *
-     * <p>
-     * In contrast to {@link #trueFacts} and {@link #falseFacts}, this map can answer queries even
-     * though the exact {@link LogicNode} standing for such query hasn't been tracked. For example,
-     * queries about subtyping. Additionally, a {@link Witness} can combine separate pieces of
-     * information more flexibly, eg, two separate observations about non-null and check-cast are
-     * promoted to an instance-of witness.
-     * </p>
-     *
-     */
-    private Map<ValueNode, Witness> typeRefinements;
-
-    Map<LogicNode, GuardingNode> trueFacts;
-    Map<LogicNode, GuardingNode> falseFacts;
-
-    public State() {
-        this.typeRefinements = Node.newIdentityMap();
-        this.trueFacts = Node.newIdentityMap();
-        this.falseFacts = Node.newIdentityMap();
-    }
-
-    public State(State other) {
-        this.isUnreachable = other.isUnreachable;
-        this.versionNr = other.versionNr;
-        this.typeRefinements = Node.newIdentityMap();
-        for (Map.Entry<ValueNode, Witness> entry : other.typeRefinements.entrySet()) {
-            this.typeRefinements.put(entry.getKey(), new Witness(entry.getValue()));
-        }
-        this.trueFacts = Node.newIdentityMap(other.trueFacts);
-        this.falseFacts = Node.newIdentityMap(other.falseFacts);
-    }
-
-    public boolean repOK() {
-        // trueFacts and falseFacts disjoint
-        for (LogicNode trueFact : trueFacts.keySet()) {
-            assert !falseFacts.containsKey(trueFact) : trueFact + " tracked as both true and false fact.";
-        }
-        return true;
-    }
-
-    /**
-     * @return A new list containing only those states that are reachable.
-     */
-    private static ArrayList<State> reachableStates(List<State> states) {
-        ArrayList<State> result = new ArrayList<>(states);
-        Iterator<State> iter = result.iterator();
-        while (iter.hasNext()) {
-            if (iter.next().isUnreachable) {
-                iter.remove();
-            }
-        }
-        return result;
-    }
-
-    private Map<ValueNode, Witness> mergeKnownTypes(MergeNode merge, ArrayList<State> withReachableStates) {
-        Map<ValueNode, Witness> newKnownTypes = Node.newIdentityMap();
-
-        for (Map.Entry<ValueNode, Witness> entry : typeRefinements.entrySet()) {
-            ValueNode node = entry.getKey();
-            Witness type = new Witness(entry.getValue());
-
-            for (State other : withReachableStates) {
-                Witness otherType = other.typeInfo(node);
-                if (otherType == null) {
-                    type = null;
-                    break;
-                }
-                type.merge(otherType, merge);
-            }
-            if (type != null && type.knowsBetterThan(node)) {
-                assert node == GraphUtil.unproxify(node);
-                newKnownTypes.put(node, type);
-            }
-        }
-
-        return newKnownTypes;
-    }
-
-    /**
-     * <p>
-     * This method handles phis, by adding to the resulting state any information that can be gained
-     * (about type-refinement and nullness) based on the data available at each of the incoming
-     * branches.
-     * </p>
-     *
-     * <p>
-     * In more detail, <code>FlowSensitiveReduction#visitAbstractEndNode()</code> has already
-     * deverbosified the phi-values contributed by each reachable branch. The paths that
-     * {@link com.oracle.graal.phases.common.cfs.FlowSensitiveReduction} determined to be
-     * unreachable will be eliminated by canonicalization and dead code elimination. For now they
-     * still exist, thus polluting the result of
-     * {@link com.oracle.graal.nodes.ValuePhiNode#inferStamp()} but we are careful to skip them when
-     * merging type-witnesses and known-null maps.
-     * </p>
-     */
-    private void mergePhis(MergeNode merge, List<State> withStates, Map<ValueNode, Witness> newKnownPhiTypes) {
-
-        if (merge instanceof LoopBeginNode) {
-            return;
-        }
-
-        for (PhiNode phi : merge.phis()) {
-            assert phi == GraphUtil.unproxify(phi);
-            if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) {
-                ArrayList<ValueNode> reachingValues = new ArrayList<>();
-                if (!isUnreachable) {
-                    reachingValues.add(phi.valueAt(0));
-                }
-                for (int i = 0; i < withStates.size(); i++) {
-                    State otherState = withStates.get(i);
-                    if (!otherState.isUnreachable) {
-                        reachingValues.add(phi.valueAt(i + 1));
-                    }
-                }
-                assert !reachingValues.isEmpty();
-                ObjectStamp phiStamp = (ObjectStamp) phi.stamp();
-                ObjectStamp nonPollutedStamp = (ObjectStamp) StampTool.meet(reachingValues);
-                Witness w = new Witness(nonPollutedStamp, merge);
-                if (w.isNull() && !phiStamp.alwaysNull()) {
-                    // precision gain: null
-                    newKnownPhiTypes.put(phi, w);
-                } else if (FlowUtil.isMorePrecise(w.type(), phiStamp.type())) {
-                    // precision gain regarding type
-                    newKnownPhiTypes.put(phi, w);
-                    // confirm no precision loss regarding nullness
-                    assert implies(phiStamp.nonNull(), w.isNonNull());
-                    assert implies(phiStamp.alwaysNull(), w.isNull());
-                } else if (w.isNonNull() && !phiStamp.nonNull()) {
-                    // precision gain: non-null
-                    newKnownPhiTypes.put(phi, w);
-                    // confirm no precision loss regarding type
-                    assert !FlowUtil.isMorePrecise(phiStamp.type(), w.type());
-                }
-            }
-        }
-
-    }
-
-    private static boolean implies(boolean a, boolean b) {
-        return !a || b;
-    }
-
-    @Override
-    public boolean merge(MergeNode merge, List<State> withStates) {
-
-        ArrayList<State> withReachableStates = reachableStates(withStates);
-        if (withReachableStates.isEmpty()) {
-            return true;
-        }
-
-        for (State other : withReachableStates) {
-            versionNr = Math.max(versionNr, other.versionNr) + 1;
-            if (!other.isUnreachable) {
-                isUnreachable = false;
-            }
-        }
-
-        if (isUnreachable) {
-            typeRefinements.clear();
-            trueFacts.clear();
-            falseFacts.clear();
-            return true;
-        }
-
-        // may also get updated in a moment, during processing of phi nodes.
-        Map<ValueNode, Witness> newKnownTypes = mergeKnownTypes(merge, withReachableStates);
-        // may also get updated in a moment, during processing of phi nodes.
-        mergePhis(merge, withStates, newKnownTypes);
-        this.typeRefinements = newKnownTypes;
-
-        this.trueFacts = mergeTrueFacts(withReachableStates, merge);
-        this.falseFacts = mergeFalseFacts(withReachableStates, merge);
-
-        assert repOK();
-
-        return true;
-    }
-
-    private Map<LogicNode, GuardingNode> mergeTrueFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
-        Map<LogicNode, GuardingNode> newTrueConditions = Node.newIdentityMap();
-        for (Map.Entry<LogicNode, GuardingNode> entry : trueFacts.entrySet()) {
-            LogicNode check = entry.getKey();
-            GuardingNode guard = entry.getValue();
-
-            for (State other : withReachableStates) {
-                GuardingNode otherGuard = other.trueFacts.get(check);
-                if (otherGuard == null) {
-                    guard = null;
-                    break;
-                }
-                if (otherGuard != guard) {
-                    guard = merge;
-                }
-            }
-            if (guard != null) {
-                newTrueConditions.put(check, guard);
-            }
-        }
-        return newTrueConditions;
-    }
-
-    private Map<LogicNode, GuardingNode> mergeFalseFacts(ArrayList<State> withReachableStates, GuardingNode merge) {
-        Map<LogicNode, GuardingNode> newFalseConditions = Node.newIdentityMap();
-        for (Map.Entry<LogicNode, GuardingNode> entry : falseFacts.entrySet()) {
-            LogicNode check = entry.getKey();
-            GuardingNode guard = entry.getValue();
-
-            for (State other : withReachableStates) {
-                GuardingNode otherGuard = other.falseFacts.get(check);
-                if (otherGuard == null) {
-                    guard = null;
-                    break;
-                }
-                if (otherGuard != guard) {
-                    guard = merge;
-                }
-            }
-            if (guard != null) {
-                newFalseConditions.put(check, guard);
-            }
-        }
-        return newFalseConditions;
-    }
-
-    /**
-     * @return null if no type-witness available for the argument, the witness otherwise.
-     */
-    public Witness typeInfo(ValueNode object) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        return typeRefinements.get(GraphUtil.unproxify(object));
-    }
-
-    /**
-     * @return true iff the argument is known to stand for null.
-     */
-    public boolean isNull(ValueNode object) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        if (StampTool.isPointerAlwaysNull(object)) {
-            return true;
-        }
-        ValueNode scrutinee = GraphUtil.unproxify(object);
-        Witness w = typeRefinements.get(scrutinee);
-        return (w != null) && w.isNull();
-    }
-
-    /**
-     * <p>
-     * It makes a difference calling {@link Witness#isNonNull()} as opposed to
-     * {@link State#isNonNull(com.oracle.graal.nodes.ValueNode)}. The former guarantees the witness
-     * provides a guard certifying non-nullness. The latter just tells us there exists some guard
-     * that certifies the property we asked about.
-     * </p>
-     *
-     * <p>
-     * TODO improvement: isKnownNonNull could be made smarter by noticing some nodes always denote a
-     * non-null value (eg, ObjectGetClassNode). Similarly for isKnownNull. Code that looks at the
-     * stamp as well as code that looks for a non-null-witness would benefit from also checking such
-     * extended isKnownNonNull. Alternatively, the stamp of those nodes should always have
-     * is-non-null set.
-     * </p>
-     *
-     * @return true iff the argument is known to stand for non-null.
-     */
-    public boolean isNonNull(ValueNode object) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        if (StampTool.isPointerNonNull(object)) {
-            return true;
-        }
-        Witness w = typeInfo(object);
-        return w == null ? false : w.isNonNull();
-    }
-
-    /**
-     * @return true iff the argument definitely stands for an object-value that conforms to the
-     *         given type.
-     */
-    public boolean knownToConform(ValueNode object, ResolvedJavaType to) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        assert !to.isPrimitive();
-        ResolvedJavaType stampType = StampTool.typeOrNull(object);
-        if (stampType != null && to.isAssignableFrom(stampType)) {
-            return true;
-        }
-        final ValueNode scrutinee = GraphUtil.unproxify(object);
-        if (isNull(scrutinee)) {
-            return true;
-        }
-        Witness w = typeInfo(scrutinee);
-        boolean witnessAnswer = w != null && w.type() != null && to.isAssignableFrom(w.type());
-        if (witnessAnswer) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * @return true iff the argument is known to stand for an object that is definitely non-null and
-     *         moreover does not conform to the given type.
-     */
-    public boolean knownNotToPassCheckCast(ValueNode object, ResolvedJavaType to) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        assert !to.isPrimitive();
-        final ValueNode scrutinee = GraphUtil.unproxify(object);
-        if (isNull(scrutinee)) {
-            // known-null means it conforms to whatever `to`
-            // and thus passes the check-cast
-            return false;
-        }
-        if (!isNonNull(scrutinee)) {
-            // unless `null` can be ruled out, a positive answer isn't safe
-            return false;
-        }
-        ResolvedJavaType stampType = StampTool.typeOrNull(object);
-        if (stampType != null && knownNotToConform(stampType, to)) {
-            return true;
-        }
-        Witness w = typeInfo(scrutinee);
-        boolean witnessAnswer = w != null && !w.cluelessAboutType() && knownNotToConform(w.type(), to);
-        if (witnessAnswer) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * @return true iff the argument is known to stand for an object that definitely does not
-     *         conform to the given type (no matter whether the object turns out to be null or
-     *         non-null).
-     */
-    public boolean knownNotToPassInstanceOf(ValueNode object, ResolvedJavaType to) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        assert !to.isPrimitive();
-        final ValueNode scrutinee = GraphUtil.unproxify(object);
-        if (isNull(scrutinee)) {
-            return true;
-        }
-        ResolvedJavaType stampType = StampTool.typeOrNull(object);
-        if (stampType != null && knownNotToConform(stampType, to)) {
-            // object turns out to be null, positive answer is correct
-            // object turns out non-null, positive answer is also correct
-            return true;
-        }
-        Witness w = typeInfo(scrutinee);
-        boolean witnessAnswer = w != null && !w.cluelessAboutType() && knownNotToConform(w.type(), to);
-        if (witnessAnswer) {
-            // object turns out to be null, positive answer is correct
-            // object turns out non-null, positive answer is also correct
-            return true;
-        }
-        return false;
-    }
-
-    // @formatter:off
-    /**
-     * Determines if the first argument is known not to conform to the second argument.
-     *
-     * <pre>
-     *   \   |     |     |     |
-     *    \ b|     |     |     |
-     *   a \ |     |     |     |
-     *      \|iface|final|non-f|
-     *  -----+-----------------|
-     *  iface|  F  |  F  |  F  |
-     *  -----+-----------------|
-     *  final|  C  |  C  |  C  |
-     *  -----+-----------------|
-     *  non-f|  F  |  C  |  C  |
-     *  -----------------------+
-     *
-     *  where:
-     *    F:     false
-     *    C:     check
-     *    iface: interface
-     *    final: exact non-interface reference-type
-     *    non-f: non-exact non-interface reference-type
-     * </pre>
-     * @return true iff the first argument is known not to conform to the second argument.
-     */
-    // @formatter:on
-    public static boolean knownNotToConform(ResolvedJavaType a, ResolvedJavaType b) {
-        assert !a.isPrimitive();
-        assert !b.isPrimitive();
-        if (b.isAssignableFrom(a)) {
-            return false;
-        }
-        if (a.isInterface()) {
-            return false;
-        }
-        boolean aFinal = Modifier.isFinal(a.getModifiers());
-        if (b.isInterface() && !aFinal) {
-            return false;
-        }
-        if (a.isAssignableFrom(b)) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    @Override
-    public State clone() {
-        return new State(this);
-    }
-
-    /**
-     * Porcelain method.
-     */
-    private Witness getOrElseAddTypeInfo(ValueNode object) {
-        ValueNode scrutinee = GraphUtil.unproxify(object);
-        Witness w = typeRefinements.get(scrutinee);
-        if (w == null) {
-            w = new Witness();
-            typeRefinements.put(scrutinee, w);
-        }
-        return w;
-    }
-
-    /**
-     * <p>
-     * Updates this {@link State State} to account for an observation about the scrutinee being
-     * non-null. In case instanceof was observed,
-     * {@link #trackIO(com.oracle.graal.nodes.ValueNode, com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode)
-     * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead.
-     * </p>
-     *
-     * <p>
-     * No check is made on whether a contradiction would be introduced into the factbase (in which
-     * case the state should be marked unreachable), the caller takes care of that.
-     * </p>
-     *
-     * @return whether state was updated (iff the observation added any new information)
-     */
-    public boolean trackNN(ValueNode object, GuardingNode anchor) {
-        if (isDependencyTainted(object, anchor)) {
-            return false;
-        }
-        assert anchor instanceof FixedNode;
-        ResolvedJavaType stampType = StampTool.typeOrNull(object);
-        if (stampType != null && !stampType.isInterface()) {
-            return trackIO(object, stampType, anchor);
-        }
-        Witness w = getOrElseAddTypeInfo(object);
-        if (w.trackNN(anchor)) {
-            versionNr++;
-            assert repOK();
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Updates this {@link State State} to account for an observation about the scrutinee conforming
-     * to a type. In case instanceof was observed,
-     * {@link #trackIO(com.oracle.graal.nodes.ValueNode, com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode)
-     * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead.
-     *
-     * <p>
-     * No check is made on whether a contradiction would be introduced into the factbase (in which
-     * case the state should be marked unreachable), the caller must take care of that.
-     * </p>
-     *
-     * @return false iff the observed type is an interface, or doesn't provide any new information
-     *         not already known. Ie, this method returns true iff the observation resulted in
-     *         information gain.
-     */
-    public boolean trackCC(ValueNode object, ResolvedJavaType observed, GuardingNode anchor) {
-        if (observed.isInterface()) {
-            return false;
-        }
-        if (isDependencyTainted(object, anchor)) {
-            return false;
-        }
-        assert anchor instanceof FixedNode;
-        Witness w = getOrElseAddTypeInfo(object);
-        if (w.trackCC(observed, anchor)) {
-            versionNr++;
-            metricTypeRegistered.increment();
-            assert repOK();
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Updates this {@link State State} to account for an observation about the non-null scrutinee
-     * conforming to a type.
-     *
-     * <p>
-     * No check is made on whether a contradiction would be introduced into the factbase (in which
-     * case the state should be marked unreachable), the caller must take care of that.
-     * </p>
-     *
-     * @return whether state was updated (iff the observation added any new information)
-     */
-    public boolean trackIO(ValueNode object, ResolvedJavaType observed, GuardingNode anchor) {
-        assert !observed.isInterface() : "no infrastructure yet in State.Witness to support interfaces in general";
-        if (isDependencyTainted(object, anchor)) {
-            return false;
-        }
-        assert anchor instanceof FixedNode;
-        Witness w = getOrElseAddTypeInfo(object);
-        if (w.trackIO(observed, anchor)) {
-            versionNr++;
-            metricTypeRegistered.increment();
-            assert repOK();
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * This method increases {@link #versionNr} (thus potentially invalidating
-     * {@link EquationalReasoner EquationalReasoner}'s caches) only if the fact wasn't known
-     * already.
-     *
-     * <p>
-     * No check is made on whether a contradiction would be introduced into the factbase (in which
-     * case the state should be marked unreachable), the caller must take care of that.
-     * </p>
-     *
-     */
-    private void addFactPrimordial(LogicNode condition, Map<LogicNode, GuardingNode> to, GuardingNode anchor) {
-        assert condition != null;
-        if (!to.containsKey(condition)) {
-            versionNr++;
-            to.put(condition, anchor);
-        }
-    }
-
-    /**
-     * Ideas for the future.
-     * <ul>
-     * <li>track inferred less-than edges from (accumulated) CompareNode-s</li>
-     * <li>track set-representative for equality classes determined by (chained) IntegerTestNode</li>
-     * </ul>
-     *
-     */
-    public void addFact(boolean isTrue, LogicNode condition, GuardingNode anchor) {
-        assert anchor != null;
-        assert anchor instanceof FixedNode;
-        assert !isUnreachable;
-
-        if (condition instanceof LogicConstantNode) {
-            if (((LogicConstantNode) condition).getValue() != isTrue) {
-                impossiblePath();
-            }
-            return;
-        }
-
-        if (condition instanceof LogicNegationNode) {
-            addFact(!isTrue, ((LogicNegationNode) condition).getValue(), anchor);
-        } else if (condition instanceof ShortCircuitOrNode) {
-            /*
-             * We can register the conditions being or-ed as long as the anchor is a fixed node,
-             * because floating guards will be registered at a BeginNode but might be "valid" only
-             * later due to data flow dependencies. Therefore, registering both conditions of a
-             * ShortCircuitOrNode for a floating guard could lead to cycles in data flow, because
-             * the guard will be used as anchor for both conditions, and one condition could be
-             * depending on the other.
-             */
-            if (isTrue) {
-                CastCheckExtractor cce = CastCheckExtractor.extract(condition);
-                if (cce == null || isDependencyTainted(cce.subject, anchor)) {
-                    addFactPrimordial(condition, isTrue ? trueFacts : falseFacts, anchor);
-                } else {
-                    trackCC(cce.subject, cce.type, anchor);
-                }
-            } else {
-                ShortCircuitOrNode disjunction = (ShortCircuitOrNode) condition;
-                addFact(disjunction.isXNegated(), disjunction.getX(), anchor);
-                // previous addFact might have resulted in impossiblePath()
-                if (isUnreachable) {
-                    return;
-                }
-                addFact(disjunction.isYNegated(), disjunction.getY(), anchor);
-            }
-        } else if (condition instanceof InstanceOfNode) {
-            addFactInstanceOf(isTrue, (InstanceOfNode) condition, anchor);
-        } else if (condition instanceof IsNullNode) {
-            IsNullNode nullCheck = (IsNullNode) condition;
-            addNullness(isTrue, nullCheck.getValue(), anchor);
-        } else if (condition instanceof ObjectEqualsNode) {
-            addFactObjectEqualsNode(isTrue, (ObjectEqualsNode) condition, anchor);
-        } else {
-            addFactPrimordial(condition, isTrue ? trueFacts : falseFacts, anchor);
-        }
-        assert repOK();
-    }
-
-    /**
-     * An instanceof hint is tracked differently depending on whether it's an interface-test or not
-     * (because type-refinements currently lacks the ability to track interface types).
-     *
-     */
-    private void addFactInstanceOf(boolean isTrue, InstanceOfNode instanceOf, GuardingNode anchor) {
-        ValueNode object = instanceOf.getValue();
-        if (isTrue) {
-            if (knownNotToPassInstanceOf(object, instanceOf.type())) {
-                impossiblePath();
-                return;
-            }
-            addNullness(false, object, anchor);
-            if (instanceOf.type().isInterface()) {
-                if (!knownToConform(object, instanceOf.type())) {
-                    addFactPrimordial(instanceOf, trueFacts, anchor);
-                }
-            } else {
-                trackIO(object, instanceOf.type(), anchor);
-            }
-        }
-    }
-
-    private void addFactObjectEqualsNode(boolean isTrue, ObjectEqualsNode equals, GuardingNode anchor) {
-        if (isDependencyTainted(equals.getX(), anchor)) {
-            return;
-        }
-        if (isDependencyTainted(equals.getY(), anchor)) {
-            return;
-        }
-        assert anchor instanceof FixedNode;
-        ValueNode x = GraphUtil.unproxify(equals.getX());
-        ValueNode y = GraphUtil.unproxify(equals.getY());
-        if (isTrue) {
-            if (isNull(x) && isNonNull(y)) {
-                impossiblePath();
-                return;
-            }
-            if (isNonNull(x) && isNull(y)) {
-                impossiblePath();
-                return;
-            }
-            if (isNull(x) || isNull(y)) {
-                metricObjectEqualsRegistered.increment();
-                addNullness(true, equals.getX(), anchor);
-                addNullness(true, equals.getY(), anchor);
-            } else if (isNonNull(x) || isNonNull(y)) {
-                metricObjectEqualsRegistered.increment();
-                addNullness(false, equals.getX(), anchor);
-                addNullness(false, equals.getY(), anchor);
-            }
-            Witness wx = typeInfo(x);
-            Witness wy = typeInfo(y);
-            if (wx == null && wy == null) {
-                return;
-            } else if (wx != null && wy != null) {
-                // tighten their type-hints, provided at least one available
-                // both witnesses may have seen == null, ie they may be NN witnesses
-                ResolvedJavaType best = FlowUtil.tighten(wx.type(), wy.type());
-                if (best != null) {
-                    assert !best.isInterface();
-                    // type tightening is enough, nullness already taken care of
-                    trackCC(equals.getX(), best, anchor);
-                    trackCC(equals.getY(), best, anchor);
-                }
-            } else if (wx == null) {
-                typeRefinements.put(x, new Witness(wy));
-            } else if (wy == null) {
-                typeRefinements.put(y, new Witness(wx));
-            }
-        } else {
-            if (isNull(x) && !isNonNull(y)) {
-                metricObjectEqualsRegistered.increment();
-                addNullness(false, equals.getY(), anchor);
-            } else if (!isNonNull(x) && isNull(y)) {
-                metricObjectEqualsRegistered.increment();
-                addNullness(false, equals.getX(), anchor);
-            }
-        }
-    }
-
-    /**
-     * Adds information about the nullness of a value. If isNull is true then the value is known to
-     * be null, otherwise the value is known to be non-null.
-     */
-    public void addNullness(boolean isNull, ValueNode value, GuardingNode anchor) {
-        if (isDependencyTainted(value, anchor)) {
-            return;
-        }
-        assert anchor instanceof FixedNode;
-        ValueNode scrutinee = GraphUtil.unproxify(value);
-        boolean wasNull = isNull(scrutinee);
-        boolean wasNonNull = isNonNull(scrutinee);
-        if (isNull) {
-            if (wasNonNull) {
-                impossiblePath();
-            } else {
-                metricNullnessRegistered.increment();
-                versionNr++;
-                Witness w = getOrElseAddTypeInfo(scrutinee);
-                w.trackDN(anchor);
-            }
-        } else {
-            if (wasNull) {
-                impossiblePath();
-            } else {
-                metricNullnessRegistered.increment();
-                trackNN(scrutinee, anchor);
-            }
-        }
-        assert repOK();
-    }
-
-    /**
-     *
-     * @return true iff `value` may lose dependency not covered by `anchor`.
-     */
-    public static boolean isDependencyTainted(ValueNode value, GuardingNode anchor) {
-        assert anchor instanceof FixedNode;
-        if (value instanceof ValueProxy) {
-            if (value instanceof GuardedNode) {
-                GuardedNode gn = (GuardedNode) value;
-                GuardingNode guardian = gn.getGuard();
-                if (guardian != null) {
-                    boolean isGuardedByFixed = guardian instanceof FixedNode;
-                    if (!isGuardedByFixed) {
-                        return true;
-                    }
-                }
-            }
-            // if (value instanceof GuardingNode) {
-            // return true;
-            // }
-            ValueProxy proxy = (ValueProxy) value;
-            return isDependencyTainted(proxy.getOriginalNode(), anchor);
-        }
-        return false;
-    }
-
-    public void clear() {
-        versionNr = 0;
-        isUnreachable = false;
-        typeRefinements.clear();
-        trueFacts.clear();
-        falseFacts.clear();
-    }
-
-    /**
-     * <p>
-     * If the argument is known null due to its stamp, there's no need to have an anchor for that
-     * fact and this method returns null.
-     * </p>
-     *
-     * <p>
-     * Otherwise, if an anchor is found it is returned, null otherwise.
-     * </p>
-     */
-    public GuardingNode nonTrivialNullAnchor(ValueNode object) {
-        assert FlowUtil.hasLegalObjectStamp(object);
-        if (StampTool.isPointerAlwaysNull(object)) {
-            return null;
-        }
-        ValueNode scrutinee = GraphUtil.unproxify(object);
-        Witness w = typeRefinements.get(scrutinee);
-        if (w != null && w.isNull()) {
-            return w.guard();
-        }
-        return null;
-    }
-
-    /**
-     * This method:
-     * <ul>
-     * <li>
-     * attempts to find an existing {@link com.oracle.graal.nodes.extended.GuardingNode} that
-     * implies the property stated by the arguments. If found, returns it as positive evidence.</li>
-     * <li>
-     * otherwise, if the property of interest is known not to hold, negative evidence is returned.</li>
-     * <li>
-     * otherwise, null is returned.</li>
-     * </ul>
-     */
-    public Evidence outcome(boolean isTrue, LogicNode cond) {
-
-        // attempt to find an anchor for the condition of interest, verbatim
-        if (isTrue) {
-            GuardingNode existingGuard = trueFacts.get(cond);
-            if (existingGuard != null) {
-                return new Evidence(existingGuard);
-            }
-            if (falseFacts.containsKey(cond)) {
-                return Evidence.COUNTEREXAMPLE;
-            }
-        } else {
-            GuardingNode existingGuard = falseFacts.get(cond);
-            if (existingGuard != null) {
-                return new Evidence(existingGuard);
-            }
-            if (trueFacts.containsKey(cond)) {
-                return Evidence.COUNTEREXAMPLE;
-            }
-        }
-
-        if (cond instanceof IsNullNode) {
-            return outcomeIsNullNode(isTrue, (IsNullNode) cond);
-        }
-
-        if (cond instanceof InstanceOfNode) {
-            return outcomeInstanceOfNode(isTrue, (InstanceOfNode) cond);
-        }
-
-        if (cond instanceof ShortCircuitOrNode) {
-            return outcomeShortCircuitOrNode(isTrue, (ShortCircuitOrNode) cond);
-        }
-
-        // can't produce evidence
-        return null;
-    }
-
-    /**
-     * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}.
-     */
-    private Evidence outcomeIsNullNode(boolean isTrue, IsNullNode isNullNode) {
-        if (isTrue) {
-            // grab an anchor attesting nullness
-            final GuardingNode replacement = nonTrivialNullAnchor(isNullNode.getValue());
-            if (replacement != null) {
-                return new Evidence(replacement);
-            }
-            if (isNonNull(isNullNode.getValue())) {
-                return Evidence.COUNTEREXAMPLE;
-            }
-        } else {
-            // grab an anchor attesting non-nullness
-            final Witness w = typeInfo(isNullNode.getValue());
-            if (w != null && w.isNonNull()) {
-                return new Evidence(w.guard());
-            }
-            if (isNull(isNullNode.getValue())) {
-                return Evidence.COUNTEREXAMPLE;
-            }
-        }
-        // can't produce evidence
-        return null;
-    }
-
-    /**
-     * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}.
-     */
-    private Evidence outcomeInstanceOfNode(boolean isTrue, InstanceOfNode iOf) {
-        final Witness w = typeInfo(iOf.getValue());
-        if (isTrue) {
-            if (isNull(iOf.getValue())) {
-                return Evidence.COUNTEREXAMPLE;
-            }
-            // grab an anchor attesting instanceof
-            if ((w != null) && (w.type() != null)) {
-                if (w.isNonNull()) {
-                    if (iOf.type().isAssignableFrom(w.type())) {
-                        return new Evidence(w.guard());
-                    }
-                }
-                if (State.knownNotToConform(w.type(), iOf.type())) {
-                    // null -> fails instanceof
-                    // non-null but non-conformant -> also fails instanceof
-                    return Evidence.COUNTEREXAMPLE;
-                }
-            }
-        } else {
-            // grab an anchor attesting not-instanceof
-            // (1 of 2) attempt determining nullness
-            final GuardingNode nullGuard = nonTrivialNullAnchor(iOf.getValue());
-            if (nullGuard != null) {
-                return new Evidence(nullGuard);
-            }
-            // (2 of 2) attempt determining known-not-to-conform
-            if (w != null && !w.cluelessAboutType()) {
-                if (State.knownNotToConform(w.type(), iOf.type())) {
-                    return new Evidence(w.guard());
-                }
-            }
-        }
-        // can't produce evidence
-        return null;
-    }
-
-    /**
-     * Utility method for {@link #outcome(boolean, com.oracle.graal.nodes.LogicNode)}.
-     */
-    private Evidence outcomeShortCircuitOrNode(boolean isTrue, ShortCircuitOrNode orNode) {
-        if (!isTrue) {
-            // too tricky to reason about
-            return null;
-        }
-        CastCheckExtractor cce = CastCheckExtractor.extract(orNode);
-        if (cce != null) {
-            // grab an anchor attesting check-cast
-            Witness w = typeInfo(cce.subject);
-            if (w != null && w.type() != null) {
-                if (cce.type.isAssignableFrom(w.type())) {
-                    return new Evidence(w.guard());
-                }
-                if (isNonNull(cce.subject) && State.knownNotToConform(w.type(), cce.type)) {
-                    return Evidence.COUNTEREXAMPLE;
-                }
-            }
-        }
-        // search for positive-evidence for the first or-input
-        Evidence evidenceX = outcome(!orNode.isXNegated(), orNode.getX());
-        if (evidenceX != null && evidenceX.isPositive()) {
-            return evidenceX;
-        }
-        // search for positive-evidence for the second or-input
-        Evidence evidenceY = outcome(!orNode.isYNegated(), orNode.getY());
-        if (evidenceY != null && evidenceY.isPositive()) {
-            return evidenceY;
-        }
-        // check for contradictions on both or-inputs
-        if (evidenceX != null && evidenceY != null) {
-            assert evidenceX.isNegative() && evidenceY.isNegative();
-            return Evidence.COUNTEREXAMPLE;
-        }
-        // can't produce evidence
-        return null;
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/Witness.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,526 +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.phases.common.cfs;
-
-import com.oracle.graal.api.meta.ResolvedJavaType;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.GuardingNode;
-import com.oracle.graal.compiler.common.type.ObjectStamp;
-
-/**
- * <p>
- * A witness progressively tracks more detailed properties about an object value (the scrutinee);
- * the properties in question comprise whether the scrutinee has been observed:
- *
- * <ul>
- * <li>as non-null,</li>
- * <li>in a successful checkcast, or</li>
- * <li>in a successful instanceof.</li>
- * </ul>
- * </p>
- *
- * <p>
- * A witness is updated only when doing so increases the information content of the witness. For
- * example, upon visiting a {@link com.oracle.graal.nodes.java.CheckCastNode CheckCastNode} the
- * witness gets a chance to become updated.
- * </p>
- *
- * <p>
- * Therefore, at any given time, a witness represents the most detailed knowledge available so far
- * about the scrutinee, which is the knowledge most relevant for upcoming program-points.
- * </p>
- *
- * <p>
- * The availability of witnesses about both non-nullness and checkcast (for a given scrutinee)
- * promotes to an instanceof-style witness . The "levels" of knowledge a witness may exhibit are
- * captured by {@link com.oracle.graal.phases.common.cfs.Witness.LEVEL}. For conciseness, the
- * following query methods are available for a {@link com.oracle.graal.phases.common.cfs.Witness}:
- * <ul>
- * <li>{@link #atNonNull()}</li>
- * <li>{@link #atCheckCast()}</li>
- * <li>{@link #atInstanceOf()}</li>
- * </ul>
- * </p>
- *
- * <p>
- * Only non-interface object types (ie, class and array types) are tracked. Small extensions are
- * required to track interfaces, extensions that might be added after the current scheme proves
- * itself.
- * </p>
- *
- * <p>
- * Some useful facts about the Statechart implemented by {@link Witness Witness}:
- *
- * <ul>
- * <li>the start-state is "clueless"</li>
- * <li>
- * A self-transition via trackCC from whichever the current state is to itself, without information
- * gain, is always possible. Just give {@link Object java.lang.Object} as observed type.</li>
- * </ul>
- * </p>
- *
- */
-public class Witness implements Cloneable {
-
-    private static enum LEVEL {
-        CLUELESS,
-        NN,
-        CC,
-        IO,
-        DN
-    }
-
-    private boolean atNonNull() {
-        return level == LEVEL.NN;
-    }
-
-    private boolean atCheckCast() {
-        return level == LEVEL.CC;
-    }
-
-    private boolean atInstanceOf() {
-        return level == LEVEL.IO;
-    }
-
-    private boolean atDefinitelyNull() {
-        return level == LEVEL.DN;
-    }
-
-    private void transition(LEVEL to, GuardingNode newAnchor) {
-        this.level = to;
-        this.gn = newAnchor;
-        assert repOK();
-    }
-
-    public Witness() {
-    }
-
-    public Witness(Witness other) {
-        level = other.level;
-        seen = other.seen;
-        gn = other.gn;
-    }
-
-    /**
-     * Counterpart to {@link #asStamp()}.
-     */
-    public Witness(ObjectStamp stamp, GuardingNode anchor) {
-        assert stamp.isLegal();
-        assert anchor != null;
-        if (stamp.alwaysNull()) {
-            // seen left null
-            transition(LEVEL.DN, anchor);
-        } else {
-            boolean isNonIface = (stamp.type() != null && !stamp.type().isInterface());
-            if (stamp.nonNull()) {
-                if (isNonIface) {
-                    seen = stamp.type();
-                    transition(LEVEL.IO, anchor);
-                } else {
-                    seen = null;
-                    transition(LEVEL.NN, anchor);
-                }
-            } else {
-                if (isNonIface) {
-                    seen = stamp.type();
-                    transition(LEVEL.CC, anchor);
-                } else {
-                    seen = null;
-                    transition(LEVEL.CLUELESS, null);
-                    assert clueless();
-                }
-            }
-        }
-        assert repOK();
-    }
-
-    public boolean isNonNull() {
-        return atNonNull() || atInstanceOf();
-    }
-
-    public boolean isNull() {
-        return atDefinitelyNull();
-    }
-
-    /**
-     * The most precise type known so far about the scrutinee. (Please notice that nothing can be
-     * deduced about the non-nullness-status of the scrutinee from invoking this method alone).
-     */
-    public ResolvedJavaType type() {
-        return seen;
-    }
-
-    public ObjectStamp asStamp() {
-        boolean isKnownExact = (seen != null && seen.equals(seen.asExactType()));
-        return new ObjectStamp(seen, isKnownExact, isNonNull(), isNull());
-    }
-
-    private LEVEL level = LEVEL.CLUELESS;
-    private ResolvedJavaType seen = null;
-
-    /**
-     * Evidence (ie, a {@link com.oracle.graal.nodes.extended.GuardingNode}) attesting to the status
-     * reported by this witness.
-     *
-     * May be one of:
-     *
-     * <ul>
-     * <li>
-     * {@link com.oracle.graal.nodes.BeginNode BeginNode},</li>
-     * <li>
-     * {@link com.oracle.graal.nodes.LoopExitNode LoopExitNode},</li>
-     * <li>
-     * {@link com.oracle.graal.nodes.FixedGuardNode FixedGuardNode}</li>
-     * <li>{@link com.oracle.graal.nodes.MergeNode MergeNode}, resulting from merging two witnesses
-     * with different values for this anchor</li>
-     * </ul>
-     *
-     * <p>
-     * An {@link com.oracle.graal.nodes.calc.ObjectEqualsNode ObjectEqualsNode} test results in the
-     * more-clueless of both scrutinees having its witness upgraded to that of the other (both
-     * scrutinees share the same {@link Witness Witness} instance from then on). For this reason,
-     * this field may also hold the anchors associated to an
-     * {@link com.oracle.graal.nodes.calc.ObjectEqualsNode ObjectEqualsNode} occurrence, ie nodes
-     * that can serve as {@link com.oracle.graal.nodes.extended.GuardingNode GuardingNode} for the
-     * purposes of building a {@link com.oracle.graal.nodes.PiNode PiNode}.
-     * </p>
-     *
-     */
-    private GuardingNode gn = null;
-
-    /**
-     * Invariants of this class:
-     * <ul>
-     * <li>All fields holding null is ok, the hallmark of a {@link #clueless() clueless} witness.
-     * Another way for a witness to be clueless is by recording <code>java.lang.Object</code> as the
-     * seen type and nothing more.</li>
-     * <li>{@link #seen seen} may be null as long as the only hint being recorded is non-nullness</li>
-     * <li>A non-null value for {@link #seen seen} can't be tracked with NN, that combination
-     * amounts to IO and is tracked as such</li>
-     * <li>At most one of NN, CC, IO may be tracked at any given time</li>
-     * <li>A non-null CC or a non-null IO force {@link #seen seen} to be non-null</li>
-     * <li>{@link #seen seen} must be null or denote a non-interface reference type (ie, either a
-     * class-type or an array-type)</li>
-     * </ul>
-     */
-    private boolean repOK() {
-        if (clueless()) {
-            assert level == LEVEL.CLUELESS;
-            return true;
-        }
-        if (atNonNull() || atDefinitelyNull()) {
-            assert seen == null;
-        }
-        if (seen != null) {
-            assert !seen.isInterface();
-            assert !seen.isPrimitive();
-        }
-        assert gn instanceof BeginNode || gn instanceof LoopExitNode || gn instanceof MergeNode || gn instanceof FixedGuardNode;
-        return true;
-    }
-
-    /**
-     * Helper method for readability in complex conditions.
-     */
-    public boolean clueless() {
-        return cluelessAboutType() && cluelessAboutNullity();
-    }
-
-    /**
-     * Helper method for readability in complex conditions.
-     */
-    public boolean cluelessAboutType() {
-        // TODO also clueless when `seen` is `java.lang.Object`
-        return seen == null;
-    }
-
-    /**
-     * Helper method for readability in complex conditions.
-     */
-    public boolean cluelessAboutNullity() {
-        return !atNonNull() && !atInstanceOf() && !atDefinitelyNull();
-    }
-
-    /**
-     * Whether this {@link Witness Witness} tracks information strictly more precise than that in
-     * the given {@link com.oracle.graal.compiler.common.type.ObjectStamp}.
-     */
-    boolean knowsBetterThan(ObjectStamp other) {
-        return FlowUtil.isMorePrecise(asStamp(), other);
-    }
-
-    /**
-     * Whether this {@link Witness Witness} tracks information strictly more precise than that in
-     * the {@link com.oracle.graal.compiler.common.type.ObjectStamp} of the given argument.
-     */
-    boolean knowsBetterThan(ValueNode other) {
-        return knowsBetterThan((ObjectStamp) other.stamp());
-    }
-
-    /**
-     * Porcelain method for internal use only, invoked upon a Facade method being notified about
-     * checkcast or instanceof.
-     *
-     * @return whether the state was updated (iff the observation adds any new information)
-     */
-    private boolean refinesSeenType(ResolvedJavaType observed) {
-        if (isNull()) {
-            return false;
-        }
-        if (cluelessAboutType() || FlowUtil.isMorePrecise(observed, seen)) {
-            seen = observed;
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Updates this {@link Witness Witness} to account for an observation about the scrutinee being
-     * non-null. In case instanceof was observed,
-     * {@link #trackIO(com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode)
-     * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead
-     *
-     * @return whether this {@link Witness Witness} was updated (iff the observation adds any new
-     *         information)
-     */
-    public boolean trackNN(GuardingNode anchor) {
-        assert repOK();
-        assert !isNull();
-        try {
-            if (atInstanceOf()) {
-                return false;
-            }
-            if (atCheckCast()) {
-                transition(LEVEL.IO, anchor);
-                return true;
-            }
-            if (!atNonNull()) {
-                transition(LEVEL.NN, anchor);
-                return true;
-            }
-            return false;
-        } finally {
-            assert repOK();
-        }
-    }
-
-    /**
-     * Updates this {@link Witness Witness} to account for an observation about the scrutinee being
-     * null.
-     *
-     * @return whether this {@link Witness Witness} was updated (iff the observation adds any new
-     *         information)
-     */
-    public boolean trackDN(GuardingNode anchor) {
-        assert repOK();
-        assert !isNonNull();
-        try {
-            if (atDefinitelyNull()) {
-                return false;
-            }
-            assert level == LEVEL.CLUELESS || atCheckCast();
-            seen = null;
-            transition(LEVEL.DN, anchor);
-            return true;
-        } finally {
-            assert repOK();
-        }
-    }
-
-    /**
-     * Updates this {@link Witness Witness} to account for an observation about the scrutinee
-     * conforming to the provided type. In case instanceof was observed,
-     * {@link #trackIO(com.oracle.graal.api.meta.ResolvedJavaType, com.oracle.graal.nodes.extended.GuardingNode)
-     * <code>trackIO(ResolvedJavaType, GuardingNode)</code>} should be invoked instead.
-     *
-     * @return true iff information was gained.
-     */
-    public boolean trackCC(ResolvedJavaType observed, GuardingNode anchor) {
-        assert !observed.isInterface();
-        assert anchor != null;
-        assert repOK();
-        try {
-            boolean anchorObsolete = refinesSeenType(observed);
-            if (atInstanceOf()) {
-                /*
-                 * Statechart: self-transition at IO, potential information gain.
-                 */
-                if (anchorObsolete) {
-                    transition(LEVEL.IO, anchor);
-                    return true;
-                }
-                return false;
-            }
-            if (anchorObsolete) {
-                if (!atNonNull()) {
-                    /* Statechart: transition from clueless to CC. */
-                    transition(LEVEL.CC, anchor);
-                    return true;
-                } else {
-                    /* Statechart: transition from NN to IO. */
-                    transition(LEVEL.IO, anchor);
-                    return true;
-                }
-            }
-            /*
-             * Statechart: self-transition from whichever the current state is to itself, without
-             * information gain.
-             */
-            return false;
-        } finally {
-            assert repOK();
-        }
-    }
-
-    /**
-     * Updates this {@link Witness Witness} to account for an observation about the non-null
-     * scrutinee conforming to a type.
-     *
-     * @return whether this {@link Witness Witness} was updated (iff the observation adds any new
-     *         information)
-     */
-    public boolean trackIO(ResolvedJavaType observed, GuardingNode anchor) {
-        assert repOK();
-        assert !isNull();
-        try {
-            boolean gotMorePreciseType = refinesSeenType(observed);
-            if (!atInstanceOf() || gotMorePreciseType) {
-                transition(LEVEL.IO, anchor);
-                return true;
-            }
-            return gotMorePreciseType;
-        } finally {
-            assert repOK();
-        }
-    }
-
-    /**
-     * Shallow cloning is enough because what's reachable from {@link Witness} is primitive or used
-     * read-only when merging states.
-     */
-    @Override
-    public Witness clone() {
-        return new Witness(this);
-    }
-
-    /**
-     * @return null for a clueless method, non-null otherwise.
-     */
-    GuardingNode guard() {
-        return gn;
-    }
-
-    /**
-     * Merges another state into this one, by mutating this object, the other is left as is.
-     */
-    public void merge(Witness that, MergeNode merge) {
-        assert this.repOK();
-        assert that.repOK();
-
-        if (clueless()) {
-            return;
-        }
-
-        // preserve guarding node only if matches other, otherwise settle on `merge`
-        final GuardingNode resultGuard = (guard() == that.guard()) ? guard() : merge;
-
-        if (isNull()) {
-            switch (that.level) {
-                case CLUELESS:
-                case NN:
-                    // lose is-null status, gain nothing
-                    level = LEVEL.CLUELESS;
-                    seen = null;
-                    break;
-                case CC:
-                case IO:
-                    // demote to check-cast
-                    level = LEVEL.CC;
-                    seen = that.seen;
-                    break;
-                case DN:
-                    // keep is-null status
-            }
-            gn = resultGuard;
-            return;
-        }
-
-        if (that.isNull()) {
-            /*
-             * Same decisions as above (based on this-being-null and that-level) are now made based
-             * on (that-being-null and this-level). Because merge is commutative.
-             */
-            switch (level) {
-                case CLUELESS:
-                case NN:
-                    // lose is-null status, gain nothing
-                    level = LEVEL.CLUELESS;
-                    seen = null;
-                    break;
-                case CC:
-                    break;
-                case IO:
-                    // demote to check-cast
-                    level = LEVEL.CC;
-                    // keep this.seen as-is
-                    break;
-                case DN:
-                    // keep is-null status
-            }
-            gn = resultGuard;
-            return;
-        }
-
-        // by now we know neither this nor that are known-to-be-null
-        assert !isNull() && !that.isNull();
-
-        // umbrella type over the observations from both witnesses
-        ResolvedJavaType newSeen = (seen == null || that.seen == null) ? null : FlowUtil.widen(seen, that.seen);
-
-        /*
-         * guarantee on (both conformance and non-nullness) required from each input in order for
-         * the result to be able to offer such guarantee
-         */
-        final boolean resultIO = atInstanceOf() && that.atInstanceOf();
-        /* failing that, attempt to rescue type-conformance */
-        final boolean resultCC = !resultIO && (!cluelessAboutType() && !that.cluelessAboutType());
-        /* if all else fails, attempt to rescue non-nullness */
-        final boolean resultNN = !resultIO && !resultCC && (isNonNull() && that.isNonNull());
-
-        seen = newSeen;
-        level = resultIO ? LEVEL.IO : resultCC ? LEVEL.CC : resultNN ? LEVEL.NN : LEVEL.CLUELESS;
-        gn = resultGuard;
-
-        assert repOK();
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(cluelessAboutType() ? "seen=?" : "seen=" + seen);
-        sb.append(";");
-        sb.append("gn=" + gn);
-        return sb.toString();
-    }
-
-}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Wed Jan 28 19:32:47 2015 +0100
@@ -228,6 +228,9 @@
      *            canonicalized after inlining
      */
     public static Map<Node, Node> inline(Invoke invoke, StructuredGraph inlineGraph, boolean receiverNullCheck, List<Node> canonicalizedNodes) {
+        if (Fingerprint.ENABLED) {
+            Fingerprint.submit("inlining %s into %s: %s", formatGraph(inlineGraph), formatGraph(invoke.asNode().graph()), inlineGraph.getNodes().snapshot());
+        }
         final NodeInputList<ValueNode> parameters = invoke.callTarget().arguments();
         FixedNode invokeNode = invoke.asNode();
         StructuredGraph graph = invokeNode.graph();
@@ -262,7 +265,7 @@
             }
         }
 
-        final BeginNode prevBegin = BeginNode.prevBegin(invokeNode);
+        final AbstractBeginNode prevBegin = AbstractBeginNode.prevBegin(invokeNode);
         DuplicationReplacement localReplacement = new DuplicationReplacement() {
 
             public Node replacement(Node node) {
@@ -300,9 +303,9 @@
             }
 
             // get rid of memory kill
-            BeginNode begin = invokeWithException.next();
+            AbstractBeginNode begin = invokeWithException.next();
             if (begin instanceof KillingBeginNode) {
-                BeginNode newBegin = new BeginNode();
+                AbstractBeginNode newBegin = new BeginNode();
                 graph.addAfterFixed(begin, graph.add(newBegin));
                 begin.replaceAtUsages(newBegin);
                 graph.removeFixed(begin);
@@ -341,7 +344,7 @@
                 for (ReturnNode returnNode : returnNodes) {
                     returnDuplicates.add((ReturnNode) duplicates.get(returnNode));
                 }
-                MergeNode merge = graph.add(new MergeNode());
+                AbstractMergeNode merge = graph.add(new MergeNode());
                 merge.setStateAfter(stateAfter);
                 ValueNode returnValue = mergeReturns(merge, returnDuplicates, canonicalizedNodes);
                 invokeNode.replaceAtUsages(returnValue);
@@ -355,6 +358,13 @@
         return duplicates;
     }
 
+    private static String formatGraph(StructuredGraph graph) {
+        if (graph.method() == null) {
+            return graph.name;
+        }
+        return graph.method().format("%H.%n(%p)");
+    }
+
     private static void processSimpleInfopoints(Invoke invoke, StructuredGraph inlineGraph, Map<Node, Node> duplicates) {
         if (inlineGraph.getNodes(SimpleInfopointNode.class).isEmpty()) {
             return;
@@ -438,8 +448,8 @@
                 } else {
                     StateSplit stateSplit = (StateSplit) usage;
                     FixedNode fixedStateSplit = stateSplit.asNode();
-                    if (fixedStateSplit instanceof MergeNode) {
-                        MergeNode merge = (MergeNode) fixedStateSplit;
+                    if (fixedStateSplit instanceof AbstractMergeNode) {
+                        AbstractMergeNode merge = (AbstractMergeNode) fixedStateSplit;
                         while (merge.isAlive()) {
                             AbstractEndNode end = merge.forwardEnds().first();
                             DeoptimizeNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
@@ -448,7 +458,7 @@
                         }
                     } else {
                         FixedNode deoptimizeNode = graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler));
-                        if (fixedStateSplit instanceof BeginNode) {
+                        if (fixedStateSplit instanceof AbstractBeginNode) {
                             deoptimizeNode = BeginNode.begin(deoptimizeNode);
                         }
                         fixedStateSplit.replaceAtPredecessor(deoptimizeNode);
@@ -459,7 +469,7 @@
         }
     }
 
-    public static ValueNode mergeReturns(MergeNode merge, List<? extends ReturnNode> returnNodes, List<Node> canonicalizedNodes) {
+    public static ValueNode mergeReturns(AbstractMergeNode merge, List<? extends ReturnNode> returnNodes, List<Node> canonicalizedNodes) {
         PhiNode returnValuePhi = null;
 
         for (ReturnNode returnNode : returnNodes) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java	Wed Jan 28 19:32:47 2015 +0100
@@ -173,7 +173,7 @@
 
         ValueNode originalReceiver = ((MethodCallTargetNode) invoke.callTarget()).receiver();
         // setup merge and phi nodes for results and exceptions
-        MergeNode returnMerge = graph.add(new MergeNode());
+        AbstractMergeNode returnMerge = graph.add(new MergeNode());
         returnMerge.setStateAfter(invoke.stateAfter());
 
         PhiNode returnValuePhi = null;
@@ -181,7 +181,7 @@
             returnValuePhi = graph.addWithoutUnique(new ValuePhiNode(invoke.asNode().stamp().unrestricted(), returnMerge));
         }
 
-        MergeNode exceptionMerge = null;
+        AbstractMergeNode exceptionMerge = null;
         PhiNode exceptionObjectPhi = null;
         if (invoke instanceof InvokeWithExceptionNode) {
             InvokeWithExceptionNode invokeWithException = (InvokeWithExceptionNode) invoke;
@@ -196,7 +196,7 @@
         }
 
         // create one separate block for each invoked method
-        BeginNode[] successors = new BeginNode[numberOfMethods + 1];
+        AbstractBeginNode[] successors = new AbstractBeginNode[numberOfMethods + 1];
         for (int i = 0; i < numberOfMethods; i++) {
             successors[i] = createInvocationBlock(graph, invoke, returnMerge, returnValuePhi, exceptionMerge, exceptionObjectPhi, true);
         }
@@ -234,7 +234,7 @@
 
         // prepare the anchors for the invokes
         for (int i = 0; i < numberOfMethods; i++) {
-            BeginNode node = successors[i];
+            AbstractBeginNode node = successors[i];
             Invoke invokeForInlining = (Invoke) node.next();
 
             ResolvedJavaType commonType;
@@ -330,10 +330,10 @@
     private Collection<Node> inlineSingleMethod(StructuredGraph graph, MetaAccessProvider metaAccess, Assumptions assumptions, StampProvider stampProvider) {
         assert concretes.size() == 1 && inlineableElements.length == 1 && ptypes.size() > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0;
 
-        BeginNode calleeEntryNode = graph.add(new BeginNode());
+        AbstractBeginNode calleeEntryNode = graph.add(new BeginNode());
 
-        BeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
-        BeginNode[] successors = new BeginNode[]{calleeEntryNode, unknownTypeSux};
+        AbstractBeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
+        AbstractBeginNode[] successors = new AbstractBeginNode[]{calleeEntryNode, unknownTypeSux};
         createDispatchOnTypeBeforeInvoke(graph, successors, false, metaAccess, stampProvider);
 
         calleeEntryNode.setNext(invoke.asNode());
@@ -341,7 +341,7 @@
         return inline(invoke, methodAt(0), inlineableElementAt(0), assumptions, false);
     }
 
-    private boolean createDispatchOnTypeBeforeInvoke(StructuredGraph graph, BeginNode[] successors, boolean invokeIsOnlySuccessor, MetaAccessProvider metaAccess, StampProvider stampProvider) {
+    private boolean createDispatchOnTypeBeforeInvoke(StructuredGraph graph, AbstractBeginNode[] successors, boolean invokeIsOnlySuccessor, MetaAccessProvider metaAccess, StampProvider stampProvider) {
         assert ptypes.size() >= 1;
         ValueNode nonNullReceiver = InliningUtil.nonNullReceiver(invoke);
         LoadHubNode hub = graph.unique(new LoadHubNode(stampProvider, nonNullReceiver));
@@ -459,10 +459,10 @@
         return costEstimateMethodDispatch < costEstimateTypeDispatch;
     }
 
-    private static BeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, MergeNode returnMerge, PhiNode returnValuePhi, MergeNode exceptionMerge, PhiNode exceptionObjectPhi,
-                    boolean useForInlining) {
+    private static AbstractBeginNode createInvocationBlock(StructuredGraph graph, Invoke invoke, AbstractMergeNode returnMerge, PhiNode returnValuePhi, AbstractMergeNode exceptionMerge,
+                    PhiNode exceptionObjectPhi, boolean useForInlining) {
         Invoke duplicatedInvoke = duplicateInvokeForInlining(graph, invoke, exceptionMerge, exceptionObjectPhi, useForInlining);
-        BeginNode calleeEntryNode = graph.add(new BeginNode());
+        AbstractBeginNode calleeEntryNode = graph.add(new BeginNode());
         calleeEntryNode.setNext(duplicatedInvoke.asNode());
 
         AbstractEndNode endNode = graph.add(new EndNode());
@@ -475,7 +475,7 @@
         return calleeEntryNode;
     }
 
-    private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, MergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) {
+    private static Invoke duplicateInvokeForInlining(StructuredGraph graph, Invoke invoke, AbstractMergeNode exceptionMerge, PhiNode exceptionObjectPhi, boolean useForInlining) {
         Invoke result = (Invoke) invoke.asNode().copyWithInputs();
         Node callTarget = result.callTarget().copyWithInputs();
         result.asNode().replaceFirstInput(result.callTarget(), callTarget);
@@ -538,9 +538,9 @@
     }
 
     private void devirtualizeWithTypeSwitch(StructuredGraph graph, InvokeKind kind, ResolvedJavaMethod target, MetaAccessProvider metaAccess, StampProvider stampProvider) {
-        BeginNode invocationEntry = graph.add(new BeginNode());
-        BeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
-        BeginNode[] successors = new BeginNode[]{invocationEntry, unknownTypeSux};
+        AbstractBeginNode invocationEntry = graph.add(new BeginNode());
+        AbstractBeginNode unknownTypeSux = createUnknownTypeSuccessor(graph);
+        AbstractBeginNode[] successors = new AbstractBeginNode[]{invocationEntry, unknownTypeSux};
         createDispatchOnTypeBeforeInvoke(graph, successors, true, metaAccess, stampProvider);
 
         invocationEntry.setNext(invoke.asNode());
@@ -550,7 +550,7 @@
         InliningUtil.replaceInvokeCallTarget(invoke, graph, kind, target);
     }
 
-    private static BeginNode createUnknownTypeSuccessor(StructuredGraph graph) {
+    private static AbstractBeginNode createUnknownTypeSuccessor(StructuredGraph graph) {
         return BeginNode.begin(graph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TypeCheckedInliningViolated)));
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/elem/InlineableGraph.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
 import com.oracle.graal.phases.common.inlining.*;
 import com.oracle.graal.phases.graph.*;
 import com.oracle.graal.phases.tiers.*;
@@ -90,7 +89,6 @@
         try (Debug.Scope s = Debug.scope("InlineGraph", graph)) {
 
             ArrayList<Node> parameterUsages = replaceParamsWithMoreInformativeArguments(invoke, context);
-            parameterUsages = rewireParamsForDuplicateArguments(invoke, parameterUsages);
             if (parameterUsages != null && OptCanonicalizer.getValue()) {
                 assert !parameterUsages.isEmpty() : "The caller didn't have more information about arguments after all";
                 canonicalizer.applyIncremental(graph, context, parameterUsages);
@@ -107,48 +105,6 @@
         }
     }
 
-    /**
-     * This method detects duplicate arguments (therefore corresponding to different
-     * {@link ParameterNode}s) and updates the graph to make all of their usages refer to the first
-     * one of them.
-     *
-     * @return a (possibly updated) list of nodes for incremental canonicalization.
-     */
-    private ArrayList<Node> rewireParamsForDuplicateArguments(Invoke invoke, ArrayList<Node> parameterUsages0) {
-        ArrayList<Node> parameterUsages = parameterUsages0;
-        ArrayList<ParameterNode> params = new ArrayList<>();
-        List<ValueNode> originalArgs = invoke.callTarget().arguments();
-        List<ValueNode> argsInEffect = new ArrayList<>();
-        // some param-nodes might have been deleted by replaceParamsWithMoreInformativeArguments()
-        // that's why we obtain an up-to-date list
-        for (ParameterNode p : graph.getNodes(ParameterNode.class)) {
-            if (!FlowUtil.lacksUsages(p)) {
-                params.add(p);
-                argsInEffect.add(originalArgs.get(p.index()));
-            }
-        }
-        // argsInEffect and params paired by position
-        assert params.size() == argsInEffect.size();
-        int argIdx = 0;
-        for (ValueNode arg : argsInEffect) {
-            int firstOccurrrence = argsInEffect.indexOf(arg);
-            assert firstOccurrrence >= 0;
-            if (firstOccurrrence < argIdx) {
-                ParameterNode survivingParam = params.get(firstOccurrrence);
-                assert survivingParam.isAlive();
-                ParameterNode duplicateParam = params.get(argIdx);
-                assert duplicateParam.isAlive();
-                assert survivingParam != duplicateParam;
-                assert !isArgMoreInformativeThanParam(arg, survivingParam);
-                parameterUsages = trackParameterUsages(duplicateParam, parameterUsages);
-                // replaceFloating() deletes the duplicate param, unlike replaceAtUsages()
-                graph.replaceFloating(duplicateParam, survivingParam);
-            }
-            argIdx++;
-        }
-        return parameterUsages;
-    }
-
     private static boolean isArgMoreInformativeThanParam(ValueNode arg, ParameterNode param) {
         return arg.isConstant() || canStampBeImproved(arg, param);
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineEverythingPolicy.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineEverythingPolicy.java	Wed Jan 28 19:32:47 2015 +0100
@@ -29,7 +29,7 @@
 
 import static com.oracle.graal.compiler.common.GraalOptions.MaximumDesiredSize;
 
-public final class InlineEverythingPolicy implements InliningPolicy {
+public class InlineEverythingPolicy implements InliningPolicy {
 
     public boolean continueInlining(StructuredGraph graph) {
         if (graph.getNodeCount() >= MaximumDesiredSize.getValue()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineMethodSubstitutionsPolicy.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, 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.phases.common.inlining.policy;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.java.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.common.inlining.walker.*;
+
+/**
+ * Inline every method which would be replaced by a substitution. Useful for testing purposes.
+ */
+public final class InlineMethodSubstitutionsPolicy extends InlineEverythingPolicy {
+
+    @Override
+    public boolean isWorthInlining(Replacements replacements, MethodInvocation invocation, int inliningDepth, boolean fullyProcessed) {
+        CallTargetNode callTarget = invocation.callee().invoke().callTarget();
+        if (callTarget instanceof MethodCallTargetNode) {
+            ResolvedJavaMethod calleeMethod = ((MethodCallTargetNode) callTarget).targetMethod();
+            if (replacements.getMethodSubstitution(calleeMethod) != null) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/ComputeInliningRelevance.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/ComputeInliningRelevance.java	Wed Jan 28 19:32:47 2015 +0100
@@ -114,9 +114,9 @@
                         parent = loops.get(null);
                         break;
                     } else {
-                        assert current.getClass() == MergeNode.class : current;
+                        assert current instanceof MergeNode : current;
                         // follow any path upwards - it doesn't matter which one
-                        current = ((MergeNode) current).forwardEndAt(0);
+                        current = ((AbstractMergeNode) current).forwardEndAt(0);
                     }
                 } else if (current instanceof LoopExitNode) {
                     // if we reach a loop exit then we follow this loop and have the same parent
@@ -278,7 +278,7 @@
         int pathBeginCount = pathBeginNodes.size();
 
         for (Node sux : controlSplit.successors()) {
-            double probability = controlSplit.probability((BeginNode) sux);
+            double probability = controlSplit.probability((AbstractBeginNode) sux);
             if (probability > maxProbability) {
                 maxProbability = probability;
                 maxSux = sux;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningData.java	Wed Jan 28 19:32:47 2015 +0100
@@ -118,7 +118,7 @@
             return "it is an abstract method";
         } else if (!method.getDeclaringClass().isInitialized()) {
             return "the method's class is not initialized";
-        } else if (!method.canBeInlined()) {
+        } else if (!method.canBeInlined() && !context.getReplacements().isForcedSubstitution(method)) {
             return "it is marked non-inlinable";
         } else if (countRecursiveInlining(method) > MaximumRecursiveInlining.getValue()) {
             return "it exceeds the maximum recursive inlining depth";
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/walker/InliningIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -67,7 +67,7 @@
                 queueSuccessors(current);
             } else if (current instanceof LoopEndNode) {
                 // nothing to do
-            } else if (current instanceof MergeNode) {
+            } else if (current instanceof AbstractMergeNode) {
                 queueSuccessors(current);
             } else if (current instanceof FixedWithNextNode) {
                 queueSuccessors(current);
@@ -114,14 +114,14 @@
     }
 
     private void queueMerge(AbstractEndNode end) {
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         if (!queuedNodes.isMarked(merge) && visitedAllEnds(merge)) {
             queuedNodes.mark(merge);
             nodeQueue.add(merge);
         }
     }
 
-    private boolean visitedAllEnds(MergeNode merge) {
+    private boolean visitedAllEnds(AbstractMergeNode merge) {
         for (int i = 0; i < merge.forwardEndCount(); i++) {
             if (!queuedNodes.isMarked(merge.forwardEndAt(i))) {
                 return false;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -106,6 +106,10 @@
             if (dumpGraph && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) {
                 Debug.dump(PHASE_DUMP_LEVEL, graph, "After phase %s", getName());
             }
+            if (Fingerprint.ENABLED) {
+                String graphDesc = graph.method() == null ? graph.name : graph.method().format("%H.%n(%p)");
+                Fingerprint.submit("After phase %s nodes in %s are %s", getName(), graphDesc, graph.getNodes().snapshot());
+            }
             if (Debug.isVerifyEnabled()) {
                 Debug.verify(graph, "After phase %s", getName());
             }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,7 +30,7 @@
 import com.oracle.graal.nodes.*;
 
 /**
- * Compute probabilities for fixed nodes on the fly and cache them at {@link BeginNode}s.
+ * Compute probabilities for fixed nodes on the fly and cache them at {@link AbstractBeginNode}s.
  */
 public class FixedNodeProbabilityCache implements ToDoubleFunction<FixedNode> {
 
@@ -40,8 +40,8 @@
 
     /**
      * <p>
-     * Given a {@link FixedNode} this method finds the most immediate {@link BeginNode} preceding it
-     * that either:
+     * Given a {@link FixedNode} this method finds the most immediate {@link AbstractBeginNode}
+     * preceding it that either:
      * <ul>
      * <li>has no predecessor (ie, the begin-node is a merge, in particular a loop-begin, or the
      * start-node)</li>
@@ -50,8 +50,8 @@
      * </p>
      *
      * <p>
-     * The thus found {@link BeginNode} is equi-probable with the {@link FixedNode} it was obtained
-     * from. When computed for the first time (afterwards a cache lookup returns it) that
+     * The thus found {@link AbstractBeginNode} is equi-probable with the {@link FixedNode} it was
+     * obtained from. When computed for the first time (afterwards a cache lookup returns it) that
      * probability is computed as follows, again depending on the begin-node's predecessor:
      * <ul>
      * <li>No predecessor. In this case the begin-node is either:</li>
@@ -77,7 +77,7 @@
         while (true) {
             assert current != null;
             Node predecessor = current.predecessor();
-            if (current instanceof BeginNode) {
+            if (current instanceof AbstractBeginNode) {
                 if (predecessor == null) {
                     break;
                 } else if (predecessor.successors().count() != 1) {
@@ -91,7 +91,7 @@
             current = (FixedNode) predecessor;
         }
 
-        assert current instanceof BeginNode;
+        assert current instanceof AbstractBeginNode;
         Double cachedValue = cache.get(current);
         if (cachedValue != null) {
             return cachedValue;
@@ -99,8 +99,8 @@
 
         double probability = 0.0;
         if (current.predecessor() == null) {
-            if (current instanceof MergeNode) {
-                MergeNode currentMerge = (MergeNode) current;
+            if (current instanceof AbstractMergeNode) {
+                AbstractMergeNode currentMerge = (AbstractMergeNode) current;
                 NodeInputList<AbstractEndNode> currentForwardEnds = currentMerge.forwardEnds();
                 /*
                  * Use simple iteration instead of streams, since the stream infrastructure adds
@@ -119,7 +119,7 @@
             }
         } else {
             ControlSplitNode split = (ControlSplitNode) current.predecessor();
-            probability = split.probability((BeginNode) current) * applyAsDouble(split);
+            probability = split.probability((AbstractBeginNode) current) * applyAsDouble(split);
         }
         assert !Double.isNaN(probability) && !Double.isInfinite(probability) : current + " " + probability;
         cache.put(current, probability);
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/MergeableState.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/MergeableState.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,7 @@
      * @param merge the merge node
      * @param withStates the state at the the merge's end node except the first one.
      */
-    public abstract boolean merge(MergeNode merge, List<T> withStates);
+    public abstract boolean merge(AbstractMergeNode merge, List<T> withStates);
 
     /**
      * This method is called before a loop is entered (before the {@link LoopBeginNode} is visited).
@@ -65,7 +65,7 @@
      *
      * @param node the successor of the control split that is about to be visited
      */
-    public void afterSplit(BeginNode node) {
+    public void afterSplit(AbstractBeginNode node) {
         // empty default implementation
     }
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/PostOrderNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
  * specified fixed node.
  * <p>
  * For this iterator the CFG is defined by the classical CFG nodes ({@link ControlSplitNode},
- * {@link MergeNode}...) and the {@link FixedWithNextNode#next() next} pointers of
+ * {@link AbstractMergeNode}...) and the {@link FixedWithNextNode#next() next} pointers of
  * {@link FixedWithNextNode}.
  * <p>
  * While iterating it maintains a user-defined state by calling the methods available in
@@ -43,7 +43,7 @@
 public abstract class PostOrderNodeIterator<T extends MergeableState<T>> {
 
     private final NodeBitMap visitedEnds;
-    private final Deque<BeginNode> nodeQueue;
+    private final Deque<AbstractBeginNode> nodeQueue;
     private final Map<FixedNode, T> nodeStates;
     private final FixedNode start;
 
@@ -77,9 +77,9 @@
                 loopEnd((LoopEndNode) current);
                 finishLoopEnds((LoopEndNode) current);
                 current = nextQueuedNode();
-            } else if (current instanceof MergeNode) {
-                merge((MergeNode) current);
-                current = ((MergeNode) current).next();
+            } else if (current instanceof AbstractMergeNode) {
+                merge((AbstractMergeNode) current);
+                current = ((AbstractMergeNode) current).next();
                 assert current != null;
             } else if (current instanceof FixedWithNextNode) {
                 FixedNode next = ((FixedWithNextNode) current).next();
@@ -110,13 +110,13 @@
             for (Node node : successors) {
                 if (node != null) {
                     nodeStates.put((FixedNode) node.predecessor(), state);
-                    nodeQueue.addFirst((BeginNode) node);
+                    nodeQueue.addFirst((AbstractBeginNode) node);
                 }
             }
         } else {
             for (Node node : x.successors()) {
                 if (node != null) {
-                    nodeQueue.addFirst((BeginNode) node);
+                    nodeQueue.addFirst((AbstractBeginNode) node);
                 }
             }
         }
@@ -125,9 +125,9 @@
     private FixedNode nextQueuedNode() {
         int maxIterations = nodeQueue.size();
         while (maxIterations-- > 0) {
-            BeginNode node = nodeQueue.removeFirst();
-            if (node instanceof MergeNode) {
-                MergeNode merge = (MergeNode) node;
+            AbstractBeginNode node = nodeQueue.removeFirst();
+            if (node instanceof AbstractMergeNode) {
+                AbstractMergeNode merge = (AbstractMergeNode) node;
                 state = nodeStates.get(merge.forwardEndAt(0)).clone();
                 ArrayList<T> states = new ArrayList<>(merge.forwardEndCount() - 1);
                 for (int i = 1; i < merge.forwardEndCount(); i++) {
@@ -181,7 +181,7 @@
         assert !nodeStates.containsKey(end);
         nodeStates.put(end, state);
         visitedEnds.mark(end);
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         boolean endsVisited = true;
         for (int i = 0; i < merge.forwardEndCount(); i++) {
             if (!visitedEnds.isMarked(merge.forwardEndAt(i))) {
@@ -200,7 +200,7 @@
         node(endNode);
     }
 
-    protected void merge(MergeNode merge) {
+    protected void merge(AbstractMergeNode merge) {
         node(merge);
     }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantBlockIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -23,8 +23,8 @@
 package com.oracle.graal.phases.graph;
 
 import java.util.*;
+import java.util.function.*;
 
-import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.cfg.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
@@ -61,7 +61,7 @@
     }
 
     public static <StateT> LoopInfo<StateT> processLoop(BlockIteratorClosure<StateT> closure, Loop<Block> loop, StateT initialState) {
-        Map<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, CollectionsFactory.newSet(loop.getBlocks()));
+        Map<FixedNode, StateT> blockEndStates = apply(closure, loop.getHeader(), initialState, block -> !(block.getLoop() == loop || block.isLoopHeader()));
 
         List<Block> predecessors = loop.getHeader().getPredecessors();
         LoopInfo<StateT> info = new LoopInfo<>(predecessors.size() - 1, loop.getExits().size());
@@ -84,7 +84,7 @@
         apply(closure, start, closure.getInitialState(), null);
     }
 
-    public static <StateT> Map<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Set<Block> boundary) {
+    public static <StateT> Map<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Predicate<Block> stopAtBlock) {
         Deque<Block> blockQueue = new ArrayDeque<>();
         /*
          * States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes.
@@ -95,81 +95,50 @@
         Block current = start;
 
         while (true) {
-            if (boundary != null && !boundary.contains(current)) {
+            Block next = null;
+            if (stopAtBlock != null && stopAtBlock.test(current)) {
                 states.put(current.getBeginNode(), state);
             } else {
                 state = closure.processBlock(current, state);
 
-                if (current.getSuccessors().isEmpty()) {
+                List<Block> successors = current.getSuccessors();
+                if (successors.isEmpty()) {
                     // nothing to do...
-                } else if (current.getSuccessors().size() == 1) {
-                    Block successor = current.getSuccessors().get(0);
+                } else if (successors.size() == 1) {
+                    Block successor = successors.get(0);
                     if (successor.isLoopHeader()) {
                         if (current.isLoopEnd()) {
                             // nothing to do... loop ends only lead to loop begins we've already
                             // visited
                             states.put(current.getEndNode(), state);
                         } else {
-                            // recurse into the loop
-                            Loop<Block> loop = successor.getLoop();
-                            LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
-                            assert successor.getBeginNode() == loopBegin;
-
-                            List<StateT> exitStates = closure.processLoop(loop, state);
-
-                            int i = 0;
-                            assert loop.getExits().size() == exitStates.size();
-                            for (Block exit : loop.getExits()) {
-                                states.put(exit.getBeginNode(), exitStates.get(i++));
-                                blockQueue.addFirst(exit);
-                            }
+                            recurseIntoLoop(closure, blockQueue, states, state, successor);
                         }
                     } else if (current.getEndNode() instanceof AbstractEndNode) {
-                        assert successor.getPredecessors().size() > 1 : "invalid block schedule at " + successor.getBeginNode();
                         AbstractEndNode end = (AbstractEndNode) current.getEndNode();
 
                         // add the end node and see if the merge is ready for processing
-                        MergeNode merge = end.merge();
-                        boolean endsVisited = true;
-                        for (AbstractEndNode forwardEnd : merge.forwardEnds()) {
-                            if (forwardEnd != current.getEndNode() && !states.containsKey(forwardEnd)) {
-                                endsVisited = false;
-                                break;
-                            }
-                        }
-                        if (endsVisited) {
-                            ArrayList<StateT> mergedStates = new ArrayList<>(merge.forwardEndCount());
-                            for (Block predecessor : successor.getPredecessors()) {
-                                assert predecessor == current || states.containsKey(predecessor.getEndNode());
-                                StateT endState = predecessor == current ? state : states.remove(predecessor.getEndNode());
-                                mergedStates.add(endState);
-                            }
+                        AbstractMergeNode merge = end.merge();
+                        if (allEndsVisited(states, current, merge)) {
+                            ArrayList<StateT> mergedStates = mergeStates(states, state, current, successor, merge);
                             state = closure.merge(successor, mergedStates);
-                            current = successor;
-                            continue;
+                            next = successor;
                         } else {
                             assert !states.containsKey(end);
                             states.put(end, state);
                         }
                     } else {
-                        assert successor.getPredecessors().size() == 1 : "invalid block schedule at " + successor.getBeginNode();
-                        current = successor;
-                        continue;
+                        next = successor;
                     }
                 } else {
-                    assert current.getSuccessors().size() > 1;
-                    for (int i = 1; i < current.getSuccessors().size(); i++) {
-                        Block successor = current.getSuccessors().get(i);
-                        blockQueue.addFirst(successor);
-                        states.put(successor.getBeginNode(), closure.cloneState(state));
-                    }
-                    current = current.getSuccessors().get(0);
-                    continue;
+                    next = processMultipleSuccessors(closure, blockQueue, states, state, successors);
                 }
             }
 
             // get next queued block
-            if (blockQueue.isEmpty()) {
+            if (next != null) {
+                current = next;
+            } else if (blockQueue.isEmpty()) {
                 return states;
             } else {
                 current = blockQueue.removeFirst();
@@ -179,4 +148,49 @@
             }
         }
     }
+
+    private static <StateT> boolean allEndsVisited(Map<FixedNode, StateT> states, Block current, AbstractMergeNode merge) {
+        for (AbstractEndNode forwardEnd : merge.forwardEnds()) {
+            if (forwardEnd != current.getEndNode() && !states.containsKey(forwardEnd)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static <StateT> Block processMultipleSuccessors(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, Map<FixedNode, StateT> states, StateT state, List<Block> successors) {
+        assert successors.size() > 1;
+        for (int i = 1; i < successors.size(); i++) {
+            Block successor = successors.get(i);
+            blockQueue.addFirst(successor);
+            states.put(successor.getBeginNode(), closure.cloneState(state));
+        }
+        return successors.get(0);
+    }
+
+    private static <StateT> ArrayList<StateT> mergeStates(Map<FixedNode, StateT> states, StateT state, Block current, Block successor, AbstractMergeNode merge) {
+        ArrayList<StateT> mergedStates = new ArrayList<>(merge.forwardEndCount());
+        for (Block predecessor : successor.getPredecessors()) {
+            assert predecessor == current || states.containsKey(predecessor.getEndNode());
+            StateT endState = predecessor == current ? state : states.remove(predecessor.getEndNode());
+            mergedStates.add(endState);
+        }
+        return mergedStates;
+    }
+
+    private static <StateT> void recurseIntoLoop(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, Map<FixedNode, StateT> states, StateT state, Block successor) {
+        // recurse into the loop
+        Loop<Block> loop = successor.getLoop();
+        LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
+        assert successor.getBeginNode() == loopBegin;
+
+        List<StateT> exitStates = closure.processLoop(loop, state);
+
+        int i = 0;
+        assert loop.getExits().size() == exitStates.size();
+        for (Block exit : loop.getExits()) {
+            states.put(exit.getBeginNode(), exitStates.get(i++));
+            blockQueue.addFirst(exit);
+        }
+    }
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -44,9 +44,9 @@
 
         protected abstract StateT processNode(FixedNode node, StateT currentState);
 
-        protected abstract StateT merge(MergeNode merge, List<StateT> states);
+        protected abstract StateT merge(AbstractMergeNode merge, List<StateT> states);
 
-        protected abstract StateT afterSplit(BeginNode node, StateT oldState);
+        protected abstract StateT afterSplit(AbstractBeginNode node, StateT oldState);
 
         protected abstract Map<LoopExitNode, StateT> processLoop(LoopBeginNode loop, StateT initialState);
 
@@ -87,7 +87,7 @@
 
     private static <StateT> Map<FixedNode, StateT> apply(NodeIteratorClosure<StateT> closure, FixedNode start, StateT initialState, LoopBeginNode boundary) {
         assert start != null;
-        Deque<BeginNode> nodeQueue = new ArrayDeque<>();
+        Deque<AbstractBeginNode> nodeQueue = new ArrayDeque<>();
         Map<FixedNode, StateT> blockEndStates = Node.newIdentityMap();
 
         StateT state = initialState;
@@ -114,7 +114,7 @@
                             blockEndStates.put(current, state);
                         } else if (current instanceof EndNode) {
                             // add the end node and see if the merge is ready for processing
-                            MergeNode merge = ((EndNode) current).merge();
+                            AbstractMergeNode merge = ((EndNode) current).merge();
                             if (merge instanceof LoopBeginNode) {
                                 Map<LoopExitNode, StateT> loopExitState = closure.processLoop((LoopBeginNode) merge, state);
                                 for (Map.Entry<LoopExitNode, StateT> entry : loopExitState.entrySet()) {
@@ -153,7 +153,7 @@
                             continue;
                         } else {
                             do {
-                                BeginNode successor = (BeginNode) successors.next();
+                                AbstractBeginNode successor = (AbstractBeginNode) successors.next();
                                 StateT successorState = closure.afterSplit(successor, state);
                                 if (closure.continueIteration(successorState)) {
                                     blockEndStates.put(successor, successorState);
@@ -161,7 +161,7 @@
                                 }
                             } while (successors.hasNext());
 
-                            state = closure.afterSplit((BeginNode) firstSuccessor, state);
+                            state = closure.afterSplit((AbstractBeginNode) firstSuccessor, state);
                             current = closure.continueIteration(state) ? firstSuccessor : null;
                             continue;
                         }
@@ -176,7 +176,7 @@
                 current = nodeQueue.removeFirst();
                 assert blockEndStates.containsKey(current);
                 state = blockEndStates.remove(current);
-                assert !(current instanceof MergeNode) && current instanceof BeginNode;
+                assert !(current instanceof AbstractMergeNode) && current instanceof AbstractBeginNode;
             }
         } while (true);
     }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ScheduledNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ScheduledNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -40,7 +40,7 @@
 
     private FixedWithNextNode lastFixed;
     private FixedWithNextNode reconnect;
-    private ListIterator<ScheduledNode> iterator;
+    private ListIterator<ValueNode> iterator;
 
     public void processNodes(Block block, SchedulePhase shedule) {
         lastFixed = block.getBeginNode();
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ScopedPostOrderNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ScopedPostOrderNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -67,7 +67,7 @@
                 queueLoopExitSuccessors((LoopExitNode) current);
             } else if (current instanceof LoopEndNode) {
                 // nothing todo
-            } else if (current instanceof MergeNode) {
+            } else if (current instanceof AbstractMergeNode) {
                 queueSuccessors(current);
             } else if (current instanceof FixedWithNextNode) {
                 queueSuccessors(current);
@@ -142,13 +142,13 @@
     }
 
     private void queueMerge(AbstractEndNode end) {
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         if (!queuedNodes.isMarked(merge) && visitedAllEnds(merge)) {
             queue(merge);
         }
     }
 
-    private boolean visitedAllEnds(MergeNode merge) {
+    private boolean visitedAllEnds(AbstractMergeNode merge) {
         for (int i = 0; i < merge.forwardEndCount(); i++) {
             if (!queuedNodes.isMarked(merge.forwardEndAt(i))) {
                 return false;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/SinglePassNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,17 +32,17 @@
  * start node. Unlike in iterative dataflow analysis, a single pass is performed, which allows
  * keeping a smaller working set of pending {@link MergeableState}. This iteration scheme requires:
  * <ul>
- * <li>{@link MergeableState#merge(MergeNode, List)} to always return <code>true</code> (an
+ * <li>{@link MergeableState#merge(AbstractMergeNode, List)} to always return <code>true</code> (an
  * assertion checks this)</li>
  * <li>{@link #controlSplit(ControlSplitNode)} to always return all successors (otherwise, not all
  * associated {@link EndNode} will be visited. In turn, visiting all the end nodes for a given
- * {@link MergeNode} is a precondition before that merge node can be visited)</li>
+ * {@link AbstractMergeNode} is a precondition before that merge node can be visited)</li>
  * </ul>
  *
  * <p>
  * For this iterator the CFG is defined by the classical CFG nodes (
- * {@link com.oracle.graal.nodes.ControlSplitNode}, {@link com.oracle.graal.nodes.MergeNode}...) and
- * the {@link com.oracle.graal.nodes.FixedWithNextNode#next() next} pointers of
+ * {@link com.oracle.graal.nodes.ControlSplitNode}, {@link com.oracle.graal.nodes.AbstractMergeNode}
+ * ...) and the {@link com.oracle.graal.nodes.FixedWithNextNode#next() next} pointers of
  * {@link com.oracle.graal.nodes.FixedWithNextNode}.
  * </p>
  *
@@ -101,18 +101,18 @@
      * <p>
      * Correspondingly each item may stand for:
      * <ul>
-     * <li>a {@link MergeNode} whose pre-state results from merging those of its forward-ends, see
-     * {@link #nextQueuedNode()}</li>
+     * <li>a {@link AbstractMergeNode} whose pre-state results from merging those of its
+     * forward-ends, see {@link #nextQueuedNode()}</li>
      * <li>a successor of a control-split node, in which case the state on entry to it (the
      * successor) is also stored in the item, see {@link #nextQueuedNode()}</li>
      * </ul>
      * </p>
      */
     private static final class PathStart<U> {
-        private final BeginNode node;
+        private final AbstractBeginNode node;
         private final U stateOnEntry;
 
-        private PathStart(BeginNode node, U stateOnEntry) {
+        private PathStart(AbstractBeginNode node, U stateOnEntry) {
             this.node = node;
             this.stateOnEntry = stateOnEntry;
             assert repOK();
@@ -125,7 +125,7 @@
             if (node == null) {
                 return false;
             }
-            if (node instanceof MergeNode) {
+            if (node instanceof AbstractMergeNode) {
                 return stateOnEntry == null;
             }
             return (stateOnEntry != null);
@@ -169,9 +169,9 @@
                 loopEnd((LoopEndNode) current);
                 finishLoopEnds((LoopEndNode) current);
                 current = nextQueuedNode();
-            } else if (current instanceof MergeNode) {
-                merge((MergeNode) current);
-                current = ((MergeNode) current).next();
+            } else if (current instanceof AbstractMergeNode) {
+                merge((AbstractMergeNode) current);
+                current = ((AbstractMergeNode) current).next();
                 assert current != null;
             } else if (current instanceof FixedWithNextNode) {
                 FixedNode next = ((FixedWithNextNode) current).next();
@@ -210,13 +210,13 @@
     private void queueSuccessors(FixedNode x) {
         Iterator<Node> iter = x.successors().nonNull().iterator();
         if (iter.hasNext()) {
-            BeginNode begin = (BeginNode) iter.next();
+            AbstractBeginNode begin = (AbstractBeginNode) iter.next();
             // the current state isn't cloned for the first successor
             // conceptually, the state is handed over to it
             nodeQueue.addFirst(new PathStart<>(begin, state));
         }
         while (iter.hasNext()) {
-            BeginNode begin = (BeginNode) iter.next();
+            AbstractBeginNode begin = (AbstractBeginNode) iter.next();
             // for all other successors it is cloned
             nodeQueue.addFirst(new PathStart<>(begin, state.clone()));
         }
@@ -228,8 +228,8 @@
      * the pre-state for that node.
      *
      * <p>
-     * Upon reaching a {@link MergeNode}, some entries are pruned from {@link #nodeStates} (ie, the
-     * entries associated to forward-ends for that merge-node).
+     * Upon reaching a {@link AbstractMergeNode}, some entries are pruned from {@link #nodeStates}
+     * (ie, the entries associated to forward-ends for that merge-node).
      * </p>
      */
     private FixedNode nextQueuedNode() {
@@ -237,8 +237,8 @@
             return null;
         }
         PathStart<T> elem = nodeQueue.removeFirst();
-        if (elem.node instanceof MergeNode) {
-            MergeNode merge = (MergeNode) elem.node;
+        if (elem.node instanceof AbstractMergeNode) {
+            AbstractMergeNode merge = (AbstractMergeNode) elem.node;
             state = pruneEntry(merge.forwardEndAt(0));
             ArrayList<T> states = new ArrayList<>(merge.forwardEndCount() - 1);
             for (int i = 1; i < merge.forwardEndCount(); i++) {
@@ -249,7 +249,7 @@
             assert ready : "Not a single-pass iterator after all";
             return merge;
         } else {
-            BeginNode begin = elem.node;
+            AbstractBeginNode begin = elem.node;
             assert begin.predecessor() != null;
             state = elem.stateOnEntry;
             state.afterSplit(begin);
@@ -309,7 +309,7 @@
         assert !visitedEnds.isMarked(end);
         visitedEnds.mark(end);
         keepForLater(end, state);
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         boolean endsVisited = true;
         for (int i = 0; i < merge.forwardEndCount(); i++) {
             if (!visitedEnds.isMarked(merge.forwardEndAt(i))) {
@@ -328,7 +328,7 @@
         node(endNode);
     }
 
-    protected void merge(MergeNode merge) {
+    protected void merge(AbstractMergeNode merge) {
         node(merge);
     }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/StatelessPostOrderNodeIterator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/StatelessPostOrderNodeIterator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
 public abstract class StatelessPostOrderNodeIterator {
 
     private final NodeBitMap visitedEnds;
-    private final Deque<BeginNode> nodeQueue;
+    private final Deque<AbstractBeginNode> nodeQueue;
     private final FixedNode start;
 
     public StatelessPostOrderNodeIterator(FixedNode start) {
@@ -58,9 +58,9 @@
                 assert !visitedEnds.isMarked(current);
                 visitedEnds.mark(current);
                 current = nodeQueue.pollFirst();
-            } else if (current instanceof MergeNode) {
-                merge((MergeNode) current);
-                current = ((MergeNode) current).next();
+            } else if (current instanceof AbstractMergeNode) {
+                merge((AbstractMergeNode) current);
+                current = ((AbstractMergeNode) current).next();
                 assert current != null;
             } else if (current instanceof FixedWithNextNode) {
                 node(current);
@@ -76,7 +76,7 @@
                 controlSplit((ControlSplitNode) current);
                 for (Node node : current.successors()) {
                     if (node != null) {
-                        nodeQueue.addFirst((BeginNode) node);
+                        nodeQueue.addFirst((AbstractBeginNode) node);
                     }
                 }
                 current = nodeQueue.pollFirst();
@@ -90,7 +90,7 @@
     private void queueMerge(EndNode end) {
         assert !visitedEnds.isMarked(end);
         visitedEnds.mark(end);
-        MergeNode merge = end.merge();
+        AbstractMergeNode merge = end.merge();
         boolean endsVisited = true;
         for (int i = 0; i < merge.forwardEndCount(); i++) {
             if (!visitedEnds.isMarked(merge.forwardEndAt(i))) {
@@ -111,7 +111,7 @@
         node(endNode);
     }
 
-    protected void merge(MergeNode merge) {
+    protected void merge(AbstractMergeNode merge) {
         node(merge);
     }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -77,65 +77,99 @@
         LATEST_OUT_OF_LOOPS
     }
 
-    public static enum MemoryScheduling {
-        NONE,
-        OPTIMAL
-    }
+    static int created;
 
-    private class KillSet implements Iterable<LocationIdentity> {
+    private class LocationSet {
+        private LocationIdentity firstLocation;
         private List<LocationIdentity> list;
 
-        public KillSet() {
+        public LocationSet() {
             list = null;
         }
 
-        public KillSet(KillSet other) {
+        public LocationSet(LocationSet other) {
+            this.firstLocation = other.firstLocation;
             if (other.list != null && other.list.size() > 0) {
                 list = new ArrayList<>(other.list);
             }
         }
 
-        private void initSet() {
+        private void initList() {
             if (list == null) {
                 list = new ArrayList<>(4);
             }
         }
 
-        public void add(LocationIdentity locationIdentity) {
-            if (list == null || !list.contains(locationIdentity)) {
-                initSet();
-                list.add(locationIdentity);
-            }
-        }
-
-        public void addAll(KillSet other) {
-            if (other.list == null) {
-                return;
-            }
-            initSet();
-            for (LocationIdentity locationIdentity : other) {
-                if (!list.contains(locationIdentity)) {
-                    list.add(locationIdentity);
+        public void add(LocationIdentity location) {
+            if (LocationIdentity.ANY_LOCATION.equals(location)) {
+                firstLocation = location;
+                list = null;
+            } else {
+                if (firstLocation == null) {
+                    firstLocation = location;
+                } else if (LocationIdentity.ANY_LOCATION.equals(firstLocation)) {
+                    return;
+                } else if (location.equals(firstLocation)) {
+                    return;
+                } else {
+                    initList();
+                    for (int i = 0; i < list.size(); ++i) {
+                        LocationIdentity value = list.get(i);
+                        if (location.equals(value)) {
+                            return;
+                        }
+                    }
+                    list.add(location);
                 }
             }
         }
 
-        public Iterator<LocationIdentity> iterator() {
-            if (list == null) {
-                return Collections.emptyIterator();
+        public void addAll(LocationSet other) {
+            if (other.firstLocation != null) {
+                add(other.firstLocation);
             }
-            return list.iterator();
+            List<LocationIdentity> otherList = other.list;
+            if (otherList != null) {
+                for (LocationIdentity l : otherList) {
+                    add(l);
+                }
+            }
         }
 
-        public boolean isKilled(LocationIdentity locationIdentity) {
-            if (list == null) {
-                return false;
+        public boolean contains(LocationIdentity locationIdentity) {
+            assert locationIdentity != null;
+            assert !locationIdentity.equals(LocationIdentity.ANY_LOCATION);
+            assert !locationIdentity.equals(LocationIdentity.FINAL_LOCATION);
+            if (LocationIdentity.ANY_LOCATION.equals(firstLocation)) {
+                return true;
+            }
+            if (locationIdentity.equals(firstLocation)) {
+                return true;
             }
-            return list.contains(locationIdentity);
+            if (list != null) {
+                for (int i = 0; i < list.size(); ++i) {
+                    LocationIdentity value = list.get(i);
+                    if (locationIdentity.equals(value)) {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+        public List<LocationIdentity> getCopyAsList() {
+            ArrayList<LocationIdentity> result = new ArrayList<>();
+            if (firstLocation != null) {
+                result.add(firstLocation);
+            }
+            if (list != null) {
+                result.addAll(list);
+            }
+            return result;
         }
     }
 
-    private class NewMemoryScheduleClosure extends BlockIteratorClosure<KillSet> {
+    private class NewMemoryScheduleClosure extends BlockIteratorClosure<LocationSet> {
         private Node excludeNode;
         private Block upperBoundBlock;
 
@@ -149,23 +183,23 @@
         }
 
         @Override
-        protected KillSet getInitialState() {
+        protected LocationSet getInitialState() {
             return cloneState(blockToKillSet.get(getCFG().getStartBlock()));
         }
 
         @Override
-        protected KillSet processBlock(Block block, KillSet currentState) {
+        protected LocationSet processBlock(Block block, LocationSet currentState) {
             assert block != null;
             currentState.addAll(computeKillSet(block, block == upperBoundBlock ? excludeNode : null));
             return currentState;
         }
 
         @Override
-        protected KillSet merge(Block merge, List<KillSet> states) {
-            assert merge.getBeginNode() instanceof MergeNode;
+        protected LocationSet merge(Block merge, List<LocationSet> states) {
+            assert merge.getBeginNode() instanceof AbstractMergeNode;
 
-            KillSet initKillSet = new KillSet();
-            for (KillSet state : states) {
+            LocationSet initKillSet = new LocationSet();
+            for (LocationSet state : states) {
                 initKillSet.addAll(state);
             }
 
@@ -173,16 +207,16 @@
         }
 
         @Override
-        protected KillSet cloneState(KillSet state) {
-            return new KillSet(state);
+        protected LocationSet cloneState(LocationSet state) {
+            return new LocationSet(state);
         }
 
         @Override
-        protected List<KillSet> processLoop(Loop<Block> loop, KillSet state) {
-            LoopInfo<KillSet> info = ReentrantBlockIterator.processLoop(this, loop, cloneState(state));
+        protected List<LocationSet> processLoop(Loop<Block> loop, LocationSet state) {
+            LoopInfo<LocationSet> info = ReentrantBlockIterator.processLoop(this, loop, cloneState(state));
 
             assert loop.getHeader().getBeginNode() instanceof LoopBeginNode;
-            KillSet headerState = merge(loop.getHeader(), info.endStates);
+            LocationSet headerState = merge(loop.getHeader(), info.endStates);
 
             // second iteration, for propagating information to loop exits
             info = ReentrantBlockIterator.processLoop(this, loop, cloneState(headerState));
@@ -201,10 +235,10 @@
      *            until we reach excludeNode.
      * @return all killed locations
      */
-    private KillSet computeKillSet(Block block, Node excludeNode) {
+    private LocationSet computeKillSet(Block block, Node excludeNode) {
         // cache is only valid if we don't potentially exclude kills from the set
         if (excludeNode == null) {
-            KillSet cachedSet = blockToKillSet.get(block);
+            LocationSet cachedSet = blockToKillSet.get(block);
             if (cachedSet != null) {
                 return cachedSet;
             }
@@ -213,10 +247,10 @@
         // add locations to excludedLocations until we reach the excluded node
         boolean foundExcludeNode = excludeNode == null;
 
-        KillSet set = new KillSet();
-        KillSet excludedLocations = new KillSet();
-        if (block.getBeginNode() instanceof MergeNode) {
-            MergeNode mergeNode = (MergeNode) block.getBeginNode();
+        LocationSet set = new LocationSet();
+        LocationSet excludedLocations = new LocationSet();
+        if (block.getBeginNode() instanceof AbstractMergeNode) {
+            AbstractMergeNode mergeNode = (AbstractMergeNode) block.getBeginNode();
             for (MemoryPhiNode phi : mergeNode.usages().filter(MemoryPhiNode.class)) {
                 if (foundExcludeNode) {
                     set.add(phi.getLocationIdentity());
@@ -227,10 +261,10 @@
             }
         }
 
-        BeginNode startNode = cfg.getStartBlock().getBeginNode();
+        AbstractBeginNode startNode = cfg.getStartBlock().getBeginNode();
         assert startNode instanceof StartNode;
 
-        KillSet accm = foundExcludeNode ? set : excludedLocations;
+        LocationSet accm = foundExcludeNode ? set : excludedLocations;
         for (Node node : block.getNodes()) {
             if (!foundExcludeNode && node == excludeNode) {
                 foundExcludeNode = true;
@@ -259,7 +293,7 @@
         return set;
     }
 
-    private KillSet computeKillSet(Block block) {
+    private LocationSet computeKillSet(Block block) {
         return computeKillSet(block, null);
     }
 
@@ -269,25 +303,18 @@
     /**
      * Map from blocks to the nodes in each block.
      */
-    private BlockMap<List<ScheduledNode>> blockToNodesMap;
-    private BlockMap<KillSet> blockToKillSet;
+    private BlockMap<List<ValueNode>> blockToNodesMap;
+    private BlockMap<LocationSet> blockToKillSet;
     private final SchedulingStrategy selectedStrategy;
-    private final MemoryScheduling memsched;
 
     public SchedulePhase() {
         this(OptScheduleOutOfLoops.getValue() ? SchedulingStrategy.LATEST_OUT_OF_LOOPS : SchedulingStrategy.LATEST);
     }
 
     public SchedulePhase(SchedulingStrategy strategy) {
-        this.memsched = MemoryScheduling.OPTIMAL;
         this.selectedStrategy = strategy;
     }
 
-    public SchedulePhase(SchedulingStrategy strategy, MemoryScheduling memsched) {
-        this.selectedStrategy = strategy;
-        this.memsched = memsched;
-    }
-
     @Override
     protected void run(StructuredGraph graph) {
         assert GraphOrder.assertNonCyclicGraph(graph);
@@ -295,7 +322,7 @@
         earliestCache = graph.createNodeMap();
         blockToNodesMap = new BlockMap<>(cfg);
 
-        if (memsched == MemoryScheduling.OPTIMAL && selectedStrategy != SchedulingStrategy.EARLIEST) {
+        if (selectedStrategy != SchedulingStrategy.EARLIEST) {
             blockToKillSet = new BlockMap<>(cfg);
         }
 
@@ -324,18 +351,18 @@
 
     private void printScheduleHelper(String desc) {
         Formatter buf = new Formatter();
-        buf.format("=== %s / %s / %s (%s) ===%n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, memsched, desc);
+        buf.format("=== %s / %s / %s ===%n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, desc);
         for (Block b : getCFG().getBlocks()) {
             buf.format("==== b: %s (loopDepth: %s). ", b, b.getLoopDepth());
             buf.format("dom: %s. ", b.getDominator());
             buf.format("post-dom: %s. ", b.getPostdominator());
             buf.format("preds: %s. ", b.getPredecessors());
             buf.format("succs: %s ====%n", b.getSuccessors());
-            BlockMap<KillSet> killSets = blockToKillSet;
+            BlockMap<LocationSet> killSets = blockToKillSet;
             if (killSets != null) {
                 buf.format("X block kills: %n");
                 if (killSets.get(b) != null) {
-                    for (LocationIdentity locId : killSets.get(b)) {
+                    for (LocationIdentity locId : killSets.get(b).getCopyAsList()) {
                         buf.format("X %s killed by %s%n", locId, "dunno anymore");
                     }
                 }
@@ -383,20 +410,20 @@
     /**
      * Gets the map from each block to the nodes in the block.
      */
-    public BlockMap<List<ScheduledNode>> getBlockToNodesMap() {
+    public BlockMap<List<ValueNode>> getBlockToNodesMap() {
         return blockToNodesMap;
     }
 
     /**
      * Gets the nodes in a given block.
      */
-    public List<ScheduledNode> nodesFor(Block block) {
+    public List<ValueNode> nodesFor(Block block) {
         return blockToNodesMap.get(block);
     }
 
     private void assignBlockToNodes(StructuredGraph graph, SchedulingStrategy strategy) {
         for (Block block : cfg.getBlocks()) {
-            List<ScheduledNode> nodes = new ArrayList<>();
+            List<ValueNode> nodes = new ArrayList<>();
             if (blockToNodesMap.get(block) != null) {
                 throw new SchedulingError();
             }
@@ -407,8 +434,8 @@
         }
 
         for (Node n : graph.getNodes()) {
-            if (n instanceof ScheduledNode) {
-                assignBlockToNode((ScheduledNode) n, strategy);
+            if (n instanceof ValueNode) {
+                assignBlockToNode((ValueNode) n, strategy);
             }
         }
     }
@@ -417,7 +444,7 @@
      * Assigns a block to the given node. This method expects that PhiNodes and FixedNodes are
      * already assigned to a block.
      */
-    private void assignBlockToNode(ScheduledNode node, SchedulingStrategy strategy) {
+    private void assignBlockToNode(ValueNode node, SchedulingStrategy strategy) {
         assert !node.isDeleted();
 
         if (cfg.getNodeToBlock().containsKey(node)) {
@@ -438,7 +465,7 @@
                 break;
             case LATEST:
             case LATEST_OUT_OF_LOOPS:
-                boolean scheduleRead = memsched == MemoryScheduling.OPTIMAL && node instanceof FloatingReadNode && !((FloatingReadNode) node).location().getLocationIdentity().isImmutable();
+                boolean scheduleRead = node instanceof FloatingReadNode && !((FloatingReadNode) node).location().getLocationIdentity().isImmutable();
                 if (scheduleRead) {
                     FloatingReadNode read = (FloatingReadNode) node;
                     block = optimalBlock(read, strategy);
@@ -472,7 +499,7 @@
                 throw new GraalInternalError("unknown scheduling strategy");
         }
         if (!dominates(earliestBlock, block)) {
-            throw new SchedulingError("%s: Graph cannot be scheduled : inconsistent for %s, %d usages, (%s needs to dominate %s)", node.graph(), node, node.usages().count(), earliestBlock, block);
+            throw new SchedulingError("%s: Graph cannot be scheduled : inconsistent for %s, %d usages, (%s needs to dominate %s)", node.graph(), node, node.getUsageCount(), earliestBlock, block);
         }
         cfg.getNodeToBlock().set(node, block);
         blockToNodesMap.get(block).add(node);
@@ -506,8 +533,6 @@
      *
      */
     private Block optimalBlock(FloatingReadNode n, SchedulingStrategy strategy) {
-        assert memsched == MemoryScheduling.OPTIMAL;
-
         LocationIdentity locid = n.location().getLocationIdentity();
         assert !locid.isImmutable();
 
@@ -533,10 +558,7 @@
             Block dominatedBlock = path.size() == 0 ? null : path.peek();
             if (dominatedBlock != null && !currentBlock.getSuccessors().contains(dominatedBlock)) {
                 // the dominated block is not a successor -> we have a split
-                assert dominatedBlock.getBeginNode() instanceof MergeNode;
-
-                HashSet<Block> region = computeRegion(currentBlock, dominatedBlock);
-                Debug.log("> merge.  %s: region for %s -> %s: %s", n, currentBlock, dominatedBlock, region);
+                assert dominatedBlock.getBeginNode() instanceof AbstractMergeNode;
 
                 NewMemoryScheduleClosure closure = null;
                 if (currentBlock == upperBoundBlock) {
@@ -546,11 +568,11 @@
                 } else {
                     closure = new NewMemoryScheduleClosure();
                 }
-                Map<FixedNode, KillSet> states;
-                states = ReentrantBlockIterator.apply(closure, currentBlock, new KillSet(), region);
+                Map<FixedNode, LocationSet> states;
+                states = ReentrantBlockIterator.apply(closure, currentBlock, new LocationSet(), block -> block == dominatedBlock);
 
-                KillSet mergeState = states.get(dominatedBlock.getBeginNode());
-                if (mergeState.isKilled(locid)) {
+                LocationSet mergeState = states.get(dominatedBlock.getBeginNode());
+                if (mergeState.contains(locid)) {
                     // location got killed somewhere in the branches,
                     // thus we've to move the read above it
                     return currentBlock;
@@ -558,11 +580,11 @@
             } else {
                 if (currentBlock == upperBoundBlock) {
                     assert earliestBlock == upperBoundBlock;
-                    KillSet ks = computeKillSet(upperBoundBlock, ValueNodeUtil.asNode(n.getLastLocationAccess()));
-                    if (ks.isKilled(locid)) {
+                    LocationSet ks = computeKillSet(upperBoundBlock, ValueNodeUtil.asNode(n.getLastLocationAccess()));
+                    if (ks.contains(locid)) {
                         return upperBoundBlock;
                     }
-                } else if (dominatedBlock == null || computeKillSet(currentBlock).isKilled(locid)) {
+                } else if (dominatedBlock == null || computeKillSet(currentBlock).contains(locid)) {
                     return currentBlock;
                 }
             }
@@ -587,37 +609,12 @@
     }
 
     /**
-     * compute a set that contains all blocks in a region spanned by dominatorBlock and
-     * dominatedBlock (exclusive the dominatedBlock).
-     */
-    private static HashSet<Block> computeRegion(Block dominatorBlock, Block dominatedBlock) {
-        HashSet<Block> region = new HashSet<>();
-        Queue<Block> workList = new LinkedList<>();
-
-        region.add(dominatorBlock);
-        workList.addAll(dominatorBlock.getSuccessors());
-        while (workList.size() > 0) {
-            Block current = workList.poll();
-            if (current != dominatedBlock) {
-                region.add(current);
-                for (Block b : current.getSuccessors()) {
-                    if (!region.contains(b) && !workList.contains(b)) {
-                        workList.offer(b);
-                    }
-                }
-            }
-        }
-        assert !region.contains(dominatedBlock) && region.containsAll(dominatedBlock.getPredecessors());
-        return region;
-    }
-
-    /**
      * Calculates the last block that the given node could be scheduled in, i.e., the common
      * dominator of all usages. To do so all usages are also assigned to blocks.
      *
      * @param strategy
      */
-    private Block latestBlock(ScheduledNode node, SchedulingStrategy strategy) {
+    private Block latestBlock(ValueNode node, SchedulingStrategy strategy) {
         CommonDominatorBlockClosure cdbc = new CommonDominatorBlockClosure(null);
         for (Node succ : node.successors().nonNull()) {
             if (cfg.getNodeToBlock().get(succ) == null) {
@@ -747,7 +744,7 @@
      * @param usage the usage whose blocks need to be considered
      * @param closure the closure that will be called for each block
      */
-    private void blocksForUsage(ScheduledNode node, Node usage, BlockClosure closure, SchedulingStrategy strategy) {
+    private void blocksForUsage(ValueNode node, Node usage, BlockClosure closure, SchedulingStrategy strategy) {
         if (node instanceof PhiNode) {
             throw new SchedulingError(node.toString());
         }
@@ -758,7 +755,7 @@
             // One PhiNode can use an input multiple times, the closure will be called for each
             // usage.
             PhiNode phi = (PhiNode) usage;
-            MergeNode merge = phi.merge();
+            AbstractMergeNode merge = phi.merge();
             Block mergeBlock = cfg.getNodeToBlock().get(merge);
             if (mergeBlock == null) {
                 throw new SchedulingError("no block for merge %s", merge.toString(Verbosity.Id));
@@ -784,7 +781,7 @@
                     // If a FrameState is an outer FrameState this method behaves as if the inner
                     // FrameState was the actual usage, by recursing.
                     blocksForUsage(node, unscheduledUsage, closure, strategy);
-                } else if (unscheduledUsage instanceof BeginNode) {
+                } else if (unscheduledUsage instanceof AbstractBeginNode) {
                     // Only FrameStates can be connected to BeginNodes.
                     if (!(usage instanceof FrameState)) {
                         throw new SchedulingError(usage.toString());
@@ -807,20 +804,20 @@
                         throw new SchedulingError(unscheduledUsage.toString());
                     }
                     // Otherwise: Put the input into the same block as the usage.
-                    assignBlockToNode((ScheduledNode) unscheduledUsage, strategy);
+                    assignBlockToNode((ValueNode) unscheduledUsage, strategy);
                     closure.apply(cfg.getNodeToBlock().get(unscheduledUsage));
                 }
             }
         } else {
             // All other types of usages: Put the input into the same block as the usage.
-            assignBlockToNode((ScheduledNode) usage, strategy);
+            assignBlockToNode((ValueNode) usage, strategy);
             closure.apply(cfg.getNodeToBlock().get(usage));
         }
     }
 
     private void ensureScheduledUsages(Node node, SchedulingStrategy strategy) {
-        for (Node usage : node.usages().filter(ScheduledNode.class)) {
-            assignBlockToNode((ScheduledNode) usage, strategy);
+        for (Node usage : node.usages().filter(ValueNode.class)) {
+            assignBlockToNode((ValueNode) usage, strategy);
         }
         // now true usages are ready
     }
@@ -835,8 +832,8 @@
     }
 
     private boolean noDuplicatedNodesInBlock(Block b) {
-        List<ScheduledNode> list = blockToNodesMap.get(b);
-        Set<ScheduledNode> hashset = Node.newSet(list);
+        List<ValueNode> list = blockToNodesMap.get(b);
+        Set<ValueNode> hashset = Node.newSet(list);
         return list.size() == hashset.size();
     }
 
@@ -848,7 +845,7 @@
             throw new SchedulingError();
         }
 
-        List<ScheduledNode> sortedInstructions;
+        List<ValueNode> sortedInstructions;
         switch (strategy) {
             case EARLIEST:
                 sortedInstructions = sortNodesWithinBlockEarliest(b, visited);
@@ -866,9 +863,9 @@
         blockToNodesMap.put(b, sortedInstructions);
     }
 
-    private static List<ScheduledNode> removeProxies(List<ScheduledNode> list) {
-        List<ScheduledNode> result = new ArrayList<>();
-        for (ScheduledNode n : list) {
+    private static List<ValueNode> removeProxies(List<ValueNode> list) {
+        List<ValueNode> result = new ArrayList<>();
+        for (ValueNode n : list) {
             if (!(n instanceof ProxyNode)) {
                 result.add(n);
             }
@@ -876,9 +873,9 @@
         return result;
     }
 
-    private static List<ScheduledNode> filterSchedulableNodes(List<ScheduledNode> list) {
-        List<ScheduledNode> result = new ArrayList<>();
-        for (ScheduledNode n : list) {
+    private static List<ValueNode> filterSchedulableNodes(List<ValueNode> list) {
+        List<ValueNode> result = new ArrayList<>();
+        for (ValueNode n : list) {
             if (!(n instanceof PhiNode)) {
                 result.add(n);
             }
@@ -886,12 +883,12 @@
         return result;
     }
 
-    private static boolean sameOrderForFixedNodes(List<ScheduledNode> fixed, List<ScheduledNode> sorted) {
-        Iterator<ScheduledNode> fixedIterator = fixed.iterator();
-        Iterator<ScheduledNode> sortedIterator = sorted.iterator();
+    private static boolean sameOrderForFixedNodes(List<ValueNode> fixed, List<ValueNode> sorted) {
+        Iterator<ValueNode> fixedIterator = fixed.iterator();
+        Iterator<ValueNode> sortedIterator = sorted.iterator();
 
         while (sortedIterator.hasNext()) {
-            ScheduledNode sortedCurrent = sortedIterator.next();
+            ValueNode sortedCurrent = sortedIterator.next();
             if (sortedCurrent instanceof FixedNode) {
                 if (!(fixedIterator.hasNext() && fixedIterator.next() == sortedCurrent)) {
                     return false;
@@ -912,10 +909,10 @@
         private Block block;
         private NodeBitMap visited;
         private NodeBitMap beforeLastLocation;
-        private List<ScheduledNode> sortedInstructions;
+        private List<ValueNode> sortedInstructions;
         private List<FloatingReadNode> reads;
 
-        SortState(Block block, NodeBitMap visited, NodeBitMap beforeLastLocation, List<ScheduledNode> sortedInstructions) {
+        SortState(Block block, NodeBitMap visited, NodeBitMap beforeLastLocation, List<ValueNode> sortedInstructions) {
             this.block = block;
             this.visited = visited;
             this.beforeLastLocation = beforeLastLocation;
@@ -961,7 +958,7 @@
             return reads.size();
         }
 
-        void removeRead(ScheduledNode i) {
+        void removeRead(ValueNode i) {
             assert reads != null;
             reads.remove(i);
         }
@@ -971,15 +968,15 @@
             return new ArrayList<>(reads);
         }
 
-        List<ScheduledNode> getSortedInstructions() {
+        List<ValueNode> getSortedInstructions() {
             return sortedInstructions;
         }
 
-        boolean containsInstruction(ScheduledNode i) {
+        boolean containsInstruction(ValueNode i) {
             return sortedInstructions.contains(i);
         }
 
-        void addInstruction(ScheduledNode i) {
+        void addInstruction(ValueNode i) {
             sortedInstructions.add(i);
         }
     }
@@ -989,33 +986,31 @@
      * all inputs. This means that a node is added to the list after all its inputs have been
      * processed.
      */
-    private List<ScheduledNode> sortNodesWithinBlockLatest(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation) {
+    private List<ValueNode> sortNodesWithinBlockLatest(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation) {
         SortState state = new SortState(b, visited, beforeLastLocation, new ArrayList<>(blockToNodesMap.get(b).size() + 2));
-        List<ScheduledNode> instructions = blockToNodesMap.get(b);
+        List<ValueNode> instructions = blockToNodesMap.get(b);
 
-        if (memsched == MemoryScheduling.OPTIMAL) {
-            for (ScheduledNode i : instructions) {
-                if (i instanceof FloatingReadNode) {
-                    FloatingReadNode frn = (FloatingReadNode) i;
-                    if (!frn.location().getLocationIdentity().isImmutable()) {
-                        state.addRead(frn);
-                        if (nodesFor(b).contains(frn.getLastLocationAccess())) {
-                            assert !state.isBeforeLastLocation(frn);
-                            state.markBeforeLastLocation(frn);
-                        }
+        for (ValueNode i : instructions) {
+            if (i instanceof FloatingReadNode) {
+                FloatingReadNode frn = (FloatingReadNode) i;
+                if (!frn.location().getLocationIdentity().isImmutable()) {
+                    state.addRead(frn);
+                    if (nodesFor(b).contains(frn.getLastLocationAccess())) {
+                        assert !state.isBeforeLastLocation(frn);
+                        state.markBeforeLastLocation(frn);
                     }
                 }
             }
         }
 
-        for (ScheduledNode i : instructions) {
+        for (ValueNode i : instructions) {
             addToLatestSorting(i, state);
         }
         assert state.readsSize() == 0 : "not all reads are scheduled";
 
         // Make sure that last node gets really last (i.e. when a frame state successor hangs off
         // it).
-        List<ScheduledNode> sortedInstructions = state.getSortedInstructions();
+        List<ValueNode> sortedInstructions = state.getSortedInstructions();
         Node lastSorted = sortedInstructions.get(sortedInstructions.size() - 1);
         if (lastSorted != b.getEndNode()) {
             int idx = sortedInstructions.indexOf(b.getEndNode());
@@ -1066,14 +1061,14 @@
                 if (input instanceof VirtualState) {
                     addUnscheduledToLatestSorting((VirtualState) input, sortState);
                 } else {
-                    addToLatestSorting((ScheduledNode) input, sortState);
+                    addToLatestSorting((ValueNode) input, sortState);
                 }
             }
         }
     }
 
-    private void addToLatestSorting(ScheduledNode i, SortState state) {
-        if (i == null || state.isVisited(i) || cfg.getNodeToBlock().get(i) != state.currentBlock() || i instanceof PhiNode) {
+    private void addToLatestSorting(ValueNode i, SortState state) {
+        if (i == null || state.isVisited(i) || cfg.getNodeToBlock().get(i) != state.currentBlock() || i instanceof PhiNode || i instanceof ProxyNode) {
             return;
         }
 
@@ -1082,25 +1077,17 @@
             stateAfter = ((StateSplit) i).stateAfter();
         }
 
-        if (i instanceof LoopExitNode) {
-            for (ProxyNode proxy : ((LoopExitNode) i).proxies()) {
-                addToLatestSorting(proxy, state);
-            }
-        }
-
         for (Node input : i.inputs()) {
             if (input instanceof FrameState) {
                 if (input != stateAfter) {
                     addUnscheduledToLatestSorting((FrameState) input, state);
                 }
             } else {
-                if (!(i instanceof ProxyNode && input instanceof LoopExitNode)) {
-                    addToLatestSorting((ScheduledNode) input, state);
-                }
+                addToLatestSorting((ValueNode) input, state);
             }
         }
 
-        if (memsched == MemoryScheduling.OPTIMAL && state.readsSize() != 0) {
+        if (state.readsSize() != 0) {
             if (i instanceof MemoryCheckpoint.Single) {
                 LocationIdentity identity = ((MemoryCheckpoint.Single) i).getLocationIdentity();
                 processKillLocation(i, identity, state);
@@ -1112,7 +1099,7 @@
             assert MemoryCheckpoint.TypeAssertion.correctType(i);
         }
 
-        addToLatestSorting((ScheduledNode) i.predecessor(), state);
+        addToLatestSorting((ValueNode) i.predecessor(), state);
         state.markVisited(i);
         addUnscheduledToLatestSorting(stateAfter, state);
 
@@ -1131,17 +1118,17 @@
      * all usages. The resulting list is reversed to create an earliest-possible scheduling of
      * nodes.
      */
-    private List<ScheduledNode> sortNodesWithinBlockEarliest(Block b, NodeBitMap visited) {
-        List<ScheduledNode> sortedInstructions = new ArrayList<>(blockToNodesMap.get(b).size() + 2);
+    private List<ValueNode> sortNodesWithinBlockEarliest(Block b, NodeBitMap visited) {
+        List<ValueNode> sortedInstructions = new ArrayList<>(blockToNodesMap.get(b).size() + 2);
         addToEarliestSorting(b, b.getEndNode(), sortedInstructions, visited);
         Collections.reverse(sortedInstructions);
         return sortedInstructions;
     }
 
-    private void addToEarliestSorting(Block b, ScheduledNode i, List<ScheduledNode> sortedInstructions, NodeBitMap visited) {
-        ScheduledNode instruction = i;
+    private void addToEarliestSorting(Block b, ValueNode i, List<ValueNode> sortedInstructions, NodeBitMap visited) {
+        ValueNode instruction = i;
         while (true) {
-            if (instruction == null || visited.isMarked(instruction) || cfg.getNodeToBlock().get(instruction) != b || instruction instanceof PhiNode) {
+            if (instruction == null || visited.isMarked(instruction) || cfg.getNodeToBlock().get(instruction) != b || instruction instanceof PhiNode || instruction instanceof ProxyNode) {
                 return;
             }
 
@@ -1150,33 +1137,21 @@
                 if (usage instanceof VirtualState) {
                     // only fixed nodes can have VirtualState -> no need to schedule them
                 } else {
-                    if (instruction instanceof LoopExitNode && usage instanceof ProxyNode) {
-                        // value proxies should be scheduled before the loopexit, not after
-                    } else {
-                        addToEarliestSorting(b, (ScheduledNode) usage, sortedInstructions, visited);
-                    }
+                    addToEarliestSorting(b, (ValueNode) usage, sortedInstructions, visited);
                 }
             }
 
-            if (instruction instanceof BeginNode) {
-                ArrayList<ProxyNode> proxies = (instruction instanceof LoopExitNode) ? new ArrayList<>() : null;
-                for (ScheduledNode inBlock : blockToNodesMap.get(b)) {
+            if (instruction instanceof AbstractBeginNode) {
+                for (ValueNode inBlock : blockToNodesMap.get(b)) {
                     if (!visited.isMarked(inBlock)) {
-                        if (inBlock instanceof ProxyNode) {
-                            proxies.add((ProxyNode) inBlock);
-                        } else {
-                            addToEarliestSorting(b, inBlock, sortedInstructions, visited);
-                        }
+                        addToEarliestSorting(b, inBlock, sortedInstructions, visited);
                     }
                 }
                 sortedInstructions.add(instruction);
-                if (proxies != null) {
-                    sortedInstructions.addAll(proxies);
-                }
                 break;
             } else {
                 sortedInstructions.add(instruction);
-                instruction = (ScheduledNode) instruction.predecessor();
+                instruction = (ValueNode) instruction.predecessor();
             }
         }
     }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/BlockWorkList.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/BlockWorkList.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
  */
 public class BlockWorkList {
 
-    MergeNode[] workList;
+    AbstractMergeNode[] workList;
     int[] workListNumbers;
     int workListIndex;
 
@@ -40,7 +40,7 @@
      * 
      * @param block the block to add
      */
-    public void add(MergeNode block) {
+    public void add(AbstractMergeNode block) {
         if (workList == null) {
             // worklist not allocated yet
             allocate();
@@ -59,7 +59,7 @@
      * @param block the block to add
      * @param number the number used to sort the block
      */
-    public void addSorted(MergeNode block, int number) {
+    public void addSorted(AbstractMergeNode block, int number) {
         if (workList == null) {
             // worklist not allocated yet
             allocate();
@@ -92,7 +92,7 @@
      * 
      * @return the next block in the list
      */
-    public MergeNode removeFromWorkList() {
+    public AbstractMergeNode removeFromWorkList() {
         if (workListIndex != 0) {
             return workList[--workListIndex];
         }
@@ -109,13 +109,13 @@
     }
 
     private void allocate() {
-        workList = new MergeNode[5];
+        workList = new AbstractMergeNode[5];
         workListNumbers = new int[5];
     }
 
     private void grow() {
         int prevLength = workList.length;
-        MergeNode[] nworkList = new MergeNode[prevLength * 3];
+        AbstractMergeNode[] nworkList = new AbstractMergeNode[prevLength * 3];
         System.arraycopy(workList, 0, nworkList, 0, prevLength);
         workList = nworkList;
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,7 +34,6 @@
 import com.oracle.graal.phases.graph.*;
 import com.oracle.graal.phases.graph.ReentrantBlockIterator.BlockIteratorClosure;
 import com.oracle.graal.phases.schedule.*;
-import com.oracle.graal.phases.schedule.SchedulePhase.MemoryScheduling;
 import com.oracle.graal.phases.schedule.SchedulePhase.SchedulingStrategy;
 
 public final class GraphOrder {
@@ -111,8 +110,8 @@
                     }
                 }
                 nodes.add(node);
-                if (node instanceof MergeNode) {
-                    for (PhiNode phi : ((MergeNode) node).phis()) {
+                if (node instanceof AbstractMergeNode) {
+                    for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
                         visited.mark(phi);
                         nodes.add(phi);
                     }
@@ -135,7 +134,7 @@
      */
     public static boolean assertSchedulableGraph(final StructuredGraph graph) {
         try {
-            final SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, MemoryScheduling.NONE);
+            final SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS);
             final Map<LoopBeginNode, NodeBitMap> loopEntryStates = Node.newIdentityMap();
             schedule.apply(graph, false);
 
@@ -148,7 +147,7 @@
 
                 @Override
                 protected NodeBitMap processBlock(final Block block, final NodeBitMap currentState) {
-                    final List<ScheduledNode> list = schedule.getBlockToNodesMap().get(block);
+                    final List<ValueNode> list = schedule.getBlockToNodesMap().get(block);
 
                     /*
                      * A stateAfter is not valid directly after its associated state split, but
@@ -156,7 +155,7 @@
                      * will be checked at the correct position.
                      */
                     FrameState pendingStateAfter = null;
-                    for (final ScheduledNode node : list) {
+                    for (final ValueNode node : list) {
                         FrameState stateAfter = node instanceof StateSplit ? ((StateSplit) node).stateAfter() : null;
                         if (node instanceof FullInfopointNode) {
                             stateAfter = ((FullInfopointNode) node).getState();
@@ -164,6 +163,7 @@
 
                         if (pendingStateAfter != null && node instanceof FixedNode) {
                             pendingStateAfter.applyToNonVirtual(new NodeClosure<Node>() {
+                                @Override
                                 public void apply(Node usage, Node nonVirtualNode) {
                                     assert currentState.isMarked(nonVirtualNode) || nonVirtualNode instanceof VirtualObjectNode : nonVirtualNode + " not available at virtualstate " + usage +
                                                     " before " + node + " in block " + block + " \n" + list;
@@ -172,21 +172,25 @@
                             pendingStateAfter = null;
                         }
 
-                        if (node instanceof MergeNode) {
+                        if (node instanceof AbstractMergeNode) {
                             // phis aren't scheduled, so they need to be added explicitly
-                            currentState.markAll(((MergeNode) node).phis());
+                            currentState.markAll(((AbstractMergeNode) node).phis());
                             if (node instanceof LoopBeginNode) {
                                 // remember the state at the loop entry, it's restored at exits
                                 loopEntryStates.put((LoopBeginNode) node, currentState.copy());
                             }
                         } else if (node instanceof ProxyNode) {
-                            for (Node input : node.inputs()) {
-                                if (input != ((ProxyNode) node).proxyPoint()) {
-                                    assert currentState.isMarked(input) : input + " not available at " + node + " in block " + block + "\n" + list;
-                                }
-                            }
+                            assert false : "proxy nodes should not be in the schedule";
                         } else if (node instanceof LoopExitNode) {
                             if (graph.hasValueProxies()) {
+                                for (ProxyNode proxy : ((LoopExitNode) node).proxies()) {
+                                    for (Node input : proxy.inputs()) {
+                                        if (input != proxy.proxyPoint()) {
+                                            assert currentState.isMarked(input) : input + " not available at " + proxy + " in block " + block + "\n" + list;
+                                        }
+                                    }
+                                }
+
                                 // loop contents are only accessible via proxies at the exit
                                 currentState.clearAll();
                                 currentState.markAll(loopEntryStates.get(((LoopExitNode) node).loopBegin()));
@@ -197,8 +201,11 @@
                             for (Node input : node.inputs()) {
                                 if (input != stateAfter) {
                                     if (input instanceof FrameState) {
-                                        ((FrameState) input).applyToNonVirtual((usage, nonVirtual) -> {
-                                            assert currentState.isMarked(nonVirtual) : nonVirtual + " not available at " + node + " in block " + block + "\n" + list;
+                                        ((FrameState) input).applyToNonVirtual(new VirtualState.NodeClosure<Node>() {
+                                            @Override
+                                            public void apply(Node usage, Node nonVirtual) {
+                                                assert currentState.isMarked(nonVirtual) : nonVirtual + " not available at " + node + " in block " + block + "\n" + list;
+                                            }
                                         });
                                     } else {
                                         assert currentState.isMarked(input) || input instanceof VirtualObjectNode : input + " not available at " + node + " in block " + block + "\n" + list;
@@ -207,7 +214,7 @@
                             }
                         }
                         if (node instanceof AbstractEndNode) {
-                            MergeNode merge = ((AbstractEndNode) node).merge();
+                            AbstractMergeNode merge = ((AbstractEndNode) node).merge();
                             for (PhiNode phi : merge.phis()) {
                                 ValueNode phiValue = phi.valueAt((AbstractEndNode) node);
                                 assert phiValue == null || currentState.isMarked(phiValue) : phiValue + " not available at phi " + phi + " / end " + node + " in block " + block;
@@ -221,6 +228,7 @@
                     }
                     if (pendingStateAfter != null) {
                         pendingStateAfter.applyToNonVirtual(new NodeClosure<Node>() {
+                            @Override
                             public void apply(Node usage, Node nonVirtualNode) {
                                 assert currentState.isMarked(nonVirtualNode) || nonVirtualNode instanceof VirtualObjectNode : nonVirtualNode + " not available at virtualstate " + usage +
                                                 " at end of block " + block + " \n" + list;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Wed Jan 28 19:32:47 2015 +0100
@@ -140,7 +140,7 @@
             }
         }
         ControlFlowGraph cfg = schedule == null ? null : schedule.getCFG();
-        BlockMap<List<ScheduledNode>> blockToNodes = schedule == null ? null : schedule.getBlockToNodesMap();
+        BlockMap<List<ValueNode>> blockToNodes = schedule == null ? null : schedule.getBlockToNodesMap();
         List<Block> blocks = cfg == null ? null : cfg.getBlocks();
         writeNodes(graph);
         writeBlocks(blocks, blockToNodes);
@@ -467,11 +467,11 @@
         }
     }
 
-    private void writeBlocks(List<Block> blocks, BlockMap<List<ScheduledNode>> blockToNodes) throws IOException {
+    private void writeBlocks(List<Block> blocks, BlockMap<List<ValueNode>> blockToNodes) throws IOException {
         if (blocks != null) {
             writeInt(blocks.size());
             for (Block block : blocks) {
-                List<ScheduledNode> nodes = blockToNodes.get(block);
+                List<ValueNode> nodes = blockToNodes.get(block);
                 writeInt(block.getId());
                 writeInt(nodes.size());
                 for (Node node : nodes) {
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Wed Jan 28 19:32:47 2015 +0100
@@ -266,9 +266,9 @@
         out.println("HIR");
         out.disableIndentation();
 
-        if (block.getBeginNode() instanceof MergeNode) {
+        if (block.getBeginNode() instanceof AbstractMergeNode) {
             // Currently phi functions are not in the schedule, so print them separately here.
-            for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) {
+            for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
                 printNode(phi, false);
             }
         }
@@ -344,7 +344,7 @@
         out.println("=== Succesors ===");
         printNamedNodes(node, node.successors().iterator(), "", "\n", null);
         out.println("=== Usages ===");
-        if (!node.usages().isEmpty()) {
+        if (!node.hasNoUsages()) {
             for (Node usage : node.usages()) {
                 out.print(nodeToString(usage)).print(" ");
             }
@@ -485,7 +485,7 @@
             return "-";
         }
         String prefix;
-        if (node instanceof BeginNode && (lir == null && schedule == null)) {
+        if (node instanceof AbstractBeginNode && (lir == null && schedule == null)) {
             prefix = "B";
         } else if (node instanceof ValueNode) {
             ValueNode value = (ValueNode) node;
@@ -620,15 +620,15 @@
         printedNodes = null;
     }
 
-    private void printScheduledBlock(Block block, List<ScheduledNode> nodesFor) {
+    private void printScheduledBlock(Block block, List<ValueNode> nodesFor) {
         printBlockProlog(block);
         begin("IR");
         out.println("HIR");
         out.disableIndentation();
 
-        if (block.getBeginNode() instanceof MergeNode) {
+        if (block.getBeginNode() instanceof AbstractMergeNode) {
             // Currently phi functions are not in the schedule, so print them separately here.
-            for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) {
+            for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
                 printNode(phi, false);
             }
         }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DebugEnvironment.java	Wed Jan 28 19:32:47 2015 +0100
@@ -59,9 +59,6 @@
             }
             dumpHandlers.add(new CFGPrinterObserver(PrintCFG.getValue()));
         }
-        if (DecompileAfterPhase.getValue() != null) {
-            dumpHandlers.add(new DecompilerDebugDumpHandler());
-        }
         List<DebugVerifyHandler> verifyHandlers = new ArrayList<>();
         String verifyFilter = Verify.getValue();
         if (verifyFilter == null && assertionsEnabled()) {
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +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.printer;
-
-import static com.oracle.graal.compiler.common.GraalOptions.*;
-
-import java.io.*;
-import java.util.concurrent.atomic.*;
-
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.java.decompiler.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.schedule.*;
-
-public class DecompilerDebugDumpHandler implements DebugDumpHandler {
-
-    public static boolean printToNowhere;
-    private final PrintStream infoPrintStream = System.out;
-    private File file;
-    private FileOutputStream fos;
-    private PrintStream printStream;
-    private String fileName;
-    private static final AtomicInteger uniqueId = new AtomicInteger();
-
-    @Override
-    public void dump(Object object, final String message) {
-        if (object instanceof StructuredGraph) {
-            if (Debug.currentScope().contains("LowTier")) {
-                // no decompilation after high / mid tier
-                return;
-            }
-            final StructuredGraph graph = (StructuredGraph) object;
-            String filter = DecompileAfterPhase.getValue();
-            if (filter.endsWith("Phase")) {
-                filter = filter.substring(0, filter.indexOf("Phase"));
-            }
-
-            if (printToNowhere) {
-                printStream = new PrintStream(new OutputStream() {
-                    @Override
-                    public void write(int b) throws IOException {
-                        // DO NOTHING
-                    }
-                });
-            }
-
-            if (printStream == null) {
-                fileName = "decompilerDump_" + uniqueId.incrementAndGet() + "_" + System.currentTimeMillis() + ".txt";
-                file = new File(fileName);
-                try {
-                    fos = new FileOutputStream(file, true);
-                } catch (FileNotFoundException e) {
-                    throw new IllegalStateException(e);
-                }
-                printStream = new PrintStream(fos);
-                infoPrintStream.println("Dump Decompiler Output to " + file.getAbsolutePath());
-            }
-
-            final String currentScope = Debug.currentScope();
-            if (currentScope.endsWith(filter) && graph.method() != null) {
-                final String methodName = graph.method().getName();
-                try (Scope s = Debug.sandbox("Printing Decompiler Output", null)) {
-                    printStream.println();
-                    printStream.println("Object: " + methodName);
-                    printStream.println("Message: " + message);
-                    new Decompiler(graph, getPredefinedSchedule(), printStream, infoPrintStream, currentScope).decompile();
-                    printStream.flush();
-                } catch (Throwable e) {
-                    throw Debug.handle(e);
-                }
-            }
-        }
-    }
-
-    private static SchedulePhase getPredefinedSchedule() {
-        SchedulePhase result = null;
-        for (Object o : Debug.context()) {
-            if (o instanceof SchedulePhase) {
-                result = (SchedulePhase) o;
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public void close() {
-        try {
-            printStream.close();
-            fos.close();
-            printStream = null;
-            fos = null;
-        } catch (IOException e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Jan 28 19:32:47 2015 +0100
@@ -152,7 +152,7 @@
 
     @Override
     public void dump(Object object, final String message) {
-        if (object instanceof Graph) {
+        if (object instanceof Graph && PrintIdealGraph.getValue()) {
             ensureInitialized();
             if (printer == null) {
                 return;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java	Wed Jan 28 19:32:47 2015 +0100
@@ -173,7 +173,7 @@
                     printProperty(bit, "true");
                 }
             }
-            if (node.getClass() == BeginNode.class) {
+            if (node instanceof BeginNode) {
                 printProperty("shortName", "B");
             } else if (node.getClass() == EndNode.class) {
                 printProperty("shortName", "E");
@@ -276,8 +276,8 @@
                 if (node instanceof StateSplit && ((StateSplit) node).stateAfter() != null) {
                     nodes.add(((StateSplit) node).stateAfter());
                 }
-                if (node instanceof MergeNode) {
-                    for (PhiNode phi : ((MergeNode) node).phis()) {
+                if (node instanceof AbstractMergeNode) {
+                    for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
                         nodes.add(phi);
                     }
                 }
--- a/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * 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.ptx;
-
-import static com.oracle.graal.api.code.MemoryBarriers.*;
-
-import java.nio.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.Register.RegisterCategory;
-import com.oracle.graal.api.meta.*;
-
-/**
- * Represents the PTX architecture.
- */
-public class PTX extends Architecture {
-
-    public static final RegisterCategory REG = new RegisterCategory("REG");
-    public static final RegisterCategory SREG = new RegisterCategory("SREG");
-    public static final RegisterCategory PARAM = new RegisterCategory("PARAM");
-
-    // @formatter:off
-
-    /*
-     * Register State Space
-     *
-     * Registers (.reg state space) are fast storage locations. The
-     * number of GPU architectural registers is limited, and will vary
-     * from platform to platform. When the limit is exceeded, register
-     * variables will be spilled to memory, causing changes in
-     * performance. For each architecture, there is a recommended
-     * maximum number of registers to use (see the "CUDA Programming
-     * Guide" for details).
-     *
-     * TODD: XXX
-     *
-     * However, PTX supports virtual registers. So, the generated PTX
-     * code does not need to use a specified number of registers. Till
-     * we figure out how to model a virtual register set in Graal, we
-     * will pretend that we can use only 16 registers.
-     */
-
-    public static final Register r0  = new Register(0,   0,  "r0",  REG);
-    public static final Register r1  = new Register(1,   1,  "r1",  REG);
-    public static final Register r2  = new Register(2,   2,  "r2",  REG);
-    public static final Register r3  = new Register(3,   3,  "r3",  REG);
-    public static final Register r4  = new Register(4,   4,  "r4",  REG);
-    public static final Register r5  = new Register(5,   5,  "r5",  REG);
-    public static final Register r6  = new Register(6,   6,  "r6",  REG);
-    public static final Register r7  = new Register(7,   7,  "r7",  REG);
-
-    public static final Register r8  = new Register(8,   8,  "r8",  REG);
-    public static final Register r9  = new Register(9,   9,  "r9",  REG);
-    public static final Register r10 = new Register(10, 10, "r10", REG);
-    public static final Register r11 = new Register(11, 11, "r11", REG);
-    public static final Register r12 = new Register(12, 12, "r12", REG);
-    public static final Register r13 = new Register(13, 13, "r13", REG);
-    public static final Register r14 = new Register(14, 14, "r14", REG);
-    public static final Register r15 = new Register(15, 15, "r15", REG);
-
-    public static final Register[] gprRegisters = {
-        r0,  r1,  r2,  r3,  r4,  r5,  r6,  r7,
-        r8,  r9,  r10, r11, r12, r13, r14, r15
-    };
-
-    /* Parameter State Space
-     *
-     * The parameter (.param) state space is used (1) to pass input
-     * arguments from the host to the kernel, (2a) to declare formal
-     * input and return parameters for device functions called from
-     * within kernel execution, and (2b) to declare locally-scoped
-     * byte array variables that serve as function call arguments,
-     * typically for passing large structures by value to a function.
-     *
-     * TODO: XXX
-     * The parameters are virtual symbols - just like registers. Bit,
-     * Till we figure out how to model a virtual register set in Graal,
-     * we will pretend that we can use only 8 parameters.
-    */
-
-    public static final Register param0  = new Register(16, 16,  "param0",  PARAM);
-    public static final Register param1  = new Register(17, 17,  "param1",  PARAM);
-    public static final Register param2  = new Register(18, 18,  "param2",  PARAM);
-    public static final Register param3  = new Register(19, 19,  "param3",  PARAM);
-    public static final Register param4  = new Register(20, 20,  "param4",  PARAM);
-    public static final Register param5  = new Register(21, 21,  "param5",  PARAM);
-    public static final Register param6  = new Register(22, 22,  "param6",  PARAM);
-    public static final Register param7  = new Register(23, 23,  "param7",  PARAM);
-
-    public static final Register[] paramRegisters = {
-        param0,  param1,  param2,  param3,  param4,  param5,  param6,  param7
-    };
-
-    // Define a virtual register that holds return value
-    public static final Register retReg = new Register(24, 24, "retReg", REG);
-
-    // PTX ISA Manual: Section 9:. Special Registers
-
-    // PTX includes a number of predefined, read-only variables, which
-    // are visible as special registers and accessed through mov or
-    // cvt instructions.
-    // Thread identifier within a Co-operative Thread Array (CTA) - %tid
-    public static final Register tid  = new Register(100,  100,  "tid", SREG);
-    // Number of thread IDs per CTA - %ntid
-    public static final Register ntid    = new Register(101, 101, "ntid", SREG);
-    // Lane identifier
-    public static final Register laneid  = new Register(102, 102, "laneid", SREG);
-    // Warp identifier
-    public static final Register warpid   = new Register(103, 103, "warid", SREG);
-    // Number of warp IDs
-    public static final Register nwarpid   = new Register(104, 104, "nwarpid", SREG);
-    // CTA identifier
-    public static final Register ctaid   = new Register(105, 105, "ctaid", SREG);
-    // Number of CTA IDs per grid
-    public static final Register nctaid   = new Register(106, 106, "nctaid", SREG);
-    // Single Multiprocessor (SM) ID
-    public static final Register smid    = new Register(107, 107, "smid", SREG);
-    // Number of SM IDs
-    public static final Register nsmid   = new Register(108, 108, "nsmid", SREG);
-    // Grid ID
-    public static final Register gridid  = new Register(109, 109, "gridid", SREG);
-    // 32-bit mask with bit set in position equal to thread's lane number in the warp
-    public static final Register lanemask_eq  = new Register(110, 110, "lanemask_eq", SREG);
-    // 32-bit mask with bits set in positions less than or equal to thread's lane number in the warp
-    public static final Register lanemask_le  = new Register(111, 111, "lanemask_le", SREG);
-    // 32-bit mask with bits set in positions less than thread's lane number in the warp
-    public static final Register lanemask_lt  = new Register(112, 112, "lanemask_lt", SREG);
-    // 32-bit mask with bits set in positions greater than or equal to thread's lane number in the warp
-    public static final Register lanemask_ge  = new Register(113, 113, "lanemask_ge", SREG);
-    // 32-bit mask with bits set in positions greater than thread's lane number in the warp
-    public static final Register lanemask_gt  = new Register(114, 114, "lanemask_gt", SREG);
-    // A predefined, read-only 32-bit unsigned 32-bit unsigned cycle counter
-    public static final Register clock  = new Register(114, 114, "clock", SREG);
-    // A predefined, read-only 64-bit unsigned 32-bit unsigned cycle counter
-    public static final Register clock64  = new Register(115, 115, "clock64", SREG);
-    // Performance monitoring registers
-    public static final Register pm0  = new Register(116, 116,  "pm0", SREG);
-    public static final Register pm1  = new Register(117, 117,  "pm1", SREG);
-    public static final Register pm2  = new Register(118, 118,  "pm2", SREG);
-    public static final Register pm3  = new Register(119, 119,  "pm3", SREG);
-    public static final Register pm4  = new Register(120, 120,  "pm4", SREG);
-    public static final Register pm5  = new Register(121, 121,  "pm5", SREG);
-    public static final Register pm6  = new Register(122, 122,  "pm6", SREG);
-    public static final Register pm7  = new Register(123, 123,  "pm7", SREG);
-    // TODO: Add Driver-defined read-only %envreg<32>
-    //       and %globaltimer, %globaltimer_lo and %globaltimer_hi
-
-    public static final Register[] specialRegisters = {
-        tid, ntid, laneid, warpid, nwarpid, ctaid,
-        nctaid, smid, nsmid, gridid,
-        lanemask_eq, lanemask_le, lanemask_lt, lanemask_ge, lanemask_gt,
-        clock, clock64,
-        pm0, pm1, pm2, pm3, pm4, pm5, pm6, pm7
-    };
-
-    public static final Register[] allRegisters = {
-        // Parameter State Space
-        param0, param1, param2, param3,
-        param4, param5, param6, param7,
-        // Register State Space
-        r0,  r1,  r2,  r3,  r4,  r5,  r6,  r7,
-        r8,  r9,  r10, r11, r12, r13, r14, r15,
-        // return register
-        retReg,
-        // Special Register State Space - SREG
-        tid, ntid, laneid, warpid, nwarpid, ctaid,
-        nctaid, smid, nsmid, gridid,
-        lanemask_eq, lanemask_le, lanemask_lt, lanemask_ge, lanemask_gt,
-        clock, clock64,
-        pm0, pm1, pm2, pm3, pm4, pm5, pm6, pm7
-    };
-
-    // @formatter:on
-
-    public PTX() {
-        super("PTX", 8, ByteOrder.LITTLE_ENDIAN, false, allRegisters, LOAD_STORE | STORE_STORE, 0, r15.encoding + 1, 8);
-    }
-
-    @Override
-    public boolean canStoreValue(RegisterCategory category, PlatformKind lirKind) {
-        if (!(lirKind instanceof Kind)) {
-            return false;
-        }
-
-        Kind kind = (Kind) lirKind;
-        if (category.equals(REG)) {
-            switch (kind) {
-                case Boolean:
-                case Byte:
-                case Char:
-                case Short:
-                case Int:
-                case Long:
-                case Object:
-                case Float:
-                case Double:
-                    return true;
-            }
-        }
-
-        return false;
-    }
-
-    @Override
-    public PlatformKind getLargestStorableKind(RegisterCategory category) {
-        if (category.equals(REG)) {
-            return Kind.Double;
-        } else {
-            return Kind.Illegal;
-        }
-    }
-
-}
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64CountLeadingZerosNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64CountLeadingZerosNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
  * Count the number of leading zeros.
  */
 @NodeInfo
-public class AMD64CountLeadingZerosNode extends UnaryNode implements LIRLowerable {
+public final class AMD64CountLeadingZerosNode extends UnaryNode implements LIRLowerable {
 
     public AMD64CountLeadingZerosNode(ValueNode value) {
         super(StampFactory.forInteger(Kind.Int, 0, ((PrimitiveStamp) value.stamp()).getBits()), value);
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64CountTrailingZerosNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64CountTrailingZerosNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
  * Count the number of trailing zeros.
  */
 @NodeInfo
-public class AMD64CountTrailingZerosNode extends UnaryNode implements LIRLowerable {
+public final class AMD64CountTrailingZerosNode extends UnaryNode implements LIRLowerable {
 
     public AMD64CountTrailingZerosNode(ValueNode value) {
         super(StampFactory.forInteger(Kind.Int, 0, ((PrimitiveStamp) value.stamp()).getBits()), value);
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64FloatConvertNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64FloatConvertNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * fixup code that handles the corner cases that differ between AMD64 and Java.
  */
 @NodeInfo
-public class AMD64FloatConvertNode extends UnaryArithmeticNode<FloatConvertOp> implements ArithmeticLIRLowerable {
+public final class AMD64FloatConvertNode extends UnaryArithmeticNode<FloatConvertOp> implements ArithmeticLIRLowerable {
 
     protected final FloatConvert op;
 
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathIntrinsicsNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * 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.replacements.hsail;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.compiler.hsail.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.lir.gen.*;
-import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.nodeinfo.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
-import com.oracle.graal.nodes.spi.*;
-
-/**
- * This node implements HSAIL intrinsics for specific {@link Math} routines.
- */
-@NodeInfo
-public class HSAILMathIntrinsicsNode extends FloatingNode implements Canonicalizable, ArithmeticLIRLowerable {
-
-    /**
-     * The parameter passed to the math operation that this node represents.
-     */
-    @Input ValueNode param;
-
-    /**
-     * The math operation that this Node represents.
-     */
-    protected final HSAILArithmetic operation;
-
-    /**
-     * Gets the parameter passed to the math operation that this node represents.
-     *
-     * @return the parameter
-     */
-    public ValueNode getParameter() {
-        return param;
-    }
-
-    /**
-     * Returns the math operation represented by this node.
-     *
-     * @return the operation
-     */
-    public HSAILArithmetic operation() {
-        return operation;
-    }
-
-    public HSAILMathIntrinsicsNode(ValueNode x, HSAILArithmetic op) {
-        super(StampFactory.forKind(x.getKind()));
-        this.param = x;
-        this.operation = op;
-    }
-
-    /**
-     * Generates the LIR instructions for the math operation represented by this node.
-     */
-    @Override
-    public void generate(NodeMappableLIRBuilder builder, ArithmeticLIRGenerator gen) {
-        Value input = builder.operand(getParameter());
-        Value result;
-        switch (operation()) {
-            case ABS:
-                result = gen.emitMathAbs(input);
-                break;
-            case CEIL:
-                result = ((HSAILLIRGenerator) gen).emitMathCeil(input);
-                break;
-            case FLOOR:
-                result = ((HSAILLIRGenerator) gen).emitMathFloor(input);
-                break;
-            case RINT:
-                result = ((HSAILLIRGenerator) gen).emitMathRint(input);
-                break;
-            case SQRT:
-                result = gen.emitMathSqrt(input);
-                break;
-
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        builder.setResult(this, result);
-    }
-
-    /**
-     * Converts the result of the math operation to a boxed Double constant node.
-     */
-    @Override
-    public Node canonical(CanonicalizerTool tool) {
-        if (getParameter().isConstant()) {
-            double ret = compute(getParameter().asJavaConstant().asDouble(), operation());
-            return ConstantNode.forDouble(ret);
-        }
-        return this;
-    }
-
-    // The routines below are node intrinsics. A call to any of these routines is replaced by a
-    // HSAILMathIntrinsicNode to handle the Math library operation represented by the
-    // HSAILArithmetic argument.
-
-    /**
-     * Node intrinsic for {@link Math} routines taking a single int parameter.
-     *
-     * @param value
-     * @param op the math operation
-     * @return the result of the operation
-     */
-    @NodeIntrinsic
-    public static native int compute(int value, @ConstantNodeParameter HSAILArithmetic op);
-
-    /**
-     * Node intrinsic for {@link Math} routines taking a single double parameter.
-     *
-     * @param value the input parameter
-     * @param op the math operation
-     * @return the result of the operation
-     */
-    @NodeIntrinsic
-    public static native long compute(long value, @ConstantNodeParameter HSAILArithmetic op);
-
-    /**
-     * Node intrinsic for {@link Math} routines taking a single float parameter.
-     *
-     * @param value the input parameter
-     * @param op the math operation
-     * @return the result of the operation
-     */
-    @NodeIntrinsic
-    public static native float compute(float value, @ConstantNodeParameter HSAILArithmetic op);
-
-    /**
-     * Node intrinsic for {@link Math} routines taking a single double parameter.
-     *
-     * @param value the input parameter
-     * @param op the math operation
-     *
-     * @return the result of the operation
-     */
-    @NodeIntrinsic
-    public static native double compute(double value, @ConstantNodeParameter HSAILArithmetic op);
-
-}
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/HSAILMathSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +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.replacements.hsail;
-
-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
- * with {@link MethodSubstitution}, Graal replaces the call with a {@link HSAILMathIntrinsicsNode}.
- */
-@ClassSubstitution(java.lang.Math.class)
-public class HSAILMathSubstitutions {
-
-    /**
-     * Substitution for {@link Math#abs(int)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static int abs(int x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.ABS);
-    }
-
-    /**
-     * Substitution for {@link Math#abs(long)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static long abs(long x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.ABS);
-    }
-
-    /**
-     * Substitution for {@link Math#abs(float)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static float abs(float x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.ABS);
-    }
-
-    /**
-     * Substitution for {@link Math#abs(double)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static double abs(double x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.ABS);
-    }
-
-    /**
-     * Substitution for Math.ceil(double).
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static double ceil(double x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.CEIL);
-    }
-
-    /**
-     * Substitution for {@link Math#floor(double)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static double floor(double x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.FLOOR);
-    }
-
-    /**
-     * Substitution for {@link Math#rint(double)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static double rint(double x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.RINT);
-    }
-
-    /**
-     * Substitution for {@link Math#sqrt(double)}.
-     *
-     * @param x the input
-     * @return the result of the computation
-     */
-    @MethodSubstitution
-    public static double sqrt(double x) {
-        return HSAILMathIntrinsicsNode.compute(x, HSAILArithmetic.SQRT);
-    }
-
-    /**
-     * Methods below this point are more complicated transcendentals and such and use
-     * {@link JStrictMath} for method substitution.
-     */
-
-    @MethodSubstitution
-    public static double sin(double x) {
-        return JStrictMath.sin(x);
-    }
-
-    @MethodSubstitution
-    public static double cos(double x) {
-        return JStrictMath.cos(x);
-    }
-
-    @MethodSubstitution
-    public static double tan(double x) {
-        return JStrictMath.tan(x);
-    }
-
-    @MethodSubstitution
-    public static double exp(double x) {
-        return JStrictMath.exp(x);
-    }
-
-    @MethodSubstitution
-    public static double expm1(double x) {
-        return JStrictMath.expm1(x);
-    }
-
-    @MethodSubstitution
-    public static double log(double x) {
-        return JStrictMath.log(x);
-    }
-
-    @MethodSubstitution
-    public static double log10(double x) {
-        return JStrictMath.log10(x);
-    }
-
-    @MethodSubstitution
-    public static double cbrt(double x) {
-        return JStrictMath.cbrt(x);
-    }
-
-    @MethodSubstitution
-    public static double asin(double x) {
-        return JStrictMath.asin(x);
-    }
-
-    @MethodSubstitution
-    public static double acos(double x) {
-        return JStrictMath.acos(x);
-    }
-
-    @MethodSubstitution
-    public static double atan(double x) {
-        return JStrictMath.atan(x);
-    }
-
-    @MethodSubstitution
-    public static double atan2(double x, double y) {
-        return JStrictMath.atan2(x, y);
-    }
-
-    @MethodSubstitution
-    public static double pow(double x, double y) {
-        return JStrictMath.pow(x, y);
-    }
-
-    // Checkstyle: stop
-    @MethodSubstitution
-    public static double IEEEremainder(double x, double y) {
-        return JStrictMath.IEEEremainder(x, y);
-    }
-
-    // Checkstyle: resume
-
-    @MethodSubstitution
-    public static double sinh(double x) {
-        return JStrictMath.sinh(x);
-    }
-
-    @MethodSubstitution
-    public static double cosh(double x) {
-        return JStrictMath.cosh(x);
-    }
-
-    @MethodSubstitution
-    public static double tanh(double x) {
-        return JStrictMath.tanh(x);
-    }
-
-    @MethodSubstitution
-    public static double hypot(double x, double y) {
-        return JStrictMath.hypot(x, y);
-    }
-
-}
--- a/graal/com.oracle.graal.replacements.hsail/src/com/oracle/graal/replacements/hsail/JStrictMath.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3393 +0,0 @@
-/*
- * 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.hsail;
-
-import java.util.*;
-
-import sun.misc.*;
-
-import com.oracle.graal.api.replacements.*;
-
-// Checkstyle: stop
-
-/**
- * This class contains methods for performing basic numeric operations such as the elementary
- * exponential, logarithm, square root, and trigonometric functions. It is a Java port of the native
- * methods in {@link StrictMath} and can thus be used by Graal backends to provide
- * {@link MethodSubstitution}s for the native methods.
- *
- * <p>
- * To help ensure portability of Java programs, the definitions of some of the numeric functions in
- * this package require that they produce the same results as certain published algorithms. These
- * algorithms are available from the well-known network library {@code netlib} as the package
- * "Freely Distributable Math Library," <a href="ftp://ftp.netlib.org/fdlibm.tar">{@code fdlibm}
- * </a>. These algorithms, which were originally written in the C programming language, are then to
- * be understood as executed with all floating-point operations following the rules of Java
- * floating-point arithmetic.
- *
- * <p>
- * The Java math library is defined with respect to {@code fdlibm} version 5.3. Where {@code fdlibm}
- * provides more than one definition for a function (such as {@code acos}), use the
- * "IEEE 754 core function" version (residing in a file whose name begins with the letter {@code e}
- * ). The methods which require {@code fdlibm} semantics are {@link #sin}, {@link #cos},
- * {@link #tan}, {@link #asin}, {@link #acos}, {@link #atan}, {@link #exp}, {@link #log},
- * {@link #log10}, {@link #cbrt}, {@link #atan2}, {@link #pow}, {@link #sinh}, {@link #cosh},
- * {@link #tanh}, {@link #hypot}, {@link #expm1}, and {@link #log1p}.
- *
- * @author Gustav Trede (port to Java)
- */
-// JaCoCo Exclude
-public final class JStrictMath {
-
-    /**
-     * Don't let anyone instantiate this class.
-     */
-    private JStrictMath() {
-    }
-
-    /**
-     * The {@code double} value that is closer than any other to <i>e</i>, the base of the natural
-     * logarithms.
-     */
-    public static final double E = 2.7182818284590452354;
-    /**
-     * The {@code double} value that is closer than any other to <i>pi</i>, the ratio of the
-     * circumference of a circle to its diameter.
-     */
-    public static final double PI = 3.14159265358979323846;
-
-    /**
-     * Returns the trigonometric sine of an angle. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or an infinity, then the result is NaN.
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     * </ul>
-     *
-     * @param a an angle, in radians.
-     * @return the sine of the argument.
-     */
-    @SuppressWarnings("javadoc")
-    public static double sin(double x) {
-        int hx = (int) (Double.doubleToRawLongBits(x) >> 32);
-        int ix = hx & 0x7fffffff;
-        if (ix >= 0x7ff00000) {
-            // x is inf or NaN
-            return Double.NaN;
-        }
-        return ix <= 0x3fe921fb ? __kernel_sin_(x, ix) : __ieee754_rem_pio2_(x, hx, sintype);
-    }
-
-    /**
-     * Returns the trigonometric cosine of an angle. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or an infinity, then the result is NaN.
-     * </ul>
-     *
-     * @param x an angle, in radians.
-     * @return the cosine of the argument.
-     */
-    public static double cos(double x) {
-        int hx = (int) (Double.doubleToRawLongBits(x) >> 32);
-        int ix = hx & 0x7fffffff;
-        if (ix >= 0x7ff00000) {
-            // x is inf or NaN
-            return Double.NaN;
-        }
-        return ix <= 0x3fe921fb ? __kernel_cos_(x, 0, ix) : __ieee754_rem_pio2_(x, hx, costype);
-    }
-
-    /**
-     * Returns the trigonometric tangent of an angle. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or an infinity, then the result is NaN.
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     * </ul>
-     *
-     * @param x an angle, in radians.
-     * @return the tangent of the argument.
-     */
-    public static double tan(double x) {
-        final int hx = (int) (Double.doubleToRawLongBits(x) >> 32);
-        int ix = hx & 0x7fffffff;
-        if (ix >= 0x7ff00000) {
-            // x is inf or NaN
-            return Double.NaN;
-        }
-        return ix <= 0x3fe921fb ? __kernel_tan(x, 0d, 1, hx) : __ieee754_rem_pio2_(x, hx, tantype);
-    }
-
-    /**
-     * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
-     *
-     * Algorithm 1. Since tan(-x) = -tan(x), we need only to consider positive x. 2. if x < 2^-28
-     * (hx<0x3e300000 0), return x with inexact if x!=0. 3. tan(x) is approximated by a odd
-     * polynomial of degree 27 on [0,0.67434] 3 27 tan(x) ~ x + T1*x + ... + T13*x where
-     *
-     * |tan(x) 2 4 26 | -59.2 |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 | x |
-     *
-     * Note: tan(x+y) = tan(x) + tan'(x)*y ~ tan(x) + (1+x*x)*y Therefore, for better accuracy in
-     * computing tan(x+y), let 3 2 2 2 2 r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) then 3 2
-     * tan(x+y) = x + (T1*x + (x *(r+y)+y))
-     *
-     * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then tan(x) = tan(pi/4-y) =
-     * (1-tan(y))/(1+tan(y)) = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
-     *
-     * @param xx is assumed to be bounded by ~pi/4 in magnitude.
-     * @param yy is the tail of x
-     * @param k indicates whether tan (if k=1) or -1/tan (if k= -1) is returned.
-     * @param hx high bits of x
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double __kernel_tan(double xx, double yy, int k, int hx) {
-        double w, r;
-        double x = xx;
-        double y = yy;
-        final int ix = hx & 0x7fffffff;
-        if (ix < 0x3e300000 && (int) x == 0) { // |x| < 2**-28
-            if (k == 1) {
-                return x;
-            }
-            if ((ix | hx) == 0) {
-                return one / abs(x); // generate inexact
-            }
-            // compute -1 / (x+y) carefully
-            r = y;
-            w = x + y;
-        } else {
-            if (ix >= 0x3FE59428) { // |x|>=0.67434
-                if (hx < 0) {
-                    x = 0.0d - x;
-                    y = 0.0d - y;
-                }
-                x = (pio4 - x) + (pio4lo - y);
-                y = 0.0;
-            }
-            final double z = x * x;
-            w = z * z;
-
-            /*
-             * Break x^5*(T[1]+x^2*T[2]+...) into x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
-             * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
-             */
-
-            final double s = z * x;
-            double v = z * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12)))));
-            r = (y + z * (s * ((T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11))))) + v) + y)) + T0 * s;
-            w = x + r;
-            if (ix >= 0x3FE59428) {
-                v = k;
-                return (1 - ((hx >> 30) & 2)) * (v - 2.0d * (x - (((w * w) / (w + v)) - r)));
-            }
-            if (k == 1) {
-                return w;
-            }
-            // if allow error up to 2 ulp, simply return -1.0/(x+r) here
-        }
-        // compute -1.0/(x+r) accurately
-        final double a = negone / w;
-        final double t = clearLow32bits(a);
-        final double z = clearLow32bits(w);
-        return t + a * ((1.0d + t * z) + t * (r - (z - x)));
-    }
-
-    private static final double S1 = -1.66666666666666324348e-01, S2 = 8.33333333332248946124e-03, /*
-                                                                                                    * 0x3F811111
-                                                                                                    * ,
-                                                                                                    * 0x1110F8A6
-                                                                                                    */
-    S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
-    S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
-    S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
-    S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
-
-    /**
-     * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 Input x is assumed to be bounded by ~pi/4
-     * in magnitude. Input y is the tail of x. Input iy indicates whether y is 0. (if iy=0, y assume
-     * to be 0).
-     *
-     * Algorithm 1. Since sin(-x) = -sin(x), we need only to consider positive x. 2. if x < 2^-27
-     * (hx<0x3e400000 0), return x with inexact if x!=0. 3. sin(x) is approximated by a polynomial
-     * of degree 13 on [0,pi/4] 3 13 sin(x) ~ x + S1*x + ... + S6*x where
-     *
-     * |sin(x) 2 4 6 8 10 12 | -58 |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 | x |
-     *
-     * 4. sin(x+y) = sin(x) + sin'(x')*y ~ sin(x) + (1-x*x/2)*y For better accuracy, let 3 2 2 2 2 r
-     * = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) then 3 2 sin(x) = x + (S1*x + (x *(r-y/2)+y))
-     *
-     * @param x
-     * @param y
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double __kernel_sin(double x, double y, int ix) {
-        if (ix < 0x3e400000 && (int) x == 0) {
-            return x; // |x| < 2**-27 generate inexact
-        }
-        final double z = x * x;
-        final double v = z * x;
-        final double r = v * (S2 + z * (S3 + z * (S4 + z * (S5 + z * S6))));
-        return x - ((z * (half * y - r) - y) - v * S1);
-    }
-
-    private static double __kernel_sin_(double x, int ix) {
-        if (ix < 0x3e400000 && (int) x == 0) {
-            return x; // |x| < 2**-27 generate inexact
-        }
-        final double z = x * x;
-        return x + (z * x) * (S1 + z * (S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)))));
-    }
-
-    private static final double two = 2.0d, one = Double.longBitsToDouble(0x3ff0000000000000L), negone = -one, C1 = 4.16666666666666019037e-02, C2 = -1.38888888888741095749e-03,
-                    C3 = 2.48015872894767294178e-05, C4 = -2.75573143513906633035e-07, C5 = 2.08757232129817482790e-09, C6 = -1.13596475577881948265e-11;
-
-    /**
-     * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 Input x is assumed to be bounded by
-     * ~pi/4 in magnitude. Input y is the tail of x.
-     *
-     * Algorithm 1. Since cos(-x) = cos(x), we need only to consider positive x. 2. if x < 2^-27
-     * (hx<0x3e400000 0), return 1 with inexact if x!=0. 3. cos(x) is approximated by a polynomial
-     * of degree 14 on [0,pi/4] 4 14 cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x where the remez error is
-     *
-     * | 2 4 6 8 10 12 14 | -58 |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 | |
-     *
-     * 4 6 8 10 12 14 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then cos(x) = 1 - x*x/2 + r
-     * since cos(x+y) ~ cos(x) - sin(x)*y ~ cos(x) - x*y, a correction term is necessary in cos(x)
-     * and hence cos(x+y) = 1 - (x*x/2 - (r - x*y)) For better accuracy when x > 0.3, let qx = |x|/4
-     * with the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125. Then cos(x+y) = (1-qx)
-     * - ((x*x/2-qx) - (r-x*y)). Note that 1-qx and (x*x/2-qx) is EXACT here, and the magnitude of
-     * the latter is at least a quarter of x*x/2, thus, reducing the rounding error in the
-     * subtraction.
-     *
-     * @param x
-     * @param y
-     * @param ix
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double __kernel_cos_(double x, double y, int ix) {
-        if (ix < 0x3e400000 && ((int) x) == 0) {
-            return one; // x < 2**27 generate inexact
-        }
-        final double z = x * x;
-        double r = z * (z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))))) - x * y;
-        if (ix < 0x3FD33333) { // |x| < 0.3
-            return one - (0.5 * z - r);
-        }
-        final double qx = ix > 0x3fe90000 ? 0.28125 : // x > 0.78125
-                        Double.longBitsToDouble((long) (ix - 0x00200000) << 32); // x/4
-        return (one - qx) - ((0.5 * z - qx) - r);
-    }
-
-    private static final int sintype = 0;
-    private static final int costype = 1;
-    private static final int tantype = 3;
-
-    /**
-     * Returns final values for tan , cos and sin.
-     *
-     * @param trigtype
-     * @param NN
-     * @param y0
-     * @param y1
-     * @author gustav trede
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double getTrigres(int trigtype, int NN, double y0, double y1) {
-        int N = NN;
-        int hx = ((int) (Double.doubleToRawLongBits(y0) >> 32));
-        if (trigtype == tantype) {
-            return __kernel_tan(y0, y1, 1 - ((N & 1) << 1), hx);
-        }
-        hx &= 0x7fffffff;
-        N = (N & 3) - trigtype;
-        double v = (N == 0 || N == 2) ? __kernel_sin(y0, y1, hx) : __kernel_cos_(y0, y1, hx);
-
-        if (N == 0 || N == 1) {
-            return trigtype == 0 ? v : 0.0d - v;
-        }
-        return trigtype == 0 ? 0.0d - v : v;
-    }
-
-    private static final double pio4 = 7.85398163397448278999e-01, pio4lo = 3.06161699786838301793e-17, T0 = 3.33333333333334091986e-01, T1 = 1.33333333333201242699e-01,
-                    T2 = 5.39682539762260521377e-02, T3 = 2.18694882948595424599e-02, T4 = 8.86323982359930005737e-03, T5 = 3.59207910759131235356e-03, T6 = 1.45620945432529025516e-03,
-                    T7 = 5.88041240820264096874e-04, T8 = 2.46463134818469906812e-04, T9 = 7.81794442939557092300e-05, T10 = 7.14072491382608190305e-05, T11 = -1.85586374855275456654e-05,
-                    T12 = 2.59073051863633712884e-05;
-
-    /*
-     * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
-     */
-    private static final int[] two_over_pi = {0xa2f983, 0x6e4e44, 0x1529fc, 0x2757d1, 0xf534dd, 0xc0db62, 0x95993c, 0x439041, 0xfe5163, 0xabdebb, 0xc561b7, 0x246e3a, 0x424dd2, 0xe00649, 0x2eea09,
-                    0xd1921c, 0xfe1deb, 0x1cb129, 0xa73ee8, 0x8235f5, 0x2ebb44, 0x84e99c, 0x7026b4, 0x5f7e41, 0x3991d6, 0x398353, 0x39f49c, 0x845f8b, 0xbdf928, 0x3b1ff8, 0x97ffde, 0x05980f, 0xef2f11,
-                    0x8b5a0a, 0x6d1f6d, 0x367ecf, 0x27cb09, 0xb74f46, 0x3f669e, 0x5fea2d, 0x7527ba, 0xc7ebe5, 0xf17b3d, 0x0739f7, 0x8a5292, 0xea6bfb, 0x5fb11f, 0x8d5d08, 0x560330, 0x46fc7b, 0x6babf0,
-                    0xcfbc20, 0x9af436, 0x1da9e3, 0x91615e, 0xe61b08, 0x659985, 0x5f14a0, 0x68408d, 0xffd880, 0x4d7327, 0x310606, 0x1556ca, 0x73a8c9, 0x60e27b, 0xc08c6b};
-
-    private static final int[] npio2_hw = {0x3ff921fb, 0x400921fb, 0x4012d97c, 0x401921fb, 0x401f6a7a, 0x4022d97c, 0x4025fdbb, 0x402921fb, 0x402c463a, 0x402f6a7a, 0x4031475c, 0x4032d97c, 0x40346b9c,
-                    0x4035fdbb, 0x40378fdb, 0x403921fb, 0x403ab41b, 0x403c463a, 0x403dd85a, 0x403f6a7a, 0x40407e4c, 0x4041475c, 0x4042106c, 0x4042d97c, 0x4043a28c, 0x40446b9c, 0x404534ac, 0x4045fdbb,
-                    0x4046c6cb, 0x40478fdb, 0x404858eb, 0x404921fb};
-
-    private static final double zero = 0.00000000000000000000e+00, half = 5.00000000000000000000e-01,
-    /* 1.67772160000000000000e+07 */
-    two24 = Double.longBitsToDouble(0x4170000000000000L),
-    /* 6.36619772367581382433e-01 53 bits of 2/pi */
-    invpio2 = Double.longBitsToDouble(0x3fe45f306dc9c883L),
-    /* 1.57079632673412561417e+00 first 33 bit of pi/2 */
-    pio2_1 = Double.longBitsToDouble(0x3ff921fb54400000L),
-    /* 6.07710050650619224932e-11 pi/2 - pio2_1 */
-    pio2_1t = Double.longBitsToDouble(0x3dd0b4611a626331L),
-    /* 6.07710050630396597660e-11 second 33 bit of pi/2 */
-    pio2_2 = Double.longBitsToDouble(0x3dd0b4611a600000L),
-    /* 2.02226624879595063154e-21 pi/2 - (pio2_1+pio2_2) */
-    pio2_2t = Double.longBitsToDouble(0x3ba3198a2e037073L),
-    /* 2.02226624871116645580e-21 third 33 bit of pi/2 */
-    pio2_3 = Double.longBitsToDouble(0x3ba3198a2e000000L),
-    /* 8.47842766036889956997e-32 pi/2 - (pio2_1+pio2_2+pio2_3) */
-    pio2_3t = Double.longBitsToDouble(0x397b839a252049c1L);
-
-    private static double __ieee754_rem_pio2_(double xx, int hx, int trigtype) {
-        double x = xx;
-        int ix = hx & 0x7fffffff;
-        if (ix <= 0x413921fb) { // |x| ~<= 2^19*(pi/2)
-            double y0, y1;
-            int n;
-            if (ix < 0x4002d97c) { // |x| < 3pi/4, special case with n=+-1
-                if (hx > 0) {
-                    x -= pio2_1;
-                    if (ix != 0x3ff921fb) { // 33+53 bit pi is good enough
-                        y0 = x - pio2_1t;
-                        y1 = (x - y0) - pio2_1t;
-                    } else { // near pi/2, use 33+33+53 bit pi
-                        x -= pio2_2;
-                        y0 = x - pio2_2t;
-                        y1 = (x - y0) - pio2_2t;
-                    }
-                    n = 1;
-                } else { // negative x
-                    x += pio2_1;
-                    if (ix != 0x3ff921fb) { // 33+53 bit pi is good enough
-                        y0 = x + pio2_1t;
-                        y1 = (x - y0) + pio2_1t;
-                    } else { // near pi/2, use 33+33+53 bit pi
-                        x += pio2_2;
-                        y0 = x + pio2_2t;
-                        y1 = (x - y0) + pio2_2t;
-                    }
-                    n = -1;
-                }
-            } else {
-                double t = abs(x);
-                n = (int) (t * invpio2 + half);
-                final double fn = n;
-                double w = fn * pio2_1t; // 1st round good to 85 bit
-                double r = t - fn * pio2_1;
-                y0 = r - w;
-                // quick check no cancellation
-                if (n >= 32 || ix == npio2_hw[n - 1]) {
-                    int i = ix - (((int) (Double.doubleToRawLongBits(y0) >> 32)) & (0x7ff << 20));
-                    if (i > (16 << 20)) { // 2nd iteration needed, good to 118
-                        w = fn * pio2_2;
-                        t = r;
-                        r -= w;
-                        w = fn * pio2_2t - ((t - r) - w);
-                        y0 = r - w;
-                        i = ix - (((int) (Double.doubleToRawLongBits(y0) >> 32)) & (0x7ff << 20));
-                        if (i > (49 << 20)) {// 3rd iteration need, 151 bits acc
-                            w = fn * pio2_3;
-                            t = r;
-                            r -= w;
-                            w = fn * pio2_3t - ((t - r) - w);
-                            y0 = r - w;
-                        }
-                    }
-                }
-                y1 = (r - y0) - w;
-                if (hx < 0) {
-                    y1 = 0.0d - y1;
-                    y0 = 0.0d - y0;
-                    n = -n;
-                }
-            }
-            return getTrigres(trigtype, n, y0, y1);
-        }
-
-        return ix >= 0x7ff00000 ? x - x : // x is inf or NaN
-                        __kernel_rem_pio2(x, hx, trigtype);
-    }
-
-    private static final double[] PIo2 = {1.57079625129699707031e+00, 7.54978941586159635335e-08, 5.39030252995776476554e-15, 3.28200341580791294123e-22, 1.27065575308067607349e-29,
-                    1.22933308981111328932e-36, 2.73370053816464559624e-44, 2.16741683877804819444e-51};
-
-    private static final double twon24 = 5.96046447753906250000e-08;
-
-    /**
-     * Used for tlocal storage to save __kernel_rem_pio2 from major mem allocs.
-     *
-     * @author gustav trede
-     */
-    private static class Rempiostruct {
-        final double[] f = new double[20];
-        final double[] q = new double[20];
-        final double[] fq = new double[20];
-        final double[] x = new double[3];
-        final int[] iq = new int[20];
-    }
-
-    /*******
-     * private static final ThreadLocal<Rempiostruct> rempstruct = new ThreadLocal<Rempiostruct>() {
-     *
-     * @Override protected Rempiostruct initialValue() { return new Rempiostruct(); } };
-     *******/
-
-    private static class RempStructAcccessor {
-        Rempiostruct get() {
-            return new Rempiostruct();
-        }
-    }
-
-    static RempStructAcccessor rempstruct;
-
-    /**
-     *
-     * __kernel_rem_pio2 return the last three digits of N with y = x - N*pi/2 so that |y| < pi/2.
-     *
-     * The method is to compute the integer (mod 8) and fraction parts of (2/pi)*x without doing the
-     * full multiplication. In general we skip the part of the product that are known to be a huge
-     * integer (more accurately, = 0 mod 8 ). Thus the number of operations are independent of the
-     * exponent of the input.
-     *
-     * (2/pi) is represented by an array of 24-bit integers in two_over_pi[].
-     *
-     * Input parameters: x[] The input value (must be positive) is broken into nx pieces of 24-bit
-     * integers in double precision format. x[i] will be the i-th 24 bit of x. The scaled exponent
-     * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 match x's up to 24 bits.
-     *
-     * Example of breaking a double positive z into x[0]+x[1]+x[2]: e0 = ilogb(z)-23 z =
-     * scalbn(z,-e0) for i = 0,1,2 x[i] = floor(z) z = (z-x[i])*2**24
-     *
-     *
-     * y[] ouput result in an array of double precision numbers. The dimension of y[] is: 24-bit
-     * precision 1 53-bit precision 2 64-bit precision 2 113-bit precision 3 The actual value is the
-     * sum of them. Thus for 113-bit precison, one may have to do something like:
-     *
-     * long double t,w,r_head, r_tail; t = (long double)y[2] + (long double)y[1]; w = (long
-     * double)y[0]; r_head = t+w; r_tail = w - (r_head - t);
-     *
-     * e0 The exponent of x[0]
-     *
-     * nx dimension of x[]
-     *
-     * prec an integer indicating the precision: 0 24 bits (single) 1 53 bits (double) 2 64 bits
-     * (extended) 3 113 bits (quad)
-     *
-     * two_over_pi[] integer array, contains the (24*i)-th to (24*i+23)-th bit of 2/pi after binary
-     * point. The corresponding floating value is
-     *
-     * two_over_pi[i] * 2^(-24(i+1)).
-     *
-     * External function: double scalbn(), floor();
-     *
-     *
-     * Here is the description of some local variables:
-     *
-     * jk jk+1 is the initial number of terms of two_over_pi[] needed in the computation. The
-     * recommended value is 2,3,4, 6 for single, double, extended,and quad.
-     *
-     * jz local integer variable indicating the number of terms of two_over_pi[] used.
-     *
-     * jx nx - 1
-     *
-     * jv index for pointing to the suitable two_over_pi[] for the computation. In general, we want
-     * ( 2^e0*x[0] * two_over_pi[jv-1]*2^(-24jv) )/8 is an integer. Thus e0-3-24*jv >= 0 or
-     * (e0-3)/24 >= jv Hence jv = max(0,(e0-3)/24).
-     *
-     * jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
-     *
-     * q[] double array with integral value, representing the 24-bits chunk of the product of x and
-     * 2/pi.
-     *
-     * q0 the corresponding exponent of q[0]. Note that the exponent for q[i] would be q0-24*i.
-     *
-     * PIo2[] double precision array, obtained by cutting pi/2 into 24 bits chunks.
-     *
-     * f[] two_over_pi[] in floating point
-     *
-     * iq[] integer array by breaking up q[] in 24-bits chunk.
-     *
-     * fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
-     *
-     * ih integer. If >0 it indicates q[] is >= 0.5, hence it also indicates the *sign* of the
-     * result.
-     *
-     * @param xv
-     * @param hx
-     * @param trig trigtype
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double __kernel_rem_pio2(double xv, int hx, final int trig) {
-        Rempiostruct rmp = rempstruct.get();
-        double[] x = rmp.x;
-        double[] f = rmp.f;
-        double[] q = rmp.q;
-        double[] fq = rmp.fq;
-        int[] iq = rmp.iq;
-
-        /* set z = scalbn(|x|,ilogb(x)-23) */
-        long lx = Double.doubleToRawLongBits(xv);
-        long exp = ((lx & 0x7ff0000000000000L) >> 52) - 1046;
-        lx = (lx - (exp << 52)) & 0x7fffffffffffffffL;
-        double zz = Double.longBitsToDouble(lx);
-        for (int i = 0; i < 2; i++) {
-            x[i] = (int) zz;
-            zz = (zz - x[i]) * two24;
-        }
-        x[2] = zz;
-        int nx = 3;
-        while (x[nx - 1] == zero) { /* skip zero term */
-            nx--;
-        }
-        double z, fw;
-        int ih, n;
-        int jk = 4;
-        int jp = jk;
-        /* determine jx,jv,q0, note that 3>q0 */
-        int jx = nx - 1;
-        int e0 = (int) exp;
-        int jv = (e0 - 3) / 24;
-        if (jv < 0) {
-            jv = 0;
-        }
-        int q0 = e0 - (24 * (jv + 1));
-        /* set up f[0] to f[jx+jk] where f[jx+jk] = two_over_pi[jv+jk] */
-        int j = jv - jx;
-        int m = jx + jk;
-        for (int i = 0; i <= m; i++, j++) {
-            f[i] = ((j < 0) ? zero : two_over_pi[j]);
-        }
-
-        /* compute q[0],q[1],...q[jk] */
-        for (int i = 0; i <= jk; i++) {
-            for (j = 0, fw = 0.0; j <= jx; j++) {
-                fw += (x[j] * f[(jx + i) - j]);
-            }
-            q[i] = fw;
-        }
-        int jz = jk;
-        while (true) { // recompute:
-            /* distill q[] into iq[] reversingly */
-            j = jz;
-            z = q[jz];
-            for (int i = 0; j > 0; i++, j--) {
-                fw = ((int) (twon24 * z));
-                iq[i] = (int) (z - (two24 * fw));
-                z = q[j - 1] + fw;
-            }
-            /* compute n */
-            z = scalb(z, q0); /* actual value of z */
-            z -= (8.0 * floor(z * 0.125)); /* trim off integer >= 8 */
-            n = (int) z;
-            z -= n;
-            ih = 0;
-            if (q0 > 0) { /* need iq[jz-1] to determine n */
-                int i = (iq[jz - 1] >> (24 - q0));
-                n += i;
-                iq[jz - 1] -= (i << (24 - q0));
-                ih = iq[jz - 1] >> (23 - q0);
-            } else if (q0 == 0) {
-                ih = iq[jz - 1] >> 23;
-            } else if (z >= 0.5) {
-                ih = 2;
-            }
-            if (ih > 0) { /* q > 0.5 */
-                n += 1;
-                int carry = 0;
-                for (int i = 0; i < jz; i++) { /* compute 1-q */
-                    j = iq[i];
-                    if (carry == 0) {
-                        if (j != 0) {
-                            carry = 1;
-                            iq[i] = 0x1000000 - j;
-                        }
-                    } else {
-                        iq[i] = 0xffffff - j;
-                    }
-                }
-                /* rare case: chance is 1 in 12 */
-                if (q0 == 1) {
-                    iq[jz - 1] &= 0x7fffff;
-                } else if (q0 == 2) {
-                    iq[jz - 1] &= 0x3fffff;
-                }
-                if (ih == 2) {
-                    z = one - z;
-                    if (carry != 0) {
-                        z -= scalb(one, q0);
-                    }
-                }
-            }
-            /* check if recomputation is needed */
-            if (z == zero) {
-                j = 0;
-                for (int i = jz - 1; i >= jk; i--) {
-                    j |= iq[i];
-                }
-                if (j == 0) { /* need recomputation */
-                    int k = 1;
-                    for (; iq[jk - k] == 0; k++) {
-                    }/* k = no. of terms needed */
-                    for (int i = jz + 1; i <= (jz + k); i++) {
-                        // add q[jz+1] to q[jz+k]
-                        f[jx + i] = two_over_pi[jv + i];
-                        for (j = 0, fw = 0.0; j <= jx; j++) {
-                            fw += (x[j] * f[(jx + i) - j]);
-                        }
-                        q[i] = fw;
-                    }
-                    jz += k;
-                    continue;
-                }
-            }
-            break;
-        }
-        /* chop off zero terms */
-        if (z == 0.0d) {
-            jz--;
-            q0 -= 24;
-            while (iq[jz] == 0) {
-                jz--;
-                q0 -= 24;
-            }
-        } else { /* break z into 24-bit if necessary */
-            z = scalb(z, -q0);
-            if (z >= two24) {
-                fw = (int) (twon24 * z);
-                iq[jz] = (int) (z - (two24 * fw));
-                jz++;
-                q0 += 24;
-                iq[jz] = (int) fw;
-            } else {
-                iq[jz] = (int) z;
-            }
-        }
-        /* convert integer "bit" chunk to floating-point value */
-        fw = scalb(one, q0);
-        for (int i = jz; i >= 0; i--) {
-            q[i] = fw * iq[i];
-            fw *= twon24;
-        }
-        /* compute PIo2[0,...,jp]*q[jz,...,0] */
-        for (int i = jz; i >= 0; i--) {
-            int k = 0;
-            for (fw = 0.0; (k <= jp) && (k <= (jz - i)); k++) {
-                fw += PIo2[k] * q[i + k];
-            }
-            fq[jz - i] = fw;
-        }
-        /* compress fq[] into y[] */
-        fw = 0.0d;
-        for (int i = jz; i >= 0; i--) {
-            fw += fq[i];
-        }
-        double y0 = (ih == 0) ? fw : (0.0d - fw);
-        fw = fq[0] - fw;
-        for (int i = 1; i <= jz; i++) {
-            fw += fq[i];
-        }
-        double y1 = ((ih == 0) ? fw : (0.0d - fw));
-        n &= 7;
-        if (hx < 0) {
-            y0 = 0.0d - y0;
-            y1 = 0.0d - y1;
-            n = -n;
-        }
-        return getTrigres(trig, n, y0, y1);
-    }
-
-    private static final double pio2_hi = 1.57079632679489655800e+00;
-    private static final double pio2_lo = 6.12323399573676603587e-17;
-    private static final double pio4_hi = 7.85398163397448278999e-01;
-    private static final double PIret = PI + 2.0 * pio2_lo;
-
-    /* coefficient for R(x^2) */
-    private static final double pS0 = 1.66666666666666657415e-01;
-    private static final double pS1 = -3.25565818622400915405e-01;
-    private static final double pS2 = 2.01212532134862925881e-01;
-    private static final double pS3 = -4.00555345006794114027e-02;
-    private static final double pS4 = 7.91534994289814532176e-04;
-    private static final double pS5 = 3.47933107596021167570e-05;
-    private static final double qS1 = -2.40339491173441421878e+00;
-    private static final double qS2 = 2.02094576023350569471e+00;
-    private static final double qS3 = -6.88283971605453293030e-01;
-    private static final double qS4 = 7.70381505559019352791e-02;
-
-    /**
-     * Returns the arc sine of a value; the returned angle is in the range -<i>pi</i>/2 through
-     * <i>pi</i>/2. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     * </ul>
-     *
-     * @param a the value whose arc sine is to be returned.
-     * @return the arc sine of the argument.
-     */
-    public static double asin(double a) {
-        /*
-         * asin(x) Method : Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... we approximate
-         * asin(x) on [0,0.5] by asin(x) = x + x*x^2*R(x^2) where R(x^2) is a rational approximation
-         * of (asin(x)-x)/x^3 and its remez error is bounded by |(asin(x)-x)/x^3 - R(x^2)| <
-         * 2^(-58.75)
-         * 
-         * For x in [0.5,1] asin(x) = pi/2-2*asin(sqrt((1-x)/2)) Let y = (1-x), z = y/2, s :=
-         * sqrt(z),and pio2_hi+pio2_lo=pi/2; then for x>0.98 asin(x) = pi/2 - 2*(s+s*z*R(z)) =
-         * pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) For x<=0.98, let pio4_hi = pio2_hi/2, then f = hi
-         * part of s; c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) and asin(x) = pi/2 -
-         * 2*(s+s*z*R(z)) = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) =
-         * pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c))
-         * 
-         * Special cases: if x is NaN, return x itself; if |x|>1, return NaN with invalid signal.
-         */
-        int hx = __HI(a);
-        int ix = hx & 0x7fffffff;
-        if (ix >= 0x3ff00000) { /* |x|>= 1 */
-            return ((ix - 0x3ff00000) | __LO(a)) == 0 ? a * pio2_hi + a * pio2_lo : // asin(1)=+-pi/2
-                                                                                    // with inexact
-                            (a - a) / (a - a); // asin(|x|>1) is NaN
-        }
-        if (ix < 0x3fe00000) { /* |x|<0.5 */
-            if (ix < 0x3e400000) { /* if |x| < 2**-27 */
-                if (huge + a > one)
-                    return a; /* return x with inexact if x!=0 */
-            } else
-                return a + (a * getPdivQ(a * a));
-        }
-        // 1> |x|>= 0.5
-        double t = (one - abs(a)) * 0.5;
-        double pdivq = getPdivQ(t);
-        double s = java.lang.Math.sqrt(t);
-        if (ix >= 0x3FEF3333) { /* if |x| > 0.975 */
-            t = pio2_hi - (2.0 * (s + s * pdivq) - pio2_lo);
-        } else {
-            double w = clearLow32bits(s);
-            double p = 2.0d * s * pdivq - (pio2_lo - 2.0d * ((t - (w * w)) / (s + w)));
-            t = pio4_hi - (p - (pio4_hi - 2.0d * w));
-        }
-        return hx > 0 ? t : -t;
-    }
-
-    /**
-     * Returns the arc cosine of a value; the returned angle is in the range 0.0 through <i>pi</i>.
-     * Special case:
-     * <ul>
-     * <li>If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
-     * </ul>
-     *
-     * @param a the value whose arc cosine is to be returned.
-     * @return the arc cosine of the argument.
-     */
-    public static double acos(double a) {
-        /*
-         * Method : acos(x) = pi/2 - asin(x) acos(-x) = pi/2 + asin(x) For |x|<=0.5 acos(x) = pi/2 -
-         * (x + x*x^2*R(x^2)) (see asin.c) For x>0.5 acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
-         * = 2asin(sqrt((1-x)/2)) = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z) = 2f + (2c + 2s*z*R(z))
-         * where f=hi part of s, and c= (z-f*f)/(s+f) is the correction term for f so that f+c ~
-         * sqrt(z). For x<-0.5 acos(x) = pi - 2asin(sqrt((1-|x|)/2)) = pi - 0.5*(s+s*z*R(z)), where
-         * z=(1-|x|)/2,s=sqrt(z)
-         * 
-         * Special cases: if x is NaN, return x itself; if |x|>1, return NaN with invalid signal.
-         */
-
-        final int hx = __HI(a);
-        final int ix = hx & 0x7fffffff;
-        if (ix >= 0x3ff00000) { // |x| >= 1
-            if (((ix - 0x3ff00000) | __LO(a)) == 0) { // |x|==1
-                return a > 0 ? 0.0 : PIret;
-            }
-            return (a - a) / (a - a); // acos(|x|>1) is NaN
-        }
-
-        if (ix < 0x3fe00000) { // |x| < 0.5
-            return ix <= 0x3c600000 ? pio2_hi + pio2_lo : // |x|<2**-57
-                            pio2_hi - (a - (pio2_lo - a * getPdivQ(a * a)));
-        }
-
-        final double z = 0.5 * ((hx < 0) ? (one + a) : (one - a));
-        final double s = java.lang.Math.sqrt(z);
-        final double pdivq = s * getPdivQ(z);
-
-        if (hx < 0) { // x < -0.5
-            return PI - 2.0 * (s + (pdivq - pio2_lo));
-        }
-        // x > 0.5
-        final double df = clearLow32bits(s);
-        return 2.0 * (df + (pdivq + (z - df * df) / (s + df)));
-    }
-
-    private static double getPdivQ(double z) {
-        return (z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5)))))) / (one + z * (qS1 + z * (qS2 + (z * (qS3 + (z * qS4))))));
-    }
-
-    private static final double atanhi[] = {4.63647609000806093515e-01, // atan(0.5)hi
-                    7.85398163397448278999e-01, // atan(1.0)hi
-                    9.82793723247329054082e-01, // atan(1.5)hi
-                    1.57079632679489655800e+00};// atan(inf)hi
-
-    private static final double atanlo[] = {2.26987774529616870924e-17, // atan(0.5)lo
-                    3.06161699786838301793e-17, // atan(1.0)lo
-                    1.39033110312309984516e-17, // atan(1.5)lo
-                    6.12323399573676603587e-17};// atan(inf)lo)
-
-    private static final double ln2_hi = 6.93147180369123816490e-01, ln2_lo = 1.90821492927058770002e-10, Lg1 = 6.666666666666735130e-01, Lg2 = 3.999999999940941908e-01,
-                    Lg3 = 2.857142874366239149e-01, Lg4 = 2.222219843214978396e-01, Lg5 = 1.818357216161805012e-01, Lg6 = 1.531383769920937332e-01, Lg7 = 1.479819860511658591e-01,
-                    two54 = 1.80143985094819840000e+16, aT0 = 3.33333333333329318027e-01, aT1 = -1.99999999998764832476e-01, aT2 = 1.42857142725034663711e-01, aT3 = -1.11111104054623557880e-01,
-                    aT4 = 9.09088713343650656196e-02, aT5 = -7.69187620504482999495e-02, aT6 = 6.66107313738753120669e-02, aT7 = -5.83357013379057348645e-02, aT8 = 4.97687799461593236017e-02,
-                    aT9 = -3.65315727442169155270e-02, aT10 = 1.62858201153657823623e-02, atanhi3PLUSatanlo3 = atanhi[3] + atanlo[3], negatanhi3MINUSatanlo3 = -atanhi[3] - atanlo[3],
-                    pi_o_4 = 7.8539816339744827900e-01, pi_o_2 = 1.5707963267948965580e+00, pi_lo = 1.2246467991473531772e-16, huge = 1.0e+300, tiny = 1.0e-300;
-
-    /**
-     * Returns the arc tangent of a value; the returned angle is in the range -<i>pi</i>/2 through
-     * <i>pi</i>/2. Special cases:
-     * <ul>
-     * <li>If the argument is NaN, then the result is NaN.
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     * </ul>
-     *
-     * @param aa the value whose arc tangent is to be returned.
-     * @return the arc tangent of the argument.
-     */
-    public static double atan(double aa) {
-        /*
-         * Method 1. Reduce x to positive by atan(x) = -atan(-x). 2. According to the integer
-         * k=4t+0.25 chopped, t=x, the argument is further reduced to one of the following intervals
-         * and the arctangent of t is evaluated by the corresponding formula:
-         * 
-         * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...) [7/16,11/16] atan(x) =
-         * atan(1/2) + atan( (t-0.5)/(1+t/2) ) [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t)
-         * ) [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) ) [39/16,INF] atan(x) =
-         * atan(INF) + atan( -1/t )
-         */
-
-        double a = aa;
-        int hx = __HI(a);
-        int ix = hx & 0x7fffffff;
-        if (ix >= 0x44100000) { /* if |x| >= 2^66 */
-            if ((ix > 0x7ff00000) || (ix == 0x7ff00000 && __LO(a) != 0)) {
-                return a + a; /* NaN */
-            }
-            return hx > 0 ? atanhi3PLUSatanlo3 : negatanhi3MINUSatanlo3;
-        }
-        int id;
-        if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
-            if (ix < 0x3e200000 && /* |x| < 2^-29 */
-            (huge + a > one)) {
-                return a; /* raise inexact */
-            }
-            id = -1;
-        } else {
-            a = abs(a);
-            if (ix < 0x3ff30000) { /* |x| < 1.1875 */
-                if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */
-                    id = 0;
-                    a = (2.0d * a - one) / (2.0d + a);
-                } else { /* 11/16<=|x|< 19/16 */
-                    id = 1;
-                    a = (a - one) / (a + one);
-                }
-            } else {
-                if (ix < 0x40038000) { /* |x| < 2.4375 */
-                    id = 2;
-                    a = (a - 1.5d) / (one + 1.5d * a);
-                } else { /* 2.4375 <= |x| < 2^66 */
-                    id = 3;
-                    a = negone / a;
-                }
-            }
-        }
-
-        /* end of argument reduction */
-        double z = a * a;
-        double w = z * z;
-
-        /* break sum from i=0 to 10 aTi z**(i+1) into odd and even poly */
-        double ss = a * (z * (aT0 + w * (aT2 + w * (aT4 + w * (aT6 + w * (aT8 + w * aT10))))) + w * (aT1 + w * (aT3 + w * (aT5 + w * (aT7 + w * aT9)))));
-        if (id < 0) {
-            return a - ss;
-        }
-        z = atanhi[id] - ((ss - atanlo[id]) - a);
-        return hx < 0 ? 0.0d - z : z;
-    }
-
-    /**
-     * Converts an angle measured in degrees to an approximately equivalent angle measured in
-     * radians. The conversion from degrees to radians is generally inexact.
-     *
-     * @param angdeg an angle, in degrees
-     * @return the measurement of the angle {@code angdeg} in radians.
-     */
-    public static strictfp double toRadians(double angdeg) {
-        return angdeg / 180.0 * PI;
-    }
-
-    /**
-     * Converts an angle measured in radians to an approximately equivalent angle measured in
-     * degrees. The conversion from radians to degrees is generally inexact; users should <i>not</i>
-     * expect {@code cos(toRadians(90.0))} to exactly equal {@code 0.0}.
-     *
-     * @param angrad an angle, in radians
-     * @return the measurement of the angle {@code angrad} in degrees.
-     */
-    public static strictfp double toDegrees(double angrad) {
-        return angrad * 180.0 / PI;
-    }
-
-    private static final double ivln10 = 4.34294481903251816668e-01, log10_2hi = 3.01029995663611771306e-01, log10_2lo = 3.69423907715893078616e-13, halF[] = {0.5, -0.5},
-                    twom1000 = 9.33263618503218878990e-302,// 2**-1000=0x01700000,0
-                    o_threshold = 7.09782712893383973096e+02, u_threshold = -7.45133219101941108420e+02, ln2HI[] = {6.93147180369123816490e-01, -6.93147180369123816490e-01,}, ln2LO[] = {
-                                    1.90821492927058770002e-10, -1.90821492927058770002e-10,}, invln2 = 1.44269504088896338700e+00, ln2HI0 = ln2HI[0], ln2LO0 = ln2LO[0];
-
-    /**
-     * Returns Euler's number <i>e</i> raised to the power of a {@code double} value. Special cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is NaN.
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     * <li>If the argument is negative infinity, then the result is positive zero.
-     * </ul>
-     *
-     * @param aa the exponent to raise <i>e</i> to.
-     * @return the value <i>e</i><sup>{@code a}</sup>, where <i>e</i> is the base of the natural
-     *         logarithms.
-     */
-    public static double exp(double aa) {
-        /*
-         * exp(x) Returns the exponential of x.
-         * 
-         * Method 1. Argument reduction: Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658. Given x,
-         * find r and integer k such that
-         * 
-         * x = k*ln2 + r, |r| <= 0.5*ln2.
-         * 
-         * Here r will be represented as r = hi-lo for better accuracy.
-         * 
-         * 2. Approximation of exp(r) by a special rational function on the interval [0,0.34658]:
-         * Write R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ... We use a special
-         * Reme algorithm on [0,0.34658] to generate a polynomial of degree 5 to approximate R. The
-         * maximum error of this polynomial approximation is bounded by 2**-59. In other words, R(z)
-         * ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5 (where z=r*r, and the values of P1
-         * to P5 are listed below) and | 5 | -59 | 2.0+P1*z+...+P5*z - R(z) | <= 2 | | The
-         * computation of exp(r) thus becomes 2*r exp(r) = 1 + ------- R - r r*R1(r) = 1 + r +
-         * ----------- (for better accuracy) 2 - R1(r) where 2 4 10 R1(r) = r - (P1*r + P2*r + ... +
-         * P5*r ).
-         * 
-         * 3. Scale back to obtain exp(x): From step 1, we have exp(x) = 2^k * exp(r)
-         * 
-         * Special cases: exp(INF) is INF, exp(NaN) is NaN; exp(-INF) is 0, and for finite argument,
-         * only exp(0)=1 is exact.
-         * 
-         * Accuracy: according to an error analysis, the error is always less than 1 ulp (unit in
-         * the last place).
-         * 
-         * Misc. info. For IEEE double if x > 7.09782712893383973096e+02 then exp(x) overflow if x <
-         * -7.45133219101941108420e+02 then exp(x) underflow
-         */
-        double a = aa;
-        int hx = __HI(a); /* high word of x */
-        final int xsb = (hx >>> 31) & 1; /* sign bit of x */
-        final boolean xsb0 = xsb == 0;
-        hx &= 0x7fffffff; /* high word of |x| */
-        // preliminary check for Nan or Infinity
-        if (hx >= 0x7ff00000) {
-            // aa is inf or NaN
-            if (xsb0) { // aa == Double.NaN || aa == Double.POSITIVE_INFINITY)
-                return aa;
-            } else {
-                // negative infinity?
-                return 0.0;
-            }
-        }
-
-        /* filter out non-finite argument */
-        if (hx >= 0x40862E42) { /* if |x|>=709.78... */
-            if (hx >= 0x7ff00000) {
-                if (((hx & 0xfffff) | __LO(a)) != 0) {
-                    return a + a; /* NaN */
-                }
-                return xsb0 ? a : 0.0d; /* exp(+-inf)={inf,0} */
-            }
-            if (a > o_threshold) {
-                return huge * huge; /* overflow */
-            }
-            if (a < u_threshold) {
-                return twom1000 * twom1000; /* underflow */
-            }
-        }
-
-        double hi = 0;
-        double lo = 0;
-        int k = 0;
-        /* argument reduction */
-        if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
-            if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
-                hi = a - ln2HI[xsb];
-                lo = ln2LO[xsb];
-                k = 1 - xsb - xsb;
-            } else {
-                k = (int) (invln2 * a + halF[xsb]);
-                double t = k;
-                hi = a - t * ln2HI0; /* t*ln2HI is exact here */
-                lo = t * ln2LO0;
-            }
-            a = hi - lo;
-        } else if (hx < 0x3e300000) { /* when |x|<2**-28 */
-            if (huge + a > one) {
-                return one + a; /* trigger inexact */
-            }
-        }
-
-        /* x is now in primary range */
-        final double t = a * a;
-        final double c = a - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
-        if (k == 0) {
-            return one - (((a * c) / (c - 2.0)) - a);
-        }
-        final long ybits = Double.doubleToRawLongBits(one - ((lo - ((a * c) / (2.0 - c))) - hi));
-        return (k >= -1021) ? addToHighBits(ybits, k << 20) : addToHighBits(ybits, (k + 1000) << 20) * twom1000;
-    }
-
-    /**
-     * Returns the natural logarithm (base <i>e</i>) of a {@code double} value. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or less than zero, then the result is NaN.
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     * <li>If the argument is positive zero or negative zero, then the result is negative infinity.
-     * </ul>
-     *
-     * @param xx a value
-     * @return the value ln&nbsp;{@code a}, the natural logarithm of {@code a}.
-     */
-    public static double log(double xx) {
-        /*
-         * __ieee754_log(x) Return the logrithm of x
-         * 
-         * Method : 1. Argument Reduction: find k and f such that x = 2^k * (1+f), where sqrt(2)/2 <
-         * 1+f < sqrt(2) .
-         * 
-         * 2. Approximation of log(1+f). Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) =
-         * 2s + 2/3 s**3 + 2/5 s**5 + ....., = 2s + s*R We use a special Reme algorithm on
-         * [0,0.1716] to generate a polynomial of degree 14 to approximate R The maximum error of
-         * this polynomial approximation is bounded by 2**-58.45. In other words, 2 4 6 8 10 12 14
-         * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s (the values of Lg1 to Lg7 are
-         * listed in the program) and | 2 14 | -58.45 | Lg1*s +...+Lg7*s - R(z) | <= 2 | | Note that
-         * 2s = f - s*f = f -hfsq + s*hfsq, where hfsq = f*f/2. In order to guarantee error in log
-         * below 1ulp, we compute log by log(1+f) = f - s*(f - R) (if f is not too large) log(1+f) =
-         * f - (hfsq - s*(hfsq+R)). (better accuracy)
-         * 
-         * 3. Finally, log(x) =k*ln2 + log(1+f). =k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) Here ln2
-         * is split into two floating point number: ln2_hi + ln2_lo, where n*ln2_hi is always exact
-         * for |n| < 2000.
-         * 
-         * Special cases: log(x) is NaN with signal if x < 0 (including -INF) ; log(+INF) is +INF;
-         * log(0) is -INF with signal; log(NaN) is that NaN with no signal.
-         * 
-         * Accuracy: according to an error analysis, the error is always less than 1 ulp (unit in
-         * the last place).
-         */
-        double x = xx;
-        int hx = (int) (Double.doubleToRawLongBits(x) >> 32);
-        int k = 0;
-        if (hx < 0x00100000) { /* x < 2**-1022 */
-            if (((hx & 0x7fffffff) | (__LO(x) & 0xFFFFFFFF)) == 0) {
-                return Double.NEGATIVE_INFINITY;  // -two54 / zero; /* log(+-0)=-inf */
-            }
-            if (hx < 0) {
-                return Double.NaN; // (x - x) / zero; /* log(-#) = NaN */
-            }
-            k = -54;
-            x *= two54; /* subnormal number, scale up x */
-            hx = __HI(x); /* high word of x */
-        }
-        if (hx >= 0x7ff00000) {
-            return x + x;
-        }
-        k += (hx >> 20) - 1023;
-        hx &= 0x000fffff;
-        final int i = (hx + 0x95f64) & 0x100000;
-        k += i >> 20;
-        /* normalize x or x/2 */
-        final double dkln2hi = k * ln2_hi;
-        final double dkln2lo = k * ln2_lo;
-        final boolean KisZero = k == 0;
-        final double f = setHigh32bits(x, hx | (i ^ 0x3ff00000)) - 1.0;
-        if ((0x000fffff & (2 + hx)) < 3) { /* |f| < 2**-20 */
-            if (f == zero) {
-                return KisZero ? zero : dkln2hi + dkln2lo;
-            }
-            double R = f * f * (0.5 - (0.33333333333333333 * f));
-            return KisZero ? f - R : dkln2hi - ((R - dkln2lo) - f);
-        }
-        double s = f / (2.0 + f);
-        final double z = s * s;
-        final double w = z * z;
-        final double R = w * (Lg2 + w * (Lg4 + w * Lg6)) + z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
-        if (((hx - 0x6147a) | (0x6b851 - hx)) > 0) {
-            double hfsq = 0.5 * f * f;
-            s *= hfsq + R;
-            return KisZero ? f - (hfsq - s) : dkln2hi - ((hfsq - (s + dkln2lo)) - f);
-        }
-        s *= f - R;
-        return KisZero ? f - s : dkln2hi - ((s - dkln2lo) - f);
-    }
-
-    /**
-     * Returns the base 10 logarithm of a {@code double} value. Special cases:
-     *
-     * <ul>
-     * <li>If the argument is NaN or less than zero, then the result is NaN.
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     * <li>If the argument is positive zero or negative zero, then the result is negative infinity.
-     * <li>If the argument is equal to 10<sup><i>n</i></sup> for integer <i>n</i>, then the result
-     * is <i>n</i>.
-     * </ul>
-     *
-     * @param aa a value
-     * @return the base 10 logarithm of {@code a}.
-     * @since 1.5
-     */
-    public static double log10(double aa) {
-        /*
-         * __ieee754_log10(x) Return the base 10 logarithm of x
-         * 
-         * Method : Let log10_2hi = leading 40 bits of log10(2) and log10_2lo = log10(2) -
-         * log10_2hi, ivln10 = 1/log(10) rounded. Then n = ilogb(x), if(n<0) n = n+1; x =
-         * scalbn(x,-n); log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
-         * 
-         * Note 1: To guarantee log10(10**n)=n, where 10**n is normal, the rounding mode must set to
-         * Round-to-Nearest. Note 2: [1/log(10)] rounded to 53 bits has error .198 ulps; log10 is
-         * monotonic at all binary break points.
-         * 
-         * Special cases: log10(x) is NaN with signal if x < 0; log10(+INF) is +INF with no signal;
-         * log10(0) is -INF with signal; log10(NaN) is that NaN with no signal; log10(10**N) = N for
-         * N=0,1,...,22.
-         */
-        double a = aa;
-        int hx = (int) (Double.doubleToRawLongBits(a) >> 32);
-        int k = 0;
-        if (hx < 0x00100000) { /* x < 2**-1022 */
-            // unsigned low bits
-            if (((hx & 0x7fffffff) | (__LO(a) & 0xFFFFFFFF)) == 0) {
-                return Double.NEGATIVE_INFINITY;  // -two54 / zero; /* log(+-0)=-inf */
-            }
-            if (hx < 0) {
-                return Double.NaN; // (x - x) / zero; /* log(-#) = NaN */
-            }
-            k = -54;
-            a *= two54; /* subnormal number, scale up x */
-            hx = __HI(a); /* high word of x */
-        }
-        if (hx >= 0x7ff00000) {
-            return a + a;
-        }
-        k += (hx >> 20) - 1023;
-        // i = ((unsigned)k&0x80000000)>>31;
-        final int i = (k & 0x80000000) >>> 31;
-        hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
-        final double y = k + i;
-        return (y * log10_2lo + ivln10 * log(setHigh32bits(a, hx))) + y * log10_2hi;
-    }
-
-    /**
-     * Returns the correctly rounded positive square root of a {@code double} value. Special cases:
-     * <ul>
-     * <li>If the argument is NaN or less than zero, then the result is NaN.
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     * <li>If the argument is positive zero or negative zero, then the result is the same as the
-     * argument.
-     * </ul>
-     * Otherwise, the result is the {@code double} value closest to the true mathematical square
-     * root of the argument value.
-     *
-     * @param a a value.
-     * @return the positive square root of {@code a}.
-     */
-    public static native double sqrt(double a);
-
-    private static final int B1 = 715094163;// B1 = (682-0.03306235651)*2**20
-    private static final long B2highbits = 696219795L << 32;// (664-0.03306235651)*2**20 << 32
-
-    private static final double C_ = 5.42857142857142815906e-01, // 19/35 = 0x3FE15F15, 0xF15F15F1
-                    D_ = -7.05306122448979611050e-01,// -864/1225= 0xBFE691DE, 0x2532C834
-                    E_ = 1.41428571428571436819e+00, // 99/70 = 0x3FF6A0EA, 0x0EA0EA0F
-                    F_ = 1.60714285714285720630e+00, // 45/28 = 0x3FF9B6DB, 0x6DB6DB6E
-                    G_ = 3.57142857142857150787e-01, // 5/14 = 0x3FD6DB6D, 0xB6DB6DB7
-                    TWOpow54 = Double.longBitsToDouble(0x43500000L << 32);
-
-    /**
-     * Returns the cube root of a {@code double} value. For positive finite {@code x},
-     * {@code cbrt(-x) ==
-     * -cbrt(x)}; that is, the cube root of a negative value is the negative of the cube root of
-     * that value's magnitude. Special cases:
-     *
-     * <ul>
-     *
-     * <li>If the argument is NaN, then the result is NaN.
-     *
-     * <li>If the argument is infinite, then the result is an infinity with the same sign as the
-     * argument.
-     *
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     *
-     * </ul>
-     *
-     * @param xx x value.
-     * @return the cube root of {@code xx}.
-     * @since 1.5
-     */
-    public static double cbrt(double xx) {
-        double x = xx;
-        long xb = Double.doubleToRawLongBits(x);
-        long hx = xb >> 32; // todo check if faster to not store sign
-        final long sign = hx & 0x80000000;// unsigned in c /* sign= sign(x) */
-        hx ^= sign;
-        if (hx >= 0x7ff00000L) {
-            return x + x; /* cbrt(NaN,INF) is itself */
-        }
-        if ((hx | (xb & 0x00000000FFFFFFFFL)) == 0) {
-            return x; /* cbrt(0) is itself */
-        }
-
-        x = setHigh32bits(xb, hx); /* x <- |x| */
-        /* rough cbrt to 5 bits */
-        if (hx < 0x00100000L) { /* subnormal number */
-            // HI(t)=0x43500000; /* set t= 2**54 */
-            // t*=x; __HI(t)=__HI(t)/3+B2;
-            long tb = Double.doubleToRawLongBits(TWOpow54 * x);
-            hx = (tb & 0x00000000FFFFFFFFL) | (tb / 3 + B2highbits);
-        } else {
-            hx = (hx / 3 + B1) << 32;
-        }
-        double t = Double.longBitsToDouble(hx);
-
-        /* new cbrt to 23 bits, may be implemented in single precision */
-        final double s = C_ + (t * t / x) * t;
-        t *= G_ + F_ / (s + E_ + D_ / s);
-
-        /* chopped to 20 bits and make it larger than cbrt(x) */
-        // __LO(t)=0; __HI(t)+=0x00000001;
-        t = Double.longBitsToDouble(((Double.doubleToRawLongBits(t) >> 32) + 0x00000001) << 32);
-        // one step newton iteration to 53 bits with error less than 0.667 ulps
-        final double r = x / (t * t); /* t*t is exact */
-        t += t * ((r - t) / ((t + t) + r)); /* r-s is exact */
-        /* retore the sign bit */
-        return Double.longBitsToDouble(Double.doubleToRawLongBits(t) | (sign << 32));
-    }
-
-    /**
-     * Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The
-     * remainder value is mathematically equal to <code>f1&nbsp;-&nbsp;f2</code>
-     * &nbsp;&times;&nbsp;<i>n</i>, where <i>n</i> is the mathematical integer closest to the exact
-     * mathematical value of the quotient {@code f1/f2}, and if two mathematical integers are
-     * equally close to {@code f1/f2}, then <i>n</i> is the integer that is even. If the remainder
-     * is zero, its sign is the same as the sign of the first argument. Special cases:
-     * <ul>
-     * <li>If either argument is NaN, or the first argument is infinite, or the second argument is
-     * positive zero or negative zero, then the result is NaN.
-     * <li>If the first argument is finite and the second argument is infinite, then the result is
-     * the same as the first argument.
-     * </ul>
-     *
-     * @param f1in the dividend.
-     * @param f2in the divisor.
-     * @return the remainder when {@code f1} is divided by {@code f2}.
-     */
-    public static double IEEEremainder(double f1in, double f2in) {
-        /*
-         * __ieee754_remainder(x,p) Return : returns x REM p = x - [x/p]*p as if in infinite precise
-         * arithmetic, where [x/p] is the (infinite bit) integer nearest x/p (in half way case
-         * choose the even one). Method : Based on fmod() return x-[x/p]chopped*p exactlp.
-         */
-        double f1 = f1in;
-        double f2 = f2in;
-        // todo need to verify that this implementation works.
-        long t = Double.doubleToRawLongBits(f1);
-        int hx = (int) (t >> 32);
-        final long sx = (long) (hx & 0x80000000) << 32; // unsigned in c
-        hx &= 0x7fffffff;
-
-        int lx = (int) t; // unsigned in c
-        t = Double.doubleToRawLongBits(f2);
-        int hp = (int) (t >> 32) & 0x7fffffff;
-        int lp = (int) t; // unsigned in c
-
-        /* purge off exception values */
-        if (((hp | lp) == 0) || /* p = 0 */
-        (hx >= 0x7ff00000) || /* x not finite */
-        ((hp >= 0x7ff00000) && /* p is NaN */
-        (((hp - 0x7ff00000) | lp) != 0))) {
-            return (f1 * f2) / (f1 * f2);
-        }
-
-        if (hp <= 0x7fdfffff) {
-            // f1 = __ieee754_fmod(f1,f2+f2); /* now x < 2p */
-            // f1 = f1 % (f2 + f2); /* now x < 2p */
-            // until we get the DREM bytecode working, call fmod here
-            f1 = fmod(f1, f2 + f2); /* now x < 2p */
-        }
-
-        if (((hx - hp) | (lx - lp)) == 0) {
-            return zero * f1;
-        }
-
-        f1 = abs(f1);
-        f2 = abs(f2);
-        if (hp < 0x00200000) {
-            if ((f1 + f1) > f2) {
-                f1 -= f2;
-                if ((f1 + f1) >= f2) {
-                    f1 -= f2;
-                }
-            }
-        } else {
-            final double p_half = 0.5 * f2;
-            if (f1 > p_half) {
-                f1 -= f2;
-                if (f1 >= p_half) {
-                    f1 -= f2;
-                }
-            }
-        }
-        return setHigh32bitsXOR(f1, sx);
-    }
-
-    /**
-     * Returns the smallest (closest to negative infinity) {@code double} value that is greater than
-     * or equal to the argument and is equal to a mathematical integer. Special cases:
-     * <ul>
-     * <li>If the argument value is already equal to a mathematical integer, then the result is the
-     * same as the argument.
-     * <li>If the argument is NaN or an infinity or positive zero or negative zero, then the result
-     * is the same as the argument.
-     * <li>If the argument value is less than zero but greater than -1.0, then the result is
-     * negative zero.
-     * </ul>
-     * Note that the value of {@code JStrictMath.ceil(x)} is exactly the value of
-     * {@code -JStrictMath.floor(-x)}.
-     *
-     * @param a a value.
-     * @return the smallest (closest to negative infinity) floating-point value that is greater than
-     *         or equal to the argument and is equal to a mathematical integer.
-     */
-    public static double ceil(double a) {
-        return Math.ceil(a);
-        // return floorOrCeil(a, false);
-    }
-
-    /**
-     * Returns the largest (closest to positive infinity) {@code double} value that is less than or
-     * equal to the argument and is equal to a mathematical integer. Special cases:
-     * <ul>
-     * <li>If the argument value is already equal to a mathematical integer, then the result is the
-     * same as the argument.
-     * <li>If the argument is NaN or an infinity or positive zero or negative zero, then the result
-     * is the same as the argument.
-     * </ul>
-     *
-     * @param a a value.
-     * @return the largest (closest to positive infinity) floating-point value that less than or
-     *         equal to the argument and is equal to a mathematical integer.
-     */
-    public static double floor(double a) {
-        return Math.floor(a);
-        // return floorOrCeil(a, true);
-    }
-
-    /**
-     * FDLIBM 5.3 s_ceil.c and s_floor.c combined in one method.
-     *
-     * @param x value to perform floor or ceil on.
-     * @param isfloor true if floor operation, false if ceil
-     * @author gustav trede
-     * @return
-     */
-    @SuppressWarnings("javadoc")
-    private static double floorOrCeil(double x, boolean isfloor) {
-        long xb = Double.doubleToRawLongBits(x);
-        long i0 = xb >> 32;
-        long i1 = (int) xb;
-        final int j0 = (int) (((i0 >> 20) & 0x7ff) - 0x3ff);
-        if (j0 < 20) {
-            if (j0 < 0) { /* raise inexact if x != 0 */
-                if (huge + x > 0.0d) {/* return 0*sign(x) if |x|<1 */
-                    if (isfloor) { // floor version
-                        if (i0 >= 0) {
-                            i0 = i1 = 0;
-                        } else if (((i0 & 0x7fffffff) | i1) != 0) {
-                            i0 = 0xbff00000;
-                            i1 = 0;
-                        }
-                    } else {   // ceil version
-                        if (i0 < 0) {
-                            i0 = 0x80000000;
-                            i1 = 0;
-                        } else if ((i0 | i1) != 0) {
-                            i0 = 0x3ff00000;
-                            i1 = 0;
-                        }
-                    }
-                }
-            } else {
-                int i = (0x000fffff) >>> j0; // unsigned declared in c
-                if (((i0 & i) | i1) == 0) {
-                    return x; /* x is integral */
-                }
-                if (huge + x > 0.0d) { /* raise inexact flag */
-                    if (isfloor && i0 < 0 || !isfloor && i0 > 0) {
-                        i0 += (0x00100000) >> j0;
-                    }
-                    i0 &= (~i);
-                    i1 = 0;
-                }
-            }
-        } else if (j0 > 51) {
-            return j0 == 0x400 ? x + x : x; /* inf or NaN , integral */
-        } else {
-            // i = ((unsigned)(0xffffffff))>>(j0-20);
-            int i = 0xffffffff >>> (j0 - 20); // unsigned declared in c
-            if ((i1 & i) == 0) {
-                return x; /* x is integral */
-            }
-            if (huge + x > 0.0d) { /* raise inexact flag */
-                if (isfloor && i0 < 0 || !isfloor && i0 > 0) {
-                    if (j0 == 20) {
-                        i0 += 1;
-                    } else {
-                        // unsigned j = i1+(1<<(52-j0));
-                        // if(j<i1)
-                        long j = i1 + (1L << (52 - j0));
-                        if ((j & 0x7fffffffffffffffL) < (i1 & 0x7fffffffffffffffL)) {
-                            i0 += 1; /* got a carry */
-                        }
-                        i1 = j;
-                    }
-                }
-                i1 &= ~i;
-            }
-        }
-        return Double.longBitsToDouble((i0 << 32) | (i1 & 0x00000000FFFFFFFFL));
-    }
-
-    /**
-     * Returns the {@code double} value that is closest in value to the argument and is equal to a
-     * mathematical integer. If two {@code double} values that are mathematical integers are equally
-     * close to the value of the argument, the result is the integer value that is even. Special
-     * cases:
-     * <ul>
-     * <li>If the argument value is already equal to a mathematical integer, then the result is the
-     * same as the argument.
-     * <li>If the argument is NaN or an infinity or positive zero or negative zero, then the result
-     * is the same as the argument.
-     * </ul>
-     *
-     * @param aa a value.
-     * @return the closest floating-point value to {@code a} that is equal to a mathematical
-     *         integer.
-     * @author Joseph D. Darcy
-     */
-    @SuppressWarnings("deprecation")
-    public static double rint(double aa) {
-        /*
-         * If the absolute value of a is not less than 2^52, it is either a finite integer (the
-         * double format does not have enough significand bits for a number that large to have any
-         * fractional portion), an infinity, or a NaN. In any of these cases, rint of the argument
-         * is the argument.
-         * 
-         * Otherwise, the sum (twoToThe52 + a ) will properly round away any fractional portion of a
-         * since ulp(twoToThe52) == 1.0; subtracting out twoToThe52 from this sum will then be exact
-         * and leave the rounded integer portion of a.
-         * 
-         * This method does *not* need to be declared strictfp to get fully reproducible results.
-         * Whether or not a method is declared strictfp can only make a difference in the returned
-         * result if some operation would overflow or underflow with strictfp semantics. The
-         * operation (twoToThe52 + a ) cannot overflow since large values of a are screened out; the
-         * add cannot underflow since twoToThe52 is too large. The subtraction ((twoToThe52 + a ) -
-         * twoToThe52) will be exact as discussed above and thus cannot overflow or meaningfully
-         * underflow. Finally, the last multiply in the return statement is by plus or minus 1.0,
-         * which is exact too.
-         */
-        double a = aa;
-        double twoToThe52 = 1L << 52; // 2^52
-        double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
-        a = Math.abs(a);
-
-        if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
-            a = ((twoToThe52 + a) - twoToThe52);
-        }
-
-        return sign * a; // restore original sign
-    }
-
-    /**
-     * Returns the angle <i>theta</i> from the conversion of rectangular coordinates ({@code x}
-     * ,&nbsp;{@code y}) to polar coordinates (r,&nbsp;<i>theta</i>). This method computes the phase
-     * <i>theta</i> by computing an arc tangent of {@code y/x} in the range of -<i>pi</i> to
-     * <i>pi</i>. Special cases:
-     * <ul>
-     * <li>If either argument is NaN, then the result is NaN.
-     * <li>If the first argument is positive zero and the second argument is positive, or the first
-     * argument is positive and finite and the second argument is positive infinity, then the result
-     * is positive zero.
-     * <li>If the first argument is negative zero and the second argument is positive, or the first
-     * argument is negative and finite and the second argument is positive infinity, then the result
-     * is negative zero.
-     * <li>If the first argument is positive zero and the second argument is negative, or the first
-     * argument is positive and finite and the second argument is negative infinity, then the result
-     * is the {@code double} value closest to <i>pi</i>.
-     * <li>If the first argument is negative zero and the second argument is negative, or the first
-     * argument is negative and finite and the second argument is negative infinity, then the result
-     * is the {@code double} value closest to -<i>pi</i>.
-     * <li>If the first argument is positive and the second argument is positive zero or negative
-     * zero, or the first argument is positive infinity and the second argument is finite, then the
-     * result is the {@code double} value closest to <i>pi</i>/2.
-     * <li>If the first argument is negative and the second argument is positive zero or negative
-     * zero, or the first argument is negative infinity and the second argument is finite, then the
-     * result is the {@code double} value closest to -<i>pi</i>/2.
-     * <li>If both arguments are positive infinity, then the result is the {@code double} value
-     * closest to <i>pi</i>/4.
-     * <li>If the first argument is positive infinity and the second argument is negative infinity,
-     * then the result is the {@code double} value closest to 3*<i>pi</i>/4.
-     * <li>If the first argument is negative infinity and the second argument is positive infinity,
-     * then the result is the {@code double} value closest to -<i>pi</i>/4.
-     * <li>If both arguments are negative infinity, then the result is the {@code double} value
-     * closest to -3*<i>pi</i>/4.
-     * </ul>
-     *
-     * @param y the ordinate coordinate
-     * @param x the abscissa coordinate
-     * @return the <i>theta</i> component of the point (<i>r</i>,&nbsp;<i>theta</i>) in polar
-     *         coordinates that corresponds to the point (<i>x</i>,&nbsp;<i>y</i>) in Cartesian
-     *         coordinates.
-     */
-    public static double atan2(double y, double x) {
-        /*
-         * __ieee754_atan2(y,x) Method : 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). 2.
-         * Reduce x to positive by (if x and y are unexceptional): ARG (x+iy) = arctan(y/x) ... if x
-         * > 0, ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
-         * 
-         * Special cases:
-         * 
-         * ATAN2((anything), NaN ) is NaN; ATAN2(NAN , (anything) ) is NaN; ATAN2(+-0, +(anything
-         * but NaN)) is +-0 ; ATAN2(+-0, -(anything but NaN)) is +-pi ; ATAN2(+-(anything but 0 and
-         * NaN), 0) is +-pi/2; ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; ATAN2(+-(anything
-         * but INF and NaN), -INF) is +-pi; ATAN2(+-INF,+INF ) is +-pi/4 ; ATAN2(+-INF,-INF ) is
-         * +-3pi/4; ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
-         */
-        long t = Double.doubleToRawLongBits(x);
-        int hx = (int) (t >> 32);
-        int lx = (int) t;
-        int ix = hx & 0x7fffffff;
-        t = Double.doubleToRawLongBits(y);
-        int hy = (int) (t >> 32);
-        int ly = (int) t;
-        int iy = hy & 0x7fffffff;
-        if (((ix | ((lx | -lx) >>> 31)) > 0x7ff00000) || ((iy | ((ly | -ly) >>> 31)) > 0x7ff00000)) {/*
-                                                                                                      * x
-                                                                                                      * or
-                                                                                                      * y
-                                                                                                      * is
-                                                                                                      * NaN
-                                                                                                      */
-            return x + y;
-        }
-        if (((hx - 0x3ff00000) | lx) == 0) {
-            return atan(y); /* x=1.0 */
-        }
-        int m = ((hy >> 31) & 1) | ((hx >> 30) & 2); /* 2*sign(x)+sign(y) */
-
-        /* when y = 0 */
-        if ((iy | ly) == 0) {
-            switch (m) {
-                case 0:
-                case 1:
-                    return y; /* atan(+-0,+anything)=+-0 */
-                case 2:
-                    return PI + tiny; /* atan(+0,-anything) = pi */
-                case 3:
-                    return -PI - tiny; /* atan(-0,-anything) =-pi */
-            }
-        }
-
-        /* when x = 0 */
-        if ((ix | lx) == 0) {
-            return hy < 0 ? -pi_o_2 - tiny : pi_o_2 + tiny;
-        }
-
-        /* when x is INF */
-        if (ix == 0x7ff00000) {
-            if (iy == 0x7ff00000) {
-                switch (m) {
-                    case 0:
-                        return pi_o_4 + tiny; /* atan(+INF,+INF) */
-                    case 1:
-                        return -pi_o_4 - tiny; /* atan(-INF,+INF) */
-                    case 2:
-                        return (3.0 * pi_o_4) + tiny; /* atan(+INF,-INF) */
-                    case 3:
-                        return (-3.0 * pi_o_4) - tiny; /* atan(-INF,-INF) */
-                }
-            } else {
-                switch (m) {
-                    case 0:
-                        return zero; /* atan(+...,+INF) */
-                    case 1:
-                        return -zero; /* atan(-...,+INF) */
-                    case 2:
-                        return PI + tiny; /* atan(+...,-INF) */
-                    case 3:
-                        return -PI - tiny; /* atan(-...,-INF) */
-                }
-            }
-        }
-
-        /* when y is INF */
-        if (iy == 0x7ff00000) {
-            return hy < 0 ? -pi_o_2 - tiny : pi_o_2 + tiny;
-        }
-
-        /* compute y/x */
-        double z;
-        int k = (iy - ix) >> 20;
-        if (k > 60) { /* |y/x| > 2**60 */
-            z = pi_o_2 + (0.5 * pi_lo);
-        } else if ((hx < 0) && (k < -60)) {
-            z = 0.0; /* |y|/x < -2**60 */
-        } else {
-            z = atan(abs(y / x)); /* safe to do y/x */
-        }
-
-        switch (m) {
-            case 0:
-                return z; /* atan(+,+) */
-            case 1:
-                return setHigh32bitsXOR(z, (0x80000000L << 32));// atan(-,+)
-            case 2:
-                return PI - (z - pi_lo); /* atan(+,-) */
-            default:
-                return (z - pi_lo) - PI; /* atan(-,-) */
-        }
-    }
-
-    private static final double bp[] = {1.0, 1.5,}, dp_h[] = {0.0, 5.84962487220764160156e-01,}, dp_l[] = {0.0, 1.35003920212974897128e-08,}, two53 = 9007199254740992.0,
-    /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-    L1 = 5.99999999999994648725e-01, L2 = 4.28571428578550184252e-01, L3 = 3.33333329818377432918e-01, L4 = 2.72728123808534006489e-01, L5 = 2.30660745775561754067e-01,
-                    L6 = 2.06975017800338417784e-01, P1 = 1.66666666666666019037e-01, P2 = -2.77777777770155933842e-03, P3 = 6.61375632143793436117e-05, P4 = -1.65339022054652515390e-06,
-                    P5 = 4.13813679705723846039e-08, lg2 = 6.93147180559945286227e-01, lg2_h = 6.93147182464599609375e-01, lg2_l = -1.90465429995776804525e-09, ovt = 8.0085662595372944372e-0017,// -(1024-log2(ovfl+.5ulp))
-                    cp = 9.61796693925975554329e-01, // =2/(3ln2)
-                    cp_h = 9.61796700954437255859e-01, // =(float)cp
-                    cp_l = -7.02846165095275826516e-09,// =tail of cp_h
-                    ivln2 = 1.44269504088896338700e+00,  // =1/ln2
-                    ivln2_h = 1.44269502162933349609e+00,// =24b 1/ln2
-                    ivln2_l = 1.92596299112661746887e-08;// =1/ln2 tail
-
-    /**
-     * Returns the value of the first argument raised to the power of the second argument. Special
-     * cases:
-     *
-     * <ul>
-     * <li>If the second argument is positive or negative zero, then the result is 1.0.
-     * <li>If the second argument is 1.0, then the result is the same as the first argument.
-     * <li>If the second argument is NaN, then the result is NaN.
-     * <li>If the first argument is NaN and the second argument is nonzero, then the result is NaN.
-     *
-     * <li>If
-     * <ul>
-     * <li>the absolute value of the first argument is greater than 1 and the second argument is
-     * positive infinity, or
-     * <li>the absolute value of the first argument is less than 1 and the second argument is
-     * negative infinity,
-     * </ul>
-     * then the result is positive infinity.
-     *
-     * <li>If
-     * <ul>
-     * <li>the absolute value of the first argument is greater than 1 and the second argument is
-     * negative infinity, or
-     * <li>the absolute value of the first argument is less than 1 and the second argument is
-     * positive infinity,
-     * </ul>
-     * then the result is positive zero.
-     *
-     * <li>If the absolute value of the first argument equals 1 and the second argument is infinite,
-     * then the result is NaN.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is positive zero and the second argument is greater than zero, or
-     * <li>the first argument is positive infinity and the second argument is less than zero,
-     * </ul>
-     * then the result is positive zero.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is positive zero and the second argument is less than zero, or
-     * <li>the first argument is positive infinity and the second argument is greater than zero,
-     * </ul>
-     * then the result is positive infinity.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is negative zero and the second argument is greater than zero but not
-     * a finite odd integer, or
-     * <li>the first argument is negative infinity and the second argument is less than zero but not
-     * a finite odd integer,
-     * </ul>
-     * then the result is positive zero.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is negative zero and the second argument is a positive finite odd
-     * integer, or
-     * <li>the first argument is negative infinity and the second argument is a negative finite odd
-     * integer,
-     * </ul>
-     * then the result is negative zero.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is negative zero and the second argument is less than zero but not a
-     * finite odd integer, or
-     * <li>the first argument is negative infinity and the second argument is greater than zero but
-     * not a finite odd integer,
-     * </ul>
-     * then the result is positive infinity.
-     *
-     * <li>If
-     * <ul>
-     * <li>the first argument is negative zero and the second argument is a negative finite odd
-     * integer, or
-     * <li>the first argument is negative infinity and the second argument is a positive finite odd
-     * integer,
-     * </ul>
-     * then the result is negative infinity.
-     *
-     * <li>If the first argument is finite and less than zero
-     * <ul>
-     * <li>if the second argument is a finite even integer, the result is equal to the result of
-     * raising the absolute value of the first argument to the power of the second argument
-     *
-     * <li>if the second argument is a finite odd integer, the result is equal to the negative of
-     * the result of raising the absolute value of the first argument to the power of the second
-     * argument
-     *
-     * <li>if the second argument is finite and not an integer, then the result is NaN.
-     * </ul>
-     *
-     * <li>If both arguments are integers, then the result is exactly equal to the mathematical
-     * result of raising the first argument to the power of the second argument if that result can
-     * in fact be represented exactly as a {@code double} value.
-     * </ul>
-     *
-     * <p>
-     * (In the foregoing descriptions, a floating-point value is considered to be an integer if and
-     * only if it is finite and a fixed point of the method {@link #ceil ceil} or, equivalently, a
-     * fixed point of the method {@link #floor floor}. A value is a fixed point of a one-argument
-     * method if and only if the result of applying the method to the value is equal to the value.)
-     *
-     * @param x base.
-     * @param y the exponent.
-     * @return the value {@code a}<sup>{@code b}</sup>.
-     */
-    public static double pow(double x, double y) {
-        /*
-         * __ieee754_pow(x,y) return x**y
-         * 
-         * n Method: Let x = 2 * (1+f) 1. Compute and return log2(x) in two pieces: log2(x) = w1 +
-         * w2, where w1 has 53-24 = 29 bit trailing zeros. 2. Perform y*log2(x) = n+y' by simulating
-         * muti-precision arithmetic, where |y'|<=0.5. 3. Return x**y = 2**n*exp(y'*log2)
-         * 
-         * Special cases: 1. (anything) ** 0 is 1 2. (anything) ** 1 is itself 3. (anything) ** NAN
-         * is NAN 4. NAN ** (anything except 0) is NAN 5. +-(|x| > 1) ** +INF is +INF 6. +-(|x| > 1)
-         * ** -INF is +0 7. +-(|x| < 1) ** +INF is +0 8. +-(|x| < 1) ** -INF is +INF 9. +-1 ** +-INF
-         * is NAN 10. +0 ** (+anything except 0, NAN) is +0 11. -0 ** (+anything except 0, NAN, odd
-         * integer) is +0 12. +0 ** (-anything except 0, NAN) is +INF 13. -0 ** (-anything except 0,
-         * NAN, odd integer) is +INF 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) 15. +INF **
-         * (+anything except 0,NAN) is +INF 16. +INF ** (-anything except 0,NAN) is +0 17. -INF **
-         * (anything) = -0 ** (-anything) 18. (-anything) ** (integer) is
-         * (-1)**(integer)*(+anything**integer) 19. (-anything except 0 and inf) ** (non-integer) is
-         * NAN
-         * 
-         * Accuracy: pow(x,y) returns x**y nearly rounded. In particular pow(integer,integer) always
-         * returns the correct integer provided it is representable.
-         */
-
-        // i0 = ((*(int*)&one)>>29)^1; i1=1-i0;
-
-        long xb = Double.doubleToRawLongBits(x);
-        int hx = (int) (xb >> 32);
-        int lx = (int) xb & 0x7fffffff;  // unsigned
-        int ix = hx & 0x7fffffff;
-        xb = Double.doubleToRawLongBits(y);
-        int hy = (int) (xb >> 32);
-        int ly = (int) xb & 0x7fffffff; // unsigned
-        int iy = hy & 0x7fffffff;
-
-        /* y==zero: x**0 = 1 */
-        if ((iy | ly) == 0)
-            return one;
-
-        /* +-NaN return x+y */
-        if (ix > 0x7ff00000 || ((ix == 0x7ff00000) && (lx != 0)) || iy > 0x7ff00000 || ((iy == 0x7ff00000) && (ly != 0)))
-            return x + y;
-
-        /*
-         * determine if y is an odd int when x < 0 yisint = 0 ... y is not an integer yisint = 1 ...
-         * y is an odd int yisint = 2 ... y is an even int
-         */
-        int yisint = 0;
-        if (hx < 0) {
-            if (iy >= 0x43400000)
-                yisint = 2; /* even integer y */
-            else if (iy >= 0x3ff00000) {
-                int k = (iy >> 20) - 0x3ff; /* exponent */
-                if (k > 20) {
-                    int j = ly >> (52 - k);
-                    if ((j << (52 - k)) == ly)
-                        yisint = 2 - (j & 1);
-                } else if (ly == 0) {
-                    int j = iy >> (20 - k);
-                    if ((j << (20 - k)) == iy)
-                        yisint = 2 - (j & 1);
-                }
-            }
-        }
-
-        /* special value of y */
-        if (ly == 0) {
-            if (iy == 0x7ff00000) { /* y is +-inf */
-                if (((ix - 0x3ff00000) | lx) == 0)
-                    return y - y; /* inf**+-1 is NaN */
-                return (ix >= 0x3ff00000) ? /* (|x|>1)**+-inf = inf,0 */
-                (hy >= 0) ? y : zero : /* (|x|<1)**-,+inf = inf,0 */
-                (hy < 0) ? -y : zero;
-            }
-            if (iy == 0x3ff00000) { /* y is +-1 */
-                return (hy < 0) ? one / x : x;
-            }
-            if (hy == 0x40000000)
-                return x * x; /* y is 2 */
-            if (hy == 0x3fe00000) { /* y is 0.5 */
-                if (hx >= 0) /* x >= +0 */
-                    return Math.sqrt(x);
-            }
-        }
-
-        double ax = abs(x);
-        /* special value of x */
-        if (lx == 0) {
-            if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) {
-                double z = ax; /* x is +-0,+-inf,+-1 */
-                if (hy < 0)
-                    z = one / z; /* z = (1/|x|) */
-                if (hx < 0) {
-                    if (((ix - 0x3ff00000) | yisint) == 0) {
-                        z = (z - z) / (z - z); /* (-1)**non-int is NaN */
-                    } else if (yisint == 1)
-                        z = -z; /* (x<0)**odd = -(|x|**odd) */
-                }
-                return z;
-            }
-        }
-
-        int n = (hx >> 31) + 1;
-
-        /* (x<0)**(non-int) is NaN */
-        if ((n | yisint) == 0)
-            return (x - x) / (x - x);
-
-        double s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
-        if ((n | (yisint - 1)) == 0)
-            s = -one;/* (-ve)**(odd int) */
-
-        double t1, t2;
-        /* |y| is huge */
-        if (iy > 0x41e00000) { /* if |y| > 2**31 */
-            if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
-                if (ix <= 0x3fefffff)
-                    return (hy < 0) ? huge * huge : tiny * tiny;
-                if (ix >= 0x3ff00000)
-                    return (hy > 0) ? huge * huge : tiny * tiny;
-            }
-            /* over/underflow if x is not close to one */
-            if (ix < 0x3fefffff)
-                return (hy < 0) ? s * huge * huge : s * tiny * tiny;
-            if (ix > 0x3ff00000)
-                return (hy > 0) ? s * huge * huge : s * tiny * tiny;
-            /*
-             * now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4
-             */
-            double t = ax - one; /* t has 20 trailing zeros */
-            double w = (t * t) * (0.5 - t * (0.3333333333333333333333 - t * 0.25));
-            double u = ivln2_h * t; /* ivln2_h has 21 sig. bits */
-            double v = t * ivln2_l - w * ivln2;
-            t1 = clearLow32bits(u + v);
-            t2 = v - (t1 - u);
-        } else {
-            n = 0;
-            /* take care subnormal number */
-            if (ix < 0x00100000) {
-                ax *= two53;
-                n -= 53;
-                ix = __HI(ax);
-            }
-            n += ((ix) >> 20) - 0x3ff;
-            int j = ix & 0x000fffff;
-            /* determine interval */
-            ix = j | 0x3ff00000; /* normalize ix */
-            int k = 0;
-            if (j <= 0x3988E)
-                k = 0; /* |x|<sqrt(3/2) */
-            else if (j < 0xBB67A)
-                k = 1; /* |x|<sqrt(3) */
-            else {
-                n += 1;
-                ix -= 0x00100000;
-            }
-
-            ax = setHigh32bits(ax, ix); // __HI(ax) = ix;
-
-            /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
-            double u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
-            double v = one / (ax + bp[k]);
-            double ss = u * v;
-            double s_h = clearLow32bits(ss);
-            /* t_h=ax+bp[k] High */
-            // __HI(t_h)=((ix>>1)|0x20000000)+0x00080000+(k<<18);
-            double t_h = setHigh32bitsDontMask(zerobitshigh, ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18));
-            double s_l = v * ((u - s_h * t_h) - s_h * (ax - (t_h - bp[k])));
-            /* compute log(ax) */
-            double s2 = ss * ss;
-            double r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6))))) + s_l * (s_h + ss);
-            s2 = s_h * s_h;
-            t_h = clearLow32bits(3.0 + s2 + r);
-            /* u+v = ss*(1+...) */
-            u = s_h * t_h;
-            v = s_l * t_h + (r - ((t_h - 3.0) - s2)) * ss;
-            /* 2/(3log2)*(ss+...) */
-            double p_h = clearLow32bits(u + v); // __LO(p_h) = 0;
-            double z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
-            double z_l = cp_l * p_h + (v - (p_h - u)) * cp + dp_l[k];
-            /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
-            double t = n;
-            t1 = clearLow32bits((((z_h + z_l) + dp_h[k]) + t)); // __LO(t1) = 0;
-            t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
-        }
-
-        /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
-        double y1 = clearLow32bits(y); // __LO(y1) = 0;
-        double p_l = (y - y1) * t1 + y * t2;
-        double p_h = y1 * t1;
-        double z = p_l + p_h;
-        long zb = Double.doubleToRawLongBits(z);
-        int j = (int) (zb >> 32);
-        if (j >= 0x40900000) { /* z >= 1024 */
-            if (((j - 0x40900000) | ((int) zb)) != 0) /* if z > 1024 */
-                return s * huge * huge; /* overflow */
-            else {
-                if (p_l + ovt > z - p_h)
-                    return s * huge * huge; /* overflow */
-            }
-        } else if ((j & 0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */
-            if (((j - 0xc090cc00) | ((int) zb)) != 0) /* z < -1075 */
-                return s * tiny * tiny; /* underflow */
-            else {
-                if (p_l <= z - p_h)
-                    return s * tiny * tiny; /* underflow */
-            }
-        }
-        /*
-         * compute 2**(p_h+p_l)
-         */
-        int i = j & 0x7fffffff;
-        n = 0;
-        if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
-            n = j + (0x00100000 >> ((i >> 20) - 0x3ff + 1));
-            final int k = ((n & 0x7fffffff) >> 20) - 0x3ff; /* new k for n */
-            double t = setHigh32bitsDontMask(zerobitshigh, (n & ~(0x000fffff >> k)));
-            n = ((n & 0x000fffff) | 0x00100000) >> (20 - k);
-            if (j < 0)
-                n = -n;
-            p_h -= t;
-        }
-        double t = clearLow32bits(p_l + p_h);// __LO(t) = 0;
-        double u = t * lg2_h;
-        double v = (p_l - (t - p_h)) * lg2 + t * lg2_l;
-        z = u + v;
-        double w = v - (z - u);
-        t = z * z;
-        t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
-        z = one - (((z * t1) / (t1 - two) - (w + z * w)) - z);
-        j = __HI(z) + (n << 20);
-        return s * ((j >> 20) <= 0 ? scalb(z, n) : /* subnormal output */
-        addToHighBits(z, (long) n << (20)));// __HI(z) += (n<<20);
-    }
-
-    /**
-     * Returns the closest {@code int} to the argument. The result is rounded to an integer by
-     * adding 1/2, taking the floor of the result, and casting the result to type {@code int}. In
-     * other words, the result is equal to the value of the expression:
-     * <p>
-     * {@code (int)Math.floor(a + 0.5f)}
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is 0.
-     * <li>If the argument is negative infinity or any value less than or equal to the value of
-     * {@code Integer.MIN_VALUE}, the result is equal to the value of {@code Integer.MIN_VALUE}.
-     * <li>If the argument is positive infinity or any value greater than or equal to the value of
-     * {@code Integer.MAX_VALUE}, the result is equal to the value of {@code Integer.MAX_VALUE}.
-     * </ul>
-     *
-     * @param a a floating-point value to be rounded to an integer.
-     * @return the value of the argument rounded to the nearest {@code int} value.
-     * @see java.lang.Integer#MAX_VALUE
-     * @see java.lang.Integer#MIN_VALUE
-     */
-    public static int round(float a) {
-        return (int) floor(a + 0.5f);
-    }
-
-    /**
-     * Returns the closest {@code long} to the argument. The result is rounded to an integer by
-     * adding 1/2, taking the floor of the result, and casting the result to type {@code long}. In
-     * other words, the result is equal to the value of the expression:
-     * <p>
-     * {@code (long)Math.floor(a + 0.5d)}
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is 0.
-     * <li>If the argument is negative infinity or any value less than or equal to the value of
-     * {@code Long.MIN_VALUE}, the result is equal to the value of {@code Long.MIN_VALUE}.
-     * <li>If the argument is positive infinity or any value greater than or equal to the value of
-     * {@code Long.MAX_VALUE}, the result is equal to the value of {@code Long.MAX_VALUE}.
-     * </ul>
-     *
-     * @param a a floating-point value to be rounded to a {@code long}.
-     * @return the value of the argument rounded to the nearest {@code long} value.
-     * @see java.lang.Long#MAX_VALUE
-     * @see java.lang.Long#MIN_VALUE
-     */
-    public static long round(double a) {
-        return (long) floor(a + 0.5d);
-    }
-
-    private static Random randomNumberGenerator;
-
-    private static synchronized void initRNG() {
-        if (randomNumberGenerator == null) {
-            randomNumberGenerator = new Random();
-        }
-    }
-
-    /**
-     * Returns a {@code double} value with a positive sign, greater than or equal to {@code 0.0} and
-     * less than {@code 1.0}. Returned values are chosen pseudorandomly with (approximately) uniform
-     * distribution from that range.
-     *
-     * <p>
-     * When this method is first called, it creates a single new pseudorandom-number generator,
-     * exactly as if by the expression <blockquote>{@code new java.util.Random}</blockquote> This
-     * new pseudorandom-number generator is used thereafter for all calls to this method and is used
-     * nowhere else.
-     *
-     * <p>
-     * This method is properly synchronized to allow correct use by more than one thread. However,
-     * if many threads need to generate pseudorandom numbers at a great rate, it may reduce
-     * contention for each thread to have its own pseudorandom number generator.
-     *
-     * @return a pseudorandom {@code double} greater than or equal to {@code 0.0} and less than
-     *         {@code 1.0}.
-     * @see java.util.Random#nextDouble()
-     */
-    public static double random() {
-        if (randomNumberGenerator == null) {
-            initRNG();
-        }
-        return randomNumberGenerator.nextDouble();
-    }
-
-    /**
-     * Returns the absolute value of an {@code int} value.. If the argument is not negative, the
-     * argument is returned. If the argument is negative, the negation of the argument is returned.
-     *
-     * <p>
-     * Note that if the argument is equal to the value of {@link Integer#MIN_VALUE}, the most
-     * negative representable {@code int} value, the result is that same value, which is negative.
-     *
-     * @param a the argument whose absolute value is to be determined.
-     * @return the absolute value of the argument.
-     */
-    public static int abs(int a) {
-        return Math.abs(a);
-        // return (a < 0) ? -a : a;
-    }
-
-    /**
-     * Returns the absolute value of a {@code long} value. If the argument is not negative, the
-     * argument is returned. If the argument is negative, the negation of the argument is returned.
-     *
-     * <p>
-     * Note that if the argument is equal to the value of {@link Long#MIN_VALUE}, the most negative
-     * representable {@code long} value, the result is that same value, which is negative.
-     *
-     * @param a the argument whose absolute value is to be determined.
-     * @return the absolute value of the argument.
-     */
-    public static long abs(long a) {
-        return Math.abs(a);
-        // return (a < 0) ? -a : a;
-    }
-
-    /**
-     * Returns the absolute value of a {@code float} value. If the argument is not negative, the
-     * argument is returned. If the argument is negative, the negation of the argument is returned.
-     * Special cases:
-     * <ul>
-     * <li>If the argument is positive zero or negative zero, the result is positive zero.
-     * <li>If the argument is infinite, the result is positive infinity.
-     * <li>If the argument is NaN, the result is NaN.
-     * </ul>
-     * In other words, the result is the same as the value of the expression:
-     * <p>
-     * {@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
-     *
-     * @param a the argument whose absolute value is to be determined
-     * @return the absolute value of the argument.
-     */
-    public static float abs(float a) {
-        return Math.abs(a);
-        // return (a <= 0.0F) ? 0.0F - a : a;
-    }
-
-    /**
-     * Returns the absolute value of a {@code double} value. If the argument is not negative, the
-     * argument is returned. If the argument is negative, the negation of the argument is returned.
-     * Special cases:
-     * <ul>
-     * <li>If the argument is positive zero or negative zero, the result is positive zero.
-     * <li>If the argument is infinite, the result is positive infinity.
-     * <li>If the argument is NaN, the result is NaN.
-     * </ul>
-     * In other words, the result is the same as the value of the expression:
-     * <p>
-     * {@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
-     *
-     * @param a the argument whose absolute value is to be determined
-     * @return the absolute value of the argument.
-     */
-    public static double abs(double a) {
-        return Math.abs(a);
-        // return (a <= 0.0D) ? 0.0D - a : a;
-    }
-
-    /**
-     * Returns the greater of two {@code int} values. That is, the result is the argument closer to
-     * the value of {@link Integer#MAX_VALUE}. If the arguments have the same value, the result is
-     * that same value.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the larger of {@code a} and {@code b}.
-     */
-    public static int max(int a, int b) {
-        return Math.max(a, b);
-        // return (a >= b) ? a : b;
-    }
-
-    /**
-     * Returns the greater of two {@code long} values. That is, the result is the argument closer to
-     * the value of {@link Long#MAX_VALUE}. If the arguments have the same value, the result is that
-     * same value.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the larger of {@code a} and {@code b}.
-     */
-    public static long max(long a, long b) {
-        return Math.max(a, b);
-        // return (a >= b) ? a : b;
-    }
-
-    private final static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f), negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d);
-
-    /**
-     * Returns the greater of two {@code float} values. That is, the result is the argument closer
-     * to positive infinity. If the arguments have the same value, the result is that same value. If
-     * either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this
-     * method considers negative zero to be strictly smaller than positive zero. If one argument is
-     * positive zero and the other negative zero, the result is positive zero.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the larger of {@code a} and {@code b}.
-     */
-    public static float max(float a, float b) {
-        return Math.max(a, b);
-        /*****
-         * if (a != a) { return a; // a is NaN } if ((a == 0.0f) && (b == 0.0f) &&
-         * (Float.floatToIntBits(a) == negativeZeroFloatBits)) { return b; } return (a >= b) ? a :
-         * b;
-         *****/
-    }
-
-    /**
-     * Returns the greater of two {@code double} values. That is, the result is the argument closer
-     * to positive infinity. If the arguments have the same value, the result is that same value. If
-     * either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this
-     * method considers negative zero to be strictly smaller than positive zero. If one argument is
-     * positive zero and the other negative zero, the result is positive zero.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the larger of {@code a} and {@code b}.
-     */
-    public static double max(double a, double b) {
-        return Math.max(a, b);
-        /******
-         * if (a != a) { return a; // a is NaN } if ((a == 0.0d) && (b == 0.0d) &&
-         * (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) { return b; } return (a >= b) ? a
-         * : b;
-         ******/
-    }
-
-    /**
-     * Returns the smaller of two {@code int} values. That is, the result the argument closer to the
-     * value of {@link Integer#MIN_VALUE}. If the arguments have the same value, the result is that
-     * same value.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the smaller of {@code a} and {@code b}.
-     */
-    public static int min(int a, int b) {
-        return Math.min(a, b);
-        // return (a <= b) ? a : b;
-    }
-
-    /**
-     * Returns the smaller of two {@code long} values. That is, the result is the argument closer to
-     * the value of {@link Long#MIN_VALUE}. If the arguments have the same value, the result is that
-     * same value.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the smaller of {@code a} and {@code b}.
-     */
-    public static long min(long a, long b) {
-        return Math.min(a, b);
-        // return (a <= b) ? a : b;
-    }
-
-    /**
-     * Returns the smaller of two {@code float} values. That is, the result is the value closer to
-     * negative infinity. If the arguments have the same value, the result is that same value. If
-     * either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this
-     * method considers negative zero to be strictly smaller than positive zero. If one argument is
-     * positive zero and the other is negative zero, the result is negative zero.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the smaller of {@code a} and {@code b.}
-     */
-    public static float min(float a, float b) {
-        return Math.min(a, b);
-        /*******
-         * if (a != a) { return a; // a is NaN } if ((a == 0.0f) && (b == 0.0f) &&
-         * (Float.floatToIntBits(b) == negativeZeroFloatBits)) { return b; } return (a <= b) ? a :
-         * b;
-         *****/
-    }
-
-    /**
-     * Returns the smaller of two {@code double} values. That is, the result is the value closer to
-     * negative infinity. If the arguments have the same value, the result is that same value. If
-     * either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this
-     * method considers negative zero to be strictly smaller than positive zero. If one argument is
-     * positive zero and the other is negative zero, the result is negative zero.
-     *
-     * @param a an argument.
-     * @param b another argument.
-     * @return the smaller of {@code a} and {@code b}.
-     */
-    public static double min(double a, double b) {
-        return Math.min(a, b);
-        /*********
-         * if (a != a) { return a; // a is NaN } if ((a == 0.0d) && (b == 0.0d) &&
-         * (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) { return b; } return (a <= b) ? a
-         * : b;
-         *******/
-    }
-
-    /**
-     * Returns the size of an ulp of the argument. An ulp of a {@code double} value is the positive
-     * distance between this floating-point value and the {@code double} value next larger in
-     * magnitude. Note that for non-NaN <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, then the result is NaN.
-     * <li>If the argument is positive or negative infinity, then the result is positive infinity.
-     * <li>If the argument is positive or negative zero, then the result is {@code Double.MIN_VALUE}.
-     * <li>If the argument is &plusmn;{@code Double.MAX_VALUE}, then the result is equal to
-     * 2<sup>971</sup>.
-     * </ul>
-     *
-     * @param d the floating-point value whose ulp is to be returned
-     * @return the size of an ulp of the argument
-     * @author Joseph D. Darcy
-     * @since 1.5
-     */
-    @SuppressWarnings("deprecation")
-    public static double ulp(double d) {
-        return sun.misc.FpUtils.ulp(d);
-    }
-
-    /**
-     * Returns the size of an ulp of the argument. An ulp of a {@code float} value is the positive
-     * distance between this floating-point value and the {@code float} value next larger in
-     * magnitude. Note that for non-NaN <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, then the result is NaN.
-     * <li>If the argument is positive or negative infinity, then the result is positive infinity.
-     * <li>If the argument is positive or negative zero, then the result is {@code Float.MIN_VALUE}.
-     * <li>If the argument is &plusmn;{@code Float.MAX_VALUE}, then the result is equal to
-     * 2<sup>104</sup>.
-     * </ul>
-     *
-     * @param f the floating-point value whose ulp is to be returned
-     * @return the size of an ulp of the argument
-     * @author Joseph D. Darcy
-     * @since 1.5
-     */
-    @SuppressWarnings("deprecation")
-    public static float ulp(float f) {
-        return sun.misc.FpUtils.ulp(f);
-    }
-
-    /**
-     * Returns the signum function of the argument; zero if the argument is zero, 1.0 if the
-     * argument is greater than zero, -1.0 if the argument is less than zero.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, then the result is NaN.
-     * <li>If the argument is positive zero or negative zero, then the result is the same as the
-     * argument.
-     * </ul>
-     *
-     * @param d the floating-point value whose signum is to be returned
-     * @return the signum function of the argument
-     * @author Joseph D. Darcy
-     * @since 1.5
-     */
-    @SuppressWarnings("deprecation")
-    public static double signum(double d) {
-        return sun.misc.FpUtils.signum(d);
-    }
-
-    /**
-     * Returns the signum function of the argument; zero if the argument is zero, 1.0f if the
-     * argument is greater than zero, -1.0f if the argument is less than zero.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, then the result is NaN.
-     * <li>If the argument is positive zero or negative zero, then the result is the same as the
-     * argument.
-     * </ul>
-     *
-     * @param f the floating-point value whose signum is to be returned
-     * @return the signum function of the argument
-     * @author Joseph D. Darcy
-     * @since 1.5
-     */
-    @SuppressWarnings("deprecation")
-    public static float signum(float f) {
-        return sun.misc.FpUtils.signum(f);
-    }
-
-    private static final double shuge = 1.0e307;
-
-    /**
-     * Returns the hyperbolic sine of a {@code double} value. The hyperbolic sine of <i>x</i> is
-     * defined to be (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/2 where <i>e</i> is
-     * {@linkplain Math#E Euler's number}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     *
-     * <li>If the argument is NaN, then the result is NaN.
-     *
-     * <li>If the argument is infinite, then the result is an infinity with the same sign as the
-     * argument.
-     *
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     *
-     * </ul>
-     *
-     * @param x The number whose hyperbolic sine is to be returned.
-     * @return The hyperbolic sine of {@code x}.
-     * @since 1.5
-     */
-    public static double sinh(double x) {
-        /*
-         * __ieee754_sinh(x) Method : mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 1.
-         * Replace x by |x| (sinh(-x) = -sinh(x)). 2. E + E/(E+1) 0 <= x <= 22 : sinh(x) :=
-         * --------------, E=expm1(x) 2
-         * 
-         * 22 <= x <= lnovft : sinh(x) := exp(x)/2 lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 *
-         * exp(x/2) ln2ovft < x : sinh(x) := x*shuge (overflow)
-         * 
-         * Special cases: sinh(x) is |x| if x is +INF, -INF, or NaN. only sinh(0)=0 is exact for
-         * finite x.
-         */
-
-        final long xb = Double.doubleToLongBits(x);
-        final double h = (xb >> 32) < 0 ? -0.5 : 0.5;
-        final int ix = (int) ((xb >> 32) & 0x7fffffff);
-
-        if (ix >= 0x7ff00000) { /* x is INF or NaN */
-            return x + x;
-        }
-
-        /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
-        if (ix < 0x40360000) { /* |x|<22 */
-            if (ix < 0x3e300000) /* |x|<2**-28 */
-                if (shuge + x > one) {
-                    return x;/* sinh(tiny) = tiny with inexact */
-                }
-            final double t = expm1(abs(x));
-            return (ix < 0x3ff00000) ? h * (2.0 * t - t * t / (t + one)) : h * (t + t / (t + one));
-        }
-
-        /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
-        if (ix < 0x40862E42)
-            return h * exp(abs(x));
-
-        // |x| in [log(Double.MAX_VALUE), overflowthreshold]
-        if (ix < 0x408633ce || (ix == 0x408633ce && (xb & 0x00000000ffffffffL) <= 0x8fb9f87dL)) {
-            final double w = exp(0.5 * abs(x));
-            return (h * w) * w;
-        }
-        /* |x| > overflowthresold, sinh(x) overflow */
-        return x * shuge;
-
-    }
-
-    /**
-     * Returns the hyperbolic cosine of a {@code double} value. The hyperbolic cosine of <i>x</i> is
-     * defined to be (<i>e<sup>x</sup>&nbsp;+&nbsp;e<sup>-x</sup></i>)/2 where <i>e</i> is
-     * {@linkplain Math#E Euler's number}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     *
-     * <li>If the argument is NaN, then the result is NaN.
-     *
-     * <li>If the argument is infinite, then the result is positive infinity.
-     *
-     * <li>If the argument is zero, then the result is {@code 1.0}.
-     *
-     * </ul>
-     *
-     * @param x The number whose hyperbolic cosine is to be returned.
-     * @return The hyperbolic cosine of {@code x}.
-     * @since 1.5
-     */
-    public static double cosh(double x) {
-        /*
-         * __ieee754_cosh(x) Method : mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2 1.
-         * Replace x by |x| (cosh(x) = cosh(-x)). 2. [ exp(x) - 1 ]^2 0 <= x <= ln2/2 : cosh(x) := 1
-         * + ------------------- 2*exp(x)
-         * 
-         * exp(x) + 1/exp(x) ln2/2 <= x <= 22 : cosh(x) := ------------------- 2 22 <= x <= lnovft :
-         * cosh(x) := exp(x)/2 lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2) ln2ovft < x
-         * : cosh(x) := huge*huge (overflow)
-         * 
-         * Special cases: cosh(x) is |x| if x is +INF, -INF, or NaN. only cosh(0)=1 is exact for
-         * finite x.
-         */
-
-        final long xb = Double.doubleToRawLongBits(x);
-        final int ix = ((int) (xb >> 32)) & 0x7fffffff;
-
-        /* x is INF or NaN */
-        if (ix >= 0x7ff00000) {
-            return x * x;
-        }
-
-        /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */
-        if (ix < 0x3fd62e43) {
-            final double t = expm1(abs(x));
-            final double w = one + t;
-            // for tiny arguments return 1.
-            return (ix < 0x3c800000) ? w : one + (t * t) / (w + w);
-        }
-
-        /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */
-        if (ix < 0x40360000) {
-            final double t = exp(abs(x));
-            return half * t + half / t;
-        }
-
-        /* |x| in [22, log(maxdouble)] return half*exp(|x|) */
-        if (ix < 0x40862e42) {
-            return half * exp(abs(x));
-        }
-
-        /* |x| in [log(maxdouble), overflowthresold] */
-        if (ix < 0x408633ce || (ix == 0x408633ce && (xb & 0x00000000ffffffffL) <= 0x8fb9f87dL)) {
-            final double w = exp(half * abs(x));
-            return (half * w) * w;
-        }
-        /* |x| > overflowthresold, cosh(x) overflow */
-        return huge * huge;
-    }
-
-    /**
-     * Returns the hyperbolic tangent of a {@code double} value. The hyperbolic tangent of <i>x</i>
-     * is defined to be
-     * (<i>e<sup>x</sup>&nbsp;-&nbsp;e<sup>-x</sup></i>)/(<i>e<sup>x</sup>&nbsp;+&nbsp
-     * ;e<sup>-x</sup></i>), in other words, {@linkplain Math#sinh sinh(<i>x</i>)}/
-     * {@linkplain Math#cosh cosh(<i>x</i>)}. Note that the absolute value of the exact tanh is
-     * always less than 1.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     *
-     * <li>If the argument is NaN, then the result is NaN.
-     *
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     *
-     * <li>If the argument is positive infinity, then the result is {@code +1.0}.
-     *
-     * <li>If the argument is negative infinity, then the result is {@code -1.0}.
-     *
-     * </ul>
-     *
-     * @param xx The number whose hyperbolic tangent is to be returned.
-     * @return The hyperbolic tangent of {@code x}.
-     * @since 1.5
-     */
-    public static double tanh(double xx) {
-        /*
-         * Tanh(x) Return the Hyperbolic Tangent of x
-         * 
-         * Method : x -x e - e 0. tanh(x) is defined to be ----------- x -x e + e 1. reduce x to
-         * non-negative by tanh(-x) = -tanh(x). 2. 0 <= x <= 2**-55 : tanh(x) := x*(one+x) -t 2**-55
-         * < x <= 1 : tanh(x) := -----; t = expm1(-2x) t + 2 2 1 <= x <= 22.0 : tanh(x) := 1- -----
-         * ; t=expm1(2x) t + 2 22.0 < x <= INF : tanh(x) := 1.
-         * 
-         * Special cases: tanh(NaN) is NaN; only tanh(0)=0 is exact for finite argument.
-         */
-
-        double x = xx;
-        /* High word of |x|. */
-        final int hx = (int) (Double.doubleToRawLongBits(x) >> 32);
-        final int ix = hx & 0x7fffffff;
-
-        /* x is INF or NaN */
-        if (ix >= 0x7ff00000) {
-            return hx >= 0 ? one / x + one : /* tanh(+-inf)=+-1 */
-            one / x - one; /* tanh(NaN) = NaN */
-        }
-
-        double z;
-        /* |x| < 22 */
-        if (ix < 0x40360000) { /* |x|<22 */
-            if (ix < 0x3c800000) { /* |x|<2**-55 */
-                return x * (one + x); /* tanh(small) = small */
-            }
-            x = abs(x);
-            if (ix >= 0x3ff00000) { /* |x|>=1 */
-                z = one - two / (expm1(2.0d * x) + two);
-            } else {
-                double t = expm1(-two * x);
-                z = -t / (t + two);
-            }
-            /* |x| > 22, return +-1 */
-        } else {
-            z = one - tiny; /* raised inexact flag */
-        }
-        return hx >= 0 ? z : 0.0d - z;
-    }
-
-    private static final double TWOpow1022 = setHigh32bits(0x7fd00000);
-    private static final long onebits = Double.doubleToLongBits(one), clearHighmask = 0x00000000FFFFFFFFL, onebitshigh = onebits & clearHighmask, zerobitshigh = Double.doubleToLongBits(zero) &
-                    clearHighmask;
-
-    /**
-     * Returns sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>) without intermediate overflow
-     * or underflow.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     *
-     * <li>If either argument is infinite, then the result is positive infinity.
-     *
-     * <li>If either argument is NaN and neither argument is infinite, then the result is NaN.
-     *
-     * </ul>
-     *
-     * @param aa a value
-     * @param bb a value
-     * @return sqrt(<i>x</i><sup>2</sup>&nbsp;+<i>y</i><sup>2</sup>) without intermediate overflow
-     *         or underflow
-     * @since 1.5
-     */
-    public static double hypot(double aa, double bb) {
-        /*
-         * __ieee754_hypot(x,y)
-         * 
-         * Method : If (assume round-to-nearest) z=x*x+y*y has error less than sqrt(2)/2 ulp, than
-         * sqrt(z) has error less than 1 ulp (exercise).
-         * 
-         * So, compute sqrt(x*x+y*y) with some care as follows to get the error below 1 ulp:
-         * 
-         * Assume x>y>0; (if possible, set rounding to round-to-nearest) 1. if x > 2y use
-         * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y where x1 = x with lower 32 bits cleared, x2 = x-x1;
-         * else 2. if x <= 2y use t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) where t1 = 2x with lower 32 bits
-         * cleared, t2 = 2x-t1, y1= y with lower 32 bits chopped, y2 = y-y1.
-         * 
-         * NOTE: scaling may be necessary if some argument is too large or too tiny
-         * 
-         * Special cases: hypot(x,y) is INF if x or y is +INF or -INF; else hypot(x,y) is NAN if x
-         * or y is NAN.
-         * 
-         * Accuracy: hypot(x,y) returns sqrt(x^2+y^2) with error less than 1 ulps (units in the last
-         * place)
-         */
-
-        double a = aa;
-        double b = bb;
-        long hx = (Double.doubleToRawLongBits(a) >>> 32) & 0x7fffffff;
-        long hy = (Double.doubleToRawLongBits(b) >>> 32) & 0x7fffffff;
-        if (hy > hx) {
-            double at = a;
-            a = b;
-            b = at;
-            long j = hx;
-            hx = hy;
-            hy = j;
-        }
-
-        a = abs(a);
-        b = abs(b);
-
-        // a = setHigh32bits(a,hx);
-        // b = setHigh32bits(b,hy);
-
-        // System.err.println("a1 ");
-        if (hx - hy > 0x3c00000) {
-            return a + b;
-        } /* x/y > 2**60 */
-        // System.err.println("a2");
-        int k = 0;
-        if (hx > 0x5f300000) { /* a>2**500 */
-            // System.err.println("b1 "+hx +" >= "+ 0x7ff00000);
-            if (hx >= 0x7ff00000) { /* Inf or NaN */
-                // System.err.println("b2");
-                return Double.isInfinite(a) || Double.isInfinite(b) ? Double.POSITIVE_INFINITY : Double.NaN;
-            }
-            /* scale a and b by 2**-600 */
-            k = 600;
-            a = setHigh32bits(a, hx -= 0x25800000);
-            b = setHigh32bits(b, hy -= 0x25800000);
-        }
-        if (hy < 0x20b00000) { /* b < 2**-500 */
-            if (hy <= 0x000fffff) { /* subnormal b or 0 */
-                // if ((hy | (bbits&clearHighmask)) == 0) {
-                if ((hy | __LO(b)) == 0) {
-                    return a;
-                }
-                b *= TWOpow1022;
-                a *= TWOpow1022;
-                k -= 1022;
-            } else { /* scale a and b by 2^600 */
-                k -= 600;
-                a = setHigh32bits(a, hx += 0x25800000); /* a *= 2^600 */
-                b = setHigh32bits(b, hy += 0x25800000); /* b *= 2^600 */
-            }
-        }
-
-        /* medium size a and b */
-        double w = a - b;
-        if (w > b) {
-            final double t1 = Double.longBitsToDouble(hx << 32);
-            w = t1 * t1 - (b * -b - (a - t1) * (a + t1));
-        } else {
-            final double y1 = Double.longBitsToDouble(hy << 32);
-            final double t1 = Double.longBitsToDouble((hx + 0x00100000) << 32);
-            w = t1 * y1 - (w * -w - (t1 * (b - y1) + b * ((a + a) - t1)));
-        }
-        w = java.lang.Math.sqrt(w);
-        return k != 0 ? w * setHhighbitsAddSome(onebits, (long) k << (20 + 32)) : w;
-    }
-
-    /* scaled coefficients related to expm1 */
-    private static final double Q1 = -3.33333333333331316428e-02, /* BFA11111 111110F4 */
-    Q2 = 1.58730158725481460165e-03, /* 3F5A01A0 19FE5585 */
-    Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
-    Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
-    Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
-
-    /**
-     * Returns <i>e</i><sup>x</sup>&nbsp;-1. Note that for values of <i>x</i> near 0, the exact sum
-     * of {@code expm1(x)}&nbsp;+&nbsp;1 is much closer to the true result of <i>e</i><sup>x</sup>
-     * than {@code exp(x)}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is NaN.
-     *
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     *
-     * <li>If the argument is negative infinity, then the result is -1.0.
-     *
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     *
-     * </ul>
-     *
-     * @param xx the exponent to raise <i>e</i> to in the computation of <i>e</i><sup>{@code x}
-     *            </sup>&nbsp;-1.
-     * @return the value <i>e</i><sup>{@code x}</sup>&nbsp;-&nbsp;1.
-     * @since 1.5
-     */
-    public static double expm1(double xx) {
-        /*
-         * expm1(x) Returns exp(x)-1, the exponential of x minus 1.
-         * 
-         * Method 1. Argument reduction: Given x, find r and integer k such that
-         * 
-         * x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658
-         * 
-         * Here a correction term c will be computed to compensate the error in r when rounded to a
-         * floating-point number.
-         * 
-         * 2. Approximating expm1(r) by a special rational function on the interval [0,0.34658]:
-         * Since r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... we define R1(r*r) by
-         * r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) That is, R1(r**2) = 6/r
-         * *((exp(r)+1)/(exp(r)-1) - 2/r) = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) = 1 - r^2/60 +
-         * r^4/2520 - r^6/100800 + ... We use a special Reme algorithm on [0,0.347] to generate a
-         * polynomial of degree 5 in r*r to approximate R1. The maximum error of this polynomial
-         * approximation is bounded by 2**-61. In other words, R1(z) ~ 1.0 + Q1*z + Q2*z**2 +
-         * Q3*z**3 + Q4*z**4 + Q5*z**5 where Q1 = -1.6666666666666567384E-2, Q2 =
-         * 3.9682539681370365873E-4, Q3 = -9.9206344733435987357E-6, Q4 = 2.5051361420808517002E-7,
-         * Q5 = -6.2843505682382617102E-9; (where z=r*r, and the values of Q1 to Q5 are listed
-         * below) with error bounded by | 5 | -61 | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 | |
-         * 
-         * expm1(r) = exp(r)-1 is then computed by the following specific way which minimize the
-         * accumulation rounding error: 2 3 r r [ 3 - (R1 + R1*r/2) ] expm1(r) = r + --- + --- *
-         * [--------------------] 2 2 [ 6 - r*(3 - R1*r/2) ]
-         * 
-         * To compensate the error in the argument reduction, we use expm1(r+c) = expm1(r) + c +
-         * expm1(r)*c ~ expm1(r) + c + r*c Thus c+r*c will be added in as the correction terms for
-         * expm1(r+c). Now rearrange the term to avoid optimization screw up: ( 2 2 ) ({ ( r [ R1 -
-         * (3 - R1*r/2) ] ) } r ) expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) ({
-         * ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) ( )
-         * 
-         * = r - E 3. Scale back to obtain expm1(x): From step 1, we have expm1(x) = either
-         * 2^k*[expm1(r)+1] - 1 = or 2^k*[expm1(r) + (1-2^-k)] 4. Implementation notes: (A). To save
-         * one multiplication, we scale the coefficient Qi to Qi*2^i, and replace z by (x^2)/2. (B).
-         * To achieve maximum accuracy, we compute expm1(x) by (i) if x < -56*ln2, return -1.0,
-         * (raise inexact if x!=inf) (ii) if k=0, return r-E (iii) if k=-1, return 0.5*(r-E)-0.5
-         * (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) else return 1.0+2.0*(r-E); (v) if
-         * (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) (vi) if k <= 20, return
-         * 2^k((1-2^-k)-(E-r)), else (vii) return 2^k(1-((E+2^-k)-r))
-         * 
-         * Special cases: expm1(INF) is INF, expm1(NaN) is NaN; expm1(-INF) is -1, and for finite
-         * argument, only expm1(0)=0 is exact.
-         * 
-         * Accuracy: according to an error analysis, the error is always less than 1 ulp (unit in
-         * the last place).
-         * 
-         * Misc. info. For IEEE double if x > 7.09782712893383973096e+02 then expm1(x) overflow
-         * 
-         * Constants: The hexadecimal values are the intended ones for the following constants. The
-         * decimal values may be used, provided that the compiler will convert from decimal to
-         * binary accurately enough to produce the hexadecimal values shown.
-         */
-
-        double x = xx;
-        long xb = Double.doubleToRawLongBits(x);
-        int hx = (int) (xb >> 32); /* high word of x UNSIGNED */
-        final boolean xsbzero = (hx & 0x80000000) == 0; /* sign bit of x */
-        // double y = xsbzero ? x : 0.0d - x; /* y = |x| */
-        hx &= 0x7fffffff; /* high word of |x| */
-
-        /* filter out huge and non-finite argument */
-        if (hx >= 0x4043687A) { /* if |x|>=56*ln2 */
-            if (hx >= 0x40862E42) { /* if |x|>=709.78... */
-                if (hx >= 0x7ff00000) {
-                    return (((hx & 0xfffff) | (int) xb) != 0) ? x + x : /* NaN */
-                    xsbzero ? x : -1.0; /* exp(+-inf)={inf,-1} */
-                }
-                if (x > o_threshold) {
-                    return huge * huge; /* overflow */
-                }
-            }
-            /* x < -56*ln2, return -1.0 with inexact */
-            if (!xsbzero && (x + tiny < 0.0)) { /* raise inexact */
-                return tiny - one; /* return -1 */
-            }
-        }
-
-        double hi, lo, c = 0;
-        int k = 0;
-        /* argument reduction */
-        if (hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
-            if (hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
-                if (xsbzero) {
-                    hi = x - ln2_hi;
-                    lo = ln2_lo;
-                    k = 1;
-                } else {
-                    hi = x + ln2_hi;
-                    lo = -ln2_lo;
-                    k = -1;
-                }
-            } else {
-                // loss of precision here ?:
-                k = (int) (invln2 * x + (xsbzero ? 0.5 : -0.5));
-                hi = x - k * ln2_hi; /* t*ln2_hi is exact here */
-                lo = k * ln2_lo;
-            }
-            x = hi - lo;
-            c = (hi - x) - lo;
-        } else if (hx < 0x3c900000) { /* when |x|<2**-54, return x */
-            /* return x with inexact flags when x!=0 */
-            return x - ((huge + x) - (huge + x));
-        }
-
-        /* x is now in primary range */
-        final double hfx = 0.5 * x;
-        final double hxs = x * hfx;
-        final double r1 = one + hxs * (Q1 + hxs * (Q2 + hxs * (Q3 + hxs * (Q4 + hxs * Q5))));
-        final double t = 3.0 - r1 * hfx;
-        double e = hxs * ((r1 - t) / (6.0 - x * t));
-        if (k == 0) {
-            return x - (x * e - hxs); /* c is 0 */
-        }
-        e = (x * (e - c) - c) - hxs;
-        if (k == -1) {
-            return 0.5 * (x - e) - 0.5;
-        }
-        if (k == 1) {
-            return x < -0.25 ? -2.0 * (e - (x + 0.5)) : one + 2.0 * (x - e);
-        }
-        if (k <= -2 || k > 56) { /* suffice to return exp(x)-1 */
-            /* add k to y's exponent */
-            return setHhighbitsAddSome(one - (e - x), (long) k << (20 + 32)) - one;
-        }
-        final double y = k < 20 ? /* 1-2^-k */
-        setHigh32bitsDontMask(onebitshigh, 0x3ff00000 - (0x200000 >> k)) - (e - x) : (x - (e + setHigh32bitsDontMask(onebitshigh, (0x3ff - k) << 20))) + one;// 2^-k
-        /* add k to y's exponent */
-        return setHhighbitsAddSome(y, (long) k << (20 + 32));
-    }
-
-    private static final double Lp1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-    Lp2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-    Lp3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-    Lp4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-    Lp5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-    Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-    Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-    /**
-     * Returns the natural logarithm of the sum of the argument and 1. Note that for small values
-     * {@code x}, the result of {@code log1p(x)} is much closer to the true result of ln(1 +
-     * {@code x}) than the floating-point evaluation of {@code log(1.0+x)}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     *
-     * <li>If the argument is NaN or less than -1, then the result is NaN.
-     *
-     * <li>If the argument is positive infinity, then the result is positive infinity.
-     *
-     * <li>If the argument is negative one, then the result is negative infinity.
-     *
-     * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
-     *
-     * </ul>
-     *
-     * @param x a value
-     * @return the value ln({@code x}&nbsp;+&nbsp;1), the natural log of {@code x}&nbsp;+&nbsp;1
-     * @since 1.5
-     */
-    @SuppressWarnings("cast")
-    public static double log1p(double x) {
-        /*
-         * double log1p(double x)
-         * 
-         * Method : 1. Argument Reduction: find k and f such that 1+x = 2^k * (1+f), where sqrt(2)/2
-         * < 1+f < sqrt(2) .
-         * 
-         * Note. If k=0, then f=x is exact. However, if k!=0, then f may not be representable
-         * exactly. In that case, a correction term is need. Let u=1+x rounded. Let c = (1+x)-u,
-         * then log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u), and add back the
-         * correction term c/u. (Note: when x > 2**53, one can simply return log(x))
-         * 
-         * 2. Approximation of log1p(f). Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) =
-         * 2s + 2/3 s**3 + 2/5 s**5 + ....., = 2s + s*R We use a special Reme algorithm on
-         * [0,0.1716] to generate a polynomial of degree 14 to approximate R The maximum error of
-         * this polynomial approximation is bounded by 2**-58.45. In other words, 2 4 6 8 10 12 14
-         * R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s (the values of Lp1 to Lp7 are
-         * listed in the program) and | 2 14 | -58.45 | Lp1*s +...+Lp7*s - R(z) | <= 2 | | Note that
-         * 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. In order to guarantee error in log
-         * below 1ulp, we compute log by log1p(f) = f - (hfsq - s*(hfsq+R)).
-         * 
-         * 3. Finally, log1p(x) = k*ln2 + log1p(f). = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) Here
-         * ln2 is split into two floating point number: ln2_hi + ln2_lo, where n*ln2_hi is always
-         * exact for |n| < 2000.
-         * 
-         * Special cases: log1p(x) is NaN with signal if x < -1 (including -INF) ; log1p(+INF) is
-         * +INF; log1p(-1) is -INF with signal; log1p(NaN) is that NaN with no signal.
-         * 
-         * Accuracy: according to an error analysis, the error is always less than 1 ulp (unit in
-         * the last place).
-         * 
-         * Constants: The hexadecimal values are the intended ones for the following constants. The
-         * decimal values may be used, provided that the compiler will convert from decimal to
-         * binary accurately enough to produce the hexadecimal values shown.
-         * 
-         * Note: Assuming log() return accurate answer, the following algorithm can be used to
-         * compute log1p(x) to within a few ULP:
-         * 
-         * u = 1+x; if(u==1.0) return x ; else return log(u)*(x/(u-1.0));
-         * 
-         * See HP-15C Advanced Functions Handbook, p.193.
-         */
-        double f = 0;
-        int k = 1, hu = 0;
-        final int hx = __HI(x); /* high word of x */
-        final int ax = hx & 0x7fffffff;
-        if (hx < 0x3FDA827A) { /* x < 0.41422 */
-            if (ax >= 0x3ff00000) { /* x <= -1.0 */
-                return x == -1.0d ? -two54 / zero : /* log1p(-1)=-inf */
-                (x - x) / (x - x); /* log1p(x<-1)=NaN */
-            }
-            if (ax < 0x3e200000) { /* |x| < 2**-29 */
-                if (two54 + x > zero /* raise inexact */
-                                && ax < 0x3c900000) /* |x| < 2**-54 */{
-                    return x;
-                }
-                return x - x * x * 0.5;
-            }
-            if (hx > 0 || hx <= ((int) 0xbfd2bec3)) { /* -0.2929<x<0.41422 */
-                k = 0;
-                f = x;
-                hu = 1;
-            }
-        }
-
-        if (hx >= 0x7ff00000) {
-            return x + x;
-        }
-        double c;
-        if (k != 0) {
-            final double u = hx < 0x43400000 ? 1.0 + x : x;
-            long ub = Double.doubleToRawLongBits(u);
-            hu = (int) (ub >> 32); /* high word of u */
-            k = (hu >> 20) - 1023;
-            c = hx < 0x43400000 ? (k > 0 ? 1.0 - (u - x) : x - (u - 1.0)) / u : 0;
-            int newhu;
-            if ((hu &= 0x000fffff) < 0x6a09e) {
-                newhu = hu | 0x3ff00000; /* normalize u */
-            } else {
-                k += 1;
-                newhu = hu | 0x3fe00000; /* normalize u/2 */
-                hu = (0x00100000 - hu) >> 2;
-            }
-            f = setHigh32bits(ub, newhu) - 1.0;
-        } else
-            c = 0;
-
-        double hfsq = 0.5 * f * f;
-        if (hu == 0) { /* |f| < 2**-20 */
-            if (f == zero) {
-                return k == 0 ? zero : k * ln2_hi + (c + k * ln2_lo);
-            }
-            final double R = hfsq * (1.0 - 0.66666666666666666 * f);
-            return k == 0 ? f - R : k * ln2_hi - ((R - (k * ln2_lo + c)) - f);
-        }
-        final double s = f / (2.0 + f);
-        final double z = s * s;
-        final double R = s * (hfsq + z * (Lp1 + z * (Lp2 + z * (Lp3 + z * (Lp4 + z * (Lp5 + z * (Lp6 + z * Lp7)))))));
-        return k == 0 ? f - (hfsq - R) : k * ln2_hi - ((hfsq - (R + (k * ln2_lo + c))) - f);
-    }
-
-    /**
-     * Returns the first floating-point argument with the sign of the second floating-point
-     * argument. For this method, a NaN {@code sign} argument is always treated as if it were
-     * positive.
-     *
-     * @param magnitude the parameter providing the magnitude of the result
-     * @param sign the parameter providing the sign of the result
-     * @return a value with the magnitude of {@code magnitude} and the sign of {@code sign}.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static double copySign(double magnitude, double sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
-    }
-
-    /**
-     * Returns the first floating-point argument with the sign of the second floating-point
-     * argument. For this method, a NaN {@code sign} argument is always treated as if it were
-     * positive.
-     *
-     * @param magnitude the parameter providing the magnitude of the result
-     * @param sign the parameter providing the sign of the result
-     * @return a value with the magnitude of {@code magnitude} and the sign of {@code sign}.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static float copySign(float magnitude, float sign) {
-        return sun.misc.FpUtils.copySign(magnitude, sign);
-    }
-
-    /**
-     * Returns the unbiased exponent used in the representation of a {@code float}. Special cases:
-     *
-     * <ul>
-     * <li>If the argument is NaN or infinite, then the result is {@link Float#MAX_EXPONENT} + 1.
-     * <li>If the argument is zero or subnormal, then the result is {@link Float#MIN_EXPONENT} -1.
-     * </ul>
-     *
-     * @param f a {@code float} value
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static int getExponent(float f) {
-        return sun.misc.FpUtils.getExponent(f);
-    }
-
-    /**
-     * Returns the unbiased exponent used in the representation of a {@code double}. Special cases:
-     *
-     * <ul>
-     * <li>If the argument is NaN or infinite, then the result is {@link Double#MAX_EXPONENT} + 1.
-     * <li>If the argument is zero or subnormal, then the result is {@link Double#MIN_EXPONENT} -1.
-     * </ul>
-     *
-     * @param d a {@code double} value
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static int getExponent(double d) {
-        return sun.misc.FpUtils.getExponent(d);
-    }
-
-    /**
-     * Returns the floating-point number adjacent to the first argument in the direction of the
-     * second argument. If both arguments compare as equal the second argument is returned.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If either argument is a NaN, then NaN is returned.
-     *
-     * <li>If both arguments are signed zeros, {@code direction} is returned unchanged (as implied
-     * by the requirement of returning the second argument if the arguments compare as equal).
-     *
-     * <li>If {@code start} is &plusmn;{@link Double#MIN_VALUE} and {@code direction} has a value
-     * such that the result should have a smaller magnitude, then a zero with the same sign as
-     * {@code start} is returned.
-     *
-     * <li>If {@code start} is infinite and {@code direction} has a value such that the result
-     * should have a smaller magnitude, {@link Double#MAX_VALUE} with the same sign as {@code start}
-     * is returned.
-     *
-     * <li>If {@code start} is equal to &plusmn; {@link Double#MAX_VALUE} and {@code direction} has
-     * a value such that the result should have a larger magnitude, an infinity with same sign as
-     * {@code start} is returned.
-     * </ul>
-     *
-     * @param start starting floating-point value
-     * @param direction value indicating which of {@code start}'s neighbors or {@code start} should
-     *            be returned
-     * @return The floating-point number adjacent to {@code start} in the direction of
-     *         {@code direction}.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static double nextAfter(double start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
-    }
-
-    /**
-     * Returns the floating-point number adjacent to the first argument in the direction of the
-     * second argument. If both arguments compare as equal a value equivalent to the second argument
-     * is returned.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If either argument is a NaN, then NaN is returned.
-     *
-     * <li>If both arguments are signed zeros, a value equivalent to {@code direction} is returned.
-     *
-     * <li>If {@code start} is &plusmn;{@link Float#MIN_VALUE} and {@code direction} has a value
-     * such that the result should have a smaller magnitude, then a zero with the same sign as
-     * {@code start} is returned.
-     *
-     * <li>If {@code start} is infinite and {@code direction} has a value such that the result
-     * should have a smaller magnitude, {@link Float#MAX_VALUE} with the same sign as {@code start}
-     * is returned.
-     *
-     * <li>If {@code start} is equal to &plusmn; {@link Float#MAX_VALUE} and {@code direction} has a
-     * value such that the result should have a larger magnitude, an infinity with same sign as
-     * {@code start} is returned.
-     * </ul>
-     *
-     * @param start starting floating-point value
-     * @param direction value indicating which of {@code start}'s neighbors or {@code start} should
-     *            be returned
-     * @return The floating-point number adjacent to {@code start} in the direction of
-     *         {@code direction}.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static float nextAfter(float start, double direction) {
-        return sun.misc.FpUtils.nextAfter(start, direction);
-    }
-
-    /**
-     * Returns the floating-point value adjacent to {@code d} in the direction of positive infinity.
-     * This method is semantically equivalent to {@code nextAfter(d,
-     * Double.POSITIVE_INFINITY)}; however, a {@code nextUp} implementation may run faster than its
-     * equivalent {@code nextAfter} call.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is NaN.
-     *
-     * <li>If the argument is positive infinity, the result is positive infinity.
-     *
-     * <li>If the argument is zero, the result is {@link Double#MIN_VALUE}
-     *
-     * </ul>
-     *
-     * @param d starting floating-point value
-     * @return The adjacent floating-point value closer to positive infinity.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static double nextUp(double d) {
-        return sun.misc.FpUtils.nextUp(d);
-    }
-
-    /**
-     * Returns the floating-point value adjacent to {@code f} in the direction of positive infinity.
-     * This method is semantically equivalent to {@code nextAfter(f,
-     * Float.POSITIVE_INFINITY)}; however, a {@code nextUp} implementation may run faster than its
-     * equivalent {@code nextAfter} call.
-     *
-     * <p>
-     * Special Cases:
-     * <ul>
-     * <li>If the argument is NaN, the result is NaN.
-     *
-     * <li>If the argument is positive infinity, the result is positive infinity.
-     *
-     * <li>If the argument is zero, the result is {@link Float#MIN_VALUE}
-     *
-     * </ul>
-     *
-     * @param f starting floating-point value
-     * @return The adjacent floating-point value closer to positive infinity.
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static float nextUp(float f) {
-        return sun.misc.FpUtils.nextUp(f);
-    }
-
-    /**
-     * Return {@code d} &times; 2<sup>{@code scaleFactor}</sup> rounded as if performed by a single
-     * correctly rounded floating-point multiply to a member of the double value set. See the Java
-     * Language Specification for a discussion of floating-point value sets. If the exponent of the
-     * result is between {@link Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the answer is
-     * calculated exactly. If the exponent of the result would be larger than
-     * {@code Double.MAX_EXPONENT}, an infinity is returned. Note that if the result is subnormal,
-     * precision may be lost; that is, when {@code scalb(x, n)} is subnormal,
-     * {@code scalb(scalb(x, n), -n)} may not equal <i>x</i>. When the result is non-NaN, the result
-     * has the same sign as {@code d}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If the first argument is NaN, NaN is returned.
-     * <li>If the first argument is infinite, then an infinity of the same sign is returned.
-     * <li>If the first argument is zero, then a zero of the same sign is returned.
-     * </ul>
-     *
-     * @param d number to be scaled by a power of two.
-     * @param scaleFactor power of 2 used to scale {@code d}
-     * @return {@code d} &times; 2<sup>{@code scaleFactor}</sup>
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static double scalb(double d, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(d, scaleFactor);
-    }
-
-    /**
-     * Return {@code f} &times; 2<sup>{@code scaleFactor}</sup> rounded as if performed by a single
-     * correctly rounded floating-point multiply to a member of the float value set. See the Java
-     * Language Specification for a discussion of floating-point value sets. If the exponent of the
-     * result is between {@link Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the answer is
-     * calculated exactly. If the exponent of the result would be larger than
-     * {@code Float.MAX_EXPONENT}, an infinity is returned. Note that if the result is subnormal,
-     * precision may be lost; that is, when {@code scalb(x, n)} is subnormal,
-     * {@code scalb(scalb(x, n), -n)} may not equal <i>x</i>. When the result is non-NaN, the result
-     * has the same sign as {@code f}.
-     *
-     * <p>
-     * Special cases:
-     * <ul>
-     * <li>If the first argument is NaN, NaN is returned.
-     * <li>If the first argument is infinite, then an infinity of the same sign is returned.
-     * <li>If the first argument is zero, then a zero of the same sign is returned.
-     * </ul>
-     *
-     * @param f number to be scaled by a power of two.
-     * @param scaleFactor power of 2 used to scale {@code f}
-     * @return {@code f} &times; 2<sup>{@code scaleFactor}</sup>
-     * @since 1.6
-     */
-    @SuppressWarnings("deprecation")
-    public static float scalb(float f, int scaleFactor) {
-        return sun.misc.FpUtils.scalb(f, scaleFactor);
-    }
-
-    public static double setHhighbitsAddSome(double x, long highadd) {
-        return setHhighbitsAddSome(Double.doubleToRawLongBits(x), highadd);
-    }
-
-    public static double setHhighbitsORSome(double x, long highOR) {
-        return Double.longBitsToDouble(Double.doubleToRawLongBits(x) | (highOR << 32));
-    }
-
-    public static double setHhighbitsAddSome(long xl, long highadd) {
-        return Double.longBitsToDouble((xl & clearHighmask) | (xl + highadd));
-    }
-
-    private static int __HI(double x) {
-        return (int) (Double.doubleToRawLongBits(x) >> 32);
-    }
-
-    private static int __LO(double x) {
-        return (int) Double.doubleToRawLongBits(x);
-    }
-
-    private static double clearLow32bits(double x) {
-        return Double.longBitsToDouble(Double.doubleToRawLongBits(x) & 0xFFFFFFFF00000000L);
-    }
-
-    private static double setHigh32bits(double x, long newhigh) {
-        return setHigh32bits(Double.doubleToRawLongBits(x), newhigh);
-    }
-
-    private static double setHigh32bitsXOR(double x, long toXor) {
-        return Double.longBitsToDouble((Double.doubleToRawLongBits(x)) ^ toXor);
-    }
-
-    private static double addToHighBits(double x, long toadd) {
-        return addToHighBits(Double.doubleToRawLongBits(x), toadd);
-    }
-
-    private static double addToHighBits(long x, long toadd) {
-        return Double.longBitsToDouble((x & clearHighmask) | (((x >> 32) + toadd) << 32));
-    }
-
-    private static double setHigh32bits(long x, long newhigh) {
-        return Double.longBitsToDouble((x & clearHighmask) | (newhigh << 32));
-    }
-
-    private static double setHigh32bitsDontMask(long x, long newhigh) {
-        return Double.longBitsToDouble(x | (newhigh << 32));
-    }
-
-    private static double setHigh32bits(long newhigh) {
-        return Double.longBitsToDouble((newhigh << 32));
-    }
-
-    private static double ldexp(double x, int exp) {
-        double r = x;
-        // set exponent of result to exp
-        long ir = Double.doubleToRawLongBits(r);
-        long oldexp = Math.getExponent(r);
-        long newexpbits = (oldexp + exp + DoubleConsts.EXP_BIAS) << (DoubleConsts.SIGNIFICAND_WIDTH - 1);
-        // clear exp bits to zero
-        ir &= ~DoubleConsts.EXP_BIT_MASK;
-        ir |= newexpbits;
-        return Double.longBitsToDouble(ir);
-    }
-
-    @SuppressWarnings("deprecation")
-    private static double fmod(double x, double y) {
-        int ir, iy;
-        double r, w;
-
-        if ((y == 0.0) || FpUtils.isNaN(y) || !FpUtils.isFinite(x)) {
-            return (x * y) / (x * y);
-        }
-
-        r = Math.abs(x);
-        double absy = Math.abs(y);
-        iy = getExponent(absy);
-        while (r >= absy) {
-            ir = getExponent(r);
-            w = ldexp(absy, ir - iy);
-            r -= (w <= r ? w : w * 0.5);
-        }
-        return (x >= 0.0 ? r : -r);
-    }
-
-}
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/EdgesTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/EdgesTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -38,12 +38,13 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.common.inlining.*;
+import com.oracle.graal.phases.common.inlining.policy.*;
 import com.oracle.graal.phases.tiers.*;
 
 public class EdgesTest extends GraalCompilerTest {
 
     @NodeInfo
-    static class TestNode extends Node {
+    static final class TestNode extends Node {
         @Input NodeInputList<ValueNode> itail;
         @Input ConstantNode i1;
         @Input FloatingNode i2;
@@ -115,7 +116,7 @@
         StructuredGraph g = parseProfiled(javaMethod);
         Assumptions assumptions = new Assumptions(false);
         HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
-        new InliningPhase(new CanonicalizerPhase(true)).apply(g, context);
+        new InliningPhase(new InlineMethodSubstitutionsPolicy(), new CanonicalizerPhase(true)).apply(g, context);
         new CanonicalizerPhase(false).apply(g, context);
         Assert.assertTrue(g.getNodes().filter(CheckCastNode.class).isEmpty());
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BlackholeSubstitutions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2015, 2015, 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 com.oracle.graal.api.replacements.*;
+import com.oracle.graal.replacements.nodes.*;
+
+@ClassSubstitution(className = "org.openjdk.jmh.infra.Blackhole", optional = true)
+public class BlackholeSubstitutions {
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, Object v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, Object[] v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, byte v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, boolean v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, char v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, short v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, int v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, long v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, float v) {
+        BlackholeNode.consume(v);
+    }
+
+    @SuppressWarnings("unused")
+    @MethodSubstitution(isStatic = false, forced = true)
+    public static void consume(final Object thisObj, double v) {
+        BlackholeNode.consume(v);
+    }
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/BoxingSnippets.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -176,6 +176,22 @@
         ValueNode value = box.getValue();
         if (value.isConstant()) {
             JavaConstant sourceConstant = value.asJavaConstant();
+            if (sourceConstant.getKind() != box.getBoxingKind() && sourceConstant.getKind().isNumericInteger()) {
+                switch (box.getBoxingKind()) {
+                    case Boolean:
+                        sourceConstant = JavaConstant.forBoolean(sourceConstant.asLong() != 0L);
+                        break;
+                    case Byte:
+                        sourceConstant = JavaConstant.forByte((byte) sourceConstant.asLong());
+                        break;
+                    case Char:
+                        sourceConstant = JavaConstant.forChar((char) sourceConstant.asLong());
+                        break;
+                    case Short:
+                        sourceConstant = JavaConstant.forShort((short) sourceConstant.asLong());
+                        break;
+                }
+            }
             JavaConstant boxedConstant = constantReflection.boxPrimitive(sourceConstant);
             if (boxedConstant != null && sourceConstant.getKind() == box.getBoxingKind()) {
                 return ConstantNode.forConstant(boxedConstant, metaAccess, box.graph());
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -68,11 +68,11 @@
             return new IterationState(this, sideEffect.asNode(), null, true);
         }
 
-        public IterationState addBranch(BeginNode begin) {
+        public IterationState addBranch(AbstractBeginNode begin) {
             return new IterationState(this, begin, null, this.invalid);
         }
 
-        public static IterationState merge(MergeNode merge, Collection<IterationState> before, boolean invalid) {
+        public static IterationState merge(AbstractMergeNode merge, Collection<IterationState> before, boolean invalid) {
             return new IterationState(null, merge, before, invalid);
         }
 
@@ -137,7 +137,7 @@
                         setStateAfter(node.graph(), stateSplit, INVALID_FRAMESTATE_BCI, false);
                     } else {
                         stateSplit.setStateAfter(null);
-                        if (frameState.usages().isEmpty()) {
+                        if (frameState.hasNoUsages()) {
                             GraphUtil.killWithUnusedFloatingInputs(frameState);
                         }
                     }
@@ -152,7 +152,7 @@
         }
 
         @Override
-        protected IterationState merge(MergeNode merge, List<IterationState> states) {
+        protected IterationState merge(AbstractMergeNode merge, List<IterationState> states) {
             boolean invalid = false;
             for (IterationState state : states) {
                 if (state.invalid) {
@@ -191,7 +191,7 @@
         }
 
         @Override
-        protected IterationState afterSplit(BeginNode node, IterationState oldState) {
+        protected IterationState afterSplit(AbstractBeginNode node, IterationState oldState) {
             return oldState.addBranch(node);
         }
 
@@ -229,7 +229,7 @@
             FrameState currentStateAfter = node.stateAfter();
             if (currentStateAfter != null || !replaceOnly) {
                 node.setStateAfter(graph.add(new FrameState(bci)));
-                if (currentStateAfter != null && currentStateAfter.usages().isEmpty()) {
+                if (currentStateAfter != null && currentStateAfter.hasNoUsages()) {
                     GraphUtil.killWithUnusedFloatingInputs(currentStateAfter);
                 }
             }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultJavaLoweringProvider.java	Wed Jan 28 19:32:47 2015 +0100
@@ -119,7 +119,7 @@
         ValueNode object = loadField.isStatic() ? staticFieldBase(graph, field) : loadField.object();
         Stamp loadStamp = loadStamp(loadField.stamp(), field.getKind());
         ConstantLocationNode location = createFieldLocation(graph, field, false);
-        assert location != null : "Field that is loaded must not be eliminated";
+        assert location != null : "Field that is loaded must not be eliminated: " + field.getDeclaringClass().toJavaName(true) + "." + field.getName();
 
         ReadNode memoryRead = graph.add(new ReadNode(object, location, loadStamp, fieldLoadBarrierType(field)));
         ValueNode readValue = implicitLoadConvert(graph, field.getKind(), memoryRead);
@@ -228,7 +228,7 @@
 
     protected void lowerLoadHubNode(LoadHubNode loadHub) {
         StructuredGraph graph = loadHub.graph();
-        if (graph.getGuardsStage().ordinal() < StructuredGraph.GuardsStage.FIXED_DEOPTS.ordinal()) {
+        if (graph.getGuardsStage().allowsFloatingGuards()) {
             return;
         }
         ValueNode hub = createReadHub(graph, loadHub.getValue(), loadHub.getGuard());
@@ -270,12 +270,12 @@
             ReadNode memoryRead = createUnsafeRead(graph, load, valueAnchorNode);
             graph.replaceFixedWithFixed(load, valueAnchorNode);
             graph.addAfterFixed(valueAnchorNode, memoryRead);
-        } else if (graph.getGuardsStage().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) {
+        } else if (!graph.getGuardsStage().allowsFloatingGuards()) {
             assert load.getKind() != Kind.Illegal;
             ReadNode memoryRead = createUnsafeRead(graph, load, null);
             // An unsafe read must not float outside its block otherwise
             // it may float above an explicit null check on its object.
-            memoryRead.setGuard(BeginNode.prevBegin(load));
+            memoryRead.setGuard(AbstractBeginNode.prevBegin(load));
             graph.replaceFixedWithFixed(load, memoryRead);
         }
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,6 +33,7 @@
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.options.*;
 
 /**
  * Method substitutions that are VM-independent.
@@ -40,6 +41,10 @@
 @ServiceProvider(ReplacementsProvider.class)
 public class GraalMethodSubstitutions implements ReplacementsProvider {
 
+    static class Options {
+        @Option(help = "") public static final OptionValue<Boolean> UseBlackholeSubstitution = new OptionValue<>(true);
+    }
+
     public void registerReplacements(MetaAccessProvider metaAccess, LoweringProvider loweringProvider, SnippetReflectionProvider snippetReflection, Replacements replacements, TargetDescription target) {
         BoxingSubstitutions.registerReplacements(replacements);
         if (Intrinsify.getValue()) {
@@ -55,6 +60,13 @@
             replacements.registerSubstitutions(Short.class, ShortSubstitutions.class);
             replacements.registerSubstitutions(UnsignedMath.class, UnsignedMathSubstitutions.class);
             replacements.registerSubstitutions(Edges.class, EdgesSubstitutions.class);
+            if (Options.UseBlackholeSubstitution.getValue()) {
+                replacements.registerSubstitutions(new Type() {
+                    public String getTypeName() {
+                        return "org.openjdk.jmh.infra.Blackhole";
+                    }
+                }, BlackholeSubstitutions.class);
+            }
         }
     }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Wed Jan 28 19:32:47 2015 +0100
@@ -246,8 +246,8 @@
      * @param trueProbability The estimated probability the the condition is true
      */
     public void startIf(LogicNode condition, double trueProbability) {
-        BeginNode thenSuccessor = graph.add(new BeginNode());
-        BeginNode elseSuccessor = graph.add(new BeginNode());
+        AbstractBeginNode thenSuccessor = graph.add(new BeginNode());
+        AbstractBeginNode elseSuccessor = graph.add(new BeginNode());
         append(new IfNode(condition, thenSuccessor, elseSuccessor, trueProbability));
         lastFixedNode = null;
 
@@ -303,7 +303,7 @@
             EndNode elseEnd = graph.add(new EndNode());
             graph.addAfterFixed(elsePart, elseEnd);
 
-            MergeNode merge = graph.add(new MergeNode());
+            AbstractMergeNode merge = graph.add(new MergeNode());
             merge.addForwardEnd(thenEnd);
             merge.addForwardEnd(elseEnd);
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/InstanceOfSnippetsTemplates.java	Wed Jan 28 19:32:47 2015 +0100
@@ -83,7 +83,7 @@
             }
         }
 
-        assert instanceOf.usages().isEmpty();
+        assert instanceOf.hasNoUsages();
         if (!instanceOf.isDeleted()) {
             GraphUtil.killWithUnusedFloatingInputs(instanceOf);
         }
@@ -234,7 +234,7 @@
         public void replaceUsingInstantiation() {
             ValueNode newValue = instantiation.asMaterialization(usage.graph(), trueValue, falseValue);
             usage.replaceAtUsages(newValue);
-            assert usage.usages().isEmpty();
+            assert usage.hasNoUsages();
             GraphUtil.killWithUnusedFloatingInputs(usage);
         }
 
@@ -245,7 +245,7 @@
             newNode.inferStamp();
             instantiation.initialize(newNode, trueValue, falseValue);
             usage.replaceAtUsages(newNode);
-            assert usage.usages().isEmpty();
+            assert usage.hasNoUsages();
             GraphUtil.killWithUnusedFloatingInputs(usage);
         }
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/MathSubstitutionsX86.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,6 +28,7 @@
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.replacements.nodes.*;
 import com.oracle.graal.replacements.nodes.MathIntrinsicNode.Operation;
 
@@ -67,6 +68,7 @@
     /**
      * Special cases from {@link Math#pow} and __ieee754_pow (in sharedRuntimeTrans.cpp).
      */
+    @MacroSubstitution(macro = MathPowNode.class)
     @MethodSubstitution(guard = UnsafeSubstitutions.GetAndSetGuard.class)
     public static double pow(double x, double y) {
         // If the second argument is positive or negative zero, then the result is 1.0.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -406,8 +406,8 @@
             usage.replaceFirstInput(input, intrinsifiedNode);
             Debug.log("%s: Checkcast used in a return with forNodeIntrinsic stamp", Debug.contextSnapshot(JavaMethod.class));
         } else if (usage instanceof IsNullNode) {
-            if (!usage.usages().isEmpty()) {
-                assert usage.usages().count() == 1 && usage.usages().first().predecessor() == input : usage + " " + input;
+            if (!usage.hasNoUsages()) {
+                assert usage.getUsageCount() == 1 && usage.usages().first().predecessor() == input : usage + " " + input;
                 graph.replaceFloating((FloatingNode) usage, LogicConstantNode.contradiction(graph));
                 Debug.log("%s: Replaced IsNull with false", Debug.contextSnapshot(JavaMethod.class));
             } else {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -196,7 +196,9 @@
     private final Map<String, AtomicReference<ClassReplacements>> classReplacements;
     private final Map<String, Class<?>[]> internalNameToSubstitutionClasses;
 
-    private final Map<Class<? extends SnippetTemplateCache>, SnippetTemplateCache> snippetTemplateCache;
+    // This map is key'ed by a class name instead of a Class object so that
+    // it is stable across VM executions (in support of replay compilation).
+    private final Map<String, SnippetTemplateCache> snippetTemplateCache;
 
     public ReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, Assumptions assumptions, TargetDescription target) {
         this.providers = providers.copyWith(this);
@@ -797,13 +799,13 @@
 
     @Override
     public void registerSnippetTemplateCache(SnippetTemplateCache templates) {
-        assert snippetTemplateCache.get(templates.getClass()) == null;
-        snippetTemplateCache.put(templates.getClass(), templates);
+        assert snippetTemplateCache.get(templates.getClass().getName()) == null;
+        snippetTemplateCache.put(templates.getClass().getName(), templates);
     }
 
     @Override
     public <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass) {
-        SnippetTemplateCache ret = snippetTemplateCache.get(templatesClass);
+        SnippetTemplateCache ret = snippetTemplateCache.get(templatesClass.getName());
         return templatesClass.cast(ret);
     }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Jan 28 19:32:47 2015 +0100
@@ -123,7 +123,7 @@
                     names[i] = method.getLocalVariableTable().getLocal(slotIdx, 0).getName();
 
                     Kind kind = method.getSignature().getParameterKind(i);
-                    slotIdx += kind == Kind.Long || kind == Kind.Double ? 2 : 1;
+                    slotIdx += kind.getSlotCount();
                 }
                 return true;
             }
@@ -675,7 +675,7 @@
 
         GuardsStage guardsStage = args.cacheKey.guardsStage;
         // Perform lowering on the snippet
-        if (guardsStage.ordinal() >= GuardsStage.FIXED_DEOPTS.ordinal()) {
+        if (!guardsStage.allowsFloatingGuards()) {
             new GuardLoweringPhase().apply(snippetCopy, null);
         }
         snippetCopy.setGuardsStage(guardsStage);
@@ -726,7 +726,7 @@
         Debug.dump(snippet, "SnippetTemplate after fixing memory anchoring");
 
         StartNode entryPointNode = snippet.start();
-        if (memoryAnchor.usages().isEmpty()) {
+        if (memoryAnchor.hasNoUsages()) {
             memoryAnchor.safeDelete();
         } else {
             snippetCopy.addAfterFixed(snippetCopy.start(), memoryAnchor);
@@ -737,7 +737,7 @@
         } else if (returnNodes.size() == 1) {
             this.returnNode = returnNodes.get(0);
         } else {
-            MergeNode merge = snippet.add(new MergeNode());
+            AbstractMergeNode merge = snippet.add(new MergeNode());
             List<MemoryMapNode> memMaps = returnNodes.stream().map(n -> n.getMemoryMap()).collect(Collectors.toList());
             ValueNode returnValue = InliningUtil.mergeReturns(merge, returnNodes, null);
             this.returnNode = snippet.add(new ReturnNode(returnValue));
@@ -746,7 +746,7 @@
             this.returnNode.setMemoryMap(memoryMap);
             for (MemoryMapNode mm : memMaps) {
                 if (mm != memoryMap && mm.isAlive()) {
-                    assert mm.usages().isEmpty();
+                    assert mm.hasNoUsages();
                     GraphUtil.killWithUnusedFloatingInputs(mm);
                 }
             }
@@ -986,14 +986,14 @@
                 }
             }
             if (newNode == null) {
-                assert oldNode.usages().isEmpty();
+                assert oldNode.hasNoUsages();
             } else {
                 oldNode.replaceAtUsages(newNode);
             }
         }
     };
 
-    private boolean assertSnippetKills(ScheduledNode replacee) {
+    private boolean assertSnippetKills(ValueNode replacee) {
         if (!replacee.graph().isAfterFloatingReadPhase()) {
             // no floating reads yet, ignore locations created while lowering
             return true;
@@ -1100,7 +1100,7 @@
             FixedNode firstCFGNode = entryPointNode.next();
             StructuredGraph replaceeGraph = replacee.graph();
             Map<Node, Node> replacements = bind(replaceeGraph, metaAccess, args);
-            replacements.put(entryPointNode, BeginNode.prevBegin(replacee));
+            replacements.put(entryPointNode, AbstractBeginNode.prevBegin(replacee));
             Map<Node, Node> duplicates = replaceeGraph.addDuplicates(nodes, snippet, snippet.getNodeCount(), replacements);
             Debug.dump(replaceeGraph, "After inlining snippet %s", snippet.method());
 
@@ -1176,7 +1176,7 @@
                 if (returnValue == null && replacee.usages().isNotEmpty() && replacee instanceof MemoryCheckpoint) {
                     replacer.replace(replacee, null, mmap);
                 } else {
-                    assert returnValue != null || replacee.usages().isEmpty();
+                    assert returnValue != null || replacee.hasNoUsages();
                     replacer.replace(replacee, returnValue, mmap);
                 }
                 if (returnDuplicate.isAlive()) {
@@ -1273,7 +1273,7 @@
             // Replace all usages of the replacee with the value returned by the snippet
             ReturnNode returnDuplicate = (ReturnNode) duplicates.get(returnNode);
             ValueNode returnValue = returnDuplicate.result();
-            assert returnValue != null || replacee.usages().isEmpty();
+            assert returnValue != null || replacee.hasNoUsages();
             replacer.replace(replacee, returnValue, new DuplicateMapper(duplicates, replaceeGraph.start()));
 
             if (returnDuplicate.isAlive()) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * Compares two arrays with the same length.
  */
 @NodeInfo
-public class ArrayEqualsNode extends FixedWithNextNode implements LIRLowerable, Canonicalizable, Virtualizable, MemoryAccess {
+public final class ArrayEqualsNode extends FixedWithNextNode implements LIRLowerable, Canonicalizable, Virtualizable, MemoryAccess {
 
     /** {@link Kind} of the arrays to compare. */
     protected final Kind kind;
@@ -63,7 +63,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         }
         if (GraphUtil.unproxify(array1) == GraphUtil.unproxify(array2)) {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/AssertionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/AssertionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * may need to insert a check.
  */
 @NodeInfo
-public class AssertionNode extends FixedWithNextNode implements Lowerable, Canonicalizable, LIRLowerable {
+public final class AssertionNode extends FixedWithNextNode implements Lowerable, Canonicalizable, LIRLowerable {
 
     @Input ValueNode value;
 
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitCountNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitCountNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,7 @@
 import com.oracle.graal.nodes.spi.*;
 
 @NodeInfo
-public class BitCountNode extends UnaryNode implements LIRLowerable {
+public final class BitCountNode extends UnaryNode implements LIRLowerable {
 
     public BitCountNode(ValueNode value) {
         super(StampFactory.forInteger(Kind.Int, 0, ((PrimitiveStamp) value.stamp()).getBits()), value);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanForwardNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanForwardNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * input is zero.
  */
 @NodeInfo
-public class BitScanForwardNode extends UnaryNode implements LIRLowerable {
+public final class BitScanForwardNode extends UnaryNode implements LIRLowerable {
 
     public BitScanForwardNode(ValueNode value) {
         super(StampFactory.forInteger(Kind.Int, 0, ((PrimitiveStamp) value.stamp()).getBits()), value);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanReverseNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BitScanReverseNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -36,7 +36,7 @@
  * input is zero.
  */
 @NodeInfo
-public class BitScanReverseNode extends UnaryNode implements LIRLowerable {
+public final class BitScanReverseNode extends UnaryNode implements LIRLowerable {
 
     public BitScanReverseNode(ValueNode value) {
         super(StampFactory.forInteger(Kind.Int, 0, ((PrimitiveStamp) value.stamp()).getBits()), value);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/BlackholeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2015, 2015, 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.compiler.common.type.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.spi.*;
+
+@NodeInfo
+public final class BlackholeNode extends FixedWithNextNode implements LIRLowerable {
+
+    @Input ValueNode value;
+
+    public BlackholeNode(ValueNode value) {
+        super(StampFactory.forVoid());
+        this.value = value;
+    }
+
+    @Override
+    public void generate(NodeLIRBuilderTool gen) {
+        gen.getLIRGeneratorTool().emitBlackhole(gen.operand(value));
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(boolean v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(byte v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(short v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(char v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(int v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(long v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(float v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(double v) {
+    }
+
+    @NodeIntrinsic
+    @SuppressWarnings("unused")
+    public static void consume(Object v) {
+    }
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DeferredPiNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DeferredPiNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,7 @@
  * is replaced by a {@link PiNode} once the type becomes constant (which <b>must</b> happen).
  */
 @NodeInfo
-public class DeferredPiNode extends FloatingNode implements Canonicalizable {
+public final class DeferredPiNode extends FloatingNode implements Canonicalizable {
 
     @Input ValueNode object;
     @Input ValueNode type;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectObjectStoreNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
  * {@link StateSplit} and does not include a write barrier.
  */
 @NodeInfo
-public class DirectObjectStoreNode extends FixedWithNextNode implements Lowerable {
+public final class DirectObjectStoreNode extends FixedWithNextNode implements Lowerable {
 
     @Input ValueNode object;
     @Input ValueNode value;
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ExplodeLoopNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ExplodeLoopNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -37,7 +37,7 @@
  * @see VarargsParameter
  */
 @NodeInfo
-public class ExplodeLoopNode extends FixedWithNextNode {
+public final class ExplodeLoopNode extends FixedWithNextNode {
 
     public ExplodeLoopNode() {
         super(StampFactory.forVoid());
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -134,9 +134,9 @@
             new RemoveValueProxyPhase().apply(replacementGraph);
         }
         GuardsStage guardsStage = graph().getGuardsStage();
-        if (guardsStage.ordinal() >= GuardsStage.FIXED_DEOPTS.ordinal()) {
+        if (!guardsStage.allowsFloatingGuards()) {
             new GuardLoweringPhase().apply(replacementGraph, null);
-            if (guardsStage.ordinal() >= GuardsStage.AFTER_FSA.ordinal()) {
+            if (guardsStage.areFrameStatesAtDeopts()) {
                 new FrameStateAssignmentPhase().apply(replacementGraph);
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MathPowNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, 2015, 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.spi.*;
+import com.oracle.graal.nodeinfo.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+
+/**
+ * This is an extension of {@link MacroNode} that is a {@link StateSplit} and a
+ * {@link MemoryCheckpoint}.
+ */
+@NodeInfo
+public class MathPowNode extends MacroStateSplitNode implements Canonicalizable.Binary<ValueNode> {
+
+    public MathPowNode(Invoke i) {
+        super(i);
+    }
+
+    public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode forY) {
+        if (forX.isConstant() && forY.isConstant()) {
+            double x = forX.asJavaConstant().asDouble();
+            double y = forY.asJavaConstant().asDouble();
+            return ConstantNode.forDouble(Math.pow(x, y));
+        } else {
+            return this;
+        }
+    }
+
+    public ValueNode getX() {
+        return arguments.get(0);
+    }
+
+    public ValueNode getY() {
+        return arguments.get(1);
+    }
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MemoryAnchorNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MemoryAnchorNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -43,6 +43,6 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        return usages().isEmpty() ? null : this;
+        return hasNoUsages() ? null : this;
     }
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/PureFunctionMacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/PureFunctionMacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -47,7 +47,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         } else {
             ValueNode param = arguments.get(0);
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java	Wed Jan 28 19:32:47 2015 +0100
@@ -23,6 +23,7 @@
 package com.oracle.graal.test;
 
 import java.io.*;
+import java.nio.file.*;
 import java.util.*;
 
 import junit.runner.*;
@@ -167,6 +168,23 @@
     }
 
     /**
+     * Gets the command line for the current process.
+     *
+     * @return the command line arguments for the current process or {@code null} if they are not
+     *         available
+     */
+    public static List<String> getProcessCommandLine() {
+        String processArgsFile = System.getenv().get("MX_SUBPROCESS_COMMAND_FILE");
+        if (processArgsFile != null) {
+            try {
+                return Files.readAllLines(new File(processArgsFile).toPath());
+            } catch (IOException e) {
+            }
+        }
+        return null;
+    }
+
+    /**
      * Expand any arguments starting with @ and return the resulting argument array.
      *
      * @param args
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Wed Jan 28 19:32:47 2015 +0100
@@ -63,7 +63,10 @@
  */
 public final class HotSpotTruffleRuntime extends GraalTruffleRuntime {
 
-    public static HotSpotTruffleRuntime makeInstance() {
+    public static TruffleRuntime makeInstance() {
+        if (GraalTruffleRuntime.alternateRuntime != null) {
+            return GraalTruffleRuntime.alternateRuntime;
+        }
         return new HotSpotTruffleRuntime();
     }
 
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLCallUntilOptimizedBuiltin.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLCallUntilOptimizedBuiltin.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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,8 +25,8 @@
 import java.util.concurrent.*;
 
 import com.oracle.graal.truffle.*;
+import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.*;
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
@@ -49,29 +49,43 @@
     @Child private IndirectCallNode indirectCall = Truffle.getRuntime().createIndirectCallNode();
 
     @Specialization
-    @TruffleBoundary
     public SLFunction callUntilCompiled(VirtualFrame frame, SLFunction function) {
         OptimizedCallTarget target = ((OptimizedCallTarget) function.getCallTarget());
         for (int i = 0; i < MAX_CALLS; i++) {
-            if (((GraalTruffleRuntime) Truffle.getRuntime()).isCompiling(target) || target.isValid()) {
+            if (isCompiling(target)) {
                 break;
             } else {
                 indirectCall.call(frame, target, EMPTY_ARGS);
             }
         }
+        waitForCompilation(target);
+
+        // call one more in compiled
+        indirectCall.call(frame, target, EMPTY_ARGS);
+
+        checkTarget(target);
+
+        return function;
+    }
+
+    @TruffleBoundary
+    private static void checkTarget(OptimizedCallTarget target) throws SLAssertionError {
+        if (!target.isValid()) {
+            throw new SLAssertionError("Function " + target + " invalidated.");
+        }
+    }
+
+    @TruffleBoundary
+    private static void waitForCompilation(OptimizedCallTarget target) {
         try {
             ((GraalTruffleRuntime) Truffle.getRuntime()).waitForCompilation(target, 640000);
         } catch (ExecutionException | TimeoutException e) {
             throw new RuntimeException(e);
         }
-
-        // call one more in compiled
-        indirectCall.call(frame, target, EMPTY_ARGS);
+    }
 
-        if (!target.isValid()) {
-            throw new SLAssertionError("Function " + target + " invalidated.");
-        }
-
-        return function;
+    @TruffleBoundary
+    private static boolean isCompiling(OptimizedCallTarget target) {
+        return ((GraalTruffleRuntime) Truffle.getRuntime()).isCompiling(target) || target.isValid();
     }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CompilationProfile.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,8 +28,6 @@
 
 public class CompilationProfile {
 
-    private static final int TIMESTAMP_THRESHOLD = Math.max(TruffleCompilationThreshold.getValue() / 2, 1);
-
     /**
      * Number of times an installed code for this tree was invalidated.
      */
@@ -112,7 +110,7 @@
         interpreterCallAndLoopCount++;
 
         int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount;
-        if (callsMissing == TIMESTAMP_THRESHOLD) {
+        if (callsMissing == getTimestampThreshold()) {
             timestamp = System.nanoTime();
         }
     }
@@ -130,7 +128,7 @@
     }
 
     public void deferCompilation() {
-        ensureProfiling(0, TIMESTAMP_THRESHOLD + 1);
+        ensureProfiling(0, getTimestampThreshold() + 1);
         timestamp = 0;
         deferedCount++;
     }
@@ -139,7 +137,7 @@
         interpreterCallAndLoopCount += count;
 
         int callsMissing = compilationCallAndLoopThreshold - interpreterCallAndLoopCount;
-        if (callsMissing <= TIMESTAMP_THRESHOLD && callsMissing + count > TIMESTAMP_THRESHOLD) {
+        if (callsMissing <= getTimestampThreshold() && callsMissing + count > getTimestampThreshold()) {
             timestamp = System.nanoTime();
         }
     }
@@ -153,4 +151,8 @@
     public long getTimestamp() {
         return timestamp;
     }
+
+    private static int getTimestampThreshold() {
+        return Math.max(TruffleCompilationThreshold.getValue() / 2, 1);
+    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,10 +22,13 @@
  */
 package com.oracle.graal.truffle;
 
+import java.nio.*;
+import java.lang.reflect.*;
 import java.util.*;
 
 import sun.misc.*;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 
@@ -35,11 +38,6 @@
  * frame object would show up very late and would be hard to identify.
  */
 public final class FrameWithoutBoxing implements VirtualFrame, MaterializedFrame {
-    private static final long OBJECT_BASE_OFFSET = Unsafe.ARRAY_OBJECT_BASE_OFFSET;
-    private static final long OBJECT_INDEX_SCALE = Unsafe.ARRAY_OBJECT_INDEX_SCALE;
-    private static final long PRIMITIVE_BASE_OFFSET = Unsafe.ARRAY_LONG_BASE_OFFSET;
-    private static final long PRIMITIVE_INDEX_SCALE = Unsafe.ARRAY_LONG_INDEX_SCALE;
-
     private final FrameDescriptor descriptor;
     private final Object[] arguments;
     private Object[] locals;
@@ -58,7 +56,7 @@
 
     @Override
     public Object[] getArguments() {
-        return CompilerDirectives.unsafeCast(arguments, Object[].class, true, true);
+        return unsafeCast(arguments, Object[].class, true, true);
     }
 
     @Override
@@ -73,20 +71,20 @@
     }
 
     private Object[] getLocals() {
-        return CompilerDirectives.unsafeCast(locals, Object[].class, true, true);
+        return unsafeCast(locals, Object[].class, true, true);
     }
 
     private long[] getPrimitiveLocals() {
-        return CompilerDirectives.unsafeCast(this.primitiveLocals, long[].class, true, true);
+        return unsafeCast(this.primitiveLocals, long[].class, true, true);
     }
 
     private byte[] getTags() {
-        return CompilerDirectives.unsafeCast(tags, byte[].class, true, true);
+        return unsafeCast(tags, byte[].class, true, true);
     }
 
     private Object getObjectUnsafe(FrameSlot slot) {
         int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetObject(getLocals(), OBJECT_BASE_OFFSET + slotIndex * OBJECT_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot);
+        return unsafeGetObject(getLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slotIndex * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Object.ordinal(), slot);
     }
 
     @Override
@@ -96,7 +94,7 @@
     }
 
     private void setObjectUnsafe(FrameSlot slot, Object value) {
-        CompilerDirectives.unsafePutObject(getLocals(), OBJECT_BASE_OFFSET + slot.getIndex() * OBJECT_INDEX_SCALE, value, slot);
+        unsafePutObject(getLocals(), Unsafe.ARRAY_OBJECT_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_OBJECT_INDEX_SCALE, value, slot);
     }
 
     @Override
@@ -106,8 +104,9 @@
     }
 
     private byte getByteUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetByte(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Byte.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Byte);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Byte.ordinal();
+        return unsafeGetByte(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -117,7 +116,8 @@
     }
 
     private void setByteUnsafe(FrameSlot slot, byte value) {
-        CompilerDirectives.unsafePutByte(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Boolean);
+        unsafePutByte(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -127,8 +127,9 @@
     }
 
     private boolean getBooleanUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetBoolean(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Boolean.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Boolean);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Boolean.ordinal();
+        return unsafeGetBoolean(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -138,7 +139,8 @@
     }
 
     private void setBooleanUnsafe(FrameSlot slot, boolean value) {
-        CompilerDirectives.unsafePutBoolean(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Boolean);
+        unsafePutBoolean(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -148,8 +150,9 @@
     }
 
     private float getFloatUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetFloat(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Float.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Float);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Float.ordinal();
+        return unsafeGetFloat(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -159,7 +162,8 @@
     }
 
     private void setFloatUnsafe(FrameSlot slot, float value) {
-        CompilerDirectives.unsafePutFloat(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Float);
+        unsafePutFloat(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -169,8 +173,9 @@
     }
 
     private long getLongUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetLong(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Long.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Long);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Long.ordinal();
+        return unsafeGetLong(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -180,7 +185,8 @@
     }
 
     private void setLongUnsafe(FrameSlot slot, long value) {
-        CompilerDirectives.unsafePutLong(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Long);
+        unsafePutLong(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -190,8 +196,9 @@
     }
 
     private int getIntUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetInt(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Int.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Int);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Int.ordinal();
+        return unsafeGetInt(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -201,7 +208,8 @@
     }
 
     private void setIntUnsafe(FrameSlot slot, int value) {
-        CompilerDirectives.unsafePutInt(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Int);
+        unsafePutInt(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -211,8 +219,9 @@
     }
 
     private double getDoubleUnsafe(FrameSlot slot) {
-        int slotIndex = slot.getIndex();
-        return CompilerDirectives.unsafeGetDouble(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slotIndex * PRIMITIVE_INDEX_SCALE, this.getTags()[slotIndex] == FrameSlotKind.Double.ordinal(), slot);
+        long offset = alignPrimitive(slot, Kind.Double);
+        boolean condition = this.getTags()[slot.getIndex()] == FrameSlotKind.Double.ordinal();
+        return unsafeGetDouble(getPrimitiveLocals(), offset, condition, slot);
     }
 
     @Override
@@ -222,7 +231,8 @@
     }
 
     private void setDoubleUnsafe(FrameSlot slot, double value) {
-        CompilerDirectives.unsafePutDouble(getPrimitiveLocals(), PRIMITIVE_BASE_OFFSET + slot.getIndex() * PRIMITIVE_INDEX_SCALE, value, slot);
+        long offset = alignPrimitive(slot, Kind.Double);
+        unsafePutDouble(getPrimitiveLocals(), offset, value, slot);
     }
 
     @Override
@@ -256,6 +266,16 @@
         }
     }
 
+    private static long alignPrimitive(FrameSlot slot, Kind forKind) {
+        long offset = Unsafe.ARRAY_LONG_BASE_OFFSET + slot.getIndex() * (long) Unsafe.ARRAY_LONG_INDEX_SCALE;
+        if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
+            // On big endian, we use int in long type, which means, when byteCount() <=4, the value
+            // is right aligned in the 4 byte half, which has the lower address.
+            offset += Kind.Long.getByteCount() - Math.min((long) Unsafe.ARRAY_LONG_INDEX_SCALE, 4 + forKind.getByteCount());
+        }
+        return offset;
+    }
+
     @Override
     public Object getValue(FrameSlot slot) {
         int slotIndex = slot.getIndex();
@@ -338,4 +358,95 @@
     public boolean isDouble(FrameSlot slot) {
         return getTag(slot) == FrameSlotKind.Double.ordinal();
     }
+
+    @SuppressWarnings({"unchecked", "unused"})
+    static <T> T unsafeCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
+        return (T) value;
+    }
+
+    @SuppressWarnings("unused")
+    static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getBoolean(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getByte(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getInt(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getLong(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getFloat(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getDouble(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
+        return UNSAFE.getObject(receiver, offset);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
+        UNSAFE.putBoolean(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) {
+        UNSAFE.putByte(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) {
+        UNSAFE.putInt(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) {
+        UNSAFE.putLong(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) {
+        UNSAFE.putFloat(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) {
+        UNSAFE.putDouble(receiver, offset, value);
+    }
+
+    @SuppressWarnings("unused")
+    static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) {
+        UNSAFE.putObject(receiver, offset, value);
+    }
+
+    private static final Unsafe UNSAFE = getUnsafe();
+
+    private static Unsafe getUnsafe() {
+        try {
+            return Unsafe.getUnsafe();
+        } catch (SecurityException e) {
+        }
+        try {
+            Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe");
+            theUnsafeInstance.setAccessible(true);
+            return (Unsafe) theUnsafeInstance.get(Unsafe.class);
+        } catch (Exception e) {
+            throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e);
+        }
+    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,6 +41,8 @@
 
 public abstract class GraalTruffleRuntime implements TruffleRuntime {
 
+    public static TruffleRuntime alternateRuntime;
+
     private ArrayList<String> includes;
     private ArrayList<String> excludes;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,6 +27,7 @@
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
 import java.util.stream.*;
 
@@ -160,7 +161,7 @@
         Object result = doInvoke(args);
         Class<?> klass = profiledReturnType;
         if (klass != null && CompilerDirectives.inCompiledCode() && profiledReturnTypeAssumption.isValid()) {
-            result = CompilerDirectives.unsafeCast(result, klass, true, true);
+            result = FrameWithoutBoxing.unsafeCast(result, klass, true, true);
         }
         return result;
     }
@@ -250,7 +251,7 @@
     public final Object callRoot(Object[] originalArguments) {
         Object[] args = originalArguments;
         if (this.profiledArgumentTypesAssumption != null && CompilerDirectives.inCompiledCode() && profiledArgumentTypesAssumption.isValid()) {
-            args = CompilerDirectives.unsafeCast(castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true);
+            args = FrameWithoutBoxing.unsafeCast(castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true);
             if (TruffleArgumentTypeSpeculation.getValue()) {
                 args = castArguments(args);
             }
@@ -314,8 +315,18 @@
     }
 
     public void compile() {
+        compile(TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue());
+    }
+
+    public void compile(boolean mayBeAsynchronous) {
         if (!runtime.isCompiling(this)) {
-            runtime.compile(this, TruffleBackgroundCompilation.getValue() && !TruffleCompilationExceptionsAreThrown.getValue());
+            runtime.compile(this, mayBeAsynchronous);
+        } else if (!mayBeAsynchronous && runtime.isCompiling(this)) {
+            try {
+                runtime.waitForCompilation(this, 20000);
+            } catch (ExecutionException | TimeoutException e) {
+                Debug.log(3, e.getMessage());
+            }
         }
     }
 
@@ -397,7 +408,7 @@
     private Object[] castArguments(Object[] originalArguments) {
         Object[] castArguments = new Object[profiledArgumentTypes.length];
         for (int i = 0; i < profiledArgumentTypes.length; i++) {
-            castArguments[i] = profiledArgumentTypes[i] != null ? CompilerDirectives.unsafeCast(originalArguments[i], profiledArgumentTypes[i], true, true) : originalArguments[i];
+            castArguments[i] = profiledArgumentTypes[i] != null ? FrameWithoutBoxing.unsafeCast(originalArguments[i], profiledArgumentTypes[i], true, true) : originalArguments[i];
         }
         return castArguments;
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,12 +30,11 @@
 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.*;
+import com.oracle.graal.graph.Graph.Mark;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Graph.Mark;
 import com.oracle.graal.graph.Node;
 import com.oracle.graal.loop.*;
 import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
@@ -73,10 +72,10 @@
     private final ResolvedJavaMethod callDirectMethod;
     private final ResolvedJavaMethod callSiteProxyMethod;
 
-    public PartialEvaluator(Providers providers, TruffleCache truffleCache) {
+    public PartialEvaluator(Providers providers, TruffleCache truffleCache, SnippetReflectionProvider snippetReflection) {
         this.providers = providers;
         this.canonicalizer = new CanonicalizerPhase(!ImmutableCode.getValue());
-        this.snippetReflection = Graal.getRequiredCapability(SnippetReflectionProvider.class);
+        this.snippetReflection = snippetReflection;
         this.truffleCache = truffleCache;
         this.callDirectMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.getCallDirectMethod());
         this.callSiteProxyMethod = providers.getMetaAccess().lookupJavaMethod(GraalFrameInstance.CallNodeFrame.METHOD);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -68,8 +68,8 @@
     private final ResolvedJavaType errorClass;
     private final ResolvedJavaType controlFlowExceptionClass;
 
-    private final ResolvedJavaMethod callRootMethod;
-    private final ResolvedJavaMethod callInlinedMethod;
+    protected final ResolvedJavaMethod callRootMethod;
+    protected final ResolvedJavaMethod callInlinedMethod;
 
     private long counter;
 
@@ -215,6 +215,10 @@
                     map.put("nodeCount", graph.getNodeCount());
                     map.put("method", method.toString());
                     TracePerformanceWarningsListener.logPerformanceWarning(String.format("Method on fast path contains more than %d graal nodes.", warnNodeCount), map);
+
+                    try (Scope s2 = Debug.scope("TrufflePerformanceWarnings")) {
+                        Debug.dump(graph, "performance warning");
+                    }
                 }
             }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,6 +31,7 @@
 import com.oracle.graal.api.code.Assumptions.Assumption;
 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.compiler.target.*;
 import com.oracle.graal.debug.*;
@@ -85,7 +86,7 @@
         this.config = GraphBuilderConfiguration.getDefault().withSkippedExceptionTypes(skippedExceptionTypes);
         this.truffleCache = new TruffleCacheImpl(providers, eagerConfig, config, TruffleCompilerImpl.Optimizations);
 
-        this.partialEvaluator = new PartialEvaluator(providers, truffleCache);
+        this.partialEvaluator = new PartialEvaluator(providers, truffleCache, Graal.getRequiredCapability(SnippetReflectionProvider.class));
 
         if (Debug.isEnabled()) {
             DebugEnvironment.initialize(System.out);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.truffle;
 
+import java.util.concurrent.atomic.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
 import com.oracle.truffle.api.*;
@@ -31,6 +33,8 @@
  * {@linkplain Debug#scope(Object) debug scopes}.
  */
 public class TruffleDebugJavaMethod implements JavaMethod {
+    private static final AtomicInteger nextId = new AtomicInteger();
+    private final int id;
     private final RootCallTarget compilable;
 
     private static final JavaType declaringClass = new JavaType() {
@@ -86,6 +90,7 @@
 
     public TruffleDebugJavaMethod(RootCallTarget compilable) {
         this.compilable = compilable;
+        this.id = nextId.incrementAndGet();
     }
 
     @Override
@@ -107,7 +112,7 @@
     }
 
     public String getName() {
-        return compilable.toString().replace('.', '_').replace(' ', '_');
+        return compilable.toString().replace('.', '_').replace(' ', '_') + "_" + id;
     }
 
     public JavaType getDeclaringClass() {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/AssumptionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/AssumptionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -35,7 +35,7 @@
 import com.oracle.graal.truffle.*;
 
 @NodeInfo
-public class AssumptionNode extends MacroNode implements com.oracle.graal.graph.IterableNodeType, Simplifiable {
+public final class AssumptionNode extends MacroNode implements Simplifiable {
 
     public AssumptionNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/BailoutNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
 import com.oracle.graal.replacements.nodes.*;
 
 @NodeInfo
-public class BailoutNode extends MacroNode implements Canonicalizable {
+public final class BailoutNode extends MacroNode implements Canonicalizable {
 
     public BailoutNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -83,7 +83,7 @@
     }
 
     @Override
-    public IntegerExactArithmeticSplitNode createSplit(BeginNode next, BeginNode deopt) {
+    public IntegerExactArithmeticSplitNode createSplit(AbstractBeginNode next, AbstractBeginNode deopt) {
         return graph().add(new IntegerAddExactSplitNode(stamp(), getX(), getY(), next, deopt));
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
 @NodeInfo
 public class IntegerAddExactSplitNode extends IntegerExactArithmeticSplitNode {
 
-    public IntegerAddExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, BeginNode next, BeginNode overflowSuccessor) {
+    public IntegerAddExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, AbstractBeginNode next, AbstractBeginNode overflowSuccessor) {
         super(stamp, x, y, next, overflowSuccessor);
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -22,11 +22,10 @@
  */
 package com.oracle.graal.truffle.nodes.arithmetic;
 
-import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 
-interface IntegerExactArithmeticNode extends Lowerable, IterableNodeType {
+interface IntegerExactArithmeticNode extends Lowerable {
 
-    IntegerExactArithmeticSplitNode createSplit(BeginNode next, BeginNode deopt);
+    IntegerExactArithmeticSplitNode createSplit(AbstractBeginNode next, AbstractBeginNode deopt);
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,12 +32,12 @@
 @NodeInfo
 public abstract class IntegerExactArithmeticSplitNode extends ControlSplitNode implements LIRLowerable {
 
-    @Successor BeginNode overflowSuccessor;
-    @Successor BeginNode next;
+    @Successor AbstractBeginNode overflowSuccessor;
+    @Successor AbstractBeginNode next;
     @Input ValueNode x;
     @Input ValueNode y;
 
-    public IntegerExactArithmeticSplitNode(Stamp stamp, ValueNode x, ValueNode y, BeginNode next, BeginNode overflowSuccessor) {
+    public IntegerExactArithmeticSplitNode(Stamp stamp, ValueNode x, ValueNode y, AbstractBeginNode next, AbstractBeginNode overflowSuccessor) {
         super(stamp);
         this.x = x;
         this.y = y;
@@ -46,15 +46,15 @@
     }
 
     @Override
-    public double probability(BeginNode successor) {
+    public double probability(AbstractBeginNode successor) {
         return successor == next ? 1 : 0;
     }
 
-    public BeginNode getNext() {
+    public AbstractBeginNode getNext() {
         return next;
     }
 
-    public BeginNode getOverflowSuccessor() {
+    public AbstractBeginNode getOverflowSuccessor() {
         return overflowSuccessor;
     }
 
@@ -81,7 +81,7 @@
             FixedNode next = previous.next();
             previous.setNext(null);
             DeoptimizeNode deopt = floatingNode.graph().add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.ArithmeticException));
-            BeginNode normalBegin = floatingNode.graph().add(new BeginNode());
+            AbstractBeginNode normalBegin = floatingNode.graph().add(new BeginNode());
             normalBegin.setNext(next);
             IntegerExactArithmeticSplitNode split = node.createSplit(normalBegin, BeginNode.begin(deopt));
             previous.setNext(split);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -80,7 +80,7 @@
     }
 
     @Override
-    public IntegerExactArithmeticSplitNode createSplit(BeginNode next, BeginNode deopt) {
+    public IntegerExactArithmeticSplitNode createSplit(AbstractBeginNode next, AbstractBeginNode deopt) {
         return graph().add(new IntegerMulExactSplitNode(stamp(), getX(), getY(), next, deopt));
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
 @NodeInfo
 public class IntegerMulExactSplitNode extends IntegerExactArithmeticSplitNode {
 
-    public IntegerMulExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, BeginNode next, BeginNode overflowSuccessor) {
+    public IntegerMulExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, AbstractBeginNode next, AbstractBeginNode overflowSuccessor) {
         super(stamp, x, y, next, overflowSuccessor);
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -84,7 +84,7 @@
     }
 
     @Override
-    public IntegerExactArithmeticSplitNode createSplit(BeginNode next, BeginNode deopt) {
+    public IntegerExactArithmeticSplitNode createSplit(AbstractBeginNode next, AbstractBeginNode deopt) {
         return graph().add(new IntegerSubExactSplitNode(stamp(), getX(), getY(), next, deopt));
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactSplitNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactSplitNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,7 +31,7 @@
 @NodeInfo
 public class IntegerSubExactSplitNode extends IntegerExactArithmeticSplitNode {
 
-    public IntegerSubExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, BeginNode next, BeginNode overflowSuccessor) {
+    public IntegerSubExactSplitNode(Stamp stamp, ValueNode x, ValueNode y, AbstractBeginNode next, AbstractBeginNode overflowSuccessor) {
         super(stamp, x, y, next, overflowSuccessor);
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/CompilationConstantNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/CompilationConstantNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,7 +28,7 @@
 import com.oracle.graal.nodes.*;
 
 @NodeInfo
-public class CompilationConstantNode extends NeverPartOfCompilationNode implements Canonicalizable {
+public final class CompilationConstantNode extends NeverPartOfCompilationNode implements Canonicalizable {
 
     public CompilationConstantNode(Invoke invoke) {
         super(invoke, "The value could not be reduced to a compile time constant.");
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/NeverInlineMacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/asserts/NeverInlineMacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -28,7 +28,7 @@
 import com.oracle.graal.replacements.nodes.*;
 
 @NodeInfo
-public class NeverInlineMacroNode extends MacroStateSplitNode implements com.oracle.graal.graph.IterableNodeType {
+public final class NeverInlineMacroNode extends MacroStateSplitNode implements com.oracle.graal.graph.IterableNodeType {
 
     public NeverInlineMacroNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -46,7 +46,7 @@
  * class.
  */
 @NodeInfo
-public class NewFrameNode extends FixedWithNextNode implements IterableNodeType, VirtualizableAllocation, Canonicalizable {
+public final class NewFrameNode extends FixedWithNextNode implements IterableNodeType, VirtualizableAllocation, Canonicalizable {
 
     @Input ValueNode descriptor;
     @Input ValueNode arguments;
@@ -96,7 +96,7 @@
     }
 
     @NodeInfo
-    public static class VirtualOnlyInstanceNode extends VirtualInstanceNode {
+    public static final class VirtualOnlyInstanceNode extends VirtualInstanceNode {
 
         protected boolean allowMaterialization;
 
@@ -226,7 +226,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().isEmpty()) {
+        if (hasNoUsages()) {
             return null;
         } else {
             return this;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -33,15 +33,14 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
 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.
+ * Substitution for method CompilerDirectives#unsafeGet*.
  */
 @NodeInfo
-public class CustomizedUnsafeLoadFinalNode extends FixedWithNextNode implements Canonicalizable, Virtualizable, Lowerable {
+public final class CustomizedUnsafeLoadFinalNode extends FixedWithNextNode implements Canonicalizable, Virtualizable, Lowerable {
     @Input ValueNode object;
     @Input ValueNode offset;
     @Input ValueNode condition;
@@ -76,7 +75,7 @@
             ValueNode offsetValue = tool.getReplacedValue(offset);
             if (offsetValue.isConstant()) {
                 long constantOffset = offsetValue.asJavaConstant().asLong();
-                int entryIndex = state.getVirtualObject().entryIndexForOffset(constantOffset);
+                int entryIndex = state.getVirtualObject().entryIndexForOffset(constantOffset, accessKind);
                 if (entryIndex != -1) {
                     ValueNode entry = state.getEntry(entryIndex);
                     if (entry.getKind() == getKind() || state.getVirtualObject().entryKind(entryIndex) == accessKind) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadMacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,14 +32,12 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
-import com.oracle.truffle.api.*;
 
 /**
- * Macro node for {@link CompilerDirectives#unsafeGetInt(Object, long, boolean, Object)} and
- * friends.
+ * Macro node for CompilerDirectives#unsafeGetInt*.
  */
 @NodeInfo
-public class CustomizedUnsafeLoadMacroNode extends NeverPartOfCompilationNode implements Canonicalizable {
+public final class CustomizedUnsafeLoadMacroNode extends NeverPartOfCompilationNode implements Canonicalizable {
 
     private static final int ARGUMENT_COUNT = 4;
     private static final int OBJECT_ARGUMENT_INDEX = 0;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreMacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreMacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -30,13 +30,12 @@
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
-import com.oracle.truffle.api.*;
 
 /**
- * Macro node for method {@link CompilerDirectives#unsafePutInt(Object, long, int, Object)} et al.
+ * Macro node for method CompilerDirectives#unsafePut*.
  */
 @NodeInfo
-public class CustomizedUnsafeStoreMacroNode extends NeverPartOfCompilationNode implements Canonicalizable, StateSplit {
+public final class CustomizedUnsafeStoreMacroNode extends NeverPartOfCompilationNode implements Canonicalizable, StateSplit {
     private static final int ARGUMENT_COUNT = 4;
     private static final int OBJECT_ARGUMENT_INDEX = 0;
     private static final int OFFSET_ARGUMENT_INDEX = 1;
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -31,10 +31,9 @@
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
-import com.oracle.truffle.api.*;
 
 /**
- * Macro node for method {@link CompilerDirectives#unsafeCast(Object, Class, boolean, boolean)}.
+ * Macro node for method CompilerDirectives#unsafeCast.
  */
 @NodeInfo
 public class UnsafeTypeCastMacroNode extends NeverPartOfCompilationNode implements Simplifiable {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -74,12 +74,12 @@
     @MacroSubstitution(macro = BailoutNode.class, isStatic = true)
     public static native void bailout(String reason);
 
+    @MacroSubstitution(macro = IsCompilationConstantNode.class, isStatic = true)
+    public static native boolean isCompilationConstant(Object value);
+
     @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true)
     public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
 
-    @MacroSubstitution(macro = IsCompilationConstantNode.class, isStatic = true)
-    public static native boolean isCompilationConstant(Object value);
-
     @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
     public static native boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/FrameWithoutBoxingSubstitutions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -23,8 +23,10 @@
 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.frame.*;
+import com.oracle.graal.truffle.nodes.typesystem.*;
 import com.oracle.truffle.api.frame.*;
 
 @ClassSubstitution(FrameWithoutBoxing.class)
@@ -34,4 +36,49 @@
     public static MaterializedFrame materialize(FrameWithoutBoxing frame) {
         return MaterializeFrameNode.materialize(frame);
     }
+
+    @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true)
+    public static native Object unsafeCast(Object value, Class<?> clazz, boolean condition, boolean nonNull);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeLoadMacroNode.class, isStatic = true)
+    public static native Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity);
+
+    @MacroSubstitution(macro = CustomizedUnsafeStoreMacroNode.class, isStatic = true)
+    public static native void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.virtual.bench/.checkstyle.exclude	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,1 @@
+src_gen
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.virtual.bench/src/com/oracle/graal/virtual/bench/PartialEscapeBench.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, 2015, 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.virtual.bench;
+
+import org.openjdk.jmh.annotations.*;
+
+public class PartialEscapeBench {
+
+    private static class Thing {
+        final int id;
+        final String name;
+
+        Thing(int id, String name) {
+            this.id = id;
+            this.name = name;
+        }
+    }
+
+    @State(Scope.Thread)
+    public static class ThingsCache {
+
+        private Thing[] cache = new Thing[100];
+
+        public Thing getOrAdd(Thing input) {
+            if (cache[input.id] == null) {
+                cache[input.id] = input;
+            }
+            return cache[input.id];
+        }
+    }
+
+    @Benchmark
+    @Warmup(iterations = 30)
+    public String benchPartialEscape(ThingsCache cache) {
+        Thing thing = cache.getOrAdd(new Thing(42, "the answer!"));
+        return thing.name;
+    }
+}
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Wed Jan 28 19:32:47 2015 +0100
@@ -124,6 +124,9 @@
             aliases.set(node, null);
             if (node instanceof LoopExitNode) {
                 LoopExitNode loopExit = (LoopExitNode) node;
+                for (ProxyNode proxy : loopExit.proxies()) {
+                    changed |= processNode(proxy, state, effects, lastFixedNode);
+                }
                 processLoopExit(loopExit, loopEntryStates.get(loopExit.loopBegin()), state, blockEffects.get(block));
             }
             changed |= processNode(node, state, effects, lastFixedNode);
@@ -174,9 +177,7 @@
 
                 assert info.exitStates.size() == loop.getExits().size();
                 loopEntryStates.put((LoopBeginNode) loop.getHeader().getBeginNode(), loopEntryState);
-                for (int i = 0; i < loop.getExits().size(); i++) {
-                    assert info.exitStates.get(i) != null : "no loop exit state at " + loop.getExits().get(i) + " / " + loop.getHeader();
-                }
+                assert assertExitStatesNonEmpty(loop, info);
 
                 return info.exitStates;
             } else {
@@ -189,6 +190,13 @@
         throw new GraalInternalError("too many iterations at %s", loop);
     }
 
+    private boolean assertExitStatesNonEmpty(Loop<Block> loop, LoopInfo<BlockT> info) {
+        for (int i = 0; i < loop.getExits().size(); i++) {
+            assert info.exitStates.get(i) != null : "no loop exit state at " + loop.getExits().get(i) + " / " + loop.getHeader();
+        }
+        return true;
+    }
+
     protected abstract void processLoopExit(LoopExitNode exitNode, BlockT initialState, BlockT exitState, GraphEffectList effects);
 
     protected abstract MergeProcessor createMergeProcessor(Block merge);
@@ -196,7 +204,7 @@
     protected class MergeProcessor {
 
         protected final Block mergeBlock;
-        protected final MergeNode merge;
+        protected final AbstractMergeNode merge;
 
         protected final GraphEffectList mergeEffects;
         protected final GraphEffectList afterMergeEffects;
@@ -204,7 +212,7 @@
 
         public MergeProcessor(Block mergeBlock) {
             this.mergeBlock = mergeBlock;
-            this.merge = (MergeNode) mergeBlock.getBeginNode();
+            this.merge = (AbstractMergeNode) mergeBlock.getBeginNode();
             this.mergeEffects = new GraphEffectList();
             this.afterMergeEffects = new GraphEffectList();
         }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -79,7 +79,7 @@
                     schedule = null;
                     cfg = ControlFlowGraph.compute(graph, true, true, false, false);
                 } else {
-                    schedule = new SchedulePhase();
+                    schedule = new SchedulePhase(SchedulePhase.SchedulingStrategy.LATEST);
                     schedule.apply(graph, false);
                     cfg = schedule.getCFG();
                 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -32,7 +32,6 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.cfs.*;
 import com.oracle.graal.phases.common.inlining.*;
 import com.oracle.graal.phases.tiers.*;
 
@@ -73,14 +72,9 @@
 
                 new DeadCodeEliminationPhase(Optional).apply(graph);
 
-                boolean reduceOrEliminate = FlowSensitiveReduction.getValue() || ConditionalElimination.getValue();
-                if (reduceOrEliminate && OptCanonicalizer.getValue()) {
+                if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) {
                     canonicalizer.apply(graph, context);
-                    if (FlowSensitiveReduction.getValue()) {
-                        new IterativeFlowSensitiveReductionPhase(canonicalizer).apply(graph, context);
-                    } else {
-                        new IterativeConditionalEliminationPhase(canonicalizer).apply(graph, context);
-                    }
+                    new IterativeConditionalEliminationPhase(canonicalizer).apply(graph, context);
                 }
                 if (!progress) {
                     break;
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Wed Jan 28 19:32:47 2015 +0100
@@ -50,62 +50,78 @@
 
     @Override
     protected boolean processNode(Node node, PEReadEliminationBlockState state, GraphEffectList effects, FixedWithNextNode lastFixedNode) {
-        boolean deleted = super.processNode(node, state, effects, lastFixedNode);
-        if (!deleted) {
-            if (node instanceof LoadFieldNode) {
-                LoadFieldNode load = (LoadFieldNode) node;
-                if (!load.isVolatile()) {
-                    ValueNode object = GraphUtil.unproxify(load.object());
-                    ValueNode cachedValue = state.getReadCache(object, load.field(), this);
-                    if (cachedValue != null) {
-                        effects.replaceAtUsages(load, cachedValue);
-                        addScalarAlias(load, cachedValue);
-                        deleted = true;
-                    } else {
-                        state.addReadCache(object, load.field(), load, this);
-                    }
-                } else {
-                    processIdentity(state, ANY_LOCATION);
-                }
-            } else if (node instanceof StoreFieldNode) {
-                StoreFieldNode store = (StoreFieldNode) node;
-                if (!store.isVolatile()) {
-                    ValueNode object = GraphUtil.unproxify(store.object());
-                    ValueNode cachedValue = state.getReadCache(object, store.field(), this);
+        if (super.processNode(node, state, effects, lastFixedNode)) {
+            return true;
+        }
 
-                    ValueNode value = getScalarAlias(store.value());
-                    if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) {
-                        effects.deleteFixedNode(store);
-                        deleted = true;
-                    }
-                    state.killReadCache(store.field());
-                    state.addReadCache(object, store.field(), value, this);
-                } else {
-                    processIdentity(state, ANY_LOCATION);
-                }
-            } else if (node instanceof ArrayLengthNode) {
-                ArrayLengthNode length = (ArrayLengthNode) node;
-                ValueNode array = GraphUtil.unproxify(length.array());
-                ValueNode cachedValue = state.getReadCache(array, ARRAY_LENGTH_LOCATION, this);
-                if (cachedValue != null) {
-                    effects.replaceAtUsages(length, cachedValue);
-                    addScalarAlias(length, cachedValue);
-                    deleted = true;
-                } else {
-                    state.addReadCache(array, ARRAY_LENGTH_LOCATION, length, this);
-                }
-            } else if (node instanceof MemoryCheckpoint.Single) {
-                METRIC_MEMORYCHECKPOINT.increment();
-                LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
+        if (node instanceof LoadFieldNode) {
+            return processLoadField((LoadFieldNode) node, state, effects);
+        } else if (node instanceof StoreFieldNode) {
+            return processStoreField((StoreFieldNode) node, state, effects);
+        } else if (node instanceof ArrayLengthNode) {
+            return processArrayLength((ArrayLengthNode) node, state, effects);
+        } else if (node instanceof MemoryCheckpoint.Single) {
+            METRIC_MEMORYCHECKPOINT.increment();
+            LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
+            processIdentity(state, identity);
+        } else if (node instanceof MemoryCheckpoint.Multi) {
+            METRIC_MEMORYCHECKPOINT.increment();
+            for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
                 processIdentity(state, identity);
-            } else if (node instanceof MemoryCheckpoint.Multi) {
-                METRIC_MEMORYCHECKPOINT.increment();
-                for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
-                    processIdentity(state, identity);
-                }
             }
         }
-        return deleted;
+
+        return false;
+    }
+
+    private boolean processArrayLength(ArrayLengthNode length, PEReadEliminationBlockState state, GraphEffectList effects) {
+        ValueNode array = GraphUtil.unproxify(length.array());
+        ValueNode cachedValue = state.getReadCache(array, ARRAY_LENGTH_LOCATION, this);
+        if (cachedValue != null) {
+            effects.replaceAtUsages(length, cachedValue);
+            addScalarAlias(length, cachedValue);
+            return true;
+        } else {
+            state.addReadCache(array, ARRAY_LENGTH_LOCATION, length, this);
+        }
+        return false;
+    }
+
+    private boolean processStoreField(StoreFieldNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
+        if (!store.isVolatile()) {
+            ValueNode object = GraphUtil.unproxify(store.object());
+            ValueNode cachedValue = state.getReadCache(object, store.field(), this);
+
+            ValueNode value = getScalarAlias(store.value());
+            boolean result = false;
+            if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) {
+                effects.deleteFixedNode(store);
+                result = true;
+            }
+            state.killReadCache(store.field());
+            state.addReadCache(object, store.field(), value, this);
+            return result;
+        } else {
+            processIdentity(state, ANY_LOCATION);
+        }
+        return false;
+    }
+
+    private boolean processLoadField(LoadFieldNode load, PEReadEliminationBlockState state, GraphEffectList effects) {
+        if (!load.isVolatile()) {
+            ValueNode object = GraphUtil.unproxify(load.object());
+            ValueNode cachedValue = state.getReadCache(object, load.field(), this);
+            if (cachedValue != null) {
+                effects.replaceAtUsages(load, cachedValue);
+                addScalarAlias(load, cachedValue);
+                return true;
+            } else {
+                state.addReadCache(object, load.field(), load, this);
+            }
+        } else {
+            processIdentity(state, ANY_LOCATION);
+        }
+        return false;
     }
 
     private static void processIdentity(PEReadEliminationBlockState state, LocationIdentity identity) {
@@ -174,7 +190,7 @@
                     }
                 }
                 if (phi) {
-                    PhiNode phiNode = getCachedPhi(entry, value.stamp().unrestricted());
+                    PhiNode phiNode = getPhi(entry, value.stamp().unrestricted());
                     mergeEffects.addFloatingNode(phiNode, "mergeReadCache");
                     for (int i = 0; i < states.size(); i++) {
                         afterMergeEffects.addPhiInput(phiNode, states.get(i).getReadCache(key.object, key.identity, PEReadEliminationClosure.this));
@@ -206,7 +222,7 @@
                 values[i] = value;
             }
 
-            PhiNode phiNode = getCachedPhi(new ReadCacheEntry(identity, phi), values[0].stamp().unrestricted());
+            PhiNode phiNode = getPhi(new ReadCacheEntry(identity, phi), values[0].stamp().unrestricted());
             mergeEffects.addFloatingNode(phiNode, "mergeReadCachePhi");
             for (int i = 0; i < values.length; i++) {
                 afterMergeEffects.addPhiInput(phiNode, values[i]);
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeBlockState.java	Wed Jan 28 19:32:47 2015 +0100
@@ -102,7 +102,7 @@
                     commit.addLocks(monitorIds);
                 }
 
-                assert commit.usages().filter(AllocatedObjectNode.class).count() == commit.usages().count();
+                assert commit.usages().filter(AllocatedObjectNode.class).count() == commit.getUsageCount();
                 List<AllocatedObjectNode> materializedValues = commit.usages().filter(AllocatedObjectNode.class).snapshot();
                 for (int i = 0; i < commit.getValues().size(); i++) {
                     if (materializedValues.contains(commit.getValues().get(i))) {
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Wed Jan 28 19:32:47 2015 +0100
@@ -56,6 +56,38 @@
     private final NodeBitMap usages;
     private final VirtualizerToolImpl tool;
 
+    private final class CollectVirtualObjectsClosure extends NodeClosure<ValueNode> {
+        private final Set<ObjectState> virtual;
+        private final GraphEffectList effects;
+        private final BlockT state;
+
+        private CollectVirtualObjectsClosure(Set<ObjectState> virtual, GraphEffectList effects, BlockT state) {
+            this.virtual = virtual;
+            this.effects = effects;
+            this.state = state;
+        }
+
+        @Override
+        public void apply(Node usage, ValueNode value) {
+            ObjectState valueObj = getObjectState(state, value);
+            if (valueObj != null) {
+                virtual.add(valueObj);
+                effects.replaceFirstInput(usage, value, valueObj.virtual);
+            } else if (value instanceof VirtualObjectNode) {
+                ObjectState virtualObj = null;
+                for (ObjectState obj : state.getStates()) {
+                    if (value == obj.virtual) {
+                        virtualObj = obj;
+                        break;
+                    }
+                }
+                if (virtualObj != null) {
+                    virtual.add(virtualObj);
+                }
+            }
+        }
+    }
+
     /**
      * Final subclass of PartialEscapeClosure, for performance and to make everything behave nicely
      * with generics.
@@ -108,11 +140,13 @@
             return !(node instanceof CommitAllocationNode || node instanceof AllocatedObjectNode || node instanceof BoxNode);
         }
         if (isMarked) {
-            for (ValueNode input : node.inputs().filter(ValueNode.class)) {
-                ObjectState obj = getObjectState(state, input);
-                if (obj != null) {
-                    VirtualUtil.trace("replacing input %s at %s: %s", input, node, obj);
-                    replaceWithMaterialized(input, node, insertBefore, state, obj, effects, METRIC_MATERIALIZATIONS_UNHANDLED);
+            for (Node input : node.inputs()) {
+                if (input instanceof ValueNode) {
+                    ObjectState obj = getObjectState(state, (ValueNode) input);
+                    if (obj != null) {
+                        VirtualUtil.trace("replacing input %s at %s: %s", input, node, obj);
+                        replaceWithMaterialized(input, node, insertBefore, state, obj, effects, METRIC_MATERIALIZATIONS_UNHANDLED);
+                    }
                 }
             }
             if (node instanceof NodeWithState) {
@@ -124,75 +158,76 @@
 
     private void processNodeWithState(NodeWithState nodeWithState, final BlockT state, final GraphEffectList effects) {
         for (FrameState fs : nodeWithState.states()) {
-            FrameState frameState = fs;
-            if (frameState.usages().count() > 1) {
-                FrameState copy = (FrameState) frameState.copyWithInputs();
-                nodeWithState.asNode().replaceFirstInput(frameState, copy);
-                frameState = copy;
-            }
-            final Set<ObjectState> virtual = new ArraySet<>();
-            frameState.applyToNonVirtual(new NodeClosure<ValueNode>() {
+            FrameState frameState = getUniqueFramestate(nodeWithState, fs);
+            Set<ObjectState> virtual = new ArraySet<>();
+            frameState.applyToNonVirtual(new CollectVirtualObjectsClosure(virtual, effects, state));
+            collectLockedVirtualObjects(state, virtual);
+            collectReferencedVirtualObjects(state, virtual);
+            addVirtualMappings(state, effects, frameState, virtual);
+        }
+    }
+
+    private static FrameState getUniqueFramestate(NodeWithState nodeWithState, FrameState frameState) {
+        if (frameState.getUsageCount() > 1) {
+            // Can happen for example from inlined snippets with multiple state split nodes.
+            FrameState copy = (FrameState) frameState.copyWithInputs();
+            nodeWithState.asNode().replaceFirstInput(frameState, copy);
+            return copy;
+        }
+        return frameState;
+    }
 
-                @Override
-                public void apply(Node usage, ValueNode value) {
-                    ObjectState valueObj = getObjectState(state, value);
-                    if (valueObj != null) {
-                        virtual.add(valueObj);
-                        effects.replaceFirstInput(usage, value, valueObj.virtual);
-                    } else if (value instanceof VirtualObjectNode) {
-                        ObjectState virtualObj = null;
-                        for (ObjectState obj : state.getStates()) {
-                            if (value == obj.virtual) {
-                                virtualObj = obj;
-                                break;
-                            }
-                        }
-                        if (virtualObj != null) {
-                            virtual.add(virtualObj);
-                        }
-                    }
-                }
-            });
-            for (ObjectState obj : state.getStates()) {
-                if (obj.isVirtual() && obj.hasLocks()) {
-                    virtual.add(obj);
-                }
+    private void addVirtualMappings(final BlockT state, final GraphEffectList effects, FrameState frameState, Set<ObjectState> virtual) {
+        for (ObjectState obj : virtual) {
+            EscapeObjectState v;
+            if (obj.isVirtual()) {
+                v = createVirtualObjectState(state, obj);
+            } else {
+                v = new MaterializedObjectState(obj.virtual, obj.getMaterializedValue());
             }
+            effects.addVirtualMapping(frameState, v);
+        }
+    }
 
-            ArrayDeque<ObjectState> queue = new ArrayDeque<>(virtual);
-            while (!queue.isEmpty()) {
-                ObjectState obj = queue.removeLast();
-                if (obj.isVirtual()) {
-                    for (ValueNode field : obj.getEntries()) {
-                        if (field instanceof VirtualObjectNode) {
-                            ObjectState fieldObj = state.getObjectState((VirtualObjectNode) field);
-                            if (fieldObj.isVirtual() && !virtual.contains(fieldObj)) {
-                                virtual.add(fieldObj);
-                                queue.addLast(fieldObj);
-                            }
+    private void collectReferencedVirtualObjects(final BlockT state, final Set<ObjectState> virtual) {
+        ArrayDeque<ObjectState> queue = new ArrayDeque<>(virtual);
+        while (!queue.isEmpty()) {
+            ObjectState obj = queue.removeLast();
+            if (obj.isVirtual()) {
+                for (ValueNode entry : obj.getEntries()) {
+                    if (entry instanceof VirtualObjectNode) {
+                        ObjectState fieldObj = state.getObjectState((VirtualObjectNode) entry);
+                        if (fieldObj.isVirtual() && !virtual.contains(fieldObj)) {
+                            virtual.add(fieldObj);
+                            queue.addLast(fieldObj);
                         }
                     }
                 }
             }
-            for (ObjectState obj : virtual) {
-                EscapeObjectState v;
-                if (obj.isVirtual()) {
-                    ValueNode[] fieldState = obj.getEntries().clone();
-                    for (int i = 0; i < fieldState.length; i++) {
-                        ObjectState valueObj = getObjectState(state, fieldState[i]);
-                        if (valueObj != null) {
-                            if (valueObj.isVirtual()) {
-                                fieldState[i] = valueObj.virtual;
-                            } else {
-                                fieldState[i] = valueObj.getMaterializedValue();
-                            }
-                        }
-                    }
-                    v = new VirtualObjectState(obj.virtual, fieldState);
+        }
+    }
+
+    private EscapeObjectState createVirtualObjectState(final BlockT state, ObjectState obj) {
+        EscapeObjectState v;
+        ValueNode[] fieldState = obj.getEntries().clone();
+        for (int i = 0; i < fieldState.length; i++) {
+            ObjectState valueObj = getObjectState(state, fieldState[i]);
+            if (valueObj != null) {
+                if (valueObj.isVirtual()) {
+                    fieldState[i] = valueObj.virtual;
                 } else {
-                    v = new MaterializedObjectState(obj.virtual, obj.getMaterializedValue());
+                    fieldState[i] = valueObj.getMaterializedValue();
                 }
-                effects.addVirtualMapping(frameState, v);
+            }
+        }
+        v = new VirtualObjectState(obj.virtual, fieldState);
+        return v;
+    }
+
+    private void collectLockedVirtualObjects(final BlockT state, final Set<ObjectState> virtual) {
+        for (ObjectState obj : state.getStates()) {
+            if (obj.isVirtual() && obj.hasLocks()) {
+                virtual.add(obj);
             }
         }
     }
@@ -213,7 +248,7 @@
         }
     }
 
-    private boolean replaceWithMaterialized(ValueNode value, Node usage, FixedNode materializeBefore, BlockT state, ObjectState obj, GraphEffectList effects, DebugMetric metric) {
+    private boolean replaceWithMaterialized(Node value, Node usage, FixedNode materializeBefore, BlockT state, ObjectState obj, GraphEffectList effects, DebugMetric metric) {
         boolean materialized = ensureMaterialized(state, obj, materializeBefore, effects, metric);
         effects.replaceFirstInput(usage, value, obj.getMaterializedValue());
         return materialized;
@@ -221,44 +256,51 @@
 
     @Override
     protected void processLoopExit(LoopExitNode exitNode, BlockT initialState, BlockT exitState, GraphEffectList effects) {
-        Map<VirtualObjectNode, ProxyNode> proxies = Node.newMap();
-
-        for (ProxyNode proxy : exitNode.proxies()) {
-            ObjectState obj = getObjectState(exitState, proxy.value());
-            if (obj != null) {
-                proxies.put(obj.virtual, proxy);
+        if (exitNode.graph().hasValueProxies()) {
+            Map<VirtualObjectNode, ProxyNode> proxies = Node.newMap();
+            for (ProxyNode proxy : exitNode.proxies()) {
+                ObjectState obj = getObjectState(exitState, proxy.value());
+                if (obj != null) {
+                    proxies.put(obj.virtual, proxy);
+                }
             }
-        }
-        if (exitNode.graph().hasValueProxies()) {
             for (ObjectState obj : exitState.getStates()) {
                 ObjectState initialObj = initialState.getObjectStateOptional(obj.virtual);
                 if (obj.isVirtual()) {
-                    for (int i = 0; i < obj.getEntries().length; i++) {
-                        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 ValueProxyNode(value, exitNode);
-                                obj.setEntry(i, proxy);
-                                effects.addFloatingNode(proxy, "virtualProxy");
-                            }
-                        }
-                    }
+                    processVirtualAtLoopExit(exitNode, effects, obj, initialObj);
                 } else {
-                    if (initialObj == null || initialObj.isVirtual()) {
-                        ProxyNode proxy = proxies.get(obj.virtual);
-                        if (proxy == null) {
-                            proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode);
-                            effects.addFloatingNode(proxy, "proxy");
-                        } else {
-                            effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue());
-                            // nothing to do - will be handled in processNode
-                        }
-                        obj.updateMaterializedValue(proxy);
-                    } else {
-                        if (initialObj.getMaterializedValue() == obj.getMaterializedValue()) {
-                            Debug.log("materialized value changes within loop: %s vs. %s at %s", initialObj.getMaterializedValue(), obj.getMaterializedValue(), exitNode);
-                        }
-                    }
+                    processMaterializedAtLoopExit(exitNode, effects, proxies, obj, initialObj);
+                }
+            }
+        }
+    }
+
+    private static void processMaterializedAtLoopExit(LoopExitNode exitNode, GraphEffectList effects, Map<VirtualObjectNode, ProxyNode> proxies, ObjectState obj, ObjectState initialObj) {
+        if (initialObj == null || initialObj.isVirtual()) {
+            ProxyNode proxy = proxies.get(obj.virtual);
+            if (proxy == null) {
+                proxy = new ValueProxyNode(obj.getMaterializedValue(), exitNode);
+                effects.addFloatingNode(proxy, "proxy");
+            } else {
+                effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue());
+                // nothing to do - will be handled in processNode
+            }
+            obj.updateMaterializedValue(proxy);
+        } else {
+            if (initialObj.getMaterializedValue() == obj.getMaterializedValue()) {
+                Debug.log("materialized value changes within loop: %s vs. %s at %s", initialObj.getMaterializedValue(), obj.getMaterializedValue(), exitNode);
+            }
+        }
+    }
+
+    private static void processVirtualAtLoopExit(LoopExitNode exitNode, GraphEffectList effects, ObjectState obj, ObjectState initialObj) {
+        for (int i = 0; i < obj.getEntries().length; i++) {
+            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 ValueProxyNode(value, exitNode);
+                    obj.setEntry(i, proxy);
+                    effects.addFloatingNode(proxy, "virtualProxy");
                 }
             }
         }
@@ -271,15 +313,28 @@
 
     protected class MergeProcessor extends EffectsClosure<BlockT>.MergeProcessor {
 
-        private final HashMap<Object, ValuePhiNode> materializedPhis = CollectionsFactory.newMap();
-        private final Map<ValueNode, ValuePhiNode[]> valuePhis = Node.newIdentityMap();
-        private final Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals = Node.newIdentityMap();
+        private HashMap<Object, ValuePhiNode> materializedPhis;
+        private Map<ValueNode, ValuePhiNode[]> valuePhis;
+        private Map<ValuePhiNode, VirtualObjectNode> valueObjectVirtuals;
+        private final boolean needsCaching;
 
         public MergeProcessor(Block mergeBlock) {
             super(mergeBlock);
+            needsCaching = mergeBlock.isLoopHeader();
         }
 
-        protected <T> PhiNode getCachedPhi(T virtual, Stamp stamp) {
+        protected <T> PhiNode getPhi(T virtual, Stamp stamp) {
+            if (needsCaching) {
+                return getPhiCached(virtual, stamp);
+            } else {
+                return new ValuePhiNode(stamp, merge);
+            }
+        }
+
+        private <T> PhiNode getPhiCached(T virtual, Stamp stamp) {
+            if (materializedPhis == null) {
+                materializedPhis = CollectionsFactory.newMap();
+            }
             ValuePhiNode result = materializedPhis.get(virtual);
             if (result == null) {
                 result = new ValuePhiNode(stamp, merge);
@@ -289,6 +344,17 @@
         }
 
         private PhiNode[] getValuePhis(ValueNode key, int entryCount) {
+            if (needsCaching) {
+                return getValuePhisCached(key, entryCount);
+            } else {
+                return new ValuePhiNode[entryCount];
+            }
+        }
+
+        private PhiNode[] getValuePhisCached(ValueNode key, int entryCount) {
+            if (valuePhis == null) {
+                valuePhis = Node.newIdentityMap();
+            }
             ValuePhiNode[] result = valuePhis.get(key);
             if (result == null) {
                 result = new ValuePhiNode[entryCount];
@@ -299,6 +365,17 @@
         }
 
         private VirtualObjectNode getValueObjectVirtual(ValuePhiNode phi, VirtualObjectNode virtual) {
+            if (needsCaching) {
+                return getValueObjectVirtualCached(phi, virtual);
+            } else {
+                return virtual.duplicate();
+            }
+        }
+
+        private VirtualObjectNode getValueObjectVirtualCached(ValuePhiNode phi, VirtualObjectNode virtual) {
+            if (valueObjectVirtuals == null) {
+                valueObjectVirtuals = Node.newIdentityMap();
+            }
             VirtualObjectNode result = valueObjectVirtuals.get(phi);
             if (result == null) {
                 result = virtual.duplicate();
@@ -321,10 +398,7 @@
             super.merge(states);
 
             // calculate the set of virtual objects that exist in all predecessors
-            Set<VirtualObjectNode> virtualObjTemp = Node.newSet(states.get(0).getVirtualObjects());
-            for (int i = 1; i < states.size(); i++) {
-                virtualObjTemp.retainAll(states.get(i).getVirtualObjects());
-            }
+            Set<VirtualObjectNode> virtualObjTemp = intersectVirtualObjects(states);
 
             ObjectState[] objStates = new ObjectState[states.size()];
             boolean materialized;
@@ -356,12 +430,14 @@
                         if (uniqueMaterializedValue != null) {
                             newState.addObject(object, new ObjectState(object, uniqueMaterializedValue, EscapeState.Materialized, null));
                         } else {
-                            PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object));
+                            PhiNode materializedValuePhi = getPhi(object, StampFactory.forKind(Kind.Object));
                             mergeEffects.addFloatingNode(materializedValuePhi, "materializedPhi");
                             for (int i = 0; i < objStates.length; i++) {
                                 ObjectState obj = objStates[i];
-                                Block predecessor = mergeBlock.getPredecessors().get(i);
-                                materialized |= ensureMaterialized(states.get(i), obj, predecessor.getEndNode(), blockEffects.get(predecessor), METRIC_MATERIALIZATIONS_MERGE);
+                                if (obj.isVirtual()) {
+                                    Block predecessor = mergeBlock.getPredecessors().get(i);
+                                    materialized |= ensureMaterialized(states.get(i), obj, predecessor.getEndNode(), blockEffects.get(predecessor), METRIC_MATERIALIZATIONS_MERGE);
+                                }
                                 afterMergeEffects.addPhiInput(materializedValuePhi, obj.getMaterializedValue());
                             }
                             newState.addObject(object, new ObjectState(object, materializedValuePhi, EscapeState.Materialized, null));
@@ -382,6 +458,14 @@
             } while (materialized);
         }
 
+        private Set<VirtualObjectNode> intersectVirtualObjects(List<BlockT> states) {
+            Set<VirtualObjectNode> virtualObjTemp = Node.newSet(states.get(0).getVirtualObjects());
+            for (int i = 1; i < states.size(); i++) {
+                virtualObjTemp.retainAll(states.get(i).getVirtualObjects());
+            }
+            return virtualObjTemp;
+        }
+
         /**
          * Try to merge multiple virtual object states into a single object state. If the incoming
          * object states are compatible, then this method will create PhiNodes for the object's
@@ -407,7 +491,7 @@
                 while (valueIndex < values.length) {
                     Kind otherKind = entries[valueIndex].getKind();
                     Kind entryKind = object.entryKind(valueIndex);
-                    if (entryKind == Kind.Int && (otherKind == Kind.Long || otherKind == Kind.Double)) {
+                    if (entryKind == Kind.Int && otherKind.needsTwoSlots()) {
                         if (twoSlotKinds == null) {
                             twoSlotKinds = new Kind[values.length];
                         }
@@ -489,7 +573,7 @@
                 return materialized;
             } else {
                 // not compatible: materialize in all predecessors
-                PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object));
+                PhiNode materializedValuePhi = getPhi(object, StampFactory.forKind(Kind.Object));
                 for (int i = 0; i < blockStates.size(); i++) {
                     ObjectState obj = objStates[i];
                     Block predecessor = mergeBlock.getPredecessors().get(i);
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java	Wed Jan 28 19:32:47 2015 +0100
@@ -117,15 +117,18 @@
 
     public static boolean matches(StructuredGraph graph, String filter) {
         if (filter != null) {
-            if (filter.startsWith("~")) {
-                ResolvedJavaMethod method = graph.method();
-                return method == null || !method.format("%H.%n").contains(filter.substring(1));
-            } else {
-                ResolvedJavaMethod method = graph.method();
-                return method != null && method.format("%H.%n").contains(filter);
-            }
+            return matchesHelper(graph, filter);
         }
         return true;
     }
 
+    private static boolean matchesHelper(StructuredGraph graph, String filter) {
+        if (filter.startsWith("~")) {
+            ResolvedJavaMethod method = graph.method();
+            return method == null || !method.format("%H.%n").contains(filter.substring(1));
+        } else {
+            ResolvedJavaMethod method = graph.method();
+            return method != null && method.format("%H.%n").contains(filter);
+        }
+    }
 }
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -61,7 +61,7 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        if (usages().count() == 0) {
+        if (getUsageCount() == 0) {
             /* If the cast is unused, it can be eliminated. */
             return input;
         }
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -405,7 +405,7 @@
          * The read must not float outside its block otherwise it may float above an explicit zero
          * check on its base address.
          */
-        read.setGuard(BeginNode.prevBegin(invoke.asNode()));
+        read.setGuard(AbstractBeginNode.prevBegin(invoke.asNode()));
         return read;
     }
 
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeVerificationPhase.java	Wed Jan 28 19:32:47 2015 +0100
@@ -86,7 +86,7 @@
                 } 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 ValuePhiNode) {
-                    if (!(node instanceof MergeNode)) {
+                    if (!(node instanceof AbstractMergeNode)) {
                         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.interop/src/com/oracle/truffle/api/interop/ForeignAccessFactory.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ForeignAccessFactory.java	Wed Jan 28 19:32:47 2015 +0100
@@ -27,10 +27,30 @@
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.interop.messages.*;
 
+/**
+ * Interface of a factory that produces AST snippets that can access a foreign {@code TruffleObject}
+ * . A Truffle language implementation accesses a {@code TruffleObject} via a {@code Message}. The
+ * {@code TruffleObject} instance provides a {@code ForeignAccessFactory} instance that provides an
+ * AST snippet for a given {@code Message}.
+ */
 public interface ForeignAccessFactory {
 
+    /**
+     * Provides a {@code InteropPredicate} that tests whether a {@code TruffleObject} can be
+     * accessed using AST snippets, produced by this {@code ForeignAccessFactory}.
+     *
+     * @return the {@code InteropPredicate} that tests if a {@code TruffleObject} can be accessed by
+     *         AST snipptes, produces by this {@code ForeignAccessFactory}.
+     */
     InteropPredicate getLanguageCheck();
 
+    /**
+     * Provides an AST snippet to access a {@code TruffleObject}.
+     *
+     * @param tree the {@code Message} that represents the access to a {@code TruffleObject}.
+     * @return the AST snippet for accessing the {@code TruffleObject}, wrapped as a
+     *         {@code CallTarget}.
+     */
     CallTarget getAccess(Message tree);
 
 }
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/InteropPredicate.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/InteropPredicate.java	Wed Jan 28 19:32:47 2015 +0100
@@ -24,8 +24,17 @@
  */
 package com.oracle.truffle.api.interop;
 
-//TODO(mg): remove this interface and use java.util.function.Predicate once api.interop can use Java 8
-
+/**
+ * Represents a predicate of a {@code TruffleObject} argument.
+ */
 public interface InteropPredicate {
-    boolean test(Object object);
+
+    /**
+     * Evaluates the predicate on the given {@code TruffleObject}.
+     *
+     * @param object the input argument
+     * @return {@code true} if the {@code TruffleObject} argument matches the predicate, otherwise
+     *         {@code false}
+     */
+    boolean test(TruffleObject object);
 }
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/TruffleObject.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/TruffleObject.java	Wed Jan 28 19:32:47 2015 +0100
@@ -25,9 +25,14 @@
 package com.oracle.truffle.api.interop;
 
 /**
- * Interface for Truffle guest language implementations that can be shared across other language
- * implementations.
+ * Interface for any entity of a Truffle guest language implementations that can be shared across
+ * other language implementations.
  */
 public interface TruffleObject {
+    /**
+     * Provides the {@code ForeignAccessFactory} instance for this {@code TruffleObject} instance.
+     *
+     * @return the {@code ForeignAccessFactory} instance for this {@code TruffleObject} instance.
+     */
     ForeignAccessFactory getForeignAccessFactory();
 }
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/AccessException.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * 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.interop.exception;
-
-/**
- * An exception thrown if the receiver of a guest language implementation cannot resolve an access.
- */
-public final class AccessException extends RuntimeException {
-
-    private static final long serialVersionUID = -2014660135608964970L;
-
-    public AccessException(String reason) {
-        super(reason);
-    }
-
-}
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/TypeException.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * 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.interop.exception;
-
-public class TypeException extends RuntimeException {
-
-    private static final long serialVersionUID = 5786411886196161509L;
-
-    public TypeException(String reason) {
-        super(reason);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/UnsupportedMessageException.java	Wed Jan 28 19:32:47 2015 +0100
@@ -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.  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.interop.exception;
+
+/**
+ * An exception thrown if the receiver of a guest language implementation cannot resolve a message.
+ */
+public final class UnsupportedMessageException extends RuntimeException {
+
+    private static final long serialVersionUID = -2014660135608964970L;
+
+    public UnsupportedMessageException(String reason) {
+        super(reason);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/exception/UnsupportedTypeException.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,37 @@
+/*
+ * 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.interop.exception;
+
+/**
+ * An exception thrown if a foreign type cannot be converted to a language-dependent regular type.
+ */
+public class UnsupportedTypeException extends RuntimeException {
+
+    private static final long serialVersionUID = 5786411886196161509L;
+
+    public UnsupportedTypeException(String reason) {
+        super(reason);
+    }
+}
--- a/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/ObjectType.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/ObjectType.java	Wed Jan 28 19:32:47 2015 +0100
@@ -76,11 +76,11 @@
         return new ForeignAccessFactory() {
 
             public InteropPredicate getLanguageCheck() {
-                throw new AccessException(this.toString() + " cannot be shared");
+                throw new UnsupportedMessageException(this.toString() + " cannot be shared");
             }
 
             public CallTarget getAccess(Message tree) {
-                throw new AccessException(this.toString() + " cannot be shared; Message not possible: " + tree.toString());
+                throw new UnsupportedMessageException(this.toString() + " cannot be shared; Message not possible: " + tree.toString());
             }
         };
     }
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/InstrumentationTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,752 +0,0 @@
-/*
- * 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.truffle.api.test;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.instrument.*;
-import com.oracle.truffle.api.instrument.Probe.ProbeListener;
-import com.oracle.truffle.api.instrument.ProbeNode.Instrumentable;
-import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
-import com.oracle.truffle.api.instrument.impl.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-
-/**
- * <h3>AST Instrumentation</h3>
- *
- * Instrumentation allows the insertion into Truffle ASTs language-specific instances of
- * {@link WrapperNode} that propagate execution events through a {@link Probe} to any instances of
- * {@link Instrument} that might be attached to the particular probe by tools.
- * <ol>
- * <li>Creates a simple add AST</li>
- * <li>Verifies its structure</li>
- * <li>"Probes" the add node by adding a {@link WrapperNode} and associated {@link Probe}</li>
- * <li>Attaches a simple {@link Instrument} to the node via the Probe's {@link ProbeNode}</li>
- * <li>Verifies the structure of the probed AST</li>
- * <li>Verifies the execution of the probed AST</li>
- * <li>Verifies the results observed by the instrument.</li>
- * </ol>
- * To do these tests, several required classes have been implemented in their most basic form, only
- * implementing the methods necessary for the tests to pass, with stubs elsewhere.
- */
-public class InstrumentationTest {
-
-    private static final SyntaxTag ADD_TAG = new SyntaxTag() {
-
-        public String name() {
-            return "Addition";
-        }
-
-        public String getDescription() {
-            return "Test Language Addition Node";
-        }
-    };
-
-    private static final SyntaxTag VALUE_TAG = new SyntaxTag() {
-
-        public String name() {
-            return "Value";
-        }
-
-        public String getDescription() {
-            return "Test Language Value Node";
-        }
-    };
-
-    @Test
-    public void testBasicInstrumentation() {
-        // Create a simple addition AST
-        final TruffleRuntime runtime = Truffle.getRuntime();
-        final TestValueNode leftValueNode = new TestValueNode(6);
-        final TestValueNode rightValueNode = new TestValueNode(7);
-        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
-        final TestRootNode rootNode = new TestRootNode(addNode);
-
-        // Creating a call target sets the parent pointers in this tree and is necessary prior to
-        // checking any parent/child relationships
-        final CallTarget callTarget1 = runtime.createCallTarget(rootNode);
-
-        // Check the tree structure
-        Assert.assertEquals(addNode, leftValueNode.getParent());
-        Assert.assertEquals(addNode, rightValueNode.getParent());
-        Iterator<Node> iterator = addNode.getChildren().iterator();
-        Assert.assertEquals(leftValueNode, iterator.next());
-        Assert.assertEquals(rightValueNode, iterator.next());
-        Assert.assertFalse(iterator.hasNext());
-        Assert.assertEquals(rootNode, addNode.getParent());
-        iterator = rootNode.getChildren().iterator();
-        Assert.assertEquals(addNode, iterator.next());
-        Assert.assertFalse(iterator.hasNext());
-
-        // Ensure it executes correctly
-        Assert.assertEquals(13, callTarget1.call());
-
-        // Probe the addition node
-        final Probe probe = addNode.probe();
-
-        // Check the modified tree structure
-        Assert.assertEquals(addNode, leftValueNode.getParent());
-        Assert.assertEquals(addNode, rightValueNode.getParent());
-        iterator = addNode.getChildren().iterator();
-        Assert.assertEquals(leftValueNode, iterator.next());
-        Assert.assertEquals(rightValueNode, iterator.next());
-        Assert.assertFalse(iterator.hasNext());
-
-        // Ensure there's a WrapperNode correctly inserted into the AST
-        iterator = rootNode.getChildren().iterator();
-        Node wrapperNode = iterator.next();
-        Assert.assertTrue(wrapperNode instanceof TestLanguageWrapperNode);
-        Assert.assertFalse(iterator.hasNext());
-        Assert.assertEquals(rootNode, wrapperNode.getParent());
-
-        // Check that the WrapperNode has both the probe and the wrapped node as children
-        iterator = wrapperNode.getChildren().iterator();
-        Assert.assertEquals(addNode, iterator.next());
-        ProbeNode probeNode = (ProbeNode) iterator.next();
-        Assert.assertTrue(probeNode.getProbe() != null);
-        Assert.assertFalse(iterator.hasNext());
-
-        // Check that you can't probe the WrapperNodes
-        TestLanguageWrapperNode wrapper = (TestLanguageWrapperNode) wrapperNode;
-        try {
-            wrapper.probe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-
-        // Check that the "probed" AST still executes correctly
-        Assert.assertEquals(13, callTarget1.call());
-
-        // Attach a counting instrument to the probe
-        final TestCounter counterA = new TestCounter();
-        counterA.attach(probe);
-
-        // Attach a second counting instrument to the probe
-        final TestCounter counterB = new TestCounter();
-        counterB.attach(probe);
-
-        // Run it again and check that the two instruments are working
-        Assert.assertEquals(13, callTarget1.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 1);
-        Assert.assertEquals(counterB.leaveCount, 1);
-
-        // Remove counterA and check the "instrument chain"
-        counterA.dispose();
-        iterator = probeNode.getChildren().iterator();
-
-        // Run it again and check that instrument B is still working but not A
-        Assert.assertEquals(13, callTarget1.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 2);
-        Assert.assertEquals(counterB.leaveCount, 2);
-
-        // Simulate a split by cloning the AST
-        final CallTarget callTarget2 = runtime.createCallTarget((TestRootNode) rootNode.copy());
-        // Run the clone and check that instrument B is still working but not A
-        Assert.assertEquals(13, callTarget2.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 3);
-        Assert.assertEquals(counterB.leaveCount, 3);
-
-        // Run the original and check that instrument B is still working but not A
-        Assert.assertEquals(13, callTarget2.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 4);
-        Assert.assertEquals(counterB.leaveCount, 4);
-
-        // Attach a second instrument to the probe
-        final TestCounter counterC = new TestCounter();
-        counterC.attach(probe);
-
-        // Run the original and check that instruments B,C working but not A
-        Assert.assertEquals(13, callTarget1.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 5);
-        Assert.assertEquals(counterB.leaveCount, 5);
-        Assert.assertEquals(counterC.enterCount, 1);
-        Assert.assertEquals(counterC.leaveCount, 1);
-
-        // Run the clone and check that instruments B,C working but not A
-        Assert.assertEquals(13, callTarget2.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 6);
-        Assert.assertEquals(counterB.leaveCount, 6);
-        Assert.assertEquals(counterC.enterCount, 2);
-        Assert.assertEquals(counterC.leaveCount, 2);
-
-        // Remove instrumentC
-        counterC.dispose();
-
-        // Run the original and check that instrument B working but not A,C
-        Assert.assertEquals(13, callTarget1.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 7);
-        Assert.assertEquals(counterB.leaveCount, 7);
-        Assert.assertEquals(counterC.enterCount, 2);
-        Assert.assertEquals(counterC.leaveCount, 2);
-
-        // Run the clone and check that instrument B working but not A,C
-        Assert.assertEquals(13, callTarget2.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 8);
-        Assert.assertEquals(counterB.leaveCount, 8);
-        Assert.assertEquals(counterC.enterCount, 2);
-        Assert.assertEquals(counterC.leaveCount, 2);
-
-        // Remove instrumentB
-        counterB.dispose();
-
-        // Run both the original and clone, check that no instruments working
-        Assert.assertEquals(13, callTarget1.call());
-        Assert.assertEquals(13, callTarget2.call());
-        Assert.assertEquals(counterA.enterCount, 1);
-        Assert.assertEquals(counterA.leaveCount, 1);
-        Assert.assertEquals(counterB.enterCount, 8);
-        Assert.assertEquals(counterB.leaveCount, 8);
-        Assert.assertEquals(counterC.enterCount, 2);
-        Assert.assertEquals(counterC.leaveCount, 2);
-    }
-
-    @Test
-    public void testTagging() {
-
-        // Applies appropriate tags
-        final TestASTProber astProber = new TestASTProber();
-        Probe.registerASTProber(astProber);
-
-        // Listens for probes and tags being added
-        final TestProbeListener probeListener = new TestProbeListener();
-        Probe.addProbeListener(probeListener);
-
-        // Counts all entries to all instances of addition nodes
-        final TestMultiCounter additionCounter = new TestMultiCounter();
-
-        // Counts all entries to all instances of value nodes
-        final TestMultiCounter valueCounter = new TestMultiCounter();
-
-        // Create a simple addition AST
-        final TruffleRuntime runtime = Truffle.getRuntime();
-        final TestValueNode leftValueNode = new TestValueNode(6);
-        final TestValueNode rightValueNode = new TestValueNode(7);
-        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
-
-        final TestRootNode rootNode = new TestRootNode(addNode);
-
-        final CallTarget callTarget = runtime.createCallTarget(rootNode);
-
-        // Check that the prober added probes to the tree
-        Assert.assertEquals(probeListener.probeCount, 3);
-        Assert.assertEquals(probeListener.tagCount, 3);
-
-        Assert.assertEquals(Probe.findProbesTaggedAs(ADD_TAG).size(), 1);
-        Assert.assertEquals(Probe.findProbesTaggedAs(VALUE_TAG).size(), 2);
-
-        // Check that it executes correctly
-        Assert.assertEquals(13, callTarget.call());
-
-        // Dynamically attach a counter for all executions of all Addition nodes
-        for (Probe probe : Probe.findProbesTaggedAs(ADD_TAG)) {
-            additionCounter.attachCounter(probe);
-        }
-        // Dynamically attach a counter for all executions of all Value nodes
-        for (Probe probe : Probe.findProbesTaggedAs(VALUE_TAG)) {
-            valueCounter.attachCounter(probe);
-        }
-
-        // Counters initialized at 0
-        Assert.assertEquals(additionCounter.count, 0);
-        Assert.assertEquals(valueCounter.count, 0);
-
-        // Execute again
-        Assert.assertEquals(13, callTarget.call());
-
-        // There are two value nodes in the AST, but only one addition node
-        Assert.assertEquals(additionCounter.count, 1);
-        Assert.assertEquals(valueCounter.count, 2);
-
-        Probe.unregisterASTProber(astProber);
-
-    }
-
-    @Test
-    public void testProbeLite() {
-
-        // Use the "lite-probing" option, limited to a single pass of
-        // probing and a single Instrument at each probed node. This
-        // particular test uses a shared event receiver at every
-        // lite-probed node.
-        final TestEventReceiver receiver = new TestEventReceiver();
-
-        TestASTLiteProber astLiteProber = new TestASTLiteProber(receiver);
-        Probe.registerASTProber(astLiteProber);
-
-        // Create a simple addition AST
-        final TruffleRuntime runtime = Truffle.getRuntime();
-        final TestValueNode leftValueNode = new TestValueNode(6);
-        final TestValueNode rightValueNode = new TestValueNode(7);
-        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
-        final TestRootNode rootNode = new TestRootNode(addNode);
-
-        // Creating a call target sets the parent pointers in this tree and is necessary prior to
-        // checking any parent/child relationships
-        final CallTarget callTarget = runtime.createCallTarget(rootNode);
-
-        // Check that the instrument is working as expected.
-        Assert.assertEquals(0, receiver.counter);
-        callTarget.call();
-        Assert.assertEquals(2, receiver.counter);
-
-        // Check that you can't probe a node that's already received a probeLite() call
-        try {
-            leftValueNode.probe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-
-        try {
-            rightValueNode.probe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-
-        // Check tree structure
-        Assert.assertTrue(leftValueNode.getParent() instanceof TestLanguageWrapperNode);
-        Assert.assertTrue(rightValueNode.getParent() instanceof TestLanguageWrapperNode);
-        TestLanguageWrapperNode leftWrapper = (TestLanguageWrapperNode) leftValueNode.getParent();
-        TestLanguageWrapperNode rightWrapper = (TestLanguageWrapperNode) rightValueNode.getParent();
-        Assert.assertEquals(addNode, leftWrapper.getParent());
-        Assert.assertEquals(addNode, rightWrapper.getParent());
-        Iterator<Node> iterator = addNode.getChildren().iterator();
-        Assert.assertEquals(leftWrapper, iterator.next());
-        Assert.assertEquals(rightWrapper, iterator.next());
-        Assert.assertFalse(iterator.hasNext());
-        Assert.assertEquals(rootNode, addNode.getParent());
-        iterator = rootNode.getChildren().iterator();
-        Assert.assertEquals(addNode, iterator.next());
-        Assert.assertFalse(iterator.hasNext());
-
-        // Check that you can't get a probe on the wrappers because they were "lite-probed"
-        try {
-            leftWrapper.getProbe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-        try {
-            rightWrapper.getProbe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-
-        // Check that you can't probe the wrappers
-        try {
-            leftWrapper.probe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-        try {
-            rightWrapper.probe();
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-        try {
-            leftWrapper.probeLite(null);
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-        try {
-            rightWrapper.probeLite(null);
-            Assert.fail();
-        } catch (IllegalStateException e) {
-        }
-
-        // Use reflection to check that each WrapperNode has a ProbeLiteNode with a
-        // SimpleEventReceiver
-        try {
-            Field probeNodeField = leftWrapper.getClass().getDeclaredField("probeNode");
-
-            // cheat: probeNode is private, so we change it's accessibility at runtime
-            probeNodeField.setAccessible(true);
-            ProbeNode probeNode = (ProbeNode) probeNodeField.get(leftWrapper);
-
-            // hack: Since ProbeLiteNode is not visible, we do a string compare here
-            Assert.assertTrue(probeNode.getClass().toString().endsWith("ProbeLiteNode"));
-
-            // Now we do the same to check the type of the eventReceiver in ProbeLiteNode
-            Field eventReceiverField = probeNode.getClass().getDeclaredField("eventReceiver");
-            eventReceiverField.setAccessible(true);
-            TruffleEventReceiver eventReceiver = (TruffleEventReceiver) eventReceiverField.get(probeNode);
-            Assert.assertTrue(eventReceiver instanceof SimpleEventReceiver);
-
-            // Reset accessibility
-            probeNodeField.setAccessible(false);
-            eventReceiverField.setAccessible(false);
-
-        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
-            Assert.fail();
-        }
-
-        Probe.unregisterASTProber(astLiteProber);
-
-    }
-
-    /**
-     * A guest language usually has a single language-specific subclass of {@link Node} from which
-     * all other nodes in the guest language subclass. By making this node {@link Instrumentable},
-     * we allow all nodes of the guest language to have {@link Probe}s attach to them.
-     *
-     */
-    private abstract class TestLanguageNode extends Node implements Instrumentable {
-        public abstract Object execute(VirtualFrame frame);
-
-        public Probe probe() {
-            Node parent = getParent();
-
-            if (parent == null) {
-                throw new IllegalStateException("Cannot call probe() on a node without a parent.");
-            }
-
-            if (parent instanceof TestLanguageWrapperNode) {
-                return ((TestLanguageWrapperNode) parent).getProbe();
-            }
-
-            // Create a new wrapper/probe with this node as its child.
-            final TestLanguageWrapperNode wrapper = new TestLanguageWrapperNode(this);
-
-            // Connect it to a Probe
-            final Probe probe = ProbeNode.insertProbe(wrapper);
-
-            // Replace this node in the AST with the wrapper
-            this.replace(wrapper);
-
-            return probe;
-        }
-
-        public void probeLite(TruffleEventReceiver eventReceiver) {
-            Node parent = getParent();
-
-            if (parent == null) {
-                throw new IllegalStateException("Cannot call probeLite() on a node without a parent");
-            }
-
-            if (parent instanceof TestLanguageWrapperNode) {
-                throw new IllegalStateException("Cannot call probeLite() on a node that already has a wrapper.");
-            }
-
-            final TestLanguageWrapperNode wrapper = new TestLanguageWrapperNode(this);
-            ProbeNode.insertProbeLite(wrapper, eventReceiver);
-
-            this.replace(wrapper);
-        }
-    }
-
-    /**
-     * The wrapper node class is usually language-specific and inherits from the language-specific
-     * subclass of {@link Node}, in this case, {@link TestLanguageNode}.
-     */
-    @NodeInfo(cost = NodeCost.NONE)
-    private class TestLanguageWrapperNode extends TestLanguageNode implements WrapperNode {
-        @Child private TestLanguageNode child;
-        @Child private ProbeNode probeNode;
-
-        public TestLanguageWrapperNode(TestLanguageNode child) {
-            assert !(child instanceof TestLanguageWrapperNode);
-            this.child = child;
-        }
-
-        public String instrumentationInfo() {
-            return "Wrapper node for testing";
-        }
-
-        public void insertProbe(ProbeNode newProbeNode) {
-            this.probeNode = newProbeNode;
-        }
-
-        public Probe getProbe() {
-            try {
-                return probeNode.getProbe();
-            } catch (IllegalStateException e) {
-                throw new IllegalStateException("Cannot call getProbe() on a wrapper that has no probe");
-            }
-        }
-
-        @Override
-        public Node getChild() {
-            return child;
-        }
-
-        @Override
-        public Object execute(VirtualFrame frame) {
-            probeNode.enter(child, frame);
-            Object result;
-
-            try {
-                result = child.execute(frame);
-                probeNode.returnValue(child, frame, result);
-            } catch (KillException e) {
-                throw (e);
-            } catch (Exception e) {
-                probeNode.returnExceptional(child, frame, e);
-                throw (e);
-            }
-
-            return result;
-        }
-
-        @Override
-        public Probe probe() {
-            throw new IllegalStateException("Cannot call probe() on a wrapper.");
-        }
-
-        @Override
-        public void probeLite(TruffleEventReceiver eventReceiver) {
-            throw new IllegalStateException("Cannot call probeLite() on a wrapper.");
-        }
-    }
-
-    /**
-     * A simple node for our test language to store a value.
-     */
-    private class TestValueNode extends TestLanguageNode {
-        private final int value;
-
-        public TestValueNode(int value) {
-            this.value = value;
-        }
-
-        @Override
-        public Object execute(VirtualFrame frame) {
-            return new Integer(this.value);
-        }
-    }
-
-    /**
-     * A node for our test language that adds up two {@link TestValueNode}s.
-     */
-    private class TestAdditionNode extends TestLanguageNode {
-        @Child private TestLanguageNode leftChild;
-        @Child private TestLanguageNode rightChild;
-
-        public TestAdditionNode(TestValueNode leftChild, TestValueNode rightChild) {
-            this.leftChild = insert(leftChild);
-            this.rightChild = insert(rightChild);
-        }
-
-        @Override
-        public Object execute(VirtualFrame frame) {
-            return new Integer(((Integer) leftChild.execute(frame)).intValue() + ((Integer) rightChild.execute(frame)).intValue());
-        }
-    }
-
-    /**
-     * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST
-     * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle
-     * completes an AST. The root nodes serves as our entry point into a program.
-     */
-    private class TestRootNode extends RootNode {
-        @Child private TestLanguageNode body;
-
-        /**
-         * This constructor emulates the global machinery that applies registered probers to every
-         * newly created AST. Global registry is not used, since that would interfere with other
-         * tests run in the same environment.
-         */
-        public TestRootNode(TestLanguageNode body) {
-            super(null);
-            this.body = body;
-        }
-
-        @Override
-        public Object execute(VirtualFrame frame) {
-            return body.execute(frame);
-        }
-
-        @Override
-        public boolean isCloningAllowed() {
-            return true;
-        }
-
-        @Override
-        public void applyInstrumentation() {
-            Probe.applyASTProbers(body);
-        }
-    }
-
-    /**
-     * A counter for the number of times execution enters and leaves a probed AST node.
-     */
-    private class TestCounter {
-
-        public int enterCount = 0;
-        public int leaveCount = 0;
-        public final Instrument instrument;
-
-        public TestCounter() {
-            instrument = Instrument.create(new SimpleEventReceiver() {
-
-                @Override
-                public void enter(Node node, VirtualFrame frame) {
-                    enterCount++;
-                }
-
-                @Override
-                public void returnAny(Node node, VirtualFrame frame) {
-                    leaveCount++;
-                }
-            }, "Instrumentation Test Counter");
-        }
-
-        public void attach(Probe probe) {
-            probe.attach(instrument);
-        }
-
-        public void dispose() {
-            instrument.dispose();
-        }
-
-    }
-
-    /**
-     * Tags selected nodes on newly constructed ASTs.
-     */
-    private static final class TestASTProber implements NodeVisitor, ASTProber {
-
-        public boolean visit(Node node) {
-            if (node instanceof TestLanguageNode) {
-
-                final TestLanguageNode testNode = (TestLanguageNode) node;
-
-                if (node instanceof TestValueNode) {
-                    testNode.probe().tagAs(VALUE_TAG, null);
-
-                } else if (node instanceof TestAdditionNode) {
-                    testNode.probe().tagAs(ADD_TAG, null);
-
-                }
-            }
-            return true;
-        }
-
-        public void probeAST(Node node) {
-            node.accept(this);
-        }
-    }
-
-    /**
-     * "lite-probes" every value node with a shared event receiver.
-     */
-    private static final class TestASTLiteProber implements NodeVisitor, ASTProber {
-        private final TruffleEventReceiver eventReceiver;
-
-        public TestASTLiteProber(SimpleEventReceiver simpleEventReceiver) {
-            this.eventReceiver = simpleEventReceiver;
-        }
-
-        public boolean visit(Node node) {
-            if (node instanceof TestValueNode) {
-                final TestLanguageNode testNode = (TestValueNode) node;
-                testNode.probeLite(eventReceiver);
-            }
-            return true;
-        }
-
-        public void probeAST(Node node) {
-            node.accept(this);
-        }
-    }
-
-    /**
-     * Counts the number of "enter" events at probed nodes.
-     *
-     */
-    static final class TestEventReceiver extends SimpleEventReceiver {
-
-        public int counter = 0;
-
-        @Override
-        public void enter(Node node, VirtualFrame frame) {
-            counter++;
-        }
-
-    }
-
-    /**
-     * A counter that can count executions at multiple nodes; it attaches a separate instrument at
-     * each Probe, but keeps a total count.
-     */
-    private static final class TestMultiCounter {
-
-        public int count = 0;
-
-        public void attachCounter(Probe probe) {
-
-            // Attach a new instrument for every Probe
-            // where we want to count executions.
-            // it will get copied when ASTs cloned, so
-            // keep the count in this outer class.
-            probe.attach(Instrument.create(new SimpleEventReceiver() {
-
-                @Override
-                public void enter(Node node, VirtualFrame frame) {
-                    count++;
-                }
-            }, "Instrumentation Test MultiCounter"));
-        }
-    }
-
-    private static final class TestProbeListener implements ProbeListener {
-
-        public int probeCount = 0;
-        public int tagCount = 0;
-
-        public void newProbeInserted(Probe probe) {
-            probeCount++;
-        }
-
-        public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
-            tagCount++;
-        }
-
-        public void startASTProbing(Source source) {
-        }
-
-        public void endASTProbing(Source source) {
-        }
-
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,721 @@
+/*
+ * Copyright (c) 2014, 2015, 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.api.test.instrument;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.ProbeFailure.Reason;
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
+import com.oracle.truffle.api.instrument.impl.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * <h3>AST Instrumentation</h3>
+ *
+ * Instrumentation allows the insertion into Truffle ASTs language-specific instances of
+ * {@link WrapperNode} that propagate execution events through a {@link Probe} to any instances of
+ * {@link Instrument} that might be attached to the particular probe by tools.
+ * <ol>
+ * <li>Creates a simple add AST</li>
+ * <li>Verifies its structure</li>
+ * <li>"Probes" the add node by adding a {@link WrapperNode} and associated {@link Probe}</li>
+ * <li>Attaches a simple {@link Instrument} to the node via the Probe's {@link ProbeNode}</li>
+ * <li>Verifies the structure of the probed AST</li>
+ * <li>Verifies the execution of the probed AST</li>
+ * <li>Verifies the results observed by the instrument.</li>
+ * </ol>
+ * To do these tests, several required classes have been implemented in their most basic form, only
+ * implementing the methods necessary for the tests to pass, with stubs elsewhere.
+ */
+public class InstrumentationTest {
+
+    private static final SyntaxTag ADD_TAG = new SyntaxTag() {
+
+        @Override
+        public String name() {
+            return "Addition";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Test Language Addition Node";
+        }
+    };
+
+    private static final SyntaxTag VALUE_TAG = new SyntaxTag() {
+
+        @Override
+        public String name() {
+            return "Value";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Test Language Value Node";
+        }
+    };
+
+    @Test
+    public void testBasicInstrumentation() {
+        // Create a simple addition AST
+        final TruffleRuntime runtime = Truffle.getRuntime();
+        final TestValueNode leftValueNode = new TestValueNode(6);
+        final TestValueNode rightValueNode = new TestValueNode(7);
+        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
+
+        try {
+            addNode.probe();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), Reason.NO_PARENT);
+        }
+        final TestRootNode rootNode = new TestRootNode(addNode);
+
+        // Creating a call target sets the parent pointers in this tree and is necessary prior to
+        // checking any parent/child relationships
+        final CallTarget callTarget1 = runtime.createCallTarget(rootNode);
+
+        // Check the tree structure
+        assertEquals(addNode, leftValueNode.getParent());
+        assertEquals(addNode, rightValueNode.getParent());
+        Iterator<Node> iterator = addNode.getChildren().iterator();
+        assertEquals(leftValueNode, iterator.next());
+        assertEquals(rightValueNode, iterator.next());
+        assertFalse(iterator.hasNext());
+        assertEquals(rootNode, addNode.getParent());
+        iterator = rootNode.getChildren().iterator();
+        assertEquals(addNode, iterator.next());
+        assertFalse(iterator.hasNext());
+
+        // Ensure it executes correctly
+        assertEquals(13, callTarget1.call());
+
+        // Probe the addition node
+        final Probe probe = addNode.probe();
+
+        // Check the modified tree structure
+        assertEquals(addNode, leftValueNode.getParent());
+        assertEquals(addNode, rightValueNode.getParent());
+        iterator = addNode.getChildren().iterator();
+        assertEquals(leftValueNode, iterator.next());
+        assertEquals(rightValueNode, iterator.next());
+        assertFalse(iterator.hasNext());
+
+        // Ensure there's a WrapperNode correctly inserted into the AST
+        iterator = rootNode.getChildren().iterator();
+        Node wrapperNode = iterator.next();
+        assertTrue(wrapperNode instanceof TestLanguageWrapperNode);
+        assertFalse(iterator.hasNext());
+        assertEquals(rootNode, wrapperNode.getParent());
+
+        // Check that the WrapperNode has both the probe and the wrapped node as children
+        iterator = wrapperNode.getChildren().iterator();
+        assertEquals(addNode, iterator.next());
+        ProbeNode probeNode = (ProbeNode) iterator.next();
+        assertTrue(probeNode.getProbe() != null);
+        assertFalse(iterator.hasNext());
+
+        // Check that you can't probe the WrapperNodes
+        TestLanguageWrapperNode wrapper = (TestLanguageWrapperNode) wrapperNode;
+        try {
+            wrapper.probe();
+            fail();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), Reason.WRAPPER_NODE);
+        }
+
+        // Check that the "probed" AST still executes correctly
+        assertEquals(13, callTarget1.call());
+
+        // Attach a counting instrument to the probe
+        final TestCounter counterA = new TestCounter();
+        counterA.attach(probe);
+
+        // Attach a second counting instrument to the probe
+        final TestCounter counterB = new TestCounter();
+        counterB.attach(probe);
+
+        // Run it again and check that the two instruments are working
+        assertEquals(13, callTarget1.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 1);
+        assertEquals(counterB.leaveCount, 1);
+
+        // Remove counterA and check the "instrument chain"
+        counterA.dispose();
+        iterator = probeNode.getChildren().iterator();
+
+        // Run it again and check that instrument B is still working but not A
+        assertEquals(13, callTarget1.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 2);
+        assertEquals(counterB.leaveCount, 2);
+
+        // Simulate a split by cloning the AST
+        final CallTarget callTarget2 = runtime.createCallTarget((TestRootNode) rootNode.copy());
+        // Run the clone and check that instrument B is still working but not A
+        assertEquals(13, callTarget2.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 3);
+        assertEquals(counterB.leaveCount, 3);
+
+        // Run the original and check that instrument B is still working but not A
+        assertEquals(13, callTarget2.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 4);
+        assertEquals(counterB.leaveCount, 4);
+
+        // Attach a second instrument to the probe
+        final TestCounter counterC = new TestCounter();
+        counterC.attach(probe);
+
+        // Run the original and check that instruments B,C working but not A
+        assertEquals(13, callTarget1.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 5);
+        assertEquals(counterB.leaveCount, 5);
+        assertEquals(counterC.enterCount, 1);
+        assertEquals(counterC.leaveCount, 1);
+
+        // Run the clone and check that instruments B,C working but not A
+        assertEquals(13, callTarget2.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 6);
+        assertEquals(counterB.leaveCount, 6);
+        assertEquals(counterC.enterCount, 2);
+        assertEquals(counterC.leaveCount, 2);
+
+        // Remove instrumentC
+        counterC.dispose();
+
+        // Run the original and check that instrument B working but not A,C
+        assertEquals(13, callTarget1.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 7);
+        assertEquals(counterB.leaveCount, 7);
+        assertEquals(counterC.enterCount, 2);
+        assertEquals(counterC.leaveCount, 2);
+
+        // Run the clone and check that instrument B working but not A,C
+        assertEquals(13, callTarget2.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 8);
+        assertEquals(counterB.leaveCount, 8);
+        assertEquals(counterC.enterCount, 2);
+        assertEquals(counterC.leaveCount, 2);
+
+        // Remove instrumentB
+        counterB.dispose();
+
+        // Run both the original and clone, check that no instruments working
+        assertEquals(13, callTarget1.call());
+        assertEquals(13, callTarget2.call());
+        assertEquals(counterA.enterCount, 1);
+        assertEquals(counterA.leaveCount, 1);
+        assertEquals(counterB.enterCount, 8);
+        assertEquals(counterB.leaveCount, 8);
+        assertEquals(counterC.enterCount, 2);
+        assertEquals(counterC.leaveCount, 2);
+    }
+
+    @Test
+    public void testTagging() {
+
+        // Applies appropriate tags
+        final TestASTProber astProber = new TestASTProber();
+        Probe.registerASTProber(astProber);
+
+        // Listens for probes and tags being added
+        final TestProbeListener probeListener = new TestProbeListener();
+        Probe.addProbeListener(probeListener);
+
+        // Counts all entries to all instances of addition nodes
+        final TestMultiCounter additionCounter = new TestMultiCounter();
+
+        // Counts all entries to all instances of value nodes
+        final TestMultiCounter valueCounter = new TestMultiCounter();
+
+        // Create a simple addition AST
+        final TruffleRuntime runtime = Truffle.getRuntime();
+        final TestValueNode leftValueNode = new TestValueNode(6);
+        final TestValueNode rightValueNode = new TestValueNode(7);
+        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
+
+        final TestRootNode rootNode = new TestRootNode(addNode);
+
+        final CallTarget callTarget = runtime.createCallTarget(rootNode);
+
+        // Check that the prober added probes to the tree
+        assertEquals(probeListener.probeCount, 3);
+        assertEquals(probeListener.tagCount, 3);
+
+        assertEquals(Probe.findProbesTaggedAs(ADD_TAG).size(), 1);
+        assertEquals(Probe.findProbesTaggedAs(VALUE_TAG).size(), 2);
+
+        // Check that it executes correctly
+        assertEquals(13, callTarget.call());
+
+        // Dynamically attach a counter for all executions of all Addition nodes
+        for (Probe probe : Probe.findProbesTaggedAs(ADD_TAG)) {
+            additionCounter.attachCounter(probe);
+        }
+        // Dynamically attach a counter for all executions of all Value nodes
+        for (Probe probe : Probe.findProbesTaggedAs(VALUE_TAG)) {
+            valueCounter.attachCounter(probe);
+        }
+
+        // Counters initialized at 0
+        assertEquals(additionCounter.count, 0);
+        assertEquals(valueCounter.count, 0);
+
+        // Execute again
+        assertEquals(13, callTarget.call());
+
+        // There are two value nodes in the AST, but only one addition node
+        assertEquals(additionCounter.count, 1);
+        assertEquals(valueCounter.count, 2);
+
+        Probe.unregisterASTProber(astProber);
+
+    }
+
+    @Test
+    public void testProbeLite() {
+
+        // Use the "lite-probing" option, limited to a single pass of
+        // probing and a single Instrument at each probed node. This
+        // particular test uses a shared event receiver at every
+        // lite-probed node.
+        final TestEventReceiver receiver = new TestEventReceiver();
+
+        TestASTLiteProber astLiteProber = new TestASTLiteProber(receiver);
+        Probe.registerASTProber(astLiteProber);
+
+        // Create a simple addition AST
+        final TruffleRuntime runtime = Truffle.getRuntime();
+        final TestValueNode leftValueNode = new TestValueNode(6);
+        final TestValueNode rightValueNode = new TestValueNode(7);
+        final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
+        final TestRootNode rootNode = new TestRootNode(addNode);
+
+        // Creating a call target sets the parent pointers in this tree and is necessary prior to
+        // checking any parent/child relationships
+        final CallTarget callTarget = runtime.createCallTarget(rootNode);
+
+        // Check that the instrument is working as expected.
+        assertEquals(0, receiver.counter);
+        callTarget.call();
+        assertEquals(2, receiver.counter);
+
+        // Check that you can't probe a node that's already received a probeLite() call
+        try {
+            leftValueNode.probe();
+            fail();
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            rightValueNode.probe();
+            fail();
+        } catch (IllegalStateException e) {
+        }
+
+        // Check tree structure
+        assertTrue(leftValueNode.getParent() instanceof TestLanguageWrapperNode);
+        assertTrue(rightValueNode.getParent() instanceof TestLanguageWrapperNode);
+        TestLanguageWrapperNode leftWrapper = (TestLanguageWrapperNode) leftValueNode.getParent();
+        TestLanguageWrapperNode rightWrapper = (TestLanguageWrapperNode) rightValueNode.getParent();
+        assertEquals(addNode, leftWrapper.getParent());
+        assertEquals(addNode, rightWrapper.getParent());
+        Iterator<Node> iterator = addNode.getChildren().iterator();
+        assertEquals(leftWrapper, iterator.next());
+        assertEquals(rightWrapper, iterator.next());
+        assertFalse(iterator.hasNext());
+        assertEquals(rootNode, addNode.getParent());
+        iterator = rootNode.getChildren().iterator();
+        assertEquals(addNode, iterator.next());
+        assertFalse(iterator.hasNext());
+
+        // Check that you can't get a probe on the wrappers because they were "lite-probed"
+        try {
+            leftWrapper.getProbe();
+            fail();
+        } catch (IllegalStateException e) {
+        }
+        try {
+            rightWrapper.getProbe();
+            fail();
+        } catch (IllegalStateException e) {
+        }
+
+        // Check that you can't probe the wrappers
+        try {
+            leftWrapper.probe();
+            fail();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), ProbeFailure.Reason.WRAPPER_NODE);
+        }
+        try {
+            rightWrapper.probe();
+            fail();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), ProbeFailure.Reason.WRAPPER_NODE);
+        }
+        try {
+            leftWrapper.probeLite(null);
+            fail();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), ProbeFailure.Reason.WRAPPER_NODE);
+        }
+        try {
+            rightWrapper.probeLite(null);
+            fail();
+        } catch (ProbeException e) {
+            assertEquals(e.getFailure().getReason(), ProbeFailure.Reason.WRAPPER_NODE);
+        }
+
+        // Use reflection to check that each WrapperNode has a ProbeLiteNode with a
+        // SimpleEventReceiver
+        try {
+            java.lang.reflect.Field probeNodeField = leftWrapper.getClass().getDeclaredField("probeNode");
+
+            // cheat: probeNode is private, so we change it's accessibility at runtime
+            probeNodeField.setAccessible(true);
+            ProbeNode probeNode = (ProbeNode) probeNodeField.get(leftWrapper);
+
+            // hack: Since ProbeLiteNode is not visible, we do a string compare here
+            assertTrue(probeNode.getClass().toString().endsWith("ProbeLiteNode"));
+
+            // Now we do the same to check the type of the eventReceiver in ProbeLiteNode
+            java.lang.reflect.Field eventReceiverField = probeNode.getClass().getDeclaredField("eventReceiver");
+            eventReceiverField.setAccessible(true);
+            TruffleEventReceiver eventReceiver = (TruffleEventReceiver) eventReceiverField.get(probeNode);
+            assertTrue(eventReceiver instanceof SimpleEventReceiver);
+
+            // Reset accessibility
+            probeNodeField.setAccessible(false);
+            eventReceiverField.setAccessible(false);
+
+        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+            fail();
+        }
+
+        Probe.unregisterASTProber(astLiteProber);
+
+    }
+
+    private abstract class TestLanguageNode extends Node {
+        public abstract Object execute(VirtualFrame frame);
+
+        @Override
+        public boolean isInstrumentable() {
+            return true;
+        }
+
+        @Override
+        public WrapperNode createWrapperNode() {
+            return new TestLanguageWrapperNode(this);
+        }
+    }
+
+    @NodeInfo(cost = NodeCost.NONE)
+    private class TestLanguageWrapperNode extends TestLanguageNode implements WrapperNode {
+        @Child private TestLanguageNode child;
+        @Child private ProbeNode probeNode;
+
+        public TestLanguageWrapperNode(TestLanguageNode child) {
+            assert !(child instanceof TestLanguageWrapperNode);
+            this.child = child;
+        }
+
+        @Override
+        public String instrumentationInfo() {
+            return "Wrapper node for testing";
+        }
+
+        @Override
+        public boolean isInstrumentable() {
+            return false;
+        }
+
+        @Override
+        public void insertProbe(ProbeNode newProbeNode) {
+            this.probeNode = newProbeNode;
+        }
+
+        @Override
+        public Probe getProbe() {
+            try {
+                return probeNode.getProbe();
+            } catch (IllegalStateException e) {
+                throw new IllegalStateException("Cannot call getProbe() on a wrapper that has no probe");
+            }
+        }
+
+        @Override
+        public Node getChild() {
+            return child;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            probeNode.enter(child, frame);
+            Object result;
+
+            try {
+                result = child.execute(frame);
+                probeNode.returnValue(child, frame, result);
+            } catch (KillException e) {
+                throw (e);
+            } catch (Exception e) {
+                probeNode.returnExceptional(child, frame, e);
+                throw (e);
+            }
+
+            return result;
+        }
+    }
+
+    /**
+     * A simple node for our test language to store a value.
+     */
+    private class TestValueNode extends TestLanguageNode {
+        private final int value;
+
+        public TestValueNode(int value) {
+            this.value = value;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return new Integer(this.value);
+        }
+    }
+
+    /**
+     * A node for our test language that adds up two {@link TestValueNode}s.
+     */
+    private class TestAdditionNode extends TestLanguageNode {
+        @Child private TestLanguageNode leftChild;
+        @Child private TestLanguageNode rightChild;
+
+        public TestAdditionNode(TestValueNode leftChild, TestValueNode rightChild) {
+            this.leftChild = insert(leftChild);
+            this.rightChild = insert(rightChild);
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return new Integer(((Integer) leftChild.execute(frame)).intValue() + ((Integer) rightChild.execute(frame)).intValue());
+        }
+    }
+
+    /**
+     * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST
+     * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle
+     * completes an AST. The root nodes serves as our entry point into a program.
+     */
+    private class TestRootNode extends RootNode {
+        @Child private TestLanguageNode body;
+
+        /**
+         * This constructor emulates the global machinery that applies registered probers to every
+         * newly created AST. Global registry is not used, since that would interfere with other
+         * tests run in the same environment.
+         */
+        public TestRootNode(TestLanguageNode body) {
+            super(null);
+            this.body = body;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return body.execute(frame);
+        }
+
+        @Override
+        public boolean isCloningAllowed() {
+            return true;
+        }
+
+        @Override
+        public void applyInstrumentation() {
+            Probe.applyASTProbers(body);
+        }
+    }
+
+    /**
+     * A counter for the number of times execution enters and leaves a probed AST node.
+     */
+    private class TestCounter {
+
+        public int enterCount = 0;
+        public int leaveCount = 0;
+        public final Instrument instrument;
+
+        public TestCounter() {
+            instrument = Instrument.create(new SimpleEventReceiver() {
+
+                @Override
+                public void enter(Node node, VirtualFrame frame) {
+                    enterCount++;
+                }
+
+                @Override
+                public void returnAny(Node node, VirtualFrame frame) {
+                    leaveCount++;
+                }
+            }, "Instrumentation Test Counter");
+        }
+
+        public void attach(Probe probe) {
+            probe.attach(instrument);
+        }
+
+        public void dispose() {
+            instrument.dispose();
+        }
+
+    }
+
+    /**
+     * Tags selected nodes on newly constructed ASTs.
+     */
+    private static final class TestASTProber implements NodeVisitor, ASTProber {
+
+        @Override
+        public boolean visit(Node node) {
+            if (node instanceof TestLanguageNode) {
+
+                final TestLanguageNode testNode = (TestLanguageNode) node;
+
+                if (node instanceof TestValueNode) {
+                    testNode.probe().tagAs(VALUE_TAG, null);
+
+                } else if (node instanceof TestAdditionNode) {
+                    testNode.probe().tagAs(ADD_TAG, null);
+
+                }
+            }
+            return true;
+        }
+
+        @Override
+        public void probeAST(Node node) {
+            node.accept(this);
+        }
+    }
+
+    /**
+     * "lite-probes" every value node with a shared event receiver.
+     */
+    private static final class TestASTLiteProber implements NodeVisitor, ASTProber {
+        private final TruffleEventReceiver eventReceiver;
+
+        public TestASTLiteProber(SimpleEventReceiver simpleEventReceiver) {
+            this.eventReceiver = simpleEventReceiver;
+        }
+
+        public boolean visit(Node node) {
+            if (node instanceof TestValueNode) {
+                final TestLanguageNode testNode = (TestValueNode) node;
+                testNode.probeLite(eventReceiver);
+            }
+            return true;
+        }
+
+        public void probeAST(Node node) {
+            node.accept(this);
+        }
+    }
+
+    /**
+     * Counts the number of "enter" events at probed nodes.
+     *
+     */
+    static final class TestEventReceiver extends SimpleEventReceiver {
+
+        public int counter = 0;
+
+        @Override
+        public void enter(Node node, VirtualFrame frame) {
+            counter++;
+        }
+
+    }
+
+    /**
+     * A counter that can count executions at multiple nodes; it attaches a separate instrument at
+     * each Probe, but keeps a total count.
+     */
+    private static final class TestMultiCounter {
+
+        public int count = 0;
+
+        public void attachCounter(Probe probe) {
+
+            // Attach a new instrument for every Probe
+            // where we want to count executions.
+            // it will get copied when ASTs cloned, so
+            // keep the count in this outer class.
+            probe.attach(Instrument.create(new SimpleEventReceiver() {
+
+                @Override
+                public void enter(Node node, VirtualFrame frame) {
+                    count++;
+                }
+            }, "Instrumentation Test MultiCounter"));
+        }
+    }
+
+    private static final class TestProbeListener extends DefaultProbeListener {
+
+        public int probeCount = 0;
+        public int tagCount = 0;
+
+        @Override
+        public void newProbeInserted(Probe probe) {
+            probeCount++;
+        }
+
+        @Override
+        public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
+            tagCount++;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/nodes/SafeReplaceTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015, 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.api.test.nodes;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * Tests optional method for ensuring that a node replacement is type safe. Ordinary node
+ * replacement is performed by unsafe assignment of a parent node's child field.
+ */
+public class SafeReplaceTest {
+
+    @Test
+    public void testCorrectReplacement() {
+        TestRootNode root = new TestRootNode();
+        final TestNode oldChild = new TestNode();
+        root.child = oldChild;
+        assertFalse(oldChild.isReplaceable());  // No parent node
+        root.adoptChildren();
+        assertTrue(oldChild.isReplaceable());   // Now adopted by parent
+        final TestNode newChild = new TestNode();
+        assertTrue(oldChild.isSafelyReplaceableBy(newChild));  // Parent field type is assignable by
+        // new node
+        oldChild.replace(newChild);
+        root.execute(null);
+        assertEquals(root.executed, 1);
+        assertEquals(oldChild.executed, 0);
+        assertEquals(newChild.executed, 1);
+    }
+
+    @Test
+    public void testIncorrectReplacement() {
+        TestRootNode root = new TestRootNode();
+        final TestNode oldChild = new TestNode();
+        root.child = oldChild;
+        root.adoptChildren();
+        final WrongTestNode newChild = new WrongTestNode();
+        assertFalse(oldChild.isSafelyReplaceableBy(newChild));
+        // Can't test: oldChild.replace(newChild);
+        // Fails if assertions checked; else unsafe assignment will eventually crash the VM
+    }
+
+    private static class TestNode extends Node {
+
+        private int executed;
+
+        public Object execute() {
+            executed++;
+            return null;
+        }
+    }
+
+    private static class TestRootNode extends RootNode {
+
+        @Child TestNode child;
+
+        private int executed;
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            executed++;
+            child.execute();
+            return null;
+        }
+    }
+
+    private static class WrongTestNode extends Node {
+    }
+
+}
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/package-info.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/package-info.java	Wed Jan 28 19:32:47 2015 +0100
@@ -44,7 +44,7 @@
  * <li>How to use frames and frame slots to store values local to an activation? {@link com.oracle.truffle.api.test.FrameTest}</li>
  * <li>How to use type specialization and speculation for frame slots? {@link com.oracle.truffle.api.test.FrameSlotTypeSpecializationTest}</li>
  * <li>How to use type specialization and speculation for node return values? {@link com.oracle.truffle.api.test.ReturnTypeSpecializationTest}</li>
- * <li>How to "instrument" an AST with nodes that can provide access to runtime state from external tools {@link com.oracle.truffle.api.test.InstrumentationTest}</li>
+ * <li>How to "instrument" an AST with nodes that can provide access to runtime state from external tools {@link com.oracle.truffle.api.test.instrument.InstrumentationTest}</li>
  * </ul>
  *
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceTextTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2013, 2015, 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.api.test.source;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.source.*;
+
+public class SourceTextTest {
+
+    private final Source emptySource = Source.fromText("", null);
+
+    private final Source emptyLineSource = Source.fromText("\n", null);
+
+    private final Source shortSource = Source.fromText("01", null);
+
+    private final Source longSource = Source.fromText("01234\n67\n9\n", null);
+
+    @Test
+    public void emptyTextTest0() {
+        assertEquals(emptySource.getLineCount(), 0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest1() {
+        emptySource.getLineNumber(0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest2() {
+        emptySource.getColumnNumber(0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest3() {
+        emptySource.getLineNumber(-1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest4() {
+        emptySource.getLineStartOffset(0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest5() {
+        emptySource.getLineStartOffset(1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyTextTest6() {
+        emptySource.getLineLength(1);
+    }
+
+    @Test
+    public void emptyLineTest0() {
+        assertEquals(emptyLineSource.getLineCount(), 1);
+        assertEquals(emptyLineSource.getLineNumber(0), 1);
+        assertEquals(emptyLineSource.getLineStartOffset(1), 0);
+        assertEquals(emptyLineSource.getColumnNumber(0), 1);
+        assertEquals(emptyLineSource.getLineLength(1), 0);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyLineTest1() {
+        emptyLineSource.getLineNumber(1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyLineTest2() {
+        emptyLineSource.getLineStartOffset(2);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyLineTest3() {
+        emptyLineSource.getColumnNumber(1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void emptyLineTest4() {
+        emptyLineSource.getLineLength(2);
+    }
+
+    @Test
+    public void shortTextTest0() {
+
+        assertEquals(shortSource.getLineCount(), 1);
+
+        assertEquals(shortSource.getLineNumber(0), 1);
+        assertEquals(shortSource.getLineStartOffset(1), 0);
+        assertEquals(shortSource.getColumnNumber(0), 1);
+
+        assertEquals(shortSource.getLineNumber(1), 1);
+        assertEquals(shortSource.getColumnNumber(1), 2);
+
+        assertEquals(shortSource.getLineLength(1), 2);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest1() {
+        shortSource.getLineNumber(-1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest2() {
+        shortSource.getColumnNumber(-1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest3() {
+        shortSource.getLineNumber(2);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest4() {
+        shortSource.getColumnNumber(2);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest5() {
+        shortSource.getLineLength(2);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void shortTextTest6() {
+        shortSource.getLineLength(2);
+    }
+
+    @Test
+    public void longTextTest0() {
+
+        assertEquals(longSource.getLineCount(), 3);
+
+        assertEquals(longSource.getLineNumber(0), 1);
+        assertEquals(longSource.getLineStartOffset(1), 0);
+        assertEquals(longSource.getColumnNumber(0), 1);
+
+        assertEquals(longSource.getLineNumber(4), 1);
+        assertEquals(longSource.getColumnNumber(4), 5);
+
+        assertEquals(longSource.getLineNumber(5), 1); // newline
+        assertEquals(longSource.getColumnNumber(5), 6); // newline
+        assertEquals(longSource.getLineLength(1), 5);
+
+        assertEquals(longSource.getLineNumber(6), 2);
+        assertEquals(longSource.getLineStartOffset(2), 6);
+        assertEquals(longSource.getColumnNumber(6), 1);
+
+        assertEquals(longSource.getLineNumber(7), 2);
+        assertEquals(longSource.getColumnNumber(7), 2);
+
+        assertEquals(longSource.getLineNumber(8), 2); // newline
+        assertEquals(longSource.getLineNumber(8), 2); // newline
+        assertEquals(longSource.getLineLength(2), 2);
+
+        assertEquals(longSource.getLineNumber(9), 3);
+        assertEquals(longSource.getLineStartOffset(3), 9);
+        assertEquals(longSource.getColumnNumber(9), 1);
+
+        assertEquals(longSource.getLineNumber(10), 3); // newline
+        assertEquals(longSource.getColumnNumber(10), 2); // newline
+        assertEquals(longSource.getLineLength(3), 1);
+
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void longTextTest1() {
+        longSource.getLineNumber(11);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void longTextTest2() {
+        longSource.getColumnNumber(11);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void longTextTest3() {
+        longSource.getLineStartOffset(4);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/CoverageTrackerTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2015, 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.api.test.tools;
+
+import static com.oracle.truffle.api.test.tools.TestNodes.*;
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.tools.*;
+
+public class CoverageTrackerTest {
+
+    @Test
+    public void testNoExecution() {
+        final CoverageTracker tool = new CoverageTracker();
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+        tool.install();
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+        tool.setEnabled(false);
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+        tool.setEnabled(true);
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+        tool.reset();
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+        tool.dispose();
+        assertEquals(tool.getCounts().entrySet().size(), 0);
+    }
+
+    @Test
+    public void testToolCreatedTooLate() {
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+        final CoverageTracker tool = new CoverageTracker();
+        tool.install();
+        assertEquals(13, expr13rootNode.execute(null));
+        assertTrue(tool.getCounts().isEmpty());
+        tool.dispose();
+    }
+
+    @Test
+    public void testToolInstalledcTooLate() {
+        final CoverageTracker tool = new CoverageTracker();
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+        tool.install();
+        assertEquals(13, expr13rootNode.execute(null));
+        assertTrue(tool.getCounts().isEmpty());
+        tool.dispose();
+    }
+
+    @Test
+    public void testCountingCoverage() {
+        final CoverageTracker tool = new CoverageTracker();
+        tool.install();
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+
+        // Not probed yet.
+        assertEquals(13, expr13rootNode.execute(null));
+        assertTrue(tool.getCounts().isEmpty());
+
+        final Node addNode = expr13rootNode.getChildren().iterator().next();
+        final Probe probe = addNode.probe();
+
+        // Probed but not tagged yet.
+        assertEquals(13, expr13rootNode.execute(null));
+        assertTrue(tool.getCounts().isEmpty());
+
+        probe.tagAs(StandardSyntaxTag.STATEMENT, "fake statement for testing");
+
+        // Counting now; execute once
+        assertEquals(13, expr13rootNode.execute(null));
+
+        final Long[] longs1 = tool.getCounts().get(addNode.getSourceSection().getSource());
+        assertNotNull(longs1);
+        assertEquals(longs1.length, 2);
+        assertNull(longs1[0]);  // Line 1 is empty (text lines are 1-based)
+        assertEquals(1L, longs1[1].longValue());  // Expression is on line 2
+
+        // Execute 99 more times
+        for (int i = 0; i < 99; i++) {
+            assertEquals(13, expr13rootNode.execute(null));
+        }
+
+        final Long[] longs100 = tool.getCounts().get(addNode.getSourceSection().getSource());
+        assertNotNull(longs100);
+        assertEquals(longs100.length, 2);
+        assertNull(longs100[0]);
+        assertEquals(100L, longs100[1].longValue());
+
+        tool.dispose();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/LineToProbesMapTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015, 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.api.test.tools;
+
+import static com.oracle.truffle.api.test.tools.TestNodes.*;
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.source.*;
+import com.oracle.truffle.api.tools.*;
+
+public class LineToProbesMapTest {
+
+    @Test
+    public void testToolCreatedTooLate() {
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+        final Node addNode = expr13rootNode.getChildren().iterator().next();
+        final Probe probe = addNode.probe();
+        final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
+        assertEquals(lineLocation, expr13Line2);
+
+        final LineToProbesMap tool = new LineToProbesMap();
+        tool.install();
+
+        assertNull(tool.findFirstProbe(expr13Line1));
+        assertNull(tool.findFirstProbe(expr13Line2));
+        tool.dispose();
+    }
+
+    @Test
+    public void testToolInstalledTooLate() {
+        final LineToProbesMap tool = new LineToProbesMap();
+
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+        final Node addNode = expr13rootNode.getChildren().iterator().next();
+        final Probe probe = addNode.probe();
+        final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
+        assertEquals(lineLocation, expr13Line2);
+
+        tool.install();
+
+        assertNull(tool.findFirstProbe(expr13Line1));
+        assertNull(tool.findFirstProbe(expr13Line2));
+        tool.dispose();
+    }
+
+    @Test
+    public void testMapping() {
+        final LineToProbesMap tool = new LineToProbesMap();
+        tool.install();
+
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+        final Node addNode = expr13rootNode.getChildren().iterator().next();
+        final Probe probe = addNode.probe();
+        final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
+        assertEquals(lineLocation, expr13Line2);
+
+        assertNull(tool.findFirstProbe(expr13Line1));
+        assertEquals(tool.findFirstProbe(expr13Line2), probe);
+        tool.dispose();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/NodeExecCounterTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2015, 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.api.test.tools;
+
+import static com.oracle.truffle.api.test.tools.TestNodes.*;
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.test.tools.TestNodes.TestAddNode;
+import com.oracle.truffle.api.test.tools.TestNodes.TestValueNode;
+import com.oracle.truffle.api.tools.*;
+import com.oracle.truffle.api.tools.NodeExecCounter.NodeExecutionCount;
+
+public class NodeExecCounterTest {
+
+    @Test
+    public void testNoExecution() {
+        final NodeExecCounter tool = new NodeExecCounter();
+        assertEquals(tool.getCounts().length, 0);
+        tool.install();
+        assertEquals(tool.getCounts().length, 0);
+        tool.setEnabled(false);
+        assertEquals(tool.getCounts().length, 0);
+        tool.setEnabled(true);
+        assertEquals(tool.getCounts().length, 0);
+        tool.reset();
+        assertEquals(tool.getCounts().length, 0);
+        tool.dispose();
+        assertEquals(tool.getCounts().length, 0);
+    }
+
+    @Test
+    public void testToolCreatedTooLate() {
+        final CallTarget expr13callTarget = createExpr13TestCallTarget();
+        final NodeExecCounter tool = new NodeExecCounter();
+        tool.install();
+        assertEquals(13, expr13callTarget.call());
+        assertEquals(tool.getCounts().length, 0);
+        tool.dispose();
+    }
+
+    @Test
+    public void testToolInstalledcTooLate() {
+        final NodeExecCounter tool = new NodeExecCounter();
+        final CallTarget expr13callTarget = createExpr13TestCallTarget();
+        tool.install();
+        assertEquals(13, expr13callTarget.call());
+        assertEquals(tool.getCounts().length, 0);
+        tool.dispose();
+    }
+
+    @Test
+    public void testCountingAll() {
+        final NodeExecCounter tool = new NodeExecCounter();
+        tool.install();
+        final CallTarget expr13callTarget = createExpr13TestCallTarget();
+
+        // execute once
+        assertEquals(13, expr13callTarget.call());
+        final NodeExecutionCount[] count1 = tool.getCounts();
+        assertNotNull(count1);
+        assertEquals(count1.length, 2);
+        for (NodeExecutionCount count : count1) {
+            final Class<?> class1 = count.nodeClass();
+            final long executionCount = count.executionCount();
+            if (class1 == TestAddNode.class) {
+                assertEquals(executionCount, 1);
+            } else if (class1 == TestValueNode.class) {
+                assertEquals(executionCount, 2);
+            } else {
+                fail();
+            }
+        }
+
+        // Execute 99 more times
+        for (int i = 0; i < 99; i++) {
+            assertEquals(13, expr13callTarget.call());
+        }
+        final NodeExecutionCount[] counts100 = tool.getCounts();
+        assertNotNull(counts100);
+        assertEquals(counts100.length, 2);
+        for (NodeExecutionCount count : counts100) {
+            final Class<?> class1 = count.nodeClass();
+            final long executionCount = count.executionCount();
+            if (class1 == TestAddNode.class) {
+                assertEquals(executionCount, 100);
+            } else if (class1 == TestValueNode.class) {
+                assertEquals(executionCount, 200);
+            } else {
+                fail();
+            }
+        }
+
+        tool.dispose();
+    }
+
+    @Test
+    public void testCountingTagged() {
+        final NodeExecCounter tool = new NodeExecCounter(StandardSyntaxTag.STATEMENT);
+        tool.install();
+        final RootNode expr13rootNode = createExpr13TestRootNode();
+
+        // Not probed yet.
+        assertEquals(13, expr13rootNode.execute(null));
+        assertEquals(tool.getCounts().length, 0);
+
+        final Node addNode = expr13rootNode.getChildren().iterator().next();
+        final Probe probe = addNode.probe();
+
+        // Probed but not tagged yet.
+        assertEquals(13, expr13rootNode.execute(null));
+        assertEquals(tool.getCounts().length, 0);
+
+        probe.tagAs(StandardSyntaxTag.STATEMENT, "fake statement for testing");
+
+        // Counting now; execute once
+        assertEquals(13, expr13rootNode.execute(null));
+        final NodeExecutionCount[] counts1 = tool.getCounts();
+        assertNotNull(counts1);
+        assertEquals(counts1.length, 1);
+        final NodeExecutionCount count1 = counts1[0];
+        assertNotNull(count1);
+        assertEquals(count1.nodeClass(), addNode.getClass());
+        assertEquals(count1.executionCount(), 1);
+
+        // Execute 99 more times
+        for (int i = 0; i < 99; i++) {
+            assertEquals(13, expr13rootNode.execute(null));
+        }
+
+        final NodeExecutionCount[] counts100 = tool.getCounts();
+        assertNotNull(counts100);
+        assertEquals(counts100.length, 1);
+        final NodeExecutionCount count100 = counts100[0];
+        assertNotNull(count100);
+        assertEquals(count100.nodeClass(), addNode.getClass());
+        assertEquals(count100.executionCount(), 100);
+
+        tool.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/TestNodes.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2015, 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.api.test.tools;
+
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.source.*;
+
+/**
+ * Nodes and an {@linkplain CallTarget executable ASTs} for testing.
+ */
+public class TestNodes {
+
+    /**
+     * A fake source used for testing: empty line 1, expression on line 2.
+     */
+    public static final Source expr13Source = Source.fromText("\n6+7\n", "Test Source: expression on line 2 that evaluates to 13");
+    public static final LineLocation expr13Line1 = expr13Source.createLineLocation(1);
+    public static final LineLocation expr13Line2 = expr13Source.createLineLocation(2);
+
+    /**
+     * An executable addition expression that evaluates to 13.
+     */
+    public static CallTarget createExpr13TestCallTarget() {
+        final RootNode rootNode = createExpr13TestRootNode();
+        return Truffle.getRuntime().createCallTarget(rootNode);
+    }
+
+    /**
+     * Root holding an addition expression that evaluates to 13.
+     */
+    public static RootNode createExpr13TestRootNode() {
+        final TestLanguageNode ast = createExpr13AST();
+        final TestRootNode rootNode = new TestRootNode(ast);
+        rootNode.adoptChildren();
+        return rootNode;
+    }
+
+    /**
+     * Addition expression that evaluates to 13, with faked source attribution.
+     */
+    public static TestLanguageNode createExpr13AST() {
+        final SourceSection leftSourceSection = expr13Source.createSection("left", 1, 1);
+        final TestValueNode leftValueNode = new TestValueNode(6, leftSourceSection);
+        final SourceSection rightSourceSection = expr13Source.createSection("right", 3, 1);
+        final TestValueNode rightValueNode = new TestValueNode(7, rightSourceSection);
+        final SourceSection exprSourceSection = expr13Source.createSection("expr", 1, 3);
+        return new TestAddNode(leftValueNode, rightValueNode, exprSourceSection);
+    }
+
+    public abstract static class TestLanguageNode extends Node {
+        public abstract Object execute(VirtualFrame frame);
+
+        public TestLanguageNode() {
+        }
+
+        public TestLanguageNode(SourceSection srcSection) {
+            super(srcSection);
+        }
+
+        @Override
+        public boolean isInstrumentable() {
+            return true;
+        }
+
+        @Override
+        public WrapperNode createWrapperNode() {
+            return new TestWrapperNode(this);
+        }
+    }
+
+    @NodeInfo(cost = NodeCost.NONE)
+    public static class TestWrapperNode extends TestLanguageNode implements WrapperNode {
+        @Child private TestLanguageNode child;
+        @Child private ProbeNode probeNode;
+
+        public TestWrapperNode(TestLanguageNode child) {
+            assert !(child instanceof TestWrapperNode);
+            this.child = child;
+        }
+
+        @Override
+        public String instrumentationInfo() {
+            return "Wrapper node for testing";
+        }
+
+        @Override
+        public boolean isInstrumentable() {
+            return false;
+        }
+
+        @Override
+        public void insertProbe(ProbeNode newProbeNode) {
+            this.probeNode = newProbeNode;
+        }
+
+        @Override
+        public Probe getProbe() {
+            try {
+                return probeNode.getProbe();
+            } catch (IllegalStateException e) {
+                throw new IllegalStateException("Cannot call getProbe() on a wrapper that has no probe");
+            }
+        }
+
+        @Override
+        public Node getChild() {
+            return child;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            probeNode.enter(child, frame);
+            Object result;
+
+            try {
+                result = child.execute(frame);
+                probeNode.returnValue(child, frame, result);
+            } catch (KillException e) {
+                throw (e);
+            } catch (Exception e) {
+                probeNode.returnExceptional(child, frame, e);
+                throw (e);
+            }
+
+            return result;
+        }
+    }
+
+    /**
+     * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST
+     * of the guest language. This is necessary since creating a {@link CallTarget} is how Truffle
+     * completes an AST. The root nodes serves as our entry point into a program.
+     */
+    public static class TestRootNode extends RootNode {
+        @Child private TestLanguageNode body;
+
+        /**
+         * This constructor emulates the global machinery that applies registered probers to every
+         * newly created AST. Global registry is not used, since that would interfere with other
+         * tests run in the same environment.
+         */
+        public TestRootNode(TestLanguageNode body) {
+            super(null);
+            this.body = body;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return body.execute(frame);
+        }
+
+        @Override
+        public boolean isCloningAllowed() {
+            return true;
+        }
+
+        @Override
+        public void applyInstrumentation() {
+            Probe.applyASTProbers(body);
+        }
+    }
+
+    public static class TestValueNode extends TestLanguageNode {
+        private final int value;
+
+        public TestValueNode(int value) {
+            this.value = value;
+        }
+
+        public TestValueNode(int value, SourceSection srcSection) {
+            super(srcSection);
+            this.value = value;
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return new Integer(this.value);
+        }
+    }
+
+    public static class TestAddNode extends TestLanguageNode {
+        @Child private TestLanguageNode leftChild;
+        @Child private TestLanguageNode rightChild;
+
+        public TestAddNode(TestValueNode leftChild, TestValueNode rightChild, SourceSection sourceSection) {
+            super(sourceSection);
+            this.leftChild = insert(leftChild);
+            this.rightChild = insert(rightChild);
+        }
+
+        @Override
+        public Object execute(VirtualFrame frame) {
+            return new Integer(((Integer) leftChild.execute(frame)).intValue() + ((Integer) rightChild.execute(frame)).intValue());
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/TruffleToolTest.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2015, 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.api.test.tools;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+import com.oracle.truffle.api.instrument.*;
+
+/**
+ * Test the basic life cycle properties shared by all instances of {@link TruffleTool}.
+ */
+public class TruffleToolTest {
+
+    @Test
+    public void testEmptyLifeCycle() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        assertFalse(tool.isEnabled());
+        tool.install();
+        assertTrue(tool.isEnabled());
+        tool.reset();
+        assertTrue(tool.isEnabled());
+        tool.setEnabled(false);
+        assertFalse(tool.isEnabled());
+        tool.reset();
+        assertFalse(tool.isEnabled());
+        tool.setEnabled(true);
+        assertTrue(tool.isEnabled());
+        tool.reset();
+        assertTrue(tool.isEnabled());
+        tool.dispose();
+        assertFalse(tool.isEnabled());
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testNotYetInstalled1() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.reset();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testNotYetInstalled2() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.setEnabled(true);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testNotYetInstalled3() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.dispose();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAlreadyInstalled() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.install();
+        tool.install();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAlreadyDisposed1() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.install();
+        tool.dispose();
+        tool.install();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAlreadyDisposed2() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.install();
+        tool.dispose();
+        tool.reset();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAlreadyDisposed3() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.install();
+        tool.dispose();
+        tool.setEnabled(true);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testAlreadyDisposed4() {
+        final DummyTruffleTool tool = new DummyTruffleTool();
+        tool.install();
+        tool.dispose();
+        tool.dispose();
+    }
+
+    private static final class DummyTruffleTool extends TruffleTool {
+
+        @Override
+        protected boolean internalInstall() {
+            return true;
+        }
+
+        @Override
+        protected void internalReset() {
+        }
+
+        @Override
+        protected void internalDispose() {
+        }
+
+    }
+}
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/SourceTextTest.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +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.truffle.api.test.utilities;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.source.*;
-
-public class SourceTextTest {
-
-    private final Source emptySource = Source.fromText("", null);
-
-    private final Source emptyLineSource = Source.fromText("\n", null);
-
-    private final Source shortSource = Source.fromText("01", null);
-
-    private final Source longSource = Source.fromText("01234\n67\n9\n", null);
-
-    @Test
-    public void emptyTextTest0() {
-        assertEquals(emptySource.getLineCount(), 0);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest1() {
-        emptySource.getLineNumber(0);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest2() {
-        emptySource.getColumnNumber(0);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest3() {
-        emptySource.getLineNumber(-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest4() {
-        emptySource.getLineStartOffset(0);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest5() {
-        emptySource.getLineStartOffset(1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyTextTest6() {
-        emptySource.getLineLength(1);
-    }
-
-    @Test
-    public void emptyLineTest0() {
-        assertEquals(emptyLineSource.getLineCount(), 1);
-        assertEquals(emptyLineSource.getLineNumber(0), 1);
-        assertEquals(emptyLineSource.getLineStartOffset(1), 0);
-        assertEquals(emptyLineSource.getColumnNumber(0), 1);
-        assertEquals(emptyLineSource.getLineLength(1), 0);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyLineTest1() {
-        emptyLineSource.getLineNumber(1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyLineTest2() {
-        emptyLineSource.getLineStartOffset(2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyLineTest3() {
-        emptyLineSource.getColumnNumber(1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void emptyLineTest4() {
-        emptyLineSource.getLineLength(2);
-    }
-
-    @Test
-    public void shortTextTest0() {
-
-        assertEquals(shortSource.getLineCount(), 1);
-
-        assertEquals(shortSource.getLineNumber(0), 1);
-        assertEquals(shortSource.getLineStartOffset(1), 0);
-        assertEquals(shortSource.getColumnNumber(0), 1);
-
-        assertEquals(shortSource.getLineNumber(1), 1);
-        assertEquals(shortSource.getColumnNumber(1), 2);
-
-        assertEquals(shortSource.getLineLength(1), 2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest1() {
-        shortSource.getLineNumber(-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest2() {
-        shortSource.getColumnNumber(-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest3() {
-        shortSource.getLineNumber(2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest4() {
-        shortSource.getColumnNumber(2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest5() {
-        shortSource.getLineLength(2);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void shortTextTest6() {
-        shortSource.getLineLength(2);
-    }
-
-    @Test
-    public void longTextTest0() {
-
-        assertEquals(longSource.getLineCount(), 3);
-
-        assertEquals(longSource.getLineNumber(0), 1);
-        assertEquals(longSource.getLineStartOffset(1), 0);
-        assertEquals(longSource.getColumnNumber(0), 1);
-
-        assertEquals(longSource.getLineNumber(4), 1);
-        assertEquals(longSource.getColumnNumber(4), 5);
-
-        assertEquals(longSource.getLineNumber(5), 1); // newline
-        assertEquals(longSource.getColumnNumber(5), 6); // newline
-        assertEquals(longSource.getLineLength(1), 5);
-
-        assertEquals(longSource.getLineNumber(6), 2);
-        assertEquals(longSource.getLineStartOffset(2), 6);
-        assertEquals(longSource.getColumnNumber(6), 1);
-
-        assertEquals(longSource.getLineNumber(7), 2);
-        assertEquals(longSource.getColumnNumber(7), 2);
-
-        assertEquals(longSource.getLineNumber(8), 2); // newline
-        assertEquals(longSource.getLineNumber(8), 2); // newline
-        assertEquals(longSource.getLineLength(2), 2);
-
-        assertEquals(longSource.getLineNumber(9), 3);
-        assertEquals(longSource.getLineStartOffset(3), 9);
-        assertEquals(longSource.getColumnNumber(9), 1);
-
-        assertEquals(longSource.getLineNumber(10), 3); // newline
-        assertEquals(longSource.getColumnNumber(10), 2); // newline
-        assertEquals(longSource.getLineLength(3), 1);
-
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void longTextTest1() {
-        longSource.getLineNumber(11);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void longTextTest2() {
-        longSource.getColumnNumber(11);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void longTextTest3() {
-        longSource.getLineStartOffset(4);
-    }
-
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java	Wed Jan 28 19:32:47 2015 +0100
@@ -213,6 +213,7 @@
      *            program
      * @return the value to be casted to the new type
      */
+    @Deprecated
     public static <T> T unsafeCast(Object value, Class<T> type, boolean condition) {
         return unsafeCast(value, type, condition, false);
     }
@@ -229,6 +230,7 @@
      * @param nonNull whether value is known to never be null
      * @return the value to be casted to the new type
      */
+    @Deprecated
     @SuppressWarnings("unchecked")
     public static <T> T unsafeCast(Object value, Class<T> type, boolean condition, boolean nonNull) {
         return (T) value;
@@ -248,6 +250,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getBoolean(receiver, offset);
     }
@@ -266,6 +269,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getByte(receiver, offset);
     }
@@ -284,6 +288,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getShort(receiver, offset);
     }
@@ -302,6 +307,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getInt(receiver, offset);
     }
@@ -320,6 +326,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getLong(receiver, offset);
     }
@@ -338,6 +345,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getFloat(receiver, offset);
     }
@@ -356,6 +364,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getDouble(receiver, offset);
     }
@@ -374,6 +383,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getObject(receiver, offset);
     }
@@ -388,6 +398,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) {
         UNSAFE.putBoolean(receiver, offset, value);
     }
@@ -402,6 +413,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) {
         UNSAFE.putByte(receiver, offset, value);
     }
@@ -416,6 +428,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity) {
         UNSAFE.putShort(receiver, offset, value);
     }
@@ -430,6 +443,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) {
         UNSAFE.putInt(receiver, offset, value);
     }
@@ -444,6 +458,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) {
         UNSAFE.putLong(receiver, offset, value);
     }
@@ -458,6 +473,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) {
         UNSAFE.putFloat(receiver, offset, value);
     }
@@ -472,6 +488,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) {
         UNSAFE.putDouble(receiver, offset, value);
     }
@@ -486,6 +503,7 @@
      * @param locationIdentity the location identity token that can be used for improved global
      *            value numbering or null
      */
+    @Deprecated
     public static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) {
         UNSAFE.putObject(receiver, offset, value);
     }
@@ -504,6 +522,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static boolean unsafeGetFinalBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getBoolean(receiver, offset);
     }
@@ -522,6 +541,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static byte unsafeGetFinalByte(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getByte(receiver, offset);
     }
@@ -540,6 +560,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static short unsafeGetFinalShort(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getShort(receiver, offset);
     }
@@ -558,6 +579,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static int unsafeGetFinalInt(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getInt(receiver, offset);
     }
@@ -576,6 +598,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static long unsafeGetFinalLong(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getLong(receiver, offset);
     }
@@ -594,6 +617,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static float unsafeGetFinalFloat(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getFloat(receiver, offset);
     }
@@ -612,6 +636,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static double unsafeGetFinalDouble(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getDouble(receiver, offset);
     }
@@ -630,6 +655,7 @@
      *            value numbering or null
      * @return the accessed value
      */
+    @Deprecated
     public static Object unsafeGetFinalObject(Object receiver, long offset, boolean condition, Object locationIdentity) {
         return UNSAFE.getObject(receiver, offset);
     }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java	Wed Jan 28 19:32:47 2015 +0100
@@ -49,6 +49,14 @@
     }
 
     private static TruffleRuntime initRuntime() {
+        if (TruffleOptions.ForceInterpreter) {
+            /*
+             * Force Truffle to run in interpreter mode even if we have a specialized implementation
+             * of TruffleRuntime available.
+             */
+            return new DefaultTruffleRuntime();
+        }
+
         try {
             return AccessController.doPrivileged(new PrivilegedAction<TruffleRuntime>() {
                 public TruffleRuntime run() {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java	Wed Jan 28 19:32:47 2015 +0100
@@ -34,6 +34,13 @@
 public class TruffleOptions {
 
     /**
+     * Force truffle to run in interpreter mode.
+     * <p>
+     * Can be set with {@code -Dtruffle.ForceInterpreter=true}.
+     */
+    public static boolean ForceInterpreter = Boolean.getBoolean("truffle.ForceInterpreter");
+
+    /**
      * Enables/disables the rewriting of traces in the Truffle runtime to stdout.
      * <p>
      * Can be set with {@code -Dtruffle.TraceRewrites=true}.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java	Wed Jan 28 19:32:47 2015 +0100
@@ -39,14 +39,11 @@
  */
 public final class DefaultTruffleRuntime implements TruffleRuntime {
 
-    private ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>();
-    private ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>();
+    private final ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>();
+    private final ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>();
     private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
 
     public DefaultTruffleRuntime() {
-        if (Truffle.getRuntime() != null) {
-            throw new IllegalArgumentException("Cannot instantiate DefaultTruffleRuntime. Use Truffle.getRuntime() instead.");
-        }
     }
 
     @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTProber.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTProber.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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,13 +31,14 @@
  * not yet executed) AST.
  *
  * @see Probe
- * @see Probe#addProbeListener(com.oracle.truffle.api.instrument.Probe.ProbeListener)
+ * @see Probe#addProbeListener(ProbeListener)
  */
 public interface ASTProber {
 
     /**
      * Walk the AST starting at a node and enable instrumentation at selected nodes by attaching
-     * {@linkplain Probe Probes} to them.
+     * {@linkplain Probe Probes} to them. Ignore {@linkplain Node#isInstrumentable()
+     * non-instrumentable} nodes.
      */
     void probeAST(Node node);
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -248,6 +248,11 @@
             this.nextInstrument = nextNode;
         }
 
+        @Override
+        public boolean isInstrumentable() {
+            return false;
+        }
+
         /**
          * Gets the instrument that created this node.
          */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -28,31 +28,32 @@
 import java.util.*;
 
 import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.instrument.ProbeNode.Instrumentable;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.api.utilities.*;
 
 //TODO (mlvdv) migrate some of this to external documentation.
 /**
- * A binding between a particular location in the Truffle AST representation of a running Guest
- * Language (GL) program (i.e. a {@link Node}) and a dynamically managed collection of "attached"
- * {@linkplain Instrument instrumentation} for use by external tools.
+ * A binding between a particular <em>location</em> in the Truffle AST representation of a running
+ * Guest Language (GL) program (i.e. a {@link Node}) and a dynamically managed collection of
+ * "attached" {@linkplain Instrument instrumentation} for use by external tools. The instrumentation
+ * is intended to persist at the location, even if the specific node instance is
+ * {@linkplain Node#replace(Node) replaced}.
  * <p>
- * The effect of a binding is to intercept {@linkplain TruffleEventReceiver execution events} at the
- * node and notify each attached {@link Instrument} before execution is allowed to resume.
+ * The effect of a binding is to intercept {@linkplain TruffleEventReceiver execution events}
+ * arriving at the node and notify each attached {@link Instrument} before execution is allowed to
+ * proceed to the child.
  * <p>
- * A Probe is "inserted" into a GL node via a call to {@link Instrumentable#probe()}; a GL node must
- * implement {@link Instrumentable} in order to support instrumentation. No more than one Probe can
- * be inserted at a node.
+ * A Probe is "inserted" into a GL node via a call to {@link Node#probe()}. No more than one Probe
+ * can be inserted at a node.
  * <p>
  * The "probing" of a Truffle AST must be done after it is complete (i.e. with parent pointers
  * correctly assigned), but before any executions. This is done by creating an instance of
  * {@link ASTProber} and registering it via {@link #registerASTProber(ASTProber)}, after which it
  * will be automatically applied to newly created ASTs.
  * <p>
- * Each Probe may also have assigned to it one or more {@link SyntaxTag}s, for example identifying a
- * node as a {@linkplain StandardSyntaxTag#STATEMENT STATEMENT}. Tags can be queried by tools to
+ * Each Probe may also have assigned to it any number of {@link SyntaxTag}s, for example identifying
+ * a node as a {@linkplain StandardSyntaxTag#STATEMENT STATEMENT}. Tags can be queried by tools to
  * configure behavior relevant to each probed node.
  * <p>
  * Instrumentation is implemented by modifying ASTs, both by inserting nodes into each AST at probed
@@ -60,69 +61,16 @@
  * Attached instrumentation code become, in effect, part of the GL program, and is subject to the
  * same levels of optimization as other GL code. This implementation accounts properly for the fact
  * that Truffle frequently <em>clones</em> ASTs, along with any attached instrumentation nodes. A
- * Probe, along with attached Instruments, represents a <em>logical</em> binding with a source code
- * location, producing event notifications that are (mostly) independent of which AST clone is
- * executing.
+ * {@link Probe}, along with attached {@link Instrument}s, represents a <em>logical</em> binding
+ * with a source code location, producing event notifications that are (mostly) independent of which
+ * AST clone is executing.
  *
  * @see Instrument
- * @see Instrumentable
  * @see ASTProber
+ * @see ProbeListener
  */
 public final class Probe implements SyntaxTagged {
 
-    /**
-     * An observer of events related to {@link Probe}s: creating and tagging.
-     */
-    public interface ProbeListener {
-
-        /**
-         * Notifies that all registered {@link ASTProber}s are about to be applied to a newly
-         * constructed AST.
-         *
-         * @param source source code from which the AST was constructed
-         */
-        void startASTProbing(Source source);
-
-        /**
-         * Notifies that a {@link Probe} has been newly attached to an AST via
-         * {@link Instrumentable#probe()}.
-         * <p>
-         * There can be no more than one {@link Probe} at a node; this notification will only be
-         * delivered the first time {@linkplain Instrumentable#probe() probe()} is called at a
-         * particular AST node. There will also be no notification when the AST to which the Probe
-         * is attached is cloned.
-         */
-        void newProbeInserted(Probe probe);
-
-        /**
-         * Notifies that a {@link SyntaxTag} has been newly added to the set of tags associated with
-         * a {@link Probe} via {@link Probe#tagAs(SyntaxTag, Object)}.
-         * <p>
-         * The {@linkplain SyntaxTag tags} at a {@link Probe} are a <em>set</em>; this notification
-         * will only be delivered the first time a particular {@linkplain SyntaxTag tag} is added at
-         * a {@link Probe}.
-         * <p>
-         * An optional value supplied with {@linkplain Probe#tagAs(SyntaxTag, Object)
-         * tagAs(SyntaxTag, Object)} is reported to all listeners, but not stored. As a consequence,
-         * the optional value will have no effect at all if the tag had already been added.
-         *
-         * @param probe where a tag has been added
-         * @param tag the tag that has been newly added (subsequent additions of the tag are
-         *            unreported).
-         * @param tagValue an optional value associated with the tag for the purposes of reporting.
-         */
-        void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue);
-
-        /**
-         * Notifies that the application of all registered {@link ASTProber}s to a newly constructed
-         * AST has completed.
-         *
-         * @param source source code from which the AST was constructed
-         */
-        void endASTProbing(Source source);
-
-    }
-
     private static final List<ASTProber> astProbers = new ArrayList<>();
 
     private static final List<ProbeListener> probeListeners = new ArrayList<>();
@@ -282,7 +230,7 @@
     private boolean trapActive = false;
 
     /**
-     * @see Instrumentable#probe()
+     * Intended for use only by {@link ProbeNode}.
      */
     Probe(ProbeNode probeNode, SourceSection sourceSection) {
         this.sourceSection = sourceSection;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeException.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, 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.instrument;
+
+import com.oracle.truffle.api.instrument.ProbeFailure.Reason;
+import com.oracle.truffle.api.nodes.*;
+
+/**
+ * An exception thrown when {@link Node#probe()} fails because of an implementation failure.
+ * <p>
+ * Language and tool implementations should ensure that clients of tools never see this exception.
+ */
+public class ProbeException extends RuntimeException {
+    static final long serialVersionUID = 1L;
+    private final ProbeFailure failure;
+
+    public ProbeException(Reason reason, Node parent, Node child, Object wrapper) {
+        this.failure = new ProbeFailure(reason, parent, child, wrapper);
+    }
+
+    public ProbeFailure getFailure() {
+        return failure;
+    }
+
+    @Override
+    public String toString() {
+        return failure.getMessage();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2015, 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.instrument;
+
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeField;
+
+/**
+ * Description of a failed attempt to instrument an AST node.
+ */
+public final class ProbeFailure {
+
+    public enum Reason {
+
+        /**
+         * Node to be probed has no parent.
+         */
+        NO_PARENT("Node to be probed has no parent"),
+
+        /**
+         * The node to be probed is a wrapper.
+         */
+        WRAPPER_NODE("The node to be probed is a wrapper"),
+
+        /**
+         * The node to be probed returned {@link Node#isInstrumentable()}{@code == false}.
+         */
+        NOT_INSTRUMENTABLE("The node to be project is \"not instrumentable\""),
+
+        /**
+         * No wrapper could be created that is also a {@link Node}.
+         */
+        NO_WRAPPER("No wrapper could be created"),
+
+        /**
+         * Wrapper not assignable to the parent's child field.
+         */
+        WRAPPER_TYPE("Wrapper not assignable to parent's child field"),
+
+        /**
+         * Attempt to \"probe lite\" an already probed node.
+         */
+        LITE_VIOLATION("Attempt to \"probe lite\" an already probed node");
+
+        final String message;
+
+        private Reason(String message) {
+            this.message = message;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+    }
+
+    private final Reason reason;
+    private final Node parent;
+    private final Node child;
+    private final Object wrapper;
+
+    /**
+     * Description of an internal failure of {@link Node#probe()}.
+     *
+     * @param reason what caused the failure
+     * @param parent the parent, if known, of the child being probed
+     * @param child this child being probed
+     * @param wrapper the {@link WrapperNode} created to implement the probe
+     */
+    public ProbeFailure(Reason reason, Node parent, Node child, Object wrapper) {
+        this.reason = reason;
+        this.parent = parent;
+        this.child = child;
+        this.wrapper = wrapper;
+    }
+
+    /**
+     * @return a short explanation of the failure
+     */
+    public Reason getReason() {
+        return reason;
+    }
+
+    /**
+     * @return the parent, if any, of the node being probed
+     */
+    public Node getParent() {
+        return parent;
+    }
+
+    /**
+     * @return the node being probed
+     */
+    public Node getChild() {
+        return child;
+    }
+
+    /**
+     * @return the {@link WrapperNode} created for the probe attempt
+     */
+    public Object getWrapper() {
+        return wrapper;
+    }
+
+    public String getMessage() {
+        final StringBuilder sb = new StringBuilder(reason.message + ": ");
+        if (parent != null) {
+            sb.append("parent=" + parent.getClass().getSimpleName() + " ");
+            if (child != null) {
+                sb.append("child=" + child.getClass().getSimpleName() + " ");
+                final NodeField field = NodeUtil.findChildField(parent, child);
+                if (field != null) {
+                    sb.append("field=" + field.getName() + " ");
+                }
+            }
+        }
+        if (wrapper != null) {
+            sb.append("wrapper=" + wrapper.getClass().getSimpleName());
+        }
+        return sb.toString();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeListener.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015, 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.instrument;
+
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.source.*;
+
+/**
+ * An observer of events related to {@link Probe}s: creating and tagging.
+ */
+public interface ProbeListener {
+
+    /**
+     * Notifies that all registered {@link ASTProber}s are about to be applied to a newly
+     * constructed AST.
+     *
+     * @param source source code from which the AST was constructed
+     */
+    void startASTProbing(Source source);
+
+    /**
+     * Notifies that a {@link Probe} has been newly attached to an AST via {@link Node#probe()}.
+     * <p>
+     * There can be no more than one {@link Probe} at a node; this notification will only be
+     * delivered the first time {@linkplain Node#probe() probe()} is called at a particular AST
+     * node. There will also be no notification when the AST to which the Probe is attached is
+     * cloned.
+     */
+    void newProbeInserted(Probe probe);
+
+    /**
+     * Notifies that a {@link SyntaxTag} has been newly added to the set of tags associated with a
+     * {@link Probe} via {@link Probe#tagAs(SyntaxTag, Object)}.
+     * <p>
+     * The {@linkplain SyntaxTag tags} at a {@link Probe} are a <em>set</em>; this notification will
+     * only be delivered the first time a particular {@linkplain SyntaxTag tag} is added at a
+     * {@link Probe}.
+     * <p>
+     * An optional value supplied with {@linkplain Probe#tagAs(SyntaxTag, Object) tagAs(SyntaxTag,
+     * Object)} is reported to all listeners, but not stored. As a consequence, the optional value
+     * will have no effect at all if the tag had already been added.
+     *
+     * @param probe where a tag has been added
+     * @param tag the tag that has been newly added (subsequent additions of the tag are
+     *            unreported).
+     * @param tagValue an optional value associated with the tag for the purposes of reporting.
+     */
+    void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue);
+
+    /**
+     * Notifies that the application of all registered {@link ASTProber}s to a newly constructed AST
+     * has completed.
+     *
+     * @param source source code from which the AST was constructed
+     */
+    void endASTProbing(Source source);
+
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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
@@ -38,46 +38,9 @@
 public abstract class ProbeNode extends Node implements TruffleEventReceiver, InstrumentationNode {
 
     /**
-     * Any Truffle node implementing this interface can be "instrumented" by installing a
-     * {@link Probe} that intercepts execution events at the node and routes them to any
-     * {@link Instrument}s that have been attached to the {@link Probe}. Only one {@link Probe} may
-     * be installed at each node; subsequent calls return the one already installed.
-     *
-     * @see Instrument
-     */
-    public interface Instrumentable {
-
-        /**
-         * Enables "instrumentation" of a Guest Language Truffle node, where the node is presumed to
-         * be part of a well-formed Truffle AST that is not being executed. The AST may be modified
-         * as a side effect.
-         * <p>
-         * This interface is not intended to be visible as part of the API for tools
-         * (instrumentation clients).
-         *
-         * @return a (possibly newly created) {@link Probe} associated with this node.
-         */
-        Probe probe();
-
-        /**
-         * Enables a one-time, unchangeable "instrumentation" of a Guest Language Truffle node,
-         * where the node is presumed to be part of a well-formed Truffle AST that is not being
-         * executed. The AST may be modified as a side-effect. Unlike {@link #probe()}, once
-         * {@link #probeLite(TruffleEventReceiver)} is called at a node, no additional probing can
-         * be added and no additional instrumentation can be attached.
-         * <p>
-         * This interface is not intended to be visible as part of the API for tools
-         * (instrumentation clients).
-         *
-         * @param eventReceiver The {@link TruffleEventReceiver} for the single "instrument" being
-         *            attached to this node.
-         */
-        void probeLite(TruffleEventReceiver eventReceiver);
-    }
-
-    /**
-     * A node that can be inserted into a Truffle AST, and which enables <em>instrumentation</em> at
-     * a particular Guest Language (GL) node.
+     * A node that can be inserted into a Truffle AST, and which enables {@linkplain Instrument
+     * instrumentation} at a particular Guest Language (GL) node. Implementations must extend
+     * {@link Node} and should override {@link Node#isInstrumentable()} to return {@code false}.
      * <p>
      * The implementation must be GL-specific. A wrapper <em>decorates</em> a GL AST node (the
      * wrapper's <em>child</em>) by acting as a transparent <em>proxy</em> with respect to the GL's
@@ -115,7 +78,6 @@
      * their runtime overhead to zero when there are no attached {@link Instrument}s.</li>
      * </ol>
      * <p>
-     * <strong>Disclaimer:</strong> experimental interface under development.
      *
      * @see Instrument
      */
@@ -130,7 +92,7 @@
 
         /**
          * Gets the {@link Probe} responsible for installing this wrapper; none if the wrapper
-         * installed via {@linkplain Instrumentable#probeLite(TruffleEventReceiver) "lite-Probing"}.
+         * installed via {@linkplain Node#probeLite(TruffleEventReceiver) "lite-Probing"}.
          */
         Probe getProbe();
 
@@ -163,6 +125,11 @@
         wrapper.insertProbe(probeLiteNode);
     }
 
+    @Override
+    public boolean isInstrumentable() {
+        return false;
+    }
+
     /**
      * @return the {@link Probe} permanently associated with this {@link ProbeNode}.
      *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/TruffleTool.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2015, 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.instrument;
+
+/**
+ * {@linkplain Instrument Instrumentation}-based tools that gather data during Guest Language
+ * program execution.
+ * <p>
+ * Tools share a common <em>life cycle</em>:
+ * <ul>
+ * <li>A newly created tool is inert until {@linkplain #install() installed}.</li>
+ * <li>An installed tool becomes <em>enabled</em> and immediately begins installing
+ * {@linkplain Instrument instrumentation} on subsequently created ASTs and collecting data from
+ * those instruments</li>
+ * <li>A tool may only be installed once.</li>
+ * <li>It should be possible to install multiple instances of a tool, possibly (but not necessarily)
+ * configured differently with respect to what data is being collected.</li>
+ * <li>Once installed, a tool can be {@linkplain #setEnabled(boolean) enabled and disabled}
+ * arbitrarily.</li>
+ * <li>A disabled tool:
+ * <ul>
+ * <li>Collects no data;</li>
+ * <li>Retains existing AST instrumentation;</li>
+ * <li>Continues to instrument newly created ASTs; and</li>
+ * <li>Retains previously collected data.</li>
+ * </ul>
+ * </li>
+ * <li>An installed tool may be {@linkplain #reset() reset} at any time, which leaves the tool
+ * installed but with all previously collected data removed.</li>
+ * <li>A {@linkplain #dispose() disposed} tool removes all instrumentation (but not
+ * {@linkplain Probe probes}) and becomes permanently disabled; previously collected data persists.</li>
+ * </ul>
+ * <p>
+ * Tool-specific methods that access data collected by the tool should:
+ * <ul>
+ * <li>Return modification-safe representations of the data; and</li>
+ * <li>Not change the state of the data.</li>
+ * </ul>
+ * <b>Note:</b><br>
+ * Tool installation is currently <em>global</em> to the Truffle Execution environment. When
+ * language-agnostic management of individual execution environments is added to the platform,
+ * installation will be (optionally) specific to a single execution environment.
+ */
+public abstract class TruffleTool {
+
+    private enum ToolState {
+        UNINSTALLED,
+        ENABLED_INSTALLED,
+        DISABLED_INSTALLED,
+        DISPOSED;
+    }
+
+    private ToolState toolState = ToolState.UNINSTALLED;
+
+    protected TruffleTool() {
+
+    }
+
+    /**
+     * Connect the tool to some part of the Truffle runtime, and enable data collection to start.
+     * Instrumentation will only be added to subsequently created ASTs.
+     *
+     * @throws IllegalStateException if the tool has previously been installed.
+     */
+    public final void install() {
+        if (toolState != ToolState.UNINSTALLED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has already been installed");
+        }
+        if (internalInstall()) {
+            toolState = ToolState.ENABLED_INSTALLED;
+        }
+    }
+
+    /**
+     * @return whether the tool is currently collecting data.
+     */
+    public final boolean isEnabled() {
+        return toolState == ToolState.ENABLED_INSTALLED;
+    }
+
+    /**
+     * Switches tool state between <em>enabled</em> (collecting data) and <em>disabled</em> (not
+     * collecting data, but keeping data already collected).
+     *
+     * @throws IllegalStateException if not yet installed or disposed.
+     */
+    public final void setEnabled(boolean isEnabled) {
+        if (toolState == ToolState.UNINSTALLED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " not yet installed");
+        }
+        if (toolState == ToolState.DISPOSED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has been disposed");
+        }
+        internalSetEnabled(isEnabled);
+        toolState = isEnabled ? ToolState.ENABLED_INSTALLED : ToolState.DISABLED_INSTALLED;
+    }
+
+    /**
+     * Clears any data already collected, but otherwise does not change the state of the tool.
+     *
+     * @throws IllegalStateException if not yet installed or disposed.
+     */
+    public final void reset() {
+        if (toolState == ToolState.UNINSTALLED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " not yet installed");
+        }
+        if (toolState == ToolState.DISPOSED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has been disposed");
+        }
+        internalReset();
+    }
+
+    /**
+     * Makes the tool permanently <em>disabled</em>, removes instrumentation, but keeps data already
+     * collected.
+     *
+     * @throws IllegalStateException if not yet installed or disposed.
+     */
+    public final void dispose() {
+        if (toolState == ToolState.UNINSTALLED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " not yet installed");
+        }
+        if (toolState == ToolState.DISPOSED) {
+            throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has been disposed");
+        }
+        internalDispose();
+        toolState = ToolState.DISPOSED;
+    }
+
+    /**
+     * @return whether the installation succeeded.
+     */
+    protected abstract boolean internalInstall();
+
+    /**
+     * No subclass action required.
+     * 
+     * @param isEnabled
+     */
+    protected void internalSetEnabled(boolean isEnabled) {
+    }
+
+    protected abstract void internalReset();
+
+    protected abstract void internalDispose();
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultProbeListener.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, 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.instrument.impl;
+
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.source.*;
+
+public abstract class DefaultProbeListener implements ProbeListener {
+
+    public void startASTProbing(Source source) {
+    }
+
+    public void newProbeInserted(Probe probe) {
+    }
+
+    public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
+    }
+
+    public void endASTProbing(Source source) {
+    }
+
+}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineToProbesMap.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
- * 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.instrument.impl;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.truffle.api.instrument.*;
-import com.oracle.truffle.api.instrument.Probe.ProbeListener;
-import com.oracle.truffle.api.source.*;
-
-/**
- * A mapping from {@link LineLocation} (a line number in a specific piece of {@link Source} code) to
- * a collection of {@link Probe}s whose associated {@link SourceSection} starts on that line.
- */
-public class LineToProbesMap implements ProbeListener {
-
-    private static final boolean TRACE = false;
-    private static final PrintStream OUT = System.out;
-
-    private static void trace(String msg) {
-        OUT.println("LineToProbesMap: " + msg);
-    }
-
-    /**
-     * Map: Source line ==> probes associated with source sections starting on the line.
-     */
-    private final Map<LineLocation, Collection<Probe>> lineToProbesMap = new HashMap<>();
-
-    public LineToProbesMap() {
-    }
-
-    public void startASTProbing(Source source) {
-    }
-
-    public void newProbeInserted(Probe probe) {
-        final SourceSection sourceSection = probe.getProbedSourceSection();
-        if (sourceSection != null && !(sourceSection instanceof NullSourceSection)) {
-            final LineLocation lineLocation = sourceSection.getLineLocation();
-            if (TRACE) {
-                trace("ADD " + lineLocation.getShortDescription() + " ==> " + probe.getShortDescription());
-            }
-            this.addProbeToLine(lineLocation, probe);
-        }
-    }
-
-    public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
-        // This map ignores tags
-    }
-
-    public void endASTProbing(Source source) {
-    }
-
-    /**
-     * Returns the {@link Probe}, if any, associated with source that starts on a specified line; if
-     * there are more than one, return the one with the first starting character location.
-     */
-    public Probe findLineProbe(LineLocation lineLocation) {
-        Probe probe = null;
-        final Collection<Probe> probes = getProbesAtLine(lineLocation);
-        for (Probe probesOnLine : probes) {
-            if (probe == null) {
-                probe = probesOnLine;
-            } else if (probesOnLine.getProbedSourceSection().getCharIndex() < probe.getProbedSourceSection().getCharIndex()) {
-                probe = probesOnLine;
-            }
-        }
-        return probe;
-    }
-
-    /**
-     * Records creation of a probe whose associated source starts on the given line.
-     * <p>
-     * If the line already exists in the internal {@link #lineToProbesMap}, this probe will be added
-     * to the existing collection. If no line already exists in the internal map, then a new key is
-     * added along with a new collection containing the probe.
-     * <p>
-     * This class requires that each added line/probe pair hasn't been previously added. However,
-     * attaching the same probe to a new line location is allowed.
-     *
-     * @param line The {@link LineLocation} to attach the probe to.
-     * @param probe The {@link Probe} to attach for that line location.
-     */
-    protected void addProbeToLine(LineLocation line, Probe probe) {
-
-        if (!lineToProbesMap.containsKey(line)) {
-            // Key does not exist, add new probe list
-            final ArrayList<Probe> newProbeList = new ArrayList<>(2);
-            newProbeList.add(probe);
-            lineToProbesMap.put(line, newProbeList);
-        } else {
-            // Probe list exists, add to existing
-            final Collection<Probe> existingProbeList = lineToProbesMap.get(line);
-            assert !existingProbeList.contains(probe);
-            existingProbeList.add(probe);
-        }
-    }
-
-    /**
-     *
-     * Returns a collection of {@link Probe}s whose associated source begins at the given
-     * {@link LineLocation}, an empty list if none.
-     *
-     * @param line The line to check.
-     * @return A collection of probes at the given line.
-     */
-    public Collection<Probe> getProbesAtLine(LineLocation line) {
-        Collection<Probe> probesList = lineToProbesMap.get(line);
-
-        if (probesList == null) {
-            return Collections.emptyList();
-        }
-        return probesList;
-    }
-
-    /**
-     * Convenience method to get probes according to a int line number. Returns a collection of
-     * {@link Probe}s at the given line number, an empty list if none.
-     *
-     * @param lineNumber The line number to check.
-     * @return A collection of probes at the given line.
-     */
-    public Collection<Probe> getProbesAtLineNumber(int lineNumber) {
-
-        final Set<LineLocation> keySet = lineToProbesMap.keySet();
-        if (keySet.size() == 0) {
-            return Collections.emptyList();
-        }
-
-        ArrayList<Probe> probes = new ArrayList<>();
-        for (LineLocation line : keySet) {
-            if (line.getLineNumber() == lineNumber) {
-                probes.addAll(lineToProbesMap.get(line));
-            }
-        }
-
-        return probes;
-    }
-
-    public void forget(Source source) {
-        final Set<LineLocation> mappedLines = lineToProbesMap.keySet();
-        if (mappedLines.size() > 0) {
-            List<LineLocation> forgetLines = new ArrayList<>();
-            for (LineLocation line : mappedLines) {
-                if (line.getSource().equals(source)) {
-                    forgetLines.add(line);
-                }
-            }
-            for (LineLocation line : forgetLines) {
-                lineToProbesMap.remove(line);
-            }
-        }
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/LineToSourceSectionMap.java	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * 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.instrument.impl;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.truffle.api.instrument.*;
-import com.oracle.truffle.api.instrument.Probe.*;
-import com.oracle.truffle.api.source.*;
-
-/**
- * A mapping from {@link LineLocation} (a line number in a specific piece of {@link Source} code) to
- * a collection of {@link SourceSection}s that exist on that line. This class assumes that all nodes
- * are instrumented as it uses the {@link ProbeListener} interface to determine the source sections
- * that exist in the file.
- */
-public class LineToSourceSectionMap implements ProbeListener {
-
-    private static final boolean TRACE = false;
-    private static final PrintStream OUT = System.out;
-
-    private static void trace(String msg) {
-        OUT.println("LineToSourceSectionMap: " + msg);
-    }
-
-    /**
-     * Map: Source line ==> source sections that exist on the line.
-     */
-    private final Map<LineLocation, Collection<SourceSection>> lineToSourceSectionsMap = new HashMap<>();
-
-    public LineToSourceSectionMap() {
-    }
-
-    public void startASTProbing(Source source) {
-    }
-
-    public void newProbeInserted(Probe probe) {
-        final SourceSection sourceSection = probe.getProbedSourceSection();
-        if (sourceSection != null && !(sourceSection instanceof NullSourceSection)) {
-            final LineLocation lineLocation = sourceSection.getLineLocation();
-            if (TRACE) {
-                trace("NEW " + lineLocation.getShortDescription() + " Probe=" + probe);
-            }
-            this.addSourceSectionToLine(lineLocation, sourceSection);
-        }
-    }
-
-    public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
-        // This map ignores tags, but this subclasses can override this method to operate on tags.
-    }
-
-    public void endASTProbing(Source source) {
-    }
-
-    /**
-     * Adds a source section to the given line.
-     * <p>
-     * If the line already exists in the internal {@link #lineToSourceSectionsMap}, this source
-     * section will be added to the existing collection. If no line already exists in the internal
-     * map, then a new key is added along with a new collection containing the source section.
-     * <p>
-     * This class does not check if a source section has already been added to a line.
-     *
-     * @param line The {@link LineLocation} to attach the source section to.
-     * @param sourceSection The {@link SourceSection} to attach for that line location.
-     */
-    protected void addSourceSectionToLine(LineLocation line, SourceSection sourceSection) {
-        if (!lineToSourceSectionsMap.containsKey(line)) {
-            // Key does not exist, add new source section list
-            final ArrayList<SourceSection> newSourceSectionList = new ArrayList<>(2);
-            newSourceSectionList.add(sourceSection);
-            lineToSourceSectionsMap.put(line, newSourceSectionList);
-        } else {
-            // Source section list exists, add to existing
-            final Collection<SourceSection> existingSourceSectionList = lineToSourceSectionsMap.get(line);
-            existingSourceSectionList.add(sourceSection);
-        }
-    }
-
-    /**
-     * Returns a collection of {@link SourceSection}s at the given {@link LineLocation}, an empty
-     * list if none.
-     *
-     * @param line The line to check.
-     * @return the source sections at the given line.
-     */
-    public Collection<SourceSection> getSourceSectionsAtLine(LineLocation line) {
-        Collection<SourceSection> sourceSectionList = lineToSourceSectionsMap.get(line);
-
-        if (sourceSectionList == null) {
-            return Collections.emptyList();
-        }
-        return sourceSectionList;
-    }
-
-    /**
-     * Convenience method to get source sections according to a int line number. Returns a
-     * collection of {@link SourceSection}s at the given line number. If there are no source
-     * sections at that line, an empty list is returned.
-     *
-     * @param lineNumber The line number to check.
-     * @return A collection of source sections at the given line.
-     */
-    public Collection<SourceSection> getSourceSectionsAtLineNumber(int lineNumber) {
-
-        final Set<LineLocation> keySet = lineToSourceSectionsMap.keySet();
-        if (keySet.size() == 0) {
-            return Collections.emptyList();
-        }
-
-        final ArrayList<SourceSection> sourceSections = new ArrayList<>();
-        for (LineLocation line : keySet) {
-            if (line.getLineNumber() == lineNumber) {
-                sourceSections.addAll(lineToSourceSectionsMap.get(line));
-            }
-        }
-
-        return sourceSections;
-    }
-}
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java	Wed Jan 28 19:32:47 2015 +0100
@@ -118,7 +118,7 @@
 
         // save old nodes
         prevNodeMap = nodeMap;
-        nodeMap = new HashMap<>();
+        nodeMap = new IdentityHashMap<>();
         edgeList = new ArrayList<>();
 
         return this;
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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
@@ -30,6 +30,8 @@
 
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
 import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.api.utilities.*;
 
@@ -288,9 +290,9 @@
     }
 
     /**
-     * Checks if this node is properly adopted by a parent and can be replaced.
+     * Checks if this node is properly adopted by its parent.
      *
-     * @return {@code true} if it is safe to replace this node.
+     * @return {@code true} if it is structurally safe to replace this node.
      */
     public final boolean isReplaceable() {
         if (getParent() != null) {
@@ -303,6 +305,13 @@
         return false;
     }
 
+    /**
+     * Checks if this node can be replaced by another node, both structurally and with type safety.
+     */
+    public final boolean isSafelyReplaceableBy(Node newNode) {
+        return isReplaceable() && NodeUtil.isReplacementSafe(getParent(), this, newNode);
+    }
+
     private void reportReplace(Node oldNode, Node newNode, CharSequence reason) {
         Node node = this;
         while (node != null) {
@@ -424,6 +433,138 @@
     }
 
     /**
+     * Any node for which this is {@code true} can be "instrumented" by installing a {@link Probe}
+     * that intercepts execution events at the node and routes them to any {@link Instrument}s that
+     * have been attached to the {@link Probe}. Only one {@link Probe} may be installed at each
+     * node; subsequent calls return the one already installed.
+     *
+     * @see Instrument
+     */
+    public boolean isInstrumentable() {
+        return false;
+    }
+
+    /**
+     * For any node that {@link #isInstrumentable()}, this method must return a {@link Node} that:
+     * <ol>
+     * <li>implements {@link WrapperNode}</li>
+     * <li>has {@code this} as it's child, and</li>
+     * <li>whose type is suitable for (unsafe) replacement of {@code this} in the parent.</li>
+     * </ol>
+     *
+     * @return an appropriately typed {@link WrapperNode} if {@link #isInstrumentable()}.
+     */
+    public WrapperNode createWrapperNode() {
+        return null;
+    }
+
+    /**
+     * Enables {@linkplain Instrument instrumentation} of a node, where the node is presumed to be
+     * part of a well-formed Truffle AST that is not being executed. If this node has not already
+     * been probed, modifies the AST by inserting a {@linkplain WrapperNode wrapper node} between
+     * the node and its parent; the wrapper node must be provided by implementations of
+     * {@link #createWrapperNode()}. No more than one {@link Probe} may be associated with a node,
+     * so a {@linkplain WrapperNode wrapper} may not wrap another {@linkplain WrapperNode wrapper}.
+     *
+     * @return a (possibly newly created) {@link Probe} associated with this node.
+     * @throws ProbeException (unchecked) when a probe cannot be created, leaving the AST unchanged
+     */
+    public final Probe probe() {
+
+        if (this instanceof WrapperNode) {
+            throw new ProbeException(ProbeFailure.Reason.WRAPPER_NODE, null, this, null);
+        }
+
+        if (parent == null) {
+            throw new ProbeException(ProbeFailure.Reason.NO_PARENT, null, this, null);
+        }
+
+        if (parent instanceof WrapperNode) {
+            return ((WrapperNode) parent).getProbe();
+        }
+
+        if (!isInstrumentable()) {
+            throw new ProbeException(ProbeFailure.Reason.NOT_INSTRUMENTABLE, parent, this, null);
+        }
+
+        // Create a new wrapper/probe with this node as its child.
+        final WrapperNode wrapper = createWrapperNode();
+
+        if (wrapper == null || !(wrapper instanceof Node)) {
+            throw new ProbeException(ProbeFailure.Reason.NO_WRAPPER, parent, this, wrapper);
+        }
+
+        final Node wrapperNode = (Node) wrapper;
+
+        if (!this.isSafelyReplaceableBy(wrapperNode)) {
+            throw new ProbeException(ProbeFailure.Reason.WRAPPER_TYPE, parent, this, wrapper);
+        }
+
+        // Connect it to a Probe
+        final Probe probe = ProbeNode.insertProbe(wrapper);
+
+        // Replace this node in the AST with the wrapper
+        this.replace(wrapperNode);
+
+        return probe;
+    }
+
+    /**
+     * Enables "one-shot", unmodifiable {@linkplain Instrument instrumentation} of a node, where the
+     * node is presumed to be part of a well-formed Truffle AST that is not being executed.
+     * <p>
+     * Modifies the AST by inserting a {@linkplain WrapperNode wrapper node} between the node and
+     * its parent; the wrapper node must be provided by implementations of
+     * {@link #createWrapperNode()}.
+     * <p>
+     * Unlike {@link #probe()}, once {@link #probeLite(TruffleEventReceiver)} is called at a node,
+     * no additional probing can be added and no additional instrumentation can be attached.
+     * <p>
+     * This restricted form of instrumentation is intended for special cases where only one kind of
+     * instrumentation is desired, and for which performance is a concern
+     *
+     * @param eventReceiver
+     * @throws ProbeException (unchecked) when a probe cannot be created, leaving the AST unchanged
+     */
+    public final void probeLite(TruffleEventReceiver eventReceiver) {
+
+        if (this instanceof WrapperNode) {
+            throw new ProbeException(ProbeFailure.Reason.WRAPPER_NODE, null, this, null);
+        }
+
+        if (parent == null) {
+            throw new ProbeException(ProbeFailure.Reason.NO_PARENT, null, this, null);
+        }
+
+        if (parent instanceof WrapperNode) {
+            throw new ProbeException(ProbeFailure.Reason.LITE_VIOLATION, null, this, null);
+        }
+
+        if (!isInstrumentable()) {
+            throw new ProbeException(ProbeFailure.Reason.NOT_INSTRUMENTABLE, parent, this, null);
+        }
+
+        // Create a new wrapper/probe with this node as its child.
+        final WrapperNode wrapper = createWrapperNode();
+
+        if (wrapper == null || !(wrapper instanceof Node)) {
+            throw new ProbeException(ProbeFailure.Reason.NO_WRAPPER, parent, this, wrapper);
+        }
+
+        final Node wrapperNode = (Node) wrapper;
+
+        if (!this.isSafelyReplaceableBy(wrapperNode)) {
+            throw new ProbeException(ProbeFailure.Reason.WRAPPER_TYPE, parent, this, wrapper);
+        }
+
+        // Connect it to a Probe
+        ProbeNode.insertProbeLite(wrapper, eventReceiver);
+
+        // Replace this node in the AST with the wrapper
+        this.replace(wrapperNode);
+    }
+
+    /**
      * Converts this node to a textual representation useful for debugging.
      */
     @Override
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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
@@ -43,6 +43,7 @@
  * Utility class that manages the special access methods for node instances.
  */
 public final class NodeUtil {
+    private static final boolean USE_UNSAFE = Boolean.getBoolean("truffle.unsafe");
 
     /**
      * Interface that allows the customization of field offsets used for {@link Unsafe} field
@@ -88,18 +89,26 @@
     /**
      * Information about a field in a {@link Node} class.
      */
-    public static final class NodeField {
+    public abstract static class NodeField {
 
         private final NodeFieldKind kind;
-        private final Class<?> type;
         private final String name;
-        private long offset;
+        protected final Class<?> type;
+        protected final long offset;
 
-        protected NodeField(NodeFieldKind kind, Class<?> type, String name, long offset) {
+        protected NodeField(NodeFieldKind kind, Field field) {
             this.kind = kind;
-            this.type = type;
-            this.name = name;
-            this.offset = offset;
+            this.type = field.getType();
+            this.name = field.getName();
+            this.offset = unsafeFieldOffsetProvider.objectFieldOffset(field);
+        }
+
+        protected static NodeField create(NodeFieldKind kind, Field field) {
+            if (USE_UNSAFE) {
+                return new UnsafeNodeField(kind, field);
+            } else {
+                return new ReflectionNodeField(kind, field);
+            }
         }
 
         public NodeFieldKind getKind() {
@@ -118,11 +127,45 @@
             return offset;
         }
 
-        public void putObject(Object receiver, Object value) {
-            assert value == null || type.isInstance(value);
+        public abstract void putObject(Node receiver, Object value);
+
+        public abstract Object getObject(Node receiver);
+
+        public abstract Object loadValue(Node node);
+
+        @Override
+        public int hashCode() {
+            return kind.hashCode() | type.hashCode() | name.hashCode() | ((Long) offset).hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof NodeField) {
+                NodeField other = (NodeField) obj;
+                return offset == other.offset && name.equals(other.name) && type.equals(other.type) && kind.equals(other.kind);
+            }
+            return false;
+        }
+    }
+
+    private static final class UnsafeNodeField extends NodeField {
+        protected UnsafeNodeField(NodeFieldKind kind, Field field) {
+            super(kind, field);
+        }
+
+        @Override
+        public void putObject(Node receiver, Object value) {
+            assert !type.isPrimitive() && value == null || type.isInstance(value);
             unsafe.putObject(receiver, offset, value);
         }
 
+        @Override
+        public Object getObject(Node receiver) {
+            assert !type.isPrimitive();
+            return unsafe.getObject(receiver, offset);
+        }
+
+        @Override
         public Object loadValue(Node node) {
             if (type == boolean.class) {
                 return unsafe.getBoolean(node, offset);
@@ -144,19 +187,62 @@
                 return unsafe.getObject(node, offset);
             }
         }
+    }
+
+    private static final class ReflectionNodeField extends NodeField {
+        private final Field field;
+
+        protected ReflectionNodeField(NodeFieldKind kind, Field field) {
+            super(kind, field);
+            this.field = field;
+            field.setAccessible(true);
+        }
 
         @Override
-        public int hashCode() {
-            return kind.hashCode() | type.hashCode() | name.hashCode() | ((Long) offset).hashCode();
+        public void putObject(Node receiver, Object value) {
+            assert !type.isPrimitive() && value == null || type.isInstance(value);
+            try {
+                field.set(receiver, value);
+            } catch (IllegalAccessException e) {
+                throw new AssertionError(e);
+            }
         }
 
         @Override
-        public boolean equals(Object obj) {
-            if (obj instanceof NodeField) {
-                NodeField other = (NodeField) obj;
-                return offset == other.offset && name.equals(other.name) && type.equals(other.type) && kind.equals(other.kind);
+        public Object getObject(Node receiver) {
+            assert !type.isPrimitive();
+            try {
+                return field.get(receiver);
+            } catch (IllegalAccessException e) {
+                throw new AssertionError(e);
             }
-            return false;
+        }
+
+        @Override
+        public Object loadValue(Node node) {
+            try {
+                if (type == boolean.class) {
+                    return field.getBoolean(node);
+                } else if (type == byte.class) {
+                    return field.getByte(node);
+                } else if (type == short.class) {
+                    return field.getShort(node);
+                } else if (type == char.class) {
+                    return field.getChar(node);
+                } else if (type == int.class) {
+                    return field.getInt(node);
+                } else if (type == long.class) {
+                    return field.getLong(node);
+                } else if (type == float.class) {
+                    return field.getFloat(node);
+                } else if (type == double.class) {
+                    return field.getDouble(node);
+                } else {
+                    return field.get(node);
+                }
+            } catch (IllegalAccessException e) {
+                throw new AssertionError(e);
+            }
         }
     }
 
@@ -172,7 +258,7 @@
                 assert Node.class.isAssignableFrom(clazz);
                 return AccessController.doPrivileged(new PrivilegedAction<NodeClass>() {
                     public NodeClass run() {
-                        return new NodeClass((Class<? extends Node>) clazz, unsafeFieldOffsetProvider);
+                        return new NodeClass((Class<? extends Node>) clazz);
                     }
                 });
             }
@@ -180,60 +266,61 @@
 
         // The comprehensive list of all fields.
         private final NodeField[] fields;
-        // Separate arrays for the frequently accessed field offsets.
-        private final long parentOffset;
-        private final long[] childOffsets;
-        private final long[] childrenOffsets;
-        private final long[] cloneableOffsets;
+        // Separate arrays for the frequently accessed fields.
+        private final NodeField parentField;
+        private final NodeField[] childFields;
+        private final NodeField[] childrenFields;
+        private final NodeField[] cloneableFields;
+
         private final Class<? extends Node> clazz;
 
         public static NodeClass get(Class<? extends Node> clazz) {
             return nodeClasses.get(clazz);
         }
 
-        public NodeClass(Class<? extends Node> clazz, FieldOffsetProvider fieldOffsetProvider) {
+        public NodeClass(Class<? extends Node> clazz) {
             List<NodeField> fieldsList = new ArrayList<>();
-            long parentFieldOffset = -1;
-            List<Long> childOffsetsList = new ArrayList<>();
-            List<Long> childrenOffsetsList = new ArrayList<>();
-            List<Long> cloneableOffsetsList = new ArrayList<>();
+            NodeField parentFieldTmp = null;
+            List<NodeField> childFieldList = new ArrayList<>();
+            List<NodeField> childrenFieldList = new ArrayList<>();
+            List<NodeField> cloneableFieldList = new ArrayList<>();
 
             for (Field field : getAllFields(clazz)) {
                 if (Modifier.isStatic(field.getModifiers()) || field.isSynthetic()) {
                     continue;
                 }
 
-                NodeFieldKind kind;
+                NodeField nodeField;
                 if (field.getDeclaringClass() == Node.class && field.getName().equals("parent")) {
                     assert Node.class.isAssignableFrom(field.getType());
-                    kind = NodeFieldKind.PARENT;
-                    parentFieldOffset = fieldOffsetProvider.objectFieldOffset(field);
+                    nodeField = NodeField.create(NodeFieldKind.PARENT, field);
+                    parentFieldTmp = nodeField;
                 } else if (field.getAnnotation(Child.class) != null) {
                     checkChildField(field);
-                    kind = NodeFieldKind.CHILD;
-                    childOffsetsList.add(fieldOffsetProvider.objectFieldOffset(field));
+                    nodeField = NodeField.create(NodeFieldKind.CHILD, field);
+                    childFieldList.add(nodeField);
                 } else if (field.getAnnotation(Children.class) != null) {
                     checkChildrenField(field);
-                    kind = NodeFieldKind.CHILDREN;
-                    childrenOffsetsList.add(fieldOffsetProvider.objectFieldOffset(field));
-                } else if (NodeCloneable.class.isAssignableFrom(field.getType())) {
-                    kind = NodeFieldKind.DATA;
-                    cloneableOffsetsList.add(fieldOffsetProvider.objectFieldOffset(field));
+                    nodeField = NodeField.create(NodeFieldKind.CHILDREN, field);
+                    childrenFieldList.add(nodeField);
                 } else {
-                    kind = NodeFieldKind.DATA;
+                    nodeField = NodeField.create(NodeFieldKind.DATA, field);
+                    if (NodeCloneable.class.isAssignableFrom(field.getType())) {
+                        cloneableFieldList.add(nodeField);
+                    }
                 }
-                fieldsList.add(new NodeField(kind, field.getType(), field.getName(), fieldOffsetProvider.objectFieldOffset(field)));
+                fieldsList.add(nodeField);
             }
 
-            if (parentFieldOffset < 0) {
+            if (parentFieldTmp == null) {
                 throw new AssertionError("parent field not found");
             }
 
             this.fields = fieldsList.toArray(new NodeField[fieldsList.size()]);
-            this.parentOffset = parentFieldOffset;
-            this.childOffsets = toLongArray(childOffsetsList);
-            this.childrenOffsets = toLongArray(childrenOffsetsList);
-            this.cloneableOffsets = toLongArray(cloneableOffsetsList);
+            this.parentField = parentFieldTmp;
+            this.childFields = childFieldList.toArray(new NodeField[childFieldList.size()]);
+            this.childrenFields = childrenFieldList.toArray(new NodeField[childrenFieldList.size()]);
+            this.cloneableFields = cloneableFieldList.toArray(new NodeField[cloneableFieldList.size()]);
             this.clazz = clazz;
         }
 
@@ -263,29 +350,37 @@
             return fields;
         }
 
-        public long getParentOffset() {
-            return parentOffset;
+        public NodeField getParentField() {
+            return parentField;
+        }
+
+        public NodeField[] getChildFields() {
+            return childFields;
         }
 
-        public long[] getChildOffsets() {
-            return childOffsets;
+        public NodeField[] getChildrenFields() {
+            return childrenFields;
         }
 
-        public long[] getChildrenOffsets() {
-            return childrenOffsets;
+        public NodeField findField(long fieldOffset) {
+            for (NodeField field : getFields()) {
+                if (field.getOffset() == fieldOffset) {
+                    return field;
+                }
+            }
+            return null;
         }
 
         @Override
         public int hashCode() {
-            return Arrays.hashCode(fields) ^ Arrays.hashCode(childOffsets) ^ Arrays.hashCode(childrenOffsets) ^ ((Long) parentOffset).hashCode();
+            return clazz.hashCode();
         }
 
         @Override
         public boolean equals(Object obj) {
             if (obj instanceof NodeClass) {
                 NodeClass other = (NodeClass) obj;
-                return Arrays.equals(fields, other.fields) && Arrays.equals(childOffsets, other.childOffsets) && Arrays.equals(childrenOffsets, other.childrenOffsets) &&
-                                parentOffset == other.parentOffset;
+                return clazz.equals(other.clazz);
             }
             return false;
         }
@@ -307,9 +402,9 @@
             }
 
             private int childrenCount() {
-                int nodeCount = childOffsets.length;
-                for (long fieldOffset : childrenOffsets) {
-                    Object[] children = ((Object[]) unsafe.getObject(node, fieldOffset));
+                int nodeCount = childFields.length;
+                for (NodeField childrenField : childrenFields) {
+                    Object[] children = ((Object[]) childrenField.getObject(node));
                     if (children != null) {
                         nodeCount += children.length;
                     }
@@ -318,12 +413,12 @@
             }
 
             private Node nodeAt(int idx) {
-                int nodeCount = childOffsets.length;
+                int nodeCount = childFields.length;
                 if (idx < nodeCount) {
-                    return (Node) unsafe.getObject(node, childOffsets[idx]);
+                    return (Node) childFields[idx].getObject(node);
                 } else {
-                    for (long fieldOffset : childrenOffsets) {
-                        Object[] nodeArray = (Object[]) unsafe.getObject(node, fieldOffset);
+                    for (NodeField childrenField : childrenFields) {
+                        Object[] nodeArray = (Object[]) childrenField.getObject(node);
                         if (idx < nodeCount + nodeArray.length) {
                             return (Node) nodeArray[idx - nodeCount];
                         }
@@ -429,14 +524,6 @@
         }
     }
 
-    private static long[] toLongArray(List<Long> list) {
-        long[] array = new long[list.size()];
-        for (int i = 0; i < list.size(); i++) {
-            array[i] = list.get(i);
-        }
-        return array;
-    }
-
     private static final Unsafe unsafe = getUnsafe();
 
     private static Unsafe getUnsafe() {
@@ -462,34 +549,34 @@
         final Node clone = orig.copy();
         NodeClass nodeClass = NodeClass.get(clone.getClass());
 
-        unsafe.putObject(clone, nodeClass.parentOffset, null);
+        nodeClass.parentField.putObject(clone, null);
 
-        for (long fieldOffset : nodeClass.childOffsets) {
-            Node child = (Node) unsafe.getObject(orig, fieldOffset);
+        for (NodeField childField : nodeClass.childFields) {
+            Node child = (Node) childField.getObject(orig);
             if (child != null) {
                 Node clonedChild = child.deepCopy();
-                unsafe.putObject(clonedChild, nodeClass.parentOffset, clone);
-                unsafe.putObject(clone, fieldOffset, clonedChild);
+                nodeClass.parentField.putObject(clonedChild, clone);
+                childField.putObject(clone, clonedChild);
             }
         }
-        for (long fieldOffset : nodeClass.childrenOffsets) {
-            Object[] children = (Object[]) unsafe.getObject(orig, fieldOffset);
+        for (NodeField childrenField : nodeClass.childrenFields) {
+            Object[] children = (Object[]) childrenField.getObject(orig);
             if (children != null) {
                 Object[] clonedChildren = (Object[]) Array.newInstance(children.getClass().getComponentType(), children.length);
                 for (int i = 0; i < children.length; i++) {
                     if (children[i] != null) {
                         Node clonedChild = ((Node) children[i]).deepCopy();
                         clonedChildren[i] = clonedChild;
-                        unsafe.putObject(clonedChild, nodeClass.parentOffset, clone);
+                        nodeClass.parentField.putObject(clonedChild, clone);
                     }
                 }
-                unsafe.putObject(clone, fieldOffset, clonedChildren);
+                childrenField.putObject(clone, clonedChildren);
             }
         }
-        for (long fieldOffset : nodeClass.cloneableOffsets) {
-            Object cloneable = unsafe.getObject(clone, fieldOffset);
-            if (cloneable != null && cloneable == unsafe.getObject(orig, fieldOffset)) {
-                unsafe.putObject(clone, fieldOffset, ((NodeCloneable) cloneable).clone());
+        for (NodeField cloneableField : nodeClass.cloneableFields) {
+            Object cloneable = cloneableField.getObject(clone);
+            if (cloneable != null && cloneable == cloneableField.getObject(orig)) {
+                cloneableField.putObject(clone, ((NodeCloneable) cloneable).clone());
             }
         }
         return clone;
@@ -499,14 +586,14 @@
         List<Node> nodes = new ArrayList<>();
         NodeClass nodeClass = NodeClass.get(node.getClass());
 
-        for (long fieldOffset : nodeClass.childOffsets) {
-            Object child = unsafe.getObject(node, fieldOffset);
+        for (NodeField nodeField : nodeClass.childFields) {
+            Object child = nodeField.getObject(node);
             if (child != null) {
                 nodes.add((Node) child);
             }
         }
-        for (long fieldOffset : nodeClass.childrenOffsets) {
-            Object[] children = (Object[]) unsafe.getObject(node, fieldOffset);
+        for (NodeField nodeField : nodeClass.childrenFields) {
+            Object[] children = (Object[]) nodeField.getObject(node);
             if (children != null) {
                 for (Object child : children) {
                     if (child != null) {
@@ -522,21 +609,21 @@
     public static boolean replaceChild(Node parent, Node oldChild, Node newChild) {
         NodeClass nodeClass = NodeClass.get(parent.getClass());
 
-        for (long fieldOffset : nodeClass.getChildOffsets()) {
-            if (unsafe.getObject(parent, fieldOffset) == oldChild) {
-                assert assertAssignable(nodeClass, fieldOffset, newChild);
-                unsafe.putObject(parent, fieldOffset, newChild);
+        for (NodeField nodeField : nodeClass.getChildFields()) {
+            if (nodeField.getObject(parent) == oldChild) {
+                assert assertAssignable(nodeField, newChild);
+                nodeField.putObject(parent, newChild);
                 return true;
             }
         }
 
-        for (long fieldOffset : nodeClass.getChildrenOffsets()) {
-            Object arrayObject = unsafe.getObject(parent, fieldOffset);
+        for (NodeField nodeField : nodeClass.getChildrenFields()) {
+            Object arrayObject = nodeField.getObject(parent);
             if (arrayObject != null) {
                 Object[] array = (Object[]) arrayObject;
                 for (int i = 0; i < array.length; i++) {
                     if (array[i] == oldChild) {
-                        assert assertAssignable(nodeClass, fieldOffset, newChild);
+                        assert assertAssignable(nodeField, newChild);
                         array[i] = newChild;
                         return true;
                     }
@@ -546,30 +633,80 @@
         return false;
     }
 
-    private static boolean assertAssignable(NodeClass clazz, long fieldOffset, Object newValue) {
+    private static boolean assertAssignable(NodeField field, Object newValue) {
         if (newValue == null) {
             return true;
         }
-        for (NodeField field : clazz.getFields()) {
-            if (field.getOffset() == fieldOffset) {
-                if (field.getKind() == NodeFieldKind.CHILD) {
-                    if (field.getType().isAssignableFrom(newValue.getClass())) {
-                        return true;
-                    } else {
-                        assert false : "Child class " + newValue.getClass().getName() + " is not assignable to field \"" + field.getName() + "\" of type " + field.getType().getName();
-                        return false;
-                    }
-                } else if (field.getKind() == NodeFieldKind.CHILDREN) {
-                    if (field.getType().getComponentType().isAssignableFrom(newValue.getClass())) {
-                        return true;
-                    } else {
-                        assert false : "Child class " + newValue.getClass().getName() + " is not assignable to field \"" + field.getName() + "\" of type " + field.getType().getName();
-                        return false;
+        if (field.getKind() == NodeFieldKind.CHILD) {
+            if (field.getType().isAssignableFrom(newValue.getClass())) {
+                return true;
+            } else {
+                assert false : "Child class " + newValue.getClass().getName() + " is not assignable to field \"" + field.getName() + "\" of type " + field.getType().getName();
+                return false;
+            }
+        } else if (field.getKind() == NodeFieldKind.CHILDREN) {
+            if (field.getType().getComponentType().isAssignableFrom(newValue.getClass())) {
+                return true;
+            } else {
+                assert false : "Child class " + newValue.getClass().getName() + " is not assignable to field \"" + field.getName() + "\" of type " + field.getType().getName();
+                return false;
+            }
+        }
+        throw new IllegalArgumentException();
+    }
+
+    /**
+     * Finds the field in a parent node, if any, that holds a specified child node.
+     *
+     * @return the field (possibly an array) holding the child, {@code null} if not found.
+     */
+    public static NodeField findChildField(Node parent, Node child) {
+        assert child != null;
+        NodeClass parentNodeClass = NodeClass.get(parent.getClass());
+
+        for (NodeField field : parentNodeClass.getChildFields()) {
+            final long fieldOffset = field.getOffset();
+            if (unsafe.getObject(parent, fieldOffset) == child) {
+                return parentNodeClass.findField(fieldOffset);
+            }
+        }
+
+        for (NodeField field : parentNodeClass.getChildrenFields()) {
+            final long fieldOffset = field.getOffset();
+            Object arrayObject = unsafe.getObject(parent, fieldOffset);
+            if (arrayObject != null) {
+                Object[] array = (Object[]) arrayObject;
+                for (int i = 0; i < array.length; i++) {
+                    if (array[i] == child) {
+                        return parentNodeClass.findField(fieldOffset);
                     }
                 }
             }
         }
-        throw new IllegalArgumentException();
+        return null;
+    }
+
+    /**
+     * Determines whether a proposed child replacement would be type safe.
+     *
+     * @param parent non-null node
+     * @param oldChild non-null existing child of parent
+     * @param newChild non-null proposed replacement for existing child
+     */
+    public static boolean isReplacementSafe(Node parent, Node oldChild, Node newChild) {
+        assert newChild != null;
+        final NodeField field = findChildField(parent, oldChild);
+        if (field == null) {
+            throw new IllegalArgumentException();
+        }
+        switch (field.getKind()) {
+            case CHILD:
+                return field.getType().isAssignableFrom(newChild.getClass());
+            case CHILDREN:
+                return field.getType().getComponentType().isAssignableFrom(newChild.getClass());
+            default:
+                throw new IllegalArgumentException();
+        }
     }
 
     /** Returns all declared fields in the class hierarchy. */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java	Wed Jan 28 19:32:47 2015 +0100
@@ -259,8 +259,7 @@
 
     private static Node updateParent(Node parent, Node child) {
         if (child != null) {
-            long parentOffset = NodeClass.get(child.getClass()).getParentOffset();
-            unsafe.putObject(child, parentOffset, parent);
+            NodeClass.get(child.getClass()).getParentField().putObject(child, parent);
         }
         return child;
     }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/LineLocation.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/LineLocation.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, 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,8 @@
  */
 package com.oracle.truffle.api.source;
 
+import java.util.*;
+
 /**
  * A specification for a location in guest language source, expressed as a line number in a specific
  * instance of {@link Source}, suitable for hash table keys with equality defined in terms of
@@ -40,4 +42,19 @@
 
     String getShortDescription();
 
+    /**
+     * Default comparator by (1) textual path name, (2) line number.
+     */
+    Comparator<LineLocation> COMPARATOR = new Comparator<LineLocation>() {
+
+        public int compare(LineLocation l1, LineLocation l2) {
+            final int sourceResult = l1.getSource().getPath().compareTo(l2.getSource().getPath());
+            if (sourceResult != 0) {
+                return sourceResult;
+            }
+            return Integer.compare(l1.getLineNumber(), l2.getLineNumber());
+        }
+
+    };
+
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java	Wed Jan 28 19:32:47 2015 +0100
@@ -542,7 +542,7 @@
         private long timeStamp;      // timestamp of the cache in the file system
 
         public FileSource(File file, String name, String path) {
-            this.file = file;
+            this.file = file.getAbsoluteFile();
             this.name = name;
             this.path = path;
         }
@@ -594,7 +594,8 @@
             try {
                 return new FileReader(file);
             } catch (FileNotFoundException e) {
-                throw new RuntimeException("Can't find file " + path);
+
+                throw new RuntimeException("Can't find file " + path, e);
             }
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/CoverageTracker.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2015, 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.tools;
+
+import java.io.*;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.*;
+
+import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.impl.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.Node.Child;
+import com.oracle.truffle.api.source.*;
+
+/**
+ * A {@link TruffleTool} that counts interpreter <em>execution calls</em> to AST nodes that hold a
+ * specified {@linkplain SyntaxTag tag}, tabulated by source and line number associated with each
+ * node. Tags are presumed to be applied external to the tool. If no tag is specified,
+ * {@linkplain StandardSyntaxTag#STATEMENT STATEMENT} is used, corresponding to conventional
+ * behavior for code coverage tools.
+ * <p>
+ * <b>Tool Life Cycle</b>
+ * <p>
+ * See {@link TruffleTool} for the life cycle common to all such tools.
+ * <p>
+ * <b>Execution Counts</b>
+ * <p>
+ * <ul>
+ * <li>"Execution call" on a node is is defined as invocation of a node method that is instrumented
+ * to produce the event {@link TruffleEventReceiver#enter(Node, VirtualFrame)};</li>
+ * <li>Execution calls are tabulated only at <em>instrumented</em> nodes, i.e. those for which
+ * {@linkplain Node#isInstrumentable() isInstrumentable() == true};</li>
+ * <li>Execution calls are tabulated only at nodes present in the AST when originally created;
+ * dynamically added nodes will not be instrumented.</li>
+ * </ul>
+ * </p>
+ * <b>Results</b>
+ * <p>
+ * A modification-safe copy of the {@linkplain #getCounts() counts} can be retrieved at any time,
+ * without effect on the state of the tool.
+ * </p>
+ * <p>
+ * A "default" {@linkplain #print(PrintStream) print()} method can summarizes the current counts at
+ * any time in a simple textual format, with no other effect on the state of the tool.
+ * </p>
+ *
+ * @see Instrument
+ * @see SyntaxTag
+ */
+public final class CoverageTracker extends TruffleTool {
+
+    /** Counting data. */
+    private final Map<LineLocation, CoverageCounter> counters = new HashMap<>();
+
+    /** For disposal. */
+    private final List<Instrument> instruments = new ArrayList<>();
+
+    /**
+     * Counting is restricted to nodes holding this tag.
+     */
+    private final SyntaxTag countingTag;
+
+    private final ProbeListener probeListener;
+
+    /**
+     * Create a per-line coverage tool for nodes tagged as {@linkplain StandardSyntaxTag#STATEMENT
+     * statements} in subsequently created ASTs.
+     */
+    public CoverageTracker() {
+        this(StandardSyntaxTag.STATEMENT);
+    }
+
+    /**
+     * Create a per-line coverage tool for nodes tagged as specified, presuming that tags applied
+     * outside this tool.
+     */
+    public CoverageTracker(SyntaxTag tag) {
+        this.probeListener = new CoverageProbeListener();
+        this.countingTag = tag;
+    }
+
+    @Override
+    protected boolean internalInstall() {
+        Probe.addProbeListener(probeListener);
+        return true;
+    }
+
+    @Override
+    protected void internalReset() {
+        counters.clear();
+    }
+
+    @Override
+    protected void internalDispose() {
+        Probe.removeProbeListener(probeListener);
+        for (Instrument instrument : instruments) {
+            instrument.dispose();
+        }
+    }
+
+    /**
+     * Gets a modification-safe summary of the current per-type node execution counts; does not
+     * affect the counts.
+     * <p>
+     * The map holds an array for each source, and elements of the a array corresponding to the
+     * textual lines of that source. An array entry contains null if the corresponding line of
+     * source is associated with no nodes of the relevant type, i.e. where no count was made. A
+     * numeric entry represents the execution count at the corresponding line of source.
+     * <p>
+     * <b>Note:</b> source line numbers are 1-based, so array index {@code i} corresponds to source
+     * line number {@code i + 1}
+     */
+    public Map<Source, Long[]> getCounts() {
+
+        /**
+         * Counters for every {Source, line number} for which a counter was installed, i.e. for
+         * every line associated with an appropriately tagged AST node; iterable in order of source
+         * name, then line number.
+         */
+        final TreeSet<Entry<LineLocation, CoverageCounter>> entries = new TreeSet<>(new LineLocationEntryComparator());
+
+        final Map<Source, Long[]> results = new HashMap<>();
+
+        for (Entry<LineLocation, CoverageCounter> entry : counters.entrySet()) {
+            entries.add(entry);
+        }
+        Source curSource = null;
+        Long[] curLineTable = null;
+        for (Entry<LineLocation, CoverageCounter> entry : entries) {
+            final LineLocation key = entry.getKey();
+            final Source source = key.getSource();
+            final int lineNo = key.getLineNumber();
+            if (source != curSource) {
+                if (curSource != null) {
+                    results.put(curSource, curLineTable);
+                }
+                curSource = source;
+                curLineTable = new Long[source.getLineCount()];
+            }
+            curLineTable[lineNo - 1] = entry.getValue().count.longValue();
+        }
+        if (curSource != null) {
+            results.put(curSource, curLineTable);
+        }
+        return results;
+    }
+
+    /**
+     * A default printer for the current line counts, producing lines of the form " (<count>) <line
+     * number> : <text of line>", grouped by source.
+     */
+    public void print(PrintStream out) {
+        out.println();
+        out.println(countingTag.name() + " coverage:");
+
+        /**
+         * Counters for every {Source, line number} for which a counter was installed, i.e. for
+         * every line associated with an appropriately tagged AST node; iterable in order of source
+         * name, then line number.
+         */
+        final TreeSet<Entry<LineLocation, CoverageCounter>> entries = new TreeSet<>(new LineLocationEntryComparator());
+
+        for (Entry<LineLocation, CoverageCounter> entry : counters.entrySet()) {
+            entries.add(entry);
+        }
+        Source curSource = null;
+        int curLineNo = 1;
+        for (Entry<LineLocation, CoverageCounter> entry : entries) {
+            final LineLocation key = entry.getKey();
+            final Source source = key.getSource();
+            final int lineNo = key.getLineNumber();
+            if (source != curSource) {
+                if (curSource != null) {
+                    while (curLineNo <= curSource.getLineCount()) {
+                        displayLine(out, null, curSource, curLineNo++);
+                    }
+                }
+                curSource = source;
+                curLineNo = 1;
+                out.println();
+                out.println(source.getPath());
+            }
+            while (curLineNo < lineNo) {
+                displayLine(out, null, curSource, curLineNo++);
+            }
+            displayLine(out, entry.getValue().count, curSource, curLineNo++);
+        }
+        if (curSource != null) {
+            while (curLineNo <= curSource.getLineCount()) {
+                displayLine(out, null, curSource, curLineNo++);
+            }
+        }
+    }
+
+    private static void displayLine(PrintStream out, AtomicLong value, Source source, int lineNo) {
+        if (value == null) {
+            out.format("%14s", " ");
+        } else {
+            out.format("(%12d)", value.longValue());
+        }
+        out.format(" %3d: ", lineNo);
+        out.println(source.getCode(lineNo));
+    }
+
+    /**
+     * A receiver for events at each instrumented AST location. This receiver counts
+     * "execution calls" to the instrumented node and is <em>stateful</em>. State in receivers must
+     * be considered carefully since ASTs, along with all instrumentation (including event receivers
+     * such as this) are routinely cloned by the Truffle runtime. AST cloning is <em>shallow</em>
+     * (for non- {@link Child} nodes), so in this case the actual count <em>is shared</em> among all
+     * the clones; the count is also held in a table indexed by source line.
+     * <p>
+     * In contrast, a primitive field would <em>not</em> be shared among clones and resulting counts
+     * would not be accurate.
+     */
+    private final class CoverageEventReceiver extends DefaultEventReceiver {
+
+        /**
+         * Shared by all clones of the associated instrument and by the table of counters for the
+         * line.
+         */
+        private final AtomicLong count;
+
+        CoverageEventReceiver(AtomicLong count) {
+            this.count = count;
+        }
+
+        @Override
+        @TruffleBoundary
+        public void enter(Node node, VirtualFrame frame) {
+            if (isEnabled()) {
+                count.getAndIncrement();
+            }
+        }
+    }
+
+    private static final class LineLocationEntryComparator implements Comparator<Entry<LineLocation, CoverageCounter>> {
+
+        public int compare(Entry<LineLocation, CoverageCounter> e1, Entry<LineLocation, CoverageCounter> e2) {
+            return LineLocation.COMPARATOR.compare(e1.getKey(), e2.getKey());
+        }
+    }
+
+    /**
+     * Attach a counting instrument to each node that is assigned a specified tag.
+     */
+    private class CoverageProbeListener extends DefaultProbeListener {
+
+        @Override
+        public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
+            if (countingTag == tag) {
+
+                final SourceSection srcSection = probe.getProbedSourceSection();
+                if (srcSection == null) {
+                    // TODO (mlvdv) report this?
+                } else {
+                    final LineLocation lineLocation = srcSection.getLineLocation();
+                    CoverageCounter counter = counters.get(lineLocation);
+                    if (counter != null) {
+                        // Another node starts on same line; count only the first (textually)
+                        if (srcSection.getCharIndex() > counter.srcSection.getCharIndex()) {
+                            // Counter already in place, corresponds to code earlier on line
+                            return;
+                        } else {
+                            // Counter already in place, corresponds to later code; replace it
+                            counter.instrument.dispose();
+                        }
+                    }
+                    final AtomicLong count = new AtomicLong();
+                    final CoverageEventReceiver eventReceiver = new CoverageEventReceiver(count);
+                    final Instrument instrument = Instrument.create(eventReceiver, CoverageTracker.class.getSimpleName());
+                    instruments.add(instrument);
+                    probe.attach(instrument);
+                    counters.put(lineLocation, new CoverageCounter(srcSection, instrument, count));
+                }
+            }
+        }
+    }
+
+    private class CoverageCounter {
+        final SourceSection srcSection;
+        final Instrument instrument;
+        final AtomicLong count;
+
+        CoverageCounter(SourceSection srcSection, Instrument instrument, AtomicLong count) {
+            this.srcSection = srcSection;
+            this.instrument = instrument;
+            this.count = count;
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/LineToProbesMap.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2014, 2015, 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.tools;
+
+import java.io.*;
+import java.util.*;
+
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.impl.*;
+import com.oracle.truffle.api.source.*;
+
+/**
+ * A {@link TruffleTool} that builds a map of every {@Probe} attached to some AST, indexed
+ * by {@link Source} and line number.
+ */
+public final class LineToProbesMap extends TruffleTool {
+
+    private static final boolean TRACE = false;
+    private static final PrintStream OUT = System.out;
+
+    private static void trace(String msg) {
+        OUT.println("LineToProbesMap: " + msg);
+    }
+
+    /**
+     * Map: Source line ==> probes associated with source sections starting on the line.
+     */
+    private final Map<LineLocation, Collection<Probe>> lineToProbesMap = new HashMap<>();
+
+    private final ProbeListener probeListener;
+
+    /**
+     * Create a map of {@link Probe}s that collects information on all probes added to subsequently
+     * created ASTs (once installed).
+     */
+    public LineToProbesMap() {
+        this.probeListener = new LineToProbesListener();
+    }
+
+    @Override
+    protected boolean internalInstall() {
+        Probe.addProbeListener(probeListener);
+        return true;
+    }
+
+    @Override
+    protected void internalReset() {
+        lineToProbesMap.clear();
+    }
+
+    @Override
+    protected void internalDispose() {
+        Probe.removeProbeListener(probeListener);
+    }
+
+    /**
+     * Returns the {@link Probe}, if any, associated with a specific line of guest language code; if
+     * more than one, return the one with the first starting character location.
+     */
+    public Probe findFirstProbe(LineLocation lineLocation) {
+        Probe probe = null;
+        final Collection<Probe> probes = findProbes(lineLocation);
+        for (Probe probesOnLine : probes) {
+            if (probe == null) {
+                probe = probesOnLine;
+            } else if (probesOnLine.getProbedSourceSection().getCharIndex() < probe.getProbedSourceSection().getCharIndex()) {
+                probe = probesOnLine;
+            }
+        }
+        return probe;
+    }
+
+    /**
+     * Returns all {@link Probe}s whose associated source begins at the given {@link LineLocation},
+     * an empty list if none.
+     */
+    public Collection<Probe> findProbes(LineLocation line) {
+        final Collection<Probe> probes = lineToProbesMap.get(line);
+        if (probes == null) {
+            return Collections.emptyList();
+        }
+        return Collections.unmodifiableCollection(probes);
+    }
+
+    private class LineToProbesListener extends DefaultProbeListener {
+
+        @Override
+        public void newProbeInserted(Probe probe) {
+            final SourceSection sourceSection = probe.getProbedSourceSection();
+            if (sourceSection != null && !(sourceSection instanceof NullSourceSection)) {
+                final LineLocation lineLocation = sourceSection.getLineLocation();
+                if (TRACE) {
+                    trace("ADD " + lineLocation.getShortDescription() + " ==> " + probe.getShortDescription());
+                }
+                Collection<Probe> probes = lineToProbesMap.get(lineLocation);
+                if (probes == null) {
+                    probes = new ArrayList<>(2);
+                    lineToProbesMap.put(lineLocation, probes);
+                } else {
+                    assert !probes.contains(probe);
+                }
+                probes.add(probe);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/tools/NodeExecCounter.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2015, 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.tools;
+
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
+import com.oracle.truffle.api.frame.*;
+import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.impl.*;
+import com.oracle.truffle.api.nodes.*;
+import com.oracle.truffle.api.nodes.Node.Child;
+
+/**
+ * A {@link TruffleTool} that counts interpreter <em>execution calls</em> to AST nodes, tabulated by
+ * the type of called nodes; counting can be enabled <em>all</em> nodes or restricted to nodes with
+ * a specified {@linkplain SyntaxTag tag} that is presumed to be applied external to the tool.
+ * <p>
+ * <b>Tool Life Cycle</b>
+ * <p>
+ * See {@link TruffleTool} for the life cycle common to all such tools.
+ * </p>
+ * <b>Execution Counts</b>
+ * <p>
+ * <ul>
+ * <li>"Execution call" on a node is is defined as invocation of a node method that is instrumented
+ * to produce the event {@link TruffleEventReceiver#enter(Node, VirtualFrame)};</li>
+ * <li>Execution calls are tabulated only at <em>instrumented</em> nodes, i.e. those for which
+ * {@linkplain Node#isInstrumentable() isInstrumentable() == true};</li>
+ * <li>Execution calls are tabulated only at nodes present in the AST when originally created;
+ * dynamically added nodes will not be instrumented.</li>
+ * </ul>
+ * </p>
+ * <b>Failure Log</b>
+ * <p>
+ * For the benefit of language implementors, the tool maintains a log describing failed attempts to
+ * probe AST nodes. Most failures occur when the type of the wrapper created by
+ * {@link Node#createWrapperNode()} is not assignable to the relevant {@link Child} field in the
+ * node's parent.
+ * </p>
+ * <p>
+ * {@linkplain #reset() Resetting} the counts has no effect on the failure log.
+ * </p>
+ * <b>Results</b>
+ * <p>
+ * A modification-safe copy of the {@linkplain #getCounts() counts} can be retrieved at any time,
+ * without effect on the state of the tool.
+ * </p>
+ * <p>
+ * A "default" {@linkplain #print(PrintStream) print()} method can summarizes the current counts at
+ * any time in a simple textual format, without effect on the state of the tool.
+ * </p>
+ *
+ * @see Instrument
+ * @see SyntaxTag
+ * @see ProbeFailure
+ */
+public final class NodeExecCounter extends TruffleTool {
+
+    /**
+     * Execution count for AST nodes of a particular type.
+     */
+    public interface NodeExecutionCount {
+        Class<?> nodeClass();
+
+        long executionCount();
+    }
+
+    /**
+     * Receiver for events at instrumented nodes. Counts are maintained in a shared table, so the
+     * receiver is stateless and can be shared by every {@link Instrument}.
+     */
+    private final TruffleEventReceiver eventReceiver = new DefaultEventReceiver() {
+        @Override
+        @TruffleBoundary
+        public void enter(Node node, VirtualFrame frame) {
+            if (isEnabled()) {
+                final Class<?> nodeClass = node.getClass();
+                AtomicLong nodeCounter = counters.get(nodeClass);
+                if (nodeCounter == null) {
+                    nodeCounter = new AtomicLong();
+                    counters.put(nodeClass, nodeCounter);
+                }
+                nodeCounter.getAndIncrement();
+            }
+        }
+    };
+
+    /** Counting data. */
+    private final Map<Class<?>, AtomicLong> counters = new HashMap<>();
+
+    /** Failure log. */
+    private final List<ProbeFailure> failures = new ArrayList<>();
+
+    /** For disposal. */
+    private final List<Instrument> instruments = new ArrayList<>();
+
+    /**
+     * If non-null, counting is restricted to nodes holding this tag.
+     */
+    private final SyntaxTag countingTag;
+
+    /**
+     * Prober used only when instrumenting every node.
+     */
+    private ASTProber astProber;
+
+    /**
+     * Listener used only when restricting counting to a specific tag.
+     */
+    private ProbeListener probeListener;
+
+    /**
+     * Create a per node-type execution counting tool for all nodes in subsequently created ASTs.
+     */
+    public NodeExecCounter() {
+        this.countingTag = null;
+    }
+
+    /**
+     * Creates a per-type execution counting for nodes tagged as specified in subsequently created
+     * ASTs.
+     */
+    public NodeExecCounter(SyntaxTag tag) {
+        this.countingTag = tag;
+    }
+
+    @Override
+    protected boolean internalInstall() {
+        if (countingTag == null) {
+            astProber = new ExecCounterASTProber();
+            Probe.registerASTProber(astProber);
+        } else {
+            probeListener = new NodeExecCounterProbeListener();
+            Probe.addProbeListener(probeListener);
+        }
+        return true;
+    }
+
+    @Override
+    protected void internalReset() {
+        counters.clear();
+        failures.clear();
+    }
+
+    @Override
+    protected void internalDispose() {
+        if (astProber != null) {
+            Probe.unregisterASTProber(astProber);
+        }
+        if (probeListener != null) {
+            Probe.removeProbeListener(probeListener);
+        }
+        for (Instrument instrument : instruments) {
+            instrument.dispose();
+        }
+    }
+
+    /**
+     * Gets a modification-safe summary of the current per-type node execution counts; does not
+     * affect the counts.
+     */
+    public NodeExecutionCount[] getCounts() {
+        final Collection<Map.Entry<Class<?>, AtomicLong>> entrySet = counters.entrySet();
+        final NodeExecutionCount[] result = new NodeExecCountImpl[entrySet.size()];
+        int i = 0;
+        for (Map.Entry<Class<?>, AtomicLong> entry : entrySet) {
+            result[i++] = new NodeExecCountImpl(entry.getKey(), entry.getValue().longValue());
+        }
+        return result;
+    }
+
+    /**
+     * Gets a log containing a report of every failed attempt to instrument a node.
+     */
+    public ProbeFailure[] getFailures() {
+        return failures.toArray(new ProbeFailure[failures.size()]);
+    }
+
+    /**
+     * A default printer for the current counts, producing lines of the form
+     * " <count> : <node type>" in descending order of count.
+     */
+    public void print(PrintStream out) {
+        print(out, false);
+    }
+
+    /**
+     * A default printer for the current counts, producing lines of the form
+     * " <count> : <node type>" in descending order of count.
+     *
+     * @param out
+     * @param verbose whether to describe nodes on which instrumentation failed
+     */
+    public void print(PrintStream out, boolean verbose) {
+
+        final long missedNodes = failures.size();
+        out.println();
+        if (countingTag == null) {
+            out.println("Execution counts by node type:");
+        } else {
+            out.println("\"" + countingTag.name() + "\"-tagged execution counts by node type:");
+        }
+        final StringBuilder disclaim = new StringBuilder("(");
+        if (missedNodes > 0) {
+            disclaim.append(Long.toString(missedNodes) + " original AST nodes not instrumented, ");
+        }
+        disclaim.append("dynamically added nodes not instrumented)");
+        out.println(disclaim.toString());
+        NodeExecutionCount[] execCounts = getCounts();
+        // Sort in descending order
+        Arrays.sort(execCounts, new Comparator<NodeExecutionCount>() {
+
+            public int compare(NodeExecutionCount o1, NodeExecutionCount o2) {
+                return Long.compare(o2.executionCount(), o1.executionCount());
+            }
+
+        });
+        for (NodeExecutionCount nodeCount : execCounts) {
+            out.format("%12d", nodeCount.executionCount());
+            out.println(" : " + nodeCount.nodeClass().getName());
+        }
+
+        if (verbose && missedNodes > 0) {
+            out.println("Instrumentation failures for execution counts:");
+
+            for (ProbeFailure failure : failures) {
+                out.println("\t" + failure.getMessage());
+            }
+        }
+    }
+
+    /**
+     * A prober that attempts to probe and instrument every node.
+     */
+    private class ExecCounterASTProber implements ASTProber, NodeVisitor {
+
+        public boolean visit(Node node) {
+
+            if (node.isInstrumentable()) {
+                try {
+                    final Instrument instrument = Instrument.create(eventReceiver, "NodeExecCounter");
+                    instruments.add(instrument);
+                    node.probe().attach(instrument);
+                } catch (ProbeException ex) {
+                    failures.add(ex.getFailure());
+                }
+            }
+            return true;
+        }
+
+        public void probeAST(Node node) {
+            node.accept(this);
+        }
+    }
+
+    /**
+     * A listener that assumes ASTs have been tagged external to this tool, and which instruments
+     * nodes holding a specified tag.
+     */
+    private class NodeExecCounterProbeListener extends DefaultProbeListener {
+
+        @Override
+        public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
+            if (countingTag == tag) {
+                final Instrument instrument = Instrument.create(eventReceiver, NodeExecCounter.class.getSimpleName());
+                instruments.add(instrument);
+                probe.attach(instrument);
+            }
+        }
+    }
+
+    private static class NodeExecCountImpl implements NodeExecutionCount {
+
+        private final Class<?> nodeClass;
+        private final long count;
+
+        public NodeExecCountImpl(Class<?> nodeClass, long count) {
+            this.nodeClass = nodeClass;
+            this.count = count;
+        }
+
+        public Class<?> nodeClass() {
+            return nodeClass;
+        }
+
+        public long executionCount() {
+            return count;
+        }
+    }
+}
--- a/graal/com.oracle.truffle.dsl.processor/src/META-INF/services/javax.annotation.processing.Processor	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/META-INF/services/javax.annotation.processing.Processor	Wed Jan 28 19:32:47 2015 +0100
@@ -1,1 +1,2 @@
 com.oracle.truffle.dsl.processor.TruffleProcessor
+com.oracle.truffle.dsl.processor.verify.VerifyTruffleProcessor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java	Wed Jan 28 19:32:47 2015 +0100
@@ -0,0 +1,137 @@
+/*
+ * 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.truffle.dsl.processor.verify;
+
+import static com.oracle.truffle.dsl.processor.java.ElementUtils.*;
+import static java.util.Collections.*;
+
+import java.io.*;
+import java.util.*;
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic.Kind;
+
+import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
+
+@SupportedSourceVersion(SourceVersion.RELEASE_7)
+@SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary"})
+public class VerifyTruffleProcessor extends AbstractProcessor {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    /**
+     * Node class currently being processed.
+     */
+    private Element scope;
+
+    public static boolean isEnclosedIn(Element e, Element scopeElement) {
+        List<Element> elementHierarchy = getElementHierarchy(e);
+        return elementHierarchy.contains(scopeElement);
+    }
+
+    void errorMessage(Element element, String format, Object... args) {
+        message(Kind.ERROR, element, format, args);
+    }
+
+    void message(Kind kind, Element element, String format, Object... args) {
+        if (scope != null && !isEnclosedIn(element, scope)) {
+            // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=428357#c1
+            List<Element> elementHierarchy = getElementHierarchy(element);
+            reverse(elementHierarchy);
+
+            StringBuilder str = new StringBuilder();
+            for (Element e : elementHierarchy) {
+                if (e.getKind() != ElementKind.PACKAGE) {
+                    str.append(str.length() == 0 ? "" : ".");
+                    str.append(e);
+                }
+            }
+            processingEnv.getMessager().printMessage(kind, String.format(str + ": " + format, args), scope);
+        } else {
+            processingEnv.getMessager().printMessage(kind, String.format(format, args), element);
+        }
+    }
+
+    /**
+     * Bugs in an annotation processor can cause silent failure so try to report any exception
+     * throws as errors.
+     */
+    private void reportException(Kind kind, Element element, Throwable t) {
+        StringWriter buf = new StringWriter();
+        t.printStackTrace(new PrintWriter(buf));
+        buf.toString();
+        message(kind, element, "Exception thrown during processing: %s", buf.toString());
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver()) {
+            return false;
+        }
+
+        TypeElement virtualFrameType = processingEnv.getElementUtils().getTypeElement("com.oracle.truffle.api.frame.VirtualFrame");
+
+        for (Element element : roundEnv.getElementsAnnotatedWith(TruffleBoundary.class)) {
+            scope = element;
+            try {
+                ExecutableElement method = (ExecutableElement) element;
+
+                for (VariableElement parameter : method.getParameters()) {
+                    Element paramType = processingEnv.getTypeUtils().asElement(parameter.asType());
+                    if (paramType != null && paramType.equals(virtualFrameType)) {
+                        errorMessage(element, "Method %s cannot be annotated with @%s and have a parameter of type %s", method.getSimpleName(), TruffleBoundary.class.getSimpleName(),
+                                        paramType.getSimpleName());
+                    }
+                }
+            } catch (Throwable t) {
+                reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t);
+            } finally {
+                scope = null;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Determines if a given exception is (most likely) caused by <a
+     * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>.
+     */
+    public static boolean isBug367599(Throwable t) {
+        if (t instanceof FilerException) {
+            for (StackTraceElement ste : t.getStackTrace()) {
+                if (ste.toString().contains("org.eclipse.jdt.internal.apt.pluggable.core.filer.IdeFilerImpl.create")) {
+                    // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599
+                    return true;
+                }
+            }
+        }
+        if (t.getCause() != null) {
+            return isBug367599(t.getCause());
+        }
+        return false;
+    }
+}
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLMain.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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,17 +24,21 @@
 
 import java.io.*;
 import java.math.*;
+import java.util.Scanner;
 
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.dsl.*;
+import com.oracle.truffle.api.instrument.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
+import com.oracle.truffle.api.tools.*;
 import com.oracle.truffle.sl.builtins.*;
 import com.oracle.truffle.sl.factory.*;
 import com.oracle.truffle.sl.nodes.*;
 import com.oracle.truffle.sl.nodes.call.*;
 import com.oracle.truffle.sl.nodes.controlflow.*;
 import com.oracle.truffle.sl.nodes.expression.*;
+import com.oracle.truffle.sl.nodes.instrument.*;
 import com.oracle.truffle.sl.nodes.local.*;
 import com.oracle.truffle.sl.parser.*;
 import com.oracle.truffle.sl.runtime.*;
@@ -111,9 +115,29 @@
  * argument and adds them to the function registry. Functions that are already defined are replaced
  * with the new version.
  * </ul>
+ *
+ * <p>
+ * <b>Tools:</b><br>
+ * The use of some of Truffle's support for developer tools (based on the Truffle Instrumentation
+ * Framework) are demonstrated in this file, for example:
+ * <ul>
+ * <li>a {@linkplain NodeExecCounter counter for node executions}, tabulated by node type; and</li>
+ * <li>a simple {@linkplain CoverageTracker code coverage engine}.</li>
+ * </ul>
+ * In each case, the tool is enabled if a corresponding local boolean variable in this file is set
+ * to {@code true}. Results are printed at the end of the execution using each tool's
+ * <em>default printer</em>.
+ *
  */
 public class SLMain {
 
+    /* Demonstrate per-type tabulation of node execution counts */
+    private static boolean nodeExecCounts = false;
+    /* Demonstrate per-line tabulation of STATEMENT node execution counts */
+    private static boolean statementCounts = false;
+    /* Demonstrate per-line tabulation of STATEMENT coverage */
+    private static boolean coverage = false;
+
     /**
      * The main entry point. Use the mx command "mx sl" to run it with the correct class path setup.
      */
@@ -140,12 +164,34 @@
      * Parse and run the specified SL source. Factored out in a separate method so that it can also
      * be used by the unit test harness.
      */
-    public static void run(SLContext context, Source source, PrintStream logOutput, int repeats) {
+    public static long run(SLContext context, Source source, PrintStream logOutput, int repeats) {
         if (logOutput != null) {
             logOutput.println("== running on " + Truffle.getRuntime().getName());
             // logOutput.println("Source = " + source.getCode());
         }
 
+        if (statementCounts || coverage) {
+            Probe.registerASTProber(new SLStandardASTProber());
+        }
+
+        NodeExecCounter nodeExecCounter = null;
+        if (nodeExecCounts) {
+            nodeExecCounter = new NodeExecCounter();
+            nodeExecCounter.install();
+        }
+
+        NodeExecCounter statementExecCounter = null;
+        if (statementCounts) {
+            statementExecCounter = new NodeExecCounter(StandardSyntaxTag.STATEMENT);
+            statementExecCounter.install();
+        }
+
+        CoverageTracker coverageTracker = null;
+        if (coverage) {
+            coverageTracker = new CoverageTracker();
+            coverageTracker.install();
+        }
+
         /* Parse the SL source file. */
         Parser.parseSL(context, source);
 
@@ -163,6 +209,7 @@
         boolean dumpASTToIGV = false;
 
         printScript("before execution", context, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV);
+        long totalRuntime = 0;
         try {
             for (int i = 0; i < repeats; i++) {
                 long start = System.nanoTime();
@@ -176,6 +223,7 @@
                     context.getOutput().println(formatTypeError(ex));
                 }
                 long end = System.nanoTime();
+                totalRuntime += end - start;
 
                 if (logOutput != null && repeats > 1) {
                     logOutput.println("== iteration " + (i + 1) + ": " + ((end - start) / 1000000) + " ms");
@@ -185,7 +233,19 @@
         } finally {
             printScript("after execution", context, logOutput, printASTToLog, printSourceAttributionToLog, dumpASTToIGV);
         }
-        return;
+        if (nodeExecCounter != null) {
+            nodeExecCounter.print(System.out);
+            nodeExecCounter.dispose();
+        }
+        if (statementExecCounter != null) {
+            statementExecCounter.print(System.out);
+            statementExecCounter.dispose();
+        }
+        if (coverageTracker != null) {
+            coverageTracker.print(System.out);
+            coverageTracker.dispose();
+        }
+        return totalRuntime;
     }
 
     /**
@@ -280,4 +340,5 @@
         }
         return result.toString();
     }
+
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLExpressionNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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,7 +26,7 @@
 
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.instrument.*;
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.sl.nodes.instrument.*;
@@ -91,43 +91,13 @@
     }
 
     @Override
-    public Probe probe() {
-        Node parent = getParent();
-
-        if (parent == null) {
-            throw new IllegalStateException("Cannot call probe() a node without a parent.");
-        }
-
-        if (parent instanceof SLExpressionWrapperNode) {
-            return ((SLExpressionWrapperNode) parent).getProbe();
-        }
-
-        // Create a new wrapper/probe with this node as its child.
-        final SLExpressionWrapperNode wrapper = new SLExpressionWrapperNode(this);
-
-        // Connect it to a Probe
-        final Probe probe = ProbeNode.insertProbe(wrapper);
-
-        // Replace this node in the AST with the wrapper
-        this.replace(wrapper);
-
-        return probe;
+    public boolean isInstrumentable() {
+        return true;
     }
 
     @Override
-    public void probeLite(TruffleEventReceiver eventReceiver) {
-        Node parent = getParent();
-
-        if (parent == null) {
-            throw new IllegalStateException("Cannot call probeLite() on a node without a parent.");
-        }
+    public WrapperNode createWrapperNode() {
+        return new SLExpressionWrapperNode(this);
+    }
 
-        if (parent instanceof SLExpressionWrapperNode) {
-            throw new IllegalStateException("Cannot call probeLite() on a node that already has a wrapper.");
-        }
-        final SLExpressionWrapperNode wrapper = new SLExpressionWrapperNode(this);
-        ProbeNode.insertProbeLite(wrapper, eventReceiver);
-
-        this.replace(wrapper);
-    }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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,8 +25,7 @@
 import java.io.*;
 
 import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.instrument.*;
-import com.oracle.truffle.api.instrument.ProbeNode.*;
+import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.sl.nodes.instrument.*;
@@ -37,7 +36,7 @@
  * local variables.
  */
 @NodeInfo(language = "Simple Language", description = "The abstract base node for all statements")
-public abstract class SLStatementNode extends Node implements Instrumentable {
+public abstract class SLStatementNode extends Node {
 
     public SLStatementNode(SourceSection src) {
         super(src);
@@ -86,44 +85,13 @@
     }
 
     @Override
-    public Probe probe() {
-        Node parent = getParent();
-
-        if (parent == null) {
-            throw new IllegalStateException("Cannot call probe() on a node without a parent.");
-        }
-
-        if (parent instanceof SLStatementWrapperNode) {
-            return ((SLStatementWrapperNode) parent).getProbe();
-        }
-
-        // Create a new wrapper/probe with this node as its child.
-        final SLStatementWrapperNode wrapper = new SLStatementWrapperNode(this);
-
-        // Connect it to a Probe
-        final Probe probe = ProbeNode.insertProbe(wrapper);
-
-        // Replace this node in the AST with the wrapper
-        this.replace(wrapper);
-
-        return probe;
+    public boolean isInstrumentable() {
+        return true;
     }
 
     @Override
-    public void probeLite(TruffleEventReceiver eventReceiver) {
-        Node parent = getParent();
-
-        if (parent == null) {
-            throw new IllegalStateException("Cannot call probeLite() on a node without a parent");
-        }
+    public WrapperNode createWrapperNode() {
+        return new SLStatementWrapperNode(this);
+    }
 
-        if (parent instanceof SLStatementWrapperNode) {
-            throw new IllegalStateException("Cannot call probeLite() on a node that already has a wrapper.");
-        }
-
-        final SLStatementWrapperNode wrapper = new SLStatementWrapperNode(this);
-        ProbeNode.insertProbeLite(wrapper, eventReceiver);
-
-        this.replace(wrapper);
-    }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLExpressionWrapperNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLExpressionWrapperNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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
@@ -58,6 +58,11 @@
     }
 
     @Override
+    public boolean isInstrumentable() {
+        return false;
+    }
+
+    @Override
     public SLExpressionNode getNonWrapperNode() {
         return child;
     }
@@ -133,14 +138,4 @@
     public SLNull executeNull(VirtualFrame frame) throws UnexpectedResultException {
         return SLTypesGen.expectSLNull(executeGeneric(frame));
     }
-
-    @Override
-    public Probe probe() {
-        throw new IllegalStateException("Cannot call probe() on a wrapper.");
-    }
-
-    @Override
-    public void probeLite(TruffleEventReceiver eventReceiver) {
-        throw new IllegalStateException("Cannot call probeLite() on a wrapper.");
-    }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStandardASTProber.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStandardASTProber.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, 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
@@ -44,31 +44,35 @@
      */
     public boolean visit(Node node) {
 
-        if (node instanceof SLStatementNode) {
+        if (node.isInstrumentable()) {
+
+            if (node instanceof SLStatementNode) {
 
-            // We have to distinguish between SLExpressionNode and SLStatementNode since some of the
-            // generated factories have methods that require SLExpressionNodes as parameters. Since
-            // SLExpressionNodes are a subclass of SLStatementNode, we check if something is an
-            // SLExpressionNode first.
-            if (node instanceof SLExpressionNode && node.getParent() != null) {
-                SLExpressionNode expressionNode = (SLExpressionNode) node;
-                if (expressionNode.getSourceSection() != null) {
-                    Probe probe = expressionNode.probe();
+                // Distinguish between SLExpressionNode and SLStatementNode since some of the
+                // generated factory methods that require SLExpressionNodes as parameters.
+                // Since
+                // SLExpressionNodes are a subclass of SLStatementNode, check if something is an
+                // SLExpressionNode first.
+                if (node instanceof SLExpressionNode && node.getParent() != null) {
+                    SLExpressionNode expressionNode = (SLExpressionNode) node;
+                    if (expressionNode.getSourceSection() != null) {
+                        Probe probe = expressionNode.probe();
 
-                    if (node instanceof SLWriteLocalVariableNode) {
+                        if (node instanceof SLWriteLocalVariableNode) {
+                            probe.tagAs(STATEMENT, null);
+                            probe.tagAs(ASSIGNMENT, null);
+                        }
+                    }
+                } else if (node instanceof SLStatementNode && node.getParent() != null) {
+
+                    SLStatementNode statementNode = (SLStatementNode) node;
+                    if (statementNode.getSourceSection() != null) {
+                        Probe probe = statementNode.probe();
                         probe.tagAs(STATEMENT, null);
-                        probe.tagAs(ASSIGNMENT, null);
-                    }
-                }
-            } else if (node instanceof SLStatementNode && node.getParent() != null) {
 
-                SLStatementNode statementNode = (SLStatementNode) node;
-                if (statementNode.getSourceSection() != null) {
-                    Probe probe = statementNode.probe();
-                    probe.tagAs(STATEMENT, null);
-
-                    if (node instanceof SLWhileNode) {
-                        probe.tagAs(START_LOOP, null);
+                        if (node instanceof SLWhileNode) {
+                            probe.tagAs(START_LOOP, null);
+                        }
                     }
                 }
             }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStatementWrapperNode.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLStatementWrapperNode.java	Wed Jan 28 19:32:47 2015 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, 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,6 +51,11 @@
     }
 
     @Override
+    public boolean isInstrumentable() {
+        return false;
+    }
+
+    @Override
     public SLStatementNode getNonWrapperNode() {
         return child;
     }
@@ -87,13 +92,4 @@
         }
     }
 
-    @Override
-    public Probe probe() {
-        throw new IllegalStateException("Cannot call probe() on a wrapper.");
-    }
-
-    @Override
-    public void probeLite(TruffleEventReceiver eventReceiver) {
-        throw new IllegalStateException("Cannot call probeLite() on a wrapper.");
-    }
 }
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.frame	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.frame	Wed Jan 28 19:32:47 2015 +0100
@@ -39,8 +39,8 @@
 // @formatter:off
 public class Parser {
 -->constants
-    static final boolean T = true;
-    static final boolean x = false;
+    static final boolean _T = true;
+    static final boolean _x = false;
     static final int minErrDist = 2;
 
     public Token t; // last recognized token
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Wed Jan 28 19:32:47 2015 +0100
@@ -41,8 +41,8 @@
 	public static final int _numericLiteral = 3;
 	public static final int maxT = 31;
 
-    static final boolean T = true;
-    static final boolean x = false;
+    static final boolean _T = true;
+    static final boolean _x = false;
     static final int minErrDist = 2;
 
     public Token t; // last recognized token
@@ -345,10 +345,11 @@
 		result = null;
 		if (la.kind == 1) {
 			Get();
-			result = factory.createRead(t);
 			if (la.kind == 5 || la.kind == 29 || la.kind == 30) {
-				result = MemberExpression(result, null, t);
-			}
+				result = MemberExpression(null, null, t);
+			} else if (StartOf(4)) {
+				result = factory.createRead(t);
+			} else SynErr(33);
 		} else if (la.kind == 2) {
 			Get();
 			result = factory.createStringLiteral(t);
@@ -363,18 +364,22 @@
 			Expect(7);
 			int length = (t.charPos + t.val.length()) - start;
 			result = factory.createParenExpression(expr, start, length);
-		} else SynErr(33);
+		} else SynErr(34);
 		return result;
 	}
 
-	SLExpressionNode  MemberExpression(SLExpressionNode receiver, SLExpressionNode assignmentReceiver, Token assignmentName) {
+	SLExpressionNode  MemberExpression(SLExpressionNode r, SLExpressionNode assignmentReceiver, Token assignmentName) {
 		SLExpressionNode  result;
 		result = null;
+		SLExpressionNode receiver = r;
 		Token nestedAssignmentName = null;
 		if (la.kind == 5) {
 			Get();
 			List<SLExpressionNode> parameters = new ArrayList<>();
 			SLExpressionNode parameter;
+			if (receiver == null) {
+			   receiver = factory.createRead(assignmentName);
+			}
 			if (StartOf(2)) {
 				parameter = Expression();
 				parameters.add(parameter);
@@ -399,10 +404,13 @@
 			}
 		} else if (la.kind == 30) {
 			Get();
+			if (receiver == null) {
+			   receiver = factory.createRead(assignmentName);
+			}
 			Expect(1);
 			result = factory.createReadProperty(receiver, t);
 			nestedAssignmentName = t;
-		} else SynErr(34);
+		} else SynErr(35);
 		if (la.kind == 5 || la.kind == 29 || la.kind == 30) {
 			result = MemberExpression(result, receiver, nestedAssignmentName);
 		}
@@ -421,10 +429,11 @@
     }
 
     private static final boolean[][] set = {
-		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
-		{x,T,T,T, x,T,x,x, x,x,T,x, T,T,T,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
-		{x,T,T,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
-		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,x,x,x, x,x,x,x, x}
+		{_T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x},
+		{_x,_T,_T,_T, _x,_T,_x,_x, _x,_x,_T,_x, _T,_T,_T,_x, _T,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x},
+		{_x,_T,_T,_T, _x,_T,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x},
+		{_x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_x, _x,_x,_x,_T, _T,_T,_T,_T, _T,_x,_x,_x, _x,_x,_x,_x, _x},
+		{_x,_x,_x,_x, _x,_T,_T,_T, _x,_x,_x,_T, _x,_x,_x,_x, _x,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_T, _T,_T,_T,_x, _x}
 
     };
 
@@ -501,7 +510,8 @@
 			case 31: s = "??? expected"; break;
 			case 32: s = "invalid Statement"; break;
 			case 33: s = "invalid Factor"; break;
-			case 34: s = "invalid MemberExpression"; break;
+			case 34: s = "invalid Factor"; break;
+			case 35: s = "invalid MemberExpression"; break;
             default:
                 s = "error " + n;
                 break;
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Wed Jan 28 19:12:57 2015 +0100
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/SimpleLanguage.atg	Wed Jan 28 19:32:47 2015 +0100
@@ -202,10 +202,12 @@
 Factor<out SLExpressionNode result>
 =                                               (. result = null; .)
 (
-    identifier                                  (. result = factory.createRead(t); .)
-    [
-        MemberExpression<out result, result, null, t>
-    ]
+    identifier
+    (
+        MemberExpression<out result, null, null, t>
+    |
+                                                (. result = factory.createRead(t); .)
+    )
 |
     stringLiteral                               (. result = factory.createStringLiteral(t); .)
 |
@@ -219,12 +221,16 @@
 .
 
 
-MemberExpression<out SLExpressionNode result, SLExpressionNode receiver, SLExpressionNode assignmentReceiver, Token assignmentName>
+MemberExpression<out SLExpressionNode result, SLExpressionNode r, SLExpressionNode assignmentReceiver, Token assignmentName>
 =                                               (. result = null;
+                                                   SLExpressionNode receiver = r;
                                                    Token nestedAssignmentName = null; .)
 (
     "("                                         (. List<SLExpressionNode> parameters = new ArrayList<>();
-                                                   SLExpressionNode parameter; .)
+                                                   SLExpressionNode parameter;
+                                                   if (receiver == null) {
+                                                       receiver = factory.createRead(assignmentName); 
+                                                   } .)
     [
         Expression<out parameter>               (. parameters.add(parameter); .)
         {
@@ -244,7 +250,9 @@
                                                        result = factory.createWriteProperty(assignmentReceiver, assignmentName, value);
                                                    } .)
 |
-    "."
+    "."                                         (. if (receiver == null) {
+                                                       receiver = factory.createRead(assignmentName); 
+                                                   } .)
     identifier
                                                 (. result = factory.createReadProperty(receiver, t); .)
                                                 (. nestedAssignmentName = t; .)
--- a/hotspot/.project	Wed Jan 28 19:12:57 2015 +0100
+++ b/hotspot/.project	Wed Jan 28 19:32:47 2015 +0100
@@ -111,11 +111,6 @@
 			<locationURI>PARENT-1-PROJECT_LOC/build/linux/linux_amd64_graal/generated</locationURI>
 		</link>
 		<link>
-			<name>hsail</name>
-			<type>2</type>
-			<locationURI>PARENT-1-PROJECT_LOC/src/gpu/hsail/vm</locationURI>
-		</link>
-		<link>
 			<name>linux</name>
 			<type>2</type>
 			<locationURI>PARENT-1-PROJECT_LOC/src/os/linux/vm</locationURI>
@@ -136,11 +131,6 @@
 			<locationURI>WORKSPACE_LOC/make</locationURI>
 		</link>
 		<link>
-			<name>ptx</name>
-			<type>2</type>
-			<locationURI>PARENT-1-PROJECT_LOC/src/gpu/ptx/vm</locationURI>
-		</link>
-		<link>
 			<name>sparc</name>
 			<type>2</type>
 			<locationURI>PARENT-1-PROJECT_LOC/src/cpu/sparc/vm</locationURI>
--- a/make/bsd/makefiles/buildtree.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/bsd/makefiles/buildtree.make	Wed Jan 28 19:32:47 2015 +0100
@@ -243,10 +243,6 @@
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu/ptx/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/ptx/vm)" \\; \
-	echo "$(call gamma-path,altsrc,gpu/hsail/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/hsail/vm)"; \
 	echo; \
 	echo "Src_Dirs_I = \\"; \
 	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
@@ -263,8 +259,6 @@
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
--- a/make/bsd/makefiles/vm.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/bsd/makefiles/vm.make	Wed Jan 28 19:32:47 2015 +0100
@@ -180,8 +180,6 @@
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/ptx/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/hsail/vm
 
 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
 CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
@@ -204,9 +202,7 @@
 SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
 
 GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal)
-GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/gpu/ptx/vm)
 GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal
-GRAAL_PATHS += $(HS_COMMON_SRC)/gpu/ptx/vm
 
 # Include dirs per type.
 Src_Dirs/CORE      := $(CORE_PATHS)
@@ -225,10 +221,8 @@
 
 ifneq ($(INCLUDE_GRAAL), true)
   GRAAL_SPECIFIC_FILES   := graal\*
-  GRAAL_SPECIFIC_GPU_FILES  := gpu\* ptx\* hsail\*
 else
   GRAAL_SPECIFIC_FILES   :=
-  GRAAL_SPECIFIC_GPU_FILES  :=
   Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot
 endif
 
@@ -236,12 +230,12 @@
 Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
 
 # Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
+Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
 Src_Files_EXCLUDE/GRAAL     := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
 
 Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/linux/makefiles/buildtree.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/linux/makefiles/buildtree.make	Wed Jan 28 19:32:47 2015 +0100
@@ -240,10 +240,6 @@
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu/ptx/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/ptx/vm)" \\; \
-	echo "$(call gamma-path,altsrc,gpu/hsail/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/hsail/vm)"; \
 	echo; \
 	echo "Src_Dirs_I = \\"; \
 	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
@@ -259,12 +255,6 @@
 	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu/ptx/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/ptx/vm)" \\; \
-	echo "$(call gamma-path,altsrc,gpu/hsail/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/hsail/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
--- a/make/linux/makefiles/vm.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/linux/makefiles/vm.make	Wed Jan 28 19:32:47 2015 +0100
@@ -160,8 +160,6 @@
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/ptx/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/hsail/vm
 
 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
 CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
@@ -184,11 +182,7 @@
 SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark
 
 GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal)
-GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/gpu/ptx/vm)
-GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/gpu/hsail/vm)
 GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal
-GRAAL_PATHS += $(HS_COMMON_SRC)/gpu/ptx/vm
-GRAAL_PATHS += $(HS_COMMON_SRC)/gpu/hsail/vm
 
 # Include dirs per type.
 Src_Dirs/CORE      := $(CORE_PATHS)
@@ -207,10 +201,8 @@
 
 ifneq ($(INCLUDE_GRAAL), true)
   GRAAL_SPECIFIC_FILES   := graal\* 
-  GRAAL_SPECIFIC_GPU_FILES  := gpu\* ptx\* hsail\*
 else
   GRAAL_SPECIFIC_FILES   :=
-  GRAAL_SPECIFIC_GPU_FILES   :=
   Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot
 endif
 
@@ -218,12 +210,12 @@
 Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
 
 # Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
+Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
 Src_Files_EXCLUDE/GRAAL     := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
 
 Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/solaris/makefiles/buildtree.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/solaris/makefiles/buildtree.make	Wed Jan 28 19:32:47 2015 +0100
@@ -230,10 +230,6 @@
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu/ptx/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/ptx/vm)" \\; \
-	echo "$(call gamma-path,altsrc,gpu/hsail/vm) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu/hsail/vm)"; \
 	echo; \
 	echo "Src_Dirs_I = \\"; \
 	echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \
@@ -249,8 +245,6 @@
 	echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \
 	echo "$(call gamma-path,commonsrc,os/posix/vm) \\"; \
-	echo "$(call gamma-path,altsrc,gpu) \\"; \
-	echo "$(call gamma-path,commonsrc,gpu)"; \
 	[ -n "$(CFLAGS_BROWSE)" ] && \
 	    echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \
 	[ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \
--- a/make/solaris/makefiles/vm.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/solaris/makefiles/vm.make	Wed Jan 28 19:32:47 2015 +0100
@@ -182,8 +182,6 @@
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm
 SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/ptx/vm
-SOURCE_PATHS+=$(HS_COMMON_SRC)/gpu/hsail/vm
 
 CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path))
 CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles
@@ -204,9 +202,7 @@
 COMPILER2_PATHS +=  $(GENERATED)/adfiles
 
 GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal)
-GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/gpu/ptx/vm)
 GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal
-GRAAL_PATHS += $(HS_COMMON_SRC)/gpu/ptx/vm
 
 # Include dirs per type.
 Src_Dirs/CORE      := $(CORE_PATHS)
@@ -225,10 +221,8 @@
 
 ifneq ($(INCLUDE_GRAAL), true)
   GRAAL_SPECIFIC_FILES   := graal\* 
-  GRAAL_SPECIFIC_GPU_FILES  := gpu\* ptx\* hsail\*
 else
   GRAAL_SPECIFIC_FILES   :=
-  GRAAL_SPECIFIC_GPU_FILES   :=
   Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.graal.hotspot/src_gen/hotspot
 endif
 
@@ -236,12 +230,12 @@
 Src_Files_EXCLUDE := dtrace jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp
 
 # Exclude per type.
-Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
-Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES) ciTypeFlow.cpp
-Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) $(GRAAL_SPECIFIC_GPU_FILES)
+Src_Files_EXCLUDE/CORE      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/TIERED    := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
+Src_Files_EXCLUDE/ZERO      := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp
+Src_Files_EXCLUDE/SHARK     := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES)
 Src_Files_EXCLUDE/GRAAL     := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp
 
 Src_Files_EXCLUDE +=  $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/windows/makefiles/projectcreator.make	Wed Jan 28 19:12:57 2015 +0100
+++ b/make/windows/makefiles/projectcreator.make	Wed Jan 28 19:32:47 2015 +0100
@@ -56,7 +56,6 @@
         -relativeInclude src\os\windows\vm \
         -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \
         -relativeInclude src\cpu\$(Platform_arch)\vm \
-        -relativeInclude src\gpu \
         -relativeInclude graal\com.oracle.graal.hotspot\src_gen\hotspot \
         -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \
         -relativeSrcInclude src \
--- a/mx/mx_graal.py	Wed Jan 28 19:12:57 2015 +0100
+++ b/mx/mx_graal.py	Wed Jan 28 19:32:47 2015 +0100
@@ -3,7 +3,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 #
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2015, 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,7 +26,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 
-import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, multiprocessing, StringIO, socket
+import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, StringIO, socket
 from os.path import join, exists, dirname, basename
 from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER
 from outputparser import OutputParser, ValuesMatcher
@@ -697,7 +697,7 @@
     buildVars = {
         'ALT_BOOTDIR' : 'The location of the bootstrap JDK installation (default: ' + mx.java().jdk + ')',
         'ALT_OUTPUTDIR' : 'Build directory',
-        'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(multiprocessing.cpu_count()) + ')',
+        'HOTSPOT_BUILD_JOBS' : 'Number of CPUs used by make (default: ' + str(mx.cpu_count()) + ')',
         'INSTALL' : 'Install the built VM into the JDK? (default: y)',
         'ZIP_DEBUGINFO_FILES' : 'Install zipped debug symbols file? (default: 0)',
     }
@@ -888,7 +888,7 @@
                 mx.log('Error building project')
                 return
         else:
-            cpus = multiprocessing.cpu_count()
+            cpus = mx.cpu_count()
             makeDir = join(_graal_home, 'make')
             runCmd = [mx.gmake_cmd(), '-C', makeDir]
 
@@ -1023,8 +1023,15 @@
         jacocoagent = mx.library("JACOCOAGENT", True)
         # Exclude all compiler tests and snippets
 
-        baseExcludes = ['com.oracle.graal.compiler.test', 'com.oracle.graal.jtt', 'com.oracle.graal.api.meta.test', 'com.oracle.truffle.api.test', \
-                'com.oracle.truffle.api.dsl.test', 'com.oracle.graal.truffle', 'com.oracle.graal.truffle.test', 'com.oracle.graal.compiler.hsail.test']
+        includes = ['com.oracle.graal.*']
+        baseExcludes = []
+        for p in mx.projects():
+            projsetting = getattr(p, 'jacoco', '')
+            if projsetting == 'exclude':
+                baseExcludes.append(p.name)
+            if projsetting == 'include':
+                includes.append(p.name + '.*')
+
         def _filter(l):
             # filter out specific classes which are already covered by a baseExclude package
             return [clazz for clazz in l if not any([clazz.startswith(package) for package in baseExcludes])]
@@ -1034,7 +1041,6 @@
             excludes += _filter(p.find_classes_with_matching_source_line(None, lambda line: 'JaCoCo Exclude' in line, includeInnerClasses=True).keys())
 
         excludes += [package + '.*' for package in baseExcludes]
-        includes = ['com.oracle.graal.*']
         agentOptions = {
                         'append' : 'true' if _jacoco == 'append' else 'false',
                         'bootclasspath' : 'true',
@@ -1331,6 +1337,46 @@
     args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args
     unittest(args)
 
+def microbench(args):
+    """run JMH microbenchmark projects"""
+    vmArgs, jmhArgs = _extract_VM_args(args, useDoubleDash=True)
+
+    # look for -f in JMH arguments
+    containsF = False
+    forking = True
+    for i in range(len(jmhArgs)):
+        arg = jmhArgs[i]
+        if arg.startswith('-f'):
+            containsF = True
+            if arg == '-f' and (i+1) < len(jmhArgs):
+                arg += jmhArgs[i+1]
+            try:
+                if int(arg[2:]) == 0:
+                    forking = False
+            except ValueError:
+                pass
+
+    # default to -f1 if not specified otherwise
+    if not containsF:
+        jmhArgs += ['-f1']
+
+    # find all projects with the JMH dependency
+    jmhProjects = []
+    for p in mx.projects():
+        if 'JMH' in p.deps:
+            jmhProjects.append(p.name)
+    cp = mx.classpath(jmhProjects)
+
+    # execute JMH runner
+    args = ['-cp', cp]
+    if not forking:
+        args += vmArgs
+    args += ['org.openjdk.jmh.Main']
+    if forking:
+        (_, _, jvm, _, _) = _parseVmArgs(vmArgs)
+        args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + vmArgs)]
+    vm(args + jmhArgs)
+
 def buildvms(args):
     """build one or more VMs in various configurations"""
 
@@ -1633,8 +1679,14 @@
     dacapo(['100', 'eclipse', '-esa'])
 
 def _igvFallbackJDK(env):
-    igvHomes = [h for h in mx._java_homes if h.version < mx.VersionSpec("1.8.0_20") or h.version >= mx.VersionSpec("1.8.0_40")]
-    if igvHomes[0] != mx._java_homes[0]:
+    v8u20 = mx.VersionSpec("1.8.0_20")
+    v8u40 = mx.VersionSpec("1.8.0_40")
+    v8 = mx.VersionSpec("1.8")
+    igvHomes = [h for h in mx._java_homes if h.version >= v8 and (h.version < v8u20 or h.version >= v8u40)]
+    defaultJava = mx.java()
+    if defaultJava not in igvHomes:
+        if not igvHomes:
+            mx.abort("No JDK available for building IGV. Must have JDK >= 1.8 and < 1.8.0u20 or >= 1.8.0u40 in JAVA_HOME or EXTRA_JAVA_HOMES")
         env = dict(env)
         fallbackJDK = igvHomes[0]
         mx.logv("1.8.0_20 has a known javac bug (JDK-8043926), thus falling back to " + str(fallbackJDK.version))
@@ -1643,7 +1695,8 @@
 
 def igv(args):
     """run the Ideal Graph Visualizer"""
-    with open(join(_graal_home, '.ideal_graph_visualizer.log'), 'w') as fp:
+    logFile = '.ideal_graph_visualizer.log'
+    with open(join(_graal_home, logFile), 'w') as fp:
         # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
         env = dict(os.environ)
         proxy = os.environ.get('http_proxy')
@@ -1673,7 +1726,10 @@
 
         if not exists(nbplatform):
             mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]')
-        mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env)
+        # make the jar for Batik 1.7 available.
+        env['IGV_BATIK_JAR'] = mx.library('BATIK').get_path(True)
+        if mx.run(['ant', '-f', mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env, nonZeroIsFatal=False):
+            mx.abort("IGV ant build & launch failed. Check '" + logFile + "'. You can also try to delete 'src/share/tools/IdealGraphVisualizer/nbplatform'.")
 
 def maven_install_truffle(args):
     """install Truffle into your local Maven repository"""
@@ -2125,7 +2181,25 @@
         out = args[0]
     elif len(args) > 1:
         mx.abort('jacocoreport takes only one argument : an output directory')
-    mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + [p.dir for p in mx.projects()])
+
+    includes = ['com.oracle.graal']
+    for p in mx.projects():
+        projsetting = getattr(p, 'jacoco', '')
+        if projsetting == 'include':
+            includes.append(p.name)
+
+    includedirs = set()
+    for p in mx.projects():
+        for include in includes:
+            if include in p.dir:
+                includedirs.add(p.dir)
+
+    for i in includedirs:
+        bindir = i + '/bin'
+        if not os.path.exists(bindir):
+            os.makedirs(bindir)
+
+    mx.run_java(['-jar', jacocoreport.get_path(True), '--in', 'jacoco.exec', '--out', out] + sorted(includedirs))
 
 def sl(args):
     """run an SL program"""
@@ -2366,6 +2440,7 @@
         'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'],
         'gate' : [gate, '[-options]'],
         'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'],
+        'microbench' : [microbench, '[VM options] [-- [JMH options]]'],
         'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
         'makejmhdeps' : [makejmhdeps, ''],
         'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix],
@@ -2392,6 +2467,7 @@
         mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
         mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>')
         mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"')
+        mx.add_argument('--lldb', action='store_const', const='lldb --', dest='vm_prefix', help='alias for --vmprefix "lldb --"')
 
         commands.update({
             'export': [export, '[-options] [zipfile]'],
--- a/mx/suite.py	Wed Jan 28 19:12:57 2015 +0100
+++ b/mx/suite.py	Wed Jan 28 19:32:47 2015 +0100
@@ -169,8 +169,21 @@
         "https://search.maven.org/remotecontent?filepath=java3d/vecmath/1.3.1/vecmath-1.3.1.jar",
       ],
       "sha1" : "a0ae4f51da409fa0c20fa0ca59e6bbc9413ae71d",
+    },
+
+    "JMH" : {
+      "path" : "lib/jmh-runner-1.4.2.jar",
+      "sha1" : "f44bffaf237305512002303a306fc5ce3fa63f76",
+      "urls" : ["http://lafo.ssw.uni-linz.ac.at/jmh/jmh-runner-1.4.2.jar"],
+      "annotationProcessor" : "true"
+    },
+
+    "BATIK" : {
+      "path" : "lib/batik-all-1.7.jar",
+      "sha1" : "122b87ca88e41a415cf8b523fd3d03b4325134a3",
+      "urls" : ["http://lafo.ssw.uni-linz.ac.at/graal-external-deps/batik-all-1.7.jar"],
     }
-  },
+},
 
   "jrelibraries" : {
     "JFR" : {
@@ -246,6 +259,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "API,Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.api.code" : {
@@ -284,15 +298,6 @@
       "workingSets" : "Graal,AMD64",
     },
 
-    "com.oracle.graal.ptx" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.api.code"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,PTX",
-    },
-
     "com.oracle.graal.sparc" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -388,35 +393,6 @@
       "workingSets" : "Graal,HotSpot,SPARC",
     },
 
-    "com.oracle.graal.hotspot.ptx" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.ptx",
-        "com.oracle.graal.compiler.ptx",
-        "com.oracle.graal.hotspot",
-        "com.oracle.graal.gpu",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "annotationProcessors" : ["com.oracle.graal.service.processor"],
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,HotSpot,PTX",
-    },
-
-    "com.oracle.graal.hotspot.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.replacements.hsail",
-        "com.oracle.graal.hotspot",
-        "com.oracle.graal.gpu",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "annotationProcessors" : ["com.oracle.graal.service.processor"],
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,HotSpot,PTX",
-    },
-
     "com.oracle.graal.hotspot.server" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -575,15 +551,6 @@
       "workingSets" : "Graal,LIR,AMD64",
     },
 
-    "com.oracle.graal.lir.ptx" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.asm.ptx"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,LIR,PTX",
-    },
-
     "com.oracle.graal.lir.sparc" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -626,6 +593,7 @@
         "com.oracle.graal.service.processor",
       ],
       "workingSets" : "Graal,Replacements",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.replacements.amd64" : {
@@ -641,15 +609,6 @@
       "workingSets" : "Graal,Replacements,AMD64",
     },
 
-    "com.oracle.graal.replacements.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.compiler.hsail"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Replacements,HSAIL",
-    },
-
     "com.oracle.graal.replacements.test" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -660,6 +619,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Replacements,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.replacements.verifier" : {
@@ -737,6 +697,15 @@
       "workingSets" : "Graal,Phases",
     },
 
+    "com.oracle.graal.virtual.bench" : {
+      "subDir" : "graal",
+      "sourceDirs" : ["src"],
+      "dependencies" : ["JMH"],
+      "checkstyle" : "com.oracle.graal.graph",
+      "javaCompliance" : "1.8",
+      "workingSets" : "Graal,Bench",
+    },
+
     "com.oracle.graal.loop" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -784,30 +753,6 @@
       "workingSets" : "Graal,AMD64,Test",
     },
 
-    "com.oracle.graal.compiler.ptx" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.lir.ptx",
-        "com.oracle.graal.compiler",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,PTX",
-    },
-
-    "com.oracle.graal.compiler.ptx.test" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.hotspot.ptx",
-        "com.oracle.graal.compiler.test",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,PTX,Test",
-    },
-
     "com.oracle.graal.compiler.sparc" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -881,33 +826,11 @@
       "workingSets" : "Graal,Java",
     },
 
-    "com.oracle.graal.java.decompiler" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.java"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal",
-    },
-
-    "com.oracle.graal.java.decompiler.test" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "JUNIT",
-        "com.oracle.graal.printer",
-        "com.oracle.graal.runtime",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Test",
-    },
-
     "com.oracle.graal.printer" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "com.oracle.graal.java.decompiler",
+        "com.oracle.graal.java",
         "com.oracle.graal.compiler",
       ],
       "checkstyle" : "com.oracle.graal.graph",
@@ -940,6 +863,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.jtt" : {
@@ -952,6 +876,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.asm" : {
@@ -999,90 +924,6 @@
       "workingSets" : "Graal,Assembler,AMD64,Test",
     },
 
-    "com.oracle.graal.gpu" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.nodes"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.api.code"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.lir.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.lir",
-        "com.oracle.graal.asm.hsail",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.compiler.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.compiler",
-        "com.oracle.graal.lir.hsail",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.compiler.hsail.test.infra" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.test",
-        "com.oracle.graal.hotspot.hsail",
-        "OKRA_WITH_SIM",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.compiler.hsail.test" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.compiler.hsail.test.infra",
-        "com.oracle.graal.compiler.test",
-        "VECMATH",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.asm.hsail" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : [
-        "com.oracle.graal.hsail",
-        "OKRA",
-        "com.oracle.graal.asm",
-        "com.oracle.graal.compiler.common",
-      ],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-    },
-
-    "com.oracle.graal.asm.ptx" : {
-      "subDir" : "graal",
-      "sourceDirs" : ["src"],
-      "dependencies" : ["com.oracle.graal.lir"],
-      "checkstyle" : "com.oracle.graal.graph",
-      "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Assembler,PTX",
-    },
-
     "com.oracle.graal.asm.sparc" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
@@ -1113,6 +954,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.7",
       "workingSets" : "API,Truffle,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.truffle.api.dsl" : {
@@ -1135,6 +977,7 @@
       "javaCompliance" : "1.7",
       "annotationProcessors" : ["com.oracle.truffle.dsl.processor"],
       "workingSets" : "API,Truffle,Codegen,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.truffle.dsl.processor" : {
@@ -1219,6 +1062,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Truffle",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.truffle.test" : {
@@ -1232,6 +1076,7 @@
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Truffle,Test",
+      "jacoco" : "exclude",
     },
 
     "com.oracle.graal.truffle.hotspot" : {
@@ -1281,11 +1126,9 @@
       "sourcesPath" : "build/graal.src.zip",
       "dependencies" : [
         "com.oracle.graal.hotspot.amd64",
-        "com.oracle.graal.hotspot.ptx",
         "com.oracle.graal.hotspot.sparc",
         "com.oracle.graal.hotspot",
         "com.oracle.graal.hotspot.jfr",
-        "com.oracle.graal.hotspot.hsail",
       ],
       "exclude" : ["FINDBUGS"],
     },
--- a/mxtool/mx.py	Wed Jan 28 19:12:57 2015 +0100
+++ b/mxtool/mx.py	Wed Jan 28 19:32:47 2015 +0100
@@ -2,7 +2,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 #
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2015, 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
@@ -34,7 +34,6 @@
 """
 
 import sys, os, errno, time, subprocess, shlex, types, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch, platform
-import multiprocessing
 import textwrap
 import socket
 import tarfile
@@ -62,6 +61,22 @@
         raise error
     return output
 
+# Support for jython
+def is_jython():
+    return sys.platform.startswith('java')
+
+if not is_jython():
+    import multiprocessing
+
+def cpu_count():
+    if is_jython():
+        from java.lang import Runtime
+        runtime = Runtime.getRuntime()
+        return runtime.availableProcessors()
+    else:
+        return multiprocessing.cpu_count()
+
+
 try: subprocess.check_output
 except: subprocess.check_output = check_output
 
@@ -251,6 +266,9 @@
         self.name = name
         self.suite = suite
 
+    def __cmp__(self, other):
+        return cmp(self.name, other.name)
+
     def __str__(self):
         return self.name
 
@@ -307,7 +325,7 @@
         Add the transitive set of dependencies for this project, including
         libraries if 'includeLibs' is true, to the 'deps' list.
         """
-        return self._all_deps_helper(deps, [], includeLibs, includeSelf, includeJreLibs, includeAnnotationProcessors)
+        return sorted(self._all_deps_helper(deps, [], includeLibs, includeSelf, includeJreLibs, includeAnnotationProcessors))
 
     def _all_deps_helper(self, deps, dependants, includeLibs, includeSelf=True, includeJreLibs=False, includeAnnotationProcessors=False):
         if self in dependants:
@@ -527,7 +545,7 @@
                 # Inherit annotation processors from dependencies
                 aps.update(p.annotation_processors())
 
-            self._annotationProcessors = list(aps)
+            self._annotationProcessors = sorted(list(aps))
         return self._annotationProcessors
 
     """
@@ -536,10 +554,17 @@
     """
     def annotation_processors_path(self):
         aps = [project(ap) for ap in self.annotation_processors()]
-        if len(aps):
-            return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist])
+        libAps = [dep for dep in self.all_deps([], includeLibs=True, includeSelf=False) if dep.isLibrary() and hasattr(dep, 'annotationProcessor') and getattr(dep, 'annotationProcessor').lower() == 'true']
+        if len(aps) + len(libAps):
+            return os.pathsep.join([ap.definedAnnotationProcessorsDist.path for ap in aps if ap.definedAnnotationProcessorsDist] + [lib.get_path(False) for lib in libAps])
         return None
 
+    def uses_annotation_processor_library(self):
+        for dep in self.all_deps([], includeLibs=True, includeSelf=False):
+            if dep.isLibrary() and hasattr(dep, 'annotationProcessor'):
+                return True
+        return False
+
     def update_current_annotation_processors_file(self):
         aps = self.annotation_processors()
         outOfDate = False
@@ -589,8 +614,9 @@
         return d.hexdigest()
 
 def download_file_with_sha1(name, path, urls, sha1, sha1path, resolve, mustExist, sources=False, canSymlink=True):
+    canSymlink = canSymlink and not (get_os() == 'windows' or get_os() == 'cygwin')
     def _download_lib():
-        cacheDir = get_env('MX_CACHE_DIR', join(_opts.user_home, '.mx', 'cache'))
+        cacheDir = _cygpathW2U(get_env('MX_CACHE_DIR', join(_opts.user_home, '.mx', 'cache')))
         if not exists(cacheDir):
             os.makedirs(cacheDir)
         base = basename(path)
@@ -680,7 +706,7 @@
         """
         if includeJreLibs and includeSelf and not self in deps:
             deps.append(self)
-        return deps
+        return sorted(deps)
 
 class Library(BaseLibrary):
     def __init__(self, suite, name, path, optional, urls, sha1, sourcePath, sourceUrls, sourceSha1, deps):
@@ -753,10 +779,10 @@
         Add the transitive set of dependencies for this library to the 'deps' list.
         """
         if not includeLibs:
-            return deps
+            return sorted(deps)
         childDeps = list(self.deps)
         if self in deps:
-            return deps
+            return sorted(deps)
         for name in childDeps:
             assert name != self.name
             dep = library(name)
@@ -764,7 +790,7 @@
                 dep.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
         if not self in deps and includeSelf:
             deps.append(self)
-        return deps
+        return sorted(deps)
 
 class HgConfig:
     """
@@ -961,7 +987,7 @@
                 abort('Attribute "' + name + '" for ' + context + ' must be a list')
             return v
 
-        for name, attrs in projsMap.iteritems():
+        for name, attrs in sorted(projsMap.iteritems()):
             context = 'project ' + name
             srcDirs = pop_list(attrs, 'sourceDirs', context)
             deps = pop_list(attrs, 'dependencies', context)
@@ -983,14 +1009,14 @@
             p.__dict__.update(attrs)
             self.projects.append(p)
 
-        for name, attrs in jreLibsMap.iteritems():
+        for name, attrs in sorted(jreLibsMap.iteritems()):
             jar = attrs.pop('jar')
             # JRE libraries are optional by default
             optional = attrs.pop('optional', 'true') != 'false'
             l = JreLibrary(self, name, jar, optional)
             self.jreLibs.append(l)
 
-        for name, attrs in libsMap.iteritems():
+        for name, attrs in sorted(libsMap.iteritems()):
             context = 'library ' + name
             if "|" in name:
                 if name.count('|') != 2:
@@ -1011,7 +1037,7 @@
             l.__dict__.update(attrs)
             self.libs.append(l)
 
-        for name, attrs in distsMap.iteritems():
+        for name, attrs in sorted(distsMap.iteritems()):
             context = 'distribution ' + name
             path = attrs.pop('path')
             sourcesPath = attrs.pop('sourcesPath', None)
@@ -1289,11 +1315,29 @@
             result = result.replace('encoding="UTF-8"?>', 'encoding="UTF-8" standalone="' + str(standalone) + '"?>')
         return result
 
+def get_jython_os():
+    from java.lang import System as System
+    os_name = System.getProperty('os.name').lower()
+    if System.getProperty('isCygwin'):
+        return 'cygwin'
+    elif os_name.startswith('mac'):
+        return 'darwin'
+    elif os_name.startswith('linux'):
+        return 'linux'
+    elif os_name.startswith('sunos'):
+        return 'solaris'
+    elif os_name.startswith('win'):
+        return 'windows'
+    else:
+        abort('Unknown operating system ' + os_name)
+
 def get_os():
     """
     Get a canonical form of sys.platform.
     """
-    if sys.platform.startswith('darwin'):
+    if is_jython():
+        return get_jython_os()
+    elif sys.platform.startswith('darwin'):
         return 'darwin'
     elif sys.platform.startswith('linux'):
         return 'linux'
@@ -1313,7 +1357,7 @@
     """
     if p is None or get_os() != "cygwin":
         return p
-    return subprocess.check_output(['cygpath', '-w', p]).strip()
+    return subprocess.check_output(['cygpath', '-a', '-w', p]).strip()
 
 def _cygpathW2U(p):
     """
@@ -1322,7 +1366,7 @@
     """
     if p is None or get_os() != "cygwin":
         return p
-    return subprocess.check_output(['cygpath', '-u', p]).strip()
+    return subprocess.check_output(['cygpath', '-a', '-u', p]).strip()
 
 def _separatedCygpathU2W(p):
     """
@@ -1593,9 +1637,21 @@
         p.all_deps(deps, includeLibs=includeLibs, includeJreLibs=includeJreLibs, includeAnnotationProcessors=includeAnnotationProcessors)
     return deps
 
-def _handle_missing_java_home():
+def _handle_lookup_java_home(jdk):
+    return _handle_lookup_jdk(jdk, 'JAVA_HOME', '--java-home', False)
+
+def _handle_lookup_extra_java_homes(jdk):
+    return _handle_lookup_jdk(jdk, 'EXTRA_JAVA_HOMES', '--extra-java-homes', True)
+
+def _handle_lookup_jdk(jdk, varName, flagName, allowMultiple):
+    if jdk != None and jdk != '':
+        return jdk
+    jdk = os.environ.get(varName)
+    if jdk != None and jdk != '':
+        return jdk
+
     if not sys.stdout.isatty():
-        abort('Could not find bootstrap JDK. Use --java-home option or ensure JAVA_HOME environment variable is set.')
+        abort('Could not find bootstrap {0}. Use {1} option or ensure {2} environment variable is set.'.format(varName, flagName, varName))
 
     candidateJdks = []
     if get_os() == 'darwin':
@@ -1613,12 +1669,15 @@
 
     javaHome = None
     if len(candidateJdks) != 0:
-        javaHome = select_items(candidateJdks + ['<other>'], allowMultiple=False)
+        log('Missing value for {0}.'.format(varName))
+        javaHome = select_items(candidateJdks + ['<other>'], allowMultiple=allowMultiple)
         if javaHome == '<other>':
             javaHome = None
+        if javaHome != None and allowMultiple:
+            javaHome = os.pathsep.join(javaHome)
 
     while javaHome is None:
-        javaHome = raw_input('Enter path of bootstrap JDK: ')
+        javaHome = raw_input('Enter path of JDK for {0}: '.format(varName))
         rtJarPath = join(javaHome, 'jre', 'lib', 'rt.jar')
         if not exists(rtJarPath):
             log('Does not appear to be a valid JDK as ' + rtJarPath + ' does not exist')
@@ -1627,9 +1686,9 @@
             break
 
     envPath = join(_primary_suite.mxDir, 'env')
-    if ask_yes_no('Persist this setting by adding "JAVA_HOME=' + javaHome + '" to ' + envPath, 'y'):
+    if ask_yes_no('Persist this setting by adding "{0}={1}" to {2}'.format(varName, javaHome, envPath), 'y'):
         with open(envPath, 'a') as fp:
-            print >> fp, 'JAVA_HOME=' + javaHome
+            print >> fp, varName + '=' + javaHome
 
     return javaHome
 
@@ -1650,6 +1709,7 @@
         self.add_argument('-p', '--primary-suite-path', help='set the primary suite directory', metavar='<path>')
         self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>')
         self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"')
+        self.add_argument('--backup-modified', action='store_true', help='backup generated files if they pre-existed and are modified')
         self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>')
         self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>')
         self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>')
@@ -1683,13 +1743,8 @@
         if opts.very_verbose:
             opts.verbose = True
 
-        if opts.java_home is None:
-            opts.java_home = os.environ.get('JAVA_HOME')
-        if opts.extra_java_homes is None:
-            opts.extra_java_homes = os.environ.get('EXTRA_JAVA_HOMES')
-
-        if opts.java_home is None or opts.java_home == '':
-            opts.java_home = _handle_missing_java_home()
+        opts.java_home = _handle_lookup_java_home(opts.java_home)
+        opts.extra_java_homes = _handle_lookup_extra_java_homes(opts.extra_java_homes)
 
         if opts.user_home is None or opts.user_home == '':
             abort('Could not find user home. Use --user-home option or ensure HOME environment variable is set.')
@@ -1820,7 +1875,19 @@
         assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg)
 
     if env is None:
-        env = os.environ
+        env = os.environ.copy()
+
+    # Ideally the command line could be communicated directly in an environment
+    # variable. However, since environment variables share the same resource
+    # space as the command line itself (on Unix at least), this would cause the
+    # limit to be exceeded too easily.
+    with tempfile.NamedTemporaryFile(suffix='', prefix='mx_subprocess_command.', mode='w', delete=False) as fp:
+        subprocessCommandFile = fp.name
+        for arg in args:
+            # TODO: handle newlines in args once there's a use case
+            assert '\n' not in arg
+            print >> fp, arg
+    env['MX_SUBPROCESS_COMMAND_FILE'] = subprocessCommandFile
 
     if _opts.verbose:
         if _opts.very_verbose:
@@ -1838,11 +1905,11 @@
         # can use os.killpg() to kill the whole subprocess group
         preexec_fn = None
         creationflags = 0
-        if get_os() == 'windows':
-            creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
-        else:
-            preexec_fn = os.setsid
-
+        if not is_jython():
+            if get_os() == 'windows':
+                creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
+            else:
+                preexec_fn = os.setsid
         def redirect(stream, f):
             for line in iter(stream.readline, ''):
                 f(line)
@@ -1882,6 +1949,7 @@
         abort(1)
     finally:
         _removeSubprocess(sub)
+        os.remove(subprocessCommandFile)
 
     if retcode and nonZeroIsFatal:
         if _opts.verbose:
@@ -2070,19 +2138,31 @@
         javaSource = join(myDir, 'ClasspathDump.java')
         if not exists(join(outDir, 'ClasspathDump.class')):
             subprocess.check_call([self.javac, '-d', _cygpathU2W(outDir), _cygpathU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
-        self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', _separatedCygpathU2W(outDir), 'ClasspathDump'], stderr=subprocess.PIPE).split('|')]
+        self._bootclasspath, self._extdirs, self._endorseddirs = [x if x != 'null' else None for x in subprocess.check_output([self.java, '-cp', _cygpathU2W(outDir), 'ClasspathDump'], stderr=subprocess.PIPE).split('|')]
         if not self._bootclasspath or not self._extdirs or not self._endorseddirs:
             warn("Could not find all classpaths: boot='" + str(self._bootclasspath) + "' extdirs='" + str(self._extdirs) + "' endorseddirs='" + str(self._endorseddirs) + "'")
         self._bootclasspath = _filter_non_existant_paths(self._bootclasspath)
         self._extdirs = _filter_non_existant_paths(self._extdirs)
         self._endorseddirs = _filter_non_existant_paths(self._endorseddirs)
 
+    def __repr__(self):
+        return "JavaConfig(" + str(self.jdk) + ", " + str(self.debug_port) + ")"
+
+    def __str__(self):
+        return "Java " + str(self.version) + " (" + str(self.javaCompliance) + ") from " + str(self.jdk)
+
     def __hash__(self):
         return hash(self.jdk)
 
     def __cmp__(self, other):
         if isinstance(other, JavaConfig):
-            return cmp(self.javaCompliance, other.javaCompliance)
+            compilanceCmp = cmp(self.javaCompliance, other.javaCompliance)
+            if compilanceCmp:
+                return compilanceCmp
+            versionCmp = cmp(self.version, other.version)
+            if versionCmp:
+                return versionCmp
+            return cmp(self.jdk, other.jdk)
         raise TypeError()
 
     def format_cmd(self, args, addDefaultArgs):
@@ -2218,7 +2298,7 @@
     def is_alive(p):
         if isinstance(p, subprocess.Popen):
             return p.poll() is None
-        assert isinstance(p, multiprocessing.Process), p
+        assert is_jython() or isinstance(p, multiprocessing.Process), p
         return p.is_alive()
 
     for p, args in _currentSubprocesses:
@@ -2278,6 +2358,9 @@
         if old == content:
             return False
 
+        if existed and _opts.backup_modified:
+            shutil.move(path, path + '.orig')
+
         with open(path, 'wb') as f:
             f.write(content)
 
@@ -2381,7 +2464,10 @@
                     with open(jdtProperties) as fp:
                         origContent = fp.read()
                         content = origContent
-                        if args.jdt_warning_as_error:
+                        if self.proj.uses_annotation_processor_library():
+                            # unfortunately, the command line compiler doesn't let us ignore warnings for generated files only
+                            content = content.replace('=warning', '=ignore')
+                        elif 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'
@@ -2424,7 +2510,7 @@
     parser = parser if parser is not None else ArgumentParser(prog='mx build')
     parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)')
     parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output')
-    parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation')
+    parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation if possible')
     parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one')
     parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
     parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)')
@@ -2444,6 +2530,11 @@
 
     args = parser.parse_args(args)
 
+    if is_jython():
+        if args.parallelize:
+            logv('[multiprocessing not available in jython]')
+            args.parallelize = False
+
     jdtJar = None
     if not args.javac and args.jdt is not None:
         if not args.jdt.endswith('.jar'):
@@ -2600,7 +2691,7 @@
                 t._d = None
             return sorted(tasks, compareTasks)
 
-        cpus = multiprocessing.cpu_count()
+        cpus = cpu_count()
         worklist = sortWorklist(tasks.values())
         active = []
         failed = []
@@ -3523,11 +3614,19 @@
             os.mkdir(srcDir)
         out.element('classpathentry', {'kind' : 'src', 'path' : src})
 
-    if len(p.annotation_processors()) > 0:
+    processorPath = p.annotation_processors_path()
+    if processorPath:
         genDir = p.source_gen_dir()
         if not exists(genDir):
             os.mkdir(genDir)
-        out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
+        out.open('classpathentry', {'kind' : 'src', 'path' : 'src_gen'})
+        if p.uses_annotation_processor_library():
+            # ignore warnings produced by third-party annotation processors
+            out.open('attributes')
+            out.element('attribute', {'name' : 'ignore_optional_problems', 'value' : 'true'})
+            out.close('attributes')
+        out.close('classpathentry')
+
         if files:
             files.append(genDir)
 
@@ -3554,10 +3653,10 @@
         elif dep.isProject():
             projectDeps.add(dep)
 
-    for dep in containerDeps:
+    for dep in sorted(containerDeps):
         out.element('classpathentry', {'exported' : 'true', 'kind' : 'con', 'path' : dep})
 
-    for dep in libraryDeps:
+    for dep in sorted(libraryDeps):
         path = dep.path
         dep.get_path(resolve=True)
 
@@ -3575,7 +3674,7 @@
         if libFiles:
             libFiles.append(path)
 
-    for dep in projectDeps:
+    for dep in sorted(projectDeps):
         out.element('classpathentry', {'combineaccessrules' : 'false', 'exported' : 'true', 'kind' : 'src', 'path' : '/' + dep.name})
 
     out.element('classpathentry', {'kind' : 'output', 'path' : getattr(p, 'eclipse.output', 'bin')})
@@ -3707,19 +3806,18 @@
     # copy a possibly modified file to the project's .settings directory
     for name, path in esdict.iteritems():
         # ignore this file altogether if this project has no annotation processors
-        if name == "org.eclipse.jdt.apt.core.prefs" and not len(p.annotation_processors()) > 0:
+        if name == "org.eclipse.jdt.apt.core.prefs" and not processorPath:
             continue
 
         with open(path) as f:
             content = f.read()
         content = content.replace('${javaCompliance}', str(p.javaCompliance))
-        if len(p.annotation_processors()) > 0:
+        if processorPath:
             content = content.replace('org.eclipse.jdt.core.compiler.processAnnotations=disabled', 'org.eclipse.jdt.core.compiler.processAnnotations=enabled')
         update_file(join(settingsDir, name), content)
         if files:
             files.append(join(settingsDir, name))
 
-    processorPath = p.annotation_processors_path()
     if processorPath:
         out = XMLDoc()
         out.open('factorypath')
@@ -4451,7 +4549,7 @@
 
     if annotationProcessorProfiles:
         compilerXml.open('annotationProcessing')
-        for processors, modules in annotationProcessorProfiles.items():
+        for processors, modules in sorted(annotationProcessorProfiles.iteritems()):
             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'})
@@ -5226,11 +5324,12 @@
     c, _ = _commands[command][:2]
     def term_handler(signum, frame):
         abort(1)
-    signal.signal(signal.SIGTERM, term_handler)
+    if not is_jython():
+        signal.signal(signal.SIGTERM, term_handler)
 
     def quit_handler(signum, frame):
         _send_sigquit()
-    if get_os() != 'windows':
+    if not is_jython() and get_os() != 'windows':
         signal.signal(signal.SIGQUIT, quit_handler)
 
     try:
--- a/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -630,7 +630,8 @@
 
 inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) {
   relocate(a.rspec(offset));
-  ldf(w, a.base(), a.disp() + offset, d);
+  if(a.has_index()) { assert(offset == 0, ""); ldf(w, a.base(), a.index(), d); }
+  else              { ldf(w, a.base(), a.disp() + offset, d); }
 }
 
 // returns if membar generates anything, obviously this code should mirror
--- a/src/cpu/x86/vm/frame_x86.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/cpu/x86/vm/frame_x86.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -704,8 +704,8 @@
     for (int i = 0; i < entry_frame_after_call_words; i++) {
       values.describe(frame_no, fp() - i, err_msg("call_stub word fp - %d", i));
     }
+#endif // AMD64
   }
-#endif // AMD64
 }
 #endif // !PRODUCT
 
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -717,7 +717,7 @@
                                     const BasicType *sig_bt,
                                     const VMRegPair *regs
                                     int frame_extension_argument) {
-  assert(frame_extension_arguments == -1, "unsupported");
+  assert(frame_extension_argument == -1, "unsupported");
 
   // Note: rsi contains the senderSP on entry. We must preserve it since
   // we may do a i2c -> c2i transition if we lose a race where compiled
--- a/src/gpu/hsail/vm/gpu_hsail.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,481 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/javaCalls.hpp"
-#include "runtime/gpu.hpp"
-#include "runtime/deoptimization.hpp"
-#include "gpu_hsail.hpp"
-#include "utilities/debug.hpp"
-#include "utilities/exceptions.hpp"
-#include "hsail/vm/gpu_hsail.hpp"
-#include "utilities/globalDefinitions.hpp"
-#include "utilities/ostream.hpp"
-#include "graal/graalEnv.hpp"
-#include "graal/graalRuntime.hpp"
-#include "graal/graalJavaAccess.hpp"
-#include "hsailKernelArguments.hpp"
-#include "hsailJavaCallArguments.hpp"
-#include "code/pcDesc.hpp"
-#include "code/scopeDesc.hpp"
-#include "gpu_hsail_Frame.hpp"
-
-// Entry to GPU native method implementation that transitions current thread to '_thread_in_vm'.
-#define GPU_VMENTRY(result_type, name, signature) \
-  JNIEXPORT result_type JNICALL name signature { \
-  GRAAL_VM_ENTRY_MARK; \
-
-// Entry to GPU native method implementation that calls a JNI function
-// and hence cannot transition current thread to '_thread_in_vm'.
-#define GPU_ENTRY(result_type, name, signature) \
-  JNIEXPORT result_type JNICALL name signature { \
-
-#define GPU_END }
-
-#define CC (char*)  /*cast a literal from (const char*)*/
-#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f))
-
-#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;"
-
-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"II[I)Z",  FN_PTR(Hsail::execute_kernel_void_1d)},
-};
-
-void* Hsail::_device_context = NULL;
-jint  Hsail::_notice_safepoints = false;
-
-Hsail::okra_get_context_func_t     Hsail::_okra_get_context;
-Hsail::okra_create_kernel_func_t   Hsail::_okra_create_kernel;
-Hsail::okra_push_pointer_func_t    Hsail::_okra_push_pointer;
-Hsail::okra_push_boolean_func_t    Hsail::_okra_push_boolean;
-Hsail::okra_push_byte_func_t       Hsail::_okra_push_byte;
-Hsail::okra_push_double_func_t     Hsail::_okra_push_double;
-Hsail::okra_push_float_func_t      Hsail::_okra_push_float;
-Hsail::okra_push_int_func_t        Hsail::_okra_push_int;
-Hsail::okra_push_long_func_t       Hsail::_okra_push_long;
-Hsail::okra_execute_kernel_func_t  Hsail::_okra_execute_kernel;
-Hsail::okra_clear_args_func_t      Hsail::_okra_clear_args;
-Hsail::okra_dispose_kernel_func_t  Hsail::_okra_dispose_kernel;
-Hsail::okra_dispose_context_func_t Hsail::_okra_dispose_context;
-
-//static jint in_kernel = 0;
-
-void Hsail::notice_safepoints() {
-  _notice_safepoints = true;
-//  if (TraceGPUInteraction) {
-//    tty->print_cr("[HSAIL] Notice safepoint in_kernel=%d", in_kernel);
-//  }
-}
-
-void Hsail::ignore_safepoints() {
-  _notice_safepoints = false;
-}
-
-GPU_VMENTRY(jboolean, Hsail::execute_kernel_void_1d, (JNIEnv* env, jclass, jobject kernel_handle, jint dimX, jobject args,
-                                                      jint num_tlabs, jint allocBytesPerWorkitem, jobject oop_map_array))
-
-  ResourceMark rm;
-  jlong nmethodValue = InstalledCode::address(kernel_handle);
-  if (nmethodValue == 0) {
-    SharedRuntime::throw_and_post_jvmti_exception(JavaThread::current(), vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException(), NULL);
-  }
-  nmethod* nm = (nmethod*) (address) nmethodValue;
-  methodHandle mh = nm->method();
-  Symbol* signature = mh->signature();
-
-  void* kernel = (void*) HotSpotInstalledCode::codeStart(kernel_handle);
-  if (kernel == NULL) {
-    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, mh, nm, num_tlabs, allocBytesPerWorkitem, oop_map_array, CHECK_0);
-GPU_END
-
-static void showRanges(jboolean* a, int len) {
-  // show ranges
-  bool lookFor = true;
-  for (int i = 0; i < len; i++) {
-    if ((lookFor == true) && (a[i] != 0)) {
-      tty->print("%d", i);
-      lookFor = false;
-    } else if ((lookFor == false) && (a[i] == 0)) {
-      tty->print_cr("-%d", i-1);
-      lookFor = true;
-    }
-  }
-  if (lookFor == false) {
-    tty->print_cr("-%d", len-1);
-  }
-}
-
-jboolean Hsail::execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod* nm,
-                                                jint num_tlabs, int allocBytesPerWorkitem, jobject oop_map_array, TRAPS) {
-  ResourceMark rm(THREAD);
-  objArrayOop argsArray = (objArrayOop) JNIHandles::resolve(args);
-  // Note this length does not include the iteration variable since it is replaced by the HSA workitemid
-  int argsArrayLength = argsArray->length();
-  assert(THREAD->is_Java_thread(), "must be a JavaThread");
-
-  // We avoid HSAILAllocationInfo logic if kernel does not allocate
-  // in which case the num_tlabs passed in will be 0
-  HSAILAllocationInfo* allocInfo = (num_tlabs == 0 ?  NULL : new HSAILAllocationInfo(num_tlabs, dimX, allocBytesPerWorkitem));
-
-  // Reset the kernel arguments
-  _okra_clear_args(kernel);
-
-  JavaThread* thread = (JavaThread*)THREAD;
-  HSAILDeoptimizationInfo* e;
-  if (UseHSAILDeoptimization) {
-    // get how many bytes per deopt save area are required
-    int saveAreaCounts = HSAILOopMapHelper::get_save_area_counts(oop_map_array);
-    int numSRegs = saveAreaCounts & 0xff;
-    int numDRegs = (saveAreaCounts >> 8) & 0xff;
-    int numStackSlots = (saveAreaCounts >> 16);
-    int bytesPerSaveArea = numSRegs * 4 + (numDRegs + numStackSlots) * 8;
-
-    e = new (MAX_DEOPT_SLOTS, bytesPerSaveArea) HSAILDeoptimizationInfo(MAX_DEOPT_SLOTS, bytesPerSaveArea, dimX, allocInfo, oop_map_array);
-    // copy cur_tlab_infos
-    if (allocInfo != NULL) {
-      e->set_cur_tlabInfos(allocInfo->getCurTlabInfos());
-    }
-    // set deopt info in thread so gc oops_do processing can find it
-    thread->set_gpu_hsail_deopt_info(e);
-  }
-
-  // This object sets up the kernel arguments
-  HSAILKernelArguments hka((address) kernel, mh->signature(), argsArray, mh->is_static(), e);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] range=%d", dimX);
-  }
-
-  // If any object passed was null, throw an exception here. Doing this
-  // means the kernel code can avoid null checks on the object parameters.
-  if (hka.getFirstNullParameterIndex() >= 0) {
-    char buf[64];
-    sprintf(buf, "Null Kernel Parameter seen, Parameter Index: %d", hka.getFirstNullParameterIndex());
-    thread->set_gpu_exception_bci(0);
-    thread->set_gpu_exception_method(mh());
-    THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), buf);
-  }
-
-  // Run the kernel
-  jboolean success = false;
-  {
-    TraceTime t("execute kernel", TraceGPUInteraction);
-    graal_okra_range_t kernel_range = {0};
-
-    //in_kernel = 1;
-    // Run the kernel
-    kernel_range.dimension = 1;
-    kernel_range.global_size[0] = dimX;
-    success = _okra_execute_kernel(_device_context, kernel, &kernel_range);
-    //in_kernel = 0;
-  }
-
-  // avoid HSAILAllocationInfo logic if kernel does not allocate
-  if (allocInfo != NULL) {
-    allocInfo->postKernelCleanup();
-  }
-
-  if (UseHSAILDeoptimization) {
-    // check if any workitem requested a deopt
-    int deoptcode = e->deopt_occurred();
-    if (deoptcode != 1) {
-      if (deoptcode == 0) {
-        if (TraceGPUInteraction && _notice_safepoints != 0) {
-          tty->print_cr("[HSAIL] observed safepoint during kernel");
-        }
-      } else {
-        // 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);
-      }
-    } else {
-      {
-        TraceTime t3("handle deoptimizing workitems", TraceGPUInteraction);
-        if (TraceGPUInteraction) {
-          tty->print_cr("deopt happened.");
-          HSAILKernelDeoptimization* pdeopt = e->get_deopt_save_state(0);
-          tty->print_cr("first deopter was workitem %d", pdeopt->workitem());
-        }
-
-        // Handle any deopting workitems.
-        int count_deoptimized = 0;
-        for (int k = 0; k < e->num_deopts(); k++) {
-          HSAILKernelDeoptimization* pdeopt = e->get_deopt_save_state(k);
-
-          jint workitem = pdeopt->workitem();
-          if (workitem != -1) {
-            int deoptId = pdeopt->pc_offset();
-            HSAILFrame* hsailFrame = pdeopt->first_frame();
-
-            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);
-            javaArgs.push_int(mh->size_of_parameters());
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] Deoptimizing to host for workitem=%d (slot=%d) with deoptId=%d, frame=" INTPTR_FORMAT ", actionAndReason=%d", workitem, k, deoptId, p2i(hsailFrame), myActionReason);
-              // show the $d registers or stack slots containing references
-              int maxOopBits = hsailFrame->num_d_regs() + hsailFrame->num_stack_slots();
-              HSAILOopMapHelper oopMapHelper(oop_map_array);
-              int pc_offset = hsailFrame->pc_offset();
-              for (int bit = 0; bit < maxOopBits; bit++) {
-                if (oopMapHelper.is_oop(pc_offset, bit)) {
-                  if (bit < hsailFrame->num_d_regs()) {
-                    // show $d reg oop
-                    tty->print_cr("  oop $d%d = " PTR64_FORMAT, bit, hsailFrame->get_oop_for_bit(bit));
-                  } else {
-                    // show stack slot oop
-                    int stackOffset = (bit - hsailFrame->num_d_regs()) * 8;  // 8 bytes per stack slot
-                    tty->print_cr("  oop stk:%d = " PTR64_FORMAT, stackOffset, hsailFrame->get_oop_for_bit(bit));
-                  }
-                }
-              }
-            }
-            JavaCalls::call(&result, mh, &javaArgs, THREAD);
-            count_deoptimized++;
-            e->set_deopt_work_index(k + 1);
-          }
-        }
-        if (TraceGPUInteraction) {
-          tty->print_cr("[HSAIL] Deoptimizing to host completed for %d workitems", count_deoptimized);
-        }
-      }
-    }
-    // when we are done with the deopts, we don't need to oops_do anything
-    // in the saved state anymore
-    thread->set_gpu_hsail_deopt_info(NULL);
-
-    // Handle any never_ran workitems if there were any
-    {
-      TraceTime t("handle never-rans ", TraceGPUInteraction);
-      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);
-            // Add the iteration variable to the HSA args length
-            JavaCallArguments javaArgs(argsArrayLength + 1);
-            // 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 && (count_never_ran > 0)) {
-          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
-    }
-
-    delete e;
-    delete allocInfo;
-  }
-  return success;
-}
-
-GPU_ENTRY(jlong, Hsail::generate_kernel, (JNIEnv* env, jclass, jbyteArray code_handle, jstring name_handle))
-  guarantee(_okra_create_kernel != NULL, "[HSAIL] Okra not linked");
-  ResourceMark rm;
-  jsize name_len = env->GetStringLength(name_handle);
-  jsize code_len = env->GetArrayLength(code_handle);
-
-  char* name = NEW_RESOURCE_ARRAY(char, name_len + 1);
-  unsigned char* code = NEW_RESOURCE_ARRAY(unsigned char, code_len + 1);
-
-  code[code_len] = 0;
-  name[name_len] = 0;
-
-  env->GetByteArrayRegion(code_handle, 0, code_len, (jbyte*) code);
-  env->GetStringUTFRegion(name_handle, 0, name_len, name);
-
-  // The kernel entrypoint is always run for the time being
-  const char* entryPointName = "&run";
-  jlong okra_kernel;
-  {
-    TraceTime t("generate kernel ", TraceGPUInteraction);
-    jint okra_status = _okra_create_kernel(_device_context, code, entryPointName, (void**)&okra_kernel);
-    guarantee(okra_status==0, "_okra_create_kernel failed");
-  }
-  return (jlong) okra_kernel;
-GPU_END
-
-#if defined(LINUX)
-static const char* okra_library_name = "libokra_x86_64.so";
-#elif defined(_WINDOWS)
-static char const* okra_library_name = "okra_x86_64.dll";
-#else
-static char const* okra_library_name = NULL;
-#endif
-
-#define STRINGIFY(x)     #x
-
-#define LOOKUP_OKRA_FUNCTION(name, alias)  \
-  _##alias =                               \
-    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; \
-  } \
-
-GPU_ENTRY(jboolean, Hsail::initialize, (JNIEnv* env, jclass))
-  if (okra_library_name == NULL) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Unsupported HSAIL platform");
-    }
-    return false;
-  }
-
-  // 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);
-  }
-  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.");
-    }
-    return false;
-  }
-
-  guarantee(_okra_get_context == NULL, "cannot repeat GPU initialization");
-
-  // 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_get_context, okra_get_context);
-  LOOKUP_OKRA_FUNCTION(okra_create_kernel, okra_create_kernel);
-  LOOKUP_OKRA_FUNCTION(okra_push_pointer, okra_push_pointer);
-  LOOKUP_OKRA_FUNCTION(okra_push_boolean, okra_push_boolean);
-  LOOKUP_OKRA_FUNCTION(okra_push_byte, okra_push_byte);
-  LOOKUP_OKRA_FUNCTION(okra_push_double, okra_push_double);
-  LOOKUP_OKRA_FUNCTION(okra_push_float, okra_push_float);
-  LOOKUP_OKRA_FUNCTION(okra_push_int, okra_push_int);
-  LOOKUP_OKRA_FUNCTION(okra_push_long, okra_push_long);
-  LOOKUP_OKRA_FUNCTION(okra_execute_kernel, okra_execute_kernel);
-  LOOKUP_OKRA_FUNCTION(okra_clear_args, okra_clear_args);
-  LOOKUP_OKRA_FUNCTION(okra_dispose_kernel, okra_dispose_kernel);
-  LOOKUP_OKRA_FUNCTION(okra_dispose_context, okra_dispose_context);
-  // if we made it this far, real success
-
-  Gpu::initialized_gpu(new Hsail());
-
-    // There is 1 context per process
-  jint result = _okra_get_context(&_device_context);
-  guarantee(result==0, "get context failed");
-
-  return true;
-GPU_END
-
-
-bool Hsail::register_natives(JNIEnv* env) {
-  jclass klass = env->FindClass("com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend");
-  if (klass == NULL) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("HSAILHotSpotBackend class not found");
-    }
-    return false;
-  }
-  jint status = env->RegisterNatives(klass, HSAIL_methods, sizeof(HSAIL_methods) / sizeof(JNINativeMethod));
-  if (status != JNI_OK) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Error registering natives for HSAILHotSpotBackend: %d", status);
-    }
-    return false;
-  }
-  return true;
-}
-
-
-void Hsail::HSAILDeoptimizationInfo::oops_do(OopClosure* f) {
-  int unprocessed_deopts = num_deopts() - deopt_work_index();
-  if (TraceGPUInteraction) {
-    tty->print_cr("HSAILDeoptimizationInfo::oops_do deopt_occurred=%d, total_deopts=%d, unprocessed_deopts=%d, oop_map_array=" INTPTR_FORMAT, _deopt_occurred, num_deopts(), unprocessed_deopts, p2i(_oop_map_array));
-  }
-  if (num_deopts() == 0 || unprocessed_deopts <= 0) {
-    return; // nothing to do
-  }
-  HSAILOopMapHelper oopMapHelper(_oop_map_array);
-  oopMapHelper.resolve_arrays();  // resolve once before processing
-
-  // go thru the unprocessed deopt frames, finding each oop and applying the closre
-  for (int k = deopt_work_index(); k < num_deopts(); k++) {
-    HSAILKernelDeoptimization* pdeopt = get_deopt_save_state(k);
-    assert (pdeopt->workitem() >= 0, "bad workitem in deopt");
-    if (TraceGPUInteraction) {
-      tty->print_cr("  deopt %d, workitem %d, pc %d", k, pdeopt->workitem(), pdeopt->pc_offset());
-    }
-    HSAILFrame* hsailFrame = pdeopt->first_frame();
-    hsailFrame->oops_do(f, &oopMapHelper);
-  }
-}
--- a/src/gpu/hsail/vm/gpu_hsail.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,259 +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 GPU_HSAIL_VM_GPU_HSAIL_HPP
-#define GPU_HSAIL_VM_GPU_HSAIL_HPP
-
-#include "runtime/gpu.hpp"
-#include "utilities/exceptions.hpp"
-#include "graal/graalEnv.hpp"
-#include "gpu_hsail_OopMapHelper.hpp"
-#include "gpu_hsail_Frame.hpp"
-#include "gpu_hsail_Tlab.hpp"
-
-struct HSAILKernelStats {
-  int _dispatches;
-  int _deopts;
-  int _overflows;
-  bool _changeSeen;
-
-public:
-  HSAILKernelStats() {
-    _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);
-  }
-};
-
-class Hsail : public Gpu {
-
-  public:
-  class HSAILKernelDeoptimization VALUE_OBJ_CLASS_SPEC {
-    friend class VMStructs;
-   private:
-    // TODO: separate workitemid and actionAndReason out
-    // since they are there only once even if there are multiple frames
-    // for now, though we only ever have one hsail frame
-    jint  _workitemid;
-    jint  _actionAndReason;
-    // the first (innermost) "hsail frame" starts after the above fields
-
-   public:
-    inline jint workitem() { return _workitemid; }
-    inline jint reason() { return _actionAndReason; }
-    inline jint pc_offset() { return first_frame()->pc_offset(); }
-    inline HSAILFrame* first_frame() {
-      // starts after the "header" fields
-      return (HSAILFrame*) (((jbyte*) this) + sizeof(*this));
-    }
-  };
-
-// 8 compute units * 40 waves per cu * wavesize 64
-// TODO: query the device to get this number
-#define MAX_DEOPT_SLOTS    (8 * 40 * 64)
-
-
-  class HSAILDeoptimizationInfo : public CHeapObj<mtInternal> {
-    friend class VMStructs;
-   private:
-    jint* _notice_safepoints;
-    jint _deopt_occurred;
-    jint _deopt_next_index;
-    jint _num_slots;
-    jint _deopt_span;
-    jint _deopt_work_index;           // how far we are in processing the deopts
-    HSAILTlabInfo** _cur_tlab_info;   // copy of what was in the HSAILAllocationInfo, to avoid an extra indirection
-    HSAILAllocationInfo* _alloc_info;
-    char _ignore;
-    jobject _oop_map_array;
-    // keep a pointer last so save area following it is word aligned
-    jboolean* _never_ran_array;
-
-   public:
-    // static HSAILKernelStats kernelStats;
-    HSAILKernelDeoptimization _deopt_save_states[1];  // number and size of these can vary per kernel
-
-    static inline size_t hdr_size() {
-      return sizeof(HSAILDeoptimizationInfo);
-    }
-
-    inline jbyte* save_area_start() {
-      return (jbyte*) (this) + hdr_size();
-    }
-
-    inline HSAILDeoptimizationInfo(int numSlots, int bytesPerSaveArea, int dimX, HSAILAllocationInfo* allocInfo, jobject oop_map_array) {
-      _notice_safepoints = &Hsail::_notice_safepoints;
-      _deopt_occurred = 0;
-      _deopt_next_index = 0;
-      _deopt_work_index = 0;
-      _num_slots = numSlots;
-      _never_ran_array = NEW_C_HEAP_ARRAY(jboolean, dimX, mtInternal);
-      memset(_never_ran_array, 0, dimX * sizeof(jboolean));
-      _alloc_info = allocInfo;
-      _oop_map_array = oop_map_array;
-      _deopt_span = sizeof(HSAILKernelDeoptimization) + sizeof(HSAILFrame) + bytesPerSaveArea;
-      if (TraceGPUInteraction) {
-        tty->print_cr("HSAILDeoptimizationInfo allocated, %d slots of size %d total size = " SIZE_FORMAT_HEX " bytes",
-            _num_slots, _deopt_span, (_num_slots * _deopt_span + sizeof(HSAILDeoptimizationInfo)));
-      }
-    }
-
-    inline ~HSAILDeoptimizationInfo() {
-      FREE_C_HEAP_ARRAY(jboolean, _never_ran_array, mtInternal);
-    }
-
-    inline jint deopt_occurred() {
-      return _deopt_occurred;
-    }
-    inline jint num_deopts() { return _deopt_next_index; }
-    inline jboolean* never_ran_array() { return _never_ran_array; }
-    inline jint num_slots() {return _num_slots;}
-    inline void set_deopt_work_index(int val) { _deopt_work_index = val; }
-    inline jint deopt_work_index() { return _deopt_work_index; }
-
-    inline HSAILKernelDeoptimization* get_deopt_save_state(int slot) {
-      // use _deopt_span to index into _deopt_states
-      return (HSAILKernelDeoptimization*) (save_area_start() + _deopt_span * slot);
-    }
-
-    void set_cur_tlabInfos(HSAILTlabInfo** ptlabInfos) {
-      _cur_tlab_info = ptlabInfos;
-    }
-
-    void oops_do(OopClosure* f);
-
-    void* operator new (size_t hdrSize, int numSlots, int bytesPerSaveArea) {
-      assert(hdrSize <= hdr_size(), "");
-      size_t totalSizeBytes = hdr_size()  + numSlots * (sizeof(HSAILKernelDeoptimization) + sizeof(HSAILFrame) + bytesPerSaveArea);
-      return NEW_C_HEAP_ARRAY(char, totalSizeBytes, mtInternal);
-    }
-
-    void operator delete (void* ptr) {
-      FREE_C_HEAP_ARRAY(char, ptr, mtInternal);
-    }
-  };
-
-private:
-
-  static JNINativeMethod HSAIL_methods[];
-
-  // static native boolean initialize();
-  JNIEXPORT static jboolean JNICALL initialize(JNIEnv* env, jclass);
-
-  // static native long generateKernel(byte[] targetCode, String name);
-  JNIEXPORT static jlong JNICALL generate_kernel(JNIEnv* env, jclass, jbyteArray code_handle, jstring name_handle);
-
-  // static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args);
-  JNIEXPORT static jboolean JNICALL execute_kernel_void_1d(JNIEnv* env, jclass, jobject hotspotInstalledCode, jint dimX, jobject args,
-                                                   jint num_tlabs, int allocBytesPerWorkitem, jobject oop_map_array);
-
-  static jboolean execute_kernel_void_1d_internal(address kernel, int dimX, jobject args, methodHandle& mh, nmethod* nm,
-                                                  jint num_tlabs, int allocBytesPerWorkitem, jobject oop_map_array, TRAPS);
-
-  static GraalEnv::CodeInstallResult install_code(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle triggered_deoptimizations);
-
-public:
-
-  // Registers the implementations for the native methods in HSAILHotSpotBackend
-  static bool register_natives(JNIEnv* env);
-
-  virtual const char* name() { return "HSAIL"; }
-
-  virtual void notice_safepoints();
-  virtual void ignore_safepoints();
-
-#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
-  typedef unsigned long long CUdeviceptr;
-#else
-  typedef unsigned int CUdeviceptr;
-#endif
-
-private:
-
-  /*
-   * Kernel launch options from okra.h
-   */
-  typedef struct graal_okra_range_s {
-    uint32_t dimension; //max value is 3
-    uint32_t global_size[3];
-    uint32_t group_size[3];
-    uint32_t reserved; //For future use
-  } graal_okra_range_t;
-
-  typedef jint (*okra_get_context_func_t)(void**);
-  typedef jint (*okra_create_kernel_func_t)(void*, unsigned char*, const char*, void**);
-  typedef jint (*okra_push_pointer_func_t)(void*, void*);
-  typedef jint (*okra_push_boolean_func_t)(void*, jboolean);
-  typedef jint (*okra_push_byte_func_t)(void*, jbyte);
-  typedef jint (*okra_push_double_func_t)(void*, jdouble);
-  typedef jint (*okra_push_float_func_t)(void*, jfloat);
-  typedef jint (*okra_push_int_func_t)(void*, jint);
-  typedef jint (*okra_push_long_func_t)(void*, jlong);
-  typedef jint (*okra_execute_kernel_func_t)(void*, void*, graal_okra_range_t*);
-  typedef jint (*okra_clear_args_func_t)(void*);
-  typedef jint (*okra_dispose_kernel_func_t)(void*);
-  typedef jint (*okra_dispose_context_func_t)(void*);
-
-public:
-  static okra_get_context_func_t                _okra_get_context;
-  static okra_create_kernel_func_t              _okra_create_kernel;
-  static okra_push_pointer_func_t               _okra_push_pointer;
-  static okra_push_boolean_func_t               _okra_push_boolean;
-  static okra_push_byte_func_t                  _okra_push_byte;
-  static okra_push_double_func_t                _okra_push_double;
-  static okra_push_float_func_t                 _okra_push_float;
-  static okra_push_int_func_t                   _okra_push_int;
-  static okra_push_long_func_t                  _okra_push_long;
-  static okra_execute_kernel_func_t             _okra_execute_kernel;
-  static okra_clear_args_func_t                 _okra_clear_args;
-  static okra_dispose_kernel_func_t             _okra_dispose_kernel;
-  static okra_dispose_context_func_t            _okra_dispose_context;
-
-protected:
-  static void* _device_context;
-
-  // true if safepoints are activated
-  static jint _notice_safepoints;
-};
-#endif // GPU_HSAIL_VM_GPU_HSAIL_HPP
--- a/src/gpu/hsail/vm/gpu_hsail_Frame.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * 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.
- *
- */
-
-#ifndef GPU_HSAIL_VM_GPU_HSAIL_FRAME_HPP
-#define GPU_HSAIL_VM_GPU_HSAIL_FRAME_HPP
-
-#include "graal/graalEnv.hpp"
-#include "code/debugInfo.hpp"
-#include "code/location.hpp"
-
-class HSAILFrame VALUE_OBJ_CLASS_SPEC {
-  friend class VMStructs;
-private:
-  jint  _pc_offset;  // The HSAIL "pc_offset" where the exception happens
-  jbyte _num_s_regs;
-  jbyte _num_d_regs;
-  jshort _num_stack_slots; 
-
-  jbyte* data_start() {return (jbyte*) this  + sizeof(*this); }
-  int sreg_ofst_start() { return 0; }
-  int dreg_ofst_start() { return sreg_ofst_start() + num_s_regs() * sizeof(jint); } 
-  int stackslot_ofst_start() { return dreg_ofst_start() + num_d_regs() * sizeof(jlong); } 
-
-  int sreg_ofst(int idx) {
-    assert(idx >= 0 && idx < num_s_regs(), "bad sreg index");
-    return sreg_ofst_start() + idx * sizeof(jint);
-  }
-
-  int dreg_ofst(int idx) {
-    assert(idx >= 0 && idx < num_d_regs(), "bad dreg index");
-    return dreg_ofst_start() + idx * sizeof(jlong);
-  }
-
-  int stackslot_ofst(int stackOffset) {
-    assert(stackOffset >= 0 && (unsigned int) stackOffset < num_stack_slots() * sizeof(jlong), "bad stackoffset");
-    return stackslot_ofst_start() + stackOffset;
-  }
-
-  // the _ptr versions just return a pointer to the indicated d reg or stackslot64
-  // some of these are used for oops_do processing
-  jint* get_s_reg_ptr(int idx) {
-    return((jint*) (data_start() + sreg_ofst(idx)));
-  }
-
-  jlong* get_d_reg_ptr(int idx) {
-    return((jlong*) (data_start() + dreg_ofst(idx)));
-  }
-
-  jlong* get_stackslot64_ptr(int stackOffset) {
-    return((jlong*) (data_start() + stackslot_ofst(stackOffset)));
-  }
-
-  jint* get_stackslot32_ptr(int stackOffset) {
-    return((jint*) (data_start() + stackslot_ofst(stackOffset)));
-  }
-
-  void* get_oop_ptr_for_bit(int bit) {
-    void* oop_ptr;
-    if (bit < num_d_regs()) {
-      // d register
-      oop_ptr = (void*) get_d_reg_ptr(bit);
-    } else {
-      // stack slot
-      int stackOffset = (bit - num_d_regs()) * 8;  // 8 bytes per stack slot
-      oop_ptr = (void*) get_stackslot64_ptr(stackOffset);
-    }
-    return oop_ptr;
-  }
-
-public:
-  // Accessors
-  jint pc_offset() { return _pc_offset; }
-  jint num_s_regs() {return _num_s_regs; }
-  jint num_d_regs() {return _num_d_regs; }
-  jint num_stack_slots() {return _num_stack_slots; }
-
-  jlong get_oop_for_bit(int bit) {
-    return * (jlong *) get_oop_ptr_for_bit(bit);
-  }
-    
-  // do the oops from this frame
-  void oops_do(OopClosure* f, HSAILOopMapHelper* oopMapHelper) {
-    int oops_per_deopt = num_d_regs() + num_stack_slots();
-
-    // handle the dregister and stackSlot based oops
-    for (int bit = 0; bit < oops_per_deopt; bit++) {
-      if (oopMapHelper->is_oop(pc_offset(), bit)) {
-        void* oop_ptr = get_oop_ptr_for_bit(bit);
-        // the oops we are dealing with here in the hsailFrame are always uncompressed
-        oop old_oop = oopDesc::load_heap_oop((oop *)oop_ptr);
-        f->do_oop((oop*) oop_ptr);
-        if (TraceGPUInteraction) {
-          oop new_oop = oopDesc::load_heap_oop((oop *)oop_ptr);
-          tty->print_cr("bit=%d, oop_ptr=%p, old=%p, new=%p", bit, oop_ptr, (void *)old_oop, (void *)new_oop);
-        }
-      }
-    }
-  }
-};
-  
-#endif // GPU_HSAIL_VM_GPU_HSAIL_FRAME_HPP
--- a/src/gpu/hsail/vm/gpu_hsail_OopMapHelper.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * 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.
- *
- */
-
-#ifndef GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP
-#define GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP
-
-#include "graal/graalEnv.hpp"
-#include "code/debugInfo.hpp"
-#include "code/location.hpp"
-
-// Takes the jobject for the array of ints created by the java side
-// and decodes the information based on pc_offset to find oops
-class HSAILOopMapHelper : public StackObj {
-private:
-  jobject _oop_map_array_jobject;
-  typeArrayOop _oop_map_array;
-  int _last_pcoffset;
-  int _last_idx;
-
-  enum {
-    SAVEAREACOUNTS_OFST=0,
-    SPAN_OFST=1,
-    HEADERSIZE=2
-  }; 
-  int mapPcOffsetToIndex(int pcOffset) {
-    if (pcOffset == _last_pcoffset) {
-      return _last_idx;
-    }
-    int span = _oop_map_array->int_at(SPAN_OFST);
-    for (int idx = HEADERSIZE; idx < _oop_map_array->length(); idx += span) {
-      int ofst = _oop_map_array->int_at(idx);
-      if (ofst == pcOffset) {
-        _last_pcoffset = pcOffset;
-        _last_idx = idx + 1;
-        return _last_idx;
-      }
-    }
-    ShouldNotReachHere();
-    return -1;
-  }
-
-public:
-  HSAILOopMapHelper(jobject oop_map_array_jobject) {
-    _oop_map_array_jobject = oop_map_array_jobject;
-    _last_pcoffset = -1;
-    resolve_arrays();
-  }
- 
-  void resolve_arrays() {
-    _oop_map_array = (typeArrayOop) JNIHandles::resolve(_oop_map_array_jobject);
-  }
-
-  static int get_save_area_counts(jobject oop_map_array_jobject) {
-    typeArrayOop oop_map_array_resolved = (typeArrayOop) JNIHandles::resolve(oop_map_array_jobject);
-    return oop_map_array_resolved->int_at(SAVEAREACOUNTS_OFST);
-  }
-
-  bool is_oop(int pcOffset, int bit){
-    int bits_int_idx = mapPcOffsetToIndex(pcOffset) + (bit / 32);
-    int bitpos = bit % 32;
-    int bits = _oop_map_array->int_at(bits_int_idx);
-    return ((bits & (1 << bitpos)) != 0);
-  }
-
-};
-
-#endif // GPU_HSAIL_VM_GPU_HSAIL_OOPMAPHELPER_HPP
--- a/src/gpu/hsail/vm/gpu_hsail_Tlab.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,255 +0,0 @@
-/*
- * 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.
- *
- */
-
-#ifndef GPU_HSAIL_VM_GPU_HSAIL_TLAB_HPP
-#define GPU_HSAIL_VM_GPU_HSAIL_TLAB_HPP
-
-#include "graal/graalEnv.hpp"
-#include "code/debugInfo.hpp"
-#include "code/location.hpp"
-#include "gpu_hsail.hpp"
-
-class HSAILAllocationInfo;
-
-class HSAILTlabInfo VALUE_OBJ_CLASS_SPEC {
-  friend class VMStructs;
-public:
-  // uses only the necessary fields from a full TLAB
-  HeapWord* _start;
-  HeapWord* _top;
-  HeapWord* _end;
-  HeapWord* _last_good_top;
-  HeapWord* _original_top;
-  ThreadLocalAllocBuffer* _tlab;      // tlab associated with this tlabInfo
-  HSAILAllocationInfo* _alloc_info;   // same as what is in HSAILDeoptimizationInfo
-
-  // Accessors
-  HeapWord* start() { return _start; }
-  HeapWord* top() { return _top; }
-  HeapWord* end() { return _end; }
-  HeapWord* last_good_top() { return _last_good_top; }
-  HeapWord* original_top() { return _original_top; }
-  ThreadLocalAllocBuffer* tlab() { return _tlab; }
-  void initialize(HeapWord* start, HeapWord* top, HeapWord* end, ThreadLocalAllocBuffer* tlab, HSAILAllocationInfo* allocInfo) {
-    _start = start;
-    _top = _original_top = top;
-    _end = end;
-    _tlab = tlab;
-    _alloc_info = allocInfo;
-  }
-};
-
-
-class HSAILAllocationInfo : public CHeapObj<mtInternal> {
-  friend class VMStructs;
-private:
-  jint   _num_tlabs;
-  size_t _tlab_align_reserve_bytes;         // filled in from ThreadLocalAllocBuffer::alignment_reserve_in_bytes()
-  HSAILTlabInfo** _cur_tlab_infos;          // array of current tlab info pointers, one per num_tlabs
-  HSAILTlabInfo* _tlab_infos_pool_start;    // pool for new tlab_infos
-  HSAILTlabInfo* _tlab_infos_pool_next;     // where next will be allocated from
-  HSAILTlabInfo* _tlab_infos_pool_end;      // where next will be allocated from
-
-public:
-  HSAILAllocationInfo(jint num_tlabs, int dimX, int allocBytesPerWorkitem) {
-    _num_tlabs = num_tlabs;
-    // if this thread doesn't have gpu_hsail_tlabs allocated yet, do so now
-    JavaThread* thread = JavaThread::current();
-    if (thread->get_gpu_hsail_tlabs_count() == 0) {
-      thread->initialize_gpu_hsail_tlabs(num_tlabs);
-      if (TraceGPUInteraction) {
-        for (int i = 0; i < num_tlabs; i++) {
-          ThreadLocalAllocBuffer* tlab = thread->get_gpu_hsail_tlab_at(i);
-          tty->print("initialized gpu_hsail_tlab %d at %p -> ", i, tlab);
-          printTlabInfoFromThread(tlab);
-        }
-      }
-    }
-
-    // Compute max_tlab_infos based on amount of free heap space
-    size_t max_tlab_infos;
-    {
-      ThreadLocalAllocBuffer* tlab = &thread->tlab();
-      size_t new_tlab_size = tlab->compute_size(0);
-      size_t heap_bytes_free = Universe::heap()->unsafe_max_tlab_alloc(thread);
-      if (new_tlab_size != 0) {
-        max_tlab_infos = MIN2(heap_bytes_free / new_tlab_size, (size_t)(64 * _num_tlabs));
-      } else {
-        max_tlab_infos = 8 * _num_tlabs;   // an arbitrary multiple
-      }
-      if (TraceGPUInteraction) {
-        tty->print_cr("heapFree = " SIZE_FORMAT ", newTlabSize=" SIZE_FORMAT ", tlabInfos allocated = " SIZE_FORMAT,
-          heap_bytes_free, new_tlab_size, max_tlab_infos);
-      }
-    }
-
-    _cur_tlab_infos = NEW_C_HEAP_ARRAY(HSAILTlabInfo*, _num_tlabs, mtInternal);
-    _tlab_infos_pool_start = NEW_C_HEAP_ARRAY(HSAILTlabInfo, max_tlab_infos, mtInternal);
-    _tlab_infos_pool_next = &_tlab_infos_pool_start[_num_tlabs];
-    _tlab_infos_pool_end = &_tlab_infos_pool_start[max_tlab_infos];
-    _tlab_align_reserve_bytes = ThreadLocalAllocBuffer::alignment_reserve_in_bytes();
-
-    // we will fill the first N tlabInfos from the gpu_hsail_tlabs
-    for (int i = 0; i < _num_tlabs; i++) {
-      ThreadLocalAllocBuffer* tlab = thread->get_gpu_hsail_tlab_at(i);
-      if (TraceGPUInteraction) {
-        tty->print("gpu_hsail_tlab %d at %p -> ", i, tlab);
-        printTlabInfoFromThread(tlab);
-      }
-
-      // Here we try to get a new tlab if current one is null. Note:
-      // eventually we may want to test if the size is too small based
-      // on some heuristic where we see how much this kernel tends to
-      // allocate, but for now we can just let it overflow and let the
-      // GPU allocate new tlabs. Actually, if we can't prime a tlab
-      // here, it might make sense to do a gc now rather than to start
-      // the kernel and have it deoptimize.  How to do that?
-      if (tlab->end() == NULL) {
-        bool success = getNewGpuHsailTlab(tlab);
-        if (TraceGPUInteraction) {
-          if (success) {
-            tty->print("gpu_hsail_tlab %d, refilled tlab, -> ", i);
-            printTlabInfoFromThread(tlab);
-          } else {
-            tty->print("gpu_hsail_tlab %d, could not refill tlab, left as ", i);
-            printTlabInfoFromThread(tlab);
-          }
-        }
-      }
-
-      // extract the necessary tlab fields into a TlabInfo record
-      HSAILTlabInfo* pTlabInfo = &_tlab_infos_pool_start[i];
-      _cur_tlab_infos[i] = pTlabInfo;
-      pTlabInfo->initialize(tlab->start(), tlab->top(), tlab->end(), tlab, this);
-    }
-  }
-
-  ~HSAILAllocationInfo() {
-    FREE_C_HEAP_ARRAY(HSAILTlabInfo*, _cur_tlab_infos, mtInternal);
-    FREE_C_HEAP_ARRAY(HSAILTlabInfo, _tlab_infos_pool_start, mtInternal);
-  }
-
-  void postKernelCleanup() {
-    // go thru all the tlabInfos, fix up any tlab tops that overflowed
-    // complete the tlabs if they overflowed
-    // update the gpu_hsail_tlabs when appropriate
-    bool anyOverflows = false;
-    size_t bytesAllocated = 0;
-    // if there was an overflow in allocating tlabInfos, correct it here
-    if (_tlab_infos_pool_next > _tlab_infos_pool_end) {
-      if (TraceGPUInteraction) {
-        int overflowAmount = _tlab_infos_pool_next - _tlab_infos_pool_end;
-        tty->print_cr("tlabInfo allocation overflowed by %d units", overflowAmount);
-      }
-      _tlab_infos_pool_next = _tlab_infos_pool_end;
-    }
-    for (HSAILTlabInfo* tlabInfo = _tlab_infos_pool_start; tlabInfo < _tlab_infos_pool_next; tlabInfo++) {
-      if (TraceGPUInteraction) {
-        tty->print_cr("postprocess tlabInfo %p, start=%p, top=%p, end=%p, last_good_top=%p", tlabInfo,
-                      tlabInfo->start(), tlabInfo->top(), tlabInfo->end(), tlabInfo->last_good_top());
-      }
-      ThreadLocalAllocBuffer* tlab = tlabInfo->tlab();
-      bool overflowed = false;
-      // if a tlabInfo has NULL fields, i.e. we could not prime it on entry,
-      // or we could not get a tlab from the gpu, so ignore tlabInfo here
-      if (tlabInfo->start() != NULL) {
-        if (tlabInfo->top() > tlabInfo->end()) {
-          anyOverflows = true;
-          overflowed = true;
-          if (TraceGPUInteraction) {
-            long overflowAmount = (long) tlabInfo->top() - (long) tlabInfo->last_good_top();
-            tty->print_cr("tlabInfo %p (tlab = %p) overflowed by %ld bytes, setting last good top to %p", tlabInfo, tlab, overflowAmount, tlabInfo->last_good_top());
-          }
-          tlabInfo->_top = tlabInfo->last_good_top();
-        }
-
-        // fill the gpu_hsail_tlab with the tlabInfo information
-        // we do this even if it will get overwritten by a later tlabinfo
-        // because it helps with tlab statistics for that tlab
-        tlab->fill(tlabInfo->start(), tlabInfo->top(), (tlabInfo->end() - tlabInfo->start()) + tlab->alignment_reserve());
-
-        // if there was an overflow, make it parsable with retire = true
-        if (overflowed) {
-          tlab->make_parsable(true);
-        }
-
-        size_t delta = (long)(tlabInfo->top()) - (long)(tlabInfo->original_top());
-        if (TraceGPUInteraction) {
-          tty->print_cr(SIZE_FORMAT " bytes were allocated by tlabInfo %p (start %p, top %p, end %p",
-            delta, tlabInfo, tlabInfo->start(), tlabInfo->top(), tlabInfo->end());
-        }
-        bytesAllocated += delta;
-      }
-    }
-    if (TraceGPUInteraction) {
-      tty->print_cr(SIZE_FORMAT" total bytes were allocated in this kernel", bytesAllocated);
-    }
-    if (anyOverflows) {
-      // Hsail::kernelStats.incOverflows();
-    }
-  }
-
-  HSAILTlabInfo** getCurTlabInfos() {
-    return _cur_tlab_infos;
-  }
-
-private:
-  // fill and retire old tlab and get a new one
-  // if we can't get one, no problem someone will eventually do a gc
-  bool getNewGpuHsailTlab(ThreadLocalAllocBuffer* tlab) {
-
-    tlab->clear_before_allocation();    // fill and retire old tlab (will also check for null)
-
-    // get a size for a new tlab that is based on the desired_size
-    size_t new_tlab_size = tlab->compute_size(0);
-    if (new_tlab_size == 0) return false;
-
-    HeapWord* tlab_start = Universe::heap()->allocate_new_tlab(new_tlab_size);
-    if (tlab_start == NULL) return false;
-
-    // ..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);
-    return true;
-  }
-
-  void printTlabInfoFromThread (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=" SIZE_FORMAT ", free=" SIZE_FORMAT " (%f%%)",
-      start, top, end, tlabSize, tlabFree, freePct);
-  }
-
-};
-
-#endif // GPU_HSAIL_VM_GPU_HSAIL_TLAB_HPP
--- a/src/gpu/hsail/vm/hsailArgumentsBase.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "hsailArgumentsBase.hpp"
-#include "runtime/javaCalls.hpp"
-
-
-// Get next java argument
-oop HSAILArgumentsBase::next_arg(BasicType expectedType) {
-  assert(_index < _args->length(), "out of bounds");
-
-  oop arg = ((objArrayOop) (_args))->obj_at(_index++);
-  assert(expectedType == T_OBJECT ||
-         java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
-
-  return arg;
-}
-
-void HSAILArgumentsBase::collectArgs() {
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::collectArgs, sig:%s  args length=%d", argsBuilderName(), _signature->as_C_string(), _length);
-  }
-  if (!_is_static) {
-    // First object in args should be 'this'
-    oop arg = _args->obj_at(_index++);
-    assert(arg->is_instance() && (!arg->is_array()), "First arg should be 'this'");
-    if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] %s, instance method, this " INTPTR_FORMAT ", is a %s", argsBuilderName(), p2i(arg), arg->klass()->external_name());
-    }
-    pushObject(arg);
-  } else {
-    if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] %s, static method", argsBuilderName());
-    }
-  }
-  // Iterate over the entire signature
-  iterate();
-
-  pushTrailingArgs();
-}
-
-void HSAILArgumentsBase::do_bool() {
-  // Get the boxed value
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_BOOLEAN), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-  
-  pushBool(jValue.z);
-}
-
-void HSAILArgumentsBase::do_byte() {
-  // Get the boxed value
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_BYTE), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-
-  pushByte(jValue.b);
-}
-
-void HSAILArgumentsBase::do_double() {
-  // Get the boxed value
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_DOUBLE), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_double, _index=%d, value = %e", argsBuilderName(), _index - 1, jValue.d);
-  }  
-  pushDouble(jValue.d);
-}
-
-void HSAILArgumentsBase::do_float() {
-  // Get the boxed value
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_FLOAT), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_float, _index=%d, value = %f", argsBuilderName(), _index - 1, jValue.f);
-  }  
-  pushFloat(jValue.f);
-}
-
-void HSAILArgumentsBase::do_int() {
-  // If the last parameter is an int, it is handled in a special way
-  // For kernel arguments we don't pass it since we use the HSAIL workitemid in place of that int value
-  // For javaCall arguments we pass the actual workitemid
-  if (isLastParameter()) {
-    handleFinalIntParameter();
-    return;
-  }
-
-  // not the final int parameter, Get the boxed int
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_INT), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_int, _index=%d, value = %d", argsBuilderName(), _index - 1, jValue.i);
-  }    
-  
-  pushInt(jValue.i);
-}
-
-void HSAILArgumentsBase::do_long() {
-  // Get the boxed value
-  oop arg = _args->obj_at(_index++);
-  assert(java_lang_boxing_object::is_instance(arg, T_LONG), "arg type mismatch");
-  
-  jvalue jValue;
-  java_lang_boxing_object::get_value(arg, &jValue);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_long, _index=%d, value = " JLONG_FORMAT, argsBuilderName(), _index - 1, jValue.j);
-  }    
-
-  pushLong(jValue.j);
-}
-
-void HSAILArgumentsBase::do_array(int begin, int end) {
-  oop arg = _args->obj_at(_index++);
-  if (arg == NULL) {
-      recordNullObjectParameter();
-  } else {
-      assert(arg->is_array(), "arg type mismatch");
-  }
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_array, _index=%d, 0x" INTPTR_FORMAT ", is a %s", argsBuilderName(), _index - 1, p2i(arg),
-                  arg == NULL ? "null" : arg->klass()->external_name());
-  }
-    
-  pushObject(arg);
-}
-
-void HSAILArgumentsBase::do_object() {
-  bool isLastParam = isLastParameter();  // determine this before incrementing _index
-
-  oop arg = _args->obj_at(_index++);
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::do_object, _index=%d, 0x" INTPTR_FORMAT " is a %s", argsBuilderName(), _index - 1, p2i(arg),
-                  arg == NULL ? "null" : arg->klass()->external_name());
-  }
-  if (arg == NULL) {
-      recordNullObjectParameter();
-  }
-
-  // check if this is last arg in signature
-  // an object as last parameter requires special handling
-  if (isLastParam) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("[HSAIL] %s, trailing object ref should be object source array ref", argsBuilderName());
-    }
-    assert(arg->is_objArray(), "arg type mismatch");
-    handleFinalObjParameter(arg);
-  } else {
-    // not the final parameter, just push
-    pushObject(arg);
-  }
-}
-
-void HSAILArgumentsBase::do_object(int begin, int end) {
-  do_object();
-}
-
-void HSAILArgumentsBase::do_void() {
-    return;
-}
-
-// TODO implement other do_*
-
--- a/src/gpu/hsail/vm/hsailArgumentsBase.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +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 GPU_HSAIL_VM_HSAIL_ARGUMENTS_BASE_HPP
-#define GPU_HSAIL_VM_HSAIL_ARGUMENTS_BASE_HPP
-
-#include "runtime/signature.hpp"
-
-
-// Base class which iterates thru a signature and pulls from a
-// objArrayOop of boxed values.  Used as base for HSAILKernelArguments
-// and HSAILJavaCallArguments The derived classes specify how to push
-// args onto their data structure
-class HSAILArgumentsBase : public SignatureIterator {
-
-public:
-
-private:
-  // Array of java argument oops
-  objArrayOop _args;
-  // Length of args array
-  int   _length;
-  // Current index into _args
-  int _index;
-  // number of parameters in the signature
-  int _parameter_count;
-
-  Symbol* _signature;
-  bool _is_static;
-
-  // records first null parameter seen
-  int _first_null_parameter_index;
-  
-  // Get next java argument
-  oop next_arg(BasicType expectedType);
-
-    virtual char* argsBuilderName() = 0;
-    virtual void pushObject(void* obj) = 0;
-    virtual void pushBool(jboolean z) = 0;
-    virtual void pushByte(jbyte b) = 0;
-    virtual void pushDouble(jdouble d) = 0;
-    virtual void pushFloat(jfloat f) = 0;
-    virtual void pushInt(jint i) = 0;
-    virtual void pushLong(jlong j) = 0;
-    virtual void handleFinalIntParameter() = 0;
-    virtual void handleFinalObjParameter(void* obj) = 0;
-    virtual void pushTrailingArgs() = 0;
-
- public:
-  HSAILArgumentsBase(Symbol* signature, objArrayOop args, bool is_static) : SignatureIterator(signature) {
-    this->_return_type = T_ILLEGAL;
-    _index = 0;
-    _args = args;
-    _is_static = is_static;
-    _signature = signature;
-
-    _length = args->length();
-    _parameter_count = ArgumentCount(signature).size();
-
-    _first_null_parameter_index = -1;
-
-  }
-
-  void recordNullObjectParameter() {
-    if (_first_null_parameter_index == -1) {
-      _first_null_parameter_index = _parameter_index;
-    }
-  }
-
-  bool is_static() {
-    return _is_static;
-  }
-
-  int length() {
-    return _length;
-  }
-
-  objArrayOop args() {
-    return _args;
-  }
-
-  int getFirstNullParameterIndex() {
-    return _first_null_parameter_index;
-  }
-
-  virtual void collectArgs();
-
-  void do_bool();
-  void do_byte();
-  void do_double();
-  void do_float();
-  void do_int();
-  void do_long();
-  void do_array(int begin, int end);
-  void do_object();
-  void do_object(int begin, int end);
-
-  void do_void();
-
-  inline void do_char()   {
-    /* TODO : To be implemented */
-    guarantee(false, "do_char:NYI");
-  }
-  inline void do_short()  {
-    /* TODO : To be implemented */
-    guarantee(false, "do_short:NYI");
-  }
-
-  bool isLastParameter() {
-      return  (_index == (_is_static ?  _parameter_count - 1 : _parameter_count));
-  }
-
-};
-
-#endif  // GPU_HSAIL_VM_HSAIL_ARGUMENTS_BASE_HPP
--- a/src/gpu/hsail/vm/hsailJavaCallArguments.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +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 GPU_HSAIL_VM_HSAIL_JAVACALL_ARGUMENTS_HPP
-#define GPU_HSAIL_VM_HSAIL_JAVACALL_ARGUMENTS_HPP
-
-#include "hsailArgumentsBase.hpp"
-#include "runtime/javaCalls.hpp"
-
-class HSAILJavaCallArguments : public HSAILArgumentsBase {
-
-public:
-
-private:
-  // JavaCall args to push into
-  JavaCallArguments* _javaArgs;
-  int _workitemid;
- public:
-    HSAILJavaCallArguments(JavaCallArguments* javaArgs, int workitemid, Symbol* signature, objArrayOop args, bool is_static) : HSAILArgumentsBase(signature, args, is_static) {
-        _javaArgs = javaArgs;
-        _workitemid = workitemid;
-        collectArgs();
-    }
-    virtual char* argsBuilderName() {return (char*)"HSAILJavaCallArguments";}
-    virtual void pushObject(void* obj) { _javaArgs->push_oop((oop) obj);  }
-    virtual void pushBool(jboolean z) { pushInt(z); }
-    virtual void pushByte(jbyte b) { pushInt(b); }
-    virtual void pushDouble(jdouble d) { _javaArgs->push_double(d); }
-    virtual void pushFloat(jfloat f) { _javaArgs->push_float(f); }
-    virtual void pushInt(jint i) { _javaArgs->push_int(i); }
-    virtual void pushLong(jlong j) { _javaArgs->push_long(j); }
-    virtual void pushTrailingArgs() {  }
-
-    // For javaCall the final int parameter gets replaced with the workitemid
-    // which was passed back in the deopt info
-    virtual void handleFinalIntParameter() {
-      if (TraceGPUInteraction) {
-        tty->print_cr("[HSAIL] HSAILJavaCallArguments, passing workitemid %d as trailing int parameter", _workitemid);
-      }
-      pushInt(_workitemid);
-    }
-    // for kernel arguments, final obj parameter should be an object
-    // stream source array (already checked in the base class) so for
-    // a javacall we need to extract the correct obj from it based on
-    // the workitemid
-    virtual void handleFinalObjParameter(void* arg) {
-      objArrayOop objArrayArg = (objArrayOop) arg;
-      oop extractedObj = objArrayArg->obj_at(_workitemid);
-      if (TraceGPUInteraction) {
-        tty->print_cr("[HSAIL] HSAILJavaCallArguments, extracted obj #%d from array, " INTPTR_FORMAT " is a %s",
-                      _workitemid, p2i(extractedObj),
-                      (extractedObj == NULL ? "null" : extractedObj->klass()->external_name()));
-      }
-      pushObject(extractedObj);
-    }
-
-};
-
-#endif  // GPU_HSAIL_VM_HSAIL_JAVACALL_ARGUMENTS_HPP
-
--- a/src/gpu/hsail/vm/hsailKernelArguments.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * 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.
- *
- */
-#include "precompiled.hpp"
-#include "hsailKernelArguments.hpp"
-
-void HSAILKernelArguments::collectArgs() {
-  int index = 0;
-  if (TraceGPUInteraction) {
-    tty->print_cr("[HSAIL] %s::collectArgs, args length=%d", argsBuilderName(), length());
-  }
-
-  // Manually iterate over the actual args array without looking at method signature
-  while (index < length()) {
-    oop arg = args()->obj_at(index++);
-    jvalue jValue;
-    if (arg == NULL) {
-      if (TraceGPUInteraction) {
-        tty->print_cr("[HSAIL] %s::collectArgs object, _index=%d, value = " PTR_FORMAT " is a %s", argsBuilderName(), index, p2i(arg), "null");
-      }
-      recordNullObjectParameter();
-      pushObject(arg);
-    } else {
-      java_lang_boxing_object::get_value(arg, &jValue);
-      BasicType basic_type = java_lang_boxing_object::basic_type(arg);
-      if (basic_type == T_ILLEGAL && (!(arg->is_array()))) {
-        if (TraceGPUInteraction) {
-          tty->print_cr("[HSAIL] %s::collectArgs object, _index=%d, value = " PTR_FORMAT " is a %s", argsBuilderName(), index, p2i(arg), arg == NULL ? "null" : arg->klass()->external_name());
-        }
-        pushObject(arg);
-      } else if (arg->is_array()) {
-        if (TraceGPUInteraction) {
-          int array_length = ((objArrayOop) arg)->length();
-          tty->print_cr("[HSAIL] %s::collectArgs array, length=%d, _index=%d, value = " PTR_FORMAT, argsBuilderName(), array_length, index, p2i(arg));
-        }
-        pushObject(arg);
-      } else {
-        switch (basic_type) {
-          case T_INT:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_INT _index=%d, value = %d", argsBuilderName(), index, jValue.i);
-            }
-            pushInt(jValue.i);
-            break;
-          case T_LONG:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_LONG _index=%d, value = " JLONG_FORMAT, argsBuilderName(), index, jValue.j);
-            }
-            pushLong(jValue.j);
-            break;
-          case T_FLOAT:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_FLOAT _index=%d, value = %f", argsBuilderName(), index, jValue.f);
-            }
-            pushFloat(jValue.f);
-            break;
-          case T_DOUBLE:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_DOUBLE _index=%d, value = %lf", argsBuilderName(), index, jValue.d);
-            }
-            pushDouble(jValue.d);
-            break;
-          case T_BYTE:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_BYTE _index=%d, value = %d", argsBuilderName(), index, jValue.b);
-            }
-            pushByte(jValue.b);
-            break;
-          case T_BOOLEAN:
-            if (TraceGPUInteraction) {
-              tty->print_cr("[HSAIL] %s::collectArgs, T_BOOLEAN _index=%d, value = %d", argsBuilderName(), index, jValue.z);
-            }
-            pushBool(jValue.z);
-            break;
-        }
-      }
-    }
-  }
-
-  pushTrailingArgs();
-}
-
--- a/src/gpu/hsail/vm/hsailKernelArguments.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +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 GPU_HSAIL_VM_HSAIL_KERNEL_ARGUMENTS_HPP
-#define GPU_HSAIL_VM_HSAIL_KERNEL_ARGUMENTS_HPP
-
-#include "gpu_hsail.hpp"
-#include "runtime/signature.hpp"
-#include "hsailArgumentsBase.hpp"
-
-class HSAILKernelArguments : public HSAILArgumentsBase {
-  friend class Hsail;
-
-public:
-
-private:
-  // Kernel to push into
-  address _kernel;
-  void* _exceptionHolder;
-
- public:
-    HSAILKernelArguments(address kernel, Symbol* signature, objArrayOop args, bool is_static, void* exceptionHolder) : HSAILArgumentsBase(signature, args, is_static) {
-        _kernel = kernel;
-        _exceptionHolder = exceptionHolder;
-        collectArgs();
-    }
-    virtual char* argsBuilderName() {return (char*)"HSAILKernelArguments";}
-    virtual void pushObject(void* obj) {
-        jint status = Hsail::_okra_push_pointer(_kernel, obj);
-        assert(status == 0, "arg push failed");
-    }
-    virtual void pushBool(jboolean z) {
-        jint status = Hsail::_okra_push_boolean(_kernel, z);
-        assert(status == 0, "arg push failed");
-    }
-    virtual void pushByte(jbyte b) {
-        jint status = Hsail::_okra_push_byte(_kernel, b);
-        assert(status == 0, "arg push failed");
-    }
-
-    virtual void pushDouble(jdouble d) {
-        jint status = Hsail::_okra_push_double(_kernel, d);
-        assert(status == 0, "arg push failed");
-    }
-
-    virtual void pushFloat(jfloat f) {
-        jint status = Hsail::_okra_push_float(_kernel, f);
-        assert(status == 0, "arg push failed");
-    }
-
-    virtual void pushInt(jint i) {
-        jint status = Hsail::_okra_push_int(_kernel, i);
-        assert(status == 0, "arg push failed");
-    }
-
-    virtual void pushLong(jlong j) {
-        jint status = Hsail::_okra_push_long(_kernel, j);
-        assert(status == 0, "arg push failed");
-    }
-    virtual void pushTrailingArgs() {
-        if (UseHSAILDeoptimization) {
-            // Last argument is the exception info block
-            if (TraceGPUInteraction) {
-                tty->print_cr("[HSAIL] exception block=" INTPTR_FORMAT, p2i(_exceptionHolder));
-            }
-            pushObject(_exceptionHolder);
-        }
-    }
-
-    // For kernel arguments we don't pass the final int parameter
-    // since we use the HSAIL workitemid instruction in place of that int value
-    virtual void handleFinalIntParameter() {
-      ShouldNotReachHere();
-    }
-
-    // For kernel arguments, final obj parameter should be an object
-    // stream source array (already checked in the base class) so here we just pass it
-    virtual void handleFinalObjParameter(void* arg) {
-      ShouldNotReachHere();
-    }
-
-    virtual void collectArgs();
-
-};
-
-#endif  // GPU_HSAIL_VM_HSAIL_KERNEL_ARGUMENTS_HPP
--- a/src/gpu/hsail/vm/vmStructs_hsail.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2001, 2010, 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 GPU_HSAIL_VM_VMSTRUCTS_HSAIL_HPP
-#define GPU_HSAIL_VM_VMSTRUCTS_HSAIL_HPP
-
-#include "gpu_hsail.hpp"
-#include "gpu_hsail_Frame.hpp"
-
-// These are the CPU-specific fields, types and integer
-// constants required by the Serviceability Agent. This file is
-// referenced by vmStructs.cpp.
-
-#define VM_STRUCTS_GPU_HSAIL(nonstatic_field)                           \
-  nonstatic_field(HSAILFrame, _pc_offset,                                                  jint)                                      \
-  nonstatic_field(HSAILFrame, _num_s_regs,                                                 jbyte)                                     \
-  nonstatic_field(HSAILFrame, _num_d_regs,                                                 jbyte)                                     \
-  nonstatic_field(HSAILFrame, _num_stack_slots,                                            jshort)                                    \
-                                                                                                                                      \
-  nonstatic_field(Hsail::HSAILKernelDeoptimization, _workitemid,                                jint)                                 \
-  nonstatic_field(Hsail::HSAILKernelDeoptimization, _actionAndReason,                           jint)                                 \
-                                                                                                                                      \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _notice_safepoints,                      jint*) \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_occurred,                         jint)                                      \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _deopt_next_index,                       jint)                                      \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _cur_tlab_info,                          HSAILTlabInfo**)                           \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _alloc_info,                             HSAILAllocationInfo*)                      \
-  nonstatic_field(Hsail::HSAILDeoptimizationInfo, _never_ran_array,                        jboolean*)                                 \
-                                                                                                                                      \
-  nonstatic_field(HSAILAllocationInfo, _tlab_infos_pool_start,                             HSAILTlabInfo*)                            \
-  nonstatic_field(HSAILAllocationInfo, _tlab_infos_pool_next,                              HSAILTlabInfo*)                            \
-  nonstatic_field(HSAILAllocationInfo, _tlab_infos_pool_end,                               HSAILTlabInfo*)                            \
-  nonstatic_field(HSAILAllocationInfo, _tlab_align_reserve_bytes,                          size_t)                                    \
-                                                                                                                                      \
-  nonstatic_field(HSAILTlabInfo, _start,                                                   HeapWord*)                                 \
-  nonstatic_field(HSAILTlabInfo, _top,                                                     HeapWord*)                                 \
-  nonstatic_field(HSAILTlabInfo, _end,                                                     HeapWord*)                                 \
-  nonstatic_field(HSAILTlabInfo, _last_good_top,                                           HeapWord*)                                 \
-  nonstatic_field(HSAILTlabInfo, _original_top,                                            HeapWord*)                                 \
-  nonstatic_field(HSAILTlabInfo, _alloc_info,                                              HSAILAllocationInfo*)                      \
-  nonstatic_field(HSAILTlabInfo, _tlab,                                                    ThreadLocalAllocBuffer*)                   \
-
-#define VM_TYPES_GPU_HSAIL(declare_type, declare_toplevel_type)      \
-  declare_toplevel_type(HSAILFrame)                                  \
-  declare_toplevel_type(HSAILFrame*)                                 \
-  declare_toplevel_type(Hsail::HSAILKernelDeoptimization)            \
-  declare_toplevel_type(HSAILAllocationInfo)                         \
-  declare_toplevel_type(HSAILTlabInfo)                               \
-  declare_toplevel_type(Hsail::HSAILDeoptimizationInfo)
-
-#endif // GPU_HSAIL_VM_VMSTRUCTS_HSAIL_HPP
--- a/src/gpu/ptx/vm/gpu_ptx.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,808 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/javaCalls.hpp"
-#include "runtime/gpu.hpp"
-#include "ptx/vm/gpu_ptx.hpp"
-#include "utilities/globalDefinitions.hpp"
-#include "utilities/ostream.hpp"
-#include "memory/allocation.hpp"
-#include "memory/allocation.inline.hpp"
-#include "memory/gcLocker.inline.hpp"
-#include "runtime/interfaceSupport.hpp"
-#include "runtime/vframe.hpp"
-#include "graal/graalEnv.hpp"
-#include "graal/graalRuntime.hpp"
-
-#define T_BYTE_SIZE        1
-#define T_BOOLEAN_SIZE     4
-#define T_INT_BYTE_SIZE    4
-#define T_FLOAT_BYTE_SIZE  4
-#define T_DOUBLE_BYTE_SIZE 8
-#define T_LONG_BYTE_SIZE   8
-#define T_OBJECT_BYTE_SIZE sizeof(intptr_t)
-#define T_ARRAY_BYTE_SIZE  sizeof(intptr_t)
-
-// Entry to GPU native method implementation that transitions current thread to '_thread_in_vm'.
-#define GPU_VMENTRY(result_type, name, signature) \
-  JNIEXPORT result_type JNICALL name signature { \
-  if (TraceGPUInteraction) tty->print_cr("[CUDA] " #name); \
-  GRAAL_VM_ENTRY_MARK; \
-
-// Entry to GPU native method implementation that calls a JNI function
-// and hence cannot transition current thread to '_thread_in_vm'.
-#define GPU_ENTRY(result_type, name, signature) \
-  JNIEXPORT result_type JNICALL name signature { \
-  if (TraceGPUInteraction) tty->print_cr("[CUDA] Ptx::" #name); \
-
-#define GPU_END }
-
-#define CC (char*)  /*cast a literal from (const char*)*/
-#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f))
-
-#define STRING                "Ljava/lang/String;"
-
-JNINativeMethod Ptx::PTX_methods[] = {
-  {CC"initialize",              CC"()Z",               FN_PTR(Ptx::initialize)},
-  {CC"generateKernel",          CC"([B" STRING ")J",   FN_PTR(Ptx::generate_kernel)},
-  {CC"getLaunchKernelAddress",  CC"()J",               FN_PTR(Ptx::get_execute_kernel_from_vm_address)},
-  {CC"getAvailableProcessors0", CC"()I",               FN_PTR(Ptx::get_total_cores)},
-  {CC"destroyContext",          CC"()V",               FN_PTR(Ptx::destroy_ptx_context)},
-};
-
-void * Ptx::_device_context = 0;
-int    Ptx::_cu_device = 0;
-
-Ptx::cuda_cu_init_func_t Ptx::_cuda_cu_init;
-Ptx::cuda_cu_ctx_create_func_t Ptx::_cuda_cu_ctx_create;
-Ptx::cuda_cu_ctx_destroy_func_t Ptx::_cuda_cu_ctx_destroy;
-Ptx::cuda_cu_ctx_synchronize_func_t Ptx::_cuda_cu_ctx_synchronize;
-Ptx::cuda_cu_ctx_get_current_func_t Ptx::_cuda_cu_ctx_get_current;
-Ptx::cuda_cu_ctx_set_current_func_t Ptx::_cuda_cu_ctx_set_current;
-Ptx::cuda_cu_device_get_count_func_t Ptx::_cuda_cu_device_get_count;
-Ptx::cuda_cu_device_get_name_func_t Ptx::_cuda_cu_device_get_name;
-Ptx::cuda_cu_device_get_func_t Ptx::_cuda_cu_device_get;
-Ptx::cuda_cu_device_compute_capability_func_t Ptx::_cuda_cu_device_compute_capability;
-Ptx::cuda_cu_device_get_attribute_func_t Ptx::_cuda_cu_device_get_attribute;
-Ptx::cuda_cu_launch_kernel_func_t Ptx::_cuda_cu_launch_kernel;
-Ptx::cuda_cu_module_get_function_func_t Ptx::_cuda_cu_module_get_function;
-Ptx::cuda_cu_module_load_data_ex_func_t Ptx::_cuda_cu_module_load_data_ex;
-Ptx::cuda_cu_memcpy_htod_func_t Ptx::_cuda_cu_memcpy_htod;
-Ptx::cuda_cu_memcpy_dtoh_func_t Ptx::_cuda_cu_memcpy_dtoh;
-Ptx::cuda_cu_memalloc_func_t Ptx::_cuda_cu_memalloc;
-Ptx::cuda_cu_memfree_func_t Ptx::_cuda_cu_memfree;
-Ptx::cuda_cu_mem_host_register_func_t Ptx::_cuda_cu_mem_host_register;
-Ptx::cuda_cu_mem_host_get_device_pointer_func_t Ptx::_cuda_cu_mem_host_get_device_pointer;
-Ptx::cuda_cu_mem_host_unregister_func_t Ptx::_cuda_cu_mem_host_unregister;
-
-#define STRINGIFY(x)     #x
-
-#define LOOKUP_CUDA_FUNCTION(name, alias)  \
-  _##alias =                               \
-    CAST_TO_FN_PTR(alias##_func_t, os::dll_lookup(handle, STRINGIFY(name))); \
-  if (_##alias == NULL) {      \
-  tty->print_cr("[CUDA] ***** Error: Failed to lookup %s", STRINGIFY(name)); \
-        return false; \
-  } \
-
-#define LOOKUP_CUDA_V2_FUNCTION(name, alias)  LOOKUP_CUDA_FUNCTION(name##_v2, alias)
-
-/*
- * see http://en.wikipedia.org/wiki/CUDA#Supported_GPUs
- */
-int Ptx::ncores(int major, int minor) {
-    int device_type = (major << 4) + minor;
-
-    switch (device_type) {
-        case 0x10: return 8;
-        case 0x11: return 8;
-        case 0x12: return 8;
-        case 0x13: return 8;
-        case 0x20: return 32;
-        case 0x21: return 48;
-        case 0x30: return 192;
-        case 0x35: return 192;
-    default:
-        tty->print_cr("[CUDA] Warning: Unhandled device %x", device_type);
-        return 0;
-    }
-}
-
-bool Ptx::register_natives(JNIEnv* env) {
-  jclass klass = env->FindClass("com/oracle/graal/hotspot/ptx/PTXHotSpotBackend");
-  if (klass == NULL) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("PTXHotSpotBackend class not found");
-    }
-    return false;
-  }
-  jint status = env->RegisterNatives(klass, PTX_methods, sizeof(PTX_methods) / sizeof(JNINativeMethod));
-  if (status != JNI_OK) {
-    if (true || TraceGPUInteraction) {
-      tty->print_cr("Error registering natives for PTXHotSpotBackend: %d", status);
-    }
-    return false;
-  }
-  return true;
-}
-
-GPU_ENTRY(jboolean, Ptx::initialize, (JNIEnv *env, jclass))
-
-  if (!link()) {
-    return false;
-  }
-
-  /* Initialize CUDA driver API */
-  int status = _cuda_cu_init(0);
-  if (status != GRAAL_CUDA_SUCCESS) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Failed to initialize CUDA device: %d", status);
-    }
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("CUDA driver initialization: Success");
-  }
-
-  /* Get the number of compute-capable device count */
-  int device_count = 0;
-  status = _cuda_cu_device_get_count(&device_count);
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get compute-capable device count");
-    return false;
-  }
-
-  if (device_count == 0) {
-    tty->print_cr("[CUDA] Found no device supporting CUDA");
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Number of compute-capable devices found: %d", device_count);
-  }
-
-  /* Get the handle to the first compute device */
-  int device_id = 0;
-  /* Compute-capable device handle */
-  status = _cuda_cu_device_get(&_cu_device, device_id);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get handle of first compute-capable device i.e., the one at ordinal: %d", device_id);
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Got the handle of first compute-device");
-  }
-
-  /* Get device attributes */
-  int minor, major;
-  int unified_addressing;
-  float version = 0.0;
-
-  /* Get the compute capability of the device found */
-  status = _cuda_cu_device_get_attribute(&minor, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, _cu_device);
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", _cu_device);
-    return false;
-  }
-  status = _cuda_cu_device_get_attribute(&major, GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, _cu_device);
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get major attribute of device: %d", _cu_device);
-    return false;
-  }
-
-  /* Check if the device supports atleast GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION */
-  version = (float) major + ((float) minor)/10;
-
-  if (version < GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION) {
-    tty->print_cr("[CUDA] Only cuda compute capability %.1f and later supported. Device %d supports %.1f",
-                  (float) GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION, _cu_device, version);
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Device %d supports cuda compute capability %.1f", _cu_device, version);
-  }
-
-  status = _cuda_cu_device_get_attribute(&unified_addressing, GRAAL_CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, _cu_device);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to query unified addressing mode of device: %d", _cu_device);
-    return false;
-  }
-  /* The CUDA driver runtime interaction and generated code as implemented requires
-     that the device supports Unified Addressing.
-  */
-  if (unified_addressing == 0) {
-    tty->print_cr("[CUDA] CUDA device %d does NOT have required Unified Addressing support.", _cu_device);
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Device %d has Unified Addressing support", _cu_device);
-  }
-
-  /* Get device name */
-  char device_name[256];
-  status = _cuda_cu_device_get_name(device_name, 256, _cu_device);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to get name of device: %d", _cu_device);
-    return false;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Using %s", device_name);
-  }
-
-  // Create CUDA context to compile and execute the kernel
-
-  status = _cuda_cu_ctx_create(&_device_context, GRAAL_CU_CTX_MAP_HOST, _cu_device);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to create CUDA context for device(%d): %d", _cu_device, status);
-    return false;
-  }
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Success: Created context for device: %d", _cu_device);
-  }
-
-  Gpu::initialized_gpu(new Ptx());
-
-  return true;
-GPU_END
-
-GPU_ENTRY(jint, Ptx::get_total_cores, (JNIEnv *env, jobject))
-
-    int minor, major, nmp;
-    int status = _cuda_cu_device_get_attribute(&minor,
-                                               GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
-                                               _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get minor attribute of device: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&major,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get major attribute of device: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&nmp,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get number of MPs on device: %d", _cu_device);
-        return 0;
-    }
-
-    int total = nmp * ncores(major, minor);
-
-    int max_threads_per_block, warp_size, async_engines, can_map_host_memory, concurrent_kernels;
-
-    status = _cuda_cu_device_get_attribute(&max_threads_per_block,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&warp_size,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&async_engines,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&can_map_host_memory,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY: %d", _cu_device);
-        return 0;
-    }
-
-    status = _cuda_cu_device_get_attribute(&concurrent_kernels,
-                                           GRAAL_CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS,
-                                           _cu_device);
-
-    if (status != GRAAL_CUDA_SUCCESS) {
-        tty->print_cr("[CUDA] Failed to get GRAAL_CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS: %d", _cu_device);
-        return 0;
-    }
-
-    if (TraceGPUInteraction) {
-        tty->print_cr("[CUDA] Number of cores: %d async engines: %d can map host mem: %d concurrent kernels: %d",
-                      total, async_engines, can_map_host_memory, concurrent_kernels);
-        tty->print_cr("[CUDA] Max threads per block: %d warp size: %d", max_threads_per_block, warp_size);
-    }
-    return total;
-GPU_END
-
-GPU_ENTRY(jlong, Ptx::generate_kernel, (JNIEnv *env, jclass, jbyteArray code_handle, jstring name_handle))
-  ResourceMark rm;
-  jsize name_len = env->GetStringLength(name_handle);
-  jsize code_len = env->GetArrayLength(code_handle);
-
-  char* name = NEW_RESOURCE_ARRAY(char, name_len + 1);
-  unsigned char *code = NEW_RESOURCE_ARRAY(unsigned char, code_len + 1);
-
-  code[code_len] = 0;
-  name[name_len] = 0;
-
-  env->GetByteArrayRegion(code_handle, 0, code_len, (jbyte*) code);
-  env->GetStringUTFRegion(name_handle, 0, name_len, name);
-
-  struct CUmod_st * cu_module;
-  // Use three JIT compiler options
-  const unsigned int jit_num_options = 3;
-  int *jit_options = NEW_RESOURCE_ARRAY(int, jit_num_options);
-  void **jit_option_values = NEW_RESOURCE_ARRAY(void *, jit_num_options);
-
-  // Set up PTX JIT compiler options
-  // 1. set size of compilation log buffer
-  int jit_log_buffer_size = 1024;
-  jit_options[0] = GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES;
-  jit_option_values[0] = (void *)(size_t)jit_log_buffer_size;
-
-  // 2. set pointer to compilation log buffer
-  char *jit_log_buffer = NEW_RESOURCE_ARRAY(char, jit_log_buffer_size);
-  jit_options[1] = GRAAL_CU_JIT_INFO_LOG_BUFFER;
-  jit_option_values[1] = jit_log_buffer;
-
-  // 3. set pointer to set the maximum number of registers (32) for the kernel
-  int jit_register_count = 32;
-  jit_options[2] = GRAAL_CU_JIT_MAX_REGISTERS;
-  jit_option_values[2] = (void *)(size_t)jit_register_count;
-
-  // Set CUDA context to compile and execute the kernel
-
-  if (_device_context == NULL) {
-    tty->print_cr("[CUDA] Encountered uninitialized CUDA context for device(%d)", _cu_device);
-      return 0L;
-  }
-
-  int status = _cuda_cu_ctx_set_current(_device_context);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] Failed to set current context for device: %d", _cu_device);
-    return 0L;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Success: Set current context for device: %d", _cu_device);
-    tty->print_cr("[CUDA] PTX Kernel\n%s", code);
-    tty->print_cr("[CUDA] Function name : %s", name);
-  }
-
-  /* Load module's data with compiler options */
-  status = _cuda_cu_module_load_data_ex(&cu_module, (void*) code, jit_num_options,
-                                        jit_options, (void **)jit_option_values);
-  if (status != GRAAL_CUDA_SUCCESS) {
-    if (status == GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU) {
-      tty->print_cr("[CUDA] Check for malformed PTX kernel or incorrect PTX compilation options");
-    }
-    tty->print_cr("[CUDA] *** Error (%d) Failed to load module data with online compiler options for method %s",
-                  status, name);
-    return 0L;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Loaded data for PTX Kernel");
-  }
-
-  struct CUfunc_st* cu_function;
-  status = _cuda_cu_module_get_function(&cu_function, cu_module, name);
-
-  if (status != GRAAL_CUDA_SUCCESS) {
-    tty->print_cr("[CUDA] *** Error: Failed to get function %s", name);
-    return 0L;
-  }
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Got function handle for %s kernel address %p", name, cu_function);
-  }
-  return (jlong) cu_function;
-GPU_END
-
-// A PtxCall is used to manage executing a GPU kernel. In addition to launching
-// the kernel, this class releases resources allocated for the execution.
-class PtxCall: StackObj {
- private:
-  JavaThread*  _thread;        // the thread on which this call is made
-  address      _buffer;        // buffer containing parameters and _return_value
-  int          _buffer_size;   // size (in bytes) of _buffer
-  oop*         _pinned;        // objects that have been pinned with cuMemHostRegister
-  int          _pinned_length; // length of _pinned
-  Ptx::CUdeviceptr  _ret_value;     // pointer to slot in GPU memory holding the return value
-  int          _ret_type_size; // size of the return type value
-  bool         _ret_is_object; // specifies if the return type is Object
-  bool         _gc_locked;     // denotes when execution has locked GC
-
-  bool check(int status, const char *action) {
-    if (status != GRAAL_CUDA_SUCCESS) {
-      Thread* THREAD = _thread;
-      ResourceMark rm(THREAD);
-      char* message = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, O_BUFLEN + 1);
-      jio_snprintf(message, O_BUFLEN, "[CUDA] *** Error (status=%d): %s", status, action);
-      if (TraceGPUInteraction) {
-        tty->print_raw_cr(message);
-      }
-      if (!HAS_PENDING_EXCEPTION) {
-        SharedRuntime::throw_and_post_jvmti_exception(_thread, vmSymbols::java_lang_RuntimeException(), message);
-      }
-      return false;
-    }
-    if (TraceGPUInteraction) {
-      tty->print_cr("[CUDA] Success: %s", action);
-    }
-    return true;
-  }
-
- public:
-  PtxCall(JavaThread* thread, address buffer, int buffer_size, oop* pinned, int encodedReturnTypeSize) : _thread(thread), _gc_locked(false),
-      _buffer(buffer), _buffer_size(buffer_size), _pinned(pinned), _pinned_length(0), _ret_value(0), _ret_is_object(encodedReturnTypeSize < 0) {
-    _ret_type_size = _ret_is_object ? -encodedReturnTypeSize : encodedReturnTypeSize;
-  }
-
-  bool is_object_return() { return _ret_is_object; }
-
-  void alloc_return_value() {
-    if (_ret_type_size != 0) {
-      if (check(Ptx::_cuda_cu_memalloc(&_ret_value, _ret_type_size), "Allocate device memory for return value")) {
-        Ptx::CUdeviceptr* retValuePtr = (Ptx::CUdeviceptr*) ((_buffer + _buffer_size) - sizeof(_ret_value));
-        *retValuePtr = _ret_value;
-      }
-    }
-  }
-
-  void pin_objects(int count, int* objectOffsets) {
-    if (count == 0) {
-      return;
-    }
-    // Once we start pinning objects, no GC must occur
-    // until the kernel has completed. This is a big
-    // hammer for ensuring we can safely pass objects
-    // to the GPU.
-    GC_locker::lock_critical(_thread);
-    _gc_locked = true;
-    if (TraceGPUInteraction) {
-      tty->print_cr("[CUDA] Locked GC");
-    }
-
-    for (int i = 0; i < count; i++) {
-      int offset = objectOffsets[i];
-      oop* argPtr = (oop*) (_buffer + offset);
-      oop obj = *argPtr;
-      if (obj != NULL) {
-        // Size (in bytes) of object
-        int objSize = obj->size() * HeapWordSize;
-        //tty->print_cr("Pinning object %d at offset %d: %p", i, offset, obj);
-        if (!check(Ptx::_cuda_cu_mem_host_register(obj, objSize, GRAAL_CU_MEMHOSTREGISTER_DEVICEMAP), "Pin object")) {
-          return;
-        }
-
-        // Record original oop so that its memory can be unpinned
-        _pinned[_pinned_length++] = obj;
-
-        // Replace host pointer to object with device pointer
-        // to object in kernel parameters buffer
-        if (!check(Ptx::_cuda_cu_mem_host_get_device_pointer((Ptx::CUdeviceptr*) argPtr, obj, 0), "Get device pointer for pinned object")) {
-          return;
-        }
-      }
-    }
-  }
-
-  void launch(address kernel, jint dimX, jint dimY, jint dimZ) {
-    // grid dimensionality
-    unsigned int gridX = 1;
-    unsigned int gridY = 1;
-    unsigned int gridZ = 1;
-    void * config[] = {
-      GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER, (char*) (address) _buffer,
-      GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE, &_buffer_size,
-      GRAAL_CU_LAUNCH_PARAM_END
-    };
-    if (check(Ptx::_cuda_cu_launch_kernel((struct CUfunc_st*) (address) kernel,
-                                      gridX, gridY, gridZ,
-                                      dimX, dimY, dimZ,
-                                      0, NULL, NULL, (void**) &config), "Launch kernel")) {
-    }
-  }
-
-  void synchronize() {
-    check(Ptx::_cuda_cu_ctx_synchronize(), "Synchronize kernel");
-  }
-
-  void unpin_objects() {
-    while (_pinned_length > 0) {
-      oop obj = _pinned[--_pinned_length];
-      assert(obj != NULL, "npe");
-      //tty->print_cr("Unpinning object %d: %p", _pinned_length, obj);
-      if (!check(Ptx::_cuda_cu_mem_host_unregister(obj), "Unpin object")) {
-        return;
-      }
-    }
-  }
-
-  oop get_object_return_value() {
-    oop return_val;
-    check(Ptx::_cuda_cu_memcpy_dtoh(&return_val, _ret_value, T_OBJECT_BYTE_SIZE), "Copy return value from device");
-    return return_val;
-  }
-
-  jlong get_primitive_return_value() {
-    jlong return_val;
-    check(Ptx::_cuda_cu_memcpy_dtoh(&return_val, _ret_value, _ret_type_size), "Copy return value from device");
-    return return_val;
-  }
-
-  void free_return_value() {
-    if (_ret_value != 0) {
-      check(Ptx::_cuda_cu_memfree(_ret_value), "Free device memory");
-      _ret_value = 0;
-    }
-  }
-
-  ~PtxCall() {
-    unpin_objects();
-    free_return_value();
-    if (_gc_locked) {
-      GC_locker::unlock_critical(_thread);
-      if (TraceGPUInteraction) {
-        tty->print_cr("[CUDA] Unlocked GC");
-      }
-      _gc_locked = false;
-    }
-  }
-};
-
-// Prints values in the kernel arguments buffer
-class KernelArgumentsPrinter: public SignatureIterator {
-  Method*       _method;
-  address       _buffer;
-  size_t        _bufferOffset;
-  outputStream* _st;
-
-private:
-
-  // Get next java argument
-  oop next_arg(BasicType expectedType);
-
- public:
-  KernelArgumentsPrinter(Method* method, address buffer, outputStream* st) : SignatureIterator(method->signature()),
-    _method(method), _buffer(buffer), _bufferOffset(0), _st(st) {
-    if (!method->is_static()) {
-      print_oop();
-    }
-    iterate();
-  }
-
-  address next(size_t dataSz) {
-    if (is_return_type()) {
-      return _buffer;
-    }
-    if (_bufferOffset != 0) {
-      _st->print(", ");
-    }
-    _bufferOffset = align_size_up_(_bufferOffset, dataSz);
-    address result = _buffer + _bufferOffset;
-    _bufferOffset += dataSz;
-    return result;
-  }
-
-  void print_oop() {
-    oop obj = *((oop*) next(sizeof(oop)));
-    if (obj != NULL) {
-      char type[256];
-      obj->klass()->name()->as_C_string(type, 256);
-      _st->print("oop "INTPTR_FORMAT" (%s)", p2i(obj), type);
-    } else {
-      _st->print("oop null");
-    }
-  }
-
-  bool skip() {
-    return is_return_type();
-  }
-
-  void do_bool  ()                     { if (!skip()) _st->print("bool %d",    *((jboolean*) next(sizeof(jboolean)))); }
-  void do_char  ()                     { if (!skip()) _st->print("char %c",    *((jchar*)    next(sizeof(jchar))));    }
-  void do_float ()                     { if (!skip()) _st->print("float %g",   *((jfloat*)   next(sizeof(jfloat))));   }
-  void do_double()                     { if (!skip()) _st->print("double %g",  *((jdouble*)  next(sizeof(jdouble))));  }
-  void do_byte  ()                     { if (!skip()) _st->print("byte %d",    *((jbyte*)    next(sizeof(jbyte))));    }
-  void do_short ()                     { if (!skip()) _st->print("short %d",   *((jshort*)   next(sizeof(jshort))));   }
-  void do_int   ()                     { if (!skip()) _st->print("int %d",     *((jint*)     next(sizeof(jint))));     }
-  void do_long  ()                     { if (!skip()) _st->print("long "JLONG_FORMAT,  *((jlong*)    next(sizeof(jlong))));    }
-  void do_void  ()                     { }
-  void do_object(int begin, int end)   { if (!skip()) print_oop();      }
-  void do_array (int begin, int end)   { if (!skip()) print_oop();      }
-};
-
-static void printKernelArguments(JavaThread* thread, address buffer) {
-  for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
-    Method* m = vfst.method();
-    if (m != NULL) {
-      ResourceMark rm;
-      stringStream st(O_BUFLEN);
-      st.print("[CUDA] Call: %s.%s(", m->method_holder()->name()->as_C_string(), m->name()->as_C_string());
-      KernelArgumentsPrinter kap(m, buffer, &st);
-      tty->print_cr("%s)", st.as_string());
-      return;
-    }
-  }
-}
-
-GPU_VMENTRY(void, Ptx::destroy_ptx_context, (void))
-    if (_device_context != NULL) {
-      int status = _cuda_cu_ctx_destroy(_device_context);
-      if (status != GRAAL_CUDA_SUCCESS) {
-        if (TraceGPUInteraction) {
-          tty->print_cr("[CUDA] Error(%d) : Failed to destroy context", status);
-        }
-      _device_context = NULL;
-      } else {
-        if (TraceGPUInteraction) {
-          tty->print_cr("[CUDA] Destroyed context");
-        }
-      }
-    }
-
-GPU_END
-
-GPU_VMENTRY(jlong, Ptx::get_execute_kernel_from_vm_address, (JNIEnv *env, jclass))
-  return (jlong) Ptx::execute_kernel_from_vm;
-GPU_END
-
-JRT_ENTRY(jlong, Ptx::execute_kernel_from_vm(JavaThread* thread, jlong kernel, jint dimX, jint dimY, jint dimZ,
-                                                  jlong buffer,
-                                                  jint bufferSize,
-                                                  jint objectParametersCount,
-                                                  jlong objectParametersOffsets,
-                                                  jlong pinnedObjects,
-                                                  int encodedReturnTypeSize))
-  if (kernel == 0L) {
-    SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL);
-    return 0L;
-  }
-
-  if (TraceGPUInteraction) {
-    printKernelArguments(thread, (address) buffer);
-  }
-
-  PtxCall call(thread, (address) buffer, bufferSize, (oop*) (address) pinnedObjects, encodedReturnTypeSize);
-
-#define TRY(action) do { \
-  action; \
-  if (HAS_PENDING_EXCEPTION) return 0L; \
-} while (0)
-
-  TRY(call.alloc_return_value());
-
-  TRY(call.pin_objects(objectParametersCount, (int*) (address) objectParametersOffsets));
-
-  TRY(call.launch((address) kernel, dimX, dimY, dimZ));
-
-  TRY(call.synchronize());
-
-  if (call.is_object_return()) {
-    oop return_val;
-    TRY(return_val = call.get_object_return_value());
-    thread->set_vm_result(return_val);
-    return 0L;
-  }
-
-  jlong return_val;
-  TRY(return_val = call.get_primitive_return_value());
-  return return_val;
-
-#undef TRY
-
-JRT_END
-
-#if defined(LINUX)
-static const char cuda_library_name[] = "/usr/lib/libcuda.so";
-#elif defined(__APPLE__)
-static char const cuda_library_name[] = "/usr/local/cuda/lib/libcuda.dylib";
-#else
-static char const cuda_library_name[] = "";
-#endif
-
-bool Ptx::link() {
-  if (cuda_library_name == NULL) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Failed to find CUDA linkage");
-    }
-    return false;
-  }
-  char ebuf[O_BUFLEN];
-  void *handle = os::dll_load(cuda_library_name, ebuf, O_BUFLEN);
-  if (handle == NULL) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Unsupported CUDA platform: %s", ebuf);
-    }
-    return false;
-  }
-
-  LOOKUP_CUDA_FUNCTION(cuInit, cuda_cu_init);
-  LOOKUP_CUDA_FUNCTION(cuCtxSynchronize, cuda_cu_ctx_synchronize);
-  LOOKUP_CUDA_FUNCTION(cuCtxGetCurrent, cuda_cu_ctx_get_current);
-  LOOKUP_CUDA_FUNCTION(cuCtxSetCurrent, cuda_cu_ctx_set_current);
-  LOOKUP_CUDA_FUNCTION(cuDeviceGetCount, cuda_cu_device_get_count);
-  LOOKUP_CUDA_FUNCTION(cuDeviceGetName, cuda_cu_device_get_name);
-  LOOKUP_CUDA_FUNCTION(cuDeviceGet, cuda_cu_device_get);
-  LOOKUP_CUDA_FUNCTION(cuDeviceComputeCapability, cuda_cu_device_compute_capability);
-  LOOKUP_CUDA_FUNCTION(cuDeviceGetAttribute, cuda_cu_device_get_attribute);
-  LOOKUP_CUDA_FUNCTION(cuModuleGetFunction, cuda_cu_module_get_function);
-  LOOKUP_CUDA_FUNCTION(cuModuleLoadDataEx, cuda_cu_module_load_data_ex);
-  LOOKUP_CUDA_FUNCTION(cuLaunchKernel, cuda_cu_launch_kernel);
-  LOOKUP_CUDA_FUNCTION(cuMemHostRegister, cuda_cu_mem_host_register);
-  LOOKUP_CUDA_FUNCTION(cuMemHostUnregister, cuda_cu_mem_host_unregister);
-#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
-  LOOKUP_CUDA_V2_FUNCTION(cuCtxCreate, cuda_cu_ctx_create);
-  LOOKUP_CUDA_V2_FUNCTION(cuCtxDestroy, cuda_cu_ctx_destroy);
-  LOOKUP_CUDA_V2_FUNCTION(cuMemAlloc, cuda_cu_memalloc);
-  LOOKUP_CUDA_V2_FUNCTION(cuMemFree, cuda_cu_memfree);
-  LOOKUP_CUDA_V2_FUNCTION(cuMemcpyHtoD, cuda_cu_memcpy_htod);
-  LOOKUP_CUDA_V2_FUNCTION(cuMemcpyDtoH, cuda_cu_memcpy_dtoh);
-  LOOKUP_CUDA_V2_FUNCTION(cuMemHostGetDevicePointer, cuda_cu_mem_host_get_device_pointer);
-#else
-  LOOKUP_CUDA_FUNCTION(cuCtxCreate, cuda_cu_ctx_create);
-  LOOKUP_CUDA_FUNCTION(cuCtxDestroy, cuda_cu_ctx_destroy);
-  LOOKUP_CUDA_FUNCTION(cuMemAlloc, cuda_cu_memalloc);
-  LOOKUP_CUDA_FUNCTION(cuMemFree, cuda_cu_memfree);
-  LOOKUP_CUDA_FUNCTION(cuMemcpyHtoD, cuda_cu_memcpy_htod);
-  LOOKUP_CUDA_FUNCTION(cuMemcpyDtoH, cuda_cu_memcpy_dtoh);
-  LOOKUP_CUDA_FUNCTION(cuMemHostGetDevicePointer, cuda_cu_mem_host_get_device_pointer);
-#endif
-
-  if (TraceGPUInteraction) {
-    tty->print_cr("[CUDA] Success: library linkage");
-  }
-  return true;
-}
--- a/src/gpu/ptx/vm/gpu_ptx.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +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 GPU_PTX_HPP
-#define GPU_PTX_HPP
-
-/*
- * Some useful macro definitions from publicly available cuda.h.
- * These definitions are for convenience.
- */
-#define GRAAL_CUDA_SUCCESS                                   0
-/**< Device shares a unified address space with the host */
-#define GRAAL_CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK     1
-#define GRAAL_CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING        41
-#define GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR  75
-#define GRAAL_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR  76
-#define GRAAL_CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT      16
-#define GRAAL_CU_DEVICE_ATTRIBUTE_WARP_SIZE                 10
-#define GRAAL_CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY       19
-#define GRAAL_CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS        31
-#define GRAAL_CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT        40
-#define GRAAL_CU_JIT_MAX_REGISTERS                           0
-#define GRAAL_CU_JIT_THREADS_PER_BLOCK                       1
-#define GRAAL_CU_JIT_INFO_LOG_BUFFER                         3
-#define GRAAL_CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES              4
-#define GRAAL_CUDA_ERROR_NO_BINARY_FOR_GPU                 209
-
-/*
- * Flags for cuMemHostRegister
- */
-
-#define GRAAL_CU_MEMHOSTREGISTER_PORTABLE                    1
-#define GRAAL_CU_MEMHOSTREGISTER_DEVICEMAP                   2
-
-/**
- * End of array terminator for the extra parameter to
- * ::cuLaunchKernel
- */
-#define GRAAL_CU_LAUNCH_PARAM_END            ((void*) 0x00)
-
-/**
- * Indicator that the next value in the  extra parameter to
- * ::cuLaunchKernel will be a pointer to a buffer containing all kernel
- * parameters used for launching kernel f.  This buffer needs to
- * honor all alignment/padding requirements of the individual parameters.
- * If ::GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE is not also specified in the
- *  extra array, then ::GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER will have no
- * effect.
- */
-#define GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER ((void*) 0x01)
-
-/**
- * Indicator that the next value in the  extra parameter to
- * ::cuLaunchKernel will be a pointer to a size_t which contains the
- * size of the buffer specified with ::GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER.
- * It is required that ::GRAAL_CU_LAUNCH_PARAM_BUFFER_POINTER also be specified
- * in the extra array if the value associated with
- * ::GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE is not zero.
- */
-#define GRAAL_CU_LAUNCH_PARAM_BUFFER_SIZE    ((void*) 0x02)
-
-/*
- * Context creation flags
- */
-
-#define GRAAL_CU_CTX_MAP_HOST            0x08
-#define GRAAL_CU_CTX_SCHED_BLOCKING_SYNC 0x04
-
-/**
- * Support compute capability 3.0 and later
- */
-
-#define GRAAL_SUPPORTED_COMPUTE_CAPABILITY_VERSION 3.0
-
-class Ptx : public Gpu {
-  friend class PtxCall;
-
-private:
-
-  static JNINativeMethod PTX_methods[];
-
-  // static native boolean initialize();
-  JNIEXPORT static jboolean JNICALL initialize(JNIEnv* env, jclass);
-
-  // static native long generateKernel(byte[] targetCode, String name);
-  JNIEXPORT static jlong JNICALL generate_kernel(JNIEnv *env, jclass, jbyteArray code_handle, jstring name_handle);
-
-  // static native long getLaunchKernelAddress();
-  JNIEXPORT static jlong JNICALL get_execute_kernel_from_vm_address(JNIEnv *env, jclass);
-
-  // static native int getAvailableProcessors0();
-  JNIEXPORT static jint JNICALL get_total_cores(JNIEnv *env, jobject);
-
-  JNIEXPORT static void JNICALL destroy_ptx_context();
-
-  // Links the CUDA driver library functions
-  static bool link();
-
-  static int ncores(int major, int minor);
-
-public:
-
-  virtual const char* name() { return "PTX"; }
-
-  // Registers the implementations for the native methods in PTXHotSpotBackend
-  static bool register_natives(JNIEnv* env);
-
-#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)
-  typedef unsigned long long CUdeviceptr;
-#else
-  typedef unsigned int CUdeviceptr;
-#endif
-
-typedef int CUdevice;     /* CUDA device */
-
-  static jlong execute_kernel_from_vm(JavaThread* thread, jlong kernel, jint dimX, jint dimY, jint dimZ,
-                                      jlong buffer,
-                                      jint bufferSize,
-                                      jint objectParametersCount,
-                                      jlong objectParametersOffsets,
-                                      jlong pinnedObjects,
-                                      int encodedReturnTypeSize);
-
-private:
-  typedef int (*cuda_cu_init_func_t)(unsigned int);
-  typedef int (*cuda_cu_ctx_create_func_t)(void*, unsigned int, CUdevice);
-  typedef int (*cuda_cu_ctx_destroy_func_t)(void*);
-  typedef int (*cuda_cu_ctx_synchronize_func_t)(void);
-  typedef int (*cuda_cu_ctx_get_current_func_t)(void*);
-  typedef int (*cuda_cu_ctx_set_current_func_t)(void*);
-  typedef int (*cuda_cu_device_get_count_func_t)(int*);
-  typedef int (*cuda_cu_device_get_name_func_t)(char*, int, int);
-  typedef int (*cuda_cu_device_get_func_t)(int*, int);
-  typedef int (*cuda_cu_device_compute_capability_func_t)(int*, int*, int);
-  typedef int (*cuda_cu_device_get_attribute_func_t)(int*, int, int);
-  typedef int (*cuda_cu_launch_kernel_func_t)(struct CUfunc_st*,
-                                              unsigned int, unsigned int, unsigned int,
-                                              unsigned int, unsigned int, unsigned int,
-                                              unsigned int, void*, void**, void**);
-  typedef int (*cuda_cu_module_get_function_func_t)(void*, void*, const char*);
-  typedef int (*cuda_cu_module_load_data_ex_func_t)(void*, void*, unsigned int, void*, void**);
-  typedef int (*cuda_cu_memalloc_func_t)(Ptx::CUdeviceptr*, size_t);
-  typedef int (*cuda_cu_memfree_func_t)(Ptx::CUdeviceptr);
-  typedef int (*cuda_cu_memcpy_htod_func_t)(Ptx::CUdeviceptr, const void*, unsigned int);
-  typedef int (*cuda_cu_memcpy_dtoh_func_t)(const void*, Ptx::CUdeviceptr,  unsigned int);
-  typedef int (*cuda_cu_mem_host_register_func_t)(void*, size_t, unsigned int);
-  typedef int (*cuda_cu_mem_host_get_device_pointer_func_t)(Ptx::CUdeviceptr*, void*, unsigned int);
-  typedef int (*cuda_cu_mem_host_unregister_func_t)(void*);
-
-public:
-  static cuda_cu_init_func_t                      _cuda_cu_init;
-  static cuda_cu_ctx_create_func_t                _cuda_cu_ctx_create;
-  static cuda_cu_ctx_destroy_func_t               _cuda_cu_ctx_destroy;
-  static cuda_cu_ctx_synchronize_func_t           _cuda_cu_ctx_synchronize;
-  static cuda_cu_device_get_count_func_t          _cuda_cu_device_get_count;
-  static cuda_cu_device_get_name_func_t           _cuda_cu_device_get_name;
-  static cuda_cu_device_get_func_t                _cuda_cu_device_get;
-  static cuda_cu_device_compute_capability_func_t _cuda_cu_device_compute_capability; /* Deprecated as of CUDA 5.0 */
-  static cuda_cu_device_get_attribute_func_t      _cuda_cu_device_get_attribute;
-  static cuda_cu_launch_kernel_func_t             _cuda_cu_launch_kernel;
-  static cuda_cu_module_get_function_func_t       _cuda_cu_module_get_function;
-  static cuda_cu_module_load_data_ex_func_t       _cuda_cu_module_load_data_ex;
-  static cuda_cu_memalloc_func_t                  _cuda_cu_memalloc;
-  static cuda_cu_memfree_func_t                   _cuda_cu_memfree;
-  static cuda_cu_memcpy_htod_func_t               _cuda_cu_memcpy_htod;
-  static cuda_cu_memcpy_dtoh_func_t               _cuda_cu_memcpy_dtoh;
-  static cuda_cu_ctx_get_current_func_t           _cuda_cu_ctx_get_current;
-  static cuda_cu_ctx_set_current_func_t           _cuda_cu_ctx_set_current;
-  static cuda_cu_mem_host_register_func_t         _cuda_cu_mem_host_register;
-  static cuda_cu_mem_host_get_device_pointer_func_t _cuda_cu_mem_host_get_device_pointer;
-  static cuda_cu_mem_host_unregister_func_t        _cuda_cu_mem_host_unregister;
-
-protected:
-  static void* _device_context;
-  static int _cu_device;
-};
-#endif // GPU_PTX_HPP
--- a/src/os/bsd/vm/gpu_bsd.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.
- *
- */
-
-#include "runtime/gpu.hpp"
-#include "ptx/vm/gpu_ptx.hpp"
-#include "hsail/vm/gpu_hsail.hpp"
-#include "utilities/ostream.hpp"
-
-jobject Gpu::probe_gpus(JNIEnv* env) {
-#ifdef __APPLE__
-  /*
-   * Let the CUDA driver initialization be the gate to GPU for now, pending
-   * a better detection solution for NVIDA PTX and AMD HSAIL.
-   */
-  if (Ptx::register_natives(env)) {
-    if (TraceGPUInteraction) {
-      tty->print_cr("Assuming NVidia/PTX support (APPLE)");
-    }
-    return env->NewStringUTF("PTX");
-  }
-#else
-  if (TraceGPUInteraction) {
-    tty->print_cr("Assuming no GPU (not APPLE)");
-  }
-#endif
-  return env->NewStringUTF("");
-}
-
--- a/src/os/linux/vm/gpu_linux.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +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.
- *
- */
-
-#include "runtime/gpu.hpp"
-#include "ptx/vm/gpu_ptx.hpp"
-#include "hsail/vm/gpu_hsail.hpp"
-#include "utilities/ostream.hpp"
-
-/*
- * Probe for CUDA device on PCI bus using /proc/bus/pci/devices. Do
- * not rely on CUDA tool kit being installed. We will check if CUDA
- * library is installed later.
- */
-
-static unsigned int nvidia_vendor_id = 0x10de;
-static unsigned int amd_vendor_id = 0x1002;
-
-#define PCI_DRIVER_NAME_START_POS 255
-
-jobject Gpu::probe_gpus(JNIEnv* env) {
-  bool hsail = false;
-  bool ptx = false;
-
-  if (Hsail::register_natives(env)) {
-    hsail = true;
-  }
-
-  /*
-   * Open /proc/bus/pci/devices to look for the first GPU device. For
-   * now, we will just find the first GPU device. Will need to revisit
-   * this to support execution on multiple GPU devices, if they exist.
-   */
-  FILE *pci_devices = fopen("/proc/bus/pci/devices", "r");
-  char contents[4096];
-  unsigned int bus_num_devfn_ign;
-  unsigned int vendor;
-  unsigned int device;
-  const char *driver_name_string = "nvidia";
-  const int driver_name_string_len = strlen(driver_name_string);
-
-  if (pci_devices == NULL) {
-    tty->print_cr("*** Failed to open /proc/bus/pci/devices");
-    return NULL;
-  }
-
-  while (fgets(contents, sizeof(contents)-1, pci_devices)) {
-    sscanf(contents, "%04x%04x%04x", &bus_num_devfn_ign, &vendor, &device);
-    if (vendor == nvidia_vendor_id) {
-      /* Check if this device is registered to be using nvidia driver */
-      if (strncmp(&contents[PCI_DRIVER_NAME_START_POS],
-                  driver_name_string, driver_name_string_len) == 0) {
-        if (TraceGPUInteraction) {
-          tty->print_cr("Found supported nVidia device [vendor=0x%04x, device=0x%04x]", vendor, device);
-        }
-        if (!ptx && Ptx::register_natives(env)) {
-          ptx = true;
-        }
-      }
-    }
-  }
-
-  // Close file pointer.
-  fclose(pci_devices);
-
-  const char* gpus = "";
-  if (ptx && hsail) {
-    gpus = "PTX,HSAIL";
-  } else if (ptx) {
-    gpus = "PTX";
-  } else if (hsail) {
-    gpus = "HSAIL";
-  }
-  return env->NewStringUTF(gpus);
-}
--- a/src/os/windows/vm/gpu_windows.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/gpu.hpp"
-#include "hsail/vm/gpu_hsail.hpp"
-#include "utilities/ostream.hpp"
-
-jobject Gpu::probe_gpus(JNIEnv* env) {
-  // TODO: add detection of PTX/NVidia
-  if (Hsail::register_natives(env)) {
-    return env->NewStringUTF("HSAIL");
-  }
-  return env->NewStringUTF("");
-}
--- a/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java	Wed Jan 28 19:32:47 2015 +0100
@@ -25,9 +25,13 @@
 
 import java.awt.Graphics2D;
 import java.io.Writer;
+import java.io.File;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import org.w3c.dom.DOMImplementation;
 
 /**
@@ -53,7 +57,13 @@
     public static Graphics2D createGraphicsObject() {
         try {
             if (SVGGraphics2DConstructor == null) {
-                ClassLoader cl = BatikSVG.class.getClassLoader();
+                String batikJar = System.getenv().get("IGV_BATIK_JAR");
+                if (batikJar == null) {
+                    return null;
+                }
+		// Load batik in it's own class loader since some it's support jars interfere with the JDK
+                URL url = new File(batikJar).toURI().toURL();
+                ClassLoader cl = new URLClassLoader(new URL[] { url });
                 Class<?> classGenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation");
                 Class<?> classSVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext");
                 classSVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D");
@@ -79,6 +89,8 @@
             return null;
         } catch (InstantiationException e) {
             return null;
+        } catch (MalformedURLException e) {
+            return null;
         }
     }
 
--- a/src/share/vm/classfile/javaClasses.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/classfile/javaClasses.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -1566,18 +1566,6 @@
     return;
   }
   
-#ifdef GRAAL
-  // Check for gpu exception to add as top frame
-  Method* gpu_method = thread->get_gpu_exception_method();
-  if (gpu_method != NULL) {
-    jint gpu_bci = thread->get_gpu_exception_bci();
-    bt.push(gpu_method, gpu_bci, CHECK);
-    // Clear the gpu exception state, it is not used after here
-    thread->set_gpu_exception_bci(0);
-    thread->set_gpu_exception_method(NULL);  
-  }
-#endif
-
   // Instead of using vframe directly, this version of fill_in_stack_trace
   // basically handles everything by hand. This significantly improved the
   // speed of this method call up to 28.5% on Solaris sparc. 27.1% on Windows.
--- a/src/share/vm/classfile/systemDictionary.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/classfile/systemDictionary.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -223,7 +223,6 @@
   GRAAL_ONLY(do_klass(CompilationResult_Mark_klass,          com_oracle_graal_api_code_CompilationResult_Mark,             Graal)) \
   GRAAL_ONLY(do_klass(CompilationResult_Infopoint_klass,     com_oracle_graal_api_code_CompilationResult_Infopoint,        Graal)) \
   GRAAL_ONLY(do_klass(CompilationResult_Site_klass,          com_oracle_graal_api_code_CompilationResult_Site,             Graal)) \
-  GRAAL_ONLY(do_klass(ExternalCompilationResult_klass,       com_oracle_graal_gpu_ExternalCompilationResult,               Graal)) \
   GRAAL_ONLY(do_klass(InfopointReason_klass,                 com_oracle_graal_api_code_InfopointReason,                    Graal)) \
   GRAAL_ONLY(do_klass(InstalledCode_klass,                   com_oracle_graal_api_code_InstalledCode,                      Graal)) \
   GRAAL_ONLY(do_klass(code_Register_klass,                   com_oracle_graal_api_code_Register,                           Graal)) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/classfile/vmSymbols.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -349,7 +349,6 @@
   GRAAL_ONLY(template(com_oracle_graal_api_code_RegisterSaveLayout,             "com/oracle/graal/api/code/RegisterSaveLayout"))                  \
   GRAAL_ONLY(template(com_oracle_graal_api_code_InvalidInstalledCodeException,  "com/oracle/graal/api/code/InvalidInstalledCodeException"))       \
   GRAAL_ONLY(template(com_oracle_graal_api_code_SpeculationLog,                 "com/oracle/graal/api/code/SpeculationLog"))                      \
-  GRAAL_ONLY(template(com_oracle_graal_gpu_ExternalCompilationResult,           "com/oracle/graal/gpu/ExternalCompilationResult"))                \
   GRAAL_ONLY(template(compileMetaspaceMethod_name,               "compileMetaspaceMethod"))                                                       \
   GRAAL_ONLY(template(compileMetaspaceMethod_signature,          "(JIJI)V"))                                                                      \
   GRAAL_ONLY(template(graal_mirror_name,                         "graal_mirror"))                                                                 \
--- a/src/share/vm/code/nmethod.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/code/nmethod.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -182,7 +182,6 @@
   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
   unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
   unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
-  unsigned int _external_method:1;           // Set for GPU methods
 
   // Protected by Patching_lock
   volatile unsigned char _state;             // {alive, not_entrant, zombie, unloaded}
@@ -477,9 +476,6 @@
   bool  has_method_handle_invokes() const         { return _has_method_handle_invokes; }
   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 
-  bool  is_external_method() const                { return _external_method; }
-  void  set_external_method(bool z)               { _external_method = z; }
-
   bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
   void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
 
--- a/src/share/vm/gc_interface/collectedHeap.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/gc_interface/collectedHeap.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -526,12 +526,7 @@
          "Attempt to fill tlabs before main thread has been added"
          " to threads list is doomed to failure!");
   for (JavaThread *thread = Threads::first(); thread; thread = thread->next()) {
-     if (use_tlab) {
-       thread->tlab().make_parsable(retire_tlabs);
-#ifdef GRAAL
-       thread->gpu_hsail_tlabs_make_parsable(retire_tlabs);
-#endif
-     }     
+     if (use_tlab) thread->tlab().make_parsable(retire_tlabs);
 #if defined(COMPILER2) || defined(GRAAL)
      // The deferred store barriers must all have been flushed to the
      // card-table (or other remembered set structure) before GC starts
--- a/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/gc_interface/collectedHeap.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -84,7 +84,6 @@
 class CollectedHeap : public CHeapObj<mtInternal> {
   friend class VMStructs;
   friend class IsGCActiveMark; // Block structured external access to _is_gc_active
-  friend class HSAILAllocationInfo;  // access to allocate_new_tlab
 
 #ifdef ASSERT
   static int       _fire_out_of_memory_count;
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -347,12 +347,7 @@
       if (isLongArray && cur_second == NULL) {
         // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations.
         // add an int 0 constant
-#ifdef VM_LITTLE_ENDIAN
         cur_second = _int_0_scope_value;
-#else
-        cur_second = value;
-        value = _int_0_scope_value;
-#endif
       }
 
       if (cur_second != NULL) {
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -43,7 +43,6 @@
 #include "runtime/vframe.hpp"
 #include "runtime/vframe_hp.hpp"
 #include "runtime/vmStructs.hpp"
-#include "runtime/gpu.hpp"
 
 
 // Entry to native method implementation that transitions current thread to '_thread_in_vm'.
@@ -477,12 +476,7 @@
       InstalledCode::set_address(installed_code_handle, (jlong) cb);
       InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1);
       oop comp_result = HotSpotCompiledCode::comp(compiled_code_handle);
-      if (comp_result->is_a(ExternalCompilationResult::klass())) {
-        if (TraceGPUInteraction) {
-          tty->print_cr("installCode0: ExternalCompilationResult");
-        }
-        HotSpotInstalledCode::set_codeStart(installed_code_handle, ExternalCompilationResult::entryPoint(comp_result));
-      } else if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) {
+      if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) {
         HotSpotInstalledCode::set_size(installed_code_handle, cb->size());
         HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin());
         HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size());
@@ -716,18 +710,6 @@
   return (jlongArray) JNIHandles::make_local(arrayOop);
 C2V_END
 
-// In general we should avoid using regular JNI methods to interact with the JVM but this
-// particular case is just about registering JNI methods so it should be a regular native
-// method.
-JNIEXPORT jobject JNICALL c2v_getGPUs (JNIEnv* env, jobject) {
-  TRACE_graal_3("CompilerToVM::getGPUs" );
-#if defined(TARGET_OS_FAMILY_bsd) || defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_windows)
-  return Gpu::probe_gpus(env);
-#else
-  return env->NewStringUTF("");
-#endif
-}
-
 C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci))
   HandleMark hm;
   ResourceMark rm;
@@ -1091,7 +1073,6 @@
   {CC"readUnsafeKlassPointer",                       CC"("OBJECT")J",                                                          FN_PTR(readUnsafeKlassPointer)},
   {CC"readUnsafeOop",                                CC"("OBJECT"JZ)"OBJECT,                                                   FN_PTR(readUnsafeOop)},
   {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)},
--- a/src/share/vm/graal/graalEnv.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalEnv.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -556,10 +556,6 @@
 
         }
       }
-      
-      if (TraceGPUInteraction && HotSpotNmethod::isExternal(installed_code())) {
-        tty->print_cr("External method:%s", method()->name_and_sig_as_C_string());
-      }
     }
   }
   // JVMTI -- compiled method notification (must be done outside lock)
--- a/src/share/vm/graal/graalGlobals.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalGlobals.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -96,19 +96,6 @@
                                                                             \
   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, UseHSAILSafepoints, true,                                   \
-          "Code gen and runtime support for safepoints in HSAIL kernels")   \
-                                                                            \
-  product(bool, GPUOffload, false,                                          \
-          "Offload execution to GPU whenever possible")                     \
-                                                                            \
-  product(bool, TraceGPUInteraction, false,                                 \
-          "Trace external GPU Interaction")                                 \
-                                                                            \
 
 
 // Read default values for Graal globals
--- a/src/share/vm/graal/graalJavaAccess.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -66,7 +66,6 @@
   end_class                                                                                                                                                    \
   start_class(HotSpotNmethod)                                                                                                                                  \
     boolean_field(HotSpotNmethod, isDefault)                                                                                                                   \
-    boolean_field(HotSpotNmethod, isExternal)                                                                                                                  \
   end_class                                                                                                                                                    \
   start_class(HotSpotCompiledCode)                                                                                                                             \
     oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/graal/api/code/CompilationResult;")                                                                      \
@@ -93,9 +92,6 @@
   start_class(HotSpotForeignCallLinkageImpl)                                                                                                                   \
     long_field(HotSpotForeignCallLinkageImpl, address)                                                                                                         \
   end_class                                                                                                                                                    \
-  start_class(ExternalCompilationResult)                                                                                                                       \
-    long_field(ExternalCompilationResult, entryPoint)                                                                                                          \
-  end_class                                                                                                                                                    \
   start_class(CompilationResult)                                                                                                                               \
     int_field(CompilationResult, totalFrameSize)                                                                                                               \
     int_field(CompilationResult, customStackAreaOffset)                                                                                                        \
--- a/src/share/vm/graal/graalRuntime.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalRuntime.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -38,7 +38,6 @@
 #include "runtime/reflection.hpp"
 #include "utilities/debug.hpp"
 
-address GraalRuntime::_external_deopt_i2c_entry = NULL;
 jobject GraalRuntime::_HotSpotGraalRuntime_instance = NULL;
 bool GraalRuntime::_HotSpotGraalRuntime_initialized = false;
 bool GraalRuntime::_shutdown_called = false;
@@ -60,13 +59,6 @@
 
     graal_compute_offsets();
 
-#ifdef TARGET_ARCH_x86
-#ifdef _LP64
-    // Only supported on x86_64 for now
-    _external_deopt_i2c_entry = create_external_deopt_i2c();
-#endif
-#endif
-
     // Ensure _non_oop_bits is initialized
     Universe::non_oop_word();
 
@@ -89,39 +81,6 @@
   return buffer_blob;
 }
 
-address GraalRuntime::create_external_deopt_i2c() {
-  ResourceMark rm;
-  BufferBlob* buffer = BufferBlob::create("externalDeopt", 1*K);
-  CodeBuffer cb(buffer);
-  short buffer_locs[20];
-  cb.insts()->initialize_shared_locs((relocInfo*)buffer_locs, sizeof(buffer_locs)/sizeof(relocInfo));
-  MacroAssembler masm(&cb);
-
-  int total_args_passed = 6;
-
-  BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
-  VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
-  int i = 0;
-  sig_bt[i++] = T_INT;
-  sig_bt[i++] = T_LONG;
-  sig_bt[i++] = T_VOID; // long stakes 2 slots
-  sig_bt[i++] = T_INT;
-  sig_bt[i++] = T_OBJECT;
-  sig_bt[i++] = T_INT; // The number of actual arguments passed to the method.
-
-  int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
-
-  SharedRuntime::gen_i2c_adapter(&masm, total_args_passed, comp_args_on_stack, sig_bt, regs, total_args_passed - 1);
-  masm.flush();
-
-  AdapterBlob* adapter = AdapterBlob::create(&cb);
-  if (PrintAdapterHandlers) {
-    tty->print_cr("Decoding external_deopt_i2c");
-    Disassembler::decode(adapter->code_begin(), adapter->code_end());
-  }
-  return adapter->code_begin();
-}
-
 BasicType GraalRuntime::kindToBasicType(jchar ch) {
   switch(ch) {
     case 'z': return T_BOOLEAN;
@@ -684,7 +643,7 @@
   KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL);
 
   TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", CHECK_NULL);
-  TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", CHECK_NULL);
+  TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/truffle/api/TruffleRuntime;", CHECK_NULL);
   JavaValue result(T_OBJECT);
   JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL);
   return JNIHandles::make_local((oop) result.get_jobject());
--- a/src/share/vm/graal/graalRuntime.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/graal/graalRuntime.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -33,7 +33,6 @@
 
   static jobject _HotSpotGraalRuntime_instance;
   static bool _HotSpotGraalRuntime_initialized;
-  static address _external_deopt_i2c_entry;
   static const char* _generated_sources_sha1;
 
   static bool _shutdown_called;
@@ -222,11 +221,6 @@
   static bool parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS);
 
   static BasicType kindToBasicType(jchar ch);
-  static address create_external_deopt_i2c();
-  static address get_external_deopt_i2c_entry() {
-    guarantee(_external_deopt_i2c_entry != NULL, "unsupported");
-    return _external_deopt_i2c_entry;
-  }
 
   // The following routines are all called from compiled Graal code
 
--- a/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -54,13 +54,6 @@
   for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
     thread->tlab().accumulate_statistics();
     thread->tlab().initialize_statistics();
-#ifdef GRAAL
-    for (jint i = 0; i < thread->get_gpu_hsail_tlabs_count(); i++) {
-      thread->get_gpu_hsail_tlab_at(i)->accumulate_statistics();
-      thread->get_gpu_hsail_tlab_at(i)->initialize_statistics();
-    }
-#endif
-
   }
 
   // Publish new stats if some allocation occurred.
@@ -147,11 +140,6 @@
   if (ResizeTLAB) {
     for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
       thread->tlab().resize();
-#ifdef GRAAL
-      for (jint i = 0; i < thread->get_gpu_hsail_tlabs_count(); i++) {
-        thread->get_gpu_hsail_tlab_at(i)->resize();
-      }
-#endif
     }
   }
 }
@@ -209,12 +197,11 @@
   invariants();
 }
 
-void ThreadLocalAllocBuffer::initialize(Thread* owning_thread) {
+void ThreadLocalAllocBuffer::initialize() {
   initialize(NULL,                    // start
              NULL,                    // top
              NULL);                   // end
 
-  _owning_thread = owning_thread;
   set_desired_size(initial_desired_size());
 
   // Following check is needed because at startup the main (primordial)
@@ -243,7 +230,7 @@
   // During jvm startup, the main (primordial) thread is initialized
   // before the heap is initialized.  So reinitialize it now.
   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
-  Thread::current()->tlab().initialize(Thread::current());
+  Thread::current()->tlab().initialize();
 
   if (PrintTLAB && Verbose) {
     gclog_or_tty->print("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT "\n",
@@ -307,7 +294,9 @@
 }
 
 Thread* ThreadLocalAllocBuffer::myThread() {
-  return _owning_thread;
+  return (Thread*)(((char *)this) +
+                   in_bytes(start_offset()) -
+                   in_bytes(Thread::tlab_start_offset()));
 }
 
 
--- a/src/share/vm/memory/threadLocalAllocBuffer.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/memory/threadLocalAllocBuffer.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -38,9 +38,6 @@
 //            used to make it available for such multiplexing.
 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
   friend class VMStructs;
-#ifdef GRAAL
-  friend class HSAILAllocationInfo;
-#endif
 private:
   HeapWord* _start;                              // address of TLAB
   HeapWord* _top;                                // address after last allocation
@@ -58,7 +55,6 @@
   unsigned  _slow_refill_waste;
   unsigned  _gc_waste;
   unsigned  _slow_allocations;
-  Thread*   _owning_thread;
 
   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs
 
@@ -160,7 +156,7 @@
   static void resize_all_tlabs();
 
   void fill(HeapWord* start, HeapWord* top, size_t new_size);
-  void initialize(Thread* owning_thread);
+  void initialize();
 
   static size_t refill_waste_limit_increment()   { return TLABWasteIncrement; }
 
--- a/src/share/vm/runtime/compilationPolicy.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/compilationPolicy.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -45,9 +45,6 @@
 #include "runtime/vm_operations.hpp"
 #include "utilities/events.hpp"
 #include "utilities/globalDefinitions.hpp"
-#ifdef GRAAL
-#include "runtime/gpu.hpp"
-#endif
 
 CompilationPolicy* CompilationPolicy::_policy;
 elapsedTimer       CompilationPolicy::_accumulated_time;
--- a/src/share/vm/runtime/gpu.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.
- *
- */
-
-#include "precompiled.hpp"
-#include "runtime/gpu.hpp"
-#include "runtime/handles.hpp"
-
-int  Gpu::_initialized_gpus_count = 0;
-Gpu* Gpu::_initialized_gpus[MAX_GPUS];
-
-void Gpu::initialized_gpu(Gpu* gpu) {
-  // GPUs are always initialized on the same thread so no need for locking
-  guarantee(_initialized_gpus_count < MAX_GPUS, "oob");
-  _initialized_gpus[_initialized_gpus_count++] = gpu;
-  if (TraceGPUInteraction) {
-    tty->print_cr("[GPU] registered initialization of %s (total initialized: %d)", gpu->name(), _initialized_gpus_count);
-  }
-}
-
-void Gpu::safepoint_event(SafepointEvent event) {
-  for (int i = 0; i < _initialized_gpus_count; i++) {
-    if (event == SafepointBegin) {
-      _initialized_gpus[i]->notice_safepoints();
-    } else {
-      _initialized_gpus[i]->ignore_safepoints();
-    }
-  }
-}
--- a/src/share/vm/runtime/gpu.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +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 SHARE_VM_RUNTIME_GPU_HPP
-#define SHARE_VM_RUNTIME_GPU_HPP
-
-#include "runtime/atomic.hpp"
-#include "oops/symbol.hpp"
-#include "utilities/array.hpp"
-
-#define MAX_GPUS 2
-
-// Defines the interface to the graphics processor(s).
-class Gpu : public CHeapObj<mtInternal> {
- private:
-  static int _initialized_gpus_count;
-  static Gpu* _initialized_gpus[MAX_GPUS];
-
- public:
-
-  // Notification of a GPU device that has been initialized.
-  static void initialized_gpu(Gpu* gpu);
-
-  // Gets a comma separated list of supported GPU architecture names.
-  static jobject probe_gpus(JNIEnv* env);
-  
-  // Gets the number of GPU devices that have been initialized.
-  static int initialized_gpus() { return _initialized_gpus_count; }
-
-  enum SafepointEvent {
-    SafepointBegin,
-    SafepointEnd
-  };
-
-  // Called when a safepoint has been activated.
-  static void safepoint_event(SafepointEvent event);
-
-  // Name of this GPU
-  virtual const char* name() = 0;
-
-  // Called when a safepoint has been activated.
-  virtual void notice_safepoints() {};
-
-  // Called when a safepoint has been deactivated.
-  virtual void ignore_safepoints() {};
-};
-
-#endif // SHARE_VM_RUNTIME_GPU_HPP
--- a/src/share/vm/runtime/javaCalls.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/javaCalls.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -48,7 +48,7 @@
 // -----------------------------------------------------
 // Implementation of JavaCallWrapper
 
-JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, JavaValue* result, TRAPS) {
+JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
   JavaThread* thread = (JavaThread *)THREAD;
   bool clear_pending_exception = true;
 
@@ -79,9 +79,10 @@
   // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing
   // the JavaCallWrapper before the entry frame is on the stack.
   _callee_method = callee_method();
+  _receiver = receiver();
 
 #ifdef CHECK_UNHANDLED_OOPS
-  // THREAD->allow_unhandled_oop(&_receiver);
+  THREAD->allow_unhandled_oop(&_receiver);
 #endif // CHECK_UNHANDLED_OOPS
 
   _thread       = (JavaThread *)thread;
@@ -145,6 +146,7 @@
 
 
 void JavaCallWrapper::oops_do(OopClosure* f) {
+  f->do_oop((oop*)&_receiver);
   handles()->oops_do(f);
 }
 
@@ -321,7 +323,7 @@
   // Check if we need to wrap a potential OS exception handler around thread
   // This is used for e.g. Win32 structured exception handlers
   assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls");
-  // Need to wrap each and everytime, since there might be native code down the
+  // Need to wrap each and every time, since there might be native code down the
   // stack that has installed its own exception handlers
   os::os_exception_wrapper(call_helper, result, &method, args, THREAD);
 }
@@ -341,7 +343,7 @@
   nmethod* nm = args->alternative_target();
   if (nm == NULL) {
 #endif
-  // Verify the arguments
+// Verify the arguments
 
   if (CheckJNICalls)  {
     args->verify(method, result->get_type(), thread);
@@ -350,6 +352,7 @@
 #ifdef GRAAL
   }
 #else
+
   // Ignore call if method is empty
   if (method->is_empty_method()) {
     assert(result->get_type() == T_VOID, "an empty method must return a void value");
@@ -357,13 +360,12 @@
   }
 #endif
 
-
 #ifdef ASSERT
   { InstanceKlass* holder = method->method_holder();
     // A klass might not be initialized since JavaCall's might be used during the executing of
     // the <clinit>. For example, a Thread.start might start executing on an object that is
     // not fully initialized! (bad Java programming style)
-    assert(holder->is_linked(), "rewritting must have taken place");
+    assert(holder->is_linked(), "rewriting must have taken place");
   }
 #endif
 
@@ -392,6 +394,9 @@
   // the call to call_stub, the optimizer produces wrong code.
   intptr_t* result_val_address = (intptr_t*)(result->get_value_addr());
 
+  // Find receiver
+  Handle receiver = (!method->is_static()) ? args->receiver() : Handle();
+
   // When we reenter Java, we need to reenable the yellow zone which
   // might already be disabled when we are in VM.
   if (thread->stack_yellow_zone_disabled()) {
@@ -413,12 +418,7 @@
   if (nm != NULL) {
     if (nm->is_alive()) {
       ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point());
-      oop graalInstalledCode = nm->graal_installed_code();
-      if (graalInstalledCode != NULL && graalInstalledCode->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isExternal(graalInstalledCode)) {
-        entry_point = GraalRuntime::get_external_deopt_i2c_entry();
-      } else {
-        entry_point = method->adapter()->get_i2c_entry();
-      }
+      entry_point = method->adapter()->get_i2c_entry();
     } else {
       THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException());
     }
@@ -426,7 +426,7 @@
 #endif
   
   // do call
-  { JavaCallWrapper link(method, result, CHECK);
+  { JavaCallWrapper link(method, receiver, result, CHECK);
     { HandleMark hm(thread);  // HandleMark used by HandleMarkCleaner
 
       StubRoutines::call_stub()(
--- a/src/share/vm/runtime/javaCalls.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/javaCalls.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -57,6 +57,7 @@
   JavaThread*      _thread;                 // the thread to which this call belongs
   JNIHandleBlock*  _handles;                // the saved handle block
   Method*          _callee_method;          // to be able to collect arguments if entry frame is top frame
+  oop              _receiver;               // the receiver of the call (if a non-static call)
 
   JavaFrameAnchor  _anchor;                 // last thread anchor state that we must restore
 
@@ -64,7 +65,7 @@
 
  public:
   // Construction/destruction
-   JavaCallWrapper(methodHandle callee_method, JavaValue* result, TRAPS);
+   JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS);
   ~JavaCallWrapper();
 
   // Accessors
@@ -76,6 +77,7 @@
   JavaValue*       result() const           { return _result; }
   // GC support
   Method*          callee_method()          { return _callee_method; }
+  oop              receiver()               { return _receiver; }
   void             oops_do(OopClosure* f);
 
   bool             is_first_frame() const   { return _anchor.last_Java_sp() == NULL; }
--- a/src/share/vm/runtime/safepoint.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/safepoint.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -39,7 +39,6 @@
 #include "runtime/compilationPolicy.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/frame.inline.hpp"
-#include "runtime/gpu.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/osThread.hpp"
@@ -208,12 +207,6 @@
     os::make_polling_page_unreadable();
   }
 
-#ifdef GRAAL
-  if (UseHSAILSafepoints) {
-    Gpu::safepoint_event(Gpu::SafepointBegin);
-  }
-#endif
-  
   // Consider using active_processor_count() ... but that call is expensive.
   int ncpus = os::processor_count() ;
 
@@ -447,12 +440,6 @@
   // Remove safepoint check from interpreter
   Interpreter::ignore_safepoints();
 
-#ifdef GRAAL
-  if (UseHSAILSafepoints) {
-    Gpu::safepoint_event(Gpu::SafepointEnd);
-  }
-#endif
-
   {
     MutexLocker mu(Safepoint_lock);
 
--- a/src/share/vm/runtime/thread.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/thread.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -54,10 +54,6 @@
 #include "runtime/deoptimization.hpp"
 #include "runtime/fprofiler.hpp"
 #include "runtime/frame.inline.hpp"
-#include "runtime/gpu.hpp"
-#ifdef GRAAL
-# include "hsail/vm/gpu_hsail.hpp"
-#endif
 #include "runtime/init.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/java.hpp"
@@ -1479,13 +1475,6 @@
   clear_must_deopt_id();
   set_monitor_chunks(NULL);
   set_next(NULL);
-#ifdef GRAAL
-  set_gpu_exception_bci(0);
-  set_gpu_exception_method(NULL);  
-  set_gpu_hsail_deopt_info(NULL);
-  _gpu_hsail_tlabs_count = 0;
-  _gpu_hsail_tlabs = NULL;
-#endif
   set_thread_state(_thread_new);
 #if INCLUDE_NMT
   set_recorder(NULL);
@@ -1704,8 +1693,6 @@
     }
     FREE_C_HEAP_ARRAY(jlong, _graal_counters, mtInternal);
   }
-
-  delete_gpu_hsail_tlabs();
 #endif // GRAAL
 }
 
@@ -1980,7 +1967,7 @@
   remove_stack_guard_pages();
 
   if (UseTLAB) {
-    tlabs_make_parsable(true);   // retire TLABs, if any
+    tlab().make_parsable(true);  // retire TLAB
   }
 
   if (JvmtiEnv::environments_might_exist()) {
@@ -2059,7 +2046,7 @@
   remove_stack_guard_pages();
 
   if (UseTLAB) {
-    tlabs_make_parsable(true);   // retire TLABs, if any
+    tlab().make_parsable(true);  // retire TLAB, if any
   }
 
 #if INCLUDE_ALL_GCS
@@ -2865,13 +2852,6 @@
     // a scan.
     cf->do_code_blob(_scanned_nmethod);
   }
-
-#ifdef GRAAL
-  Hsail::HSAILDeoptimizationInfo* gpu_hsail_deopt_info = (Hsail::HSAILDeoptimizationInfo*) get_gpu_hsail_deopt_info();
-  if (gpu_hsail_deopt_info != NULL) {
-    gpu_hsail_deopt_info->oops_do(f);
-  }
-#endif
 }
 
 void JavaThread::nmethods_do(CodeBlobClosure* cf) {
@@ -4791,54 +4771,3 @@
   VMThread* thread = VMThread::vm_thread();
   if (thread != NULL) thread->verify();
 }
-
-void JavaThread::tlabs_make_parsable(bool retire) {
-  // do the primary tlab for this thread
-  tlab().make_parsable(retire);
-#ifdef GRAAL
-  // do the gpu_hsail tlabs if any
-  gpu_hsail_tlabs_make_parsable(retire);
-#endif
-}
-
-
-#ifdef GRAAL
-void JavaThread::initialize_gpu_hsail_tlabs(jint count) {
-  if (!UseTLAB) return;
-  // create tlabs
-  _gpu_hsail_tlabs = NEW_C_HEAP_ARRAY(ThreadLocalAllocBuffer*, count, mtInternal);
-  // initialize
-  for (jint i = 0; i < count; i++) {
-    _gpu_hsail_tlabs[i] = new ThreadLocalAllocBuffer();
-    _gpu_hsail_tlabs[i]->initialize(Thread::current());
-  }
-  _gpu_hsail_tlabs_count = count;
-}
-
-ThreadLocalAllocBuffer* JavaThread::get_gpu_hsail_tlab_at(jint idx) {
-  assert(idx >= 0 && idx < get_gpu_hsail_tlabs_count(), "illegal gpu tlab index");
-  return _gpu_hsail_tlabs[idx];
-}
-
-void JavaThread::gpu_hsail_tlabs_make_parsable(bool retire) {
-  for (jint i = 0; i < get_gpu_hsail_tlabs_count(); i++) {
-    get_gpu_hsail_tlab_at(i)->make_parsable(retire);
-  }
-}
-
-void JavaThread::delete_gpu_hsail_tlabs() {
-  if (!UseTLAB) return;
-  if (_gpu_hsail_tlabs_count == 0) return;
-
-  gpu_hsail_tlabs_make_parsable(true);
-  for (jint i = 0; i < get_gpu_hsail_tlabs_count(); i++) {
-    delete get_gpu_hsail_tlab_at(i);
-  }
-  FREE_C_HEAP_ARRAY(ThreadLocalAllocBuffer*, _gpu_hsail_tlabs, mtInternal);
-  _gpu_hsail_tlabs = NULL;
-  _gpu_hsail_tlabs_count = 0;
-}
-
-
-#endif
-
--- a/src/share/vm/runtime/thread.hpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/thread.hpp	Wed Jan 28 19:32:47 2015 +0100
@@ -432,7 +432,7 @@
   ThreadLocalAllocBuffer& tlab()                 { return _tlab; }
   void initialize_tlab() {
     if (UseTLAB) {
-      tlab().initialize(this);
+      tlab().initialize();
     }
   }
 
@@ -944,36 +944,7 @@
   volatile address _exception_handler_pc;        // PC for handler of exception
   volatile int     _is_method_handle_return;     // true (== 1) if the current exception PC is a MethodHandle call site.
 
-#ifdef GRAAL
-  // Record the method and bci from a gpu kernel exception so
-  // it can be added into the exception stack trace
-  jint    _gpu_exception_bci;
-  Method* _gpu_exception_method;
-  // Record the hsailDeoptimization info so gc oops_do processing can find it
-  void*   _gpu_hsail_deopt_info;
-  jint    _gpu_hsail_tlabs_count;
-  ThreadLocalAllocBuffer** _gpu_hsail_tlabs;
-#endif
-
- public:
-#ifdef GRAAL
-  void set_gpu_exception_bci(jint bci)           { _gpu_exception_bci = bci; } 
-  jint get_gpu_exception_bci()                   { return _gpu_exception_bci; }
-  void set_gpu_exception_method(Method* method)  { _gpu_exception_method = method; }
-  Method* get_gpu_exception_method()             { return _gpu_exception_method; }
-  void set_gpu_hsail_deopt_info(void * deoptInfo) { _gpu_hsail_deopt_info = deoptInfo; }
-  void* get_gpu_hsail_deopt_info()               { return _gpu_hsail_deopt_info; }
-  jint  get_gpu_hsail_tlabs_count()              { return _gpu_hsail_tlabs_count; }
-
-  void  initialize_gpu_hsail_tlabs(jint count);
-  ThreadLocalAllocBuffer* get_gpu_hsail_tlab_at(jint idx);
-  void gpu_hsail_tlabs_make_parsable(bool retire);
-  void  delete_gpu_hsail_tlabs();
-#endif
-
  private:  
-  void tlabs_make_parsable(bool retire);
-
   // support for JNI critical regions
   jint    _jni_active_critical;                  // count of entries into JNI critical region
 
--- a/src/share/vm/runtime/vmStructs.cpp	Wed Jan 28 19:12:57 2015 +0100
+++ b/src/share/vm/runtime/vmStructs.cpp	Wed Jan 28 19:32:47 2015 +0100
@@ -93,7 +93,6 @@
 #include "runtime/deoptimization.hpp"
 #include "runtime/vframeArray.hpp"
 #include "runtime/globals.hpp"
-#include "runtime/gpu.hpp"
 #include "runtime/java.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/perfMemory.hpp"
@@ -110,7 +109,6 @@
 #ifdef GRAAL
 # include "graal/graalRuntime.hpp"
 # include "graal/vmStructs_graal.hpp"
-# include "hsail/vm/vmStructs_hsail.hpp"
 #endif
 #ifdef TARGET_ARCH_x86
 # include "vmStructs_x86.hpp"
@@ -3054,10 +3052,6 @@
                  GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY,
                  GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
 
-#ifdef GRAAL
-  VM_STRUCTS_GPU_HSAIL(GENERATE_NONSTATIC_VM_STRUCT_ENTRY)
-#endif
-          
   VM_STRUCTS_OS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
                     GENERATE_STATIC_VM_STRUCT_ENTRY,
                     GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
@@ -3108,11 +3102,6 @@
                GENERATE_C2_VM_TYPE_ENTRY,
                GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)
 
-#ifdef GRAAL
-  VM_TYPES_GPU_HSAIL(GENERATE_VM_TYPE_ENTRY,
-               GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
-#endif
-
   VM_TYPES_OS_CPU(GENERATE_VM_TYPE_ENTRY,
                   GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
                   GENERATE_OOP_VM_TYPE_ENTRY,
@@ -3218,10 +3207,6 @@
                  CHECK_NO_OP,
                  CHECK_NO_OP);
 
-#ifdef GRAAL
-  VM_STRUCTS_GPU_HSAIL(CHECK_NONSTATIC_VM_STRUCT_ENTRY)
-#endif
-
   VM_STRUCTS_OS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
                     CHECK_STATIC_VM_STRUCT_ENTRY,
                     CHECK_NO_OP,
@@ -3262,11 +3247,6 @@
                CHECK_C2_VM_TYPE_ENTRY,
                CHECK_C2_TOPLEVEL_VM_TYPE_ENTRY);
 
-#ifdef GRAAL
-  VM_TYPES_GPU_HSAIL(CHECK_VM_TYPE_ENTRY,
-               CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
-#endif
-
   VM_TYPES_OS_CPU(CHECK_VM_TYPE_ENTRY,
                   CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
                   CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
--- a/test/blacklist_sparc.txt	Wed Jan 28 19:12:57 2015 +0100
+++ b/test/blacklist_sparc.txt	Wed Jan 28 19:32:47 2015 +0100
@@ -1,3 +1,5 @@
 com.oracle.graal.replacements.test.StandardMethodSubstitutionsTest
 com.oracle.graal.hotspot.amd64.test.CompressedNullCheckTest
 com.oracle.graal.compiler.test.ea.UnsafeEATest
+com.oracle.graal.truffle.test.SimplePartialEvaluationTest
+com.oracle.graal.replacements.test.ArraysSubstitutionsTest