1 /*
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2018, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
1901 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
1902 __ lwz( crc, 5*wordSize, argP); // current crc state
1903 __ add( data, data, tmp); // Add byte buffer offset.
1904 } else { // Used for "updateBytes update".
1905 BLOCK_COMMENT("CRC32_updateBytes {");
1906 // crc @ (SP + 4W) (32bit)
1907 // buf @ (SP + 3W) (64bit ptr to byte array)
1908 // off @ (SP + 2W) (32bit)
1909 // dataLen @ (SP + 1W) (32bit)
1910 // data = buf + off + base_offset
1911 __ ld( data, 3*wordSize, argP); // start of byte buffer
1912 __ lwa( tmp, 2*wordSize, argP); // byte buffer offset
1913 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
1914 __ add( data, data, tmp); // add byte buffer offset
1915 __ lwz( crc, 4*wordSize, argP); // current crc state
1916 __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
1917 }
1918
1919 StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1920
1921 // Performance measurements show the 1word and 2word variants to be almost equivalent,
1922 // with very light advantages for the 1word variant. We chose the 1word variant for
1923 // code compactness.
1924 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
1925
1926 // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
1927 __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
1928 __ blr();
1929
1930 // Generate a vanilla native entry as the slow path.
1931 BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
1932 BIND(slow_path);
1933 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1934 return start;
1935 }
1936
1937 return NULL;
1938 }
1939
1940
1941 /**
1942 * Method entry for intrinsic-candidate (non-native) methods:
1943 * int java.util.zip.CRC32C.updateBytes( int crc, byte[] b, int off, int end)
1944 * int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int end)
1989 __ add( data, data, tmp); // Add byte buffer offset.
1990 __ sub( dataLen, dataLen, tmp); // (end_index - offset)
1991 } else { // Used for "updateBytes update".
1992 BLOCK_COMMENT("CRC32C_updateBytes {");
1993 // crc @ (SP + 4W) (32bit)
1994 // buf @ (SP + 3W) (64bit ptr to byte array)
1995 // off @ (SP + 2W) (32bit)
1996 // dataLen @ (SP + 1W) (32bit)
1997 // data = buf + off + base_offset
1998 __ ld( data, 3*wordSize, argP); // start of byte buffer
1999 __ lwa( tmp, 2*wordSize, argP); // byte buffer offset
2000 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
2001 __ add( data, data, tmp); // add byte buffer offset
2002 __ sub( dataLen, dataLen, tmp); // (end_index - offset)
2003 __ lwz( crc, 4*wordSize, argP); // current crc state
2004 __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2005 }
2006
2007 StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
2008
2009 // Performance measurements show the 1word and 2word variants to be almost equivalent,
2010 // with very light advantages for the 1word variant. We chose the 1word variant for
2011 // code compactness.
2012 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
2013
2014 // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
2015 __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
2016 __ blr();
2017
2018 BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2019 return start;
2020 }
2021
2022 return NULL;
2023 }
2024
2025 // =============================================================================
2026 // Exceptions
2027
2028 void TemplateInterpreterGenerator::generate_throw_exception() {
2029 Register Rexception = R17_tos,
2030 Rcontinuation = R3_RET;
2031
2032 // --------------------------------------------------------------------------
|
1 /*
2 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, 2019, SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
1901 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
1902 __ lwz( crc, 5*wordSize, argP); // current crc state
1903 __ add( data, data, tmp); // Add byte buffer offset.
1904 } else { // Used for "updateBytes update".
1905 BLOCK_COMMENT("CRC32_updateBytes {");
1906 // crc @ (SP + 4W) (32bit)
1907 // buf @ (SP + 3W) (64bit ptr to byte array)
1908 // off @ (SP + 2W) (32bit)
1909 // dataLen @ (SP + 1W) (32bit)
1910 // data = buf + off + base_offset
1911 __ ld( data, 3*wordSize, argP); // start of byte buffer
1912 __ lwa( tmp, 2*wordSize, argP); // byte buffer offset
1913 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
1914 __ add( data, data, tmp); // add byte buffer offset
1915 __ lwz( crc, 4*wordSize, argP); // current crc state
1916 __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
1917 }
1918
1919 StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1920
1921 if (!VM_Version::has_vpmsumb()) {
1922 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
1923 } else {
1924 StubRoutines::ppc64::generate_load_crc_constants_addr(_masm, t0);
1925 __ kernel_crc32_vpmsum(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, true);
1926 }
1927
1928 // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
1929 __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
1930 __ blr();
1931
1932 // Generate a vanilla native entry as the slow path.
1933 BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
1934 BIND(slow_path);
1935 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1936 return start;
1937 }
1938
1939 return NULL;
1940 }
1941
1942
1943 /**
1944 * Method entry for intrinsic-candidate (non-native) methods:
1945 * int java.util.zip.CRC32C.updateBytes( int crc, byte[] b, int off, int end)
1946 * int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int end)
1991 __ add( data, data, tmp); // Add byte buffer offset.
1992 __ sub( dataLen, dataLen, tmp); // (end_index - offset)
1993 } else { // Used for "updateBytes update".
1994 BLOCK_COMMENT("CRC32C_updateBytes {");
1995 // crc @ (SP + 4W) (32bit)
1996 // buf @ (SP + 3W) (64bit ptr to byte array)
1997 // off @ (SP + 2W) (32bit)
1998 // dataLen @ (SP + 1W) (32bit)
1999 // data = buf + off + base_offset
2000 __ ld( data, 3*wordSize, argP); // start of byte buffer
2001 __ lwa( tmp, 2*wordSize, argP); // byte buffer offset
2002 __ lwa( dataLen, 1*wordSize, argP); // #bytes to process
2003 __ add( data, data, tmp); // add byte buffer offset
2004 __ sub( dataLen, dataLen, tmp); // (end_index - offset)
2005 __ lwz( crc, 4*wordSize, argP); // current crc state
2006 __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2007 }
2008
2009 StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
2010
2011 if (!VM_Version::has_vpmsumb()) {
2012 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
2013 } else {
2014 StubRoutines::ppc64::generate_load_crc32c_constants_addr(_masm, t0);
2015 __ kernel_crc32_vpmsum(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, false);
2016 }
2017
2018 // Restore caller sp for c2i case (from compiled) and for resized sender frame (from interpreted).
2019 __ resize_frame_absolute(R21_sender_SP, R11_scratch1, R0);
2020 __ blr();
2021
2022 BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2023 return start;
2024 }
2025
2026 return NULL;
2027 }
2028
2029 // =============================================================================
2030 // Exceptions
2031
2032 void TemplateInterpreterGenerator::generate_throw_exception() {
2033 Register Rexception = R17_tos,
2034 Rcontinuation = R3_RET;
2035
2036 // --------------------------------------------------------------------------
|