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 // emit enum used to size per-blob code buffers 35 36 #define DEFINE_BLOB_SIZE(blob_name, size) \ 37 _ ## blob_name ## _code_size = size, 38 39 enum platform_dependent_constants { 40 STUBGEN_ARCH_BLOBS_DO(DEFINE_BLOB_SIZE) 41 }; 42 43 #undef DEFINE_BLOB_SIZE 44 45 class x86 { 46 friend class StubGenerator; 47 friend class VMStructs; 48 49 // declare fields for arch-specific entries 50 51 #define DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name) \ 52 static address STUB_FIELD_NAME(field_name) ; 53 54 #define DECLARE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \ 55 DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name) 56 57 private: 58 STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT) 59 60 #undef DECLARE_ARCH_ENTRY_INIT 61 #undef DECLARE_ARCH_ENTRY 62 63 64 // define getters for arch-specific entries 65 66 #define DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name) \ 67 static address getter_name() { return STUB_FIELD_NAME(field_name); } 68 69 #define DEFINE_ARCH_ENTRY_GETTER_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \ 70 DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name) 71 72 public: 73 STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT) 74 75 #undef DEFINE_ARCH_ENTRY_GETTER_INIT 76 #undef DEFINE_ARCH_GETTER_ENTRY 77 78 private: 79 static jint _mxcsr_std; 80 static jint _mxcsr_rz; 81 // masks and table for CRC32 82 static const uint64_t _crc_by128_masks[]; 83 static const juint _crc_table[]; 84 static const juint _crc_by128_masks_avx512[]; 85 static const juint _crc_table_avx512[]; 86 static const juint _crc32c_table_avx512[]; 87 static const juint _shuf_table_crc32_avx512[]; 88 // table for CRC32C 89 static juint* _crc32c_table; 90 // table for arrays_hashcode 91 static const jint _arrays_hashcode_powers_of_31[]; 92 //k256 table for sha256 93 static const juint _k256[]; 94 static address _k256_adr; 95 static juint _k256_W[]; 96 static address _k256_W_adr; 97 static const julong _k512_W[]; 98 static address _k512_W_addr; 99 100 public: 101 static address addr_mxcsr_std() { return (address)&_mxcsr_std; } 102 static address addr_mxcsr_rz() { return (address)&_mxcsr_rz; } 103 static address crc_by128_masks_addr() { return (address)_crc_by128_masks; } 104 static address crc_by128_masks_avx512_addr() { return (address)_crc_by128_masks_avx512; } 105 static address shuf_table_crc32_avx512_addr() { return (address)_shuf_table_crc32_avx512; } 106 static address crc_table_avx512_addr() { return (address)_crc_table_avx512; } 107 static address crc32c_table_avx512_addr() { return (address)_crc32c_table_avx512; } 108 static address k256_addr() { return _k256_adr; } 109 static address k256_W_addr() { return _k256_W_adr; } 110 static address k512_W_addr() { return _k512_W_addr; } 111 112 static address arrays_hashcode_powers_of_31() { return (address)_arrays_hashcode_powers_of_31; } 113 static void generate_CRC32C_table(bool is_pclmulqdq_supported); 114 }; 115 116 #endif // CPU_X86_STUBROUTINES_X86_HPP