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