changeset 11230:5c153c59ba62

fixed bug in java.util.zip.CRC32.updateBytes interpreter entry stub
author Doug Simon <doug.simon@oracle.com>
date Tue, 06 Aug 2013 21:40:09 +0200
parents 78da293f6efa
children cf9603cd8b13
files graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_update.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CRC32_updateBytes.java src/cpu/x86/vm/templateInterpreter_x86_64.cpp
diffstat 3 files changed, 59 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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) {
--- /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());
+    }
+
+}
--- 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