Mercurial > hg > truffle
annotate src/cpu/x86/vm/interp_masm_x86_64.cpp @ 344:6aae2f9d0294
Merge
author | ysr |
---|---|
date | Thu, 12 Jun 2008 13:50:55 -0700 |
parents | 37f87013dfd8 6d172e3548cb |
children | 1ee8caae33af |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_interp_masm_x86_64.cpp.incl" | |
27 | |
28 | |
29 // Implementation of InterpreterMacroAssembler | |
30 | |
31 void InterpreterMacroAssembler::call_VM_leaf_base(address entry_point, | |
32 int number_of_arguments) { | |
33 // interpreter specific | |
34 // | |
35 // Note: No need to save/restore bcp & locals (r13 & r14) pointer | |
36 // since these are callee saved registers and no blocking/ | |
37 // GC can happen in leaf calls. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
38 // Further Note: DO NOT save/restore bcp/locals. If a caller has |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
39 // already saved them so that it can use esi/edi as temporaries |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
40 // then a save/restore here will DESTROY the copy the caller |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
41 // saved! There used to be a save_bcp() that only happened in |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
42 // the ASSERT path (no restore_bcp). Which caused bizarre failures |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
43 // when jvm built with ASSERTs. |
0 | 44 #ifdef ASSERT |
45 { | |
46 Label L; | |
47 cmpq(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int)NULL_WORD); | |
48 jcc(Assembler::equal, L); | |
49 stop("InterpreterMacroAssembler::call_VM_leaf_base:" | |
50 " last_sp != NULL"); | |
51 bind(L); | |
52 } | |
53 #endif | |
54 // super call | |
55 MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments); | |
56 // interpreter specific | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
57 // Used to ASSERT that r13/r14 were equal to frame's bcp/locals |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
58 // but since they may not have been saved (and we don't want to |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
59 // save thme here (see note above) the assert is invalid. |
0 | 60 } |
61 | |
62 void InterpreterMacroAssembler::call_VM_base(Register oop_result, | |
63 Register java_thread, | |
64 Register last_java_sp, | |
65 address entry_point, | |
66 int number_of_arguments, | |
67 bool check_exceptions) { | |
68 // interpreter specific | |
69 // | |
70 // Note: Could avoid restoring locals ptr (callee saved) - however doesn't | |
71 // really make a difference for these runtime calls, since they are | |
72 // slow anyway. Btw., bcp must be saved/restored since it may change | |
73 // due to GC. | |
74 // assert(java_thread == noreg , "not expecting a precomputed java thread"); | |
75 save_bcp(); | |
76 #ifdef ASSERT | |
77 { | |
78 Label L; | |
79 cmpq(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int)NULL_WORD); | |
80 jcc(Assembler::equal, L); | |
81 stop("InterpreterMacroAssembler::call_VM_leaf_base:" | |
82 " last_sp != NULL"); | |
83 bind(L); | |
84 } | |
85 #endif /* ASSERT */ | |
86 // super call | |
87 MacroAssembler::call_VM_base(oop_result, noreg, last_java_sp, | |
88 entry_point, number_of_arguments, | |
89 check_exceptions); | |
90 // interpreter specific | |
91 restore_bcp(); | |
92 restore_locals(); | |
93 } | |
94 | |
95 | |
96 void InterpreterMacroAssembler::check_and_handle_popframe(Register java_thread) { | |
97 if (JvmtiExport::can_pop_frame()) { | |
98 Label L; | |
99 // Initiate popframe handling only if it is not already being | |
100 // processed. If the flag has the popframe_processing bit set, it | |
101 // means that this code is called *during* popframe handling - we | |
102 // don't want to reenter. | |
103 // This method is only called just after the call into the vm in | |
104 // call_VM_base, so the arg registers are available. | |
105 movl(c_rarg0, Address(r15_thread, JavaThread::popframe_condition_offset())); | |
106 testl(c_rarg0, JavaThread::popframe_pending_bit); | |
107 jcc(Assembler::zero, L); | |
108 testl(c_rarg0, JavaThread::popframe_processing_bit); | |
109 jcc(Assembler::notZero, L); | |
110 // Call Interpreter::remove_activation_preserving_args_entry() to get the | |
111 // address of the same-named entrypoint in the generated interpreter code. | |
112 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_preserving_args_entry)); | |
113 jmp(rax); | |
114 bind(L); | |
115 } | |
116 } | |
117 | |
118 | |
119 void InterpreterMacroAssembler::load_earlyret_value(TosState state) { | |
120 movq(rcx, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); | |
121 const Address tos_addr(rcx, JvmtiThreadState::earlyret_tos_offset()); | |
122 const Address oop_addr(rcx, JvmtiThreadState::earlyret_oop_offset()); | |
123 const Address val_addr(rcx, JvmtiThreadState::earlyret_value_offset()); | |
124 switch (state) { | |
125 case atos: movq(rax, oop_addr); | |
126 movptr(oop_addr, NULL_WORD); | |
127 verify_oop(rax, state); break; | |
128 case ltos: movq(rax, val_addr); break; | |
129 case btos: // fall through | |
130 case ctos: // fall through | |
131 case stos: // fall through | |
132 case itos: movl(rax, val_addr); break; | |
133 case ftos: movflt(xmm0, val_addr); break; | |
134 case dtos: movdbl(xmm0, val_addr); break; | |
135 case vtos: /* nothing to do */ break; | |
136 default : ShouldNotReachHere(); | |
137 } | |
138 // Clean up tos value in the thread object | |
139 movl(tos_addr, (int) ilgl); | |
140 movl(val_addr, (int) NULL_WORD); | |
141 } | |
142 | |
143 | |
144 void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread) { | |
145 if (JvmtiExport::can_force_early_return()) { | |
146 Label L; | |
147 movq(c_rarg0, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); | |
148 testq(c_rarg0, c_rarg0); | |
149 jcc(Assembler::zero, L); // if (thread->jvmti_thread_state() == NULL) exit; | |
150 | |
151 // Initiate earlyret handling only if it is not already being processed. | |
152 // If the flag has the earlyret_processing bit set, it means that this code | |
153 // is called *during* earlyret handling - we don't want to reenter. | |
154 movl(c_rarg0, Address(c_rarg0, JvmtiThreadState::earlyret_state_offset())); | |
155 cmpl(c_rarg0, JvmtiThreadState::earlyret_pending); | |
156 jcc(Assembler::notEqual, L); | |
157 | |
158 // Call Interpreter::remove_activation_early_entry() to get the address of the | |
159 // same-named entrypoint in the generated interpreter code. | |
160 movq(c_rarg0, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); | |
161 movl(c_rarg0, Address(c_rarg0, JvmtiThreadState::earlyret_tos_offset())); | |
162 call_VM_leaf(CAST_FROM_FN_PTR(address, Interpreter::remove_activation_early_entry), c_rarg0); | |
163 jmp(rax); | |
164 bind(L); | |
165 } | |
166 } | |
167 | |
168 | |
169 void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp( | |
170 Register reg, | |
171 int bcp_offset) { | |
172 assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode"); | |
173 movl(reg, Address(r13, bcp_offset)); | |
174 bswapl(reg); | |
175 shrl(reg, 16); | |
176 } | |
177 | |
178 | |
179 void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, | |
180 Register index, | |
181 int bcp_offset) { | |
182 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); | |
183 assert(cache != index, "must use different registers"); | |
184 load_unsigned_word(index, Address(r13, bcp_offset)); | |
185 movq(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); | |
186 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); | |
187 // convert from field index to ConstantPoolCacheEntry index | |
188 shll(index, 2); | |
189 } | |
190 | |
191 | |
192 void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, | |
193 Register tmp, | |
194 int bcp_offset) { | |
195 assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); | |
196 assert(cache != tmp, "must use different register"); | |
197 load_unsigned_word(tmp, Address(r13, bcp_offset)); | |
198 assert(sizeof(ConstantPoolCacheEntry) == 4 * wordSize, "adjust code below"); | |
199 // convert from field index to ConstantPoolCacheEntry index | |
200 // and from word offset to byte offset | |
201 shll(tmp, 2 + LogBytesPerWord); | |
202 movq(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); | |
203 // skip past the header | |
204 addq(cache, in_bytes(constantPoolCacheOopDesc::base_offset())); | |
205 addq(cache, tmp); // construct pointer to cache entry | |
206 } | |
207 | |
208 | |
209 // Generate a subtype check: branch to ok_is_subtype if sub_klass is a | |
210 // subtype of super_klass. | |
211 // | |
212 // Args: | |
213 // rax: superklass | |
214 // Rsub_klass: subklass | |
215 // | |
216 // Kills: | |
217 // rcx, rdi | |
218 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, | |
219 Label& ok_is_subtype) { | |
220 assert(Rsub_klass != rax, "rax holds superklass"); | |
221 assert(Rsub_klass != r14, "r14 holds locals"); | |
222 assert(Rsub_klass != r13, "r13 holds bcp"); | |
223 assert(Rsub_klass != rcx, "rcx holds 2ndary super array length"); | |
224 assert(Rsub_klass != rdi, "rdi holds 2ndary super array scan ptr"); | |
225 | |
178
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
226 Label not_subtype, not_subtype_pop, loop; |
0 | 227 |
228 // Profile the not-null value's klass. | |
229 profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, rdi | |
230 | |
231 // Load the super-klass's check offset into rcx | |
232 movl(rcx, Address(rax, sizeof(oopDesc) + | |
233 Klass::super_check_offset_offset_in_bytes())); | |
234 // Load from the sub-klass's super-class display list, or a 1-word | |
235 // cache of the secondary superclass list, or a failing value with a | |
236 // sentinel offset if the super-klass is an interface or | |
237 // exceptionally deep in the Java hierarchy and we have to scan the | |
238 // secondary superclass list the hard way. See if we get an | |
239 // immediate positive hit | |
240 cmpq(rax, Address(Rsub_klass, rcx, Address::times_1)); | |
241 jcc(Assembler::equal,ok_is_subtype); | |
242 | |
243 // Check for immediate negative hit | |
244 cmpl(rcx, sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes()); | |
245 jcc( Assembler::notEqual, not_subtype ); | |
246 // Check for self | |
247 cmpq(Rsub_klass, rax); | |
248 jcc(Assembler::equal, ok_is_subtype); | |
249 | |
250 // Now do a linear scan of the secondary super-klass chain. | |
251 movq(rdi, Address(Rsub_klass, sizeof(oopDesc) + | |
252 Klass::secondary_supers_offset_in_bytes())); | |
253 // rdi holds the objArrayOop of secondary supers. | |
254 // Load the array length | |
255 movl(rcx, Address(rdi, arrayOopDesc::length_offset_in_bytes())); | |
256 // Skip to start of data; also clear Z flag incase rcx is zero | |
257 addq(rdi, arrayOopDesc::base_offset_in_bytes(T_OBJECT)); | |
258 // Scan rcx words at [rdi] for occurance of rax | |
259 // Set NZ/Z based on last compare | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
260 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
261 // this part is kind tricky, as values in supers array could be 32 or 64 bit wide |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
262 // and we store values in objArrays always encoded, thus we need to encode value |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
263 // before repne |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
264 if (UseCompressedOops) { |
178
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
265 pushq(rax); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
266 encode_heap_oop(rax); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
267 repne_scanl(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
268 // Not equal? |
178
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
269 jcc(Assembler::notEqual, not_subtype_pop); |
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
270 // restore heap oop here for movq |
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
271 popq(rax); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
272 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
273 repne_scanq(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
274 jcc(Assembler::notEqual, not_subtype); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
275 } |
0 | 276 // Must be equal but missed in cache. Update cache. |
277 movq(Address(Rsub_klass, sizeof(oopDesc) + | |
278 Klass::secondary_super_cache_offset_in_bytes()), rax); | |
279 jmp(ok_is_subtype); | |
280 | |
178
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
281 bind(not_subtype_pop); |
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
282 // restore heap oop here for miss |
6d172e3548cb
6695819: verify_oopx rax: broken oop in decode_heap_oop
coleenp
parents:
113
diff
changeset
|
283 if (UseCompressedOops) popq(rax); |
0 | 284 bind(not_subtype); |
285 profile_typecheck_failed(rcx); // blows rcx | |
286 } | |
287 | |
288 | |
289 // Java Expression Stack | |
290 | |
291 #ifdef ASSERT | |
292 // Verifies that the stack tag matches. Must be called before the stack | |
293 // value is popped off the stack. | |
294 void InterpreterMacroAssembler::verify_stack_tag(frame::Tag t) { | |
295 if (TaggedStackInterpreter) { | |
296 frame::Tag tag = t; | |
297 if (t == frame::TagCategory2) { | |
298 tag = frame::TagValue; | |
299 Label hokay; | |
300 cmpq(Address(rsp, 3*wordSize), (int)tag); | |
301 jcc(Assembler::equal, hokay); | |
302 stop("Java Expression stack tag high value is bad"); | |
303 bind(hokay); | |
304 } | |
305 Label okay; | |
306 cmpq(Address(rsp, wordSize), (int)tag); | |
307 jcc(Assembler::equal, okay); | |
308 // Also compare if the stack value is zero, then the tag might | |
309 // not have been set coming from deopt. | |
310 cmpq(Address(rsp, 0), 0); | |
311 jcc(Assembler::equal, okay); | |
312 stop("Java Expression stack tag value is bad"); | |
313 bind(okay); | |
314 } | |
315 } | |
316 #endif // ASSERT | |
317 | |
318 void InterpreterMacroAssembler::pop_ptr(Register r) { | |
319 debug_only(verify_stack_tag(frame::TagReference)); | |
320 popq(r); | |
321 if (TaggedStackInterpreter) addq(rsp, 1 * wordSize); | |
322 } | |
323 | |
324 void InterpreterMacroAssembler::pop_ptr(Register r, Register tag) { | |
325 popq(r); | |
326 if (TaggedStackInterpreter) popq(tag); | |
327 } | |
328 | |
329 void InterpreterMacroAssembler::pop_i(Register r) { | |
330 // XXX can't use popq currently, upper half non clean | |
331 debug_only(verify_stack_tag(frame::TagValue)); | |
332 movl(r, Address(rsp, 0)); | |
333 addq(rsp, wordSize); | |
334 if (TaggedStackInterpreter) addq(rsp, 1 * wordSize); | |
335 } | |
336 | |
337 void InterpreterMacroAssembler::pop_l(Register r) { | |
338 debug_only(verify_stack_tag(frame::TagCategory2)); | |
339 movq(r, Address(rsp, 0)); | |
340 addq(rsp, 2 * Interpreter::stackElementSize()); | |
341 } | |
342 | |
343 void InterpreterMacroAssembler::pop_f(XMMRegister r) { | |
344 debug_only(verify_stack_tag(frame::TagValue)); | |
345 movflt(r, Address(rsp, 0)); | |
346 addq(rsp, wordSize); | |
347 if (TaggedStackInterpreter) addq(rsp, 1 * wordSize); | |
348 } | |
349 | |
350 void InterpreterMacroAssembler::pop_d(XMMRegister r) { | |
351 debug_only(verify_stack_tag(frame::TagCategory2)); | |
352 movdbl(r, Address(rsp, 0)); | |
353 addq(rsp, 2 * Interpreter::stackElementSize()); | |
354 } | |
355 | |
356 void InterpreterMacroAssembler::push_ptr(Register r) { | |
357 if (TaggedStackInterpreter) pushq(frame::TagReference); | |
358 pushq(r); | |
359 } | |
360 | |
361 void InterpreterMacroAssembler::push_ptr(Register r, Register tag) { | |
362 if (TaggedStackInterpreter) pushq(tag); | |
363 pushq(r); | |
364 } | |
365 | |
366 void InterpreterMacroAssembler::push_i(Register r) { | |
367 if (TaggedStackInterpreter) pushq(frame::TagValue); | |
368 pushq(r); | |
369 } | |
370 | |
371 void InterpreterMacroAssembler::push_l(Register r) { | |
372 if (TaggedStackInterpreter) { | |
373 pushq(frame::TagValue); | |
374 subq(rsp, 1 * wordSize); | |
375 pushq(frame::TagValue); | |
376 subq(rsp, 1 * wordSize); | |
377 } else { | |
378 subq(rsp, 2 * wordSize); | |
379 } | |
380 movq(Address(rsp, 0), r); | |
381 } | |
382 | |
383 void InterpreterMacroAssembler::push_f(XMMRegister r) { | |
384 if (TaggedStackInterpreter) pushq(frame::TagValue); | |
385 subq(rsp, wordSize); | |
386 movflt(Address(rsp, 0), r); | |
387 } | |
388 | |
389 void InterpreterMacroAssembler::push_d(XMMRegister r) { | |
390 if (TaggedStackInterpreter) { | |
391 pushq(frame::TagValue); | |
392 subq(rsp, 1 * wordSize); | |
393 pushq(frame::TagValue); | |
394 subq(rsp, 1 * wordSize); | |
395 } else { | |
396 subq(rsp, 2 * wordSize); | |
397 } | |
398 movdbl(Address(rsp, 0), r); | |
399 } | |
400 | |
401 void InterpreterMacroAssembler::pop(TosState state) { | |
402 switch (state) { | |
403 case atos: pop_ptr(); break; | |
404 case btos: | |
405 case ctos: | |
406 case stos: | |
407 case itos: pop_i(); break; | |
408 case ltos: pop_l(); break; | |
409 case ftos: pop_f(); break; | |
410 case dtos: pop_d(); break; | |
411 case vtos: /* nothing to do */ break; | |
412 default: ShouldNotReachHere(); | |
413 } | |
414 verify_oop(rax, state); | |
415 } | |
416 | |
417 void InterpreterMacroAssembler::push(TosState state) { | |
418 verify_oop(rax, state); | |
419 switch (state) { | |
420 case atos: push_ptr(); break; | |
421 case btos: | |
422 case ctos: | |
423 case stos: | |
424 case itos: push_i(); break; | |
425 case ltos: push_l(); break; | |
426 case ftos: push_f(); break; | |
427 case dtos: push_d(); break; | |
428 case vtos: /* nothing to do */ break; | |
429 default : ShouldNotReachHere(); | |
430 } | |
431 } | |
432 | |
433 | |
434 // Tagged stack helpers for swap and dup | |
435 void InterpreterMacroAssembler::load_ptr_and_tag(int n, Register val, | |
436 Register tag) { | |
437 movq(val, Address(rsp, Interpreter::expr_offset_in_bytes(n))); | |
438 if (TaggedStackInterpreter) { | |
439 movq(tag, Address(rsp, Interpreter::expr_tag_offset_in_bytes(n))); | |
440 } | |
441 } | |
442 | |
443 void InterpreterMacroAssembler::store_ptr_and_tag(int n, Register val, | |
444 Register tag) { | |
445 movq(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val); | |
446 if (TaggedStackInterpreter) { | |
447 movq(Address(rsp, Interpreter::expr_tag_offset_in_bytes(n)), tag); | |
448 } | |
449 } | |
450 | |
451 | |
452 // Tagged local support | |
453 void InterpreterMacroAssembler::tag_local(frame::Tag tag, int n) { | |
454 if (TaggedStackInterpreter) { | |
455 if (tag == frame::TagCategory2) { | |
456 mov64(Address(r14, Interpreter::local_tag_offset_in_bytes(n+1)), | |
457 (intptr_t)frame::TagValue); | |
458 mov64(Address(r14, Interpreter::local_tag_offset_in_bytes(n)), | |
459 (intptr_t)frame::TagValue); | |
460 } else { | |
461 mov64(Address(r14, Interpreter::local_tag_offset_in_bytes(n)), (intptr_t)tag); | |
462 } | |
463 } | |
464 } | |
465 | |
466 void InterpreterMacroAssembler::tag_local(frame::Tag tag, Register idx) { | |
467 if (TaggedStackInterpreter) { | |
468 if (tag == frame::TagCategory2) { | |
469 mov64(Address(r14, idx, Address::times_8, | |
470 Interpreter::local_tag_offset_in_bytes(1)), (intptr_t)frame::TagValue); | |
471 mov64(Address(r14, idx, Address::times_8, | |
472 Interpreter::local_tag_offset_in_bytes(0)), (intptr_t)frame::TagValue); | |
473 } else { | |
474 mov64(Address(r14, idx, Address::times_8, Interpreter::local_tag_offset_in_bytes(0)), | |
475 (intptr_t)tag); | |
476 } | |
477 } | |
478 } | |
479 | |
480 void InterpreterMacroAssembler::tag_local(Register tag, Register idx) { | |
481 if (TaggedStackInterpreter) { | |
482 // can only be TagValue or TagReference | |
483 movq(Address(r14, idx, Address::times_8, Interpreter::local_tag_offset_in_bytes(0)), tag); | |
484 } | |
485 } | |
486 | |
487 | |
488 void InterpreterMacroAssembler::tag_local(Register tag, int n) { | |
489 if (TaggedStackInterpreter) { | |
490 // can only be TagValue or TagReference | |
491 movq(Address(r14, Interpreter::local_tag_offset_in_bytes(n)), tag); | |
492 } | |
493 } | |
494 | |
495 #ifdef ASSERT | |
496 void InterpreterMacroAssembler::verify_local_tag(frame::Tag tag, int n) { | |
497 if (TaggedStackInterpreter) { | |
498 frame::Tag t = tag; | |
499 if (tag == frame::TagCategory2) { | |
500 Label nbl; | |
501 t = frame::TagValue; // change to what is stored in locals | |
502 cmpq(Address(r14, Interpreter::local_tag_offset_in_bytes(n+1)), (int)t); | |
503 jcc(Assembler::equal, nbl); | |
504 stop("Local tag is bad for long/double"); | |
505 bind(nbl); | |
506 } | |
507 Label notBad; | |
508 cmpq(Address(r14, Interpreter::local_tag_offset_in_bytes(n)), (int)t); | |
509 jcc(Assembler::equal, notBad); | |
510 // Also compare if the local value is zero, then the tag might | |
511 // not have been set coming from deopt. | |
512 cmpq(Address(r14, Interpreter::local_offset_in_bytes(n)), 0); | |
513 jcc(Assembler::equal, notBad); | |
514 stop("Local tag is bad"); | |
515 bind(notBad); | |
516 } | |
517 } | |
518 | |
519 void InterpreterMacroAssembler::verify_local_tag(frame::Tag tag, Register idx) { | |
520 if (TaggedStackInterpreter) { | |
521 frame::Tag t = tag; | |
522 if (tag == frame::TagCategory2) { | |
523 Label nbl; | |
524 t = frame::TagValue; // change to what is stored in locals | |
525 cmpq(Address(r14, idx, Address::times_8, Interpreter::local_tag_offset_in_bytes(1)), (int)t); | |
526 jcc(Assembler::equal, nbl); | |
527 stop("Local tag is bad for long/double"); | |
528 bind(nbl); | |
529 } | |
530 Label notBad; | |
531 cmpq(Address(r14, idx, Address::times_8, Interpreter::local_tag_offset_in_bytes(0)), (int)t); | |
532 jcc(Assembler::equal, notBad); | |
533 // Also compare if the local value is zero, then the tag might | |
534 // not have been set coming from deopt. | |
535 cmpq(Address(r14, idx, Address::times_8, Interpreter::local_offset_in_bytes(0)), 0); | |
536 jcc(Assembler::equal, notBad); | |
537 stop("Local tag is bad"); | |
538 bind(notBad); | |
539 } | |
540 } | |
541 #endif // ASSERT | |
542 | |
543 | |
544 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point) { | |
545 MacroAssembler::call_VM_leaf_base(entry_point, 0); | |
546 } | |
547 | |
548 | |
549 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point, | |
550 Register arg_1) { | |
551 if (c_rarg0 != arg_1) { | |
552 movq(c_rarg0, arg_1); | |
553 } | |
554 MacroAssembler::call_VM_leaf_base(entry_point, 1); | |
555 } | |
556 | |
557 | |
558 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point, | |
559 Register arg_1, | |
560 Register arg_2) { | |
561 assert(c_rarg0 != arg_2, "smashed argument"); | |
562 assert(c_rarg1 != arg_1, "smashed argument"); | |
563 if (c_rarg0 != arg_1) { | |
564 movq(c_rarg0, arg_1); | |
565 } | |
566 if (c_rarg1 != arg_2) { | |
567 movq(c_rarg1, arg_2); | |
568 } | |
569 MacroAssembler::call_VM_leaf_base(entry_point, 2); | |
570 } | |
571 | |
572 void InterpreterMacroAssembler::super_call_VM_leaf(address entry_point, | |
573 Register arg_1, | |
574 Register arg_2, | |
575 Register arg_3) { | |
576 assert(c_rarg0 != arg_2, "smashed argument"); | |
577 assert(c_rarg0 != arg_3, "smashed argument"); | |
578 assert(c_rarg1 != arg_1, "smashed argument"); | |
579 assert(c_rarg1 != arg_3, "smashed argument"); | |
580 assert(c_rarg2 != arg_1, "smashed argument"); | |
581 assert(c_rarg2 != arg_2, "smashed argument"); | |
582 if (c_rarg0 != arg_1) { | |
583 movq(c_rarg0, arg_1); | |
584 } | |
585 if (c_rarg1 != arg_2) { | |
586 movq(c_rarg1, arg_2); | |
587 } | |
588 if (c_rarg2 != arg_3) { | |
589 movq(c_rarg2, arg_3); | |
590 } | |
591 MacroAssembler::call_VM_leaf_base(entry_point, 3); | |
592 } | |
593 | |
594 // Jump to from_interpreted entry of a call unless single stepping is possible | |
595 // in this thread in which case we must call the i2i entry | |
596 void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register temp) { | |
597 // set sender sp | |
598 leaq(r13, Address(rsp, wordSize)); | |
599 // record last_sp | |
600 movq(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), r13); | |
601 | |
602 if (JvmtiExport::can_post_interpreter_events()) { | |
603 Label run_compiled_code; | |
604 // JVMTI events, such as single-stepping, are implemented partly by avoiding running | |
605 // compiled code in threads for which the event is enabled. Check here for | |
606 // interp_only_mode if these events CAN be enabled. | |
607 get_thread(temp); | |
608 // interp_only is an int, on little endian it is sufficient to test the byte only | |
609 // Is a cmpl faster (ce | |
610 cmpb(Address(temp, JavaThread::interp_only_mode_offset()), 0); | |
611 jcc(Assembler::zero, run_compiled_code); | |
612 jmp(Address(method, methodOopDesc::interpreter_entry_offset())); | |
613 bind(run_compiled_code); | |
614 } | |
615 | |
616 jmp(Address(method, methodOopDesc::from_interpreted_offset())); | |
617 | |
618 } | |
619 | |
620 | |
621 // The following two routines provide a hook so that an implementation | |
622 // can schedule the dispatch in two parts. amd64 does not do this. | |
623 void InterpreterMacroAssembler::dispatch_prolog(TosState state, int step) { | |
624 // Nothing amd64 specific to be done here | |
625 } | |
626 | |
627 void InterpreterMacroAssembler::dispatch_epilog(TosState state, int step) { | |
628 dispatch_next(state, step); | |
629 } | |
630 | |
631 void InterpreterMacroAssembler::dispatch_base(TosState state, | |
632 address* table, | |
633 bool verifyoop) { | |
634 verify_FPU(1, state); | |
635 if (VerifyActivationFrameSize) { | |
636 Label L; | |
637 movq(rcx, rbp); | |
638 subq(rcx, rsp); | |
639 int min_frame_size = | |
640 (frame::link_offset - frame::interpreter_frame_initial_sp_offset) * | |
641 wordSize; | |
642 cmpq(rcx, min_frame_size); | |
643 jcc(Assembler::greaterEqual, L); | |
644 stop("broken stack frame"); | |
645 bind(L); | |
646 } | |
647 if (verifyoop) { | |
648 verify_oop(rax, state); | |
649 } | |
650 lea(rscratch1, ExternalAddress((address)table)); | |
651 jmp(Address(rscratch1, rbx, Address::times_8)); | |
652 } | |
653 | |
654 void InterpreterMacroAssembler::dispatch_only(TosState state) { | |
655 dispatch_base(state, Interpreter::dispatch_table(state)); | |
656 } | |
657 | |
658 void InterpreterMacroAssembler::dispatch_only_normal(TosState state) { | |
659 dispatch_base(state, Interpreter::normal_table(state)); | |
660 } | |
661 | |
662 void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) { | |
663 dispatch_base(state, Interpreter::normal_table(state), false); | |
664 } | |
665 | |
666 | |
667 void InterpreterMacroAssembler::dispatch_next(TosState state, int step) { | |
668 // load next bytecode (load before advancing r13 to prevent AGI) | |
669 load_unsigned_byte(rbx, Address(r13, step)); | |
670 // advance r13 | |
671 incrementq(r13, step); | |
672 dispatch_base(state, Interpreter::dispatch_table(state)); | |
673 } | |
674 | |
675 void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) { | |
676 // load current bytecode | |
677 load_unsigned_byte(rbx, Address(r13, 0)); | |
678 dispatch_base(state, table); | |
679 } | |
680 | |
681 // remove activation | |
682 // | |
683 // Unlock the receiver if this is a synchronized method. | |
684 // Unlock any Java monitors from syncronized blocks. | |
685 // Remove the activation from the stack. | |
686 // | |
687 // If there are locked Java monitors | |
688 // If throw_monitor_exception | |
689 // throws IllegalMonitorStateException | |
690 // Else if install_monitor_exception | |
691 // installs IllegalMonitorStateException | |
692 // Else | |
693 // no error processing | |
694 void InterpreterMacroAssembler::remove_activation( | |
695 TosState state, | |
696 Register ret_addr, | |
697 bool throw_monitor_exception, | |
698 bool install_monitor_exception, | |
699 bool notify_jvmdi) { | |
700 // Note: Registers rdx xmm0 may be in use for the | |
701 // result check if synchronized method | |
702 Label unlocked, unlock, no_unlock; | |
703 | |
704 // get the value of _do_not_unlock_if_synchronized into rdx | |
705 const Address do_not_unlock_if_synchronized(r15_thread, | |
706 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
707 movbool(rdx, do_not_unlock_if_synchronized); | |
708 movbool(do_not_unlock_if_synchronized, false); // reset the flag | |
709 | |
710 // get method access flags | |
711 movq(rbx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); | |
712 movl(rcx, Address(rbx, methodOopDesc::access_flags_offset())); | |
713 testl(rcx, JVM_ACC_SYNCHRONIZED); | |
714 jcc(Assembler::zero, unlocked); | |
715 | |
716 // Don't unlock anything if the _do_not_unlock_if_synchronized flag | |
717 // is set. | |
718 testbool(rdx); | |
719 jcc(Assembler::notZero, no_unlock); | |
720 | |
721 // unlock monitor | |
722 push(state); // save result | |
723 | |
724 // BasicObjectLock will be first in list, since this is a | |
725 // synchronized method. However, need to check that the object has | |
726 // not been unlocked by an explicit monitorexit bytecode. | |
727 const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * | |
728 wordSize - (int) sizeof(BasicObjectLock)); | |
729 // We use c_rarg1 so that if we go slow path it will be the correct | |
730 // register for unlock_object to pass to VM directly | |
731 leaq(c_rarg1, monitor); // address of first monitor | |
732 | |
733 movq(rax, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); | |
734 testq(rax, rax); | |
735 jcc(Assembler::notZero, unlock); | |
736 | |
737 pop(state); | |
738 if (throw_monitor_exception) { | |
739 // Entry already unlocked, need to throw exception | |
740 call_VM(noreg, CAST_FROM_FN_PTR(address, | |
741 InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
742 should_not_reach_here(); | |
743 } else { | |
744 // Monitor already unlocked during a stack unroll. If requested, | |
745 // install an illegal_monitor_state_exception. Continue with | |
746 // stack unrolling. | |
747 if (install_monitor_exception) { | |
748 call_VM(noreg, CAST_FROM_FN_PTR(address, | |
749 InterpreterRuntime::new_illegal_monitor_state_exception)); | |
750 } | |
751 jmp(unlocked); | |
752 } | |
753 | |
754 bind(unlock); | |
755 unlock_object(c_rarg1); | |
756 pop(state); | |
757 | |
758 // Check that for block-structured locking (i.e., that all locked | |
759 // objects has been unlocked) | |
760 bind(unlocked); | |
761 | |
762 // rax: Might contain return value | |
763 | |
764 // Check that all monitors are unlocked | |
765 { | |
766 Label loop, exception, entry, restart; | |
767 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
768 const Address monitor_block_top( | |
769 rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
770 const Address monitor_block_bot( | |
771 rbp, frame::interpreter_frame_initial_sp_offset * wordSize); | |
772 | |
773 bind(restart); | |
774 // We use c_rarg1 so that if we go slow path it will be the correct | |
775 // register for unlock_object to pass to VM directly | |
776 movq(c_rarg1, monitor_block_top); // points to current entry, starting | |
777 // with top-most entry | |
778 leaq(rbx, monitor_block_bot); // points to word before bottom of | |
779 // monitor block | |
780 jmp(entry); | |
781 | |
782 // Entry already locked, need to throw exception | |
783 bind(exception); | |
784 | |
785 if (throw_monitor_exception) { | |
786 // Throw exception | |
787 MacroAssembler::call_VM(noreg, | |
788 CAST_FROM_FN_PTR(address, InterpreterRuntime:: | |
789 throw_illegal_monitor_state_exception)); | |
790 should_not_reach_here(); | |
791 } else { | |
792 // Stack unrolling. Unlock object and install illegal_monitor_exception. | |
793 // Unlock does not block, so don't have to worry about the frame. | |
794 // We don't have to preserve c_rarg1 since we are going to throw an exception. | |
795 | |
796 push(state); | |
797 unlock_object(c_rarg1); | |
798 pop(state); | |
799 | |
800 if (install_monitor_exception) { | |
801 call_VM(noreg, CAST_FROM_FN_PTR(address, | |
802 InterpreterRuntime:: | |
803 new_illegal_monitor_state_exception)); | |
804 } | |
805 | |
806 jmp(restart); | |
807 } | |
808 | |
809 bind(loop); | |
810 // check if current entry is used | |
811 cmpq(Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes()), (int) NULL); | |
812 jcc(Assembler::notEqual, exception); | |
813 | |
814 addq(c_rarg1, entry_size); // otherwise advance to next entry | |
815 bind(entry); | |
816 cmpq(c_rarg1, rbx); // check if bottom reached | |
817 jcc(Assembler::notEqual, loop); // if not at bottom then check this entry | |
818 } | |
819 | |
820 bind(no_unlock); | |
821 | |
822 // jvmti support | |
823 if (notify_jvmdi) { | |
824 notify_method_exit(state, NotifyJVMTI); // preserve TOSCA | |
825 } else { | |
826 notify_method_exit(state, SkipNotifyJVMTI); // preserve TOSCA | |
827 } | |
828 | |
829 // remove activation | |
830 // get sender sp | |
831 movq(rbx, | |
832 Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); | |
833 leave(); // remove frame anchor | |
834 popq(ret_addr); // get return address | |
835 movq(rsp, rbx); // set sp to sender sp | |
836 } | |
837 | |
838 // Lock object | |
839 // | |
840 // Args: | |
841 // c_rarg1: BasicObjectLock to be used for locking | |
842 // | |
843 // Kills: | |
844 // rax | |
845 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, .. (param regs) | |
846 // rscratch1, rscratch2 (scratch regs) | |
847 void InterpreterMacroAssembler::lock_object(Register lock_reg) { | |
848 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1"); | |
849 | |
850 if (UseHeavyMonitors) { | |
851 call_VM(noreg, | |
852 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), | |
853 lock_reg); | |
854 } else { | |
855 Label done; | |
856 | |
857 const Register swap_reg = rax; // Must use rax for cmpxchg instruction | |
858 const Register obj_reg = c_rarg3; // Will contain the oop | |
859 | |
860 const int obj_offset = BasicObjectLock::obj_offset_in_bytes(); | |
861 const int lock_offset = BasicObjectLock::lock_offset_in_bytes (); | |
862 const int mark_offset = lock_offset + | |
863 BasicLock::displaced_header_offset_in_bytes(); | |
864 | |
865 Label slow_case; | |
866 | |
867 // Load object pointer into obj_reg %c_rarg3 | |
868 movq(obj_reg, Address(lock_reg, obj_offset)); | |
869 | |
870 if (UseBiasedLocking) { | |
871 biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, done, &slow_case); | |
872 } | |
873 | |
874 // Load immediate 1 into swap_reg %rax | |
875 movl(swap_reg, 1); | |
876 | |
877 // Load (object->mark() | 1) into swap_reg %rax | |
878 orq(swap_reg, Address(obj_reg, 0)); | |
879 | |
880 // Save (object->mark() | 1) into BasicLock's displaced header | |
881 movq(Address(lock_reg, mark_offset), swap_reg); | |
882 | |
883 assert(lock_offset == 0, | |
884 "displached header must be first word in BasicObjectLock"); | |
885 | |
886 if (os::is_MP()) lock(); | |
887 cmpxchgq(lock_reg, Address(obj_reg, 0)); | |
888 if (PrintBiasedLockingStatistics) { | |
889 cond_inc32(Assembler::zero, | |
890 ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr())); | |
891 } | |
892 jcc(Assembler::zero, done); | |
893 | |
894 // Test if the oopMark is an obvious stack pointer, i.e., | |
895 // 1) (mark & 7) == 0, and | |
896 // 2) rsp <= mark < mark + os::pagesize() | |
897 // | |
898 // These 3 tests can be done by evaluating the following | |
899 // expression: ((mark - rsp) & (7 - os::vm_page_size())), | |
900 // assuming both stack pointer and pagesize have their | |
901 // least significant 3 bits clear. | |
902 // NOTE: the oopMark is in swap_reg %rax as the result of cmpxchg | |
903 subq(swap_reg, rsp); | |
904 andq(swap_reg, 7 - os::vm_page_size()); | |
905 | |
906 // Save the test result, for recursive case, the result is zero | |
907 movq(Address(lock_reg, mark_offset), swap_reg); | |
908 | |
909 if (PrintBiasedLockingStatistics) { | |
910 cond_inc32(Assembler::zero, | |
911 ExternalAddress((address) BiasedLocking::fast_path_entry_count_addr())); | |
912 } | |
913 jcc(Assembler::zero, done); | |
914 | |
915 bind(slow_case); | |
916 | |
917 // Call the runtime routine for slow case | |
918 call_VM(noreg, | |
919 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter), | |
920 lock_reg); | |
921 | |
922 bind(done); | |
923 } | |
924 } | |
925 | |
926 | |
927 // Unlocks an object. Used in monitorexit bytecode and | |
928 // remove_activation. Throws an IllegalMonitorException if object is | |
929 // not locked by current thread. | |
930 // | |
931 // Args: | |
932 // c_rarg1: BasicObjectLock for lock | |
933 // | |
934 // Kills: | |
935 // rax | |
936 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ... (param regs) | |
937 // rscratch1, rscratch2 (scratch regs) | |
938 void InterpreterMacroAssembler::unlock_object(Register lock_reg) { | |
939 assert(lock_reg == c_rarg1, "The argument is only for looks. It must be rarg1"); | |
940 | |
941 if (UseHeavyMonitors) { | |
942 call_VM(noreg, | |
943 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), | |
944 lock_reg); | |
945 } else { | |
946 Label done; | |
947 | |
948 const Register swap_reg = rax; // Must use rax for cmpxchg instruction | |
949 const Register header_reg = c_rarg2; // Will contain the old oopMark | |
950 const Register obj_reg = c_rarg3; // Will contain the oop | |
951 | |
952 save_bcp(); // Save in case of exception | |
953 | |
954 // Convert from BasicObjectLock structure to object and BasicLock | |
955 // structure Store the BasicLock address into %rax | |
956 leaq(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes())); | |
957 | |
958 // Load oop into obj_reg(%c_rarg3) | |
959 movq(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes())); | |
960 | |
961 // Free entry | |
962 movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), NULL_WORD); | |
963 | |
964 if (UseBiasedLocking) { | |
965 biased_locking_exit(obj_reg, header_reg, done); | |
966 } | |
967 | |
968 // Load the old header from BasicLock structure | |
969 movq(header_reg, Address(swap_reg, | |
970 BasicLock::displaced_header_offset_in_bytes())); | |
971 | |
972 // Test for recursion | |
973 testq(header_reg, header_reg); | |
974 | |
975 // zero for recursive case | |
976 jcc(Assembler::zero, done); | |
977 | |
978 // Atomic swap back the old header | |
979 if (os::is_MP()) lock(); | |
980 cmpxchgq(header_reg, Address(obj_reg, 0)); | |
981 | |
982 // zero for recursive case | |
983 jcc(Assembler::zero, done); | |
984 | |
985 // Call the runtime routine for slow case. | |
986 movq(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), | |
987 obj_reg); // restore obj | |
988 call_VM(noreg, | |
989 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), | |
990 lock_reg); | |
991 | |
992 bind(done); | |
993 | |
994 restore_bcp(); | |
995 } | |
996 } | |
997 | |
998 | |
999 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, | |
1000 Label& zero_continue) { | |
1001 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1002 movq(mdp, Address(rbp, frame::interpreter_frame_mdx_offset * wordSize)); | |
1003 testq(mdp, mdp); | |
1004 jcc(Assembler::zero, zero_continue); | |
1005 } | |
1006 | |
1007 | |
1008 // Set the method data pointer for the current bcp. | |
1009 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { | |
1010 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1011 Label zero_continue; | |
1012 pushq(rax); | |
1013 pushq(rbx); | |
1014 | |
1015 get_method(rbx); | |
1016 // Test MDO to avoid the call if it is NULL. | |
1017 movq(rax, Address(rbx, in_bytes(methodOopDesc::method_data_offset()))); | |
1018 testq(rax, rax); | |
1019 jcc(Assembler::zero, zero_continue); | |
1020 | |
1021 // rbx: method | |
1022 // r13: bcp | |
1023 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, r13); | |
1024 // rax: mdi | |
1025 | |
1026 movq(rbx, Address(rbx, in_bytes(methodOopDesc::method_data_offset()))); | |
1027 testq(rbx, rbx); | |
1028 jcc(Assembler::zero, zero_continue); | |
1029 addq(rbx, in_bytes(methodDataOopDesc::data_offset())); | |
1030 addq(rbx, rax); | |
1031 movq(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rbx); | |
1032 | |
1033 bind(zero_continue); | |
1034 popq(rbx); | |
1035 popq(rax); | |
1036 } | |
1037 | |
1038 void InterpreterMacroAssembler::verify_method_data_pointer() { | |
1039 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1040 #ifdef ASSERT | |
1041 Label verify_continue; | |
1042 pushq(rax); | |
1043 pushq(rbx); | |
1044 pushq(c_rarg3); | |
1045 pushq(c_rarg2); | |
1046 test_method_data_pointer(c_rarg3, verify_continue); // If mdp is zero, continue | |
1047 get_method(rbx); | |
1048 | |
1049 // If the mdp is valid, it will point to a DataLayout header which is | |
1050 // consistent with the bcp. The converse is highly probable also. | |
1051 load_unsigned_word(c_rarg2, | |
1052 Address(c_rarg3, in_bytes(DataLayout::bci_offset()))); | |
1053 addq(c_rarg2, Address(rbx, methodOopDesc::const_offset())); | |
1054 leaq(c_rarg2, Address(c_rarg2, constMethodOopDesc::codes_offset())); | |
1055 cmpq(c_rarg2, r13); | |
1056 jcc(Assembler::equal, verify_continue); | |
1057 // rbx: method | |
1058 // r13: bcp | |
1059 // c_rarg3: mdp | |
1060 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::verify_mdp), | |
1061 rbx, r13, c_rarg3); | |
1062 bind(verify_continue); | |
1063 popq(c_rarg2); | |
1064 popq(c_rarg3); | |
1065 popq(rbx); | |
1066 popq(rax); | |
1067 #endif // ASSERT | |
1068 } | |
1069 | |
1070 | |
1071 void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, | |
1072 int constant, | |
1073 Register value) { | |
1074 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1075 Address data(mdp_in, constant); | |
1076 movq(data, value); | |
1077 } | |
1078 | |
1079 | |
1080 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, | |
1081 int constant, | |
1082 bool decrement) { | |
1083 // Counter address | |
1084 Address data(mdp_in, constant); | |
1085 | |
1086 increment_mdp_data_at(data, decrement); | |
1087 } | |
1088 | |
1089 void InterpreterMacroAssembler::increment_mdp_data_at(Address data, | |
1090 bool decrement) { | |
1091 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1092 | |
1093 if (decrement) { | |
1094 // Decrement the register. Set condition codes. | |
1095 addq(data, -DataLayout::counter_increment); | |
1096 // If the decrement causes the counter to overflow, stay negative | |
1097 Label L; | |
1098 jcc(Assembler::negative, L); | |
1099 addq(data, DataLayout::counter_increment); | |
1100 bind(L); | |
1101 } else { | |
1102 assert(DataLayout::counter_increment == 1, | |
1103 "flow-free idiom only works with 1"); | |
1104 // Increment the register. Set carry flag. | |
1105 addq(data, DataLayout::counter_increment); | |
1106 // If the increment causes the counter to overflow, pull back by 1. | |
1107 sbbq(data, 0); | |
1108 } | |
1109 } | |
1110 | |
1111 | |
1112 void InterpreterMacroAssembler::increment_mdp_data_at(Register mdp_in, | |
1113 Register reg, | |
1114 int constant, | |
1115 bool decrement) { | |
1116 Address data(mdp_in, reg, Address::times_1, constant); | |
1117 | |
1118 increment_mdp_data_at(data, decrement); | |
1119 } | |
1120 | |
1121 void InterpreterMacroAssembler::set_mdp_flag_at(Register mdp_in, | |
1122 int flag_byte_constant) { | |
1123 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1124 int header_offset = in_bytes(DataLayout::header_offset()); | |
1125 int header_bits = DataLayout::flag_mask_to_header_mask(flag_byte_constant); | |
1126 // Set the flag | |
1127 orl(Address(mdp_in, header_offset), header_bits); | |
1128 } | |
1129 | |
1130 | |
1131 | |
1132 void InterpreterMacroAssembler::test_mdp_data_at(Register mdp_in, | |
1133 int offset, | |
1134 Register value, | |
1135 Register test_value_out, | |
1136 Label& not_equal_continue) { | |
1137 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1138 if (test_value_out == noreg) { | |
1139 cmpq(value, Address(mdp_in, offset)); | |
1140 } else { | |
1141 // Put the test value into a register, so caller can use it: | |
1142 movq(test_value_out, Address(mdp_in, offset)); | |
1143 cmpq(test_value_out, value); | |
1144 } | |
1145 jcc(Assembler::notEqual, not_equal_continue); | |
1146 } | |
1147 | |
1148 | |
1149 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, | |
1150 int offset_of_disp) { | |
1151 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1152 Address disp_address(mdp_in, offset_of_disp); | |
1153 addq(mdp_in, disp_address); | |
1154 movq(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); | |
1155 } | |
1156 | |
1157 | |
1158 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, | |
1159 Register reg, | |
1160 int offset_of_disp) { | |
1161 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1162 Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp); | |
1163 addq(mdp_in, disp_address); | |
1164 movq(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); | |
1165 } | |
1166 | |
1167 | |
1168 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, | |
1169 int constant) { | |
1170 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1171 addq(mdp_in, constant); | |
1172 movq(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); | |
1173 } | |
1174 | |
1175 | |
1176 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { | |
1177 assert(ProfileInterpreter, "must be profiling interpreter"); | |
1178 pushq(return_bci); // save/restore across call_VM | |
1179 call_VM(noreg, | |
1180 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), | |
1181 return_bci); | |
1182 popq(return_bci); | |
1183 } | |
1184 | |
1185 | |
1186 void InterpreterMacroAssembler::profile_taken_branch(Register mdp, | |
1187 Register bumped_count) { | |
1188 if (ProfileInterpreter) { | |
1189 Label profile_continue; | |
1190 | |
1191 // If no method data exists, go to profile_continue. | |
1192 // Otherwise, assign to mdp | |
1193 test_method_data_pointer(mdp, profile_continue); | |
1194 | |
1195 // We are taking a branch. Increment the taken count. | |
1196 // We inline increment_mdp_data_at to return bumped_count in a register | |
1197 //increment_mdp_data_at(mdp, in_bytes(JumpData::taken_offset())); | |
1198 Address data(mdp, in_bytes(JumpData::taken_offset())); | |
1199 movq(bumped_count, data); | |
1200 assert(DataLayout::counter_increment == 1, | |
1201 "flow-free idiom only works with 1"); | |
1202 addq(bumped_count, DataLayout::counter_increment); | |
1203 sbbq(bumped_count, 0); | |
1204 movq(data, bumped_count); // Store back out | |
1205 | |
1206 // The method data pointer needs to be updated to reflect the new target. | |
1207 update_mdp_by_offset(mdp, in_bytes(JumpData::displacement_offset())); | |
1208 bind(profile_continue); | |
1209 } | |
1210 } | |
1211 | |
1212 | |
1213 void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { | |
1214 if (ProfileInterpreter) { | |
1215 Label profile_continue; | |
1216 | |
1217 // If no method data exists, go to profile_continue. | |
1218 test_method_data_pointer(mdp, profile_continue); | |
1219 | |
1220 // We are taking a branch. Increment the not taken count. | |
1221 increment_mdp_data_at(mdp, in_bytes(BranchData::not_taken_offset())); | |
1222 | |
1223 // The method data pointer needs to be updated to correspond to | |
1224 // the next bytecode | |
1225 update_mdp_by_constant(mdp, in_bytes(BranchData::branch_data_size())); | |
1226 bind(profile_continue); | |
1227 } | |
1228 } | |
1229 | |
1230 | |
1231 void InterpreterMacroAssembler::profile_call(Register mdp) { | |
1232 if (ProfileInterpreter) { | |
1233 Label profile_continue; | |
1234 | |
1235 // If no method data exists, go to profile_continue. | |
1236 test_method_data_pointer(mdp, profile_continue); | |
1237 | |
1238 // We are making a call. Increment the count. | |
1239 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
1240 | |
1241 // The method data pointer needs to be updated to reflect the new target. | |
1242 update_mdp_by_constant(mdp, in_bytes(CounterData::counter_data_size())); | |
1243 bind(profile_continue); | |
1244 } | |
1245 } | |
1246 | |
1247 | |
1248 void InterpreterMacroAssembler::profile_final_call(Register mdp) { | |
1249 if (ProfileInterpreter) { | |
1250 Label profile_continue; | |
1251 | |
1252 // If no method data exists, go to profile_continue. | |
1253 test_method_data_pointer(mdp, profile_continue); | |
1254 | |
1255 // We are making a call. Increment the count. | |
1256 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
1257 | |
1258 // The method data pointer needs to be updated to reflect the new target. | |
1259 update_mdp_by_constant(mdp, | |
1260 in_bytes(VirtualCallData:: | |
1261 virtual_call_data_size())); | |
1262 bind(profile_continue); | |
1263 } | |
1264 } | |
1265 | |
1266 | |
1267 void InterpreterMacroAssembler::profile_virtual_call(Register receiver, | |
1268 Register mdp, | |
1269 Register reg2) { | |
1270 if (ProfileInterpreter) { | |
1271 Label profile_continue; | |
1272 | |
1273 // If no method data exists, go to profile_continue. | |
1274 test_method_data_pointer(mdp, profile_continue); | |
1275 | |
1276 // We are making a call. Increment the count. | |
1277 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
1278 | |
1279 // Record the receiver type. | |
1280 record_klass_in_profile(receiver, mdp, reg2); | |
1281 | |
1282 // The method data pointer needs to be updated to reflect the new target. | |
1283 update_mdp_by_constant(mdp, | |
1284 in_bytes(VirtualCallData:: | |
1285 virtual_call_data_size())); | |
1286 bind(profile_continue); | |
1287 } | |
1288 } | |
1289 | |
1290 // This routine creates a state machine for updating the multi-row | |
1291 // type profile at a virtual call site (or other type-sensitive bytecode). | |
1292 // The machine visits each row (of receiver/count) until the receiver type | |
1293 // is found, or until it runs out of rows. At the same time, it remembers | |
1294 // the location of the first empty row. (An empty row records null for its | |
1295 // receiver, and can be allocated for a newly-observed receiver type.) | |
1296 // Because there are two degrees of freedom in the state, a simple linear | |
1297 // search will not work; it must be a decision tree. Hence this helper | |
1298 // function is recursive, to generate the required tree structured code. | |
1299 // It's the interpreter, so we are trading off code space for speed. | |
1300 // See below for example code. | |
1301 void InterpreterMacroAssembler::record_klass_in_profile_helper( | |
1302 Register receiver, Register mdp, | |
1303 Register reg2, | |
1304 int start_row, Label& done) { | |
1305 int last_row = VirtualCallData::row_limit() - 1; | |
1306 assert(start_row <= last_row, "must be work left to do"); | |
1307 // Test this row for both the receiver and for null. | |
1308 // Take any of three different outcomes: | |
1309 // 1. found receiver => increment count and goto done | |
1310 // 2. found null => keep looking for case 1, maybe allocate this cell | |
1311 // 3. found something else => keep looking for cases 1 and 2 | |
1312 // Case 3 is handled by a recursive call. | |
1313 for (int row = start_row; row <= last_row; row++) { | |
1314 Label next_test; | |
1315 bool test_for_null_also = (row == start_row); | |
1316 | |
1317 // See if the receiver is receiver[n]. | |
1318 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row)); | |
1319 test_mdp_data_at(mdp, recvr_offset, receiver, | |
1320 (test_for_null_also ? reg2 : noreg), | |
1321 next_test); | |
1322 // (Reg2 now contains the receiver from the CallData.) | |
1323 | |
1324 // The receiver is receiver[n]. Increment count[n]. | |
1325 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row)); | |
1326 increment_mdp_data_at(mdp, count_offset); | |
1327 jmp(done); | |
1328 bind(next_test); | |
1329 | |
1330 if (test_for_null_also) { | |
1331 // Failed the equality check on receiver[n]... Test for null. | |
1332 testq(reg2, reg2); | |
1333 if (start_row == last_row) { | |
1334 // The only thing left to do is handle the null case. | |
1335 jcc(Assembler::notZero, done); | |
1336 break; | |
1337 } | |
1338 // Since null is rare, make it be the branch-taken case. | |
1339 Label found_null; | |
1340 jcc(Assembler::zero, found_null); | |
1341 | |
1342 // Put all the "Case 3" tests here. | |
1343 record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done); | |
1344 | |
1345 // Found a null. Keep searching for a matching receiver, | |
1346 // but remember that this is an empty (unused) slot. | |
1347 bind(found_null); | |
1348 } | |
1349 } | |
1350 | |
1351 // In the fall-through case, we found no matching receiver, but we | |
1352 // observed the receiver[start_row] is NULL. | |
1353 | |
1354 // Fill in the receiver field and increment the count. | |
1355 int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row)); | |
1356 set_mdp_data_at(mdp, recvr_offset, receiver); | |
1357 int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row)); | |
1358 movl(reg2, DataLayout::counter_increment); | |
1359 set_mdp_data_at(mdp, count_offset, reg2); | |
1360 jmp(done); | |
1361 } | |
1362 | |
1363 // Example state machine code for three profile rows: | |
1364 // // main copy of decision tree, rooted at row[1] | |
1365 // if (row[0].rec == rec) { row[0].incr(); goto done; } | |
1366 // if (row[0].rec != NULL) { | |
1367 // // inner copy of decision tree, rooted at row[1] | |
1368 // if (row[1].rec == rec) { row[1].incr(); goto done; } | |
1369 // if (row[1].rec != NULL) { | |
1370 // // degenerate decision tree, rooted at row[2] | |
1371 // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
1372 // if (row[2].rec != NULL) { goto done; } // overflow | |
1373 // row[2].init(rec); goto done; | |
1374 // } else { | |
1375 // // remember row[1] is empty | |
1376 // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
1377 // row[1].init(rec); goto done; | |
1378 // } | |
1379 // } else { | |
1380 // // remember row[0] is empty | |
1381 // if (row[1].rec == rec) { row[1].incr(); goto done; } | |
1382 // if (row[2].rec == rec) { row[2].incr(); goto done; } | |
1383 // row[0].init(rec); goto done; | |
1384 // } | |
1385 | |
1386 void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, | |
1387 Register mdp, | |
1388 Register reg2) { | |
1389 assert(ProfileInterpreter, "must be profiling"); | |
1390 Label done; | |
1391 | |
1392 record_klass_in_profile_helper(receiver, mdp, reg2, 0, done); | |
1393 | |
1394 bind (done); | |
1395 } | |
1396 | |
1397 void InterpreterMacroAssembler::profile_ret(Register return_bci, | |
1398 Register mdp) { | |
1399 if (ProfileInterpreter) { | |
1400 Label profile_continue; | |
1401 uint row; | |
1402 | |
1403 // If no method data exists, go to profile_continue. | |
1404 test_method_data_pointer(mdp, profile_continue); | |
1405 | |
1406 // Update the total ret count. | |
1407 increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); | |
1408 | |
1409 for (row = 0; row < RetData::row_limit(); row++) { | |
1410 Label next_test; | |
1411 | |
1412 // See if return_bci is equal to bci[n]: | |
1413 test_mdp_data_at(mdp, | |
1414 in_bytes(RetData::bci_offset(row)), | |
1415 return_bci, noreg, | |
1416 next_test); | |
1417 | |
1418 // return_bci is equal to bci[n]. Increment the count. | |
1419 increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row))); | |
1420 | |
1421 // The method data pointer needs to be updated to reflect the new target. | |
1422 update_mdp_by_offset(mdp, | |
1423 in_bytes(RetData::bci_displacement_offset(row))); | |
1424 jmp(profile_continue); | |
1425 bind(next_test); | |
1426 } | |
1427 | |
1428 update_mdp_for_ret(return_bci); | |
1429 | |
1430 bind(profile_continue); | |
1431 } | |
1432 } | |
1433 | |
1434 | |
1435 void InterpreterMacroAssembler::profile_null_seen(Register mdp) { | |
1436 if (ProfileInterpreter) { | |
1437 Label profile_continue; | |
1438 | |
1439 // If no method data exists, go to profile_continue. | |
1440 test_method_data_pointer(mdp, profile_continue); | |
1441 | |
1442 // The method data pointer needs to be updated. | |
1443 int mdp_delta = in_bytes(BitData::bit_data_size()); | |
1444 if (TypeProfileCasts) { | |
1445 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
1446 } | |
1447 update_mdp_by_constant(mdp, mdp_delta); | |
1448 | |
1449 bind(profile_continue); | |
1450 } | |
1451 } | |
1452 | |
1453 | |
1454 void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) { | |
1455 if (ProfileInterpreter && TypeProfileCasts) { | |
1456 Label profile_continue; | |
1457 | |
1458 // If no method data exists, go to profile_continue. | |
1459 test_method_data_pointer(mdp, profile_continue); | |
1460 | |
1461 int count_offset = in_bytes(CounterData::count_offset()); | |
1462 // Back up the address, since we have already bumped the mdp. | |
1463 count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); | |
1464 | |
1465 // *Decrement* the counter. We expect to see zero or small negatives. | |
1466 increment_mdp_data_at(mdp, count_offset, true); | |
1467 | |
1468 bind (profile_continue); | |
1469 } | |
1470 } | |
1471 | |
1472 | |
1473 void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) { | |
1474 if (ProfileInterpreter) { | |
1475 Label profile_continue; | |
1476 | |
1477 // If no method data exists, go to profile_continue. | |
1478 test_method_data_pointer(mdp, profile_continue); | |
1479 | |
1480 // The method data pointer needs to be updated. | |
1481 int mdp_delta = in_bytes(BitData::bit_data_size()); | |
1482 if (TypeProfileCasts) { | |
1483 mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); | |
1484 | |
1485 // Record the object type. | |
1486 record_klass_in_profile(klass, mdp, reg2); | |
1487 } | |
1488 update_mdp_by_constant(mdp, mdp_delta); | |
1489 | |
1490 bind(profile_continue); | |
1491 } | |
1492 } | |
1493 | |
1494 | |
1495 void InterpreterMacroAssembler::profile_switch_default(Register mdp) { | |
1496 if (ProfileInterpreter) { | |
1497 Label profile_continue; | |
1498 | |
1499 // If no method data exists, go to profile_continue. | |
1500 test_method_data_pointer(mdp, profile_continue); | |
1501 | |
1502 // Update the default case count | |
1503 increment_mdp_data_at(mdp, | |
1504 in_bytes(MultiBranchData::default_count_offset())); | |
1505 | |
1506 // The method data pointer needs to be updated. | |
1507 update_mdp_by_offset(mdp, | |
1508 in_bytes(MultiBranchData:: | |
1509 default_displacement_offset())); | |
1510 | |
1511 bind(profile_continue); | |
1512 } | |
1513 } | |
1514 | |
1515 | |
1516 void InterpreterMacroAssembler::profile_switch_case(Register index, | |
1517 Register mdp, | |
1518 Register reg2) { | |
1519 if (ProfileInterpreter) { | |
1520 Label profile_continue; | |
1521 | |
1522 // If no method data exists, go to profile_continue. | |
1523 test_method_data_pointer(mdp, profile_continue); | |
1524 | |
1525 // Build the base (index * per_case_size_in_bytes()) + | |
1526 // case_array_offset_in_bytes() | |
1527 movl(reg2, in_bytes(MultiBranchData::per_case_size())); | |
1528 imulq(index, reg2); // XXX l ? | |
1529 addq(index, in_bytes(MultiBranchData::case_array_offset())); // XXX l ? | |
1530 | |
1531 // Update the case count | |
1532 increment_mdp_data_at(mdp, | |
1533 index, | |
1534 in_bytes(MultiBranchData::relative_count_offset())); | |
1535 | |
1536 // The method data pointer needs to be updated. | |
1537 update_mdp_by_offset(mdp, | |
1538 index, | |
1539 in_bytes(MultiBranchData:: | |
1540 relative_displacement_offset())); | |
1541 | |
1542 bind(profile_continue); | |
1543 } | |
1544 } | |
1545 | |
1546 | |
1547 void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { | |
1548 if (state == atos) { | |
1549 MacroAssembler::verify_oop(reg); | |
1550 } | |
1551 } | |
1552 | |
1553 void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { | |
1554 } | |
1555 | |
1556 | |
1557 void InterpreterMacroAssembler::notify_method_entry() { | |
1558 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to | |
1559 // track stack depth. If it is possible to enter interp_only_mode we add | |
1560 // the code to check if the event should be sent. | |
1561 if (JvmtiExport::can_post_interpreter_events()) { | |
1562 Label L; | |
1563 movl(rdx, Address(r15_thread, JavaThread::interp_only_mode_offset())); | |
1564 testl(rdx, rdx); | |
1565 jcc(Assembler::zero, L); | |
1566 call_VM(noreg, CAST_FROM_FN_PTR(address, | |
1567 InterpreterRuntime::post_method_entry)); | |
1568 bind(L); | |
1569 } | |
1570 | |
1571 { | |
1572 SkipIfEqual skip(this, &DTraceMethodProbes, false); | |
1573 get_method(c_rarg1); | |
1574 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), | |
1575 r15_thread, c_rarg1); | |
1576 } | |
1577 } | |
1578 | |
1579 | |
1580 void InterpreterMacroAssembler::notify_method_exit( | |
1581 TosState state, NotifyMethodExitMode mode) { | |
1582 // Whenever JVMTI is interp_only_mode, method entry/exit events are sent to | |
1583 // track stack depth. If it is possible to enter interp_only_mode we add | |
1584 // the code to check if the event should be sent. | |
1585 if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { | |
1586 Label L; | |
1587 // Note: frame::interpreter_frame_result has a dependency on how the | |
1588 // method result is saved across the call to post_method_exit. If this | |
1589 // is changed then the interpreter_frame_result implementation will | |
1590 // need to be updated too. | |
1591 push(state); | |
1592 movl(rdx, Address(r15_thread, JavaThread::interp_only_mode_offset())); | |
1593 testl(rdx, rdx); | |
1594 jcc(Assembler::zero, L); | |
1595 call_VM(noreg, | |
1596 CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit)); | |
1597 bind(L); | |
1598 pop(state); | |
1599 } | |
1600 | |
1601 { | |
1602 SkipIfEqual skip(this, &DTraceMethodProbes, false); | |
1603 push(state); | |
1604 get_method(c_rarg1); | |
1605 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), | |
1606 r15_thread, c_rarg1); | |
1607 pop(state); | |
1608 } | |
1609 } |