# HG changeset patch # User Doug Simon # Date 1363876722 -3600 # Node ID a444497c48a9043e54d69231143aa6534df8dfd2 # Parent 87346100d7a5791115eb084439f30403b213c1ba moved tests for HotSpot specific method substitutions into HotSpotMethodSubstitutionsTest diff -r 87346100d7a5 -r a444497c48a9 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/HotSpotMethodSubstitutionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/HotSpotMethodSubstitutionTest.java Thu Mar 21 15:38:42 2013 +0100 @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot; + +import org.junit.*; + +import com.oracle.graal.api.replacements.*; +import com.oracle.graal.replacements.*; + +/** + * Tests HotSpot specific {@link MethodSubstitution}s. + */ +public class HotSpotMethodSubstitutionTest extends MethodSubstitutionTest { + + @Test + public void testObjectSubstitutions() { + test("getClass_"); + test("objectHashCode"); + } + + @SuppressWarnings("all") + public static boolean getClass_(Object obj, Class clazz) { + return obj.getClass() == clazz; + } + + @SuppressWarnings("all") + public static int objectHashCode(TestClassA obj) { + return obj.hashCode(); + } + + @Test + public void testClassSubstitutions() { + test("getModifiers"); + test("isInstance"); + test("isInterface"); + test("isArray"); + test("isPrimitive"); + test("getSuperClass"); + test("getComponentType"); + } + + @SuppressWarnings("all") + public static int getModifiers(Class clazz) { + return clazz.getModifiers(); + } + + @SuppressWarnings("all") + public static boolean isInstance(Class clazz) { + return clazz.isInstance(Number.class); + } + + @SuppressWarnings("all") + public static boolean isInterface(Class clazz) { + return clazz.isInterface(); + } + + @SuppressWarnings("all") + public static boolean isArray(Class clazz) { + return clazz.isArray(); + } + + @SuppressWarnings("all") + public static boolean isPrimitive(Class clazz) { + return clazz.isPrimitive(); + } + + @SuppressWarnings("all") + public static Class getSuperClass(Class clazz) { + return clazz.getSuperclass(); + } + + @SuppressWarnings("all") + public static Class getComponentType(Class clazz) { + return clazz.getComponentType(); + } + + @Test + public void testThreadSubstitutions() { + test("currentThread"); + test("threadIsInterrupted"); + test("threadInterrupted"); + } + + @SuppressWarnings("all") + public static Thread currentThread() { + return Thread.currentThread(); + } + + @SuppressWarnings("all") + public static boolean threadIsInterrupted(Thread thread) { + return thread.isInterrupted(); + } + + @SuppressWarnings("all") + public static boolean threadInterrupted() { + return Thread.interrupted(); + } + + @Test + public void testSystemSubstitutions() { + test("systemTime"); + test("systemIdentityHashCode"); + } + + @SuppressWarnings("all") + public static long systemTime() { + return System.currentTimeMillis() + System.nanoTime(); + } + + @SuppressWarnings("all") + public static int systemIdentityHashCode(Object obj) { + return System.identityHashCode(obj); + } + + private static class TestClassA { + } +} diff -r 87346100d7a5 -r a444497c48a9 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java Thu Mar 21 15:36:31 2013 +0100 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/MethodSubstitutionTest.java Thu Mar 21 15:38:42 2013 +0100 @@ -49,106 +49,6 @@ public class MethodSubstitutionTest extends GraalCompilerTest { @Test - public void testObjectSubstitutions() { - test("getClass_"); - test("objectHashCode"); - } - - @SuppressWarnings("all") - public static boolean getClass_(Object obj, Class clazz) { - return obj.getClass() == clazz; - } - - @SuppressWarnings("all") - public static int objectHashCode(TestClassA obj) { - return obj.hashCode(); - } - - @Test - public void testClassSubstitutions() { - test("getModifiers"); - test("isInstance"); - test("isInterface"); - test("isArray"); - test("isPrimitive"); - test("getSuperClass"); - test("getComponentType"); - } - - @SuppressWarnings("all") - public static int getModifiers(Class clazz) { - return clazz.getModifiers(); - } - - @SuppressWarnings("all") - public static boolean isInstance(Class clazz) { - return clazz.isInstance(Number.class); - } - - @SuppressWarnings("all") - public static boolean isInterface(Class clazz) { - return clazz.isInterface(); - } - - @SuppressWarnings("all") - public static boolean isArray(Class clazz) { - return clazz.isArray(); - } - - @SuppressWarnings("all") - public static boolean isPrimitive(Class clazz) { - return clazz.isPrimitive(); - } - - @SuppressWarnings("all") - public static Class getSuperClass(Class clazz) { - return clazz.getSuperclass(); - } - - @SuppressWarnings("all") - public static Class getComponentType(Class clazz) { - return clazz.getComponentType(); - } - - @Test - public void testThreadSubstitutions() { - test("currentThread"); - test("threadIsInterrupted"); - test("threadInterrupted"); - } - - @SuppressWarnings("all") - public static Thread currentThread() { - return Thread.currentThread(); - } - - @SuppressWarnings("all") - public static boolean threadIsInterrupted(Thread thread) { - return thread.isInterrupted(); - } - - @SuppressWarnings("all") - public static boolean threadInterrupted() { - return Thread.interrupted(); - } - - @Test - public void testSystemSubstitutions() { - test("systemTime"); - test("systemIdentityHashCode"); - } - - @SuppressWarnings("all") - public static long systemTime() { - return System.currentTimeMillis() + System.nanoTime(); - } - - @SuppressWarnings("all") - public static int systemIdentityHashCode(Object obj) { - return System.identityHashCode(obj); - } - - @Test public void testUnsafeSubstitutions() { test("unsafeCompareAndSwapInt"); test("unsafeCompareAndSwapLong"); @@ -417,7 +317,7 @@ return Double.longBitsToDouble(value); } - private StructuredGraph test(final String snippet) { + protected StructuredGraph test(final String snippet) { return Debug.scope("MethodSubstitutionTest", runtime.lookupJavaMethod(getMethod(snippet)), new Callable() { @Override @@ -438,7 +338,7 @@ }); } - private static StructuredGraph assertNotInGraph(StructuredGraph graph, Class clazz) { + protected static StructuredGraph assertNotInGraph(StructuredGraph graph, Class clazz) { for (Node node : graph.getNodes()) { if (clazz.isInstance(node)) { fail(node.toString()); @@ -447,7 +347,7 @@ return graph; } - private static StructuredGraph assertInGraph(StructuredGraph graph, Class clazz) { + protected static StructuredGraph assertInGraph(StructuredGraph graph, Class clazz) { for (Node node : graph.getNodes()) { if (clazz.isInstance(node)) { return graph; @@ -456,7 +356,4 @@ fail("Graph does not contain a node of class " + clazz.getName()); return graph; } - - private static class TestClassA { - } } diff -r 87346100d7a5 -r a444497c48a9 mx/projects --- a/mx/projects Thu Mar 21 15:36:31 2013 +0100 +++ b/mx/projects Thu Mar 21 15:38:42 2013 +0100 @@ -117,7 +117,7 @@ # graal.hotspot.test project@com.oracle.graal.hotspot.test@subDir=graal project@com.oracle.graal.hotspot.test@sourceDirs=src -project@com.oracle.graal.hotspot.test@dependencies=com.oracle.graal.hotspot,com.oracle.graal.compiler.test +project@com.oracle.graal.hotspot.test@dependencies=com.oracle.graal.hotspot,com.oracle.graal.compiler.test,com.oracle.graal.replacements.test project@com.oracle.graal.hotspot.test@checkstyle=com.oracle.graal.graph project@com.oracle.graal.hotspot.test@javaCompliance=1.7