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