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