Mercurial > hg > graal-compiler
annotate src/cpu/x86/vm/templateInterpreter_x86_64.cpp @ 1580:f56e28f22410
6958458: Bump the HS19 build number to 03
Summary: Update the HS19 build number to 03
Reviewed-by: jcoomes
author | trims |
---|---|
date | Thu, 03 Jun 2010 18:18:56 -0700 |
parents | e9ff18c4ace7 |
children | d5d065957597 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_interpreter_x86_64.cpp.incl" | |
27 | |
28 #define __ _masm-> | |
29 | |
304 | 30 #ifndef CC_INTERP |
31 | |
0 | 32 const int method_offset = frame::interpreter_frame_method_offset * wordSize; |
33 const int bci_offset = frame::interpreter_frame_bcx_offset * wordSize; | |
34 const int locals_offset = frame::interpreter_frame_locals_offset * wordSize; | |
35 | |
36 //----------------------------------------------------------------------------- | |
37 | |
38 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { | |
39 address entry = __ pc(); | |
40 | |
41 #ifdef ASSERT | |
42 { | |
43 Label L; | |
304 | 44 __ lea(rax, Address(rbp, |
45 frame::interpreter_frame_monitor_block_top_offset * | |
46 wordSize)); | |
47 __ cmpptr(rax, rsp); // rax = maximal rsp for current rbp (stack | |
48 // grows negative) | |
0 | 49 __ jcc(Assembler::aboveEqual, L); // check if frame is complete |
50 __ stop ("interpreter frame not set up"); | |
51 __ bind(L); | |
52 } | |
53 #endif // ASSERT | |
54 // Restore bcp under the assumption that the current frame is still | |
55 // interpreted | |
56 __ restore_bcp(); | |
57 | |
58 // expression stack must be empty before entering the VM if an | |
59 // exception happened | |
60 __ empty_expression_stack(); | |
61 // throw exception | |
62 __ call_VM(noreg, | |
63 CAST_FROM_FN_PTR(address, | |
64 InterpreterRuntime::throw_StackOverflowError)); | |
65 return entry; | |
66 } | |
67 | |
68 address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler( | |
69 const char* name) { | |
70 address entry = __ pc(); | |
71 // expression stack must be empty before entering the VM if an | |
72 // exception happened | |
73 __ empty_expression_stack(); | |
74 // setup parameters | |
75 // ??? convention: expect aberrant index in register ebx | |
76 __ lea(c_rarg1, ExternalAddress((address)name)); | |
77 __ call_VM(noreg, | |
78 CAST_FROM_FN_PTR(address, | |
79 InterpreterRuntime:: | |
80 throw_ArrayIndexOutOfBoundsException), | |
81 c_rarg1, rbx); | |
82 return entry; | |
83 } | |
84 | |
85 address TemplateInterpreterGenerator::generate_ClassCastException_handler() { | |
86 address entry = __ pc(); | |
87 | |
88 // object is at TOS | |
304 | 89 __ pop(c_rarg1); |
0 | 90 |
91 // expression stack must be empty before entering the VM if an | |
92 // exception happened | |
93 __ empty_expression_stack(); | |
94 | |
95 __ call_VM(noreg, | |
96 CAST_FROM_FN_PTR(address, | |
97 InterpreterRuntime:: | |
98 throw_ClassCastException), | |
99 c_rarg1); | |
100 return entry; | |
101 } | |
102 | |
1108 | 103 // Arguments are: required type at TOS+8, failing object (or NULL) at TOS+4. |
710 | 104 address TemplateInterpreterGenerator::generate_WrongMethodType_handler() { |
105 address entry = __ pc(); | |
106 | |
107 __ pop(c_rarg2); // failing object is at TOS | |
108 __ pop(c_rarg1); // required type is at TOS+8 | |
109 | |
1108 | 110 __ verify_oop(c_rarg1); |
111 __ verify_oop(c_rarg2); | |
112 | |
113 // Various method handle types use interpreter registers as temps. | |
114 __ restore_bcp(); | |
115 __ restore_locals(); | |
116 | |
117 // Expression stack must be empty before entering the VM for an exception. | |
710 | 118 __ empty_expression_stack(); |
119 | |
120 __ call_VM(noreg, | |
121 CAST_FROM_FN_PTR(address, | |
1108 | 122 InterpreterRuntime::throw_WrongMethodTypeException), |
710 | 123 // pass required type, failing object (or NULL) |
124 c_rarg1, c_rarg2); | |
125 return entry; | |
126 } | |
127 | |
0 | 128 address TemplateInterpreterGenerator::generate_exception_handler_common( |
129 const char* name, const char* message, bool pass_oop) { | |
130 assert(!pass_oop || message == NULL, "either oop or message but not both"); | |
131 address entry = __ pc(); | |
132 if (pass_oop) { | |
133 // object is at TOS | |
304 | 134 __ pop(c_rarg2); |
0 | 135 } |
136 // expression stack must be empty before entering the VM if an | |
137 // exception happened | |
138 __ empty_expression_stack(); | |
139 // setup parameters | |
140 __ lea(c_rarg1, ExternalAddress((address)name)); | |
141 if (pass_oop) { | |
142 __ call_VM(rax, CAST_FROM_FN_PTR(address, | |
143 InterpreterRuntime:: | |
144 create_klass_exception), | |
145 c_rarg1, c_rarg2); | |
146 } else { | |
147 // kind of lame ExternalAddress can't take NULL because | |
148 // external_word_Relocation will assert. | |
149 if (message != NULL) { | |
150 __ lea(c_rarg2, ExternalAddress((address)message)); | |
151 } else { | |
152 __ movptr(c_rarg2, NULL_WORD); | |
153 } | |
154 __ call_VM(rax, | |
155 CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), | |
156 c_rarg1, c_rarg2); | |
157 } | |
158 // throw exception | |
159 __ jump(ExternalAddress(Interpreter::throw_exception_entry())); | |
160 return entry; | |
161 } | |
162 | |
163 | |
164 address TemplateInterpreterGenerator::generate_continuation_for(TosState state) { | |
165 address entry = __ pc(); | |
166 // NULL last_sp until next java call | |
304 | 167 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 168 __ dispatch_next(state); |
169 return entry; | |
170 } | |
171 | |
172 | |
173 address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
174 int step) { |
0 | 175 |
176 // amd64 doesn't need to do anything special about compiled returns | |
177 // to the interpreter so the code that exists on x86 to place a sentinel | |
178 // here and the specialized cleanup code is not needed here. | |
179 | |
180 address entry = __ pc(); | |
181 | |
182 // Restore stack bottom in case i2c adjusted stack | |
304 | 183 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
0 | 184 // and NULL it as marker that esp is now tos until next java call |
304 | 185 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 186 |
187 __ restore_bcp(); | |
188 __ restore_locals(); | |
304 | 189 |
1108 | 190 Label L_got_cache, L_giant_index; |
191 if (EnableInvokeDynamic) { | |
192 __ cmpb(Address(r13, 0), Bytecodes::_invokedynamic); | |
193 __ jcc(Assembler::equal, L_giant_index); | |
194 } | |
1565 | 195 __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u2)); |
1108 | 196 __ bind(L_got_cache); |
0 | 197 __ movl(rbx, Address(rbx, rcx, |
1108 | 198 Address::times_ptr, |
0 | 199 in_bytes(constantPoolCacheOopDesc::base_offset()) + |
200 3 * wordSize)); | |
201 __ andl(rbx, 0xFF); | |
304 | 202 __ lea(rsp, Address(rsp, rbx, Address::times_8)); |
0 | 203 __ dispatch_next(state, step); |
1108 | 204 |
205 // out of the main line of code... | |
206 if (EnableInvokeDynamic) { | |
207 __ bind(L_giant_index); | |
1565 | 208 __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u4)); |
1108 | 209 __ jmp(L_got_cache); |
210 } | |
211 | |
0 | 212 return entry; |
213 } | |
214 | |
215 | |
216 address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, | |
217 int step) { | |
218 address entry = __ pc(); | |
219 // NULL last_sp until next java call | |
304 | 220 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 221 __ restore_bcp(); |
222 __ restore_locals(); | |
223 // handle exceptions | |
224 { | |
225 Label L; | |
304 | 226 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
0 | 227 __ jcc(Assembler::zero, L); |
228 __ call_VM(noreg, | |
229 CAST_FROM_FN_PTR(address, | |
230 InterpreterRuntime::throw_pending_exception)); | |
231 __ should_not_reach_here(); | |
232 __ bind(L); | |
233 } | |
234 __ dispatch_next(state, step); | |
235 return entry; | |
236 } | |
237 | |
238 int AbstractInterpreter::BasicType_as_index(BasicType type) { | |
239 int i = 0; | |
240 switch (type) { | |
241 case T_BOOLEAN: i = 0; break; | |
242 case T_CHAR : i = 1; break; | |
243 case T_BYTE : i = 2; break; | |
244 case T_SHORT : i = 3; break; | |
245 case T_INT : i = 4; break; | |
246 case T_LONG : i = 5; break; | |
247 case T_VOID : i = 6; break; | |
248 case T_FLOAT : i = 7; break; | |
249 case T_DOUBLE : i = 8; break; | |
250 case T_OBJECT : i = 9; break; | |
251 case T_ARRAY : i = 9; break; | |
252 default : ShouldNotReachHere(); | |
253 } | |
254 assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, | |
255 "index out of bounds"); | |
256 return i; | |
257 } | |
258 | |
259 | |
260 address TemplateInterpreterGenerator::generate_result_handler_for( | |
261 BasicType type) { | |
262 address entry = __ pc(); | |
263 switch (type) { | |
264 case T_BOOLEAN: __ c2bool(rax); break; | |
265 case T_CHAR : __ movzwl(rax, rax); break; | |
266 case T_BYTE : __ sign_extend_byte(rax); break; | |
267 case T_SHORT : __ sign_extend_short(rax); break; | |
268 case T_INT : /* nothing to do */ break; | |
269 case T_LONG : /* nothing to do */ break; | |
270 case T_VOID : /* nothing to do */ break; | |
271 case T_FLOAT : /* nothing to do */ break; | |
272 case T_DOUBLE : /* nothing to do */ break; | |
273 case T_OBJECT : | |
274 // retrieve result from frame | |
304 | 275 __ movptr(rax, Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize)); |
0 | 276 // and verify it |
277 __ verify_oop(rax); | |
278 break; | |
279 default : ShouldNotReachHere(); | |
280 } | |
281 __ ret(0); // return from result handler | |
282 return entry; | |
283 } | |
284 | |
285 address TemplateInterpreterGenerator::generate_safept_entry_for( | |
286 TosState state, | |
287 address runtime_entry) { | |
288 address entry = __ pc(); | |
289 __ push(state); | |
290 __ call_VM(noreg, runtime_entry); | |
291 __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos)); | |
292 return entry; | |
293 } | |
294 | |
295 | |
296 | |
297 // Helpers for commoning out cases in the various type of method entries. | |
298 // | |
299 | |
300 | |
301 // increment invocation count & check for overflow | |
302 // | |
303 // Note: checking for negative value instead of overflow | |
304 // so we have a 'sticky' overflow test | |
305 // | |
306 // rbx: method | |
307 // ecx: invocation counter | |
308 // | |
309 void InterpreterGenerator::generate_counter_incr( | |
310 Label* overflow, | |
311 Label* profile_method, | |
312 Label* profile_method_continue) { | |
313 | |
314 const Address invocation_counter(rbx, | |
315 methodOopDesc::invocation_counter_offset() + | |
316 InvocationCounter::counter_offset()); | |
317 const Address backedge_counter(rbx, | |
318 methodOopDesc::backedge_counter_offset() + | |
319 InvocationCounter::counter_offset()); | |
320 | |
321 if (ProfileInterpreter) { // %%% Merge this into methodDataOop | |
322 __ incrementl(Address(rbx, | |
323 methodOopDesc::interpreter_invocation_counter_offset())); | |
324 } | |
325 // Update standard invocation counters | |
326 __ movl(rax, backedge_counter); // load backedge counter | |
327 | |
328 __ incrementl(rcx, InvocationCounter::count_increment); | |
329 __ andl(rax, InvocationCounter::count_mask_value); // mask out the | |
330 // status bits | |
331 | |
332 __ movl(invocation_counter, rcx); // save invocation count | |
333 __ addl(rcx, rax); // add both counters | |
334 | |
335 // profile_method is non-null only for interpreted method so | |
336 // profile_method != NULL == !native_call | |
337 | |
338 if (ProfileInterpreter && profile_method != NULL) { | |
339 // Test to see if we should create a method data oop | |
340 __ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterProfileLimit)); | |
341 __ jcc(Assembler::less, *profile_method_continue); | |
342 | |
343 // if no method data exists, go to profile_method | |
344 __ test_method_data_pointer(rax, *profile_method); | |
345 } | |
346 | |
347 __ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit)); | |
348 __ jcc(Assembler::aboveEqual, *overflow); | |
349 } | |
350 | |
351 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { | |
352 | |
353 // Asm interpreter on entry | |
354 // r14 - locals | |
355 // r13 - bcp | |
356 // rbx - method | |
357 // edx - cpool --- DOES NOT APPEAR TO BE TRUE | |
358 // rbp - interpreter frame | |
359 | |
360 // On return (i.e. jump to entry_point) [ back to invocation of interpreter ] | |
361 // Everything as it was on entry | |
362 // rdx is not restored. Doesn't appear to really be set. | |
363 | |
364 const Address size_of_parameters(rbx, | |
365 methodOopDesc::size_of_parameters_offset()); | |
366 | |
367 // InterpreterRuntime::frequency_counter_overflow takes two | |
368 // arguments, the first (thread) is passed by call_VM, the second | |
369 // indicates if the counter overflow occurs at a backwards branch | |
370 // (NULL bcp). We pass zero for it. The call returns the address | |
371 // of the verified entry point for the method or NULL if the | |
372 // compilation did not complete (either went background or bailed | |
373 // out). | |
374 __ movl(c_rarg1, 0); | |
375 __ call_VM(noreg, | |
376 CAST_FROM_FN_PTR(address, | |
377 InterpreterRuntime::frequency_counter_overflow), | |
378 c_rarg1); | |
379 | |
304 | 380 __ movptr(rbx, Address(rbp, method_offset)); // restore methodOop |
0 | 381 // Preserve invariant that r13/r14 contain bcp/locals of sender frame |
382 // and jump to the interpreted entry. | |
383 __ jmp(*do_continue, relocInfo::none); | |
384 } | |
385 | |
386 // See if we've got enough room on the stack for locals plus overhead. | |
387 // The expression stack grows down incrementally, so the normal guard | |
388 // page mechanism will work for that. | |
389 // | |
390 // NOTE: Since the additional locals are also always pushed (wasn't | |
391 // obvious in generate_method_entry) so the guard should work for them | |
392 // too. | |
393 // | |
394 // Args: | |
395 // rdx: number of additional locals this frame needs (what we must check) | |
396 // rbx: methodOop | |
397 // | |
398 // Kills: | |
399 // rax | |
400 void InterpreterGenerator::generate_stack_overflow_check(void) { | |
401 | |
402 // monitor entry size: see picture of stack set | |
403 // (generate_method_entry) and frame_amd64.hpp | |
404 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
405 | |
406 // total overhead size: entry_size + (saved rbp through expr stack | |
407 // bottom). be sure to change this if you add/subtract anything | |
408 // to/from the overhead area | |
409 const int overhead_size = | |
410 -(frame::interpreter_frame_initial_sp_offset * wordSize) + entry_size; | |
411 | |
412 const int page_size = os::vm_page_size(); | |
413 | |
414 Label after_frame_check; | |
415 | |
416 // see if the frame is greater than one page in size. If so, | |
417 // then we need to verify there is enough stack space remaining | |
418 // for the additional locals. | |
1506 | 419 __ cmpl(rdx, (page_size - overhead_size) / Interpreter::stackElementSize); |
0 | 420 __ jcc(Assembler::belowEqual, after_frame_check); |
421 | |
422 // compute rsp as if this were going to be the last frame on | |
423 // the stack before the red zone | |
424 | |
425 const Address stack_base(r15_thread, Thread::stack_base_offset()); | |
426 const Address stack_size(r15_thread, Thread::stack_size_offset()); | |
427 | |
428 // locals + overhead, in bytes | |
304 | 429 __ mov(rax, rdx); |
1506 | 430 __ shlptr(rax, Interpreter::logStackElementSize); // 2 slots per parameter. |
304 | 431 __ addptr(rax, overhead_size); |
0 | 432 |
433 #ifdef ASSERT | |
434 Label stack_base_okay, stack_size_okay; | |
435 // verify that thread stack base is non-zero | |
304 | 436 __ cmpptr(stack_base, (int32_t)NULL_WORD); |
0 | 437 __ jcc(Assembler::notEqual, stack_base_okay); |
438 __ stop("stack base is zero"); | |
439 __ bind(stack_base_okay); | |
440 // verify that thread stack size is non-zero | |
304 | 441 __ cmpptr(stack_size, 0); |
0 | 442 __ jcc(Assembler::notEqual, stack_size_okay); |
443 __ stop("stack size is zero"); | |
444 __ bind(stack_size_okay); | |
445 #endif | |
446 | |
447 // Add stack base to locals and subtract stack size | |
304 | 448 __ addptr(rax, stack_base); |
449 __ subptr(rax, stack_size); | |
0 | 450 |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
451 // Use the maximum number of pages we might bang. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
452 const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages : |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
453 (StackRedPages+StackYellowPages); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
454 |
0 | 455 // add in the red and yellow zone sizes |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
456 __ addptr(rax, max_pages * page_size); |
0 | 457 |
458 // check against the current stack bottom | |
304 | 459 __ cmpptr(rsp, rax); |
0 | 460 __ jcc(Assembler::above, after_frame_check); |
461 | |
304 | 462 __ pop(rax); // get return address |
0 | 463 __ jump(ExternalAddress(Interpreter::throw_StackOverflowError_entry())); |
464 | |
465 // all done with frame size check | |
466 __ bind(after_frame_check); | |
467 } | |
468 | |
469 // Allocate monitor and lock method (asm interpreter) | |
470 // | |
471 // Args: | |
472 // rbx: methodOop | |
473 // r14: locals | |
474 // | |
475 // Kills: | |
476 // rax | |
477 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ...(param regs) | |
478 // rscratch1, rscratch2 (scratch regs) | |
479 void InterpreterGenerator::lock_method(void) { | |
480 // synchronize method | |
481 const Address access_flags(rbx, methodOopDesc::access_flags_offset()); | |
482 const Address monitor_block_top( | |
483 rbp, | |
484 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
485 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
486 | |
487 #ifdef ASSERT | |
488 { | |
489 Label L; | |
490 __ movl(rax, access_flags); | |
491 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
492 __ jcc(Assembler::notZero, L); | |
493 __ stop("method doesn't need synchronization"); | |
494 __ bind(L); | |
495 } | |
496 #endif // ASSERT | |
497 | |
498 // get synchronization object | |
499 { | |
500 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + | |
501 Klass::java_mirror_offset_in_bytes(); | |
502 Label done; | |
503 __ movl(rax, access_flags); | |
504 __ testl(rax, JVM_ACC_STATIC); | |
505 // get receiver (assume this is frequent case) | |
304 | 506 __ movptr(rax, Address(r14, Interpreter::local_offset_in_bytes(0))); |
0 | 507 __ jcc(Assembler::zero, done); |
304 | 508 __ movptr(rax, Address(rbx, methodOopDesc::constants_offset())); |
509 __ movptr(rax, Address(rax, | |
510 constantPoolOopDesc::pool_holder_offset_in_bytes())); | |
511 __ movptr(rax, Address(rax, mirror_offset)); | |
0 | 512 |
513 #ifdef ASSERT | |
514 { | |
515 Label L; | |
304 | 516 __ testptr(rax, rax); |
0 | 517 __ jcc(Assembler::notZero, L); |
518 __ stop("synchronization object is NULL"); | |
519 __ bind(L); | |
520 } | |
521 #endif // ASSERT | |
522 | |
523 __ bind(done); | |
524 } | |
525 | |
526 // add space for monitor & lock | |
304 | 527 __ subptr(rsp, entry_size); // add space for a monitor entry |
528 __ movptr(monitor_block_top, rsp); // set new monitor block top | |
0 | 529 // store object |
304 | 530 __ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); |
531 __ movptr(c_rarg1, rsp); // object address | |
0 | 532 __ lock_object(c_rarg1); |
533 } | |
534 | |
535 // Generate a fixed interpreter frame. This is identical setup for | |
536 // interpreted methods and for native methods hence the shared code. | |
537 // | |
538 // Args: | |
539 // rax: return address | |
540 // rbx: methodOop | |
541 // r14: pointer to locals | |
542 // r13: sender sp | |
543 // rdx: cp cache | |
544 void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { | |
545 // initialize fixed part of activation frame | |
304 | 546 __ push(rax); // save return address |
0 | 547 __ enter(); // save old & set new rbp |
304 | 548 __ push(r13); // set sender sp |
549 __ push((int)NULL_WORD); // leave last_sp as null | |
550 __ movptr(r13, Address(rbx, methodOopDesc::const_offset())); // get constMethodOop | |
551 __ lea(r13, Address(r13, constMethodOopDesc::codes_offset())); // get codebase | |
552 __ push(rbx); // save methodOop | |
0 | 553 if (ProfileInterpreter) { |
554 Label method_data_continue; | |
304 | 555 __ movptr(rdx, Address(rbx, in_bytes(methodOopDesc::method_data_offset()))); |
556 __ testptr(rdx, rdx); | |
0 | 557 __ jcc(Assembler::zero, method_data_continue); |
304 | 558 __ addptr(rdx, in_bytes(methodDataOopDesc::data_offset())); |
0 | 559 __ bind(method_data_continue); |
304 | 560 __ push(rdx); // set the mdp (method data pointer) |
0 | 561 } else { |
304 | 562 __ push(0); |
0 | 563 } |
564 | |
304 | 565 __ movptr(rdx, Address(rbx, methodOopDesc::constants_offset())); |
566 __ movptr(rdx, Address(rdx, constantPoolOopDesc::cache_offset_in_bytes())); | |
567 __ push(rdx); // set constant pool cache | |
568 __ push(r14); // set locals pointer | |
0 | 569 if (native_call) { |
304 | 570 __ push(0); // no bcp |
0 | 571 } else { |
304 | 572 __ push(r13); // set bcp |
0 | 573 } |
304 | 574 __ push(0); // reserve word for pointer to expression stack bottom |
575 __ movptr(Address(rsp, 0), rsp); // set expression stack bottom | |
0 | 576 } |
577 | |
578 // End of helpers | |
579 | |
304 | 580 // Various method entries |
581 //------------------------------------------------------------------------------------------------------------------------ | |
582 // | |
583 // | |
584 | |
585 // Call an accessor method (assuming it is resolved, otherwise drop | |
586 // into vanilla (slow path) entry | |
587 address InterpreterGenerator::generate_accessor_entry(void) { | |
588 // rbx: methodOop | |
589 | |
590 // r13: senderSP must preserver for slow path, set SP to it on fast path | |
591 | |
592 address entry_point = __ pc(); | |
593 Label xreturn_path; | |
594 | |
595 // do fastpath for resolved accessor methods | |
596 if (UseFastAccessorMethods) { | |
597 // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites | |
598 // thereof; parameter size = 1 | |
599 // Note: We can only use this code if the getfield has been resolved | |
600 // and if we don't have a null-pointer exception => check for | |
601 // these conditions first and use slow path if necessary. | |
602 Label slow_path; | |
603 // If we need a safepoint check, generate full interpreter entry. | |
604 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), | |
605 SafepointSynchronize::_not_synchronized); | |
606 | |
607 __ jcc(Assembler::notEqual, slow_path); | |
608 // rbx: method | |
609 __ movptr(rax, Address(rsp, wordSize)); | |
610 | |
611 // check if local 0 != NULL and read field | |
612 __ testptr(rax, rax); | |
613 __ jcc(Assembler::zero, slow_path); | |
614 | |
615 __ movptr(rdi, Address(rbx, methodOopDesc::constants_offset())); | |
616 // read first instruction word and extract bytecode @ 1 and index @ 2 | |
617 __ movptr(rdx, Address(rbx, methodOopDesc::const_offset())); | |
618 __ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset())); | |
619 // Shift codes right to get the index on the right. | |
620 // The bytecode fetched looks like <index><0xb4><0x2a> | |
621 __ shrl(rdx, 2 * BitsPerByte); | |
622 __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); | |
623 __ movptr(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes())); | |
624 | |
625 // rax: local 0 | |
626 // rbx: method | |
627 // rdx: constant pool cache index | |
628 // rdi: constant pool cache | |
629 | |
630 // check if getfield has been resolved and read constant pool cache entry | |
631 // check the validity of the cache entry by testing whether _indices field | |
632 // contains Bytecode::_getfield in b1 byte. | |
633 assert(in_words(ConstantPoolCacheEntry::size()) == 4, | |
634 "adjust shift below"); | |
635 __ movl(rcx, | |
636 Address(rdi, | |
637 rdx, | |
638 Address::times_8, | |
639 constantPoolCacheOopDesc::base_offset() + | |
640 ConstantPoolCacheEntry::indices_offset())); | |
641 __ shrl(rcx, 2 * BitsPerByte); | |
642 __ andl(rcx, 0xFF); | |
643 __ cmpl(rcx, Bytecodes::_getfield); | |
644 __ jcc(Assembler::notEqual, slow_path); | |
645 | |
646 // Note: constant pool entry is not valid before bytecode is resolved | |
647 __ movptr(rcx, | |
648 Address(rdi, | |
649 rdx, | |
650 Address::times_8, | |
651 constantPoolCacheOopDesc::base_offset() + | |
652 ConstantPoolCacheEntry::f2_offset())); | |
653 // edx: flags | |
654 __ movl(rdx, | |
655 Address(rdi, | |
656 rdx, | |
657 Address::times_8, | |
658 constantPoolCacheOopDesc::base_offset() + | |
659 ConstantPoolCacheEntry::flags_offset())); | |
660 | |
661 Label notObj, notInt, notByte, notShort; | |
662 const Address field_address(rax, rcx, Address::times_1); | |
663 | |
664 // Need to differentiate between igetfield, agetfield, bgetfield etc. | |
665 // because they are different sizes. | |
666 // Use the type from the constant pool cache | |
667 __ shrl(rdx, ConstantPoolCacheEntry::tosBits); | |
668 // Make sure we don't need to mask edx for tosBits after the above shift | |
669 ConstantPoolCacheEntry::verify_tosBits(); | |
670 | |
671 __ cmpl(rdx, atos); | |
672 __ jcc(Assembler::notEqual, notObj); | |
673 // atos | |
674 __ load_heap_oop(rax, field_address); | |
675 __ jmp(xreturn_path); | |
676 | |
677 __ bind(notObj); | |
678 __ cmpl(rdx, itos); | |
679 __ jcc(Assembler::notEqual, notInt); | |
680 // itos | |
681 __ movl(rax, field_address); | |
682 __ jmp(xreturn_path); | |
683 | |
684 __ bind(notInt); | |
685 __ cmpl(rdx, btos); | |
686 __ jcc(Assembler::notEqual, notByte); | |
687 // btos | |
688 __ load_signed_byte(rax, field_address); | |
689 __ jmp(xreturn_path); | |
690 | |
691 __ bind(notByte); | |
692 __ cmpl(rdx, stos); | |
693 __ jcc(Assembler::notEqual, notShort); | |
694 // stos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
695 __ load_signed_short(rax, field_address); |
304 | 696 __ jmp(xreturn_path); |
697 | |
698 __ bind(notShort); | |
699 #ifdef ASSERT | |
700 Label okay; | |
701 __ cmpl(rdx, ctos); | |
702 __ jcc(Assembler::equal, okay); | |
703 __ stop("what type is this?"); | |
704 __ bind(okay); | |
705 #endif | |
706 // ctos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
707 __ load_unsigned_short(rax, field_address); |
304 | 708 |
709 __ bind(xreturn_path); | |
710 | |
711 // _ireturn/_areturn | |
712 __ pop(rdi); | |
713 __ mov(rsp, r13); | |
714 __ jmp(rdi); | |
715 __ ret(0); | |
716 | |
717 // generate a vanilla interpreter entry as the slow path | |
718 __ bind(slow_path); | |
719 (void) generate_normal_entry(false); | |
720 } else { | |
721 (void) generate_normal_entry(false); | |
722 } | |
723 | |
724 return entry_point; | |
725 } | |
726 | |
0 | 727 // Interpreter stub for calling a native method. (asm interpreter) |
728 // This sets up a somewhat different looking stack for calling the | |
729 // native method than the typical interpreter frame setup. | |
730 address InterpreterGenerator::generate_native_entry(bool synchronized) { | |
731 // determine code generation flags | |
732 bool inc_counter = UseCompiler || CountCompiledCalls; | |
733 | |
734 // rbx: methodOop | |
735 // r13: sender sp | |
736 | |
737 address entry_point = __ pc(); | |
738 | |
739 const Address size_of_parameters(rbx, methodOopDesc:: | |
740 size_of_parameters_offset()); | |
741 const Address invocation_counter(rbx, methodOopDesc:: | |
742 invocation_counter_offset() + | |
743 InvocationCounter::counter_offset()); | |
744 const Address access_flags (rbx, methodOopDesc::access_flags_offset()); | |
745 | |
746 // get parameter size (always needed) | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
747 __ load_unsigned_short(rcx, size_of_parameters); |
0 | 748 |
749 // native calls don't need the stack size check since they have no | |
750 // expression stack and the arguments are already on the stack and | |
751 // we only add a handful of words to the stack | |
752 | |
753 // rbx: methodOop | |
754 // rcx: size of parameters | |
755 // r13: sender sp | |
304 | 756 __ pop(rax); // get return address |
0 | 757 |
758 // for natives the size of locals is zero | |
759 | |
760 // compute beginning of parameters (r14) | |
304 | 761 __ lea(r14, Address(rsp, rcx, Address::times_8, -wordSize)); |
0 | 762 |
763 // add 2 zero-initialized slots for native calls | |
764 // initialize result_handler slot | |
304 | 765 __ push((int) NULL_WORD); |
0 | 766 // slot for oop temp |
767 // (static native method holder mirror/jni oop result) | |
304 | 768 __ push((int) NULL_WORD); |
0 | 769 |
770 if (inc_counter) { | |
771 __ movl(rcx, invocation_counter); // (pre-)fetch invocation count | |
772 } | |
773 | |
774 // initialize fixed part of activation frame | |
775 generate_fixed_frame(true); | |
776 | |
777 // make sure method is native & not abstract | |
778 #ifdef ASSERT | |
779 __ movl(rax, access_flags); | |
780 { | |
781 Label L; | |
782 __ testl(rax, JVM_ACC_NATIVE); | |
783 __ jcc(Assembler::notZero, L); | |
784 __ stop("tried to execute non-native method as native"); | |
785 __ bind(L); | |
786 } | |
787 { | |
788 Label L; | |
789 __ testl(rax, JVM_ACC_ABSTRACT); | |
790 __ jcc(Assembler::zero, L); | |
791 __ stop("tried to execute abstract method in interpreter"); | |
792 __ bind(L); | |
793 } | |
794 #endif | |
795 | |
796 // Since at this point in the method invocation the exception handler | |
797 // would try to exit the monitor of synchronized methods which hasn't | |
798 // been entered yet, we set the thread local variable | |
799 // _do_not_unlock_if_synchronized to true. The remove_activation will | |
800 // check this flag. | |
801 | |
802 const Address do_not_unlock_if_synchronized(r15_thread, | |
803 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
804 __ movbool(do_not_unlock_if_synchronized, true); | |
805 | |
806 // increment invocation count & check for overflow | |
807 Label invocation_counter_overflow; | |
808 if (inc_counter) { | |
809 generate_counter_incr(&invocation_counter_overflow, NULL, NULL); | |
810 } | |
811 | |
812 Label continue_after_compile; | |
813 __ bind(continue_after_compile); | |
814 | |
815 bang_stack_shadow_pages(true); | |
816 | |
817 // reset the _do_not_unlock_if_synchronized flag | |
818 __ movbool(do_not_unlock_if_synchronized, false); | |
819 | |
820 // check for synchronized methods | |
821 // Must happen AFTER invocation_counter check and stack overflow check, | |
822 // so method is not locked if overflows. | |
823 if (synchronized) { | |
824 lock_method(); | |
825 } else { | |
826 // no synchronization necessary | |
827 #ifdef ASSERT | |
828 { | |
829 Label L; | |
830 __ movl(rax, access_flags); | |
831 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
832 __ jcc(Assembler::zero, L); | |
833 __ stop("method needs synchronization"); | |
834 __ bind(L); | |
835 } | |
836 #endif | |
837 } | |
838 | |
839 // start execution | |
840 #ifdef ASSERT | |
841 { | |
842 Label L; | |
843 const Address monitor_block_top(rbp, | |
844 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
304 | 845 __ movptr(rax, monitor_block_top); |
846 __ cmpptr(rax, rsp); | |
0 | 847 __ jcc(Assembler::equal, L); |
848 __ stop("broken stack frame setup in interpreter"); | |
849 __ bind(L); | |
850 } | |
851 #endif | |
852 | |
853 // jvmti support | |
854 __ notify_method_entry(); | |
855 | |
856 // work registers | |
857 const Register method = rbx; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
858 const Register t = r11; |
0 | 859 |
860 // allocate space for parameters | |
861 __ get_method(method); | |
862 __ verify_oop(method); | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
863 __ load_unsigned_short(t, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
864 Address(method, |
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
865 methodOopDesc::size_of_parameters_offset())); |
1506 | 866 __ shll(t, Interpreter::logStackElementSize); |
0 | 867 |
304 | 868 __ subptr(rsp, t); |
869 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows | |
605 | 870 __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI) |
0 | 871 |
872 // get signature handler | |
873 { | |
874 Label L; | |
304 | 875 __ movptr(t, Address(method, methodOopDesc::signature_handler_offset())); |
876 __ testptr(t, t); | |
0 | 877 __ jcc(Assembler::notZero, L); |
878 __ call_VM(noreg, | |
879 CAST_FROM_FN_PTR(address, | |
880 InterpreterRuntime::prepare_native_call), | |
881 method); | |
882 __ get_method(method); | |
304 | 883 __ movptr(t, Address(method, methodOopDesc::signature_handler_offset())); |
0 | 884 __ bind(L); |
885 } | |
886 | |
887 // call signature handler | |
888 assert(InterpreterRuntime::SignatureHandlerGenerator::from() == r14, | |
889 "adjust this code"); | |
890 assert(InterpreterRuntime::SignatureHandlerGenerator::to() == rsp, | |
891 "adjust this code"); | |
892 assert(InterpreterRuntime::SignatureHandlerGenerator::temp() == rscratch1, | |
893 "adjust this code"); | |
894 | |
895 // The generated handlers do not touch RBX (the method oop). | |
896 // However, large signatures cannot be cached and are generated | |
897 // each time here. The slow-path generator can do a GC on return, | |
898 // so we must reload it after the call. | |
899 __ call(t); | |
900 __ get_method(method); // slow path can do a GC, reload RBX | |
901 | |
902 | |
903 // result handler is in rax | |
904 // set result handler | |
304 | 905 __ movptr(Address(rbp, |
906 (frame::interpreter_frame_result_handler_offset) * wordSize), | |
907 rax); | |
0 | 908 |
909 // pass mirror handle if static call | |
910 { | |
911 Label L; | |
912 const int mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + | |
913 Klass::java_mirror_offset_in_bytes(); | |
914 __ movl(t, Address(method, methodOopDesc::access_flags_offset())); | |
915 __ testl(t, JVM_ACC_STATIC); | |
916 __ jcc(Assembler::zero, L); | |
917 // get mirror | |
304 | 918 __ movptr(t, Address(method, methodOopDesc::constants_offset())); |
919 __ movptr(t, Address(t, constantPoolOopDesc::pool_holder_offset_in_bytes())); | |
920 __ movptr(t, Address(t, mirror_offset)); | |
0 | 921 // copy mirror into activation frame |
304 | 922 __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize), |
0 | 923 t); |
924 // pass handle to mirror | |
304 | 925 __ lea(c_rarg1, |
926 Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize)); | |
0 | 927 __ bind(L); |
928 } | |
929 | |
930 // get native function entry point | |
931 { | |
932 Label L; | |
304 | 933 __ movptr(rax, Address(method, methodOopDesc::native_function_offset())); |
0 | 934 ExternalAddress unsatisfied(SharedRuntime::native_method_throw_unsatisfied_link_error_entry()); |
935 __ movptr(rscratch2, unsatisfied.addr()); | |
304 | 936 __ cmpptr(rax, rscratch2); |
0 | 937 __ jcc(Assembler::notEqual, L); |
938 __ call_VM(noreg, | |
939 CAST_FROM_FN_PTR(address, | |
940 InterpreterRuntime::prepare_native_call), | |
941 method); | |
942 __ get_method(method); | |
943 __ verify_oop(method); | |
304 | 944 __ movptr(rax, Address(method, methodOopDesc::native_function_offset())); |
0 | 945 __ bind(L); |
946 } | |
947 | |
948 // pass JNIEnv | |
304 | 949 __ lea(c_rarg0, Address(r15_thread, JavaThread::jni_environment_offset())); |
0 | 950 |
951 // It is enough that the pc() points into the right code | |
952 // segment. It does not have to be the correct return pc. | |
953 __ set_last_Java_frame(rsp, rbp, (address) __ pc()); | |
954 | |
955 // change thread state | |
956 #ifdef ASSERT | |
957 { | |
958 Label L; | |
959 __ movl(t, Address(r15_thread, JavaThread::thread_state_offset())); | |
960 __ cmpl(t, _thread_in_Java); | |
961 __ jcc(Assembler::equal, L); | |
962 __ stop("Wrong thread state in native stub"); | |
963 __ bind(L); | |
964 } | |
965 #endif | |
966 | |
967 // Change state to native | |
968 | |
969 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), | |
970 _thread_in_native); | |
971 | |
972 // Call the native method. | |
973 __ call(rax); | |
974 // result potentially in rax or xmm0 | |
975 | |
976 // Depending on runtime options, either restore the MXCSR | |
977 // register after returning from the JNI Call or verify that | |
978 // it wasn't changed during -Xcheck:jni. | |
979 if (RestoreMXCSROnJNICalls) { | |
304 | 980 __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); |
0 | 981 } |
982 else if (CheckJNICalls) { | |
304 | 983 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::verify_mxcsr_entry()))); |
0 | 984 } |
985 | |
986 // NOTE: The order of these pushes is known to frame::interpreter_frame_result | |
987 // in order to extract the result of a method call. If the order of these | |
988 // pushes change or anything else is added to the stack then the code in | |
989 // interpreter_frame_result must also change. | |
990 | |
991 __ push(dtos); | |
992 __ push(ltos); | |
993 | |
994 // change thread state | |
995 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), | |
996 _thread_in_native_trans); | |
997 | |
998 if (os::is_MP()) { | |
999 if (UseMembar) { | |
1000 // Force this write out before the read below | |
1001 __ membar(Assembler::Membar_mask_bits( | |
1002 Assembler::LoadLoad | Assembler::LoadStore | | |
1003 Assembler::StoreLoad | Assembler::StoreStore)); | |
1004 } else { | |
1005 // Write serialization page so VM thread can do a pseudo remote membar. | |
1006 // We use the current thread pointer to calculate a thread specific | |
1007 // offset to write to within the page. This minimizes bus traffic | |
1008 // due to cache line collision. | |
1009 __ serialize_memory(r15_thread, rscratch2); | |
1010 } | |
1011 } | |
1012 | |
1013 // check for safepoint operation in progress and/or pending suspend requests | |
1014 { | |
1015 Label Continue; | |
1016 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), | |
1017 SafepointSynchronize::_not_synchronized); | |
1018 | |
1019 Label L; | |
1020 __ jcc(Assembler::notEqual, L); | |
1021 __ cmpl(Address(r15_thread, JavaThread::suspend_flags_offset()), 0); | |
1022 __ jcc(Assembler::equal, Continue); | |
1023 __ bind(L); | |
1024 | |
1025 // Don't use call_VM as it will see a possible pending exception | |
1026 // and forward it and never return here preventing us from | |
1027 // clearing _last_native_pc down below. Also can't use | |
1028 // call_VM_leaf either as it will check to see if r13 & r14 are | |
1029 // preserved and correspond to the bcp/locals pointers. So we do a | |
1030 // runtime call by hand. | |
1031 // | |
304 | 1032 __ mov(c_rarg0, r15_thread); |
1033 __ mov(r12, rsp); // remember sp | |
1034 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows | |
1035 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1036 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans))); |
304 | 1037 __ mov(rsp, r12); // restore sp |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1038 __ reinit_heapbase(); |
0 | 1039 __ bind(Continue); |
1040 } | |
1041 | |
1042 // change thread state | |
1043 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_Java); | |
1044 | |
1045 // reset_last_Java_frame | |
1046 __ reset_last_Java_frame(true, true); | |
1047 | |
1048 // reset handle block | |
304 | 1049 __ movptr(t, Address(r15_thread, JavaThread::active_handles_offset())); |
1050 __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); | |
0 | 1051 |
1052 // If result is an oop unbox and store it in frame where gc will see it | |
1053 // and result handler will pick it up | |
1054 | |
1055 { | |
1056 Label no_oop, store_result; | |
1057 __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT))); | |
304 | 1058 __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize)); |
0 | 1059 __ jcc(Assembler::notEqual, no_oop); |
1060 // retrieve result | |
1061 __ pop(ltos); | |
304 | 1062 __ testptr(rax, rax); |
0 | 1063 __ jcc(Assembler::zero, store_result); |
304 | 1064 __ movptr(rax, Address(rax, 0)); |
0 | 1065 __ bind(store_result); |
304 | 1066 __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize), rax); |
0 | 1067 // keep stack depth as expected by pushing oop which will eventually be discarde |
1068 __ push(ltos); | |
1069 __ bind(no_oop); | |
1070 } | |
1071 | |
1072 | |
1073 { | |
1074 Label no_reguard; | |
1075 __ cmpl(Address(r15_thread, JavaThread::stack_guard_state_offset()), | |
1076 JavaThread::stack_guard_yellow_disabled); | |
1077 __ jcc(Assembler::notEqual, no_reguard); | |
1078 | |
304 | 1079 __ pusha(); // XXX only save smashed registers |
1080 __ mov(r12, rsp); // remember sp | |
1081 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows | |
1082 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1083 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); |
304 | 1084 __ mov(rsp, r12); // restore sp |
1085 __ popa(); // XXX only restore smashed registers | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1086 __ reinit_heapbase(); |
0 | 1087 |
1088 __ bind(no_reguard); | |
1089 } | |
1090 | |
1091 | |
1092 // The method register is junk from after the thread_in_native transition | |
1093 // until here. Also can't call_VM until the bcp has been | |
1094 // restored. Need bcp for throwing exception below so get it now. | |
1095 __ get_method(method); | |
1096 __ verify_oop(method); | |
1097 | |
1098 // restore r13 to have legal interpreter frame, i.e., bci == 0 <=> | |
1099 // r13 == code_base() | |
304 | 1100 __ movptr(r13, Address(method, methodOopDesc::const_offset())); // get constMethodOop |
1101 __ lea(r13, Address(r13, constMethodOopDesc::codes_offset())); // get codebase | |
0 | 1102 // handle exceptions (exception handling will handle unlocking!) |
1103 { | |
1104 Label L; | |
304 | 1105 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
0 | 1106 __ jcc(Assembler::zero, L); |
1107 // Note: At some point we may want to unify this with the code | |
1108 // used in call_VM_base(); i.e., we should use the | |
1109 // StubRoutines::forward_exception code. For now this doesn't work | |
1110 // here because the rsp is not correctly set at this point. | |
1111 __ MacroAssembler::call_VM(noreg, | |
1112 CAST_FROM_FN_PTR(address, | |
1113 InterpreterRuntime::throw_pending_exception)); | |
1114 __ should_not_reach_here(); | |
1115 __ bind(L); | |
1116 } | |
1117 | |
1118 // do unlocking if necessary | |
1119 { | |
1120 Label L; | |
1121 __ movl(t, Address(method, methodOopDesc::access_flags_offset())); | |
1122 __ testl(t, JVM_ACC_SYNCHRONIZED); | |
1123 __ jcc(Assembler::zero, L); | |
1124 // the code below should be shared with interpreter macro | |
1125 // assembler implementation | |
1126 { | |
1127 Label unlock; | |
1128 // BasicObjectLock will be first in list, since this is a | |
1129 // synchronized method. However, need to check that the object | |
1130 // has not been unlocked by an explicit monitorexit bytecode. | |
1131 const Address monitor(rbp, | |
1132 (intptr_t)(frame::interpreter_frame_initial_sp_offset * | |
1133 wordSize - sizeof(BasicObjectLock))); | |
1134 | |
1135 // monitor expect in c_rarg1 for slow unlock path | |
304 | 1136 __ lea(c_rarg1, monitor); // address of first monitor |
0 | 1137 |
304 | 1138 __ movptr(t, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); |
1139 __ testptr(t, t); | |
0 | 1140 __ jcc(Assembler::notZero, unlock); |
1141 | |
1142 // Entry already unlocked, need to throw exception | |
1143 __ MacroAssembler::call_VM(noreg, | |
1144 CAST_FROM_FN_PTR(address, | |
1145 InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
1146 __ should_not_reach_here(); | |
1147 | |
1148 __ bind(unlock); | |
1149 __ unlock_object(c_rarg1); | |
1150 } | |
1151 __ bind(L); | |
1152 } | |
1153 | |
1154 // jvmti support | |
1155 // Note: This must happen _after_ handling/throwing any exceptions since | |
1156 // the exception handler code notifies the runtime of method exits | |
1157 // too. If this happens before, method entry/exit notifications are | |
1158 // not properly paired (was bug - gri 11/22/99). | |
1159 __ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI); | |
1160 | |
1161 // restore potential result in edx:eax, call result handler to | |
1162 // restore potential result in ST0 & handle result | |
1163 | |
1164 __ pop(ltos); | |
1165 __ pop(dtos); | |
1166 | |
304 | 1167 __ movptr(t, Address(rbp, |
1168 (frame::interpreter_frame_result_handler_offset) * wordSize)); | |
0 | 1169 __ call(t); |
1170 | |
1171 // remove activation | |
304 | 1172 __ movptr(t, Address(rbp, |
1173 frame::interpreter_frame_sender_sp_offset * | |
1174 wordSize)); // get sender sp | |
0 | 1175 __ leave(); // remove frame anchor |
304 | 1176 __ pop(rdi); // get return address |
1177 __ mov(rsp, t); // set sp to sender sp | |
0 | 1178 __ jmp(rdi); |
1179 | |
1180 if (inc_counter) { | |
1181 // Handle overflow of counter and compile method | |
1182 __ bind(invocation_counter_overflow); | |
1183 generate_counter_overflow(&continue_after_compile); | |
1184 } | |
1185 | |
1186 return entry_point; | |
1187 } | |
1188 | |
1189 // | |
1190 // Generic interpreted method entry to (asm) interpreter | |
1191 // | |
1192 address InterpreterGenerator::generate_normal_entry(bool synchronized) { | |
1193 // determine code generation flags | |
1194 bool inc_counter = UseCompiler || CountCompiledCalls; | |
1195 | |
1196 // ebx: methodOop | |
1197 // r13: sender sp | |
1198 address entry_point = __ pc(); | |
1199 | |
1200 const Address size_of_parameters(rbx, | |
1201 methodOopDesc::size_of_parameters_offset()); | |
1202 const Address size_of_locals(rbx, methodOopDesc::size_of_locals_offset()); | |
1203 const Address invocation_counter(rbx, | |
1204 methodOopDesc::invocation_counter_offset() + | |
1205 InvocationCounter::counter_offset()); | |
1206 const Address access_flags(rbx, methodOopDesc::access_flags_offset()); | |
1207 | |
1208 // get parameter size (always needed) | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
1209 __ load_unsigned_short(rcx, size_of_parameters); |
0 | 1210 |
1211 // rbx: methodOop | |
1212 // rcx: size of parameters | |
1213 // r13: sender_sp (could differ from sp+wordSize if we were called via c2i ) | |
1214 | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
1215 __ load_unsigned_short(rdx, size_of_locals); // get size of locals in words |
0 | 1216 __ subl(rdx, rcx); // rdx = no. of additional locals |
1217 | |
1218 // YYY | |
1219 // __ incrementl(rdx); | |
1220 // __ andl(rdx, -2); | |
1221 | |
1222 // see if we've got enough room on the stack for locals plus overhead. | |
1223 generate_stack_overflow_check(); | |
1224 | |
1225 // get return address | |
304 | 1226 __ pop(rax); |
0 | 1227 |
1228 // compute beginning of parameters (r14) | |
304 | 1229 __ lea(r14, Address(rsp, rcx, Address::times_8, -wordSize)); |
0 | 1230 |
1231 // rdx - # of additional locals | |
1232 // allocate space for locals | |
1233 // explicitly initialize locals | |
1234 { | |
1235 Label exit, loop; | |
1236 __ testl(rdx, rdx); | |
1237 __ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0 | |
1238 __ bind(loop); | |
304 | 1239 __ push((int) NULL_WORD); // initialize local variables |
0 | 1240 __ decrementl(rdx); // until everything initialized |
1241 __ jcc(Assembler::greater, loop); | |
1242 __ bind(exit); | |
1243 } | |
1244 | |
1245 // (pre-)fetch invocation count | |
1246 if (inc_counter) { | |
1247 __ movl(rcx, invocation_counter); | |
1248 } | |
1249 // initialize fixed part of activation frame | |
1250 generate_fixed_frame(false); | |
1251 | |
1252 // make sure method is not native & not abstract | |
1253 #ifdef ASSERT | |
1254 __ movl(rax, access_flags); | |
1255 { | |
1256 Label L; | |
1257 __ testl(rax, JVM_ACC_NATIVE); | |
1258 __ jcc(Assembler::zero, L); | |
1259 __ stop("tried to execute native method as non-native"); | |
1260 __ bind(L); | |
1261 } | |
1262 { | |
1263 Label L; | |
1264 __ testl(rax, JVM_ACC_ABSTRACT); | |
1265 __ jcc(Assembler::zero, L); | |
1266 __ stop("tried to execute abstract method in interpreter"); | |
1267 __ bind(L); | |
1268 } | |
1269 #endif | |
1270 | |
1271 // Since at this point in the method invocation the exception | |
1272 // handler would try to exit the monitor of synchronized methods | |
1273 // which hasn't been entered yet, we set the thread local variable | |
1274 // _do_not_unlock_if_synchronized to true. The remove_activation | |
1275 // will check this flag. | |
1276 | |
1277 const Address do_not_unlock_if_synchronized(r15_thread, | |
1278 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
1279 __ movbool(do_not_unlock_if_synchronized, true); | |
1280 | |
1281 // increment invocation count & check for overflow | |
1282 Label invocation_counter_overflow; | |
1283 Label profile_method; | |
1284 Label profile_method_continue; | |
1285 if (inc_counter) { | |
1286 generate_counter_incr(&invocation_counter_overflow, | |
1287 &profile_method, | |
1288 &profile_method_continue); | |
1289 if (ProfileInterpreter) { | |
1290 __ bind(profile_method_continue); | |
1291 } | |
1292 } | |
1293 | |
1294 Label continue_after_compile; | |
1295 __ bind(continue_after_compile); | |
1296 | |
1297 // check for synchronized interpreted methods | |
1298 bang_stack_shadow_pages(false); | |
1299 | |
1300 // reset the _do_not_unlock_if_synchronized flag | |
1301 __ movbool(do_not_unlock_if_synchronized, false); | |
1302 | |
1303 // check for synchronized methods | |
1304 // Must happen AFTER invocation_counter check and stack overflow check, | |
1305 // so method is not locked if overflows. | |
1306 if (synchronized) { | |
1307 // Allocate monitor and lock method | |
1308 lock_method(); | |
1309 } else { | |
1310 // no synchronization necessary | |
1311 #ifdef ASSERT | |
1312 { | |
1313 Label L; | |
1314 __ movl(rax, access_flags); | |
1315 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
1316 __ jcc(Assembler::zero, L); | |
1317 __ stop("method needs synchronization"); | |
1318 __ bind(L); | |
1319 } | |
1320 #endif | |
1321 } | |
1322 | |
1323 // start execution | |
1324 #ifdef ASSERT | |
1325 { | |
1326 Label L; | |
1327 const Address monitor_block_top (rbp, | |
1328 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
304 | 1329 __ movptr(rax, monitor_block_top); |
1330 __ cmpptr(rax, rsp); | |
0 | 1331 __ jcc(Assembler::equal, L); |
1332 __ stop("broken stack frame setup in interpreter"); | |
1333 __ bind(L); | |
1334 } | |
1335 #endif | |
1336 | |
1337 // jvmti support | |
1338 __ notify_method_entry(); | |
1339 | |
1340 __ dispatch_next(vtos); | |
1341 | |
1342 // invocation counter overflow | |
1343 if (inc_counter) { | |
1344 if (ProfileInterpreter) { | |
1345 // We have decided to profile this method in the interpreter | |
1346 __ bind(profile_method); | |
1347 | |
1348 __ call_VM(noreg, | |
1349 CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method), | |
1350 r13, true); | |
1351 | |
304 | 1352 __ movptr(rbx, Address(rbp, method_offset)); // restore methodOop |
1353 __ movptr(rax, Address(rbx, | |
1354 in_bytes(methodOopDesc::method_data_offset()))); | |
1355 __ movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), | |
1356 rax); | |
0 | 1357 __ test_method_data_pointer(rax, profile_method_continue); |
304 | 1358 __ addptr(rax, in_bytes(methodDataOopDesc::data_offset())); |
1359 __ movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), | |
0 | 1360 rax); |
1361 __ jmp(profile_method_continue); | |
1362 } | |
1363 // Handle overflow of counter and compile method | |
1364 __ bind(invocation_counter_overflow); | |
1365 generate_counter_overflow(&continue_after_compile); | |
1366 } | |
1367 | |
1368 return entry_point; | |
1369 } | |
1370 | |
1371 // Entry points | |
1372 // | |
1373 // Here we generate the various kind of entries into the interpreter. | |
1374 // The two main entry type are generic bytecode methods and native | |
1375 // call method. These both come in synchronized and non-synchronized | |
1376 // versions but the frame layout they create is very similar. The | |
1377 // other method entry types are really just special purpose entries | |
1378 // that are really entry and interpretation all in one. These are for | |
1379 // trivial methods like accessor, empty, or special math methods. | |
1380 // | |
1381 // When control flow reaches any of the entry types for the interpreter | |
1382 // the following holds -> | |
1383 // | |
1384 // Arguments: | |
1385 // | |
1386 // rbx: methodOop | |
1387 // | |
1388 // Stack layout immediately at entry | |
1389 // | |
1390 // [ return address ] <--- rsp | |
1391 // [ parameter n ] | |
1392 // ... | |
1393 // [ parameter 1 ] | |
1394 // [ expression stack ] (caller's java expression stack) | |
1395 | |
1396 // Assuming that we don't go to one of the trivial specialized entries | |
1397 // the stack will look like below when we are ready to execute the | |
1398 // first bytecode (or call the native routine). The register usage | |
1399 // will be as the template based interpreter expects (see | |
1400 // interpreter_amd64.hpp). | |
1401 // | |
1402 // local variables follow incoming parameters immediately; i.e. | |
1403 // the return address is moved to the end of the locals). | |
1404 // | |
1405 // [ monitor entry ] <--- rsp | |
1406 // ... | |
1407 // [ monitor entry ] | |
1408 // [ expr. stack bottom ] | |
1409 // [ saved r13 ] | |
1410 // [ current r14 ] | |
1411 // [ methodOop ] | |
1412 // [ saved ebp ] <--- rbp | |
1413 // [ return address ] | |
1414 // [ local variable m ] | |
1415 // ... | |
1416 // [ local variable 1 ] | |
1417 // [ parameter n ] | |
1418 // ... | |
1419 // [ parameter 1 ] <--- r14 | |
1420 | |
1421 address AbstractInterpreterGenerator::generate_method_entry( | |
1422 AbstractInterpreter::MethodKind kind) { | |
1423 // determine code generation flags | |
1424 bool synchronized = false; | |
1425 address entry_point = NULL; | |
1426 | |
1427 switch (kind) { | |
1428 case Interpreter::zerolocals : break; | |
1429 case Interpreter::zerolocals_synchronized: synchronized = true; break; | |
1430 case Interpreter::native : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false); break; | |
1431 case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*) this)->generate_native_entry(true); break; | |
1432 case Interpreter::empty : entry_point = ((InterpreterGenerator*) this)->generate_empty_entry(); break; | |
1433 case Interpreter::accessor : entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry(); break; | |
1434 case Interpreter::abstract : entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry(); break; | |
710 | 1435 case Interpreter::method_handle : entry_point = ((InterpreterGenerator*) this)->generate_method_handle_entry();break; |
706
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1436 |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1437 case Interpreter::java_lang_math_sin : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1438 case Interpreter::java_lang_math_cos : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1439 case Interpreter::java_lang_math_tan : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1440 case Interpreter::java_lang_math_abs : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1441 case Interpreter::java_lang_math_log : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1442 case Interpreter::java_lang_math_log10 : // fall thru |
0 | 1443 case Interpreter::java_lang_math_sqrt : entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind); break; |
1444 default : ShouldNotReachHere(); break; | |
1445 } | |
1446 | |
1447 if (entry_point) { | |
1448 return entry_point; | |
1449 } | |
1450 | |
1451 return ((InterpreterGenerator*) this)-> | |
1452 generate_normal_entry(synchronized); | |
1453 } | |
1454 | |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1455 // These should never be compiled since the interpreter will prefer |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1456 // the compiled version to the intrinsic version. |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1457 bool AbstractInterpreter::can_be_compiled(methodHandle m) { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1458 switch (method_kind(m)) { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1459 case Interpreter::java_lang_math_sin : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1460 case Interpreter::java_lang_math_cos : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1461 case Interpreter::java_lang_math_tan : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1462 case Interpreter::java_lang_math_abs : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1463 case Interpreter::java_lang_math_log : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1464 case Interpreter::java_lang_math_log10 : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1465 case Interpreter::java_lang_math_sqrt : |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1466 return false; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1467 default: |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1468 return true; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1469 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1470 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1471 |
0 | 1472 // How much stack a method activation needs in words. |
1473 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) { | |
1474 const int entry_size = frame::interpreter_frame_monitor_size(); | |
1475 | |
1476 // total overhead size: entry_size + (saved rbp thru expr stack | |
1477 // bottom). be sure to change this if you add/subtract anything | |
1478 // to/from the overhead area | |
1479 const int overhead_size = | |
1480 -(frame::interpreter_frame_initial_sp_offset) + entry_size; | |
1481 | |
1482 const int stub_code = frame::entry_frame_after_call_words; | |
710 | 1483 const int extra_stack = methodOopDesc::extra_stack_entries(); |
1484 const int method_stack = (method->max_locals() + method->max_stack() + extra_stack) * | |
1506 | 1485 Interpreter::stackElementWords; |
0 | 1486 return (overhead_size + method_stack + stub_code); |
1487 } | |
1488 | |
1489 int AbstractInterpreter::layout_activation(methodOop method, | |
1490 int tempcount, | |
1491 int popframe_extra_args, | |
1492 int moncount, | |
1493 int callee_param_count, | |
1494 int callee_locals, | |
1495 frame* caller, | |
1496 frame* interpreter_frame, | |
1497 bool is_top_frame) { | |
1498 // Note: This calculation must exactly parallel the frame setup | |
1499 // in AbstractInterpreterGenerator::generate_method_entry. | |
1500 // If interpreter_frame!=NULL, set up the method, locals, and monitors. | |
1501 // The frame interpreter_frame, if not NULL, is guaranteed to be the | |
1502 // right size, as determined by a previous call to this method. | |
1503 // It is also guaranteed to be walkable even though it is in a skeletal state | |
1504 | |
1505 // fixed size of an interpreter frame: | |
1506 | 1506 int max_locals = method->max_locals() * Interpreter::stackElementWords; |
0 | 1507 int extra_locals = (method->max_locals() - method->size_of_parameters()) * |
1506 | 1508 Interpreter::stackElementWords; |
0 | 1509 |
1510 int overhead = frame::sender_sp_offset - | |
1511 frame::interpreter_frame_initial_sp_offset; | |
1512 // Our locals were accounted for by the caller (or last_frame_adjust | |
1513 // on the transistion) Since the callee parameters already account | |
1514 // for the callee's params we only need to account for the extra | |
1515 // locals. | |
1516 int size = overhead + | |
1506 | 1517 (callee_locals - callee_param_count)*Interpreter::stackElementWords + |
0 | 1518 moncount * frame::interpreter_frame_monitor_size() + |
1506 | 1519 tempcount* Interpreter::stackElementWords + popframe_extra_args; |
0 | 1520 if (interpreter_frame != NULL) { |
1521 #ifdef ASSERT | |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
1522 if (!EnableMethodHandles) |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
1523 // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences? |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
1524 // Probably, since deoptimization doesn't work yet. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
1525 assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable"); |
0 | 1526 assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)"); |
1527 #endif | |
1528 | |
1529 interpreter_frame->interpreter_frame_set_method(method); | |
1530 // NOTE the difference in using sender_sp and | |
1531 // interpreter_frame_sender_sp interpreter_frame_sender_sp is | |
1532 // the original sp of the caller (the unextended_sp) and | |
1533 // sender_sp is fp+16 XXX | |
1534 intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1; | |
1535 | |
1536 interpreter_frame->interpreter_frame_set_locals(locals); | |
1537 BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin(); | |
1538 BasicObjectLock* monbot = montop - moncount; | |
1539 interpreter_frame->interpreter_frame_set_monitor_end(monbot); | |
1540 | |
1541 // Set last_sp | |
1542 intptr_t* esp = (intptr_t*) monbot - | |
1506 | 1543 tempcount*Interpreter::stackElementWords - |
0 | 1544 popframe_extra_args; |
1545 interpreter_frame->interpreter_frame_set_last_sp(esp); | |
1546 | |
1547 // All frames but the initial (oldest) interpreter frame we fill in have | |
1548 // a value for sender_sp that allows walking the stack but isn't | |
1549 // truly correct. Correct the value here. | |
1550 if (extra_locals != 0 && | |
1551 interpreter_frame->sender_sp() == | |
1552 interpreter_frame->interpreter_frame_sender_sp()) { | |
1553 interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + | |
1554 extra_locals); | |
1555 } | |
1556 *interpreter_frame->interpreter_frame_cache_addr() = | |
1557 method->constants()->cache(); | |
1558 } | |
1559 return size; | |
1560 } | |
1561 | |
1562 //----------------------------------------------------------------------------- | |
1563 // Exceptions | |
1564 | |
1565 void TemplateInterpreterGenerator::generate_throw_exception() { | |
1566 // Entry point in previous activation (i.e., if the caller was | |
1567 // interpreted) | |
1568 Interpreter::_rethrow_exception_entry = __ pc(); | |
1569 // Restore sp to interpreter_frame_last_sp even though we are going | |
1570 // to empty the expression stack for the exception processing. | |
304 | 1571 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 1572 // rax: exception |
1573 // rdx: return address/pc that threw exception | |
1574 __ restore_bcp(); // r13 points to call/send | |
1575 __ restore_locals(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1576 __ reinit_heapbase(); // restore r12 as heapbase. |
0 | 1577 // Entry point for exceptions thrown within interpreter code |
1578 Interpreter::_throw_exception_entry = __ pc(); | |
1579 // expression stack is undefined here | |
1580 // rax: exception | |
1581 // r13: exception bcp | |
1582 __ verify_oop(rax); | |
304 | 1583 __ mov(c_rarg1, rax); |
0 | 1584 |
1585 // expression stack must be empty before entering the VM in case of | |
1586 // an exception | |
1587 __ empty_expression_stack(); | |
1588 // find exception handler address and preserve exception oop | |
1589 __ call_VM(rdx, | |
1590 CAST_FROM_FN_PTR(address, | |
1591 InterpreterRuntime::exception_handler_for_exception), | |
1592 c_rarg1); | |
1593 // rax: exception handler entry point | |
1594 // rdx: preserved exception oop | |
1595 // r13: bcp for exception handler | |
1596 __ push_ptr(rdx); // push exception which is now the only value on the stack | |
1597 __ jmp(rax); // jump to exception handler (may be _remove_activation_entry!) | |
1598 | |
1599 // If the exception is not handled in the current frame the frame is | |
1600 // removed and the exception is rethrown (i.e. exception | |
1601 // continuation is _rethrow_exception). | |
1602 // | |
1603 // Note: At this point the bci is still the bxi for the instruction | |
1604 // which caused the exception and the expression stack is | |
1605 // empty. Thus, for any VM calls at this point, GC will find a legal | |
1606 // oop map (with empty expression stack). | |
1607 | |
1608 // In current activation | |
1609 // tos: exception | |
1610 // esi: exception bcp | |
1611 | |
1612 // | |
1613 // JVMTI PopFrame support | |
1614 // | |
1615 | |
1616 Interpreter::_remove_activation_preserving_args_entry = __ pc(); | |
1617 __ empty_expression_stack(); | |
1618 // Set the popframe_processing bit in pending_popframe_condition | |
1619 // indicating that we are currently handling popframe, so that | |
1620 // call_VMs that may happen later do not trigger new popframe | |
1621 // handling cycles. | |
1622 __ movl(rdx, Address(r15_thread, JavaThread::popframe_condition_offset())); | |
1623 __ orl(rdx, JavaThread::popframe_processing_bit); | |
1624 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), rdx); | |
1625 | |
1626 { | |
1627 // Check to see whether we are returning to a deoptimized frame. | |
1628 // (The PopFrame call ensures that the caller of the popped frame is | |
1629 // either interpreted or compiled and deoptimizes it if compiled.) | |
1630 // In this case, we can't call dispatch_next() after the frame is | |
1631 // popped, but instead must save the incoming arguments and restore | |
1632 // them after deoptimization has occurred. | |
1633 // | |
1634 // Note that we don't compare the return PC against the | |
1635 // deoptimization blob's unpack entry because of the presence of | |
1636 // adapter frames in C2. | |
1637 Label caller_not_deoptimized; | |
304 | 1638 __ movptr(c_rarg1, Address(rbp, frame::return_addr_offset * wordSize)); |
0 | 1639 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1640 InterpreterRuntime::interpreter_contains), c_rarg1); | |
1641 __ testl(rax, rax); | |
1642 __ jcc(Assembler::notZero, caller_not_deoptimized); | |
1643 | |
1644 // Compute size of arguments for saving when returning to | |
1645 // deoptimized caller | |
1646 __ get_method(rax); | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
1647 __ load_unsigned_short(rax, Address(rax, in_bytes(methodOopDesc:: |
0 | 1648 size_of_parameters_offset()))); |
1506 | 1649 __ shll(rax, Interpreter::logStackElementSize); |
0 | 1650 __ restore_locals(); // XXX do we need this? |
304 | 1651 __ subptr(r14, rax); |
1652 __ addptr(r14, wordSize); | |
0 | 1653 // Save these arguments |
1654 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, | |
1655 Deoptimization:: | |
1656 popframe_preserve_args), | |
1657 r15_thread, rax, r14); | |
1658 | |
1659 __ remove_activation(vtos, rdx, | |
1660 /* throw_monitor_exception */ false, | |
1661 /* install_monitor_exception */ false, | |
1662 /* notify_jvmdi */ false); | |
1663 | |
1664 // Inform deoptimization that it is responsible for restoring | |
1665 // these arguments | |
1666 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), | |
1667 JavaThread::popframe_force_deopt_reexecution_bit); | |
1668 | |
1669 // Continue in deoptimization handler | |
1670 __ jmp(rdx); | |
1671 | |
1672 __ bind(caller_not_deoptimized); | |
1673 } | |
1674 | |
1675 __ remove_activation(vtos, rdx, /* rdx result (retaddr) is not used */ | |
1676 /* throw_monitor_exception */ false, | |
1677 /* install_monitor_exception */ false, | |
1678 /* notify_jvmdi */ false); | |
1679 | |
1680 // Finish with popframe handling | |
1681 // A previous I2C followed by a deoptimization might have moved the | |
1682 // outgoing arguments further up the stack. PopFrame expects the | |
1683 // mutations to those outgoing arguments to be preserved and other | |
1684 // constraints basically require this frame to look exactly as | |
1685 // though it had previously invoked an interpreted activation with | |
1686 // no space between the top of the expression stack (current | |
1687 // last_sp) and the top of stack. Rather than force deopt to | |
1688 // maintain this kind of invariant all the time we call a small | |
1689 // fixup routine to move the mutated arguments onto the top of our | |
1690 // expression stack if necessary. | |
304 | 1691 __ mov(c_rarg1, rsp); |
1692 __ movptr(c_rarg2, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); | |
0 | 1693 // PC must point into interpreter here |
1694 __ set_last_Java_frame(noreg, rbp, __ pc()); | |
1695 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), r15_thread, c_rarg1, c_rarg2); | |
1696 __ reset_last_Java_frame(true, true); | |
1697 // Restore the last_sp and null it out | |
304 | 1698 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1699 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); | |
0 | 1700 |
1701 __ restore_bcp(); // XXX do we need this? | |
1702 __ restore_locals(); // XXX do we need this? | |
1703 // The method data pointer was incremented already during | |
1704 // call profiling. We have to restore the mdp for the current bcp. | |
1705 if (ProfileInterpreter) { | |
1706 __ set_method_data_pointer_for_bcp(); | |
1707 } | |
1708 | |
1709 // Clear the popframe condition flag | |
1710 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), | |
1711 JavaThread::popframe_inactive); | |
1712 | |
1713 __ dispatch_next(vtos); | |
1714 // end of PopFrame support | |
1715 | |
1716 Interpreter::_remove_activation_entry = __ pc(); | |
1717 | |
1718 // preserve exception over this code sequence | |
1719 __ pop_ptr(rax); | |
304 | 1720 __ movptr(Address(r15_thread, JavaThread::vm_result_offset()), rax); |
0 | 1721 // remove the activation (without doing throws on illegalMonitorExceptions) |
1722 __ remove_activation(vtos, rdx, false, true, false); | |
1723 // restore exception | |
304 | 1724 __ movptr(rax, Address(r15_thread, JavaThread::vm_result_offset())); |
1725 __ movptr(Address(r15_thread, JavaThread::vm_result_offset()), (int32_t)NULL_WORD); | |
0 | 1726 __ verify_oop(rax); |
1727 | |
1728 // In between activations - previous activation type unknown yet | |
1729 // compute continuation point - the continuation point expects the | |
1730 // following registers set up: | |
1731 // | |
1732 // rax: exception | |
1733 // rdx: return address/pc that threw exception | |
1734 // rsp: expression stack of caller | |
1735 // rbp: ebp of caller | |
304 | 1736 __ push(rax); // save exception |
1737 __ push(rdx); // save return address | |
0 | 1738 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1739 SharedRuntime::exception_handler_for_return_address), | |
1295 | 1740 r15_thread, rdx); |
304 | 1741 __ mov(rbx, rax); // save exception handler |
1742 __ pop(rdx); // restore return address | |
1743 __ pop(rax); // restore exception | |
0 | 1744 // Note that an "issuing PC" is actually the next PC after the call |
1745 __ jmp(rbx); // jump to exception | |
1746 // handler of caller | |
1747 } | |
1748 | |
1749 | |
1750 // | |
1751 // JVMTI ForceEarlyReturn support | |
1752 // | |
1753 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { | |
1754 address entry = __ pc(); | |
1755 | |
1756 __ restore_bcp(); | |
1757 __ restore_locals(); | |
1758 __ empty_expression_stack(); | |
1759 __ load_earlyret_value(state); | |
1760 | |
304 | 1761 __ movptr(rdx, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); |
0 | 1762 Address cond_addr(rdx, JvmtiThreadState::earlyret_state_offset()); |
1763 | |
1764 // Clear the earlyret state | |
1765 __ movl(cond_addr, JvmtiThreadState::earlyret_inactive); | |
1766 | |
1767 __ remove_activation(state, rsi, | |
1768 false, /* throw_monitor_exception */ | |
1769 false, /* install_monitor_exception */ | |
1770 true); /* notify_jvmdi */ | |
1771 __ jmp(rsi); | |
1772 | |
1773 return entry; | |
1774 } // end of ForceEarlyReturn support | |
1775 | |
1776 | |
1777 //----------------------------------------------------------------------------- | |
1778 // Helper for vtos entry point generation | |
1779 | |
1780 void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t, | |
1781 address& bep, | |
1782 address& cep, | |
1783 address& sep, | |
1784 address& aep, | |
1785 address& iep, | |
1786 address& lep, | |
1787 address& fep, | |
1788 address& dep, | |
1789 address& vep) { | |
1790 assert(t->is_valid() && t->tos_in() == vtos, "illegal template"); | |
1791 Label L; | |
1792 aep = __ pc(); __ push_ptr(); __ jmp(L); | |
1793 fep = __ pc(); __ push_f(); __ jmp(L); | |
1794 dep = __ pc(); __ push_d(); __ jmp(L); | |
1795 lep = __ pc(); __ push_l(); __ jmp(L); | |
1796 bep = cep = sep = | |
1797 iep = __ pc(); __ push_i(); | |
1798 vep = __ pc(); | |
1799 __ bind(L); | |
1800 generate_and_dispatch(t); | |
1801 } | |
1802 | |
1803 | |
1804 //----------------------------------------------------------------------------- | |
1805 // Generation of individual instructions | |
1806 | |
1807 // helpers for generate_and_dispatch | |
1808 | |
1809 | |
1810 InterpreterGenerator::InterpreterGenerator(StubQueue* code) | |
1811 : TemplateInterpreterGenerator(code) { | |
1812 generate_all(); // down here so it can be "virtual" | |
1813 } | |
1814 | |
1815 //----------------------------------------------------------------------------- | |
1816 | |
1817 // Non-product code | |
1818 #ifndef PRODUCT | |
1819 address TemplateInterpreterGenerator::generate_trace_code(TosState state) { | |
1820 address entry = __ pc(); | |
1821 | |
1822 __ push(state); | |
304 | 1823 __ push(c_rarg0); |
1824 __ push(c_rarg1); | |
1825 __ push(c_rarg2); | |
1826 __ push(c_rarg3); | |
1827 __ mov(c_rarg2, rax); // Pass itos | |
0 | 1828 #ifdef _WIN64 |
1829 __ movflt(xmm3, xmm0); // Pass ftos | |
1830 #endif | |
1831 __ call_VM(noreg, | |
1832 CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode), | |
1833 c_rarg1, c_rarg2, c_rarg3); | |
304 | 1834 __ pop(c_rarg3); |
1835 __ pop(c_rarg2); | |
1836 __ pop(c_rarg1); | |
1837 __ pop(c_rarg0); | |
0 | 1838 __ pop(state); |
1839 __ ret(0); // return from result handler | |
1840 | |
1841 return entry; | |
1842 } | |
1843 | |
1844 void TemplateInterpreterGenerator::count_bytecode() { | |
1845 __ incrementl(ExternalAddress((address) &BytecodeCounter::_counter_value)); | |
1846 } | |
1847 | |
1848 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) { | |
1849 __ incrementl(ExternalAddress((address) &BytecodeHistogram::_counters[t->bytecode()])); | |
1850 } | |
1851 | |
1852 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) { | |
1853 __ mov32(rbx, ExternalAddress((address) &BytecodePairHistogram::_index)); | |
1854 __ shrl(rbx, BytecodePairHistogram::log2_number_of_codes); | |
1855 __ orl(rbx, | |
1856 ((int) t->bytecode()) << | |
1857 BytecodePairHistogram::log2_number_of_codes); | |
1858 __ mov32(ExternalAddress((address) &BytecodePairHistogram::_index), rbx); | |
1859 __ lea(rscratch1, ExternalAddress((address) BytecodePairHistogram::_counters)); | |
1860 __ incrementl(Address(rscratch1, rbx, Address::times_4)); | |
1861 } | |
1862 | |
1863 | |
1864 void TemplateInterpreterGenerator::trace_bytecode(Template* t) { | |
1865 // Call a little run-time stub to avoid blow-up for each bytecode. | |
1866 // The run-time runtime saves the right registers, depending on | |
1867 // the tosca in-state for the given template. | |
1868 | |
1869 assert(Interpreter::trace_code(t->tos_in()) != NULL, | |
1870 "entry must have been generated"); | |
304 | 1871 __ mov(r12, rsp); // remember sp |
1872 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1873 __ call(RuntimeAddress(Interpreter::trace_code(t->tos_in()))); |
304 | 1874 __ mov(rsp, r12); // restore sp |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1875 __ reinit_heapbase(); |
0 | 1876 } |
1877 | |
1878 | |
1879 void TemplateInterpreterGenerator::stop_interpreter_at() { | |
1880 Label L; | |
1881 __ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value), | |
1882 StopInterpreterAt); | |
1883 __ jcc(Assembler::notEqual, L); | |
1884 __ int3(); | |
1885 __ bind(L); | |
1886 } | |
1887 #endif // !PRODUCT | |
304 | 1888 #endif // ! CC_INTERP |