< prev index next >

src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp

Print this page


   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2015, 2016 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  *


1874     const Register argP    = R15_esp;
1875     const Register crc     = R3_ARG1;  // crc value
1876     const Register data    = R4_ARG2;  // address of java byte value (kernel_crc32 needs address)
1877     const Register dataLen = R5_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
1878     const Register table   = R6_ARG4;  // address of crc32 table
1879     const Register tmp     = dataLen;  // Reuse unused len register to show we don't actually need a separate tmp here.
1880 
1881     BLOCK_COMMENT("CRC32_update {");
1882 
1883     // Arguments are reversed on java expression stack
1884 #ifdef VM_LITTLE_ENDIAN
1885     __ addi(data, argP, 0+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
1886                                        // Being passed as an int, the single byte is at offset +0.
1887 #else
1888     __ addi(data, argP, 3+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
1889                                        // Being passed from java as an int, the single byte is at offset +3.
1890 #endif
1891     __ lwz(crc,  2*wordSize, argP);    // Current crc state, zero extend to 64 bit to have a clean register.
1892 
1893     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1894     __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp);
1895 
1896     // Restore caller sp for c2i case and return.
1897     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1898     __ blr();
1899 
1900     // Generate a vanilla native entry as the slow path.
1901     BLOCK_COMMENT("} CRC32_update");
1902     BIND(slow_path);
1903     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1904     return start;
1905   }
1906 
1907   return NULL;
1908 }
1909 




1910 // CRC32 Intrinsics.
1911 /**
1912  * Method entry for static native methods:
1913  *   int java.util.zip.CRC32.updateBytes(     int crc, byte[] b,  int off, int len)
1914  *   int java.util.zip.CRC32.updateByteBuffer(int crc, long* buf, int off, int len)
1915  */
1916 address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
1917   if (UseCRC32Intrinsics) {
1918     address start = __ pc();  // Remember stub start address (is rtn value).
1919     Label slow_path;
1920 
1921     // Safepoint check
1922     const Register sync_state = R11_scratch1;
1923     int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
1924     __ lwz(sync_state, sync_state_offs, sync_state);
1925     __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
1926     __ bne(CCR0, slow_path);
1927 
1928     // We don't generate local frame and don't align stack because
1929     // we not even call stub code (we generate the code inline)


1966     } else {                                                         // Used for "updateBytes update".
1967       BLOCK_COMMENT("CRC32_updateBytes {");
1968       // crc     @ (SP + 4W) (32bit)
1969       // buf     @ (SP + 3W) (64bit ptr to byte array)
1970       // off     @ (SP + 2W) (32bit)
1971       // dataLen @ (SP + 1W) (32bit)
1972       // data = buf + off + base_offset
1973       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
1974       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
1975       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
1976       __ add( data, data, tmp);            // add byte buffer offset
1977       __ lwz( crc,     4*wordSize, argP);  // current crc state
1978       __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
1979     }
1980 
1981     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1982 
1983     // Performance measurements show the 1word and 2word variants to be almost equivalent,
1984     // with very light advantages for the 1word variant. We chose the 1word variant for
1985     // code compactness.
1986     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3);
1987 
1988     // Restore caller sp for c2i case and return.
1989     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1990     __ blr();
1991 
1992     // Generate a vanilla native entry as the slow path.
1993     BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
1994     BIND(slow_path);
1995     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1996     return start;
1997   }
1998 
1999   return NULL;
2000 }
2001 
2002 // Not supported





