< prev index next >

src/cpu/s390/vm/templateInterpreterGenerator_s390.cpp

Print this page
rev 12672 : [mq]: crc32_s390.patch
   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 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  *


1947     BLOCK_COMMENT("CRC32_update {");
1948 
1949     // We don't generate local frame and don't align stack because
1950     // we not even call stub code (we generate the code inline)
1951     // and there is no safepoint on this path.
1952 
1953     // Load java parameters.
1954     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
1955     const Register argP    = Z_esp;
1956     const Register crc     = Z_ARG1;  // crc value
1957     const Register data    = Z_ARG2;  // address of java byte value (kernel_crc32 needs address)
1958     const Register dataLen = Z_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
1959     const Register table   = Z_ARG4;  // address of crc32 table
1960 
1961     // Arguments are reversed on java expression stack.
1962     __ z_la(data, 3+1*wordSize, argP);  // byte value (stack address).
1963                                         // Being passed as an int, the single byte is at offset +3.
1964     __ z_llgf(crc, 2 * wordSize, argP); // Current crc state, zero extend to 64 bit to have a clean register.
1965 
1966     StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
1967     __ kernel_crc32_singleByte(crc, data, dataLen, table, Z_R1);
1968 
1969     // Restore caller sp for c2i case.
1970     __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1971 
1972     __ z_br(Z_R14);
1973 
1974     BLOCK_COMMENT("} CRC32_update");
1975 
1976     // Use a previously generated vanilla native entry as the slow path.
1977     BIND(slow_path);
1978     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
1979     return __ addr_at(entry_off);
1980   }
1981 
1982   return NULL;
1983 }
1984 
1985 
1986 // Method entry for static native methods:
1987 //   int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len)


2024       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2025       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2026     } else {                         // Used for "updateBytes update".
2027       // crc     @ (SP + 4W) (32bit)
2028       // buf     @ (SP + 3W) (64bit ptr to byte array)
2029       // off     @ (SP + 2W) (32bit)
2030       // dataLen @ (SP + 1W) (32bit)
2031       // data = buf + off + base_offset
2032       BLOCK_COMMENT("CRC32_updateBytes {");
2033       __ z_llgf(crc,    4*wordSize, argP);  // current crc state
2034       __ z_lg(data,    3*wordSize, argP);   // start of byte buffer
2035       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2036       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2037       __ z_aghi(data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2038     }
2039 
2040     StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
2041 
2042     __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2043     __ z_stmg(t0, t3, 1*8, Z_SP);        // Spill regs 10..13 to make them available as work registers.
2044     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3);
2045     __ z_lmg(t0, t3, 1*8, Z_SP);         // Spill regs 10..13 back from stack.
2046 
2047     // Restore caller sp for c2i case.
2048     __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
2049 
2050     __ z_br(Z_R14);
2051 
2052     BLOCK_COMMENT("} CRC32_update{Bytes|ByteBuffer}");
2053 
2054     // Use a previously generated vanilla native entry as the slow path.
2055     BIND(slow_path);
2056     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
2057     return __ addr_at(entry_off);
2058   }
2059 
2060   return NULL;
2061 }
2062 
2063 // Not supported



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






























































