# HG changeset patch # User Doug Simon # Date 1375833753 -7200 # Node ID 0a40e1032037179969a23ec9a5fa1b7f5a4ae776 # Parent 5420b872e72826ccc533a3a65e084a0f5050657c added test for intrinsification of CRC32 method introduced in jdk8 (GRAAL-385) diff -r 5420b872e728 -r 0a40e1032037 graal/com.oracle.graal.hotspot.jdk8.test/src/com/oracle/graal/hotspot/jdk8/test/CRC32UpdateByteBufferSubstitutionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.jdk8.test/src/com/oracle/graal/hotspot/jdk8/test/CRC32UpdateByteBufferSubstitutionTest.java Wed Aug 07 02:02:33 2013 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle 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.jdk8.test; + +import java.io.*; +import java.nio.*; +import java.util.zip.*; + +import org.junit.*; + +import com.oracle.graal.compiler.test.*; + +/** + * Tests compiled call to {@link CRC32#updateByteBuffer(int, long, int, int)}. + */ +@SuppressWarnings("javadoc") +public class CRC32UpdateByteBufferSubstitutionTest extends GraalCompilerTest { + + public static long updateByteBuffer(ByteBuffer buffer) { + CRC32 crc = new CRC32(); + buffer.rewind(); + crc.update(buffer); + return crc.getValue(); + } + + @Test + public void test1() throws Throwable { + String classfileName = CRC32UpdateByteBufferSubstitutionTest.class.getSimpleName().replace('.', '/') + ".class"; + InputStream s = CRC32UpdateByteBufferSubstitutionTest.class.getResourceAsStream(classfileName); + byte[] buf = new byte[s.available()]; + new DataInputStream(s).readFully(buf); + + ByteBuffer directBuf = ByteBuffer.allocateDirect(buf.length); + directBuf.put(buf); + ByteBuffer heapBuf = ByteBuffer.wrap(buf); + + test("updateByteBuffer", directBuf); + test("updateByteBuffer", heapBuf); + } +} diff -r 5420b872e728 -r 0a40e1032037 mx/projects --- a/mx/projects Wed Aug 07 01:57:15 2013 +0200 +++ b/mx/projects Wed Aug 07 02:02:33 2013 +0200 @@ -150,6 +150,14 @@ project@com.oracle.graal.hotspot.test@javaCompliance=1.7 project@com.oracle.graal.hotspot.test@workingSets=Graal,HotSpot,Test +# graal.hotspot.test +project@com.oracle.graal.hotspot.jdk8.test@subDir=graal +project@com.oracle.graal.hotspot.jdk8.test@sourceDirs=src +project@com.oracle.graal.hotspot.jdk8.test@dependencies=com.oracle.graal.compiler.test +project@com.oracle.graal.hotspot.jdk8.test@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.hotspot.jdk8.test@javaCompliance=1.8 +project@com.oracle.graal.hotspot.jdk8.test@workingSets=Graal,HotSpot,Test + # graal.hotspot.amd64.test project@com.oracle.graal.hotspot.amd64.test@subDir=graal project@com.oracle.graal.hotspot.amd64.test@sourceDirs=src