2003 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {







































































2004   return NULL;
2005 }
2006 
2007 // =============================================================================
2008 // Exceptions
2009 
2010 void TemplateInterpreterGenerator::generate_throw_exception() {
2011   Register Rexception    = R17_tos,
2012            Rcontinuation = R3_RET;
2013 
2014   // --------------------------------------------------------------------------
2015   // Entry point if an method returns with a pending exception (rethrow).
2016   Interpreter::_rethrow_exception_entry = __ pc();
2017   {
2018     __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
2019     __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
2020     __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
2021 
2022     // Compiled code destroys templateTableBase, reload.
2023     __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);


   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2015, 2017, 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  *


1874     const Register argP    = R15_esp;
1875     const Register crc     = R3_ARG1;  // crc value
1876     const Register data    = R4_ARG2;  // address of java byte value (kernel_crc32 needs address)
1877     const Register dataLen = R5_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
1878     const Register table   = R6_ARG4;  // address of crc32 table
1879     const Register tmp     = dataLen;  // Reuse unused len register to show we don't actually need a separate tmp here.
1880 
1881     BLOCK_COMMENT("CRC32_update {");
1882 
1883     // Arguments are reversed on java expression stack
1884 #ifdef VM_LITTLE_ENDIAN
1885     __ addi(data, argP, 0+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
1886                                        // Being passed as an int, the single byte is at offset +0.
1887 #else
1888     __ addi(data, argP, 3+1*wordSize); // (stack) address of byte value. Emitter expects address, not value.
1889                                        // Being passed from java as an int, the single byte is at offset +3.
1890 #endif
1891     __ lwz(crc,  2*wordSize, argP);    // Current crc state, zero extend to 64 bit to have a clean register.
1892 
1893     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1894     __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true);
1895 
1896     // Restore caller sp for c2i case and return.
1897     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1898     __ blr();
1899 
1900     // Generate a vanilla native entry as the slow path.
1901     BLOCK_COMMENT("} CRC32_update");
1902     BIND(slow_path);
1903     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1904     return start;
1905   }
1906 
1907   return NULL;
1908 }
1909 
1910 // TODO: generate_CRC32_updateBytes_entry and generate_CRC32C_updateBytes_entry are identical
1911 //       except for using different crc tables and some block comment strings.
1912 //       We should provide a common implementation.
1913 
1914 // CRC32 Intrinsics.
1915 /**
1916  * Method entry for static native methods:
1917  *   int java.util.zip.CRC32.updateBytes(     int crc, byte[] b,  int off, int len)
1918  *   int java.util.zip.CRC32.updateByteBuffer(int crc, long* buf, int off, int len)
1919  */
1920 address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
1921   if (UseCRC32Intrinsics) {
1922     address start = __ pc();  // Remember stub start address (is rtn value).
1923     Label slow_path;
1924 
1925     // Safepoint check
1926     const Register sync_state = R11_scratch1;
1927     int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
1928     __ lwz(sync_state, sync_state_offs, sync_state);
1929     __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
1930     __ bne(CCR0, slow_path);
1931 
1932     // We don't generate local frame and don't align stack because
1933     // we not even call stub code (we generate the code inline)


1970     } else {                                                         // Used for "updateBytes update".
1971       BLOCK_COMMENT("CRC32_updateBytes {");
1972       // crc     @ (SP + 4W) (32bit)
1973       // buf     @ (SP + 3W) (64bit ptr to byte array)
1974       // off     @ (SP + 2W) (32bit)
1975       // dataLen @ (SP + 1W) (32bit)
1976       // data = buf + off + base_offset
1977       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
1978       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
1979       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
1980       __ add( data, data, tmp);            // add byte buffer offset
1981       __ lwz( crc,     4*wordSize, argP);  // current crc state
1982       __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
1983     }
1984 
1985     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1986 
1987     // Performance measurements show the 1word and 2word variants to be almost equivalent,
1988     // with very light advantages for the 1word variant. We chose the 1word variant for
1989     // code compactness.
1990     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
1991 
1992     // Restore caller sp for c2i case and return.
1993     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1994     __ blr();
1995 
1996     // Generate a vanilla native entry as the slow path.
1997     BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
1998     BIND(slow_path);
1999     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
2000     return start;
2001   }
2002 
2003   return NULL;
2004 }
2005 
2006 // CRC32C Intrinsics.
2007 /**
2008  * Method entry for static native methods:
2009  *   int java.util.zip.CRC32C.updateBytes(           int crc, byte[] b,  int off, int len)
2010  *   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int len)
2011  **/
2012 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
2013   if (UseCRC32CIntrinsics) {
2014     address start = __ pc();  // Remember stub start address (is rtn value).
2015 
2016     // We don't generate local frame and don't align stack because
2017     // we not even call stub code (we generate the code inline)
2018     // and there is no safepoint on this path.
2019 
2020     // Load parameters.
2021     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
2022     const Register argP    = R15_esp;
2023     const Register crc     = R3_ARG1;  // crc value
2024     const Register data    = R4_ARG2;  // address of java byte array
2025     const Register dataLen = R5_ARG3;  // source data len
2026     const Register table   = R6_ARG4;  // address of crc32c table
2027 
2028     const Register t0      = R9;       // scratch registers for crc calculation
2029     const Register t1      = R10;
2030     const Register t2      = R11;
2031     const Register t3      = R12;
2032 
2033     const Register tc0     = R2;       // registers to hold pre-calculated column addresses
2034     const Register tc1     = R7;
2035     const Register tc2     = R8;
2036     const Register tc3     = table;    // table address is reconstructed at the end of kernel_crc32_* emitters
2037 
2038     const Register tmp     = t0;       // Only used very locally to calculate byte buffer address.
2039 
2040     // Arguments are reversed on java expression stack.
2041     // Calculate address of start element.
2042     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateDirectByteBuffer".
2043       BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
2044       // crc     @ (SP + 5W) (32bit)
2045       // buf     @ (SP + 3W) (64bit ptr to long array)
2046       // off     @ (SP + 2W) (32bit)
2047       // dataLen @ (SP + 1W) (32bit)
2048       // data = buf + off
2049       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2050       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2051       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2052       __ lwz( crc,     5*wordSize, argP);  // current crc state
2053       __ add( data, data, tmp);            // Add byte buffer offset.
2054     } else {                                                         // Used for "updateBytes update".
2055       BLOCK_COMMENT("CRC32C_updateBytes {");
2056       // crc     @ (SP + 4W) (32bit)
2057       // buf     @ (SP + 3W) (64bit ptr to byte array)
2058       // off     @ (SP + 2W) (32bit)
2059       // dataLen @ (SP + 1W) (32bit)
2060       // data = buf + off + base_offset
2061       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2062       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2063       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2064       __ add( data, data, tmp);            // add byte buffer offset
2065       __ lwz( crc,     4*wordSize, argP);  // current crc state
2066       __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2067     }
2068 
2069     StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
2070 
2071     // Performance measurements show the 1word and 2word variants to be almost equivalent,
2072     // with very light advantages for the 1word variant. We chose the 1word variant for
2073     // code compactness.
2074     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
2075 
2076     // Restore caller sp for c2i case and return.
2077     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
2078     __ blr();
2079 
2080     BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2081     return start;
2082   }
2083 
2084   return NULL;
2085 }
2086 
2087 // =============================================================================
2088 // Exceptions
2089 
2090 void TemplateInterpreterGenerator::generate_throw_exception() {
2091   Register Rexception    = R17_tos,
2092            Rcontinuation = R3_RET;
2093 
2094   // --------------------------------------------------------------------------
2095   // Entry point if an method returns with a pending exception (rethrow).
2096   Interpreter::_rethrow_exception_entry = __ pc();
2097   {
2098     __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp.
2099     __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1);
2100     __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0);
2101 
2102     // Compiled code destroys templateTableBase, reload.
2103     __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1);


< prev index next >