2065   return NULL;
2066 }
2067 
2068 void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
2069   // Quick & dirty stack overflow checking: bang the stack & handle trap.
2070   // Note that we do the banging after the frame is setup, since the exception
2071   // handling code expects to find a valid interpreter frame on the stack.
2072   // Doing the banging earlier fails if the caller frame is not an interpreter
2073   // frame.
2074   // (Also, the exception throwing code expects to unlock any synchronized
2075   // method receiver, so do the banging after locking the receiver.)
2076 
2077   // Bang each page in the shadow zone. We can't assume it's been done for
2078   // an interpreter frame with greater than a page of locals, so each page
2079   // needs to be checked. Only true for non-native. For native, we only bang the last page.
2080   if (UseStackBanging) {
2081     const int page_size      = os::vm_page_size();
2082     const int n_shadow_pages = (int)(JavaThread::stack_shadow_zone_size()/page_size);
2083     const int start_page_num = native_call ? n_shadow_pages : 1;
2084     for (int pages = start_page_num; pages <= n_shadow_pages; pages++) {


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


1947     BLOCK_COMMENT("CRC32_update {");
1948 
1949     // We don't generate local frame and don't align stack because
1950     // we not even call stub code (we generate the code inline)
1951     // and there is no safepoint on this path.
1952 
1953     // Load java parameters.
1954     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
1955     const Register argP    = Z_esp;
1956     const Register crc     = Z_ARG1;  // crc value
1957     const Register data    = Z_ARG2;  // address of java byte value (kernel_crc32 needs address)
1958     const Register dataLen = Z_ARG3;  // source data len (1 byte). Not used because calling the single-byte emitter.
1959     const Register table   = Z_ARG4;  // address of crc32 table
1960 
1961     // Arguments are reversed on java expression stack.
1962     __ z_la(data, 3+1*wordSize, argP);  // byte value (stack address).
1963                                         // Being passed as an int, the single byte is at offset +3.
1964     __ z_llgf(crc, 2 * wordSize, argP); // Current crc state, zero extend to 64 bit to have a clean register.
1965 
1966     StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
1967     __ kernel_crc32_singleByte(crc, data, dataLen, table, Z_R1, true);
1968 
1969     // Restore caller sp for c2i case.
1970     __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
1971 
1972     __ z_br(Z_R14);
1973 
1974     BLOCK_COMMENT("} CRC32_update");
1975 
1976     // Use a previously generated vanilla native entry as the slow path.
1977     BIND(slow_path);
1978     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
1979     return __ addr_at(entry_off);
1980   }
1981 
1982   return NULL;
1983 }
1984 
1985 
1986 // Method entry for static native methods:
1987 //   int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len)


