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