< prev index next >

src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp

Print this page
rev 12684 : [mq]: 8176580.patch


1894 #endif
1895     __ lwz(crc,  2*wordSize, argP);    // Current crc state, zero extend to 64 bit to have a clean register.
1896 
1897     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1898     __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true);
1899 
1900     // Restore caller sp for c2i case and return.
1901     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1902     __ blr();
1903 
1904     // Generate a vanilla native entry as the slow path.
1905     BLOCK_COMMENT("} CRC32_update");
1906     BIND(slow_path);
1907     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1908     return start;
1909   }
1910 
1911   return NULL;
1912 }
1913 
1914 // TODO: generate_CRC32_updateBytes_entry and generate_CRC32C_updateBytes_entry are identical
1915 //       except for using different crc tables and some block comment strings.
1916 //       We should provide a common implementation.
1917 
1918 // CRC32 Intrinsics.
1919 /**
1920  * Method entry for static native methods:
1921  *   int java.util.zip.CRC32.updateBytes(     int crc, byte[] b,  int off, int len)
1922  *   int java.util.zip.CRC32.updateByteBuffer(int crc, long* buf, int off, int len)
1923  */
1924 address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
1925   if (UseCRC32Intrinsics) {
1926     address start = __ pc();  // Remember stub start address (is rtn value).
1927     Label slow_path;
1928 
1929     // Safepoint check
1930     const Register sync_state = R11_scratch1;
1931     int sync_state_offs = __ load_const_optimized(sync_state, SafepointSynchronize::address_of_state(), /*temp*/R0, true);
1932     __ lwz(sync_state, sync_state_offs, sync_state);
1933     __ cmpwi(CCR0, sync_state, SafepointSynchronize::_not_synchronized);
1934     __ bne(CCR0, slow_path);
1935 
1936     // We don't generate local frame and don't align stack because
1937     // we not even call stub code (we generate the code inline)
1938     // and there is no safepoint on this path.


1990 
1991     // Performance measurements show the 1word and 2word variants to be almost equivalent,
1992     // with very light advantages for the 1word variant. We chose the 1word variant for
1993     // code compactness.
1994     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, true);
1995 
1996     // Restore caller sp for c2i case and return.
1997     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1998     __ blr();
1999 
2000     // Generate a vanilla native entry as the slow path.
2001     BLOCK_COMMENT("} CRC32_updateBytes(Buffer)");
2002     BIND(slow_path);
2003     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
2004     return start;
2005   }
2006 
2007   return NULL;
2008 }
2009 
2010 // CRC32C Intrinsics.
2011 /**
2012  * Method entry for static native methods:
2013  *   int java.util.zip.CRC32C.updateBytes(           int crc, byte[] b,  int off, int len)
2014  *   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int len)


2015  **/
2016 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
2017   if (UseCRC32CIntrinsics) {
2018     address start = __ pc();  // Remember stub start address (is rtn value).
2019 
2020     // We don't generate local frame and don't align stack because
2021     // we not even call stub code (we generate the code inline)
2022     // and there is no safepoint on this path.
2023 
2024     // Load parameters.
2025     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
2026     const Register argP    = R15_esp;
2027     const Register crc     = R3_ARG1;  // crc value
2028     const Register data    = R4_ARG2;  // address of java byte array
2029     const Register dataLen = R5_ARG3;  // source data len
2030     const Register table   = R6_ARG4;  // address of crc32c table
2031 
2032     const Register t0      = R9;       // scratch registers for crc calculation
2033     const Register t1      = R10;
2034     const Register t2      = R11;


2038     const Register tc1     = R7;
2039     const Register tc2     = R8;
2040     const Register tc3     = table;    // table address is reconstructed at the end of kernel_crc32_* emitters
2041 
2042     const Register tmp     = t0;       // Only used very locally to calculate byte buffer address.
2043 
2044     // Arguments are reversed on java expression stack.
2045     // Calculate address of start element.
2046     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateDirectByteBuffer".
2047       BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
2048       // crc     @ (SP + 5W) (32bit)
2049       // buf     @ (SP + 3W) (64bit ptr to long array)
2050       // off     @ (SP + 2W) (32bit)
2051       // dataLen @ (SP + 1W) (32bit)
2052       // data = buf + off
2053       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2054       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2055       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2056       __ lwz( crc,     5*wordSize, argP);  // current crc state
2057       __ add( data, data, tmp);            // Add byte buffer offset.

2058     } else {                                                         // Used for "updateBytes update".
2059       BLOCK_COMMENT("CRC32C_updateBytes {");
2060       // crc     @ (SP + 4W) (32bit)
2061       // buf     @ (SP + 3W) (64bit ptr to byte array)
2062       // off     @ (SP + 2W) (32bit)
2063       // dataLen @ (SP + 1W) (32bit)
2064       // data = buf + off + base_offset
2065       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2066       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2067       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2068       __ add( data, data, tmp);            // add byte buffer offset

2069       __ lwz( crc,     4*wordSize, argP);  // current crc state
2070       __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2071     }
2072 
2073     StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
2074 
2075     // Performance measurements show the 1word and 2word variants to be almost equivalent,
2076     // with very light advantages for the 1word variant. We chose the 1word variant for
2077     // code compactness.
2078     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
2079 
2080     // Restore caller sp for c2i case and return.
2081     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
2082     __ blr();
2083 
2084     BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2085     return start;
2086   }
2087 
2088   return NULL;




