annotate src/share/vm/interpreter/templateInterpreter.cpp @ 1145:e018e6884bd8

6631166: CMS: better heuristics when combatting fragmentation Summary: Autonomic per-worker free block cache sizing, tunable coalition policies, fixes to per-size block statistics, retuned gain and bandwidth of some feedback loop filters to allow quicker reactivity to abrupt changes in ambient demand, and other heuristics to reduce fragmentation of the CMS old gen. Also tightened some assertions, including those related to locking. Reviewed-by: jmasa
author ysr
date Wed, 23 Dec 2009 09:23:54 -0800
parents b18963243361
children cff162798819
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_templateInterpreter.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 # define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 void TemplateInterpreter::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 if (_code != NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // assertions
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 "dispatch table too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 AbstractInterpreter::initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 TemplateTable::initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // generate interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
43 { ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 TraceTime timer("Interpreter generation", TraceStartupTime);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 int code_size = InterpreterCodeSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 "Interpreter");
a61af66fc99e Initial load
duke
parents:
diff changeset
49 InterpreterGenerator g(_code);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (PrintInterpreter) print();
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // initialize dispatch table
a61af66fc99e Initial load
duke
parents:
diff changeset
54 _active_table = _normal_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Implementation of EntryPoint
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 EntryPoint::EntryPoint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 assert(number_of_states == 9, "check the code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _entry[btos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _entry[ctos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _entry[stos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _entry[atos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _entry[itos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _entry[ltos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _entry[ftos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _entry[dtos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _entry[vtos] = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 assert(number_of_states == 9, "check the code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _entry[btos] = bentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _entry[ctos] = centry;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _entry[stos] = sentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 _entry[atos] = aentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _entry[itos] = ientry;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _entry[ltos] = lentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _entry[ftos] = fentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _entry[dtos] = dentry;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 _entry[vtos] = ventry;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void EntryPoint::set_entry(TosState state, address entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert(0 <= state && state < number_of_states, "state out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _entry[state] = entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 address EntryPoint::entry(TosState state) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 assert(0 <= state && state < number_of_states, "state out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
96 return _entry[state];
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void EntryPoint::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 tty->print("[");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 for (int i = 0; i < number_of_states; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (i > 0) tty->print(", ");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 tty->print(INTPTR_FORMAT, _entry[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 tty->print("]");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 bool EntryPoint::operator == (const EntryPoint& y) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int i = number_of_states;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (_entry[i] != y._entry[i]) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Implementation of DispatchTable
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 EntryPoint DispatchTable::entry(int i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert(0 <= i && i < length, "index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return
a61af66fc99e Initial load
duke
parents:
diff changeset
125 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
126 _table[btos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
127 _table[ctos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
128 _table[stos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _table[atos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
130 _table[itos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
131 _table[ltos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
132 _table[ftos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
133 _table[dtos][i],
a61af66fc99e Initial load
duke
parents:
diff changeset
134 _table[vtos][i]
a61af66fc99e Initial load
duke
parents:
diff changeset
135 );
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void DispatchTable::set_entry(int i, EntryPoint& entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 assert(0 <= i && i < length, "index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(number_of_states == 9, "check the code below");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 _table[btos][i] = entry.entry(btos);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 _table[ctos][i] = entry.entry(ctos);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _table[stos][i] = entry.entry(stos);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 _table[atos][i] = entry.entry(atos);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 _table[itos][i] = entry.entry(itos);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 _table[ltos][i] = entry.entry(ltos);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 _table[ftos][i] = entry.entry(ftos);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 _table[dtos][i] = entry.entry(dtos);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 _table[vtos][i] = entry.entry(vtos);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 bool DispatchTable::operator == (DispatchTable& y) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 int i = length;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 EntryPoint t = y.entry(i); // for compiler compatibility (BugId 4150096)
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (!(entry(i) == t)) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 address TemplateInterpreter::_remove_activation_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 address TemplateInterpreter::_remove_activation_preserving_args_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 address TemplateInterpreter::_throw_ArrayIndexOutOfBoundsException_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 address TemplateInterpreter::_throw_ArrayStoreException_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 address TemplateInterpreter::_throw_ArithmeticException_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 address TemplateInterpreter::_throw_ClassCastException_entry = NULL;
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
171 address TemplateInterpreter::_throw_WrongMethodType_entry = NULL;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
172 address TemplateInterpreter::_throw_NullPointerException_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 address TemplateInterpreter::_throw_StackOverflowError_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 address TemplateInterpreter::_throw_exception_entry = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
177 EntryPoint TemplateInterpreter::_trace_code;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 #endif // !PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
179 EntryPoint TemplateInterpreter::_return_entry[TemplateInterpreter::number_of_return_entries];
a61af66fc99e Initial load
duke
parents:
diff changeset
180 EntryPoint TemplateInterpreter::_earlyret_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 EntryPoint TemplateInterpreter::_deopt_entry [TemplateInterpreter::number_of_deopt_entries ];
a61af66fc99e Initial load
duke
parents:
diff changeset
182 EntryPoint TemplateInterpreter::_continuation_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 EntryPoint TemplateInterpreter::_safept_entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 address TemplateInterpreter::_return_3_addrs_by_index[TemplateInterpreter::number_of_return_addrs];
a61af66fc99e Initial load
duke
parents:
diff changeset
186 address TemplateInterpreter::_return_5_addrs_by_index[TemplateInterpreter::number_of_return_addrs];
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 DispatchTable TemplateInterpreter::_active_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 DispatchTable TemplateInterpreter::_normal_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 DispatchTable TemplateInterpreter::_safept_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 address TemplateInterpreter::_wentry_point[DispatchTable::length];
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 TemplateInterpreterGenerator::TemplateInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 _unimplemented_bytecode = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 _illegal_bytecode_sequence = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 static const BasicType types[Interpreter::number_of_result_handlers] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 T_BOOLEAN,
a61af66fc99e Initial load
duke
parents:
diff changeset
200 T_CHAR ,
a61af66fc99e Initial load
duke
parents:
diff changeset
201 T_BYTE ,
a61af66fc99e Initial load
duke
parents:
diff changeset
202 T_SHORT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
203 T_INT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
204 T_LONG ,
a61af66fc99e Initial load
duke
parents:
diff changeset
205 T_VOID ,
a61af66fc99e Initial load
duke
parents:
diff changeset
206 T_FLOAT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
207 T_DOUBLE ,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 T_OBJECT
a61af66fc99e Initial load
duke
parents:
diff changeset
209 };
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 void TemplateInterpreterGenerator::generate_all() {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 AbstractInterpreterGenerator::generate_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 { CodeletMark cm(_masm, "error exits");
a61af66fc99e Initial load
duke
parents:
diff changeset
215 _unimplemented_bytecode = generate_error_exit("unimplemented bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
216 _illegal_bytecode_sequence = generate_error_exit("illegal bytecode sequence - method not verified");
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
220 if (TraceBytecodes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 CodeletMark cm(_masm, "bytecode tracing support");
a61af66fc99e Initial load
duke
parents:
diff changeset
222 Interpreter::_trace_code =
a61af66fc99e Initial load
duke
parents:
diff changeset
223 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
224 generate_trace_code(btos),
a61af66fc99e Initial load
duke
parents:
diff changeset
225 generate_trace_code(ctos),
a61af66fc99e Initial load
duke
parents:
diff changeset
226 generate_trace_code(stos),
a61af66fc99e Initial load
duke
parents:
diff changeset
227 generate_trace_code(atos),
a61af66fc99e Initial load
duke
parents:
diff changeset
228 generate_trace_code(itos),
a61af66fc99e Initial load
duke
parents:
diff changeset
229 generate_trace_code(ltos),
a61af66fc99e Initial load
duke
parents:
diff changeset
230 generate_trace_code(ftos),
a61af66fc99e Initial load
duke
parents:
diff changeset
231 generate_trace_code(dtos),
a61af66fc99e Initial load
duke
parents:
diff changeset
232 generate_trace_code(vtos)
a61af66fc99e Initial load
duke
parents:
diff changeset
233 );
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 #endif // !PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 { CodeletMark cm(_masm, "return entry points");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 for (int i = 0; i < Interpreter::number_of_return_entries; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 Interpreter::_return_entry[i] =
a61af66fc99e Initial load
duke
parents:
diff changeset
240 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
241 generate_return_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
242 generate_return_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
243 generate_return_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
244 generate_return_entry_for(atos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
245 generate_return_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
246 generate_return_entry_for(ltos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
247 generate_return_entry_for(ftos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
248 generate_return_entry_for(dtos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
249 generate_return_entry_for(vtos, i)
a61af66fc99e Initial load
duke
parents:
diff changeset
250 );
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 { CodeletMark cm(_masm, "earlyret entry points");
a61af66fc99e Initial load
duke
parents:
diff changeset
255 Interpreter::_earlyret_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
256 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
257 generate_earlyret_entry_for(btos),
a61af66fc99e Initial load
duke
parents:
diff changeset
258 generate_earlyret_entry_for(ctos),
a61af66fc99e Initial load
duke
parents:
diff changeset
259 generate_earlyret_entry_for(stos),
a61af66fc99e Initial load
duke
parents:
diff changeset
260 generate_earlyret_entry_for(atos),
a61af66fc99e Initial load
duke
parents:
diff changeset
261 generate_earlyret_entry_for(itos),
a61af66fc99e Initial load
duke
parents:
diff changeset
262 generate_earlyret_entry_for(ltos),
a61af66fc99e Initial load
duke
parents:
diff changeset
263 generate_earlyret_entry_for(ftos),
a61af66fc99e Initial load
duke
parents:
diff changeset
264 generate_earlyret_entry_for(dtos),
a61af66fc99e Initial load
duke
parents:
diff changeset
265 generate_earlyret_entry_for(vtos)
a61af66fc99e Initial load
duke
parents:
diff changeset
266 );
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 { CodeletMark cm(_masm, "deoptimization entry points");
a61af66fc99e Initial load
duke
parents:
diff changeset
270 for (int i = 0; i < Interpreter::number_of_deopt_entries; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 Interpreter::_deopt_entry[i] =
a61af66fc99e Initial load
duke
parents:
diff changeset
272 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
273 generate_deopt_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
274 generate_deopt_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
275 generate_deopt_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
276 generate_deopt_entry_for(atos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
277 generate_deopt_entry_for(itos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
278 generate_deopt_entry_for(ltos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
279 generate_deopt_entry_for(ftos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
280 generate_deopt_entry_for(dtos, i),
a61af66fc99e Initial load
duke
parents:
diff changeset
281 generate_deopt_entry_for(vtos, i)
a61af66fc99e Initial load
duke
parents:
diff changeset
282 );
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285
a61af66fc99e Initial load
duke
parents:
diff changeset
286 { CodeletMark cm(_masm, "result handlers for native calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // The various result converter stublets.
a61af66fc99e Initial load
duke
parents:
diff changeset
288 int is_generated[Interpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
289 memset(is_generated, 0, sizeof(is_generated));
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 BasicType type = types[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
293 if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 }
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 for (int j = 0; j < number_of_states; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 const TosState states[] = {btos, ctos, stos, itos, ltos, ftos, dtos, atos, vtos};
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 710
diff changeset
301 int index = Interpreter::TosState_as_index(states[j]);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 710
diff changeset
302 Interpreter::_return_3_addrs_by_index[index] = Interpreter::return_entry(states[j], 3);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 710
diff changeset
303 Interpreter::_return_5_addrs_by_index[index] = Interpreter::return_entry(states[j], 5);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 { CodeletMark cm(_masm, "continuation entry points");
a61af66fc99e Initial load
duke
parents:
diff changeset
307 Interpreter::_continuation_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
308 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
309 generate_continuation_for(btos),
a61af66fc99e Initial load
duke
parents:
diff changeset
310 generate_continuation_for(ctos),
a61af66fc99e Initial load
duke
parents:
diff changeset
311 generate_continuation_for(stos),
a61af66fc99e Initial load
duke
parents:
diff changeset
312 generate_continuation_for(atos),
a61af66fc99e Initial load
duke
parents:
diff changeset
313 generate_continuation_for(itos),
a61af66fc99e Initial load
duke
parents:
diff changeset
314 generate_continuation_for(ltos),
a61af66fc99e Initial load
duke
parents:
diff changeset
315 generate_continuation_for(ftos),
a61af66fc99e Initial load
duke
parents:
diff changeset
316 generate_continuation_for(dtos),
a61af66fc99e Initial load
duke
parents:
diff changeset
317 generate_continuation_for(vtos)
a61af66fc99e Initial load
duke
parents:
diff changeset
318 );
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 { CodeletMark cm(_masm, "safepoint entry points");
a61af66fc99e Initial load
duke
parents:
diff changeset
322 Interpreter::_safept_entry =
a61af66fc99e Initial load
duke
parents:
diff changeset
323 EntryPoint(
a61af66fc99e Initial load
duke
parents:
diff changeset
324 generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
325 generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
326 generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
327 generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
328 generate_safept_entry_for(itos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
329 generate_safept_entry_for(ltos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
330 generate_safept_entry_for(ftos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
331 generate_safept_entry_for(dtos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
a61af66fc99e Initial load
duke
parents:
diff changeset
332 generate_safept_entry_for(vtos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint))
a61af66fc99e Initial load
duke
parents:
diff changeset
333 );
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 { CodeletMark cm(_masm, "exception handling");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // (Note: this is not safepoint safe because thread may return to compiled code)
a61af66fc99e Initial load
duke
parents:
diff changeset
338 generate_throw_exception();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 { CodeletMark cm(_masm, "throw exception entrypoints");
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Interpreter::_throw_ArrayIndexOutOfBoundsException_entry = generate_ArrayIndexOutOfBounds_handler("java/lang/ArrayIndexOutOfBoundsException");
a61af66fc99e Initial load
duke
parents:
diff changeset
343 Interpreter::_throw_ArrayStoreException_entry = generate_klass_exception_handler("java/lang/ArrayStoreException" );
a61af66fc99e Initial load
duke
parents:
diff changeset
344 Interpreter::_throw_ArithmeticException_entry = generate_exception_handler("java/lang/ArithmeticException" , "/ by zero");
a61af66fc99e Initial load
duke
parents:
diff changeset
345 Interpreter::_throw_ClassCastException_entry = generate_ClassCastException_handler();
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
346 Interpreter::_throw_WrongMethodType_entry = generate_WrongMethodType_handler();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
347 Interpreter::_throw_NullPointerException_entry = generate_exception_handler("java/lang/NullPointerException" , NULL );
a61af66fc99e Initial load
duke
parents:
diff changeset
348 Interpreter::_throw_StackOverflowError_entry = generate_StackOverflowError_handler();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 #define method_entry(kind) \
a61af66fc99e Initial load
duke
parents:
diff changeset
354 { CodeletMark cm(_masm, "method entry point (kind = " #kind ")"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
355 Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind); \
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // all non-native method kinds
a61af66fc99e Initial load
duke
parents:
diff changeset
359 method_entry(zerolocals)
a61af66fc99e Initial load
duke
parents:
diff changeset
360 method_entry(zerolocals_synchronized)
a61af66fc99e Initial load
duke
parents:
diff changeset
361 method_entry(empty)
a61af66fc99e Initial load
duke
parents:
diff changeset
362 method_entry(accessor)
a61af66fc99e Initial load
duke
parents:
diff changeset
363 method_entry(abstract)
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 0
diff changeset
364 method_entry(method_handle)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
365 method_entry(java_lang_math_sin )
a61af66fc99e Initial load
duke
parents:
diff changeset
366 method_entry(java_lang_math_cos )
a61af66fc99e Initial load
duke
parents:
diff changeset
367 method_entry(java_lang_math_tan )
a61af66fc99e Initial load
duke
parents:
diff changeset
368 method_entry(java_lang_math_abs )
a61af66fc99e Initial load
duke
parents:
diff changeset
369 method_entry(java_lang_math_sqrt )
a61af66fc99e Initial load
duke
parents:
diff changeset
370 method_entry(java_lang_math_log )
a61af66fc99e Initial load
duke
parents:
diff changeset
371 method_entry(java_lang_math_log10)
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // all native method kinds (must be one contiguous block)
a61af66fc99e Initial load
duke
parents:
diff changeset
374 Interpreter::_native_entry_begin = Interpreter::code()->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
375 method_entry(native)
a61af66fc99e Initial load
duke
parents:
diff changeset
376 method_entry(native_synchronized)
a61af66fc99e Initial load
duke
parents:
diff changeset
377 Interpreter::_native_entry_end = Interpreter::code()->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 #undef method_entry
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // Bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
382 set_entry_points_for_all_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
383 set_safepoints_for_all_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 address TemplateInterpreterGenerator::generate_error_exit(const char* msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
389 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
390 __ stop(msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 void TemplateInterpreterGenerator::set_entry_points_for_all_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 for (int i = 0; i < DispatchTable::length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 Bytecodes::Code code = (Bytecodes::Code)i;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 if (Bytecodes::is_defined(code)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
401 set_entry_points(code);
a61af66fc99e Initial load
duke
parents:
diff changeset
402 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 set_unimplemented(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 void TemplateInterpreterGenerator::set_safepoints_for_all_bytes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 for (int i = 0; i < DispatchTable::length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411 Bytecodes::Code code = (Bytecodes::Code)i;
a61af66fc99e Initial load
duke
parents:
diff changeset
412 if (Bytecodes::is_defined(code)) Interpreter::_safept_table.set_entry(code, Interpreter::_safept_entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417 void TemplateInterpreterGenerator::set_unimplemented(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 address e = _unimplemented_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
419 EntryPoint entry(e, e, e, e, e, e, e, e, e);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 Interpreter::_normal_table.set_entry(i, entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
421 Interpreter::_wentry_point[i] = _unimplemented_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 void TemplateInterpreterGenerator::set_entry_points(Bytecodes::Code code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 CodeletMark cm(_masm, Bytecodes::name(code), code);
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // initialize entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
428 assert(_unimplemented_bytecode != NULL, "should have been generated before");
a61af66fc99e Initial load
duke
parents:
diff changeset
429 assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
a61af66fc99e Initial load
duke
parents:
diff changeset
430 address bep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 address cep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 address sep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
433 address aep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
434 address iep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
435 address lep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 address fep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 address dep = _illegal_bytecode_sequence;
a61af66fc99e Initial load
duke
parents:
diff changeset
438 address vep = _unimplemented_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 address wep = _unimplemented_bytecode;
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // code for short & wide version of bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
441 if (Bytecodes::is_defined(code)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 Template* t = TemplateTable::template_for(code);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 assert(t->is_valid(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
444 set_short_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep);
a61af66fc99e Initial load
duke
parents:
diff changeset
445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
446 if (Bytecodes::wide_is_defined(code)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 Template* t = TemplateTable::template_for_wide(code);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 assert(t->is_valid(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
449 set_wide_entry_point(t, wep);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // set entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
452 EntryPoint entry(bep, cep, sep, aep, iep, lep, fep, dep, vep);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 Interpreter::_normal_table.set_entry(code, entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 Interpreter::_wentry_point[code] = wep;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 void TemplateInterpreterGenerator::set_wide_entry_point(Template* t, address& wep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 assert(t->is_valid(), "template must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
460 assert(t->tos_in() == vtos, "only vtos tos_in supported for wide instructions")
a61af66fc99e Initial load
duke
parents:
diff changeset
461 wep = __ pc(); generate_and_dispatch(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464
a61af66fc99e Initial load
duke
parents:
diff changeset
465 void TemplateInterpreterGenerator::set_short_entry_points(Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) {
a61af66fc99e Initial load
duke
parents:
diff changeset
466 assert(t->is_valid(), "template must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
467 switch (t->tos_in()) {
1071
b18963243361 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 1059
diff changeset
468 case btos:
b18963243361 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 1059
diff changeset
469 case ctos:
b18963243361 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 1059
diff changeset
470 case stos:
b18963243361 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 1059
diff changeset
471 ShouldNotReachHere(); // btos/ctos/stos should use itos.
b18963243361 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 1059
diff changeset
472 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
473 case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
474 case itos: vep = __ pc(); __ pop(itos); iep = __ pc(); generate_and_dispatch(t); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 case ltos: vep = __ pc(); __ pop(ltos); lep = __ pc(); generate_and_dispatch(t); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
476 case ftos: vep = __ pc(); __ pop(ftos); fep = __ pc(); generate_and_dispatch(t); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
477 case dtos: vep = __ pc(); __ pop(dtos); dep = __ pc(); generate_and_dispatch(t); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
478 case vtos: set_vtos_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
479 default : ShouldNotReachHere(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 void TemplateInterpreterGenerator::generate_and_dispatch(Template* t, TosState tos_out) {
a61af66fc99e Initial load
duke
parents:
diff changeset
487 if (PrintBytecodeHistogram) histogram_bytecode(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // debugging code
a61af66fc99e Initial load
duke
parents:
diff changeset
490 if (CountBytecodes || TraceBytecodes || StopInterpreterAt > 0) count_bytecode();
a61af66fc99e Initial load
duke
parents:
diff changeset
491 if (PrintBytecodePairHistogram) histogram_bytecode_pair(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
492 if (TraceBytecodes) trace_bytecode(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
493 if (StopInterpreterAt > 0) stop_interpreter_at();
a61af66fc99e Initial load
duke
parents:
diff changeset
494 __ verify_FPU(1, t->tos_in());
a61af66fc99e Initial load
duke
parents:
diff changeset
495 #endif // !PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
496 int step;
a61af66fc99e Initial load
duke
parents:
diff changeset
497 if (!t->does_dispatch()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 step = t->is_wide() ? Bytecodes::wide_length_for(t->bytecode()) : Bytecodes::length_for(t->bytecode());
a61af66fc99e Initial load
duke
parents:
diff changeset
499 if (tos_out == ilgl) tos_out = t->tos_out();
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // compute bytecode size
a61af66fc99e Initial load
duke
parents:
diff changeset
501 assert(step > 0, "just checkin'");
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // setup stuff for dispatching next bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
503 if (ProfileInterpreter && VerifyDataPointer
a61af66fc99e Initial load
duke
parents:
diff changeset
504 && methodDataOopDesc::bytecode_has_profile(t->bytecode())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
505 __ verify_method_data_pointer();
a61af66fc99e Initial load
duke
parents:
diff changeset
506 }
a61af66fc99e Initial load
duke
parents:
diff changeset
507 __ dispatch_prolog(tos_out, step);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // generate template
a61af66fc99e Initial load
duke
parents:
diff changeset
510 t->generate(_masm);
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // advance
a61af66fc99e Initial load
duke
parents:
diff changeset
512 if (t->does_dispatch()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // make sure execution doesn't go beyond this point if code is broken
a61af66fc99e Initial load
duke
parents:
diff changeset
515 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
517 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // dispatch to next bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
519 __ dispatch_epilog(tos_out, step);
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // Entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 address TemplateInterpreter::return_entry(TosState state, int length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 guarantee(0 <= length && length < Interpreter::number_of_return_entries, "illegal length");
a61af66fc99e Initial load
duke
parents:
diff changeset
528 return _return_entry[length].entry(state);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 address TemplateInterpreter::deopt_entry(TosState state, int length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
533 guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length");
a61af66fc99e Initial load
duke
parents:
diff changeset
534 return _deopt_entry[length].entry(state);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // Suport for invokes
a61af66fc99e Initial load
duke
parents:
diff changeset
539
a61af66fc99e Initial load
duke
parents:
diff changeset
540 int TemplateInterpreter::TosState_as_index(TosState state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
541 assert( state < number_of_states , "Invalid state in TosState_as_index");
a61af66fc99e Initial load
duke
parents:
diff changeset
542 assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
543 return (int)state;
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // Safepoint suppport
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 static inline void copy_table(address* from, address* to, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // Copy non-overlapping tables. The copy has to occur word wise for MT safety.
a61af66fc99e Initial load
duke
parents:
diff changeset
552 while (size-- > 0) *to++ = *from++;
a61af66fc99e Initial load
duke
parents:
diff changeset
553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
554
a61af66fc99e Initial load
duke
parents:
diff changeset
555 void TemplateInterpreter::notice_safepoints() {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 if (!_notice_safepoints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // switch to safepoint dispatch table
a61af66fc99e Initial load
duke
parents:
diff changeset
558 _notice_safepoints = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
559 copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // switch from the dispatch table which notices safepoints back to the
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // normal dispatch table. So that we can notice single stepping points,
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // keep the safepoint dispatch table if we are single stepping in JVMTI.
a61af66fc99e Initial load
duke
parents:
diff changeset
566 // Note that the should_post_single_step test is exactly as fast as the
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // JvmtiExport::_enabled test and covers both cases.
a61af66fc99e Initial load
duke
parents:
diff changeset
568 void TemplateInterpreter::ignore_safepoints() {
a61af66fc99e Initial load
duke
parents:
diff changeset
569 if (_notice_safepoints) {
a61af66fc99e Initial load
duke
parents:
diff changeset
570 if (!JvmtiExport::should_post_single_step()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
571 // switch to normal dispatch table
a61af66fc99e Initial load
duke
parents:
diff changeset
572 _notice_safepoints = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
573 copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
a61af66fc99e Initial load
duke
parents:
diff changeset
574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
575 }
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
578 //------------------------------------------------------------------------------------------------------------------------
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
579 // Deoptimization support
0
a61af66fc99e Initial load
duke
parents:
diff changeset
580
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
581 // If deoptimization happens, this function returns the point of next bytecode to continue execution
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
582 address TemplateInterpreter::deopt_continue_after_entry(methodOop method, address bcp, int callee_parameters, bool is_top_frame) {
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
583 return AbstractInterpreter::deopt_continue_after_entry(method, bcp, callee_parameters, is_top_frame);
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
584 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
585
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
586 // If deoptimization happens, this function returns the point where the interpreter reexecutes
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
587 // the bytecode.
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
588 // Note: Bytecodes::_athrow (C1 only) and Bytecodes::_return are the special cases
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
589 // that do not return "Interpreter::deopt_entry(vtos, 0)"
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
590 address TemplateInterpreter::deopt_reexecute_entry(methodOop method, address bcp) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
591 assert(method->contains(bcp), "just checkin'");
a61af66fc99e Initial load
duke
parents:
diff changeset
592 Bytecodes::Code code = Bytecodes::java_code_at(bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 if (code == Bytecodes::_return) {
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
594 // This is used for deopt during registration of finalizers
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
595 // during Object.<init>. We simply need to resume execution at
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
596 // the standard return vtos bytecode to pop the frame normally.
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
597 // reexecuting the real bytecode would cause double registration
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
598 // of the finalizable object.
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
599 return _normal_table.entry(Bytecodes::_return).entry(vtos);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
600 } else {
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
601 return AbstractInterpreter::deopt_reexecute_entry(method, bcp);
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
602 }
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
603 }
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
604
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
605 // If deoptimization happens, the interpreter should reexecute this bytecode.
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
606 // This function mainly helps the compilers to set up the reexecute bit.
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
607 bool TemplateInterpreter::bytecode_should_reexecute(Bytecodes::Code code) {
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
608 if (code == Bytecodes::_return) {
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
609 //Yes, we consider Bytecodes::_return as a special case of reexecution
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
610 return true;
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
611 } else {
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 726
diff changeset
612 return AbstractInterpreter::bytecode_should_reexecute(code);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
615
a61af66fc99e Initial load
duke
parents:
diff changeset
616 #endif // !CC_INTERP