Mercurial > hg > graal-jvmci-8
comparison src/share/vm/interpreter/templateInterpreter.cpp @ 23660:b5f3a471e646
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 01 Jun 2016 00:11:44 +0200 |
parents | 52b4284cb496 32b682649973 |
children | f13e777eb255 |
comparison
equal
deleted
inserted
replaced
23411:d7cf78885a3a | 23660:b5f3a471e646 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
59 | 59 |
60 //------------------------------------------------------------------------------------------------------------------------ | 60 //------------------------------------------------------------------------------------------------------------------------ |
61 // Implementation of EntryPoint | 61 // Implementation of EntryPoint |
62 | 62 |
63 EntryPoint::EntryPoint() { | 63 EntryPoint::EntryPoint() { |
64 assert(number_of_states == 9, "check the code below"); | 64 assert(number_of_states == 10, "check the code below"); |
65 _entry[btos] = NULL; | 65 _entry[btos] = NULL; |
66 _entry[ztos] = NULL; | |
66 _entry[ctos] = NULL; | 67 _entry[ctos] = NULL; |
67 _entry[stos] = NULL; | 68 _entry[stos] = NULL; |
68 _entry[atos] = NULL; | 69 _entry[atos] = NULL; |
69 _entry[itos] = NULL; | 70 _entry[itos] = NULL; |
70 _entry[ltos] = NULL; | 71 _entry[ltos] = NULL; |
72 _entry[dtos] = NULL; | 73 _entry[dtos] = NULL; |
73 _entry[vtos] = NULL; | 74 _entry[vtos] = NULL; |
74 } | 75 } |
75 | 76 |
76 | 77 |
77 EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) { | 78 EntryPoint::EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) { |
78 assert(number_of_states == 9, "check the code below"); | 79 assert(number_of_states == 10, "check the code below"); |
79 _entry[btos] = bentry; | 80 _entry[btos] = bentry; |
81 _entry[ztos] = zentry; | |
80 _entry[ctos] = centry; | 82 _entry[ctos] = centry; |
81 _entry[stos] = sentry; | 83 _entry[stos] = sentry; |
82 _entry[atos] = aentry; | 84 _entry[atos] = aentry; |
83 _entry[itos] = ientry; | 85 _entry[itos] = ientry; |
84 _entry[ltos] = lentry; | 86 _entry[ltos] = lentry; |
125 EntryPoint DispatchTable::entry(int i) const { | 127 EntryPoint DispatchTable::entry(int i) const { |
126 assert(0 <= i && i < length, "index out of bounds"); | 128 assert(0 <= i && i < length, "index out of bounds"); |
127 return | 129 return |
128 EntryPoint( | 130 EntryPoint( |
129 _table[btos][i], | 131 _table[btos][i], |
132 _table[ztos][i], | |
130 _table[ctos][i], | 133 _table[ctos][i], |
131 _table[stos][i], | 134 _table[stos][i], |
132 _table[atos][i], | 135 _table[atos][i], |
133 _table[itos][i], | 136 _table[itos][i], |
134 _table[ltos][i], | 137 _table[ltos][i], |
139 } | 142 } |
140 | 143 |
141 | 144 |
142 void DispatchTable::set_entry(int i, EntryPoint& entry) { | 145 void DispatchTable::set_entry(int i, EntryPoint& entry) { |
143 assert(0 <= i && i < length, "index out of bounds"); | 146 assert(0 <= i && i < length, "index out of bounds"); |
144 assert(number_of_states == 9, "check the code below"); | 147 assert(number_of_states == 10, "check the code below"); |
145 _table[btos][i] = entry.entry(btos); | 148 _table[btos][i] = entry.entry(btos); |
149 _table[ztos][i] = entry.entry(ztos); | |
146 _table[ctos][i] = entry.entry(ctos); | 150 _table[ctos][i] = entry.entry(ctos); |
147 _table[stos][i] = entry.entry(stos); | 151 _table[stos][i] = entry.entry(stos); |
148 _table[atos][i] = entry.entry(atos); | 152 _table[atos][i] = entry.entry(atos); |
149 _table[itos][i] = entry.entry(itos); | 153 _table[itos][i] = entry.entry(itos); |
150 _table[ltos][i] = entry.entry(ltos); | 154 _table[ltos][i] = entry.entry(ltos); |
223 if (TraceBytecodes) { | 227 if (TraceBytecodes) { |
224 CodeletMark cm(_masm, "bytecode tracing support"); | 228 CodeletMark cm(_masm, "bytecode tracing support"); |
225 Interpreter::_trace_code = | 229 Interpreter::_trace_code = |
226 EntryPoint( | 230 EntryPoint( |
227 generate_trace_code(btos), | 231 generate_trace_code(btos), |
232 generate_trace_code(ztos), | |
228 generate_trace_code(ctos), | 233 generate_trace_code(ctos), |
229 generate_trace_code(stos), | 234 generate_trace_code(stos), |
230 generate_trace_code(atos), | 235 generate_trace_code(atos), |
231 generate_trace_code(itos), | 236 generate_trace_code(itos), |
232 generate_trace_code(ltos), | 237 generate_trace_code(ltos), |
240 { CodeletMark cm(_masm, "return entry points"); | 245 { CodeletMark cm(_masm, "return entry points"); |
241 const int index_size = sizeof(u2); | 246 const int index_size = sizeof(u2); |
242 for (int i = 0; i < Interpreter::number_of_return_entries; i++) { | 247 for (int i = 0; i < Interpreter::number_of_return_entries; i++) { |
243 Interpreter::_return_entry[i] = | 248 Interpreter::_return_entry[i] = |
244 EntryPoint( | 249 EntryPoint( |
250 generate_return_entry_for(itos, i, index_size), | |
245 generate_return_entry_for(itos, i, index_size), | 251 generate_return_entry_for(itos, i, index_size), |
246 generate_return_entry_for(itos, i, index_size), | 252 generate_return_entry_for(itos, i, index_size), |
247 generate_return_entry_for(itos, i, index_size), | 253 generate_return_entry_for(itos, i, index_size), |
248 generate_return_entry_for(atos, i, index_size), | 254 generate_return_entry_for(atos, i, index_size), |
249 generate_return_entry_for(itos, i, index_size), | 255 generate_return_entry_for(itos, i, index_size), |
254 ); | 260 ); |
255 } | 261 } |
256 } | 262 } |
257 | 263 |
258 { CodeletMark cm(_masm, "invoke return entry points"); | 264 { CodeletMark cm(_masm, "invoke return entry points"); |
259 const TosState states[] = {itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos}; | 265 // These states are in order specified in TosState, except btos/ztos/ctos/stos are |
266 // really the same as itos since there is no top of stack optimization for these types | |
267 const TosState states[] = {itos, itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos, ilgl}; | |
260 const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic); | 268 const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic); |
261 const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface); | 269 const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface); |
262 const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic); | 270 const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic); |
263 | 271 |
264 for (int i = 0; i < Interpreter::number_of_return_addrs; i++) { | 272 for (int i = 0; i < Interpreter::number_of_return_addrs; i++) { |
265 TosState state = states[i]; | 273 TosState state = states[i]; |
274 assert(state != ilgl, "states array is wrong above"); | |
266 Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2)); | 275 Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2)); |
267 Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2)); | 276 Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2)); |
268 Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4)); | 277 Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4)); |
269 } | 278 } |
270 } | 279 } |
271 | 280 |
272 { CodeletMark cm(_masm, "earlyret entry points"); | 281 { CodeletMark cm(_masm, "earlyret entry points"); |
273 Interpreter::_earlyret_entry = | 282 Interpreter::_earlyret_entry = |
274 EntryPoint( | 283 EntryPoint( |
275 generate_earlyret_entry_for(btos), | 284 generate_earlyret_entry_for(btos), |
285 generate_earlyret_entry_for(ztos), | |
276 generate_earlyret_entry_for(ctos), | 286 generate_earlyret_entry_for(ctos), |
277 generate_earlyret_entry_for(stos), | 287 generate_earlyret_entry_for(stos), |
278 generate_earlyret_entry_for(atos), | 288 generate_earlyret_entry_for(atos), |
279 generate_earlyret_entry_for(itos), | 289 generate_earlyret_entry_for(itos), |
280 generate_earlyret_entry_for(ltos), | 290 generate_earlyret_entry_for(ltos), |
286 | 296 |
287 { CodeletMark cm(_masm, "deoptimization entry points"); | 297 { CodeletMark cm(_masm, "deoptimization entry points"); |
288 for (int i = 0; i < Interpreter::number_of_deopt_entries; i++) { | 298 for (int i = 0; i < Interpreter::number_of_deopt_entries; i++) { |
289 Interpreter::_deopt_entry[i] = | 299 Interpreter::_deopt_entry[i] = |
290 EntryPoint( | 300 EntryPoint( |
301 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), | |
291 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), | 302 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), |
292 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), | 303 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), |
293 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), | 304 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), |
294 ((InterpreterGenerator*)this)->generate_deopt_entry_for(atos, i), | 305 ((InterpreterGenerator*)this)->generate_deopt_entry_for(atos, i), |
295 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), | 306 ((InterpreterGenerator*)this)->generate_deopt_entry_for(itos, i), |
316 | 327 |
317 { CodeletMark cm(_masm, "continuation entry points"); | 328 { CodeletMark cm(_masm, "continuation entry points"); |
318 Interpreter::_continuation_entry = | 329 Interpreter::_continuation_entry = |
319 EntryPoint( | 330 EntryPoint( |
320 generate_continuation_for(btos), | 331 generate_continuation_for(btos), |
332 generate_continuation_for(ztos), | |
321 generate_continuation_for(ctos), | 333 generate_continuation_for(ctos), |
322 generate_continuation_for(stos), | 334 generate_continuation_for(stos), |
323 generate_continuation_for(atos), | 335 generate_continuation_for(atos), |
324 generate_continuation_for(itos), | 336 generate_continuation_for(itos), |
325 generate_continuation_for(ltos), | 337 generate_continuation_for(ltos), |
331 | 343 |
332 { CodeletMark cm(_masm, "safepoint entry points"); | 344 { CodeletMark cm(_masm, "safepoint entry points"); |
333 Interpreter::_safept_entry = | 345 Interpreter::_safept_entry = |
334 EntryPoint( | 346 EntryPoint( |
335 generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 347 generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
348 generate_safept_entry_for(ztos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | |
336 generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 349 generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
337 generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 350 generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
338 generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 351 generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
339 generate_safept_entry_for(itos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 352 generate_safept_entry_for(itos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
340 generate_safept_entry_for(ltos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), | 353 generate_safept_entry_for(ltos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)), |
434 } | 447 } |
435 | 448 |
436 | 449 |
437 void TemplateInterpreterGenerator::set_unimplemented(int i) { | 450 void TemplateInterpreterGenerator::set_unimplemented(int i) { |
438 address e = _unimplemented_bytecode; | 451 address e = _unimplemented_bytecode; |
439 EntryPoint entry(e, e, e, e, e, e, e, e, e); | 452 EntryPoint entry(e, e, e, e, e, e, e, e, e, e); |
440 Interpreter::_normal_table.set_entry(i, entry); | 453 Interpreter::_normal_table.set_entry(i, entry); |
441 Interpreter::_wentry_point[i] = _unimplemented_bytecode; | 454 Interpreter::_wentry_point[i] = _unimplemented_bytecode; |
442 } | 455 } |
443 | 456 |
444 | 457 |
446 CodeletMark cm(_masm, Bytecodes::name(code), code); | 459 CodeletMark cm(_masm, Bytecodes::name(code), code); |
447 // initialize entry points | 460 // initialize entry points |
448 assert(_unimplemented_bytecode != NULL, "should have been generated before"); | 461 assert(_unimplemented_bytecode != NULL, "should have been generated before"); |
449 assert(_illegal_bytecode_sequence != NULL, "should have been generated before"); | 462 assert(_illegal_bytecode_sequence != NULL, "should have been generated before"); |
450 address bep = _illegal_bytecode_sequence; | 463 address bep = _illegal_bytecode_sequence; |
464 address zep = _illegal_bytecode_sequence; | |
451 address cep = _illegal_bytecode_sequence; | 465 address cep = _illegal_bytecode_sequence; |
452 address sep = _illegal_bytecode_sequence; | 466 address sep = _illegal_bytecode_sequence; |
453 address aep = _illegal_bytecode_sequence; | 467 address aep = _illegal_bytecode_sequence; |
454 address iep = _illegal_bytecode_sequence; | 468 address iep = _illegal_bytecode_sequence; |
455 address lep = _illegal_bytecode_sequence; | 469 address lep = _illegal_bytecode_sequence; |
467 Template* t = TemplateTable::template_for_wide(code); | 481 Template* t = TemplateTable::template_for_wide(code); |
468 assert(t->is_valid(), "just checking"); | 482 assert(t->is_valid(), "just checking"); |
469 set_wide_entry_point(t, wep); | 483 set_wide_entry_point(t, wep); |
470 } | 484 } |
471 // set entry points | 485 // set entry points |
472 EntryPoint entry(bep, cep, sep, aep, iep, lep, fep, dep, vep); | 486 EntryPoint entry(bep, zep, cep, sep, aep, iep, lep, fep, dep, vep); |
473 Interpreter::_normal_table.set_entry(code, entry); | 487 Interpreter::_normal_table.set_entry(code, entry); |
474 Interpreter::_wentry_point[code] = wep; | 488 Interpreter::_wentry_point[code] = wep; |
475 } | 489 } |
476 | 490 |
477 | 491 |
484 | 498 |
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) { | 499 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"); | 500 assert(t->is_valid(), "template must exist"); |
487 switch (t->tos_in()) { | 501 switch (t->tos_in()) { |
488 case btos: | 502 case btos: |
503 case ztos: | |
489 case ctos: | 504 case ctos: |
490 case stos: | 505 case stos: |
491 ShouldNotReachHere(); // btos/ctos/stos should use itos. | 506 ShouldNotReachHere(); // btos/ctos/stos should use itos. |
492 break; | 507 break; |
493 case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break; | 508 case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break; |