author | twisti |
Wed, 16 Dec 2009 12:48:04 +0100 | |
changeset 4478 | c3a8af0fc6b0 |
parent 3814 | 91f531a11872 |
child 4754 | 8aef16f24e16 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2105 | 2 |
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
1 | 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) { |
|
1066 | 32 |
movptr(reg, Address(rbp, -(sizeof(BytecodeInterpreter) + 2 * wordSize))); |
33 |
movptr(reg, Address(reg, byte_offset_of(BytecodeInterpreter, _method))); |
|
1 | 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; |
|
1066 | 56 |
cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 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; |
|
1066 | 82 |
cmpptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
1 | 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) { |
|
1066 | 135 |
case atos: movptr(rax, oop_addr); |
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
136 |
movptr(oop_addr, NULL_WORD); |
1 | 137 |
verify_oop(rax, state); break; |
1066 | 138 |
case ltos: |
139 |
movl(rdx, val_addr1); // fall through |
|
1 | 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 |
|
1066 | 150 |
movl(tos_addr, (int32_t) ilgl); |
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
151 |
movptr(val_addr, NULL_WORD); |
1909
952b42dad1fc
6795913: A few remaining wrong casts need to be fixed for building hotspot successfully on Mac OS.
xlu
parents:
1888
diff
changeset
|
152 |
NOT_LP64(movptr(val_addr1, NULL_WORD)); |
1 | 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; |
|
1066 | 160 |
movptr(tmp, Address(tmp, JavaThread::jvmti_thread_state_offset())); |
161 |
testptr(tmp, tmp); |
|
1 | 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); |
|
1066 | 174 |
movptr(tmp, Address(java_thread, JavaThread::jvmti_thread_state_offset())); |
1 | 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)); |
|
1066 | 187 |
bswapl(reg); |
1 | 188 |
shrl(reg, 16); |
189 |
} |
|
190 |
||
191 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
192 |
void InterpreterMacroAssembler::get_cache_index_at_bcp(Register reg, int bcp_offset, bool giant_index) { |
1 | 193 |
assert(bcp_offset > 0, "bcp is still pointing to start of bytecode"); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
194 |
if (!giant_index) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
195 |
load_unsigned_short(reg, Address(rsi, bcp_offset)); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
196 |
} else { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
197 |
assert(EnableInvokeDynamic, "giant index used only for EnableInvokeDynamic"); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
198 |
movl(reg, Address(rsi, bcp_offset)); |
4478 | 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. |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
202 |
assert(constantPoolCacheOopDesc::decode_secondary_index(~123) == 123, "else change next line"); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
203 |
notl(reg); // convert to plain index |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
204 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
205 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
206 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
207 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
208 |
void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, Register index, |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
209 |
int bcp_offset, bool giant_index) { |
1 | 210 |
assert(cache != index, "must use different registers"); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
211 |
get_cache_index_at_bcp(index, bcp_offset, giant_index); |
1066 | 212 |
movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); |
1 | 213 |
assert(sizeof(ConstantPoolCacheEntry) == 4*wordSize, "adjust code below"); |
1066 | 214 |
shlptr(index, 2); // convert from field index to ConstantPoolCacheEntry index |
1 | 215 |
} |
216 |
||
217 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
218 |
void InterpreterMacroAssembler::get_cache_entry_pointer_at_bcp(Register cache, Register tmp, |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
219 |
int bcp_offset, bool giant_index) { |
1 | 220 |
assert(cache != tmp, "must use different register"); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
221 |
get_cache_index_at_bcp(tmp, bcp_offset, giant_index); |
1 | 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); |
|
1066 | 226 |
movptr(cache, Address(rbp, frame::interpreter_frame_cache_offset * wordSize)); |
1 | 227 |
// skip past the header |
1066 | 228 |
addptr(cache, in_bytes(constantPoolCacheOopDesc::base_offset())); |
229 |
addptr(cache, tmp); // construct pointer to cache entry |
|
1 | 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" ); |
|
2256
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
238 |
assert( Rsub_klass != rcx, "used as a temp" ); |
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
239 |
assert( Rsub_klass != rdi, "used as a temp, restored from locals" ); |
1 | 240 |
|
241 |
// Profile the not-null value's klass. |
|
2256
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
242 |
profile_typecheck(rcx, Rsub_klass, rdi); // blows rcx, reloads rdi |
1 | 243 |
|
2256
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
244 |
// Do the check. |
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
245 |
check_klass_subtype(Rsub_klass, rax, rcx, ok_is_subtype); // blows rcx |
1 | 246 |
|
2256
82d4e10b7c6b
6813212: factor duplicated assembly code for general subclass check (for 6655638)
jrose
parents:
2151
diff
changeset
|
247 |
// Profile the failure of the check. |
1 | 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; |
|
1066 | 272 |
cmpptr(Address(rsp, wordSize), (int32_t)t); |
1 | 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. |
|
1066 | 276 |
cmpptr(Address(rsp, 0), 0); |
1 | 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)); |
|
1066 | 286 |
pop(r); |
287 |
if (TaggedStackInterpreter) addptr(rsp, 1 * wordSize); |
|
1 | 288 |
} |
289 |
||
290 |
void InterpreterMacroAssembler::pop_ptr(Register r, Register tag) { |
|
1066 | 291 |
pop(r); |
1 | 292 |
// Tag may not be reference for jsr, can be returnAddress |
1066 | 293 |
if (TaggedStackInterpreter) pop(tag); |
1 | 294 |
} |
295 |
||
296 |
void InterpreterMacroAssembler::pop_i(Register r) { |
|
297 |
debug_only(verify_stack_tag(frame::TagValue)); |
|
1066 | 298 |
pop(r); |
299 |
if (TaggedStackInterpreter) addptr(rsp, 1 * wordSize); |
|
1 | 300 |
} |
301 |
||
302 |
void InterpreterMacroAssembler::pop_l(Register lo, Register hi) { |
|
303 |
debug_only(verify_stack_tag(frame::TagValue)); |
|
1066 | 304 |
pop(lo); |
305 |
if (TaggedStackInterpreter) addptr(rsp, 1 * wordSize); |
|
1 | 306 |
debug_only(verify_stack_tag(frame::TagValue)); |
1066 | 307 |
pop(hi); |
308 |
if (TaggedStackInterpreter) addptr(rsp, 1 * wordSize); |
|
1 | 309 |
} |
310 |
||
311 |
void InterpreterMacroAssembler::pop_f() { |
|
312 |
debug_only(verify_stack_tag(frame::TagValue)); |
|
313 |
fld_s(Address(rsp, 0)); |
|
1066 | 314 |
addptr(rsp, 1 * wordSize); |
315 |
if (TaggedStackInterpreter) addptr(rsp, 1 * wordSize); |
|
1 | 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)); |
|
1066 | 322 |
addptr(rsp, 2 * wordSize); |
1 | 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)); |
|
1066 | 332 |
pop(rax); |
333 |
addptr(rsp, 1* wordSize); |
|
1 | 334 |
debug_only(verify_stack_tag(frame::TagValue)); |
1066 | 335 |
pop(rdx); |
336 |
addptr(rsp, 1* wordSize); |
|
337 |
push(rdx); |
|
338 |
push(rax); |
|
1 | 339 |
} |
340 |
} |
|
341 |
||
342 |
void InterpreterMacroAssembler::pop_ftos_to_rsp() { |
|
343 |
if (TaggedStackInterpreter) { |
|
344 |
debug_only(verify_stack_tag(frame::TagValue)); |
|
1066 | 345 |
pop(rax); |
346 |
addptr(rsp, 1 * wordSize); |
|
347 |
push(rax); // ftos is at rsp |
|
1 | 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) { |
|
1066 | 368 |
if (TaggedStackInterpreter) push(frame::TagReference); |
369 |
push(r); |
|
1 | 370 |
} |
371 |
||
372 |
void InterpreterMacroAssembler::push_ptr(Register r, Register tag) { |
|
1066 | 373 |
if (TaggedStackInterpreter) push(tag); // tag first |
374 |
push(r); |
|
1 | 375 |
} |
376 |
||
377 |
void InterpreterMacroAssembler::push_i(Register r) { |
|
1066 | 378 |
if (TaggedStackInterpreter) push(frame::TagValue); |
379 |
push(r); |
|
1 | 380 |
} |
381 |
||
382 |
void InterpreterMacroAssembler::push_l(Register lo, Register hi) { |
|
1066 | 383 |
if (TaggedStackInterpreter) push(frame::TagValue); |
384 |
push(hi); |
|
385 |
if (TaggedStackInterpreter) push(frame::TagValue); |
|
386 |
push(lo); |
|
1 | 387 |
} |
388 |
||
389 |
void InterpreterMacroAssembler::push_f() { |
|
1066 | 390 |
if (TaggedStackInterpreter) push(frame::TagValue); |
1 | 391 |
// Do not schedule for no AGI! Never write beyond rsp! |
1066 | 392 |
subptr(rsp, 1 * wordSize); |
1 | 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 |
|
1066 | 403 |
push(frame::TagValue); |
404 |
subptr(rsp, 3 * wordSize); |
|
1 | 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! |
|
1066 | 413 |
subptr(rsp, 2 * wordSize); |
1 | 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) { |
|
1066 | 439 |
movptr(val, Address(rsp, Interpreter::expr_offset_in_bytes(n))); |
1 | 440 |
if (TaggedStackInterpreter) { |
1066 | 441 |
movptr(tag, Address(rsp, Interpreter::expr_tag_offset_in_bytes(n))); |
1 | 442 |
} |
443 |
} |
|
444 |
||
445 |
void InterpreterMacroAssembler::store_ptr_and_tag(int n, Register val, |
|
446 |
Register tag) { |
|
1066 | 447 |
movptr(Address(rsp, Interpreter::expr_offset_in_bytes(n)), val); |
1 | 448 |
if (TaggedStackInterpreter) { |
1066 | 449 |
movptr(Address(rsp, Interpreter::expr_tag_offset_in_bytes(n)), tag); |
1 | 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) { |
|
1066 | 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); |
|
1 | 460 |
} else { |
1066 | 461 |
movptr(Address(rdi, Interpreter::local_tag_offset_in_bytes(n)), (int32_t)tag); |
1 | 462 |
} |
463 |
} |
|
464 |
} |
|
465 |
||
466 |
void InterpreterMacroAssembler::tag_local(frame::Tag tag, Register idx) { |
|
467 |
if (TaggedStackInterpreter) { |
|
468 |
if (tag == frame::TagCategory2) { |
|
1066 | 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); |
|
1 | 473 |
} else { |
1066 | 474 |
movptr(Address(rdi, idx, Interpreter::stackElementScale(), |
475 |
Interpreter::local_tag_offset_in_bytes(0)), (int32_t)tag); |
|
1 | 476 |
} |
477 |
} |
|
478 |
} |
|
479 |
||
480 |
void InterpreterMacroAssembler::tag_local(Register tag, Register idx) { |
|
481 |
if (TaggedStackInterpreter) { |
|
482 |
// can only be TagValue or TagReference |
|
1066 | 483 |
movptr(Address(rdi, idx, Interpreter::stackElementScale(), |
1 | 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 |
|
1066 | 492 |
movptr(Address(rdi, Interpreter::local_tag_offset_in_bytes(n)), tag); |
1 | 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 |
|
1066 | 503 |
cmpptr(Address(rdi, Interpreter::local_tag_offset_in_bytes(n+1)), (int32_t)t); |
1 | 504 |
jcc(Assembler::equal, nbl); |
505 |
stop("Local tag is bad for long/double"); |
|
506 |
bind(nbl); |
|
507 |
} |
|
508 |
Label notBad; |
|
1066 | 509 |
cmpptr(Address(rdi, Interpreter::local_tag_offset_in_bytes(n)), (int32_t)t); |
1 | 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. |
|
1066 | 513 |
cmpptr(Address(rdi, Interpreter::local_offset_in_bytes(n)), 0); |
1 | 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 |
|
1066 | 526 |
cmpptr(Address(rdi, idx, Interpreter::stackElementScale(), |
527 |
Interpreter::local_tag_offset_in_bytes(1)), (int32_t)t); |
|
1 | 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(), |
|
1066 | 534 |
Interpreter::local_tag_offset_in_bytes(0)), (int32_t)t); |
1 | 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. |
|
1066 | 538 |
cmpptr(Address(rdi, idx, Interpreter::stackElementScale(), |
1 | 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) { |
|
1066 | 554 |
push(arg_1); |
1 | 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) { |
|
1066 | 560 |
push(arg_2); |
561 |
push(arg_1); |
|
1 | 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) { |
|
1066 | 567 |
push(arg_3); |
568 |
push(arg_2); |
|
569 |
push(arg_1); |
|
1 | 570 |
MacroAssembler::call_VM_leaf_base(entry_point, 3); |
571 |
} |
|
572 |
||
573 |
||
2534 | 574 |
void InterpreterMacroAssembler::prepare_to_jump_from_interpreted() { |
1 | 575 |
// set sender sp |
1066 | 576 |
lea(rsi, Address(rsp, wordSize)); |
1 | 577 |
// record last_sp |
1066 | 578 |
movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), rsi); |
2534 | 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(); |
|
1 | 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; |
|
1066 | 621 |
mov(rcx, rbp); |
622 |
subptr(rcx, rsp); |
|
1 | 623 |
int min_frame_size = (frame::link_offset - frame::interpreter_frame_initial_sp_offset) * wordSize; |
1066 | 624 |
cmpptr(rcx, min_frame_size); |
1 | 625 |
jcc(Assembler::greaterEqual, L); |
626 |
stop("broken stack frame"); |
|
627 |
bind(L); |
|
628 |
} |
|
629 |
if (verifyoop) verify_oop(rax, state); |
|
1066 | 630 |
Address index(noreg, rbx, Address::times_ptr); |
1 | 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); |
|
1066 | 692 |
mov(rdi,rbx); |
1 | 693 |
movbool(do_not_unlock_if_synchronized, false); // reset the flag |
694 |
||
1066 | 695 |
movptr(rbx, Address(rbp, frame::interpreter_frame_method_offset * wordSize)); // get method access flags |
1 | 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. |
|
1066 | 703 |
mov(rcx,rdi); |
1 | 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)); |
|
1066 | 713 |
lea (rdx, monitor); // address of first monitor |
1 | 714 |
|
1066 | 715 |
movptr (rax, Address(rdx, BasicObjectLock::obj_offset_in_bytes())); |
716 |
testptr(rax, rax); |
|
717 |
jcc (Assembler::notZero, unlock); |
|
1 | 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); |
|
1066 | 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 |
|
1 | 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); |
|
1066 | 772 |
mov(rdx, rcx); |
1 | 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); |
|
1066 | 785 |
cmpptr(Address(rcx, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD); // check if current entry is used |
1 | 786 |
jcc(Assembler::notEqual, exception); |
787 |
||
1066 | 788 |
addptr(rcx, entry_size); // otherwise advance to next entry |
1 | 789 |
bind(entry); |
1066 | 790 |
cmpptr(rcx, rbx); // check if bottom reached |
1 | 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 |
|
1066 | 804 |
movptr(rbx, Address(rbp, frame::interpreter_frame_sender_sp_offset * wordSize)); // get sender sp |
1 | 805 |
leave(); // remove frame anchor |
1066 | 806 |
pop(ret_addr); // get return address |
807 |
mov(rsp, rbx); // set sp to sender sp |
|
1 | 808 |
if (UseSSE) { |
809 |
// float and double are returned in xmm register in SSE-mode |
|
810 |
if (state == ftos && UseSSE >= 1) { |
|
1066 | 811 |
subptr(rsp, wordSize); |
1 | 812 |
fstp_s(Address(rsp, 0)); |
813 |
movflt(xmm0, Address(rsp, 0)); |
|
1066 | 814 |
addptr(rsp, wordSize); |
1 | 815 |
} else if (state == dtos && UseSSE >= 2) { |
1066 | 816 |
subptr(rsp, 2*wordSize); |
1 | 817 |
fstp_d(Address(rsp, 0)); |
818 |
movdbl(xmm0, Address(rsp, 0)); |
|
1066 | 819 |
addptr(rsp, 2*wordSize); |
1 | 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 |
|
1066 | 850 |
movptr(obj_reg, Address(lock_reg, obj_offset)); |
1 | 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, |
|
1066 | 859 |
movptr(swap_reg, (int32_t)1); |
1 | 860 |
|
861 |
// Load (object->mark() | 1) into swap_reg %rax, |
|
1066 | 862 |
orptr(swap_reg, Address(obj_reg, 0)); |
1 | 863 |
|
864 |
// Save (object->mark() | 1) into BasicLock's displaced header |
|
1066 | 865 |
movptr(Address(lock_reg, mark_offset), swap_reg); |
1 | 866 |
|
867 |
assert(lock_offset == 0, "displached header must be first word in BasicObjectLock"); |
|
868 |
if (os::is_MP()) { |
|
869 |
lock(); |
|
870 |
} |
|
1066 | 871 |
cmpxchgptr(lock_reg, Address(obj_reg, 0)); |
1 | 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 |
|
1066 | 887 |
subptr(swap_reg, rsp); |
888 |
andptr(swap_reg, 3 - os::vm_page_size()); |
|
1 | 889 |
|
890 |
// Save the test result, for recursive case, the result is zero |
|
1066 | 891 |
movptr(Address(lock_reg, mark_offset), swap_reg); |
1 | 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, |
|
1066 | 931 |
lea(swap_reg, Address(lock_reg, BasicObjectLock::lock_offset_in_bytes())); |
1 | 932 |
|
933 |
// Load oop into obj_reg(%rcx) |
|
1066 | 934 |
movptr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset_in_bytes ())); |
1 | 935 |
|
936 |
// Free entry |
|
1888
bbf498fb4354
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t
xlu
parents:
1217
diff
changeset
|
937 |
movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), NULL_WORD); |
1 | 938 |
|
939 |
if (UseBiasedLocking) { |
|
940 |
biased_locking_exit(obj_reg, header_reg, done); |
|
941 |
} |
|
942 |
||
943 |
// Load the old header from BasicLock structure |
|
1066 | 944 |
movptr(header_reg, Address(swap_reg, BasicLock::displaced_header_offset_in_bytes())); |
1 | 945 |
|
946 |
// Test for recursion |
|
1066 | 947 |
testptr(header_reg, header_reg); |
1 | 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(); |
|
1066 | 954 |
cmpxchgptr(header_reg, Address(obj_reg, 0)); |
1 | 955 |
|
956 |
// zero for recursive case |
|
957 |
jcc(Assembler::zero, done); |
|
958 |
||
959 |
// Call the runtime routine for slow case. |
|
1066 | 960 |
movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), obj_reg); // restore obj |
1 | 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"); |
|
1066 | 975 |
movptr(mdp, Address(rbp, frame::interpreter_frame_mdx_offset * wordSize)); |
976 |
testptr(mdp, mdp); |
|
1 | 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; |
|
1066 | 985 |
push(rax); |
986 |
push(rbx); |
|
1 | 987 |
|
988 |
get_method(rbx); |
|
989 |
// Test MDO to avoid the call if it is NULL. |
|
1066 | 990 |
movptr(rax, Address(rbx, in_bytes(methodOopDesc::method_data_offset()))); |
991 |
testptr(rax, rax); |
|
1 | 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 |
||
1066 | 999 |
movptr(rbx, Address(rbx, in_bytes(methodOopDesc::method_data_offset()))); |
1000 |
testptr(rbx, rbx); |
|
1 | 1001 |
jcc(Assembler::zero, zero_continue); |
1066 | 1002 |
addptr(rbx, in_bytes(methodDataOopDesc::data_offset())); |
1003 |
addptr(rbx, rax); |
|
1004 |
movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rbx); |
|
1 | 1005 |
|
1006 |
bind(zero_continue); |
|
1066 | 1007 |
pop(rbx); |
1008 |
pop(rax); |
|
1 | 1009 |
} |
1010 |
||
1011 |
void InterpreterMacroAssembler::verify_method_data_pointer() { |
|
1012 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
|
1013 |
#ifdef ASSERT |
|
1014 |
Label verify_continue; |
|
1066 | 1015 |
push(rax); |
1016 |
push(rbx); |
|
1017 |
push(rcx); |
|
1018 |
push(rdx); |
|
1 | 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. |
|
2148
09c7f703773b
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
1909
diff
changeset
|
1024 |
load_unsigned_short(rdx, Address(rcx, in_bytes(DataLayout::bci_offset()))); |
1066 | 1025 |
addptr(rdx, Address(rbx, methodOopDesc::const_offset())); |
1026 |
lea(rdx, Address(rdx, constMethodOopDesc::codes_offset())); |
|
1027 |
cmpptr(rdx, rsi); |
|
1 | 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); |
|
1066 | 1034 |
pop(rdx); |
1035 |
pop(rcx); |
|
1036 |
pop(rbx); |
|
1037 |
pop(rax); |
|
1 | 1038 |
#endif // ASSERT |
1039 |
} |
|
1040 |
||
1041 |
||
1042 |
void InterpreterMacroAssembler::set_mdp_data_at(Register mdp_in, int constant, Register value) { |
|
1066 | 1043 |
// %%% this seems to be used to store counter data which is surely 32bits |
1044 |
// however 64bit side stores 64 bits which seems wrong |
|
1 | 1045 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
1046 |
Address data(mdp_in, constant); |
|
1066 | 1047 |
movptr(data, value); |
1 | 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 |
||
1066 | 1067 |
// %%% 64bit treats this as 64 bit which seems unlikely |
1 | 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) { |
|
1066 | 1114 |
cmpptr(value, Address(mdp_in, offset)); |
1 | 1115 |
} else { |
1116 |
// Put the test value into a register, so caller can use it: |
|
1066 | 1117 |
movptr(test_value_out, Address(mdp_in, offset)); |
1118 |
cmpptr(test_value_out, value); |
|
1 | 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); |
|
1066 | 1127 |
addptr(mdp_in,disp_address); |
1128 |
movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); |
|
1 | 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); |
|
1066 | 1135 |
addptr(mdp_in, disp_address); |
1136 |
movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); |
|
1 | 1137 |
} |
1138 |
||
1139 |
||
1140 |
void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, int constant) { |
|
1141 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
|
1066 | 1142 |
addptr(mdp_in, constant); |
1143 |
movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); |
|
1 | 1144 |
} |
1145 |
||
1146 |
||
1147 |
void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { |
|
1148 |
assert(ProfileInterpreter, "must be profiling interpreter"); |
|
1066 | 1149 |
push(return_bci); // save/restore across call_VM |
1 | 1150 |
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), return_bci); |
1066 | 1151 |
pop(return_bci); |
1 | 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())); |
|
1066 | 1167 |
|
1168 |
// %%% 64bit treats these cells as 64 bit but they seem to be 32 bit |
|
1 | 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 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1233 |
void InterpreterMacroAssembler::profile_virtual_call(Register receiver, Register mdp, |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1234 |
Register reg2, |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1235 |
bool receiver_can_be_null) { |
1 | 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 |
||
1242 |
// We are making a call. Increment the count. |
|
1243 |
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); |
|
1244 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1245 |
Label skip_receiver_profile; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1246 |
if (receiver_can_be_null) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1247 |
testptr(receiver, receiver); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1248 |
jcc(Assembler::zero, skip_receiver_profile); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1249 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1250 |
|
1 | 1251 |
// Record the receiver type. |
1252 |
record_klass_in_profile(receiver, mdp, reg2); |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2534
diff
changeset
|
1253 |
bind(skip_receiver_profile); |
1 | 1254 |
|
1255 |
// The method data pointer needs to be updated to reflect the new target. |
|
1256 |
update_mdp_by_constant(mdp, |
|
1257 |
in_bytes(VirtualCallData:: |
|
1258 |
virtual_call_data_size())); |
|
1259 |
bind(profile_continue); |
|
1260 |
} |
|
1261 |
} |
|
1262 |
||
1263 |
||
1264 |
void InterpreterMacroAssembler::record_klass_in_profile_helper( |
|
1265 |
Register receiver, Register mdp, |
|
1266 |
Register reg2, |
|
1267 |
int start_row, Label& done) { |
|
3814
91f531a11872
6858208: jvm crash when specifying TypeProfileWidth=0 on jdk 6.0
poonam
parents:
3179
diff
changeset
|
1268 |
if (TypeProfileWidth == 0) |
91f531a11872
6858208: jvm crash when specifying TypeProfileWidth=0 on jdk 6.0
poonam
parents:
3179
diff
changeset
|
1269 |
return; |
91f531a11872
6858208: jvm crash when specifying TypeProfileWidth=0 on jdk 6.0
poonam
parents:
3179
diff
changeset
|
1270 |
|
1 | 1271 |
int last_row = VirtualCallData::row_limit() - 1; |
1272 |
assert(start_row <= last_row, "must be work left to do"); |
|
1273 |
// Test this row for both the receiver and for null. |
|
1274 |
// Take any of three different outcomes: |
|
1275 |
// 1. found receiver => increment count and goto done |
|
1276 |
// 2. found null => keep looking for case 1, maybe allocate this cell |
|
1277 |
// 3. found something else => keep looking for cases 1 and 2 |
|
1278 |
// Case 3 is handled by a recursive call. |
|
1279 |
for (int row = start_row; row <= last_row; row++) { |
|
1280 |
Label next_test; |
|
1281 |
bool test_for_null_also = (row == start_row); |
|
1282 |
||
1283 |
// See if the receiver is receiver[n]. |
|
1284 |
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(row)); |
|
1285 |
test_mdp_data_at(mdp, recvr_offset, receiver, |
|
1286 |
(test_for_null_also ? reg2 : noreg), |
|
1287 |
next_test); |
|
1288 |
// (Reg2 now contains the receiver from the CallData.) |
|
1289 |
||
1290 |
// The receiver is receiver[n]. Increment count[n]. |
|
1291 |
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(row)); |
|
1292 |
increment_mdp_data_at(mdp, count_offset); |
|
1293 |
jmp(done); |
|
1294 |
bind(next_test); |
|
1295 |
||
1296 |
if (row == start_row) { |
|
1297 |
// Failed the equality check on receiver[n]... Test for null. |
|
1066 | 1298 |
testptr(reg2, reg2); |
1 | 1299 |
if (start_row == last_row) { |
1300 |
// The only thing left to do is handle the null case. |
|
1301 |
jcc(Assembler::notZero, done); |
|
1302 |
break; |
|
1303 |
} |
|
1304 |
// Since null is rare, make it be the branch-taken case. |
|
1305 |
Label found_null; |
|
1306 |
jcc(Assembler::zero, found_null); |
|
1307 |
||
1308 |
// Put all the "Case 3" tests here. |
|
1309 |
record_klass_in_profile_helper(receiver, mdp, reg2, start_row + 1, done); |
|
1310 |
||
1311 |
// Found a null. Keep searching for a matching receiver, |
|
1312 |
// but remember that this is an empty (unused) slot. |
|
1313 |
bind(found_null); |
|
1314 |
} |
|
1315 |
} |
|
1316 |
||
1317 |
// In the fall-through case, we found no matching receiver, but we |
|
1318 |
// observed the receiver[start_row] is NULL. |
|
1319 |
||
1320 |
// Fill in the receiver field and increment the count. |
|
1321 |
int recvr_offset = in_bytes(VirtualCallData::receiver_offset(start_row)); |
|
1322 |
set_mdp_data_at(mdp, recvr_offset, receiver); |
|
1323 |
int count_offset = in_bytes(VirtualCallData::receiver_count_offset(start_row)); |
|
1066 | 1324 |
movptr(reg2, (int32_t)DataLayout::counter_increment); |
1 | 1325 |
set_mdp_data_at(mdp, count_offset, reg2); |
1326 |
jmp(done); |
|
1327 |
} |
|
1328 |
||
1329 |
void InterpreterMacroAssembler::record_klass_in_profile(Register receiver, |
|
1330 |
Register mdp, |
|
1331 |
Register reg2) { |
|
1332 |
assert(ProfileInterpreter, "must be profiling"); |
|
1333 |
Label done; |
|
1334 |
||
1335 |
record_klass_in_profile_helper(receiver, mdp, reg2, 0, done); |
|
1336 |
||
1337 |
bind (done); |
|
1338 |
} |
|
1339 |
||
1340 |
void InterpreterMacroAssembler::profile_ret(Register return_bci, Register mdp) { |
|
1341 |
if (ProfileInterpreter) { |
|
1342 |
Label profile_continue; |
|
1343 |
uint row; |
|
1344 |
||
1345 |
// If no method data exists, go to profile_continue. |
|
1346 |
test_method_data_pointer(mdp, profile_continue); |
|
1347 |
||
1348 |
// Update the total ret count. |
|
1349 |
increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); |
|
1350 |
||
1351 |
for (row = 0; row < RetData::row_limit(); row++) { |
|
1352 |
Label next_test; |
|
1353 |
||
1354 |
// See if return_bci is equal to bci[n]: |
|
1355 |
test_mdp_data_at(mdp, in_bytes(RetData::bci_offset(row)), return_bci, |
|
1356 |
noreg, next_test); |
|
1357 |
||
1358 |
// return_bci is equal to bci[n]. Increment the count. |
|
1359 |
increment_mdp_data_at(mdp, in_bytes(RetData::bci_count_offset(row))); |
|
1360 |
||
1361 |
// The method data pointer needs to be updated to reflect the new target. |
|
1362 |
update_mdp_by_offset(mdp, in_bytes(RetData::bci_displacement_offset(row))); |
|
1363 |
jmp(profile_continue); |
|
1364 |
bind(next_test); |
|
1365 |
} |
|
1366 |
||
1367 |
update_mdp_for_ret(return_bci); |
|
1368 |
||
1369 |
bind (profile_continue); |
|
1370 |
} |
|
1371 |
} |
|
1372 |
||
1373 |
||
1374 |
void InterpreterMacroAssembler::profile_null_seen(Register mdp) { |
|
1375 |
if (ProfileInterpreter) { |
|
1376 |
Label profile_continue; |
|
1377 |
||
1378 |
// If no method data exists, go to profile_continue. |
|
1379 |
test_method_data_pointer(mdp, profile_continue); |
|
1380 |
||
3179
e9442e207d31
6851908: interpreter null check profiling broken causing extra compilation invalidation
never
parents:
2570
diff
changeset
|
1381 |
set_mdp_flag_at(mdp, BitData::null_seen_byte_constant()); |
e9442e207d31
6851908: interpreter null check profiling broken causing extra compilation invalidation
never
parents:
2570
diff
changeset
|
1382 |
|
1 | 1383 |
// The method data pointer needs to be updated. |
1384 |
int mdp_delta = in_bytes(BitData::bit_data_size()); |
|
1385 |
if (TypeProfileCasts) { |
|
1386 |
mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); |
|
1387 |
} |
|
1388 |
update_mdp_by_constant(mdp, mdp_delta); |
|
1389 |
||
1390 |
bind (profile_continue); |
|
1391 |
} |
|
1392 |
} |
|
1393 |
||
1394 |
||
1395 |
void InterpreterMacroAssembler::profile_typecheck_failed(Register mdp) { |
|
1396 |
if (ProfileInterpreter && TypeProfileCasts) { |
|
1397 |
Label profile_continue; |
|
1398 |
||
1399 |
// If no method data exists, go to profile_continue. |
|
1400 |
test_method_data_pointer(mdp, profile_continue); |
|
1401 |
||
1402 |
int count_offset = in_bytes(CounterData::count_offset()); |
|
1403 |
// Back up the address, since we have already bumped the mdp. |
|
1404 |
count_offset -= in_bytes(VirtualCallData::virtual_call_data_size()); |
|
1405 |
||
1406 |
// *Decrement* the counter. We expect to see zero or small negatives. |
|
1407 |
increment_mdp_data_at(mdp, count_offset, true); |
|
1408 |
||
1409 |
bind (profile_continue); |
|
1410 |
} |
|
1411 |
} |
|
1412 |
||
1413 |
||
1414 |
void InterpreterMacroAssembler::profile_typecheck(Register mdp, Register klass, Register reg2) |
|
1415 |
{ |
|
1416 |
if (ProfileInterpreter) { |
|
1417 |
Label profile_continue; |
|
1418 |
||
1419 |
// If no method data exists, go to profile_continue. |
|
1420 |
test_method_data_pointer(mdp, profile_continue); |
|
1421 |
||
1422 |
// The method data pointer needs to be updated. |
|
1423 |
int mdp_delta = in_bytes(BitData::bit_data_size()); |
|
1424 |
if (TypeProfileCasts) { |
|
1425 |
mdp_delta = in_bytes(VirtualCallData::virtual_call_data_size()); |
|
1426 |
||
1427 |
// Record the object type. |
|
1428 |
record_klass_in_profile(klass, mdp, reg2); |
|
1429 |
assert(reg2 == rdi, "we know how to fix this blown reg"); |
|
1430 |
restore_locals(); // Restore EDI |
|
1431 |
} |
|
1432 |
update_mdp_by_constant(mdp, mdp_delta); |
|
1433 |
||
1434 |
bind(profile_continue); |
|
1435 |
} |
|
1436 |
} |
|
1437 |
||
1438 |
||
1439 |
void InterpreterMacroAssembler::profile_switch_default(Register mdp) { |
|
1440 |
if (ProfileInterpreter) { |
|
1441 |
Label profile_continue; |
|
1442 |
||
1443 |
// If no method data exists, go to profile_continue. |
|
1444 |
test_method_data_pointer(mdp, profile_continue); |
|
1445 |
||
1446 |
// Update the default case count |
|
1447 |
increment_mdp_data_at(mdp, in_bytes(MultiBranchData::default_count_offset())); |
|
1448 |
||
1449 |
// The method data pointer needs to be updated. |
|
1450 |
update_mdp_by_offset(mdp, in_bytes(MultiBranchData::default_displacement_offset())); |
|
1451 |
||
1452 |
bind (profile_continue); |
|
1453 |
} |
|
1454 |
} |
|
1455 |
||
1456 |
||
1457 |
void InterpreterMacroAssembler::profile_switch_case(Register index, Register mdp, Register reg2) { |
|
1458 |
if (ProfileInterpreter) { |
|
1459 |
Label profile_continue; |
|
1460 |
||
1461 |
// If no method data exists, go to profile_continue. |
|
1462 |
test_method_data_pointer(mdp, profile_continue); |
|
1463 |
||
1464 |
// Build the base (index * per_case_size_in_bytes()) + case_array_offset_in_bytes() |
|
1066 | 1465 |
movptr(reg2, (int32_t)in_bytes(MultiBranchData::per_case_size())); |
1466 |
// index is positive and so should have correct value if this code were |
|
1467 |
// used on 64bits |
|
1468 |
imulptr(index, reg2); |
|
1469 |
addptr(index, in_bytes(MultiBranchData::case_array_offset())); |
|
1 | 1470 |
|
1471 |
// Update the case count |
|
1472 |
increment_mdp_data_at(mdp, index, in_bytes(MultiBranchData::relative_count_offset())); |
|
1473 |
||
1474 |
// The method data pointer needs to be updated. |
|
1475 |
update_mdp_by_offset(mdp, index, in_bytes(MultiBranchData::relative_displacement_offset())); |
|
1476 |
||
1477 |
bind (profile_continue); |
|
1478 |
} |
|
1479 |
} |
|
1480 |
||
1481 |
#endif // !CC_INTERP |
|
1482 |
||
1483 |
||
1484 |
||
1485 |
void InterpreterMacroAssembler::verify_oop(Register reg, TosState state) { |
|
1486 |
if (state == atos) MacroAssembler::verify_oop(reg); |
|
1487 |
} |
|
1488 |
||
1489 |
||
1490 |
#ifndef CC_INTERP |
|
1491 |
void InterpreterMacroAssembler::verify_FPU(int stack_depth, TosState state) { |
|
1492 |
if (state == ftos || state == dtos) MacroAssembler::verify_FPU(stack_depth); |
|
1493 |
} |
|
1494 |
||
1495 |
#endif /* CC_INTERP */ |
|
1496 |
||
1497 |
||
1498 |
void InterpreterMacroAssembler::notify_method_entry() { |
|
1499 |
// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to |
|
1500 |
// track stack depth. If it is possible to enter interp_only_mode we add |
|
1501 |
// the code to check if the event should be sent. |
|
1502 |
if (JvmtiExport::can_post_interpreter_events()) { |
|
1503 |
Label L; |
|
1504 |
get_thread(rcx); |
|
1505 |
movl(rcx, Address(rcx, JavaThread::interp_only_mode_offset())); |
|
1506 |
testl(rcx,rcx); |
|
1507 |
jcc(Assembler::zero, L); |
|
1508 |
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_entry)); |
|
1509 |
bind(L); |
|
1510 |
} |
|
1511 |
||
1512 |
{ |
|
1513 |
SkipIfEqual skip_if(this, &DTraceMethodProbes, 0); |
|
1514 |
get_thread(rcx); |
|
1515 |
get_method(rbx); |
|
1516 |
call_VM_leaf( |
|
1517 |
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), rcx, rbx); |
|
1518 |
} |
|
2136
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1519 |
|
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1520 |
// RedefineClasses() tracing support for obsolete method entry |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1521 |
if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1522 |
get_thread(rcx); |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1523 |
get_method(rbx); |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1524 |
call_VM_leaf( |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1525 |
CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1526 |
rcx, rbx); |
c55428da3cec
6805864: 4/3 Problem with jvmti->redefineClasses: some methods don't get redefined
dcubed
parents:
1217
diff
changeset
|
1527 |
} |
1 | 1528 |
} |
1529 |
||
1530 |
||
1531 |
void InterpreterMacroAssembler::notify_method_exit( |
|
1532 |
TosState state, NotifyMethodExitMode mode) { |
|
1533 |
// Whenever JVMTI is interp_only_mode, method entry/exit events are sent to |
|
1534 |
// track stack depth. If it is possible to enter interp_only_mode we add |
|
1535 |
// the code to check if the event should be sent. |
|
1536 |
if (mode == NotifyJVMTI && JvmtiExport::can_post_interpreter_events()) { |
|
1537 |
Label L; |
|
1538 |
// Note: frame::interpreter_frame_result has a dependency on how the |
|
1539 |
// method result is saved across the call to post_method_exit. If this |
|
1540 |
// is changed then the interpreter_frame_result implementation will |
|
1541 |
// need to be updated too. |
|
1542 |
||
1543 |
// For c++ interpreter the result is always stored at a known location in the frame |
|
1544 |
// template interpreter will leave it on the top of the stack. |
|
1545 |
NOT_CC_INTERP(push(state);) |
|
1546 |
get_thread(rcx); |
|
1547 |
movl(rcx, Address(rcx, JavaThread::interp_only_mode_offset())); |
|
1548 |
testl(rcx,rcx); |
|
1549 |
jcc(Assembler::zero, L); |
|
1550 |
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_method_exit)); |
|
1551 |
bind(L); |
|
1552 |
NOT_CC_INTERP(pop(state);) |
|
1553 |
} |
|
1554 |
||
1555 |
{ |
|
1556 |
SkipIfEqual skip_if(this, &DTraceMethodProbes, 0); |
|
1066 | 1557 |
NOT_CC_INTERP(push(state)); |
1 | 1558 |
get_thread(rbx); |
1559 |
get_method(rcx); |
|
1560 |
call_VM_leaf( |
|
1561 |
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), |
|
1562 |
rbx, rcx); |
|
1066 | 1563 |
NOT_CC_INTERP(pop(state)); |
1 | 1564 |
} |
1565 |
} |