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