1 /* 2 * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. 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 #include "precompiled.hpp" 27 #include "asm/assembler.hpp" 28 #include "interpreter/interpreter.hpp" 29 #include "interpreter/interpreterRuntime.hpp" 30 #include "interpreter/zero/bytecodeInterpreter.hpp" 31 #include "interpreter/zero/zeroInterpreter.hpp" 32 #include "oops/method.hpp" 33 #include "zeroInterpreterGenerator.hpp" 34 35 ZeroInterpreterGenerator::ZeroInterpreterGenerator(): AbstractInterpreterGenerator() { 36 generate_all(); 37 } 38 39 void ZeroInterpreterGenerator::generate_all() { 40 { CodeletMark cm(_masm, "slow signature handler"); 41 AbstractInterpreter::_slow_signature_handler = generate_slow_signature_handler(); 42 } 43 44 #define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind) 45 46 { CodeletMark cm(_masm, "(kind = frame_manager)"); 47 // all non-native method kinds 48 method_entry(zerolocals); 49 method_entry(zerolocals_synchronized); 50 method_entry(empty); 51 method_entry(getter); 52 method_entry(setter); 53 method_entry(abstract); 54 method_entry(java_lang_math_sin ); 55 method_entry(java_lang_math_cos ); 56 method_entry(java_lang_math_tan ); 57 method_entry(java_lang_math_tanh ); 58 method_entry(java_lang_math_abs ); 59 method_entry(java_lang_math_sqrt ); 60 method_entry(java_lang_math_sqrt_strict); 61 method_entry(java_lang_math_log ); 62 method_entry(java_lang_math_log10 ); 63 method_entry(java_lang_math_pow ); 64 method_entry(java_lang_math_exp ); 65 method_entry(java_lang_math_fmaD ); 66 method_entry(java_lang_math_fmaF ); 67 method_entry(java_lang_ref_reference_get); 68 69 AbstractInterpreter::initialize_method_handle_entries(); 70 71 method_entry(native); 72 method_entry(native_synchronized); 73 } 74 75 #undef method_entry 76 } 77 78 // Generate method entries 79 address ZeroInterpreterGenerator::generate_method_entry( 80 AbstractInterpreter::MethodKind kind) { 81 // determine code generation flags 82 bool native = false; 83 bool synchronized = false; 84 address entry_point = nullptr; 85 86 switch (kind) { 87 case Interpreter::zerolocals : break; 88 case Interpreter::zerolocals_synchronized: synchronized = true; break; 89 case Interpreter::native : native = true; break; 90 case Interpreter::native_synchronized : native = true; synchronized = true; break; 91 case Interpreter::empty : entry_point = generate_empty_entry(); break; 92 case Interpreter::getter : entry_point = generate_getter_entry(); break; 93 case Interpreter::setter : entry_point = generate_setter_entry(); break; 94 case Interpreter::abstract : entry_point = generate_abstract_entry(); break; 95 96 case Interpreter::java_lang_math_sin : // fall thru 97 case Interpreter::java_lang_math_cos : // fall thru 98 case Interpreter::java_lang_math_tan : // fall thru 99 case Interpreter::java_lang_math_tanh : // fall thru 100 case Interpreter::java_lang_math_abs : // fall thru 101 case Interpreter::java_lang_math_log : // fall thru 102 case Interpreter::java_lang_math_log10 : // fall thru 103 case Interpreter::java_lang_math_sqrt : // fall thru 104 case Interpreter::java_lang_math_sqrt_strict: // fall thru 105 case Interpreter::java_lang_math_pow : // fall thru 106 case Interpreter::java_lang_math_exp : // fall thru 107 case Interpreter::java_lang_math_fmaD : // fall thru 108 case Interpreter::java_lang_math_fmaF : entry_point = generate_math_entry(kind); break; 109 case Interpreter::java_lang_ref_reference_get 110 : entry_point = generate_Reference_get_entry(); break; 111 default: 112 fatal("unexpected method kind: %d", kind); 113 break; 114 } 115 116 if (entry_point) { 117 return entry_point; 118 } 119 120 // We expect the normal and native entry points to be generated first so we can reuse them. 121 if (native) { 122 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::native_synchronized : Interpreter::native); 123 if (entry_point == nullptr) { 124 entry_point = generate_native_entry(synchronized, false); 125 } 126 } else { 127 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::zerolocals_synchronized : Interpreter::zerolocals); 128 if (entry_point == nullptr) { 129 entry_point = generate_normal_entry(synchronized, false); 130 } 131 } 132 133 return entry_point; 134 } 135 136 address ZeroInterpreterGenerator::generate_slow_signature_handler() { 137 _masm->advance(1); 138 return (address) InterpreterRuntime::slow_signature_handler; 139 } 140 141 address ZeroInterpreterGenerator::generate_math_entry( 142 AbstractInterpreter::MethodKind kind) { 143 if (!InlineIntrinsics) 144 return nullptr; 145 146 Unimplemented(); 147 return nullptr; 148 } 149 150 address ZeroInterpreterGenerator::generate_abstract_entry() { 151 return generate_entry((address) ShouldNotCallThisEntry()); 152 } 153 154 address ZeroInterpreterGenerator::generate_empty_entry() { 155 if (!UseFastEmptyMethods) 156 return nullptr; 157 158 return generate_entry((address) ZeroInterpreter::empty_entry); 159 } 160 161 address ZeroInterpreterGenerator::generate_getter_entry() { 162 if (!UseFastAccessorMethods) 163 return nullptr; 164 165 return generate_entry((address) ZeroInterpreter::getter_entry); 166 } 167 168 address ZeroInterpreterGenerator::generate_setter_entry() { 169 if (!UseFastAccessorMethods) 170 return nullptr; 171 172 return generate_entry((address) ZeroInterpreter::setter_entry); 173 } 174 175 address ZeroInterpreterGenerator::generate_Reference_get_entry(void) { 176 return generate_entry((address) ZeroInterpreter::Reference_get_entry); 177 } 178 179 address ZeroInterpreterGenerator::generate_native_entry(bool synchronized, bool runtime_upcalls) { 180 return generate_entry((address) ZeroInterpreter::native_entry); 181 } 182 183 address ZeroInterpreterGenerator::generate_normal_entry(bool synchronized, bool runtime_upcalls) { 184 return generate_entry((address) ZeroInterpreter::normal_entry); 185 }