1 /* 2 * Copyright (c) 2016, 2024, 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 * 24 */ 25 26 #ifndef CPU_S390_STUBROUTINES_S390_HPP 27 #define CPU_S390_STUBROUTINES_S390_HPP 28 29 // This file holds the platform specific parts of the StubRoutines 30 // definition. See stubRoutines.hpp for a description on how to 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 // MethodHandles adapters 46 enum method_handles_platform_dependent_constants { 47 method_handles_adapters_code_size = 5000 48 }; 49 50 #define CRC32_COLUMN_SIZE 256 51 #define CRC32_BYFOUR 52 #ifdef CRC32_BYFOUR 53 #define CRC32_TABLES 8 54 #else 55 #define CRC32_TABLES 1 56 #endif 57 58 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction. 59 #define TROT_ALIGNMENT 8 // Required by instruction, 60 // guaranteed by jlong table element type. 61 #define TROT_COLUMN_SIZE (256*sizeof(jchar)/sizeof(jlong)) 62 63 class zarch { 64 friend class StubGenerator; 65 66 public: 67 enum { nof_instance_allocators = 10 }; 68 69 // allocator lock values 70 enum { 71 unlocked = 0, 72 locked = 1 73 }; 74 75 // declare fields for arch-specific entries 76 77 #define DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name) \ 78 static address STUB_FIELD_NAME(field_name) ; 79 80 #define DECLARE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \ 81 DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name) 82 83 private: 84 STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT) 85 86 #undef DECLARE_ARCH_ENTRY_INIT 87 #undef DECLARE_ARCH_ENTRY 88 89 private: 90 91 static int _atomic_memory_operation_lock; 92 93 static juint _crc_table[CRC32_TABLES][CRC32_COLUMN_SIZE]; 94 static juint _crc32c_table[CRC32_TABLES][CRC32_COLUMN_SIZE]; 95 96 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction. 97 static address _trot_table_addr; 98 static jlong _trot_table[TROT_COLUMN_SIZE]; 99 100 public: 101 102 // declare getters for arch-specific entries 103 104 #define DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name) \ 105 static address getter_name() { return STUB_FIELD_NAME(field_name) ; } 106 107 #define DEFINE_ARCH_ENTRY_GETTER_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \ 108 DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name) 109 110 STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT) 111 112 #undef DEFINE_ARCH_ENTRY_GETTER_INIT 113 #undef DEFINE_ARCH_ENTRY_GETTER 114 115 // Global lock for everyone who needs to use atomic_compare_and_exchange 116 // or atomic_increment -- should probably use more locks for more 117 // scalability -- for instance one for each eden space or group of. 118 119 // Address of the lock for atomic_compare_and_exchange. 120 static int* atomic_memory_operation_lock_addr() { return &_atomic_memory_operation_lock; } 121 122 // Accessor and mutator for _atomic_memory_operation_lock. 123 static int atomic_memory_operation_lock() { return _atomic_memory_operation_lock; } 124 static void set_atomic_memory_operation_lock(int value) { _atomic_memory_operation_lock = value; } 125 126 static void generate_load_absolute_address(MacroAssembler* masm, Register table, address table_addr, uint64_t table_contents); 127 static void generate_load_crc_table_addr(MacroAssembler* masm, Register table); 128 static void generate_load_crc32c_table_addr(MacroAssembler* masm, Register table); 129 130 // Comapct string intrinsics: Translate table for string inflate intrinsic. Used by trot instruction. 131 static void generate_load_trot_table_addr(MacroAssembler* masm, Register table); 132 }; 133 134 #endif // CPU_S390_STUBROUTINES_S390_HPP