2024       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2025       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2026     } else {                                                         // Used for "updateBytes update".
2027       // crc     @ (SP + 4W) (32bit)
2028       // buf     @ (SP + 3W) (64bit ptr to byte array)
2029       // off     @ (SP + 2W) (32bit)
2030       // dataLen @ (SP + 1W) (32bit)
2031       // data = buf + off + base_offset
2032       BLOCK_COMMENT("CRC32_updateBytes {");
2033       __ z_llgf(crc,    4*wordSize, argP);  // current crc state
2034       __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
2035       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2036       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2037       __ z_aghi(data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2038     }
2039 
2040     StubRoutines::zarch::generate_load_crc_table_addr(_masm, table);
2041 
2042     __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2043     __ z_stmg(t0, t3, 1*8, Z_SP);        // Spill regs 10..13 to make them available as work registers.
2044     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, true);
2045     __ z_lmg(t0, t3, 1*8, Z_SP);         // Spill regs 10..13 back from stack.
2046 
2047     // Restore caller sp for c2i case.
2048     __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
2049 
2050     __ z_br(Z_R14);
2051 
2052     BLOCK_COMMENT("} CRC32_update{Bytes|ByteBuffer}");
2053 
2054     // Use a previously generated vanilla native entry as the slow path.
2055     BIND(slow_path);
2056     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), Z_R1);
2057     return __ addr_at(entry_off);
2058   }
2059 
2060   return NULL;
2061 }
2062 
2063 
2064 // Method entry for static native methods:
2065 //   int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int len)
2066 //   int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long buf, int off, int len)
2067 address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) {
2068 
2069   if (UseCRC32CIntrinsics) {
2070     uint64_t entry_off = __ offset();
2071 
2072     // We don't generate local frame and don't align stack because
2073     // we call stub code and there is no safepoint on this path.
2074 
2075     // Load parameters.
2076     // Z_esp is callers operand stack pointer, i.e. it points to the parameters.
2077     const Register argP    = Z_esp;
2078     const Register crc     = Z_ARG1;  // crc value
2079     const Register data    = Z_ARG2;  // address of java byte array
2080     const Register dataLen = Z_ARG3;  // source data len
2081     const Register table   = Z_ARG4;  // address of crc32 table
2082     const Register t0      = Z_R10;   // work reg for kernel* emitters
2083     const Register t1      = Z_R11;   // work reg for kernel* emitters
2084     const Register t2      = Z_R12;   // work reg for kernel* emitters
2085     const Register t3      = Z_R13;   // work reg for kernel* emitters
2086 
2087     // Arguments are reversed on java expression stack.
2088     // Calculate address of start element.
2089     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { // Used for "updateByteBuffer direct".
2090       // crc     @ (SP + 5W) (32bit)
2091       // buf     @ (SP + 3W) (64bit ptr to long array)
2092       // off     @ (SP + 2W) (32bit)
2093       // dataLen @ (SP + 1W) (32bit)
2094       // data = buf + off
2095       BLOCK_COMMENT("CRC32C_updateDirectByteBuffer {");
2096       __ z_llgf(crc,    5*wordSize, argP);  // current crc state
2097       __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
2098       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2099       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2100     } else {                                                                // Used for "updateBytes update".
2101       // crc     @ (SP + 4W) (32bit)
2102       // buf     @ (SP + 3W) (64bit ptr to byte array)
2103       // off     @ (SP + 2W) (32bit)
2104       // dataLen @ (SP + 1W) (32bit)
2105       // data = buf + off + base_offset
2106       BLOCK_COMMENT("CRC32C_updateBytes {");
2107       __ z_llgf(crc,    4*wordSize, argP);  // current crc state
2108       __ z_lg(data,     3*wordSize, argP);  // start of byte buffer
2109       __ z_agf(data,    2*wordSize, argP);  // Add byte buffer offset.
2110       __ z_lgf(dataLen, 1*wordSize, argP);  // #bytes to process
2111       __ z_aghi(data, arrayOopDesc::base_offset_in_bytes(T_BYTE));
2112     }
2113 
2114     StubRoutines::zarch::generate_load_crc32c_table_addr(_masm, table);
2115 
2116     __ resize_frame(-(6*8), Z_R0, true); // Resize frame to provide add'l space to spill 5 registers.
2117     __ z_stmg(t0, t3, 1*8, Z_SP);        // Spill regs 10..13 to make them available as work registers.
2118     __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, false);
2119     __ z_lmg(t0, t3, 1*8, Z_SP);         // Spill regs 10..13 back from stack.
2120 
2121     // Restore caller sp for c2i case.
2122     __ resize_frame_absolute(Z_R10, Z_R0, true); // Cut the stack back to where the caller started.
2123 
2124     __ z_br(Z_R14);
2125 
2126     BLOCK_COMMENT("} CRC32C_update{Bytes|DirectByteBuffer}");
2127     return __ addr_at(entry_off);
2128   }
2129 
2130   return NULL;
2131 }
2132 
2133 void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
2134   // Quick & dirty stack overflow checking: bang the stack & handle trap.
2135   // Note that we do the banging after the frame is setup, since the exception
2136   // handling code expects to find a valid interpreter frame on the stack.
2137   // Doing the banging earlier fails if the caller frame is not an interpreter
2138   // frame.
2139   // (Also, the exception throwing code expects to unlock any synchronized
2140   // method receiver, so do the banging after locking the receiver.)
2141 
2142   // Bang each page in the shadow zone. We can't assume it's been done for
2143   // an interpreter frame with greater than a page of locals, so each page
2144   // needs to be checked. Only true for non-native. For native, we only bang the last page.
2145   if (UseStackBanging) {
2146     const int page_size      = os::vm_page_size();
2147     const int n_shadow_pages = (int)(JavaThread::stack_shadow_zone_size()/page_size);
2148     const int start_page_num = native_call ? n_shadow_pages : 1;
2149     for (int pages = start_page_num; pages <= n_shadow_pages; pages++) {


< prev index next >