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