1 /* 2 * Copyright (c) 1997, 2015, 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 #include "precompiled.hpp" 26 #include "interpreter/bytecodeInterpreter.hpp" 27 #include "interpreter/cppInterpreterGenerator.hpp" 28 #include "interpreter/interpreter.hpp" 29 #include "interpreter/interpreterRuntime.hpp" 30 31 #ifdef CC_INTERP 32 33 CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) { 34 generate_all(); 35 } 36 37 void CppInterpreterGenerator::generate_all() { 38 { CodeletMark cm(_masm, "slow signature handler"); 39 AbstractInterpreter::_slow_signature_handler = generate_slow_signature_handler(); 40 } 41 42 #define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind) 43 44 { CodeletMark cm(_masm, "(kind = frame_manager)"); 45 // all non-native method kinds 46 method_entry(zerolocals); 47 method_entry(zerolocals_synchronized); 48 method_entry(empty); 49 method_entry(accessor); 50 method_entry(abstract); 51 method_entry(java_lang_math_sin ); 52 method_entry(java_lang_math_cos ); 53 method_entry(java_lang_math_tan ); 54 method_entry(java_lang_math_abs ); 55 method_entry(java_lang_math_sqrt ); 56 method_entry(java_lang_math_log ); 57 method_entry(java_lang_math_log10 ); 58 method_entry(java_lang_math_pow ); 59 method_entry(java_lang_math_exp ); 60 method_entry(java_lang_ref_reference_get); 61 62 AbstractInterpreter::initialize_method_handle_entries(); 63 64 Interpreter::_native_entry_begin = Interpreter::code()->code_end(); 65 method_entry(native); 66 method_entry(native_synchronized); 67 Interpreter::_native_entry_end = Interpreter::code()->code_end(); 68 } 69 70 #undef method_entry 71 } 72 73 // Generate method entries 74 address CppInterpreterGenerator::generate_method_entry( 75 AbstractInterpreter::MethodKind kind) { 76 // determine code generation flags 77 bool native = false; 78 bool synchronized = false; 79 address entry_point = NULL; 80 81 switch (kind) { 82 case Interpreter::zerolocals : break; 83 case Interpreter::zerolocals_synchronized: synchronized = true; break; 84 case Interpreter::native : native = true; break; 85 case Interpreter::native_synchronized : native = true; synchronized = true; break; 86 case Interpreter::empty : entry_point = generate_empty_entry(); break; 87 case Interpreter::accessor : entry_point = generate_accessor_entry(); break; 88 case Interpreter::abstract : entry_point = generate_abstract_entry(); break; 89 90 case Interpreter::java_lang_math_sin : // fall thru 91 case Interpreter::java_lang_math_cos : // fall thru 92 case Interpreter::java_lang_math_tan : // fall thru 93 case Interpreter::java_lang_math_abs : // fall thru 94 case Interpreter::java_lang_math_log : // fall thru 95 case Interpreter::java_lang_math_log10 : // fall thru 96 case Interpreter::java_lang_math_sqrt : // fall thru 97 case Interpreter::java_lang_math_pow : // fall thru 98 case Interpreter::java_lang_math_exp : entry_point = generate_math_entry(kind); break; 99 case Interpreter::java_lang_ref_reference_get 100 : entry_point = generate_Reference_get_entry(); break; 101 default: 102 fatal("unexpected method kind: %d", kind); 103 break; 104 } 105 106 if (entry_point) { 107 return entry_point; 108 } 109 110 // We expect the normal and native entry points to be generated first so we can reuse them. 111 if (native) { 112 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::native_synchronized : Interpreter::native); 113 if (entry_point == NULL) { 114 entry_point = generate_native_entry(synchronized); 115 } 116 } else { 117 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::zerolocals_synchronized : Interpreter::zerolocals); 118 if (entry_point == NULL) { 119 entry_point = generate_normal_entry(synchronized); 120 } 121 } 122 123 return entry_point; 124 } 125 #endif // CC_INTERP