changeset 21709:3c17c0c41a6b

moved com.oracle.asm.**.test to JVMCI namespace (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 03 Jun 2015 18:33:23 +0200
parents 6df25b1418be
children 26774dc3a5e7
files graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/BitOpsTest.java graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/IncrementDecrementMacroTest.java graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StaticInterfaceFieldTest.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/BitOpsTest.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/IncrementDecrementMacroTest.java graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/SimpleAssemblerTest.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64Address.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64AsmOptions.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64Assembler.java graal/com.oracle.jvmci.asm.amd64/src/com/oracle/jvmci/asm/amd64/AMD64MacroAssembler.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAddress.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCAssembler.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCInstructionCounter.java graal/com.oracle.jvmci.asm.sparc/src/com/oracle/jvmci/asm/sparc/SPARCMacroAssembler.java graal/com.oracle.jvmci.asm.test/src/com/oracle/jvmci/asm/test/AssemblerTest.java graal/com.oracle.jvmci.asm/overview.html graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/AsmOptions.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Assembler.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Buffer.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/Label.java graal/com.oracle.jvmci.asm/src/com/oracle/jvmci/asm/NumUtil.java graal/com.oracle.jvmci.test/src/com/oracle/jvmci/test/TestBase.java mx/suite.py
diffstat 14 files changed, 1088 insertions(+), 1077 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/BitOpsTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-/*
- * 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.graal.asm.amd64.test;
-
-import com.oracle.graal.asm.test.*;
-import com.oracle.jvmci.amd64.*;
-import com.oracle.jvmci.amd64.AMD64.*;
-import com.oracle.jvmci.asm.amd64.*;
-import com.oracle.jvmci.code.RegisterConfig;
-import com.oracle.jvmci.code.TargetDescription;
-import com.oracle.jvmci.code.Register;
-import com.oracle.jvmci.code.CallingConvention;
-import com.oracle.jvmci.code.CompilationResult;
-import com.oracle.jvmci.meta.Kind;
-
-import static com.oracle.jvmci.asm.amd64.AMD64Assembler.AMD64RMOp.*;
-import static com.oracle.jvmci.asm.amd64.AMD64Assembler.OperandSize.*;
-import static com.oracle.jvmci.code.ValueUtil.*;
-import static com.oracle.jvmci.common.UnsafeAccess.*;
-import static org.junit.Assume.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.junit.*;
-
-public class BitOpsTest extends AssemblerTest {
-    private static boolean lzcntSupported;
-    private static boolean tzcntSupported;
-
-    @Before
-    public void checkAMD64() {
-        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
-        EnumSet<CPUFeature> features = ((AMD64) codeCache.getTarget().arch).getFeatures();
-        lzcntSupported = features.contains(CPUFeature.LZCNT);
-        tzcntSupported = features.contains(CPUFeature.BMI1);
-    }
-
-    @Test
-    public void lzcntlTest() {
-        if (lzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    Register arg = asRegister(cc.getArgument(0));
-                    LZCNT.emit(asm, DWORD, ret, arg);
-                    asm.ret(0);
-                    return asm.close(true);
-                }
-            };
-            assertReturn("intStub", test, 31, 1);
-        }
-    }
-
-    @Test
-    public void lzcntlMemTest() {
-        if (lzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    try {
-                        Field f = IntField.class.getDeclaredField("x");
-                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                        LZCNT.emit(asm, DWORD, ret, arg);
-                        asm.ret(0);
-                        return asm.close(true);
-                    } catch (Exception e) {
-                        throw new RuntimeException("exception while trying to generate field access:", e);
-                    }
-                }
-            };
-            assertReturn("intFieldStub", test, 31, new IntField(1));
-        }
-    }
-
-    @Test
-    public void lzcntqTest() {
-        if (lzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    Register arg = asRegister(cc.getArgument(0));
-                    LZCNT.emit(asm, QWORD, ret, arg);
-                    asm.ret(0);
-                    return asm.close(true);
-                }
-            };
-            assertReturn("longStub", test, 63, 1L);
-        }
-    }
-
-    @Test
-    public void lzcntqMemTest() {
-        if (lzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    try {
-                        Field f = LongField.class.getDeclaredField("x");
-                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                        LZCNT.emit(asm, QWORD, ret, arg);
-                        asm.ret(0);
-                        return asm.close(true);
-                    } catch (Exception e) {
-                        throw new RuntimeException("exception while trying to generate field access:", e);
-                    }
-                }
-            };
-            assertReturn("longFieldStub", test, 63, new LongField(1));
-        }
-    }
-
-    @Test
-    public void tzcntlTest() {
-        if (tzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    Register arg = asRegister(cc.getArgument(0));
-                    TZCNT.emit(asm, DWORD, ret, arg);
-                    asm.ret(0);
-                    return asm.close(true);
-                }
-            };
-            assertReturn("intStub", test, 31, 0x8000_0000);
-        }
-    }
-
-    @Test
-    public void tzcntlMemTest() {
-        if (tzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    try {
-                        Field f = IntField.class.getDeclaredField("x");
-                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                        TZCNT.emit(asm, DWORD, ret, arg);
-                        asm.ret(0);
-                        return asm.close(true);
-                    } catch (Exception e) {
-                        throw new RuntimeException("exception while trying to generate field access:", e);
-                    }
-                }
-            };
-            assertReturn("intFieldStub", test, 31, new IntField(0x8000_0000));
-        }
-    }
-
-    @Test
-    public void tzcntqTest() {
-        if (tzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    Register arg = asRegister(cc.getArgument(0));
-                    TZCNT.emit(asm, QWORD, ret, arg);
-                    asm.ret(0);
-                    return asm.close(true);
-                }
-            };
-            assertReturn("longStub", test, 63, 0x8000_0000_0000_0000L);
-        }
-    }
-
-    @Test
-    public void tzcntqMemTest() {
-        if (tzcntSupported) {
-            CodeGenTest test = new CodeGenTest() {
-
-                @Override
-                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                    Register ret = registerConfig.getReturnRegister(Kind.Int);
-                    try {
-                        Field f = LongField.class.getDeclaredField("x");
-                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                        TZCNT.emit(asm, QWORD, ret, arg);
-                        asm.ret(0);
-                        return asm.close(true);
-                    } catch (Exception e) {
-                        throw new RuntimeException("exception while trying to generate field access:", e);
-                    }
-                }
-            };
-            assertReturn("longFieldStub", test, 63, new LongField(0x8000_0000_0000_0000L));
-        }
-    }
-
-    @SuppressWarnings("unused")
-    public static int intStub(int arg) {
-        return 0;
-    }
-
-    @SuppressWarnings("unused")
-    public static int longStub(long arg) {
-        return 0;
-    }
-
-    public static class IntField {
-        public int x;
-
-        IntField(int x) {
-            this.x = x;
-        }
-    }
-
-    public static class LongField {
-        public long x;
-
-        LongField(long x) {
-            this.x = x;
-        }
-    }
-
-    @SuppressWarnings("unused")
-    public static int intFieldStub(IntField arg) {
-        return 0;
-    }
-
-    @SuppressWarnings("unused")
-    public static int longFieldStub(LongField arg) {
-        return 0;
-    }
-}
--- a/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/IncrementDecrementMacroTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * 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.asm.amd64.test;
-
-import com.oracle.graal.asm.test.*;
-import com.oracle.jvmci.amd64.*;
-import com.oracle.jvmci.asm.amd64.*;
-import com.oracle.jvmci.code.RegisterConfig;
-import com.oracle.jvmci.code.TargetDescription;
-import com.oracle.jvmci.code.Register;
-import com.oracle.jvmci.code.CallingConvention;
-import com.oracle.jvmci.code.CompilationResult;
-import com.oracle.jvmci.meta.Kind;
-
-import static com.oracle.jvmci.code.ValueUtil.*;
-import static com.oracle.jvmci.common.UnsafeAccess.*;
-import static org.junit.Assume.*;
-
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-public class IncrementDecrementMacroTest extends AssemblerTest {
-
-    @Before
-    public void checkAMD64() {
-        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
-    }
-
-    public static class LongField {
-        public long x;
-
-        LongField(long x) {
-            this.x = x;
-        }
-    }
-
-    private static class IncrementCodeGenTest implements CodeGenTest {
-        final int value;
-
-        public IncrementCodeGenTest(int value) {
-            this.value = value;
-        }
-
-        @Override
-        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-            AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
-            Register ret = registerConfig.getReturnRegister(Kind.Int);
-            try {
-                Field f = LongField.class.getDeclaredField("x");
-                AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                asm.incrementq(arg, value);
-                asm.movq(ret, arg);
-                asm.ret(0);
-                return asm.close(true);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to generate field access:", e);
-            }
-        }
-    }
-
-    private void assertIncrement(long initValue, int increment) {
-        assertReturn("longFieldStubIncrement", new IncrementCodeGenTest(increment), initValue + increment, new LongField(initValue));
-    }
-
-    private void assertIncrements(int increment) {
-        assertIncrement(0x4242_4242_4242_4242L, increment);
-    }
-
-    @SuppressWarnings("unused")
-    public static long longFieldStubIncrement(LongField arg) {
-        return 0;
-    }
-
-    private static class DecrementCodeGenTest implements CodeGenTest {
-        final int value;
-
-        public DecrementCodeGenTest(int value) {
-            this.value = value;
-        }
-
-        @Override
-        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-            AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
-            Register ret = registerConfig.getReturnRegister(Kind.Int);
-            try {
-                Field f = LongField.class.getDeclaredField("x");
-                AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
-                asm.decrementq(arg, value);
-                asm.movq(ret, arg);
-                asm.ret(0);
-                return asm.close(true);
-            } catch (Exception e) {
-                throw new RuntimeException("exception while trying to generate field access:", e);
-            }
-        }
-    }
-
-    private void assertDecrement(long initValue, int increment) {
-        assertReturn("longFieldStubDecrement", new DecrementCodeGenTest(increment), initValue - increment, new LongField(initValue));
-    }
-
-    private void assertDecrements(int increment) {
-        assertDecrement(0x4242_4242_4242_4242L, increment);
-    }
-
-    @SuppressWarnings("unused")
-    public static long longFieldStubDecrement(LongField arg) {
-        return 0;
-    }
-
-    @Test
-    public void incrementMemTest0() {
-        int increment = 0;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest1() {
-        int increment = 1;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest2() {
-        int increment = 2;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest3() {
-        int increment = Integer.MAX_VALUE;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest4() {
-        int increment = Integer.MIN_VALUE;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest5() {
-        int increment = -1;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest6() {
-        int increment = -2;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void incrementMemTest7() {
-        int increment = -0x1000_0000;
-        assertIncrements(increment);
-    }
-
-    @Test
-    public void decrementMemTest0() {
-        int decrement = 0;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest1() {
-        int decrement = 1;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest2() {
-        int decrement = 2;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest3() {
-        int decrement = Integer.MAX_VALUE;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest4() {
-        int decrement = Integer.MIN_VALUE;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest5() {
-        int decrement = -1;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest6() {
-        int decrement = -2;
-        assertDecrements(decrement);
-    }
-
-    @Test
-    public void decrementMemTest7() {
-        int decrement = -0x1000_0000;
-        assertDecrements(decrement);
-    }
-
-}
--- a/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +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.amd64.test;
-
-import com.oracle.graal.asm.test.*;
-import com.oracle.jvmci.amd64.*;
-import com.oracle.jvmci.asm.amd64.*;
-import com.oracle.jvmci.code.RegisterConfig;
-import com.oracle.jvmci.code.TargetDescription;
-import com.oracle.jvmci.code.Register;
-import com.oracle.jvmci.code.CallingConvention;
-import com.oracle.jvmci.code.CompilationResult;
-import com.oracle.jvmci.meta.JavaConstant;
-import com.oracle.jvmci.meta.Kind;
-
-import static org.junit.Assume.*;
-
-import java.nio.*;
-
-import org.junit.*;
-
-import com.oracle.jvmci.code.CompilationResult.DataSectionReference;
-import com.oracle.jvmci.code.DataSection.Data;
-import com.oracle.jvmci.code.DataSection.DataBuilder;
-
-public class SimpleAssemblerTest extends AssemblerTest {
-
-    @Before
-    public void checkAMD64() {
-        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
-    }
-
-    @Test
-    public void intTest() {
-        CodeGenTest test = new CodeGenTest() {
-
-            @Override
-            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
-                Register ret = registerConfig.getReturnRegister(Kind.Int);
-                asm.movl(ret, 8472);
-                asm.ret(0);
-                return asm.close(true);
-            }
-        };
-        assertReturn("intStub", test, 8472);
-    }
-
-    @Test
-    public void doubleTest() {
-        CodeGenTest test = new CodeGenTest() {
-
-            @Override
-            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
-                Register ret = registerConfig.getReturnRegister(Kind.Double);
-                Data data = new Data(8, 8, DataBuilder.serializable(JavaConstant.forDouble(84.72)));
-                DataSectionReference ref = compResult.getDataSection().insertData(data);
-                compResult.recordDataPatch(asm.position(), ref);
-                asm.movdbl(ret, asm.getPlaceholder());
-                asm.ret(0);
-                return asm.close(true);
-            }
-        };
-        assertReturn("doubleStub", test, 84.72);
-    }
-
-    @Test
-    public void rawDoubleTest() {
-        CodeGenTest test = new CodeGenTest() {
-
-            @Override
-            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
-                AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
-                Register ret = registerConfig.getReturnRegister(Kind.Double);
-
-                byte[] rawBytes = new byte[8];
-                ByteBuffer.wrap(rawBytes).order(ByteOrder.nativeOrder()).putDouble(84.72);
-                Data data = new Data(8, 8, DataBuilder.raw(rawBytes));
-                DataSectionReference ref = compResult.getDataSection().insertData(data);
-                compResult.recordDataPatch(asm.position(), ref);
-                asm.movdbl(ret, asm.getPlaceholder());
-                asm.ret(0);
-                return asm.close(true);
-            }
-        };
-        assertReturn("doubleStub", test, 84.72);
-    }
-
-    public static int intStub() {
-        return 0;
-    }
-
-    public static double doubleStub() {
-        return 0.0;
-    }
-}
--- a/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ /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.
- */
-package com.oracle.graal.asm.test;
-
-import java.lang.reflect.*;
-
-import org.junit.*;
-
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.phases.util.*;
-import com.oracle.graal.runtime.*;
-import com.oracle.graal.test.*;
-import com.oracle.jvmci.code.*;
-import com.oracle.jvmci.debug.*;
-import com.oracle.jvmci.debug.Debug.Scope;
-import com.oracle.jvmci.meta.*;
-import com.oracle.jvmci.service.*;
-
-public abstract class AssemblerTest extends GraalTest {
-
-    private final MetaAccessProvider metaAccess;
-    protected final CodeCacheProvider codeCache;
-
-    public interface CodeGenTest {
-        byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc);
-    }
-
-    public AssemblerTest() {
-        Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
-        this.metaAccess = providers.getMetaAccess();
-        this.codeCache = providers.getCodeCache();
-    }
-
-    public MetaAccessProvider getMetaAccess() {
-        return metaAccess;
-    }
-
-    protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
-        ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m);
-        try (Scope s = Debug.scope("assembleMethod", method, codeCache)) {
-            RegisterConfig registerConfig = codeCache.getRegisterConfig();
-            CallingConvention cc = CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false);
-
-            CompilationResult compResult = new CompilationResult();
-            byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
-            compResult.setTargetCode(targetCode, targetCode.length);
-            compResult.setTotalFrameSize(0);
-
-            InstalledCode code = codeCache.addMethod(method, compResult, null, null);
-
-            for (DisassemblerProvider dis : Services.load(DisassemblerProvider.class)) {
-                String disasm = dis.disassemble(code);
-                Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
-            }
-            return code;
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-    }
-
-    protected Object runTest(String methodName, CodeGenTest test, Object... args) {
-        Method method = getMethod(methodName);
-        InstalledCode code = assembleMethod(method, test);
-        try {
-            return code.executeVarargs(args);
-        } catch (InvalidInstalledCodeException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    protected void assertReturn(String methodName, CodeGenTest test, Object expected, Object... args) {
-        Object actual = runTest(methodName, test, args);
-        Assert.assertEquals("unexpected return value", expected, actual);
-    }
-}
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Jun 03 18:06:44 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java	Wed Jun 03 18:33:23 2015 +0200
@@ -33,6 +33,8 @@
 import com.oracle.jvmci.meta.ExcludeFromIdentityComparisonVerification;
 import com.oracle.jvmci.meta.MetaAccessProvider;
 import com.oracle.jvmci.meta.JavaField;
+import com.oracle.jvmci.test.*;
+
 import static com.oracle.jvmci.debug.DelegatingDebugConfig.Feature.*;
 
 import java.io.*;
@@ -62,14 +64,13 @@
 import com.oracle.graal.phases.verify.*;
 import com.oracle.graal.printer.*;
 import com.oracle.graal.runtime.*;
-import com.oracle.graal.test.*;
 import com.oracle.jvmci.debug.*;
 
 /**
  * Checks that all classes in graal*.jar from the boot classpath comply with global invariants such
  * as using {@link Object#equals(Object)} to compare certain types instead of identity comparisons.
  */
-public class CheckGraalInvariants extends GraalTest {
+public class CheckGraalInvariants extends TestBase {
 
     @Test
     public void test() {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -70,11 +70,11 @@
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.printer.*;
 import com.oracle.graal.runtime.*;
-import com.oracle.graal.test.*;
 import com.oracle.jvmci.common.*;
 import com.oracle.jvmci.debug.*;
 import com.oracle.jvmci.debug.Debug.Scope;
 import com.oracle.jvmci.options.*;
+import com.oracle.jvmci.test.*;
 
 /**
  * Base class for Graal compiler unit tests.
@@ -95,7 +95,7 @@
  * <p>
  * These tests will be run by the {@code mx unittest} command.
  */
-public abstract class GraalCompilerTest extends GraalTest {
+public abstract class GraalCompilerTest extends TestBase {
 
     private final Providers providers;
     private final Backend backend;
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StaticInterfaceFieldTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StaticInterfaceFieldTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -38,15 +38,15 @@
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.runtime.*;
-import com.oracle.graal.test.*;
 import com.oracle.jvmci.debug.*;
 import com.oracle.jvmci.meta.*;
+import com.oracle.jvmci.test.*;
 
 /**
  * Test that interfaces are correctly initialized by a static field resolution during eager graph
  * building.
  */
-public class StaticInterfaceFieldTest extends GraalTest {
+public class StaticInterfaceFieldTest extends TestBase {
 
     private interface I {
         Object CONST = new Object() {
--- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java	Wed Jun 03 18:06:44 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +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.test;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.junit.*;
-import org.junit.internal.*;
-
-/**
- * Base class for Graal tests.
- * <p>
- * This contains common utility methods and classes that are used in tests.
- */
-public class GraalTest {
-
-    protected Method getMethod(String methodName) {
-        return getMethod(getClass(), methodName);
-    }
-
-    protected Method getMethod(Class<?> clazz, String methodName) {
-        Method found = null;
-        for (Method m : clazz.getMethods()) {
-            if (m.getName().equals(methodName)) {
-                Assert.assertNull(found);
-                found = m;
-            }
-        }
-        if (found == null) {
-            /* Now look for non-public methods (but this does not look in superclasses). */
-            for (Method m : clazz.getDeclaredMethods()) {
-                if (m.getName().equals(methodName)) {
-                    Assert.assertNull(found);
-                    found = m;
-                }
-            }
-        }
-        if (found != null) {
-            return found;
-        } else {
-            throw new RuntimeException("method not found: " + methodName);
-        }
-    }
-
-    protected Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {
-        try {
-            return clazz.getMethod(methodName, parameterTypes);
-        } catch (NoSuchMethodException | SecurityException e) {
-            throw new RuntimeException("method not found: " + methodName + "" + Arrays.toString(parameterTypes));
-        }
-    }
-
-    /**
-     * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}.
-     * Does a deep copy equality comparison if {@code expected} is an array.
-     */
-    protected void assertDeepEquals(Object expected, Object actual) {
-        assertDeepEquals(null, expected, actual);
-    }
-
-    /**
-     * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}.
-     * Does a deep copy equality comparison if {@code expected} is an array.
-     *
-     * @param message the identifying message for the {@link AssertionError}
-     */
-    protected void assertDeepEquals(String message, Object expected, Object actual) {
-        if (ulpsDelta() > 0) {
-            assertDeepEquals(message, expected, actual, ulpsDelta());
-        } else {
-            assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta());
-        }
-    }
-
-    /**
-     * Compares two given values for equality, doing a recursive test if both values are arrays of
-     * the same type.
-     *
-     * @param message the identifying message for the {@link AssertionError}
-     * @param delta the maximum delta between two doubles or floats for which both numbers are still
-     *            considered equal.
-     */
-    protected void assertDeepEquals(String message, Object expected, Object actual, double delta) {
-        if (expected != null && actual != null) {
-            Class<?> expectedClass = expected.getClass();
-            Class<?> actualClass = actual.getClass();
-            if (expectedClass.isArray()) {
-                Assert.assertTrue(message, expected != null);
-                Assert.assertTrue(message, actual != null);
-                Assert.assertEquals(message, expectedClass, actual.getClass());
-                if (expected instanceof int[]) {
-                    Assert.assertArrayEquals(message, (int[]) expected, (int[]) actual);
-                } else if (expected instanceof byte[]) {
-                    Assert.assertArrayEquals(message, (byte[]) expected, (byte[]) actual);
-                } else if (expected instanceof char[]) {
-                    Assert.assertArrayEquals(message, (char[]) expected, (char[]) actual);
-                } else if (expected instanceof short[]) {
-                    Assert.assertArrayEquals(message, (short[]) expected, (short[]) actual);
-                } else if (expected instanceof float[]) {
-                    Assert.assertArrayEquals(message, (float[]) expected, (float[]) actual, (float) delta);
-                } else if (expected instanceof long[]) {
-                    Assert.assertArrayEquals(message, (long[]) expected, (long[]) actual);
-                } else if (expected instanceof double[]) {
-                    Assert.assertArrayEquals(message, (double[]) expected, (double[]) actual, delta);
-                } else if (expected instanceof boolean[]) {
-                    new ExactComparisonCriteria().arrayEquals(message, expected, actual);
-                } else if (expected instanceof Object[]) {
-                    new ComparisonCriteria() {
-                        @Override
-                        protected void assertElementsEqual(Object e, Object a) {
-                            assertDeepEquals(message, e, a, delta);
-                        }
-                    }.arrayEquals(message, expected, actual);
-                } else {
-                    Assert.fail((message == null ? "" : message) + "non-array value encountered: " + expected);
-                }
-            } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) {
-                Assert.assertEquals((double) expected, (double) actual, delta);
-            } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) {
-                Assert.assertEquals((float) expected, (float) actual, delta);
-            } else {
-                Assert.assertEquals(message, expected, actual);
-            }
-        } else {
-            Assert.assertEquals(message, expected, actual);
-        }
-    }
-
-    /**
-     * Compares two given values for equality, doing a recursive test if both values are arrays of
-     * the same type. Uses {@linkplain StrictMath#ulp(float) ULP}s for comparison of floats.
-     *
-     * @param message the identifying message for the {@link AssertionError}
-     * @param ulpsDelta the maximum allowed ulps difference between two doubles or floats for which
-     *            both numbers are still considered equal.
-     */
-    protected void assertDeepEquals(String message, Object expected, Object actual, int ulpsDelta) {
-        ComparisonCriteria doubleUlpsDeltaCriteria = new ComparisonCriteria() {
-            @Override
-            protected void assertElementsEqual(Object e, Object a) {
-                assertTrue(message, e instanceof Double && a instanceof Double);
-                // determine acceptable error based on whether it is a normal number or a NaN/Inf
-                double de = (Double) e;
-                double epsilon = (!Double.isNaN(de) && Double.isFinite(de) ? ulpsDelta * Math.ulp(de) : 0);
-                Assert.assertEquals(message, (Double) e, (Double) a, epsilon);
-            }
-        };
-
-        ComparisonCriteria floatUlpsDeltaCriteria = new ComparisonCriteria() {
-            @Override
-            protected void assertElementsEqual(Object e, Object a) {
-                assertTrue(message, e instanceof Float && a instanceof Float);
-                // determine acceptable error based on whether it is a normal number or a NaN/Inf
-                float fe = (Float) e;
-                float epsilon = (!Float.isNaN(fe) && Float.isFinite(fe) ? ulpsDelta * Math.ulp(fe) : 0);
-                Assert.assertEquals(message, (Float) e, (Float) a, epsilon);
-            }
-        };
-
-        if (expected != null && actual != null) {
-            Class<?> expectedClass = expected.getClass();
-            Class<?> actualClass = actual.getClass();
-            if (expectedClass.isArray()) {
-                Assert.assertEquals(message, expectedClass, actualClass);
-                if (expected instanceof double[] || expected instanceof Object[]) {
-                    doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual);
-                    return;
-                } else if (expected instanceof float[] || expected instanceof Object[]) {
-                    floatUlpsDeltaCriteria.arrayEquals(message, expected, actual);
-                    return;
-                }
-            } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) {
-                doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual);
-                return;
-            } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) {
-                floatUlpsDeltaCriteria.arrayEquals(message, expected, actual);
-                return;
-            }
-        }
-        // anything else just use the non-ulps version
-        assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta());
-    }
-
-    /**
-     * Gets the value used by {@link #assertDeepEquals(Object, Object)} and
-     * {@link #assertDeepEquals(String, Object, Object)} for the maximum delta between two doubles
-     * or floats for which both numbers are still considered equal.
-     */
-    protected double equalFloatsOrDoublesDelta() {
-        return 0.0D;
-    }
-
-    // unless overridden ulpsDelta is not used
-    protected int ulpsDelta() {
-        return 0;
-    }
-
-    @SuppressWarnings("serial")
-    public static class MultiCauseAssertionError extends AssertionError {
-
-        private Throwable[] causes;
-
-        public MultiCauseAssertionError(String message, Throwable... causes) {
-            super(message);
-            this.causes = causes;
-        }
-
-        @Override
-        public void printStackTrace(PrintStream out) {
-            super.printStackTrace(out);
-            int num = 0;
-            for (Throwable cause : causes) {
-                if (cause != null) {
-                    out.print("cause " + (num++));
-                    cause.printStackTrace(out);
-                }
-            }
-        }
-
-        @Override
-        public void printStackTrace(PrintWriter out) {
-            super.printStackTrace(out);
-            int num = 0;
-            for (Throwable cause : causes) {
-                if (cause != null) {
-                    out.print("cause " + (num++) + ": ");
-                    cause.printStackTrace(out);
-                }
-            }
-        }
-    }
-
-    /*
-     * Overrides to the normal JUnit {@link Assert} routines that provide varargs style formatting
-     * and produce an exception stack trace with the assertion frames trimmed out.
-     */
-
-    /**
-     * Fails a test with the given message.
-     *
-     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
-     *            okay)
-     * @see AssertionError
-     */
-    public static void fail(String message, Object... objects) {
-        AssertionError e;
-        if (message == null) {
-            e = new AssertionError();
-        } else {
-            e = new AssertionError(String.format(message, objects));
-        }
-        // Trim the assert frames from the stack trace
-        StackTraceElement[] trace = e.getStackTrace();
-        int start = 1; // Skip this frame
-        String thisClassName = GraalTest.class.getName();
-        while (start < trace.length && trace[start].getClassName().equals(thisClassName) && (trace[start].getMethodName().equals("assertTrue") || trace[start].getMethodName().equals("assertFalse"))) {
-            start++;
-        }
-        e.setStackTrace(Arrays.copyOfRange(trace, start, trace.length));
-        throw e;
-    }
-
-    /**
-     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the
-     * given message.
-     *
-     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
-     *            okay)
-     * @param condition condition to be checked
-     */
-    public static void assertTrue(String message, boolean condition) {
-        assertTrue(condition, message);
-    }
-
-    /**
-     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} without a
-     * message.
-     *
-     * @param condition condition to be checked
-     */
-    public static void assertTrue(boolean condition) {
-        assertTrue(condition, null);
-    }
-
-    /**
-     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} with the
-     * given message.
-     *
-     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
-     *            okay)
-     * @param condition condition to be checked
-     */
-    public static void assertFalse(String message, boolean condition) {
-        assertTrue(!condition, message);
-    }
-
-    /**
-     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} without a
-     * message.
-     *
-     * @param condition condition to be checked
-     */
-    public static void assertFalse(boolean condition) {
-        assertTrue(!condition, null);
-    }
-
-    /**
-     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the
-     * given message.
-     *
-     * @param condition condition to be checked
-     * @param message the identifying message for the {@link AssertionError}
-     * @param objects arguments to the format string
-     */
-    public static void assertTrue(boolean condition, String message, Object... objects) {
-        if (!condition) {
-            fail(message, objects);
-        }
-    }
-
-    /**
-     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} with the
-     * given message produced by {@link String#format}.
-     *
-     * @param condition condition to be checked
-     * @param message the identifying message for the {@link AssertionError}
-     * @param objects arguments to the format string
-     */
-    public static void assertFalse(boolean condition, String message, Object... objects) {
-        assertTrue(!condition, message, objects);
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/BitOpsTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -0,0 +1,267 @@
+/*
+ * 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.jvmci.asm.amd64.test;
+
+import com.oracle.jvmci.amd64.*;
+import com.oracle.jvmci.amd64.AMD64.*;
+import com.oracle.jvmci.asm.amd64.*;
+import com.oracle.jvmci.asm.test.*;
+import com.oracle.jvmci.code.RegisterConfig;
+import com.oracle.jvmci.code.TargetDescription;
+import com.oracle.jvmci.code.Register;
+import com.oracle.jvmci.code.CallingConvention;
+import com.oracle.jvmci.code.CompilationResult;
+import com.oracle.jvmci.meta.Kind;
+
+import static com.oracle.jvmci.asm.amd64.AMD64Assembler.AMD64RMOp.*;
+import static com.oracle.jvmci.asm.amd64.AMD64Assembler.OperandSize.*;
+import static com.oracle.jvmci.code.ValueUtil.*;
+import static com.oracle.jvmci.common.UnsafeAccess.*;
+import static org.junit.Assume.*;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import org.junit.*;
+
+public class BitOpsTest extends AssemblerTest {
+    private static boolean lzcntSupported;
+    private static boolean tzcntSupported;
+
+    @Before
+    public void checkAMD64() {
+        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
+        EnumSet<CPUFeature> features = ((AMD64) codeCache.getTarget().arch).getFeatures();
+        lzcntSupported = features.contains(CPUFeature.LZCNT);
+        tzcntSupported = features.contains(CPUFeature.BMI1);
+    }
+
+    @Test
+    public void lzcntlTest() {
+        if (lzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    Register arg = asRegister(cc.getArgument(0));
+                    LZCNT.emit(asm, DWORD, ret, arg);
+                    asm.ret(0);
+                    return asm.close(true);
+                }
+            };
+            assertReturn("intStub", test, 31, 1);
+        }
+    }
+
+    @Test
+    public void lzcntlMemTest() {
+        if (lzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    try {
+                        Field f = IntField.class.getDeclaredField("x");
+                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                        LZCNT.emit(asm, DWORD, ret, arg);
+                        asm.ret(0);
+                        return asm.close(true);
+                    } catch (Exception e) {
+                        throw new RuntimeException("exception while trying to generate field access:", e);
+                    }
+                }
+            };
+            assertReturn("intFieldStub", test, 31, new IntField(1));
+        }
+    }
+
+    @Test
+    public void lzcntqTest() {
+        if (lzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    Register arg = asRegister(cc.getArgument(0));
+                    LZCNT.emit(asm, QWORD, ret, arg);
+                    asm.ret(0);
+                    return asm.close(true);
+                }
+            };
+            assertReturn("longStub", test, 63, 1L);
+        }
+    }
+
+    @Test
+    public void lzcntqMemTest() {
+        if (lzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    try {
+                        Field f = LongField.class.getDeclaredField("x");
+                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                        LZCNT.emit(asm, QWORD, ret, arg);
+                        asm.ret(0);
+                        return asm.close(true);
+                    } catch (Exception e) {
+                        throw new RuntimeException("exception while trying to generate field access:", e);
+                    }
+                }
+            };
+            assertReturn("longFieldStub", test, 63, new LongField(1));
+        }
+    }
+
+    @Test
+    public void tzcntlTest() {
+        if (tzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    Register arg = asRegister(cc.getArgument(0));
+                    TZCNT.emit(asm, DWORD, ret, arg);
+                    asm.ret(0);
+                    return asm.close(true);
+                }
+            };
+            assertReturn("intStub", test, 31, 0x8000_0000);
+        }
+    }
+
+    @Test
+    public void tzcntlMemTest() {
+        if (tzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    try {
+                        Field f = IntField.class.getDeclaredField("x");
+                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                        TZCNT.emit(asm, DWORD, ret, arg);
+                        asm.ret(0);
+                        return asm.close(true);
+                    } catch (Exception e) {
+                        throw new RuntimeException("exception while trying to generate field access:", e);
+                    }
+                }
+            };
+            assertReturn("intFieldStub", test, 31, new IntField(0x8000_0000));
+        }
+    }
+
+    @Test
+    public void tzcntqTest() {
+        if (tzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    Register arg = asRegister(cc.getArgument(0));
+                    TZCNT.emit(asm, QWORD, ret, arg);
+                    asm.ret(0);
+                    return asm.close(true);
+                }
+            };
+            assertReturn("longStub", test, 63, 0x8000_0000_0000_0000L);
+        }
+    }
+
+    @Test
+    public void tzcntqMemTest() {
+        if (tzcntSupported) {
+            CodeGenTest test = new CodeGenTest() {
+
+                @Override
+                public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                    AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                    Register ret = registerConfig.getReturnRegister(Kind.Int);
+                    try {
+                        Field f = LongField.class.getDeclaredField("x");
+                        AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                        TZCNT.emit(asm, QWORD, ret, arg);
+                        asm.ret(0);
+                        return asm.close(true);
+                    } catch (Exception e) {
+                        throw new RuntimeException("exception while trying to generate field access:", e);
+                    }
+                }
+            };
+            assertReturn("longFieldStub", test, 63, new LongField(0x8000_0000_0000_0000L));
+        }
+    }
+
+    @SuppressWarnings("unused")
+    public static int intStub(int arg) {
+        return 0;
+    }
+
+    @SuppressWarnings("unused")
+    public static int longStub(long arg) {
+        return 0;
+    }
+
+    public static class IntField {
+        public int x;
+
+        IntField(int x) {
+            this.x = x;
+        }
+    }
+
+    public static class LongField {
+        public long x;
+
+        LongField(long x) {
+            this.x = x;
+        }
+    }
+
+    @SuppressWarnings("unused")
+    public static int intFieldStub(IntField arg) {
+        return 0;
+    }
+
+    @SuppressWarnings("unused")
+    public static int longFieldStub(LongField arg) {
+        return 0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/IncrementDecrementMacroTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -0,0 +1,228 @@
+/*
+ * 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.jvmci.asm.amd64.test;
+
+import com.oracle.jvmci.amd64.*;
+import com.oracle.jvmci.asm.amd64.*;
+import com.oracle.jvmci.asm.test.*;
+import com.oracle.jvmci.code.RegisterConfig;
+import com.oracle.jvmci.code.TargetDescription;
+import com.oracle.jvmci.code.Register;
+import com.oracle.jvmci.code.CallingConvention;
+import com.oracle.jvmci.code.CompilationResult;
+import com.oracle.jvmci.meta.Kind;
+
+import static com.oracle.jvmci.code.ValueUtil.*;
+import static com.oracle.jvmci.common.UnsafeAccess.*;
+import static org.junit.Assume.*;
+
+import java.lang.reflect.*;
+
+import org.junit.*;
+
+public class IncrementDecrementMacroTest extends AssemblerTest {
+
+    @Before
+    public void checkAMD64() {
+        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
+    }
+
+    public static class LongField {
+        public long x;
+
+        LongField(long x) {
+            this.x = x;
+        }
+    }
+
+    private static class IncrementCodeGenTest implements CodeGenTest {
+        final int value;
+
+        public IncrementCodeGenTest(int value) {
+            this.value = value;
+        }
+
+        @Override
+        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+            AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
+            Register ret = registerConfig.getReturnRegister(Kind.Int);
+            try {
+                Field f = LongField.class.getDeclaredField("x");
+                AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                asm.incrementq(arg, value);
+                asm.movq(ret, arg);
+                asm.ret(0);
+                return asm.close(true);
+            } catch (Exception e) {
+                throw new RuntimeException("exception while trying to generate field access:", e);
+            }
+        }
+    }
+
+    private void assertIncrement(long initValue, int increment) {
+        assertReturn("longFieldStubIncrement", new IncrementCodeGenTest(increment), initValue + increment, new LongField(initValue));
+    }
+
+    private void assertIncrements(int increment) {
+        assertIncrement(0x4242_4242_4242_4242L, increment);
+    }
+
+    @SuppressWarnings("unused")
+    public static long longFieldStubIncrement(LongField arg) {
+        return 0;
+    }
+
+    private static class DecrementCodeGenTest implements CodeGenTest {
+        final int value;
+
+        public DecrementCodeGenTest(int value) {
+            this.value = value;
+        }
+
+        @Override
+        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+            AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
+            Register ret = registerConfig.getReturnRegister(Kind.Int);
+            try {
+                Field f = LongField.class.getDeclaredField("x");
+                AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) unsafe.objectFieldOffset(f));
+                asm.decrementq(arg, value);
+                asm.movq(ret, arg);
+                asm.ret(0);
+                return asm.close(true);
+            } catch (Exception e) {
+                throw new RuntimeException("exception while trying to generate field access:", e);
+            }
+        }
+    }
+
+    private void assertDecrement(long initValue, int increment) {
+        assertReturn("longFieldStubDecrement", new DecrementCodeGenTest(increment), initValue - increment, new LongField(initValue));
+    }
+
+    private void assertDecrements(int increment) {
+        assertDecrement(0x4242_4242_4242_4242L, increment);
+    }
+
+    @SuppressWarnings("unused")
+    public static long longFieldStubDecrement(LongField arg) {
+        return 0;
+    }
+
+    @Test
+    public void incrementMemTest0() {
+        int increment = 0;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest1() {
+        int increment = 1;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest2() {
+        int increment = 2;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest3() {
+        int increment = Integer.MAX_VALUE;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest4() {
+        int increment = Integer.MIN_VALUE;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest5() {
+        int increment = -1;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest6() {
+        int increment = -2;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void incrementMemTest7() {
+        int increment = -0x1000_0000;
+        assertIncrements(increment);
+    }
+
+    @Test
+    public void decrementMemTest0() {
+        int decrement = 0;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest1() {
+        int decrement = 1;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest2() {
+        int decrement = 2;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest3() {
+        int decrement = Integer.MAX_VALUE;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest4() {
+        int decrement = Integer.MIN_VALUE;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest5() {
+        int decrement = -1;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest6() {
+        int decrement = -2;
+        assertDecrements(decrement);
+    }
+
+    @Test
+    public void decrementMemTest7() {
+        int decrement = -0x1000_0000;
+        assertDecrements(decrement);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.asm.amd64.test/src/com/oracle/jvmci/asm/amd64/test/SimpleAssemblerTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -0,0 +1,117 @@
+/*
+ * 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.jvmci.asm.amd64.test;
+
+import com.oracle.jvmci.amd64.*;
+import com.oracle.jvmci.asm.amd64.*;
+import com.oracle.jvmci.asm.test.*;
+import com.oracle.jvmci.code.RegisterConfig;
+import com.oracle.jvmci.code.TargetDescription;
+import com.oracle.jvmci.code.Register;
+import com.oracle.jvmci.code.CallingConvention;
+import com.oracle.jvmci.code.CompilationResult;
+import com.oracle.jvmci.meta.JavaConstant;
+import com.oracle.jvmci.meta.Kind;
+
+import static org.junit.Assume.*;
+
+import java.nio.*;
+
+import org.junit.*;
+
+import com.oracle.jvmci.code.CompilationResult.DataSectionReference;
+import com.oracle.jvmci.code.DataSection.Data;
+import com.oracle.jvmci.code.DataSection.DataBuilder;
+
+public class SimpleAssemblerTest extends AssemblerTest {
+
+    @Before
+    public void checkAMD64() {
+        assumeTrue("skipping AMD64 specific test", codeCache.getTarget().arch instanceof AMD64);
+    }
+
+    @Test
+    public void intTest() {
+        CodeGenTest test = new CodeGenTest() {
+
+            @Override
+            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                AMD64Assembler asm = new AMD64Assembler(target, registerConfig);
+                Register ret = registerConfig.getReturnRegister(Kind.Int);
+                asm.movl(ret, 8472);
+                asm.ret(0);
+                return asm.close(true);
+            }
+        };
+        assertReturn("intStub", test, 8472);
+    }
+
+    @Test
+    public void doubleTest() {
+        CodeGenTest test = new CodeGenTest() {
+
+            @Override
+            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
+                Register ret = registerConfig.getReturnRegister(Kind.Double);
+                Data data = new Data(8, 8, DataBuilder.serializable(JavaConstant.forDouble(84.72)));
+                DataSectionReference ref = compResult.getDataSection().insertData(data);
+                compResult.recordDataPatch(asm.position(), ref);
+                asm.movdbl(ret, asm.getPlaceholder());
+                asm.ret(0);
+                return asm.close(true);
+            }
+        };
+        assertReturn("doubleStub", test, 84.72);
+    }
+
+    @Test
+    public void rawDoubleTest() {
+        CodeGenTest test = new CodeGenTest() {
+
+            @Override
+            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
+                AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig);
+                Register ret = registerConfig.getReturnRegister(Kind.Double);
+
+                byte[] rawBytes = new byte[8];
+                ByteBuffer.wrap(rawBytes).order(ByteOrder.nativeOrder()).putDouble(84.72);
+                Data data = new Data(8, 8, DataBuilder.raw(rawBytes));
+                DataSectionReference ref = compResult.getDataSection().insertData(data);
+                compResult.recordDataPatch(asm.position(), ref);
+                asm.movdbl(ret, asm.getPlaceholder());
+                asm.ret(0);
+                return asm.close(true);
+            }
+        };
+        assertReturn("doubleStub", test, 84.72);
+    }
+
+    public static int intStub() {
+        return 0;
+    }
+
+    public static double doubleStub() {
+        return 0.0;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.asm.test/src/com/oracle/jvmci/asm/test/AssemblerTest.java	Wed Jun 03 18:33:23 2015 +0200
@@ -0,0 +1,93 @@
+/*
+ * 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.jvmci.asm.test;
+
+import java.lang.reflect.*;
+
+import org.junit.*;
+
+import com.oracle.jvmci.code.*;
+import com.oracle.jvmci.debug.*;
+import com.oracle.jvmci.debug.Debug.Scope;
+import com.oracle.jvmci.meta.*;
+import com.oracle.jvmci.runtime.*;
+import com.oracle.jvmci.service.*;
+import com.oracle.jvmci.test.*;
+
+public abstract class AssemblerTest extends TestBase {
+
+    private final MetaAccessProvider metaAccess;
+    protected final CodeCacheProvider codeCache;
+
+    public interface CodeGenTest {
+        byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc);
+    }
+
+    public AssemblerTest() {
+        JVMCIBackend providers = JVMCI.getRuntime().getHostJVMCIBackend();
+        this.metaAccess = providers.getMetaAccess();
+        this.codeCache = providers.getCodeCache();
+    }
+
+    public MetaAccessProvider getMetaAccess() {
+        return metaAccess;
+    }
+
+    protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
+        ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m);
+        try (Scope s = Debug.scope("assembleMethod", method, codeCache)) {
+            RegisterConfig registerConfig = codeCache.getRegisterConfig();
+            CallingConvention cc = CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false);
+
+            CompilationResult compResult = new CompilationResult();
+            byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
+            compResult.setTargetCode(targetCode, targetCode.length);
+            compResult.setTotalFrameSize(0);
+
+            InstalledCode code = codeCache.addMethod(method, compResult, null, null);
+
+            for (DisassemblerProvider dis : Services.load(DisassemblerProvider.class)) {
+                String disasm = dis.disassemble(code);
+                Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
+            }
+            return code;
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
+    }
+
+    protected Object runTest(String methodName, CodeGenTest test, Object... args) {
+        Method method = getMethod(methodName);
+        InstalledCode code = assembleMethod(method, test);
+        try {
+            return code.executeVarargs(args);
+        } catch (InvalidInstalledCodeException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected void assertReturn(String methodName, CodeGenTest test, Object expected, Object... args) {
+        Object actual = runTest(methodName, test, args);
+        Assert.assertEquals("unexpected return value", expected, actual);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.jvmci.test/src/com/oracle/jvmci/test/TestBase.java	Wed Jun 03 18:33:23 2015 +0200
@@ -0,0 +1,353 @@
+/*
+ * 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.jvmci.test;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+import org.junit.*;
+import org.junit.internal.*;
+
+/**
+ * Base class that contains common utility methods and classes useful in unit tests.
+ */
+public class TestBase {
+
+    protected Method getMethod(String methodName) {
+        return getMethod(getClass(), methodName);
+    }
+
+    protected Method getMethod(Class<?> clazz, String methodName) {
+        Method found = null;
+        for (Method m : clazz.getMethods()) {
+            if (m.getName().equals(methodName)) {
+                Assert.assertNull(found);
+                found = m;
+            }
+        }
+        if (found == null) {
+            /* Now look for non-public methods (but this does not look in superclasses). */
+            for (Method m : clazz.getDeclaredMethods()) {
+                if (m.getName().equals(methodName)) {
+                    Assert.assertNull(found);
+                    found = m;
+                }
+            }
+        }
+        if (found != null) {
+            return found;
+        } else {
+            throw new RuntimeException("method not found: " + methodName);
+        }
+    }
+
+    protected Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) {
+        try {
+            return clazz.getMethod(methodName, parameterTypes);
+        } catch (NoSuchMethodException | SecurityException e) {
+            throw new RuntimeException("method not found: " + methodName + "" + Arrays.toString(parameterTypes));
+        }
+    }
+
+    /**
+     * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}.
+     * Does a deep copy equality comparison if {@code expected} is an array.
+     */
+    protected void assertDeepEquals(Object expected, Object actual) {
+        assertDeepEquals(null, expected, actual);
+    }
+
+    /**
+     * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}.
+     * Does a deep copy equality comparison if {@code expected} is an array.
+     *
+     * @param message the identifying message for the {@link AssertionError}
+     */
+    protected void assertDeepEquals(String message, Object expected, Object actual) {
+        if (ulpsDelta() > 0) {
+            assertDeepEquals(message, expected, actual, ulpsDelta());
+        } else {
+            assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta());
+        }
+    }
+
+    /**
+     * Compares two given values for equality, doing a recursive test if both values are arrays of
+     * the same type.
+     *
+     * @param message the identifying message for the {@link AssertionError}
+     * @param delta the maximum delta between two doubles or floats for which both numbers are still
+     *            considered equal.
+     */
+    protected void assertDeepEquals(String message, Object expected, Object actual, double delta) {
+        if (expected != null && actual != null) {
+            Class<?> expectedClass = expected.getClass();
+            Class<?> actualClass = actual.getClass();
+            if (expectedClass.isArray()) {
+                Assert.assertTrue(message, expected != null);
+                Assert.assertTrue(message, actual != null);
+                Assert.assertEquals(message, expectedClass, actual.getClass());
+                if (expected instanceof int[]) {
+                    Assert.assertArrayEquals(message, (int[]) expected, (int[]) actual);
+                } else if (expected instanceof byte[]) {
+                    Assert.assertArrayEquals(message, (byte[]) expected, (byte[]) actual);
+                } else if (expected instanceof char[]) {
+                    Assert.assertArrayEquals(message, (char[]) expected, (char[]) actual);
+                } else if (expected instanceof short[]) {
+                    Assert.assertArrayEquals(message, (short[]) expected, (short[]) actual);
+                } else if (expected instanceof float[]) {
+                    Assert.assertArrayEquals(message, (float[]) expected, (float[]) actual, (float) delta);
+                } else if (expected instanceof long[]) {
+                    Assert.assertArrayEquals(message, (long[]) expected, (long[]) actual);
+                } else if (expected instanceof double[]) {
+                    Assert.assertArrayEquals(message, (double[]) expected, (double[]) actual, delta);
+                } else if (expected instanceof boolean[]) {
+                    new ExactComparisonCriteria().arrayEquals(message, expected, actual);
+                } else if (expected instanceof Object[]) {
+                    new ComparisonCriteria() {
+                        @Override
+                        protected void assertElementsEqual(Object e, Object a) {
+                            assertDeepEquals(message, e, a, delta);
+                        }
+                    }.arrayEquals(message, expected, actual);
+                } else {
+                    Assert.fail((message == null ? "" : message) + "non-array value encountered: " + expected);
+                }
+            } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) {
+                Assert.assertEquals((double) expected, (double) actual, delta);
+            } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) {
+                Assert.assertEquals((float) expected, (float) actual, delta);
+            } else {
+                Assert.assertEquals(message, expected, actual);
+            }
+        } else {
+            Assert.assertEquals(message, expected, actual);
+        }
+    }
+
+    /**
+     * Compares two given values for equality, doing a recursive test if both values are arrays of
+     * the same type. Uses {@linkplain StrictMath#ulp(float) ULP}s for comparison of floats.
+     *
+     * @param message the identifying message for the {@link AssertionError}
+     * @param ulpsDelta the maximum allowed ulps difference between two doubles or floats for which
+     *            both numbers are still considered equal.
+     */
+    protected void assertDeepEquals(String message, Object expected, Object actual, int ulpsDelta) {
+        ComparisonCriteria doubleUlpsDeltaCriteria = new ComparisonCriteria() {
+            @Override
+            protected void assertElementsEqual(Object e, Object a) {
+                assertTrue(message, e instanceof Double && a instanceof Double);
+                // determine acceptable error based on whether it is a normal number or a NaN/Inf
+                double de = (Double) e;
+                double epsilon = (!Double.isNaN(de) && Double.isFinite(de) ? ulpsDelta * Math.ulp(de) : 0);
+                Assert.assertEquals(message, (Double) e, (Double) a, epsilon);
+            }
+        };
+
+        ComparisonCriteria floatUlpsDeltaCriteria = new ComparisonCriteria() {
+            @Override
+            protected void assertElementsEqual(Object e, Object a) {
+                assertTrue(message, e instanceof Float && a instanceof Float);
+                // determine acceptable error based on whether it is a normal number or a NaN/Inf
+                float fe = (Float) e;
+                float epsilon = (!Float.isNaN(fe) && Float.isFinite(fe) ? ulpsDelta * Math.ulp(fe) : 0);
+                Assert.assertEquals(message, (Float) e, (Float) a, epsilon);
+            }
+        };
+
+        if (expected != null && actual != null) {
+            Class<?> expectedClass = expected.getClass();
+            Class<?> actualClass = actual.getClass();
+            if (expectedClass.isArray()) {
+                Assert.assertEquals(message, expectedClass, actualClass);
+                if (expected instanceof double[] || expected instanceof Object[]) {
+                    doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual);
+                    return;
+                } else if (expected instanceof float[] || expected instanceof Object[]) {
+                    floatUlpsDeltaCriteria.arrayEquals(message, expected, actual);
+                    return;
+                }
+            } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) {
+                doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual);
+                return;
+            } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) {
+                floatUlpsDeltaCriteria.arrayEquals(message, expected, actual);
+                return;
+            }
+        }
+        // anything else just use the non-ulps version
+        assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta());
+    }
+
+    /**
+     * Gets the value used by {@link #assertDeepEquals(Object, Object)} and
+     * {@link #assertDeepEquals(String, Object, Object)} for the maximum delta between two doubles
+     * or floats for which both numbers are still considered equal.
+     */
+    protected double equalFloatsOrDoublesDelta() {
+        return 0.0D;
+    }
+
+    // unless overridden ulpsDelta is not used
+    protected int ulpsDelta() {
+        return 0;
+    }
+
+    @SuppressWarnings("serial")
+    public static class MultiCauseAssertionError extends AssertionError {
+
+        private Throwable[] causes;
+
+        public MultiCauseAssertionError(String message, Throwable... causes) {
+            super(message);
+            this.causes = causes;
+        }
+
+        @Override
+        public void printStackTrace(PrintStream out) {
+            super.printStackTrace(out);
+            int num = 0;
+            for (Throwable cause : causes) {
+                if (cause != null) {
+                    out.print("cause " + (num++));
+                    cause.printStackTrace(out);
+                }
+            }
+        }
+
+        @Override
+        public void printStackTrace(PrintWriter out) {
+            super.printStackTrace(out);
+            int num = 0;
+            for (Throwable cause : causes) {
+                if (cause != null) {
+                    out.print("cause " + (num++) + ": ");
+                    cause.printStackTrace(out);
+                }
+            }
+        }
+    }
+
+    /*
+     * Overrides to the normal JUnit {@link Assert} routines that provide varargs style formatting
+     * and produce an exception stack trace with the assertion frames trimmed out.
+     */
+
+    /**
+     * Fails a test with the given message.
+     *
+     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
+     *            okay)
+     * @see AssertionError
+     */
+    public static void fail(String message, Object... objects) {
+        AssertionError e;
+        if (message == null) {
+            e = new AssertionError();
+        } else {
+            e = new AssertionError(String.format(message, objects));
+        }
+        // Trim the assert frames from the stack trace
+        StackTraceElement[] trace = e.getStackTrace();
+        int start = 1; // Skip this frame
+        String thisClassName = TestBase.class.getName();
+        while (start < trace.length && trace[start].getClassName().equals(thisClassName) && (trace[start].getMethodName().equals("assertTrue") || trace[start].getMethodName().equals("assertFalse"))) {
+            start++;
+        }
+        e.setStackTrace(Arrays.copyOfRange(trace, start, trace.length));
+        throw e;
+    }
+
+    /**
+     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the
+     * given message.
+     *
+     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
+     *            okay)
+     * @param condition condition to be checked
+     */
+    public static void assertTrue(String message, boolean condition) {
+        assertTrue(condition, message);
+    }
+
+    /**
+     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} without a
+     * message.
+     *
+     * @param condition condition to be checked
+     */
+    public static void assertTrue(boolean condition) {
+        assertTrue(condition, null);
+    }
+
+    /**
+     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} with the
+     * given message.
+     *
+     * @param message the identifying message for the {@link AssertionError} (<code>null</code>
+     *            okay)
+     * @param condition condition to be checked
+     */
+    public static void assertFalse(String message, boolean condition) {
+        assertTrue(!condition, message);
+    }
+
+    /**
+     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} without a
+     * message.
+     *
+     * @param condition condition to be checked
+     */
+    public static void assertFalse(boolean condition) {
+        assertTrue(!condition, null);
+    }
+
+    /**
+     * Asserts that a condition is true. If it isn't it throws an {@link AssertionError} with the
+     * given message.
+     *
+     * @param condition condition to be checked
+     * @param message the identifying message for the {@link AssertionError}
+     * @param objects arguments to the format string
+     */
+    public static void assertTrue(boolean condition, String message, Object... objects) {
+        if (!condition) {
+            fail(message, objects);
+        }
+    }
+
+    /**
+     * Asserts that a condition is false. If it isn't it throws an {@link AssertionError} with the
+     * given message produced by {@link String#format}.
+     *
+     * @param condition condition to be checked
+     * @param message the identifying message for the {@link AssertionError}
+     * @param objects arguments to the format string
+     */
+    public static void assertFalse(boolean condition, String message, Object... objects) {
+        assertTrue(!condition, message, objects);
+    }
+
+}
--- a/mx/suite.py	Wed Jun 03 18:06:44 2015 +0200
+++ b/mx/suite.py	Wed Jun 03 18:33:23 2015 +0200
@@ -310,7 +310,7 @@
       "dependencies" : ["com.oracle.jvmci.code"],
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Assembler",
+      "workingSets" : "JVMCI,Assembler",
     },
 
     "com.oracle.jvmci.asm.amd64" : {
@@ -322,7 +322,7 @@
       ],
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Assembler,AMD64",
+      "workingSets" : "JVMCI,Assembler,AMD64",
     },
 
     "com.oracle.jvmci.asm.sparc" : {
@@ -334,9 +334,22 @@
       ],
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
-      "workingSets" : "Graal,Assembler,SPARC",
+      "workingSets" : "JVMCI,Assembler,SPARC",
     },
 
