1 /* 2 * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef CPU_X86_STUBROUTINES_X86_HPP 26 #define CPU_X86_STUBROUTINES_X86_HPP 27 28 // This file holds the platform specific parts of the StubRoutines 29 // definition. See stubRoutines.hpp for a description on how to 30 // extend it. 31 32 static bool returns_to_call_stub(address return_pc) { return return_pc == _call_stub_return_address; } 33 34 enum platform_dependent_constants { 35 // simply increase sizes if too small (assembler will crash if too small) 36 _initial_stubs_code_size = 20000 WINDOWS_ONLY(+1000), 37 _continuation_stubs_code_size = 1000 LP64_ONLY(+2000), 38 // AVX512 intrinsics add more code in 64-bit VM, 39 // Windows have more code to save/restore registers 40 _compiler_stubs_code_size = 20000 LP64_ONLY(+46000) WINDOWS_ONLY(+2000), 41 _final_stubs_code_size = 10000 LP64_ONLY(+20000) WINDOWS_ONLY(+2000) ZGC_ONLY(+20000) 42 }; 43 44 class x86 { 45 friend class StubGenerator; 46 friend class VMStructs; 47 48 #ifdef _LP64 49 private: 50 static address _get_previous_sp_entry; 51 52 static address _f2i_fixup; 53 static address _f2l_fixup; 54 static address _d2i_fixup; 55 static address _d2l_fixup; 56 57 static address _float_sign_mask; 58 static address _float_sign_flip; 59 static address _double_sign_mask; 60 static address _double_sign_flip; 61 static address _compress_perm_table32; 62 static address _compress_perm_table64; 63 static address _expand_perm_table32; 64 static address _expand_perm_table64; 65 66 public: 67 68 static address get_previous_sp_entry() { 69 return _get_previous_sp_entry; 70 } 71 72 static address f2i_fixup() { 73 return _f2i_fixup; 74 } 75 76 static address f2l_fixup() { 77 return _f2l_fixup; 78 } 79 80 static address d2i_fixup() { 81 return _d2i_fixup; 82 } 83 84 static address d2l_fixup() { 85 return _d2l_fixup; 86 } 87 88 static address float_sign_mask() { 89 return _float_sign_mask; 90 } 91 92 static address float_sign_flip() { 93 return _float_sign_flip; 94 } 95 96 static address double_sign_mask() { 97 return _double_sign_mask; 98 } 99 100 static address double_sign_flip() { 101 return _double_sign_flip; 102 } 103 104 #else // !LP64 105 106 private: 107 static address _verify_fpu_cntrl_wrd_entry; 108 static address _d2i_wrapper; 109 static address _d2l_wrapper; 110 111 static jint _fpu_cntrl_wrd_std; 112 static jint _fpu_cntrl_wrd_24; 113 static jint _fpu_cntrl_wrd_trunc; 114 115 static jint _fpu_subnormal_bias1[3]; 116 static jint _fpu_subnormal_bias2[3]; 117 118 public: 119 static address verify_fpu_cntrl_wrd_entry() { return _verify_fpu_cntrl_wrd_entry; } 120 static address d2i_wrapper() { return _d2i_wrapper; } 121 static address d2l_wrapper() { return _d2l_wrapper; } 122 static address addr_fpu_cntrl_wrd_std() { return (address)&_fpu_cntrl_wrd_std; } 123 static address addr_fpu_cntrl_wrd_24() { return (address)&_fpu_cntrl_wrd_24; } 124 static address addr_fpu_cntrl_wrd_trunc() { return (address)&_fpu_cntrl_wrd_trunc; } 125 static address addr_fpu_subnormal_bias1() { return (address)&_fpu_subnormal_bias1; } 126 static address addr_fpu_subnormal_bias2() { return (address)&_fpu_subnormal_bias2; } 127 128 static jint fpu_cntrl_wrd_std() { return _fpu_cntrl_wrd_std; } 129 #endif // !LP64 130 131 private: 132 static jint _mxcsr_std; 133 #ifdef _LP64 134 static jint _mxcsr_rz; 135 #endif // _LP64 136 137 static address _verify_mxcsr_entry; 138 139 // masks and table for CRC32 140 static const uint64_t _crc_by128_masks[]; 141 static const juint _crc_table[]; 142 #ifdef _LP64 143 static const juint _crc_by128_masks_avx512[]; 144 static const juint _crc_table_avx512[]; 145 static const juint _crc32c_table_avx512[]; 146 static const juint _shuf_table_crc32_avx512[]; 147 #endif // _LP64 148 // table for CRC32C 149 static juint* _crc32c_table; 150 // table for arrays_hashcode 151 static const jint _arrays_hashcode_powers_of_31[]; 152 153 // upper word mask for sha1 154 static address _upper_word_mask_addr; 155 // byte flip mask for sha1 156 static address _shuffle_byte_flip_mask_addr; 157 158 //k256 table for sha256 159 static const juint _k256[]; 160 static address _k256_adr; 161 static address _vector_short_to_byte_mask; 162 static address _vector_float_sign_mask; 163 static address _vector_float_sign_flip; 164 static address _vector_double_sign_mask; 165 static address _vector_double_sign_flip; 166 static address _vector_long_sign_mask; 167 static address _vector_all_bits_set; 168 static address _vector_int_mask_cmp_bits; 169 static address _vector_byte_perm_mask; 170 static address _vector_int_to_byte_mask; 171 static address _vector_int_to_short_mask; 172 static address _vector_32_bit_mask; 173 static address _vector_64_bit_mask; 174 static address _vector_int_shuffle_mask; 175 static address _vector_byte_shuffle_mask; 176 static address _vector_short_shuffle_mask; 177 static address _vector_long_shuffle_mask; 178 static address _vector_iota_indices; 179 static address _vector_popcount_lut; 180 static address _vector_count_leading_zeros_lut; 181 static address _vector_reverse_bit_lut; 182 static address _vector_reverse_byte_perm_mask_long; 183 static address _vector_reverse_byte_perm_mask_int; 184 static address _vector_reverse_byte_perm_mask_short; 185 #ifdef _LP64 186 static juint _k256_W[]; 187 static address _k256_W_adr; 188 static const julong _k512_W[]; 189 static address _k512_W_addr; 190 // byte flip mask for sha512 191 static address _pshuffle_byte_flip_mask_addr_sha512; 192 // Masks for base64 193 static address _encoding_table_base64; 194 static address _shuffle_base64; 195 static address _avx2_shuffle_base64; 196 static address _avx2_input_mask_base64; 197 static address _avx2_lut_base64; 198 static address _avx2_decode_tables_base64; 199 static address _avx2_decode_lut_tables_base64; 200 static address _lookup_lo_base64; 201 static address _lookup_hi_base64; 202 static address _lookup_lo_base64url; 203 static address _lookup_hi_base64url; 204 static address _pack_vec_base64; 205 static address _join_0_1_base64; 206 static address _join_1_2_base64; 207 static address _join_2_3_base64; 208 static address _decoding_table_base64; 209 #endif 210 // byte flip mask for sha256 211 static address _pshuffle_byte_flip_mask_addr; 212 213 public: 214 static address addr_mxcsr_std() { return (address)&_mxcsr_std; } 215 #ifdef _LP64 216 static address addr_mxcsr_rz() { return (address)&_mxcsr_rz; } 217 #endif // _LP64 218 static address verify_mxcsr_entry() { return _verify_mxcsr_entry; } 219 static address crc_by128_masks_addr() { return (address)_crc_by128_masks; } 220 #ifdef _LP64 221 static address crc_by128_masks_avx512_addr() { return (address)_crc_by128_masks_avx512; } 222 static address shuf_table_crc32_avx512_addr() { return (address)_shuf_table_crc32_avx512; } 223 static address crc_table_avx512_addr() { return (address)_crc_table_avx512; } 224 static address crc32c_table_avx512_addr() { return (address)_crc32c_table_avx512; } 225 #endif // _LP64 226 static address upper_word_mask_addr() { return _upper_word_mask_addr; } 227 static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; } 228 static address k256_addr() { return _k256_adr; } 229 static address method_entry_barrier() { return _method_entry_barrier; } 230 231 static address vector_short_to_byte_mask() { 232 return _vector_short_to_byte_mask; 233 } 234 static address vector_float_sign_mask() { 235 return _vector_float_sign_mask; 236 } 237 238 static address vector_float_sign_flip() { 239 return _vector_float_sign_flip; 240 } 241 242 static address vector_double_sign_mask() { 243 return _vector_double_sign_mask; 244 } 245 246 static address vector_double_sign_flip() { 247 return _vector_double_sign_flip; 248 } 249 250 static address vector_all_bits_set() { 251 return _vector_all_bits_set; 252 } 253 254 static address vector_int_mask_cmp_bits() { 255 return _vector_int_mask_cmp_bits; 256 } 257 258 static address vector_byte_perm_mask() { 259 return _vector_byte_perm_mask; 260 } 261 262 static address vector_int_to_byte_mask() { 263 return _vector_int_to_byte_mask; 264 } 265 266 static address vector_int_to_short_mask() { 267 return _vector_int_to_short_mask; 268 } 269 270 static address vector_32_bit_mask() { 271 return _vector_32_bit_mask; 272 } 273 274 static address vector_64_bit_mask() { 275 return _vector_64_bit_mask; 276 } 277 278 static address vector_int_shuffle_mask() { 279 return _vector_int_shuffle_mask; 280 } 281 282 static address vector_byte_shuffle_mask() { 283 return _vector_byte_shuffle_mask; 284 } 285 286 static address vector_short_shuffle_mask() { 287 return _vector_short_shuffle_mask; 288 } 289 290 static address vector_long_shuffle_mask() { 291 return _vector_long_shuffle_mask; 292 } 293 294 static address vector_long_sign_mask() { 295 return _vector_long_sign_mask; 296 } 297 298 static address vector_iota_indices() { 299 return _vector_iota_indices; 300 } 301 302 static address vector_count_leading_zeros_lut() { 303 return _vector_count_leading_zeros_lut; 304 } 305 306 static address vector_reverse_bit_lut() { 307 return _vector_reverse_bit_lut; 308 } 309 310 static address vector_reverse_byte_perm_mask_long() { 311 return _vector_reverse_byte_perm_mask_long; 312 } 313 314 static address vector_reverse_byte_perm_mask_int() { 315 return _vector_reverse_byte_perm_mask_int; 316 } 317 318 static address vector_reverse_byte_perm_mask_short() { 319 return _vector_reverse_byte_perm_mask_short; 320 } 321 322 static address vector_popcount_lut() { 323 return _vector_popcount_lut; 324 } 325 #ifdef _LP64 326 static address k256_W_addr() { return _k256_W_adr; } 327 static address k512_W_addr() { return _k512_W_addr; } 328 static address pshuffle_byte_flip_mask_addr_sha512() { return _pshuffle_byte_flip_mask_addr_sha512; } 329 static address base64_encoding_table_addr() { return _encoding_table_base64; } 330 static address base64_shuffle_addr() { return _shuffle_base64; } 331 static address base64_avx2_shuffle_addr() { return _avx2_shuffle_base64; } 332 static address base64_avx2_input_mask_addr() { return _avx2_input_mask_base64; } 333 static address base64_avx2_lut_addr() { return _avx2_lut_base64; } 334 static address base64_vbmi_lookup_lo_addr() { return _lookup_lo_base64; } 335 static address base64_vbmi_lookup_hi_addr() { return _lookup_hi_base64; } 336 static address base64_vbmi_lookup_lo_url_addr() { return _lookup_lo_base64url; } 337 static address base64_vbmi_lookup_hi_url_addr() { return _lookup_hi_base64url; } 338 static address base64_vbmi_pack_vec_addr() { return _pack_vec_base64; } 339 static address base64_vbmi_join_0_1_addr() { return _join_0_1_base64; } 340 static address base64_vbmi_join_1_2_addr() { return _join_1_2_base64; } 341 static address base64_vbmi_join_2_3_addr() { return _join_2_3_base64; } 342 static address base64_decoding_table_addr() { return _decoding_table_base64; } 343 static address base64_AVX2_decode_tables_addr() { return _avx2_decode_tables_base64; } 344 static address base64_AVX2_decode_LUT_tables_addr() { return _avx2_decode_lut_tables_base64; } 345 static address compress_perm_table32() { return _compress_perm_table32; } 346 static address compress_perm_table64() { return _compress_perm_table64; } 347 static address expand_perm_table32() { return _expand_perm_table32; } 348 static address expand_perm_table64() { return _expand_perm_table64; } 349 #endif 350 static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; } 351 static address arrays_hashcode_powers_of_31() { return (address)_arrays_hashcode_powers_of_31; } 352 static void generate_CRC32C_table(bool is_pclmulqdq_supported); 353 }; 354 355 #endif // CPU_X86_STUBROUTINES_X86_HPP