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