+    "com.oracle.jvmci.test" : {
+      "subDir" : "graal",
+      "sourceDirs" : ["src"],
+      "dependencies" : [
+        "JUNIT",
+        "com.oracle.jvmci.debug",
+      ],
+      "checkstyle" : "com.oracle.graal.graph",
+      "javaCompliance" : "1.8",
+      "workingSets" : "JVMCI,Test",
+    },
+
+
     # ------------- JVMCI:HotSpot -------------
 
     "com.oracle.jvmci.hotspot" : {
@@ -988,7 +1001,7 @@
       "subDir" : "graal",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "JUNIT",
+        "com.oracle.jvmci.test",
         "com.oracle.jvmci.debug",
       ],
       "checkstyle" : "com.oracle.graal.graph",
@@ -1024,23 +1037,24 @@
       "jacoco" : "exclude",
     },
 
-    "com.oracle.graal.asm.test" : {
+    "com.oracle.jvmci.asm.test" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "com.oracle.graal.test",
-        "com.oracle.graal.runtime",
+        "com.oracle.jvmci.test",
+        "com.oracle.jvmci.common",
+        "com.oracle.jvmci.runtime",
       ],
       "checkstyle" : "com.oracle.graal.graph",
       "javaCompliance" : "1.8",
       "workingSets" : "Graal,Assembler,Test",
     },
 
-    "com.oracle.graal.asm.amd64.test" : {
+    "com.oracle.jvmci.asm.amd64.test" : {
       "subDir" : "graal",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "com.oracle.graal.asm.test",
+        "com.oracle.jvmci.asm.test",
         "com.oracle.jvmci.asm.amd64",
       ],
       "checkstyle" : "com.oracle.graal.graph",