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
33CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
34 generate_all();
35}
36
37void 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_math_fmaD );
61 method_entry(java_lang_math_fmaF );
62 method_entry(java_lang_ref_reference_get);
63
64 AbstractInterpreter::initialize_method_handle_entries();
65
66 Interpreter::_native_entry_begin = Interpreter::code()->code_end();
67 method_entry(native);
68 method_entry(native_synchronized);
69 Interpreter::_native_entry_end = Interpreter::code()->code_end();
70 }
71
72#undef method_entry
73}
74
75// Generate method entries
76address CppInterpreterGenerator::generate_method_entry(
77 AbstractInterpreter::MethodKind kind) {
78 // determine code generation flags
79 bool native = false;
80 bool synchronized = false;
81 address entry_point = NULL;
82
83 switch (kind) {
84 case Interpreter::zerolocals : break;
85 case Interpreter::zerolocals_synchronized: synchronized = true; break;
86 case Interpreter::native : native = true; break;
87 case Interpreter::native_synchronized : native = true; synchronized = true; break;
88 case Interpreter::empty : entry_point = generate_empty_entry(); break;
89 case Interpreter::accessor : entry_point = generate_accessor_entry(); break;
90 case Interpreter::abstract : entry_point = generate_abstract_entry(); break;
91
92 case Interpreter::java_lang_math_sin : // fall thru
93 case Interpreter::java_lang_math_cos : // fall thru
94 case Interpreter::java_lang_math_tan : // fall thru
95 case Interpreter::java_lang_math_abs : // fall thru
96 case Interpreter::java_lang_math_log : // fall thru
97 case Interpreter::java_lang_math_log10 : // fall thru
98 case Interpreter::java_lang_math_sqrt : // fall thru
99 case Interpreter::java_lang_math_pow : // fall thru
100 case Interpreter::java_lang_math_exp : // fall thru
101 case Interpreter::java_lang_math_fmaD : // fall thru
102 case Interpreter::java_lang_math_fmaF : entry_point = generate_math_entry(kind); break;
103 case Interpreter::java_lang_ref_reference_get
104 : entry_point = generate_Reference_get_entry(); break;
105 default:
106 fatal("unexpected method kind: %d", kind);
107 break;
108 }
109
110 if (entry_point) {
111 return entry_point;
112 }
113
114 // We expect the normal and native entry points to be generated first so we can reuse them.
115 if (native) {
116 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::native_synchronized : Interpreter::native);
117 if (entry_point == NULL) {
118 entry_point = generate_native_entry(synchronized);
119 }
120 } else {
121 entry_point = Interpreter::entry_for_kind(synchronized ? Interpreter::zerolocals_synchronized : Interpreter::zerolocals);
122 if (entry_point == NULL) {
123 entry_point = generate_normal_entry(synchronized);
124 }
125 }
126
127 return entry_point;
128}
129#endif // CC_INTERP
130