1894 #endif
1895     __ lwz(crc,  2*wordSize, argP);    // Current crc state, zero extend to 64 bit to have a clean register.
1896 
1897     StubRoutines::ppc64::generate_load_crc_table_addr(_masm, table);
1898     __ kernel_crc32_singleByte(crc, data, dataLen, table, tmp, true);
1899 
1900     // Restore caller sp for c2i case and return.
1901     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
1902     __ blr();
1903 
1904     // Generate a vanilla native entry as the slow path.
1905     BLOCK_COMMENT("} CRC32_update");
1906     BIND(slow_path);
1907     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1);
1908     return start;
1909   }
1910 
1911   return NULL;
1912 }
1913 



1914 

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)
1934     // and there is no safepoint on this path.


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 
2007 /**
2008  * Method entry for intrinsic-candidate (non-native) methods:
2009  *   int java.util.zip.CRC32C.updateBytes(           int crc, byte[] b,  int off, int end)
2010  *   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long* buf, int off, int end)
2011  * Unlike CRC32, CRC32C does not have any methods marked as native
2012  * CRC32C also uses an "end" variable instead of the length variable CRC32 uses
2013  **/
2014 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
2015   if (UseCRC32CIntrinsics) {
2016     address start = __ pc();  // Remember stub start address (is rtn value).
2017 
2018     // We don't generate local frame and don't align stack because
2019     // we not even call stub code (we generate the code inline)
2020     // and there is no safepoint on this path.
2021 
2022     // Load parameters.
2023     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
2024     const Register argP    = R15_esp;
2025     const Register crc     = R3_ARG1;  // crc value
2026     const Register data    = R4_ARG2;  // address of java byte array
2027     const Register dataLen = R5_ARG3;  // source data len
2028     const Register table   = R6_ARG4;  // address of crc32c table
2029 
2030     const Register t0      = R9;       // scratch registers for crc calculation
2031     const Register t1      = R10;
2032     const Register t2      = R11;


2036     const Register tc1     = R7;
2037     const Register tc2     = R8;
2038     const Register tc3     = table;    // table address is reconstructed at the end of kernel_crc32_* emitters
2039 
2040     const Register tmp     = t0;       // Only used very locally to calculate byte buffer address.
2041 
2042     // Arguments are reversed on java expression stack.
2043     // Calculate address of start element.
2044     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateDirectByteBuffer".
2045       BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
2046       // crc     @ (SP + 5W) (32bit)
2047       // buf     @ (SP + 3W) (64bit ptr to long array)
2048       // off     @ (SP + 2W) (32bit)
2049       // dataLen @ (SP + 1W) (32bit)
2050       // data = buf + off
2051       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2052       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2053       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2054       __ lwz( crc,     5*wordSize, argP);  // current crc state
2055       __ add( data, data, tmp);            // Add byte buffer offset.
2056       __ sub( dataLen, dataLen, tmp);      // (end_index - offset)
2057     } else {                                                         // Used for "updateBytes update".
2058       BLOCK_COMMENT("CRC32C_updateBytes {");
2059       // crc     @ (SP + 4W) (32bit)
2060       // buf     @ (SP + 3W) (64bit ptr to byte array)
2061       // off     @ (SP + 2W) (32bit)
2062       // dataLen @ (SP + 1W) (32bit)
2063       // data = buf + off + base_offset
2064       __ ld(  data,    3*wordSize, argP);  // start of byte buffer
2065       __ lwa( tmp,     2*wordSize, argP);  // byte buffer offset
2066       __ lwa( dataLen, 1*wordSize, argP);  // #bytes to process
2067       __ add( data, data, tmp);            // add byte buffer offset
2068       __ sub( dataLen, dataLen, tmp);      // (end_index - offset)
2069       __ lwz( crc,     4*wordSize, argP);  // current crc state
2070       __ addi(data, data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2071     }
2072 
2073     StubRoutines::ppc64::generate_load_crc32c_table_addr(_masm, table);
2074 
2075     // Performance measurements show the 1word and 2word variants to be almost equivalent,
2076     // with very light advantages for the 1word variant. We chose the 1word variant for
2077     // code compactness.
2078     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3, false);
2079 
2080     // Restore caller sp for c2i case and return.
2081     __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
2082     __ blr();
2083 
2084     BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2085     return start;
2086   }
2087 
2088   return NULL;


< prev index next >