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