# HG changeset patch # User Doug Simon # Date 1375818009 -7200 # Node ID 5c153c59ba626b38849dd6fd7b2248ed7bc90d5d # Parent 78da293f6efa36328b71fc5f73bbf33d3b8dc97e fixed bug in java.util.zip.CRC32.updateBytes interpreter entry stub diff -r 78da293f6efa -r 5c153c59ba62 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_update.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_update.java Tue Aug 06 18:32:04 2013 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_update.java Tue Aug 06 21:40:09 2013 +0200 @@ -28,6 +28,10 @@ import com.oracle.graal.jtt.*; +/** + * Tests compiled call to {@link CRC32#update(int, int)}. + */ +@SuppressWarnings("javadoc") public class CRC32_update extends JTTTest { public static long test(byte[] input) { diff -r 78da293f6efa -r 5c153c59ba62 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_updateBytes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_updateBytes.java Tue Aug 06 21:40:09 2013 +0200 @@ -0,0 +1,48 @@ +/* + * 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.jtt.jdk; + +import java.util.zip.*; + +import org.junit.*; + +import com.oracle.graal.jtt.*; + +/** + * Tests compiled call to {@link CRC32#updateBytes(int, byte[], int, int)}. + */ +@SuppressWarnings("javadoc") +public class CRC32_updateBytes extends JTTTest { + + public static long test(byte[] input) { + CRC32 crc = new CRC32(); + crc.update(input, 0, input.length); + return crc.getValue(); + } + + @Test + public void run0() throws Throwable { + runTest("test", "some string".getBytes()); + } + +} diff -r 78da293f6efa -r 5c153c59ba62 src/cpu/x86/vm/templateInterpreter_x86_64.cpp --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Aug 06 18:32:04 2013 +0200 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Aug 06 21:40:09 2013 +0200 @@ -995,20 +995,24 @@ const Register crc = c_rarg0; // crc const Register buf = c_rarg1; // source java byte array address const Register len = c_rarg2; // length + const Register off = len; // offset (never overlaps with 'len') // Arguments are reversed on java expression stack - __ movl(len, Address(rsp, wordSize)); // Length // Calculate address of start element if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) { __ movptr(buf, Address(rsp, 3*wordSize)); // long buf - __ addptr(buf, Address(rsp, 2*wordSize)); // + offset + __ movl(len, Address(rsp, 2*wordSize)); // offset + __ addq(buf, len); // + offset __ movl(crc, Address(rsp, 5*wordSize)); // Initial CRC } else { __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size - __ addptr(buf, Address(rsp, 2*wordSize)); // + offset + __ movl(len, Address(rsp, 2*wordSize)); // offset + __ addq(buf, len); // + offset __ movl(crc, Address(rsp, 4*wordSize)); // Initial CRC } + // Can now load 'len' since we're finished with 'off' + __ movl(len, Address(rsp, wordSize)); // Length __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32()), crc, buf, len); // result in rax