Mercurial > hg > graal-jvmci-8
annotate src/cpu/x86/vm/templateInterpreter_x86_64.cpp @ 23758:ca5c97226d1c
Try to load the MDO on return from frequency_counter_overflow
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 21 Sep 2016 20:15:14 -0700 |
parents | b5f3a471e646 |
children | a5a2ac8dfaba |
rev | line source |
---|---|
0 | 1 /* |
23614 | 2 * Copyright (c) 2003, 2016, 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" |
7199
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
6725
diff
changeset
|
26 #include "asm/macroAssembler.hpp" |
1972 | 27 #include "interpreter/bytecodeHistogram.hpp" |
28 #include "interpreter/interpreter.hpp" | |
29 #include "interpreter/interpreterGenerator.hpp" | |
30 #include "interpreter/interpreterRuntime.hpp" | |
31 #include "interpreter/templateTable.hpp" | |
32 #include "oops/arrayOop.hpp" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
33 #include "oops/methodData.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
34 #include "oops/method.hpp" |
1972 | 35 #include "oops/oop.inline.hpp" |
36 #include "prims/jvmtiExport.hpp" | |
37 #include "prims/jvmtiThreadState.hpp" | |
38 #include "runtime/arguments.hpp" | |
39 #include "runtime/deoptimization.hpp" | |
40 #include "runtime/frame.inline.hpp" | |
41 #include "runtime/sharedRuntime.hpp" | |
42 #include "runtime/stubRoutines.hpp" | |
43 #include "runtime/synchronizer.hpp" | |
44 #include "runtime/timer.hpp" | |
45 #include "runtime/vframeArray.hpp" | |
46 #include "utilities/debug.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7402
diff
changeset
|
47 #include "utilities/macros.hpp" |
0 | 48 |
49 #define __ _masm-> | |
50 | |
304 | 51 #ifndef CC_INTERP |
52 | |
0 | 53 const int method_offset = frame::interpreter_frame_method_offset * wordSize; |
54 const int bci_offset = frame::interpreter_frame_bcx_offset * wordSize; | |
55 const int locals_offset = frame::interpreter_frame_locals_offset * wordSize; | |
56 | |
57 //----------------------------------------------------------------------------- | |
58 | |
59 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { | |
60 address entry = __ pc(); | |
61 | |
62 #ifdef ASSERT | |
63 { | |
64 Label L; | |
304 | 65 __ lea(rax, Address(rbp, |
66 frame::interpreter_frame_monitor_block_top_offset * | |
67 wordSize)); | |
68 __ cmpptr(rax, rsp); // rax = maximal rsp for current rbp (stack | |
69 // grows negative) | |
0 | 70 __ jcc(Assembler::aboveEqual, L); // check if frame is complete |
71 __ stop ("interpreter frame not set up"); | |
72 __ bind(L); | |
73 } | |
74 #endif // ASSERT | |
75 // Restore bcp under the assumption that the current frame is still | |
76 // interpreted | |
77 __ restore_bcp(); | |
78 | |
79 // expression stack must be empty before entering the VM if an | |
80 // exception happened | |
81 __ empty_expression_stack(); | |
82 // throw exception | |
83 __ call_VM(noreg, | |
84 CAST_FROM_FN_PTR(address, | |
85 InterpreterRuntime::throw_StackOverflowError)); | |
86 return entry; | |
87 } | |
88 | |
89 address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler( | |
90 const char* name) { | |
91 address entry = __ pc(); | |
92 // expression stack must be empty before entering the VM if an | |
93 // exception happened | |
94 __ empty_expression_stack(); | |
95 // setup parameters | |
96 // ??? convention: expect aberrant index in register ebx | |
97 __ lea(c_rarg1, ExternalAddress((address)name)); | |
98 __ call_VM(noreg, | |
99 CAST_FROM_FN_PTR(address, | |
100 InterpreterRuntime:: | |
101 throw_ArrayIndexOutOfBoundsException), | |
102 c_rarg1, rbx); | |
103 return entry; | |
104 } | |
105 | |
106 address TemplateInterpreterGenerator::generate_ClassCastException_handler() { | |
107 address entry = __ pc(); | |
108 | |
109 // object is at TOS | |
304 | 110 __ pop(c_rarg1); |
0 | 111 |
112 // expression stack must be empty before entering the VM if an | |
113 // exception happened | |
114 __ empty_expression_stack(); | |
115 | |
116 __ call_VM(noreg, | |
117 CAST_FROM_FN_PTR(address, | |
118 InterpreterRuntime:: | |
119 throw_ClassCastException), | |
120 c_rarg1); | |
121 return entry; | |
122 } | |
123 | |
124 address TemplateInterpreterGenerator::generate_exception_handler_common( | |
125 const char* name, const char* message, bool pass_oop) { | |
126 assert(!pass_oop || message == NULL, "either oop or message but not both"); | |
127 address entry = __ pc(); | |
128 if (pass_oop) { | |
129 // object is at TOS | |
304 | 130 __ pop(c_rarg2); |
0 | 131 } |
132 // expression stack must be empty before entering the VM if an | |
133 // exception happened | |
134 __ empty_expression_stack(); | |
135 // setup parameters | |
136 __ lea(c_rarg1, ExternalAddress((address)name)); | |
137 if (pass_oop) { | |
138 __ call_VM(rax, CAST_FROM_FN_PTR(address, | |
139 InterpreterRuntime:: | |
140 create_klass_exception), | |
141 c_rarg1, c_rarg2); | |
142 } else { | |
143 // kind of lame ExternalAddress can't take NULL because | |
144 // external_word_Relocation will assert. | |
145 if (message != NULL) { | |
146 __ lea(c_rarg2, ExternalAddress((address)message)); | |
147 } else { | |
148 __ movptr(c_rarg2, NULL_WORD); | |
149 } | |
150 __ call_VM(rax, | |
151 CAST_FROM_FN_PTR(address, InterpreterRuntime::create_exception), | |
152 c_rarg1, c_rarg2); | |
153 } | |
154 // throw exception | |
155 __ jump(ExternalAddress(Interpreter::throw_exception_entry())); | |
156 return entry; | |
157 } | |
158 | |
159 | |
160 address TemplateInterpreterGenerator::generate_continuation_for(TosState state) { | |
161 address entry = __ pc(); | |
162 // NULL last_sp until next java call | |
304 | 163 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 164 __ dispatch_next(state); |
165 return entry; | |
166 } | |
167 | |
168 | |
13010
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
169 address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { |
0 | 170 address entry = __ pc(); |
171 | |
172 // Restore stack bottom in case i2c adjusted stack | |
304 | 173 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
0 | 174 // and NULL it as marker that esp is now tos until next java call |
304 | 175 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 176 |
177 __ restore_bcp(); | |
178 __ restore_locals(); | |
304 | 179 |
12882
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
180 if (state == atos) { |
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
181 Register mdp = rbx; |
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
182 Register tmp = rcx; |
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
183 __ profile_return_type(mdp, rax, tmp); |
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
184 } |
ce0cc25bc5e2
8026054: New type profiling points: type of return values at calls
roland
parents:
12076
diff
changeset
|
185 |
13010
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
186 const Register cache = rbx; |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
187 const Register index = rcx; |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
188 __ get_cache_and_index_at_bcp(cache, index, 1, index_size); |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
189 |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
190 const Register flags = cache; |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
191 __ movl(flags, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
192 __ andl(flags, ConstantPoolCacheEntry::parameter_size_mask); |
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
12962
diff
changeset
|
193 __ lea(rsp, Address(rsp, flags, Interpreter::stackElementScale())); |
0 | 194 __ dispatch_next(state, step); |
1108 | 195 |
0 | 196 return entry; |
197 } | |
198 | |
199 | |
8328
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
200 address InterpreterGenerator::generate_deopt_entry_for(TosState state, |
0 | 201 int step) { |
202 address entry = __ pc(); | |
203 // NULL last_sp until next java call | |
304 | 204 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 205 __ restore_bcp(); |
206 __ restore_locals(); | |
22298 | 207 #if INCLUDE_JVMCI |
8328
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
208 // Check if we need to take lock at entry of synchronized method. |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
209 { |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
210 Label L; |
22460
f27c163d7dc2
moved JVMCI fields from ThreadShadow to Thread
Doug Simon <doug.simon@oracle.com>
parents:
22298
diff
changeset
|
211 __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0); |
8328
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
212 __ jcc(Assembler::zero, L); |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
213 // Clear flag. |
22460
f27c163d7dc2
moved JVMCI fields from ThreadShadow to Thread
Doug Simon <doug.simon@oracle.com>
parents:
22298
diff
changeset
|
214 __ movb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0); |
8328
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
215 // Satisfy calling convention for lock_method(). |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
216 __ get_method(rbx); |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
217 // Take lock. |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
218 lock_method(); |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
219 __ bind(L); |
6b6cbd8b8914
Support deoptimizing before the entry to a synchronized method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8124
diff
changeset
|
220 } |
13220
2b43fcc68add
Put _pending_deoptimization and _pending_monitorenter under ifdef GRAAL
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13086
diff
changeset
|
221 #endif |
0 | 222 // handle exceptions |
223 { | |
224 Label L; | |
304 | 225 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
0 | 226 __ jcc(Assembler::zero, L); |
227 __ call_VM(noreg, | |
228 CAST_FROM_FN_PTR(address, | |
229 InterpreterRuntime::throw_pending_exception)); | |
230 __ should_not_reach_here(); | |
231 __ bind(L); | |
232 } | |
233 __ dispatch_next(state, step); | |
234 return entry; | |
235 } | |
236 | |
237 int AbstractInterpreter::BasicType_as_index(BasicType type) { | |
238 int i = 0; | |
239 switch (type) { | |
240 case T_BOOLEAN: i = 0; break; | |
241 case T_CHAR : i = 1; break; | |
242 case T_BYTE : i = 2; break; | |
243 case T_SHORT : i = 3; break; | |
244 case T_INT : i = 4; break; | |
245 case T_LONG : i = 5; break; | |
246 case T_VOID : i = 6; break; | |
247 case T_FLOAT : i = 7; break; | |
248 case T_DOUBLE : i = 8; break; | |
249 case T_OBJECT : i = 9; break; | |
250 case T_ARRAY : i = 9; break; | |
251 default : ShouldNotReachHere(); | |
252 } | |
253 assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, | |
254 "index out of bounds"); | |
255 return i; | |
256 } | |
257 | |
258 | |
259 address TemplateInterpreterGenerator::generate_result_handler_for( | |
260 BasicType type) { | |
261 address entry = __ pc(); | |
262 switch (type) { | |
263 case T_BOOLEAN: __ c2bool(rax); break; | |
264 case T_CHAR : __ movzwl(rax, rax); break; | |
265 case T_BYTE : __ sign_extend_byte(rax); break; | |
266 case T_SHORT : __ sign_extend_short(rax); break; | |
267 case T_INT : /* nothing to do */ break; | |
268 case T_LONG : /* nothing to do */ break; | |
269 case T_VOID : /* nothing to do */ break; | |
270 case T_FLOAT : /* nothing to do */ break; | |
271 case T_DOUBLE : /* nothing to do */ break; | |
272 case T_OBJECT : | |
273 // retrieve result from frame | |
304 | 274 __ movptr(rax, Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize)); |
0 | 275 // and verify it |
276 __ verify_oop(rax); | |
277 break; | |
278 default : ShouldNotReachHere(); | |
279 } | |
280 __ ret(0); // return from result handler | |
281 return entry; | |
282 } | |
283 | |
284 address TemplateInterpreterGenerator::generate_safept_entry_for( | |
285 TosState state, | |
286 address runtime_entry) { | |
287 address entry = __ pc(); | |
288 __ push(state); | |
289 __ call_VM(noreg, runtime_entry); | |
290 __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos)); | |
291 return entry; | |
292 } | |
293 | |
294 | |
295 | |
296 // Helpers for commoning out cases in the various type of method entries. | |
297 // | |
298 | |
299 | |
300 // increment invocation count & check for overflow | |
301 // | |
302 // Note: checking for negative value instead of overflow | |
303 // so we have a 'sticky' overflow test | |
304 // | |
305 // rbx: method | |
306 // ecx: invocation counter | |
307 // | |
308 void InterpreterGenerator::generate_counter_incr( | |
309 Label* overflow, | |
310 Label* profile_method, | |
311 Label* profile_method_continue) { | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
312 Label done; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
313 // Note: In tiered we increment either counters in Method* or in MDO depending if we're profiling or not. |
1783 | 314 if (TieredCompilation) { |
315 int increment = InvocationCounter::count_increment; | |
316 int mask = ((1 << Tier0InvokeNotifyFreqLog) - 1) << InvocationCounter::count_shift; | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
317 Label no_mdo; |
1783 | 318 if (ProfileInterpreter) { |
319 // Are we profiling? | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
320 __ movptr(rax, Address(rbx, Method::method_data_offset())); |
1783 | 321 __ testptr(rax, rax); |
322 __ jccb(Assembler::zero, no_mdo); | |
323 // Increment counter in the MDO | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
324 const Address mdo_invocation_counter(rax, in_bytes(MethodData::invocation_counter_offset()) + |
1783 | 325 in_bytes(InvocationCounter::counter_offset())); |
326 __ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow); | |
10141
47766e2d2527
8013041: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset.
jiangli
parents:
10105
diff
changeset
|
327 __ jmp(done); |
1783 | 328 } |
329 __ bind(no_mdo); | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
330 // Increment counter in MethodCounters |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
331 const Address invocation_counter(rax, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
332 MethodCounters::invocation_counter_offset() + |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
333 InvocationCounter::counter_offset()); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
334 __ get_method_counters(rbx, rax, done); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
335 __ increment_mask_and_jump(invocation_counter, increment, mask, rcx, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
336 false, Assembler::zero, overflow); |
1783 | 337 __ bind(done); |
338 } else { | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
339 const Address backedge_counter(rax, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
340 MethodCounters::backedge_counter_offset() + |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
341 InvocationCounter::counter_offset()); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
342 const Address invocation_counter(rax, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
343 MethodCounters::invocation_counter_offset() + |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
344 InvocationCounter::counter_offset()); |
0 | 345 |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
346 __ get_method_counters(rbx, rax, done); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
347 |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
348 if (ProfileInterpreter) { |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
349 __ incrementl(Address(rax, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
350 MethodCounters::interpreter_invocation_counter_offset())); |
1783 | 351 } |
352 // Update standard invocation counters | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
353 __ movl(rcx, invocation_counter); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
354 __ incrementl(rcx, InvocationCounter::count_increment); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
355 __ movl(invocation_counter, rcx); // save invocation count |
0 | 356 |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
357 __ movl(rax, backedge_counter); // load backedge counter |
1783 | 358 __ andl(rax, InvocationCounter::count_mask_value); // mask out the status bits |
0 | 359 |
1783 | 360 __ addl(rcx, rax); // add both counters |
0 | 361 |
1783 | 362 // profile_method is non-null only for interpreted method so |
363 // profile_method != NULL == !native_call | |
364 | |
365 if (ProfileInterpreter && profile_method != NULL) { | |
366 // Test to see if we should create a method data oop | |
367 __ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterProfileLimit)); | |
368 __ jcc(Assembler::less, *profile_method_continue); | |
0 | 369 |
1783 | 370 // if no method data exists, go to profile_method |
371 __ test_method_data_pointer(rax, *profile_method); | |
372 } | |
373 | |
374 __ cmp32(rcx, ExternalAddress((address)&InvocationCounter::InterpreterInvocationLimit)); | |
375 __ jcc(Assembler::aboveEqual, *overflow); | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8873
diff
changeset
|
376 __ bind(done); |
0 | 377 } |
378 } | |
379 | |
380 void InterpreterGenerator::generate_counter_overflow(Label* do_continue) { | |
381 | |
382 // Asm interpreter on entry | |
383 // r14 - locals | |
384 // r13 - bcp | |
385 // rbx - method | |
386 // edx - cpool --- DOES NOT APPEAR TO BE TRUE | |
387 // rbp - interpreter frame | |
388 | |
389 // On return (i.e. jump to entry_point) [ back to invocation of interpreter ] | |
390 // Everything as it was on entry | |
391 // rdx is not restored. Doesn't appear to really be set. | |
392 | |
393 // InterpreterRuntime::frequency_counter_overflow takes two | |
394 // arguments, the first (thread) is passed by call_VM, the second | |
395 // indicates if the counter overflow occurs at a backwards branch | |
396 // (NULL bcp). We pass zero for it. The call returns the address | |
397 // of the verified entry point for the method or NULL if the | |
398 // compilation did not complete (either went background or bailed | |
399 // out). | |
400 __ movl(c_rarg1, 0); | |
401 __ call_VM(noreg, | |
402 CAST_FROM_FN_PTR(address, | |
403 InterpreterRuntime::frequency_counter_overflow), | |
404 c_rarg1); | |
405 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
406 __ movptr(rbx, Address(rbp, method_offset)); // restore Method* |
23758
ca5c97226d1c
Try to load the MDO on return from frequency_counter_overflow
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23660
diff
changeset
|
407 __ set_method_data_pointer_for_bcp(); |
0 | 408 // Preserve invariant that r13/r14 contain bcp/locals of sender frame |
409 // and jump to the interpreted entry. | |
410 __ jmp(*do_continue, relocInfo::none); | |
411 } | |
412 | |
413 // See if we've got enough room on the stack for locals plus overhead. | |
414 // The expression stack grows down incrementally, so the normal guard | |
415 // page mechanism will work for that. | |
416 // | |
417 // NOTE: Since the additional locals are also always pushed (wasn't | |
418 // obvious in generate_method_entry) so the guard should work for them | |
419 // too. | |
420 // | |
421 // Args: | |
422 // rdx: number of additional locals this frame needs (what we must check) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
423 // rbx: Method* |
0 | 424 // |
425 // Kills: | |
426 // rax | |
427 void InterpreterGenerator::generate_stack_overflow_check(void) { | |
428 | |
429 // monitor entry size: see picture of stack set | |
430 // (generate_method_entry) and frame_amd64.hpp | |
431 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
432 | |
433 // total overhead size: entry_size + (saved rbp through expr stack | |
434 // bottom). be sure to change this if you add/subtract anything | |
435 // to/from the overhead area | |
436 const int overhead_size = | |
437 -(frame::interpreter_frame_initial_sp_offset * wordSize) + entry_size; | |
438 | |
439 const int page_size = os::vm_page_size(); | |
440 | |
441 Label after_frame_check; | |
442 | |
443 // see if the frame is greater than one page in size. If so, | |
444 // then we need to verify there is enough stack space remaining | |
445 // for the additional locals. | |
1506 | 446 __ cmpl(rdx, (page_size - overhead_size) / Interpreter::stackElementSize); |
0 | 447 __ jcc(Assembler::belowEqual, after_frame_check); |
448 | |
449 // compute rsp as if this were going to be the last frame on | |
450 // the stack before the red zone | |
451 | |
452 const Address stack_base(r15_thread, Thread::stack_base_offset()); | |
453 const Address stack_size(r15_thread, Thread::stack_size_offset()); | |
454 | |
455 // locals + overhead, in bytes | |
304 | 456 __ mov(rax, rdx); |
1506 | 457 __ shlptr(rax, Interpreter::logStackElementSize); // 2 slots per parameter. |
304 | 458 __ addptr(rax, overhead_size); |
0 | 459 |
460 #ifdef ASSERT | |
461 Label stack_base_okay, stack_size_okay; | |
462 // verify that thread stack base is non-zero | |
304 | 463 __ cmpptr(stack_base, (int32_t)NULL_WORD); |
0 | 464 __ jcc(Assembler::notEqual, stack_base_okay); |
465 __ stop("stack base is zero"); | |
466 __ bind(stack_base_okay); | |
467 // verify that thread stack size is non-zero | |
304 | 468 __ cmpptr(stack_size, 0); |
0 | 469 __ jcc(Assembler::notEqual, stack_size_okay); |
470 __ stop("stack size is zero"); | |
471 __ bind(stack_size_okay); | |
472 #endif | |
473 | |
474 // Add stack base to locals and subtract stack size | |
304 | 475 __ addptr(rax, stack_base); |
476 __ subptr(rax, stack_size); | |
0 | 477 |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
478 // Use the maximum number of pages we might bang. |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
479 const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages : |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
480 (StackRedPages+StackYellowPages); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
481 |
0 | 482 // add in the red and yellow zone sizes |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1108
diff
changeset
|
483 __ addptr(rax, max_pages * page_size); |
0 | 484 |
485 // check against the current stack bottom | |
304 | 486 __ cmpptr(rsp, rax); |
0 | 487 __ jcc(Assembler::above, after_frame_check); |
488 | |
4743 | 489 // Restore sender's sp as SP. This is necessary if the sender's |
490 // frame is an extended compiled frame (see gen_c2i_adapter()) | |
491 // and safer anyway in case of JSR292 adaptations. | |
492 | |
493 __ pop(rax); // return address must be moved if SP is changed | |
494 __ mov(rsp, r13); | |
495 __ push(rax); | |
496 | |
497 // Note: the restored frame is not necessarily interpreted. | |
498 // Use the shared runtime version of the StackOverflowError. | |
499 assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "stub not yet generated"); | |
500 __ jump(ExternalAddress(StubRoutines::throw_StackOverflowError_entry())); | |
0 | 501 |
502 // all done with frame size check | |
503 __ bind(after_frame_check); | |
504 } | |
505 | |
506 // Allocate monitor and lock method (asm interpreter) | |
507 // | |
508 // Args: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
509 // rbx: Method* |
0 | 510 // r14: locals |
511 // | |
512 // Kills: | |
513 // rax | |
514 // c_rarg0, c_rarg1, c_rarg2, c_rarg3, ...(param regs) | |
515 // rscratch1, rscratch2 (scratch regs) | |
516 void InterpreterGenerator::lock_method(void) { | |
517 // synchronize method | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
518 const Address access_flags(rbx, Method::access_flags_offset()); |
0 | 519 const Address monitor_block_top( |
520 rbp, | |
521 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
522 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
523 | |
524 #ifdef ASSERT | |
525 { | |
526 Label L; | |
527 __ movl(rax, access_flags); | |
528 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
529 __ jcc(Assembler::notZero, L); | |
530 __ stop("method doesn't need synchronization"); | |
531 __ bind(L); | |
532 } | |
533 #endif // ASSERT | |
534 | |
535 // get synchronization object | |
536 { | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4042
diff
changeset
|
537 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); |
0 | 538 Label done; |
539 __ movl(rax, access_flags); | |
540 __ testl(rax, JVM_ACC_STATIC); | |
541 // get receiver (assume this is frequent case) | |
304 | 542 __ movptr(rax, Address(r14, Interpreter::local_offset_in_bytes(0))); |
0 | 543 __ jcc(Assembler::zero, done); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
544 __ movptr(rax, Address(rbx, Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
545 __ movptr(rax, Address(rax, ConstMethod::constants_offset())); |
304 | 546 __ movptr(rax, Address(rax, |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
547 ConstantPool::pool_holder_offset_in_bytes())); |
304 | 548 __ movptr(rax, Address(rax, mirror_offset)); |
0 | 549 |
550 #ifdef ASSERT | |
551 { | |
552 Label L; | |
304 | 553 __ testptr(rax, rax); |
0 | 554 __ jcc(Assembler::notZero, L); |
555 __ stop("synchronization object is NULL"); | |
556 __ bind(L); | |
557 } | |
558 #endif // ASSERT | |
559 | |
560 __ bind(done); | |
561 } | |
562 | |
563 // add space for monitor & lock | |
304 | 564 __ subptr(rsp, entry_size); // add space for a monitor entry |
565 __ movptr(monitor_block_top, rsp); // set new monitor block top | |
0 | 566 // store object |
304 | 567 __ movptr(Address(rsp, BasicObjectLock::obj_offset_in_bytes()), rax); |
568 __ movptr(c_rarg1, rsp); // object address | |
0 | 569 __ lock_object(c_rarg1); |
570 } | |
571 | |
572 // Generate a fixed interpreter frame. This is identical setup for | |
573 // interpreted methods and for native methods hence the shared code. | |
574 // | |
575 // Args: | |
576 // rax: return address | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
577 // rbx: Method* |
0 | 578 // r14: pointer to locals |
579 // r13: sender sp | |
580 // rdx: cp cache | |
581 void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { | |
582 // initialize fixed part of activation frame | |
304 | 583 __ push(rax); // save return address |
0 | 584 __ enter(); // save old & set new rbp |
304 | 585 __ push(r13); // set sender sp |
586 __ push((int)NULL_WORD); // leave last_sp as null | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
587 __ movptr(r13, Address(rbx, Method::const_offset())); // get ConstMethod* |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
588 __ lea(r13, Address(r13, ConstMethod::codes_offset())); // get codebase |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
589 __ push(rbx); // save Method* |
0 | 590 if (ProfileInterpreter) { |
591 Label method_data_continue; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
592 __ movptr(rdx, Address(rbx, in_bytes(Method::method_data_offset()))); |
304 | 593 __ testptr(rdx, rdx); |
0 | 594 __ jcc(Assembler::zero, method_data_continue); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
595 __ addptr(rdx, in_bytes(MethodData::data_offset())); |
0 | 596 __ bind(method_data_continue); |
304 | 597 __ push(rdx); // set the mdp (method data pointer) |
0 | 598 } else { |
304 | 599 __ push(0); |
0 | 600 } |
601 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
602 __ movptr(rdx, Address(rbx, Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
603 __ movptr(rdx, Address(rdx, ConstMethod::constants_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
604 __ movptr(rdx, Address(rdx, ConstantPool::cache_offset_in_bytes())); |
304 | 605 __ push(rdx); // set constant pool cache |
606 __ push(r14); // set locals pointer | |
0 | 607 if (native_call) { |
304 | 608 __ push(0); // no bcp |
0 | 609 } else { |
304 | 610 __ push(r13); // set bcp |
0 | 611 } |
304 | 612 __ push(0); // reserve word for pointer to expression stack bottom |
613 __ movptr(Address(rsp, 0), rsp); // set expression stack bottom | |
0 | 614 } |
615 | |
616 // End of helpers | |
617 | |
304 | 618 // Various method entries |
619 //------------------------------------------------------------------------------------------------------------------------ | |
620 // | |
621 // | |
622 | |
623 // Call an accessor method (assuming it is resolved, otherwise drop | |
624 // into vanilla (slow path) entry | |
625 address InterpreterGenerator::generate_accessor_entry(void) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
626 // rbx: Method* |
304 | 627 |
628 // r13: senderSP must preserver for slow path, set SP to it on fast path | |
629 | |
630 address entry_point = __ pc(); | |
631 Label xreturn_path; | |
632 | |
633 // do fastpath for resolved accessor methods | |
634 if (UseFastAccessorMethods) { | |
635 // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites | |
636 // thereof; parameter size = 1 | |
637 // Note: We can only use this code if the getfield has been resolved | |
638 // and if we don't have a null-pointer exception => check for | |
639 // these conditions first and use slow path if necessary. | |
640 Label slow_path; | |
641 // If we need a safepoint check, generate full interpreter entry. | |
642 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), | |
643 SafepointSynchronize::_not_synchronized); | |
644 | |
645 __ jcc(Assembler::notEqual, slow_path); | |
646 // rbx: method | |
647 __ movptr(rax, Address(rsp, wordSize)); | |
648 | |
649 // check if local 0 != NULL and read field | |
650 __ testptr(rax, rax); | |
651 __ jcc(Assembler::zero, slow_path); | |
652 | |
653 // read first instruction word and extract bytecode @ 1 and index @ 2 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
654 __ movptr(rdx, Address(rbx, Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
655 __ movptr(rdi, Address(rdx, ConstMethod::constants_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
656 __ movl(rdx, Address(rdx, ConstMethod::codes_offset())); |
304 | 657 // Shift codes right to get the index on the right. |
658 // The bytecode fetched looks like <index><0xb4><0x2a> | |
659 __ shrl(rdx, 2 * BitsPerByte); | |
660 __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size()))); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
661 __ movptr(rdi, Address(rdi, ConstantPool::cache_offset_in_bytes())); |
304 | 662 |
663 // rax: local 0 | |
664 // rbx: method | |
665 // rdx: constant pool cache index | |
666 // rdi: constant pool cache | |
667 | |
668 // check if getfield has been resolved and read constant pool cache entry | |
669 // check the validity of the cache entry by testing whether _indices field | |
670 // contains Bytecode::_getfield in b1 byte. | |
671 assert(in_words(ConstantPoolCacheEntry::size()) == 4, | |
672 "adjust shift below"); | |
673 __ movl(rcx, | |
674 Address(rdi, | |
675 rdx, | |
676 Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
677 ConstantPoolCache::base_offset() + |
304 | 678 ConstantPoolCacheEntry::indices_offset())); |
679 __ shrl(rcx, 2 * BitsPerByte); | |
680 __ andl(rcx, 0xFF); | |
681 __ cmpl(rcx, Bytecodes::_getfield); | |
682 __ jcc(Assembler::notEqual, slow_path); | |
683 | |
684 // Note: constant pool entry is not valid before bytecode is resolved | |
685 __ movptr(rcx, | |
686 Address(rdi, | |
687 rdx, | |
688 Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
689 ConstantPoolCache::base_offset() + |
304 | 690 ConstantPoolCacheEntry::f2_offset())); |
691 // edx: flags | |
692 __ movl(rdx, | |
693 Address(rdi, | |
694 rdx, | |
695 Address::times_8, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
696 ConstantPoolCache::base_offset() + |
304 | 697 ConstantPoolCacheEntry::flags_offset())); |
698 | |
23614 | 699 Label notObj, notInt, notByte, notBool, notShort; |
304 | 700 const Address field_address(rax, rcx, Address::times_1); |
701 | |
702 // Need to differentiate between igetfield, agetfield, bgetfield etc. | |
703 // because they are different sizes. | |
704 // Use the type from the constant pool cache | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
705 __ shrl(rdx, ConstantPoolCacheEntry::tos_state_shift); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
706 // Make sure we don't need to mask edx after the above shift |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
707 ConstantPoolCacheEntry::verify_tos_state_shift(); |
304 | 708 |
709 __ cmpl(rdx, atos); | |
710 __ jcc(Assembler::notEqual, notObj); | |
711 // atos | |
712 __ load_heap_oop(rax, field_address); | |
713 __ jmp(xreturn_path); | |
714 | |
715 __ bind(notObj); | |
716 __ cmpl(rdx, itos); | |
717 __ jcc(Assembler::notEqual, notInt); | |
718 // itos | |
719 __ movl(rax, field_address); | |
720 __ jmp(xreturn_path); | |
721 | |
722 __ bind(notInt); | |
723 __ cmpl(rdx, btos); | |
724 __ jcc(Assembler::notEqual, notByte); | |
725 // btos | |
726 __ load_signed_byte(rax, field_address); | |
727 __ jmp(xreturn_path); | |
728 | |
729 __ bind(notByte); | |
23614 | 730 __ cmpl(rdx, ztos); |
731 __ jcc(Assembler::notEqual, notBool); | |
732 // ztos | |
733 __ load_signed_byte(rax, field_address); | |
734 __ jmp(xreturn_path); | |
735 | |
736 __ bind(notBool); | |
304 | 737 __ cmpl(rdx, stos); |
738 __ jcc(Assembler::notEqual, notShort); | |
739 // stos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
740 __ load_signed_short(rax, field_address); |
304 | 741 __ jmp(xreturn_path); |
742 | |
743 __ bind(notShort); | |
744 #ifdef ASSERT | |
745 Label okay; | |
746 __ cmpl(rdx, ctos); | |
747 __ jcc(Assembler::equal, okay); | |
748 __ stop("what type is this?"); | |
749 __ bind(okay); | |
750 #endif | |
751 // ctos | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
752 __ load_unsigned_short(rax, field_address); |
304 | 753 |
754 __ bind(xreturn_path); | |
755 | |
756 // _ireturn/_areturn | |
757 __ pop(rdi); | |
758 __ mov(rsp, r13); | |
759 __ jmp(rdi); | |
760 __ ret(0); | |
761 | |
762 // generate a vanilla interpreter entry as the slow path | |
763 __ bind(slow_path); | |
764 (void) generate_normal_entry(false); | |
765 } else { | |
766 (void) generate_normal_entry(false); | |
767 } | |
768 | |
769 return entry_point; | |
770 } | |
771 | |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
772 // Method entry for java.lang.ref.Reference.get. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
773 address InterpreterGenerator::generate_Reference_get_entry(void) { |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7402
diff
changeset
|
774 #if INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
775 // Code: _aload_0, _getfield, _areturn |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
776 // parameter size = 1 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
777 // |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
778 // The code that gets generated by this routine is split into 2 parts: |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
779 // 1. The "intrinsified" code for G1 (or any SATB based GC), |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
780 // 2. The slow path - which is an expansion of the regular method entry. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
781 // |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
782 // Notes:- |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
783 // * In the G1 code we do not check whether we need to block for |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
784 // a safepoint. If G1 is enabled then we must execute the specialized |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
785 // code for Reference.get (except when the Reference object is null) |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
786 // so that we can log the value in the referent field with an SATB |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
787 // update buffer. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
788 // If the code for the getfield template is modified so that the |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
789 // G1 pre-barrier code is executed when the current method is |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
790 // Reference.get() then going through the normal method entry |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
791 // will be fine. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
792 // * The G1 code can, however, check the receiver object (the instance |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
793 // of java.lang.Reference) and jump to the slow path if null. If the |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
794 // Reference object is null then we obviously cannot fetch the referent |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
795 // and so we don't need to call the G1 pre-barrier. Thus we can use the |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
796 // regular method entry code to generate the NPE. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
797 // |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
798 // This code is based on generate_accessor_enty. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
799 // |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
800 // rbx: Method* |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
801 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
802 // r13: senderSP must preserve for slow path, set SP to it on fast path |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
803 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
804 address entry = __ pc(); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
805 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
806 const int referent_offset = java_lang_ref_Reference::referent_offset; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
807 guarantee(referent_offset > 0, "referent offset not initialized"); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
808 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
809 if (UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
810 Label slow_path; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
811 // rbx: method |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
812 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
813 // Check if local 0 != NULL |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
814 // If the receiver is null then it is OK to jump to the slow path. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
815 __ movptr(rax, Address(rsp, wordSize)); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
816 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
817 __ testptr(rax, rax); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
818 __ jcc(Assembler::zero, slow_path); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
819 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
820 // rax: local 0 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
821 // rbx: method (but can be used as scratch now) |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
822 // rdx: scratch |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
823 // rdi: scratch |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
824 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
825 // Generate the G1 pre-barrier code to log the value of |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
826 // the referent field in an SATB buffer. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
827 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
828 // Load the value of the referent field. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
829 const Address field_address(rax, referent_offset); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
830 __ load_heap_oop(rax, field_address); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
831 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
832 // Generate the G1 pre-barrier code to log the value of |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
833 // the referent field in an SATB buffer. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
834 __ g1_write_barrier_pre(noreg /* obj */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
835 rax /* pre_val */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
836 r15_thread /* thread */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
837 rbx /* tmp */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
838 true /* tosca_live */, |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
839 true /* expand_call */); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
840 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
841 // _areturn |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
842 __ pop(rdi); // get return address |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
843 __ mov(rsp, r13); // set sp to sender sp |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
844 __ jmp(rdi); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
845 __ ret(0); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
846 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
847 // generate a vanilla interpreter entry as the slow path |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
848 __ bind(slow_path); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
849 (void) generate_normal_entry(false); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
850 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
851 return entry; |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
852 } |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7402
diff
changeset
|
853 #endif // INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
854 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
855 // If G1 is not enabled then attempt to go through the accessor entry point |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
856 // Reference.get is an accessor |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
857 return generate_accessor_entry(); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
858 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
859 |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
860 /** |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
861 * Method entry for static native methods: |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
862 * int java.util.zip.CRC32.update(int crc, int b) |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
863 */ |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
864 address InterpreterGenerator::generate_CRC32_update_entry() { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
865 if (UseCRC32Intrinsics) { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
866 address entry = __ pc(); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
867 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
868 // rbx,: Method* |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
869 // r13: senderSP must preserved for slow path, set SP to it on fast path |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
870 // c_rarg0: scratch (rdi on non-Win64, rcx on Win64) |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
871 // c_rarg1: scratch (rsi on non-Win64, rdx on Win64) |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
872 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
873 Label slow_path; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
874 // If we need a safepoint check, generate full interpreter entry. |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
875 ExternalAddress state(SafepointSynchronize::address_of_state()); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
876 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
877 SafepointSynchronize::_not_synchronized); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
878 __ jcc(Assembler::notEqual, slow_path); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
879 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
880 // We don't generate local frame and don't align stack because |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
881 // we call stub code and there is no safepoint on this path. |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
882 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
883 // Load parameters |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
884 const Register crc = rax; // crc |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
885 const Register val = c_rarg0; // source java byte value |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
886 const Register tbl = c_rarg1; // scratch |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
887 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
888 // Arguments are reversed on java expression stack |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
889 __ movl(val, Address(rsp, wordSize)); // byte value |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
890 __ movl(crc, Address(rsp, 2*wordSize)); // Initial CRC |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
891 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
892 __ lea(tbl, ExternalAddress(StubRoutines::crc_table_addr())); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
893 __ notl(crc); // ~crc |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
894 __ update_byte_crc32(crc, val, tbl); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
895 __ notl(crc); // ~crc |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
896 // result in rax |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
897 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
898 // _areturn |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
899 __ pop(rdi); // get return address |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
900 __ mov(rsp, r13); // set sp to sender sp |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
901 __ jmp(rdi); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
902 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
903 // generate a vanilla native entry as the slow path |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
904 __ bind(slow_path); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
905 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
906 (void) generate_native_entry(false); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
907 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
908 return entry; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
909 } |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
910 return generate_native_entry(false); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
911 } |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
912 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
913 /** |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
914 * Method entry for static native methods: |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
915 * int java.util.zip.CRC32.updateBytes(int crc, byte[] b, int off, int len) |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
916 * int java.util.zip.CRC32.updateByteBuffer(int crc, long buf, int off, int len) |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
917 */ |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
918 address InterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractInterpreter::MethodKind kind) { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
919 if (UseCRC32Intrinsics) { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
920 address entry = __ pc(); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
921 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
922 // rbx,: Method* |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
923 // r13: senderSP must preserved for slow path, set SP to it on fast path |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
924 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
925 Label slow_path; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
926 // If we need a safepoint check, generate full interpreter entry. |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
927 ExternalAddress state(SafepointSynchronize::address_of_state()); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
928 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
929 SafepointSynchronize::_not_synchronized); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
930 __ jcc(Assembler::notEqual, slow_path); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
931 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
932 // We don't generate local frame and don't align stack because |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
933 // we call stub code and there is no safepoint on this path. |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
934 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
935 // Load parameters |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
936 const Register crc = c_rarg0; // crc |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
937 const Register buf = c_rarg1; // source java byte array address |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
938 const Register len = c_rarg2; // length |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
939 const Register off = len; // offset (never overlaps with 'len') |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
940 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
941 // Arguments are reversed on java expression stack |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
942 // Calculate address of start element |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
943 if (kind == Interpreter::java_util_zip_CRC32_updateByteBuffer) { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
944 __ movptr(buf, Address(rsp, 3*wordSize)); // long buf |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
945 __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
946 __ addq(buf, off); // + offset |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
947 __ movl(crc, Address(rsp, 5*wordSize)); // Initial CRC |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
948 } else { |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
949 __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
950 __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
951 __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
952 __ addq(buf, off); // + offset |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
953 __ movl(crc, Address(rsp, 4*wordSize)); // Initial CRC |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
954 } |
12070
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
955 // Can now load 'len' since we're finished with 'off' |
afbe18ae0905
8022441: Bad code generated for certain interpreted CRC intrinsics, 2 cases
bharadwaj
parents:
11080
diff
changeset
|
956 __ movl(len, Address(rsp, wordSize)); // Length |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
957 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
958 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, StubRoutines::updateBytesCRC32()), crc, buf, len); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
959 // result in rax |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
960 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
961 // _areturn |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
962 __ pop(rdi); // get return address |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
963 __ mov(rsp, r13); // set sp to sender sp |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
964 __ jmp(rdi); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
965 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
966 // generate a vanilla native entry as the slow path |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
967 __ bind(slow_path); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
968 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
969 (void) generate_native_entry(false); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
970 |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
971 return entry; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
972 } |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
973 return generate_native_entry(false); |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
974 } |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
975 |
0 | 976 // Interpreter stub for calling a native method. (asm interpreter) |
977 // This sets up a somewhat different looking stack for calling the | |
978 // native method than the typical interpreter frame setup. | |
979 address InterpreterGenerator::generate_native_entry(bool synchronized) { | |
980 // determine code generation flags | |
981 bool inc_counter = UseCompiler || CountCompiledCalls; | |
982 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
983 // rbx: Method* |
0 | 984 // r13: sender sp |
985 | |
986 address entry_point = __ pc(); | |
987 | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
988 const Address constMethod (rbx, Method::const_offset()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
989 const Address access_flags (rbx, Method::access_flags_offset()); |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
990 const Address size_of_parameters(rcx, ConstMethod:: |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
991 size_of_parameters_offset()); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
992 |
0 | 993 |
994 // get parameter size (always needed) | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
995 __ movptr(rcx, constMethod); |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
996 __ load_unsigned_short(rcx, size_of_parameters); |
0 | 997 |
998 // native calls don't need the stack size check since they have no | |
999 // expression stack and the arguments are already on the stack and | |
1000 // we only add a handful of words to the stack | |
1001 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1002 // rbx: Method* |
0 | 1003 // rcx: size of parameters |
1004 // r13: sender sp | |
304 | 1005 __ pop(rax); // get return address |
0 | 1006 |
1007 // for natives the size of locals is zero | |
1008 | |
1009 // compute beginning of parameters (r14) | |
304 | 1010 __ lea(r14, Address(rsp, rcx, Address::times_8, -wordSize)); |
0 | 1011 |
1012 // add 2 zero-initialized slots for native calls | |
1013 // initialize result_handler slot | |
304 | 1014 __ push((int) NULL_WORD); |
0 | 1015 // slot for oop temp |
1016 // (static native method holder mirror/jni oop result) | |
304 | 1017 __ push((int) NULL_WORD); |
0 | 1018 |
1019 // initialize fixed part of activation frame | |
1020 generate_fixed_frame(true); | |
1021 | |
1022 // make sure method is native & not abstract | |
1023 #ifdef ASSERT | |
1024 __ movl(rax, access_flags); | |
1025 { | |
1026 Label L; | |
1027 __ testl(rax, JVM_ACC_NATIVE); | |
1028 __ jcc(Assembler::notZero, L); | |
1029 __ stop("tried to execute non-native method as native"); | |
1030 __ bind(L); | |
1031 } | |
1032 { | |
1033 Label L; | |
1034 __ testl(rax, JVM_ACC_ABSTRACT); | |
1035 __ jcc(Assembler::zero, L); | |
1036 __ stop("tried to execute abstract method in interpreter"); | |
1037 __ bind(L); | |
1038 } | |
1039 #endif | |
1040 | |
1041 // Since at this point in the method invocation the exception handler | |
1042 // would try to exit the monitor of synchronized methods which hasn't | |
1043 // been entered yet, we set the thread local variable | |
1044 // _do_not_unlock_if_synchronized to true. The remove_activation will | |
1045 // check this flag. | |
1046 | |
1047 const Address do_not_unlock_if_synchronized(r15_thread, | |
1048 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
1049 __ movbool(do_not_unlock_if_synchronized, true); | |
1050 | |
1051 // increment invocation count & check for overflow | |
1052 Label invocation_counter_overflow; | |
1053 if (inc_counter) { | |
1054 generate_counter_incr(&invocation_counter_overflow, NULL, NULL); | |
1055 } | |
1056 | |
1057 Label continue_after_compile; | |
1058 __ bind(continue_after_compile); | |
1059 | |
1060 bang_stack_shadow_pages(true); | |
1061 | |
1062 // reset the _do_not_unlock_if_synchronized flag | |
1063 __ movbool(do_not_unlock_if_synchronized, false); | |
1064 | |
1065 // check for synchronized methods | |
1066 // Must happen AFTER invocation_counter check and stack overflow check, | |
1067 // so method is not locked if overflows. | |
1068 if (synchronized) { | |
1069 lock_method(); | |
1070 } else { | |
1071 // no synchronization necessary | |
1072 #ifdef ASSERT | |
1073 { | |
1074 Label L; | |
1075 __ movl(rax, access_flags); | |
1076 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
1077 __ jcc(Assembler::zero, L); | |
1078 __ stop("method needs synchronization"); | |
1079 __ bind(L); | |
1080 } | |
1081 #endif | |
1082 } | |
1083 | |
1084 // start execution | |
1085 #ifdef ASSERT | |
1086 { | |
1087 Label L; | |
1088 const Address monitor_block_top(rbp, | |
1089 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
304 | 1090 __ movptr(rax, monitor_block_top); |
1091 __ cmpptr(rax, rsp); | |
0 | 1092 __ jcc(Assembler::equal, L); |
1093 __ stop("broken stack frame setup in interpreter"); | |
1094 __ bind(L); | |
1095 } | |
1096 #endif | |
1097 | |
1098 // jvmti support | |
1099 __ notify_method_entry(); | |
1100 | |
1101 // work registers | |
1102 const Register method = rbx; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1103 const Register t = r11; |
0 | 1104 |
1105 // allocate space for parameters | |
1106 __ get_method(method); | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1107 __ movptr(t, Address(method, Method::const_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1108 __ load_unsigned_short(t, Address(t, ConstMethod::size_of_parameters_offset())); |
1506 | 1109 __ shll(t, Interpreter::logStackElementSize); |
0 | 1110 |
304 | 1111 __ subptr(rsp, t); |
1112 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows | |
605 | 1113 __ andptr(rsp, -16); // must be 16 byte boundary (see amd64 ABI) |
0 | 1114 |
1115 // get signature handler | |
1116 { | |
1117 Label L; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1118 __ movptr(t, Address(method, Method::signature_handler_offset())); |
304 | 1119 __ testptr(t, t); |
0 | 1120 __ jcc(Assembler::notZero, L); |
1121 __ call_VM(noreg, | |
1122 CAST_FROM_FN_PTR(address, | |
1123 InterpreterRuntime::prepare_native_call), | |
1124 method); | |
1125 __ get_method(method); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1126 __ movptr(t, Address(method, Method::signature_handler_offset())); |
0 | 1127 __ bind(L); |
1128 } | |
1129 | |
1130 // call signature handler | |
1131 assert(InterpreterRuntime::SignatureHandlerGenerator::from() == r14, | |
1132 "adjust this code"); | |
1133 assert(InterpreterRuntime::SignatureHandlerGenerator::to() == rsp, | |
1134 "adjust this code"); | |
1135 assert(InterpreterRuntime::SignatureHandlerGenerator::temp() == rscratch1, | |
1136 "adjust this code"); | |
1137 | |
1138 // The generated handlers do not touch RBX (the method oop). | |
1139 // However, large signatures cannot be cached and are generated | |
1140 // each time here. The slow-path generator can do a GC on return, | |
1141 // so we must reload it after the call. | |
1142 __ call(t); | |
1143 __ get_method(method); // slow path can do a GC, reload RBX | |
1144 | |
1145 | |
1146 // result handler is in rax | |
1147 // set result handler | |
304 | 1148 __ movptr(Address(rbp, |
1149 (frame::interpreter_frame_result_handler_offset) * wordSize), | |
1150 rax); | |
0 | 1151 |
1152 // pass mirror handle if static call | |
1153 { | |
1154 Label L; | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
4042
diff
changeset
|
1155 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1156 __ movl(t, Address(method, Method::access_flags_offset())); |
0 | 1157 __ testl(t, JVM_ACC_STATIC); |
1158 __ jcc(Assembler::zero, L); | |
1159 // get mirror | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1160 __ movptr(t, Address(method, Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1161 __ movptr(t, Address(t, ConstMethod::constants_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1162 __ movptr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes())); |
304 | 1163 __ movptr(t, Address(t, mirror_offset)); |
0 | 1164 // copy mirror into activation frame |
304 | 1165 __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize), |
0 | 1166 t); |
1167 // pass handle to mirror | |
304 | 1168 __ lea(c_rarg1, |
1169 Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize)); | |
0 | 1170 __ bind(L); |
1171 } | |
1172 | |
1173 // get native function entry point | |
1174 { | |
1175 Label L; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1176 __ movptr(rax, Address(method, Method::native_function_offset())); |
0 | 1177 ExternalAddress unsatisfied(SharedRuntime::native_method_throw_unsatisfied_link_error_entry()); |
1178 __ movptr(rscratch2, unsatisfied.addr()); | |
304 | 1179 __ cmpptr(rax, rscratch2); |
0 | 1180 __ jcc(Assembler::notEqual, L); |
1181 __ call_VM(noreg, | |
1182 CAST_FROM_FN_PTR(address, | |
1183 InterpreterRuntime::prepare_native_call), | |
1184 method); | |
1185 __ get_method(method); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1186 __ movptr(rax, Address(method, Method::native_function_offset())); |
0 | 1187 __ bind(L); |
1188 } | |
1189 | |
1190 // pass JNIEnv | |
304 | 1191 __ lea(c_rarg0, Address(r15_thread, JavaThread::jni_environment_offset())); |
0 | 1192 |
1193 // It is enough that the pc() points into the right code | |
1194 // segment. It does not have to be the correct return pc. | |
1195 __ set_last_Java_frame(rsp, rbp, (address) __ pc()); | |
1196 | |
1197 // change thread state | |
1198 #ifdef ASSERT | |
1199 { | |
1200 Label L; | |
1201 __ movl(t, Address(r15_thread, JavaThread::thread_state_offset())); | |
1202 __ cmpl(t, _thread_in_Java); | |
1203 __ jcc(Assembler::equal, L); | |
1204 __ stop("Wrong thread state in native stub"); | |
1205 __ bind(L); | |
1206 } | |
1207 #endif | |
1208 | |
1209 // Change state to native | |
1210 | |
1211 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), | |
1212 _thread_in_native); | |
1213 | |
1214 // Call the native method. | |
1215 __ call(rax); | |
1216 // result potentially in rax or xmm0 | |
1217 | |
8873
e961c11b85fe
8011102: Clear AVX registers after return from JNI call
kvn
parents:
8727
diff
changeset
|
1218 // Verify or restore cpu control state after JNI call |
e961c11b85fe
8011102: Clear AVX registers after return from JNI call
kvn
parents:
8727
diff
changeset
|
1219 __ restore_cpu_control_state_after_jni(); |
0 | 1220 |
1221 // NOTE: The order of these pushes is known to frame::interpreter_frame_result | |
1222 // in order to extract the result of a method call. If the order of these | |
1223 // pushes change or anything else is added to the stack then the code in | |
1224 // interpreter_frame_result must also change. | |
1225 | |
1226 __ push(dtos); | |
1227 __ push(ltos); | |
1228 | |
1229 // change thread state | |
1230 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), | |
1231 _thread_in_native_trans); | |
1232 | |
1233 if (os::is_MP()) { | |
1234 if (UseMembar) { | |
1235 // Force this write out before the read below | |
1236 __ membar(Assembler::Membar_mask_bits( | |
1237 Assembler::LoadLoad | Assembler::LoadStore | | |
1238 Assembler::StoreLoad | Assembler::StoreStore)); | |
1239 } else { | |
1240 // Write serialization page so VM thread can do a pseudo remote membar. | |
1241 // We use the current thread pointer to calculate a thread specific | |
1242 // offset to write to within the page. This minimizes bus traffic | |
1243 // due to cache line collision. | |
1244 __ serialize_memory(r15_thread, rscratch2); | |
1245 } | |
1246 } | |
1247 | |
1248 // check for safepoint operation in progress and/or pending suspend requests | |
1249 { | |
1250 Label Continue; | |
1251 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), | |
1252 SafepointSynchronize::_not_synchronized); | |
1253 | |
1254 Label L; | |
1255 __ jcc(Assembler::notEqual, L); | |
1256 __ cmpl(Address(r15_thread, JavaThread::suspend_flags_offset()), 0); | |
1257 __ jcc(Assembler::equal, Continue); | |
1258 __ bind(L); | |
1259 | |
1260 // Don't use call_VM as it will see a possible pending exception | |
1261 // and forward it and never return here preventing us from | |
1262 // clearing _last_native_pc down below. Also can't use | |
1263 // call_VM_leaf either as it will check to see if r13 & r14 are | |
1264 // preserved and correspond to the bcp/locals pointers. So we do a | |
1265 // runtime call by hand. | |
1266 // | |
304 | 1267 __ mov(c_rarg0, r15_thread); |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
1268 __ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
304 | 1269 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
1270 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1271 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans))); |
304 | 1272 __ mov(rsp, r12); // restore sp |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1273 __ reinit_heapbase(); |
0 | 1274 __ bind(Continue); |
1275 } | |
1276 | |
1277 // change thread state | |
1278 __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_Java); | |
1279 | |
1280 // reset_last_Java_frame | |
1281 __ reset_last_Java_frame(true, true); | |
1282 | |
1283 // reset handle block | |
304 | 1284 __ movptr(t, Address(r15_thread, JavaThread::active_handles_offset())); |
17850
2100bf712e2a
8039146: Fix 64-bit store to int JNIHandleBlock::_top
goetz
parents:
13010
diff
changeset
|
1285 __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); |
0 | 1286 |
1287 // If result is an oop unbox and store it in frame where gc will see it | |
1288 // and result handler will pick it up | |
1289 | |
1290 { | |
1291 Label no_oop, store_result; | |
1292 __ lea(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT))); | |
304 | 1293 __ cmpptr(t, Address(rbp, frame::interpreter_frame_result_handler_offset*wordSize)); |
0 | 1294 __ jcc(Assembler::notEqual, no_oop); |
1295 // retrieve result | |
1296 __ pop(ltos); | |
304 | 1297 __ testptr(rax, rax); |
0 | 1298 __ jcc(Assembler::zero, store_result); |
304 | 1299 __ movptr(rax, Address(rax, 0)); |
0 | 1300 __ bind(store_result); |
304 | 1301 __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset*wordSize), rax); |
0 | 1302 // keep stack depth as expected by pushing oop which will eventually be discarde |
1303 __ push(ltos); | |
1304 __ bind(no_oop); | |
1305 } | |
1306 | |
1307 | |
1308 { | |
1309 Label no_reguard; | |
1310 __ cmpl(Address(r15_thread, JavaThread::stack_guard_state_offset()), | |
1311 JavaThread::stack_guard_yellow_disabled); | |
1312 __ jcc(Assembler::notEqual, no_reguard); | |
1313 | |
304 | 1314 __ pusha(); // XXX only save smashed registers |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
1315 __ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
304 | 1316 __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows |
1317 __ andptr(rsp, -16); // align stack as required by ABI | |
0 | 1318 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages))); |
304 | 1319 __ mov(rsp, r12); // restore sp |
1320 __ popa(); // XXX only restore smashed registers | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1321 __ reinit_heapbase(); |
0 | 1322 |
1323 __ bind(no_reguard); | |
1324 } | |
1325 | |
1326 | |
1327 // The method register is junk from after the thread_in_native transition | |
1328 // until here. Also can't call_VM until the bcp has been | |
1329 // restored. Need bcp for throwing exception below so get it now. | |
1330 __ get_method(method); | |
1331 | |
1332 // restore r13 to have legal interpreter frame, i.e., bci == 0 <=> | |
1333 // r13 == code_base() | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1334 __ movptr(r13, Address(method, Method::const_offset())); // get ConstMethod* |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1335 __ lea(r13, Address(r13, ConstMethod::codes_offset())); // get codebase |
0 | 1336 // handle exceptions (exception handling will handle unlocking!) |
1337 { | |
1338 Label L; | |
304 | 1339 __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t) NULL_WORD); |
0 | 1340 __ jcc(Assembler::zero, L); |
1341 // Note: At some point we may want to unify this with the code | |
1342 // used in call_VM_base(); i.e., we should use the | |
1343 // StubRoutines::forward_exception code. For now this doesn't work | |
1344 // here because the rsp is not correctly set at this point. | |
1345 __ MacroAssembler::call_VM(noreg, | |
1346 CAST_FROM_FN_PTR(address, | |
1347 InterpreterRuntime::throw_pending_exception)); | |
1348 __ should_not_reach_here(); | |
1349 __ bind(L); | |
1350 } | |
1351 | |
1352 // do unlocking if necessary | |
1353 { | |
1354 Label L; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1355 __ movl(t, Address(method, Method::access_flags_offset())); |
0 | 1356 __ testl(t, JVM_ACC_SYNCHRONIZED); |
1357 __ jcc(Assembler::zero, L); | |
1358 // the code below should be shared with interpreter macro | |
1359 // assembler implementation | |
1360 { | |
1361 Label unlock; | |
1362 // BasicObjectLock will be first in list, since this is a | |
1363 // synchronized method. However, need to check that the object | |
1364 // has not been unlocked by an explicit monitorexit bytecode. | |
1365 const Address monitor(rbp, | |
1366 (intptr_t)(frame::interpreter_frame_initial_sp_offset * | |
1367 wordSize - sizeof(BasicObjectLock))); | |
1368 | |
1369 // monitor expect in c_rarg1 for slow unlock path | |
304 | 1370 __ lea(c_rarg1, monitor); // address of first monitor |
0 | 1371 |
304 | 1372 __ movptr(t, Address(c_rarg1, BasicObjectLock::obj_offset_in_bytes())); |
1373 __ testptr(t, t); | |
0 | 1374 __ jcc(Assembler::notZero, unlock); |
1375 | |
1376 // Entry already unlocked, need to throw exception | |
1377 __ MacroAssembler::call_VM(noreg, | |
1378 CAST_FROM_FN_PTR(address, | |
1379 InterpreterRuntime::throw_illegal_monitor_state_exception)); | |
1380 __ should_not_reach_here(); | |
1381 | |
1382 __ bind(unlock); | |
1383 __ unlock_object(c_rarg1); | |
1384 } | |
1385 __ bind(L); | |
1386 } | |
1387 | |
1388 // jvmti support | |
1389 // Note: This must happen _after_ handling/throwing any exceptions since | |
1390 // the exception handler code notifies the runtime of method exits | |
1391 // too. If this happens before, method entry/exit notifications are | |
1392 // not properly paired (was bug - gri 11/22/99). | |
1393 __ notify_method_exit(vtos, InterpreterMacroAssembler::NotifyJVMTI); | |
1394 | |
1395 // restore potential result in edx:eax, call result handler to | |
1396 // restore potential result in ST0 & handle result | |
1397 | |
1398 __ pop(ltos); | |
1399 __ pop(dtos); | |
1400 | |
304 | 1401 __ movptr(t, Address(rbp, |
1402 (frame::interpreter_frame_result_handler_offset) * wordSize)); | |
0 | 1403 __ call(t); |
1404 | |
1405 // remove activation | |
304 | 1406 __ movptr(t, Address(rbp, |
1407 frame::interpreter_frame_sender_sp_offset * | |
1408 wordSize)); // get sender sp | |
0 | 1409 __ leave(); // remove frame anchor |
304 | 1410 __ pop(rdi); // get return address |
1411 __ mov(rsp, t); // set sp to sender sp | |
0 | 1412 __ jmp(rdi); |
1413 | |
1414 if (inc_counter) { | |
1415 // Handle overflow of counter and compile method | |
1416 __ bind(invocation_counter_overflow); | |
1417 generate_counter_overflow(&continue_after_compile); | |
1418 } | |
1419 | |
1420 return entry_point; | |
1421 } | |
1422 | |
1423 // | |
1424 // Generic interpreted method entry to (asm) interpreter | |
1425 // | |
1426 address InterpreterGenerator::generate_normal_entry(bool synchronized) { | |
1427 // determine code generation flags | |
1428 bool inc_counter = UseCompiler || CountCompiledCalls; | |
1429 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1430 // ebx: Method* |
0 | 1431 // r13: sender sp |
1432 address entry_point = __ pc(); | |
1433 | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1434 const Address constMethod(rbx, Method::const_offset()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1435 const Address access_flags(rbx, Method::access_flags_offset()); |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1436 const Address size_of_parameters(rdx, |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1437 ConstMethod::size_of_parameters_offset()); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1438 const Address size_of_locals(rdx, ConstMethod::size_of_locals_offset()); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1439 |
0 | 1440 |
1441 // get parameter size (always needed) | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1442 __ movptr(rdx, constMethod); |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
1443 __ load_unsigned_short(rcx, size_of_parameters); |
0 | 1444 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1445 // rbx: Method* |
0 | 1446 // rcx: size of parameters |
1447 // r13: sender_sp (could differ from sp+wordSize if we were called via c2i ) | |
1448 | |
622
56aae7be60d4
6812678: macro assembler needs delayed binding of a few constants (for 6655638)
jrose
parents:
605
diff
changeset
|
1449 __ load_unsigned_short(rdx, size_of_locals); // get size of locals in words |
0 | 1450 __ subl(rdx, rcx); // rdx = no. of additional locals |
1451 | |
1452 // YYY | |
1453 // __ incrementl(rdx); | |
1454 // __ andl(rdx, -2); | |
1455 | |
1456 // see if we've got enough room on the stack for locals plus overhead. | |
1457 generate_stack_overflow_check(); | |
1458 | |
1459 // get return address | |
304 | 1460 __ pop(rax); |
0 | 1461 |
1462 // compute beginning of parameters (r14) | |
304 | 1463 __ lea(r14, Address(rsp, rcx, Address::times_8, -wordSize)); |
0 | 1464 |
1465 // rdx - # of additional locals | |
1466 // allocate space for locals | |
1467 // explicitly initialize locals | |
1468 { | |
1469 Label exit, loop; | |
1470 __ testl(rdx, rdx); | |
1471 __ jcc(Assembler::lessEqual, exit); // do nothing if rdx <= 0 | |
1472 __ bind(loop); | |
304 | 1473 __ push((int) NULL_WORD); // initialize local variables |
0 | 1474 __ decrementl(rdx); // until everything initialized |
1475 __ jcc(Assembler::greater, loop); | |
1476 __ bind(exit); | |
1477 } | |
1478 | |
1479 // initialize fixed part of activation frame | |
1480 generate_fixed_frame(false); | |
1481 | |
1482 // make sure method is not native & not abstract | |
1483 #ifdef ASSERT | |
1484 __ movl(rax, access_flags); | |
1485 { | |
1486 Label L; | |
1487 __ testl(rax, JVM_ACC_NATIVE); | |
1488 __ jcc(Assembler::zero, L); | |
1489 __ stop("tried to execute native method as non-native"); | |
1490 __ bind(L); | |
1491 } | |
1492 { | |
1493 Label L; | |
1494 __ testl(rax, JVM_ACC_ABSTRACT); | |
1495 __ jcc(Assembler::zero, L); | |
1496 __ stop("tried to execute abstract method in interpreter"); | |
1497 __ bind(L); | |
1498 } | |
1499 #endif | |
1500 | |
1501 // Since at this point in the method invocation the exception | |
1502 // handler would try to exit the monitor of synchronized methods | |
1503 // which hasn't been entered yet, we set the thread local variable | |
1504 // _do_not_unlock_if_synchronized to true. The remove_activation | |
1505 // will check this flag. | |
1506 | |
1507 const Address do_not_unlock_if_synchronized(r15_thread, | |
1508 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
1509 __ movbool(do_not_unlock_if_synchronized, true); | |
1510 | |
12962
5ccbab1c69f3
8026251: New type profiling points: parameters to methods
roland
parents:
12882
diff
changeset
|
1511 __ profile_parameters_type(rax, rcx, rdx); |
0 | 1512 // increment invocation count & check for overflow |
1513 Label invocation_counter_overflow; | |
1514 Label profile_method; | |
1515 Label profile_method_continue; | |
1516 if (inc_counter) { | |
1517 generate_counter_incr(&invocation_counter_overflow, | |
1518 &profile_method, | |
1519 &profile_method_continue); | |
1520 if (ProfileInterpreter) { | |
1521 __ bind(profile_method_continue); | |
1522 } | |
1523 } | |
1524 | |
1525 Label continue_after_compile; | |
1526 __ bind(continue_after_compile); | |
1527 | |
1528 // check for synchronized interpreted methods | |
1529 bang_stack_shadow_pages(false); | |
1530 | |
1531 // reset the _do_not_unlock_if_synchronized flag | |
1532 __ movbool(do_not_unlock_if_synchronized, false); | |
1533 | |
1534 // check for synchronized methods | |
1535 // Must happen AFTER invocation_counter check and stack overflow check, | |
1536 // so method is not locked if overflows. | |
1537 if (synchronized) { | |
1538 // Allocate monitor and lock method | |
1539 lock_method(); | |
1540 } else { | |
1541 // no synchronization necessary | |
1542 #ifdef ASSERT | |
1543 { | |
1544 Label L; | |
1545 __ movl(rax, access_flags); | |
1546 __ testl(rax, JVM_ACC_SYNCHRONIZED); | |
1547 __ jcc(Assembler::zero, L); | |
1548 __ stop("method needs synchronization"); | |
1549 __ bind(L); | |
1550 } | |
1551 #endif | |
1552 } | |
1553 | |
1554 // start execution | |
1555 #ifdef ASSERT | |
1556 { | |
1557 Label L; | |
1558 const Address monitor_block_top (rbp, | |
1559 frame::interpreter_frame_monitor_block_top_offset * wordSize); | |
304 | 1560 __ movptr(rax, monitor_block_top); |
1561 __ cmpptr(rax, rsp); | |
0 | 1562 __ jcc(Assembler::equal, L); |
1563 __ stop("broken stack frame setup in interpreter"); | |
1564 __ bind(L); | |
1565 } | |
1566 #endif | |
1567 | |
1568 // jvmti support | |
1569 __ notify_method_entry(); | |
1570 | |
1571 __ dispatch_next(vtos); | |
1572 | |
1573 // invocation counter overflow | |
1574 if (inc_counter) { | |
1575 if (ProfileInterpreter) { | |
1576 // We have decided to profile this method in the interpreter | |
1577 __ bind(profile_method); | |
2118
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1976
diff
changeset
|
1578 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method)); |
dd031b2226de
4930919: race condition in MDO creation at back branch locations
iveresov
parents:
1976
diff
changeset
|
1579 __ set_method_data_pointer_for_bcp(); |
2141
b599a4c6c2df
7012766: assert(false) failed: DEBUG MESSAGE in MacroAssembler::debug32
iveresov
parents:
2118
diff
changeset
|
1580 __ get_method(rbx); |
0 | 1581 __ jmp(profile_method_continue); |
1582 } | |
1583 // Handle overflow of counter and compile method | |
1584 __ bind(invocation_counter_overflow); | |
1585 generate_counter_overflow(&continue_after_compile); | |
1586 } | |
1587 | |
1588 return entry_point; | |
1589 } | |
1590 | |
1591 // Entry points | |
1592 // | |
1593 // Here we generate the various kind of entries into the interpreter. | |
1594 // The two main entry type are generic bytecode methods and native | |
1595 // call method. These both come in synchronized and non-synchronized | |
1596 // versions but the frame layout they create is very similar. The | |
1597 // other method entry types are really just special purpose entries | |
1598 // that are really entry and interpretation all in one. These are for | |
1599 // trivial methods like accessor, empty, or special math methods. | |
1600 // | |
1601 // When control flow reaches any of the entry types for the interpreter | |
1602 // the following holds -> | |
1603 // | |
1604 // Arguments: | |
1605 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1606 // rbx: Method* |
0 | 1607 // |
1608 // Stack layout immediately at entry | |
1609 // | |
1610 // [ return address ] <--- rsp | |
1611 // [ parameter n ] | |
1612 // ... | |
1613 // [ parameter 1 ] | |
1614 // [ expression stack ] (caller's java expression stack) | |
1615 | |
1616 // Assuming that we don't go to one of the trivial specialized entries | |
1617 // the stack will look like below when we are ready to execute the | |
1618 // first bytecode (or call the native routine). The register usage | |
1619 // will be as the template based interpreter expects (see | |
1620 // interpreter_amd64.hpp). | |
1621 // | |
1622 // local variables follow incoming parameters immediately; i.e. | |
1623 // the return address is moved to the end of the locals). | |
1624 // | |
1625 // [ monitor entry ] <--- rsp | |
1626 // ... | |
1627 // [ monitor entry ] | |
1628 // [ expr. stack bottom ] | |
1629 // [ saved r13 ] | |
1630 // [ current r14 ] | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1631 // [ Method* ] |
0 | 1632 // [ saved ebp ] <--- rbp |
1633 // [ return address ] | |
1634 // [ local variable m ] | |
1635 // ... | |
1636 // [ local variable 1 ] | |
1637 // [ parameter n ] | |
1638 // ... | |
1639 // [ parameter 1 ] <--- r14 | |
1640 | |
1641 address AbstractInterpreterGenerator::generate_method_entry( | |
1642 AbstractInterpreter::MethodKind kind) { | |
1643 // determine code generation flags | |
1644 bool synchronized = false; | |
1645 address entry_point = NULL; | |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1646 InterpreterGenerator* ig_this = (InterpreterGenerator*)this; |
0 | 1647 |
1648 switch (kind) { | |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1649 case Interpreter::zerolocals : break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1650 case Interpreter::zerolocals_synchronized: synchronized = true; break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1651 case Interpreter::native : entry_point = ig_this->generate_native_entry(false); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1652 case Interpreter::native_synchronized : entry_point = ig_this->generate_native_entry(true); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1653 case Interpreter::empty : entry_point = ig_this->generate_empty_entry(); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1654 case Interpreter::accessor : entry_point = ig_this->generate_accessor_entry(); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1655 case Interpreter::abstract : entry_point = ig_this->generate_abstract_entry(); break; |
706
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1656 |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1657 case Interpreter::java_lang_math_sin : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1658 case Interpreter::java_lang_math_cos : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1659 case Interpreter::java_lang_math_tan : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1660 case Interpreter::java_lang_math_abs : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1661 case Interpreter::java_lang_math_log : // fall thru |
819880572f09
6539464: Math.log() produces inconsistent results between successive runs.
never
parents:
622
diff
changeset
|
1662 case Interpreter::java_lang_math_log10 : // fall thru |
6084
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4771
diff
changeset
|
1663 case Interpreter::java_lang_math_sqrt : // fall thru |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4771
diff
changeset
|
1664 case Interpreter::java_lang_math_pow : // fall thru |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1665 case Interpreter::java_lang_math_exp : entry_point = ig_this->generate_math_entry(kind); break; |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2245
diff
changeset
|
1666 case Interpreter::java_lang_ref_reference_get |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1667 : entry_point = ig_this->generate_Reference_get_entry(); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1668 case Interpreter::java_util_zip_CRC32_update |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1669 : entry_point = ig_this->generate_CRC32_update_entry(); break; |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1670 case Interpreter::java_util_zip_CRC32_updateBytes |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1671 : // fall thru |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1672 case Interpreter::java_util_zip_CRC32_updateByteBuffer |
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1673 : entry_point = ig_this->generate_CRC32_updateBytes_entry(kind); break; |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
1674 default: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
1675 fatal(err_msg("unexpected method kind: %d", kind)); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
1676 break; |
0 | 1677 } |
1678 | |
1679 if (entry_point) { | |
1680 return entry_point; | |
1681 } | |
1682 | |
11080
b800986664f4
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
10393
diff
changeset
|
1683 return ig_this->generate_normal_entry(synchronized); |
0 | 1684 } |
1685 | |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1686 // These should never be compiled since the interpreter will prefer |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1687 // the compiled version to the intrinsic version. |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1688 bool AbstractInterpreter::can_be_compiled(methodHandle m) { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1689 switch (method_kind(m)) { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1690 case Interpreter::java_lang_math_sin : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1691 case Interpreter::java_lang_math_cos : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1692 case Interpreter::java_lang_math_tan : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1693 case Interpreter::java_lang_math_abs : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1694 case Interpreter::java_lang_math_log : // fall thru |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1695 case Interpreter::java_lang_math_log10 : // fall thru |
6084
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4771
diff
changeset
|
1696 case Interpreter::java_lang_math_sqrt : // fall thru |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4771
diff
changeset
|
1697 case Interpreter::java_lang_math_pow : // fall thru |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
4771
diff
changeset
|
1698 case Interpreter::java_lang_math_exp : |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1699 return false; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1700 default: |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1701 return true; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1702 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1703 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
1135
diff
changeset
|
1704 |
0 | 1705 // How much stack a method activation needs in words. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1706 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
0 | 1707 const int entry_size = frame::interpreter_frame_monitor_size(); |
1708 | |
1709 // total overhead size: entry_size + (saved rbp thru expr stack | |
1710 // bottom). be sure to change this if you add/subtract anything | |
1711 // to/from the overhead area | |
1712 const int overhead_size = | |
1713 -(frame::interpreter_frame_initial_sp_offset) + entry_size; | |
1714 | |
1715 const int stub_code = frame::entry_frame_after_call_words; | |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10141
diff
changeset
|
1716 const int method_stack = (method->max_locals() + method->max_stack()) * |
1506 | 1717 Interpreter::stackElementWords; |
0 | 1718 return (overhead_size + method_stack + stub_code); |
1719 } | |
1720 | |
1721 //----------------------------------------------------------------------------- | |
1722 // Exceptions | |
1723 | |
1724 void TemplateInterpreterGenerator::generate_throw_exception() { | |
1725 // Entry point in previous activation (i.e., if the caller was | |
1726 // interpreted) | |
1727 Interpreter::_rethrow_exception_entry = __ pc(); | |
1728 // Restore sp to interpreter_frame_last_sp even though we are going | |
1729 // to empty the expression stack for the exception processing. | |
304 | 1730 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); |
0 | 1731 // rax: exception |
1732 // rdx: return address/pc that threw exception | |
1733 __ restore_bcp(); // r13 points to call/send | |
1734 __ restore_locals(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1735 __ reinit_heapbase(); // restore r12 as heapbase. |
0 | 1736 // Entry point for exceptions thrown within interpreter code |
1737 Interpreter::_throw_exception_entry = __ pc(); | |
1738 // expression stack is undefined here | |
1739 // rax: exception | |
1740 // r13: exception bcp | |
1741 __ verify_oop(rax); | |
304 | 1742 __ mov(c_rarg1, rax); |
0 | 1743 |
1744 // expression stack must be empty before entering the VM in case of | |
1745 // an exception | |
1746 __ empty_expression_stack(); | |
1747 // find exception handler address and preserve exception oop | |
1748 __ call_VM(rdx, | |
1749 CAST_FROM_FN_PTR(address, | |
1750 InterpreterRuntime::exception_handler_for_exception), | |
1751 c_rarg1); | |
1752 // rax: exception handler entry point | |
1753 // rdx: preserved exception oop | |
1754 // r13: bcp for exception handler | |
1755 __ push_ptr(rdx); // push exception which is now the only value on the stack | |
1756 __ jmp(rax); // jump to exception handler (may be _remove_activation_entry!) | |
1757 | |
1758 // If the exception is not handled in the current frame the frame is | |
1759 // removed and the exception is rethrown (i.e. exception | |
1760 // continuation is _rethrow_exception). | |
1761 // | |
1762 // Note: At this point the bci is still the bxi for the instruction | |
1763 // which caused the exception and the expression stack is | |
1764 // empty. Thus, for any VM calls at this point, GC will find a legal | |
1765 // oop map (with empty expression stack). | |
1766 | |
1767 // In current activation | |
1768 // tos: exception | |
1769 // esi: exception bcp | |
1770 | |
1771 // | |
1772 // JVMTI PopFrame support | |
1773 // | |
1774 | |
1775 Interpreter::_remove_activation_preserving_args_entry = __ pc(); | |
1776 __ empty_expression_stack(); | |
1777 // Set the popframe_processing bit in pending_popframe_condition | |
1778 // indicating that we are currently handling popframe, so that | |
1779 // call_VMs that may happen later do not trigger new popframe | |
1780 // handling cycles. | |
1781 __ movl(rdx, Address(r15_thread, JavaThread::popframe_condition_offset())); | |
1782 __ orl(rdx, JavaThread::popframe_processing_bit); | |
1783 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), rdx); | |
1784 | |
1785 { | |
1786 // Check to see whether we are returning to a deoptimized frame. | |
1787 // (The PopFrame call ensures that the caller of the popped frame is | |
1788 // either interpreted or compiled and deoptimizes it if compiled.) | |
1789 // In this case, we can't call dispatch_next() after the frame is | |
1790 // popped, but instead must save the incoming arguments and restore | |
1791 // them after deoptimization has occurred. | |
1792 // | |
1793 // Note that we don't compare the return PC against the | |
1794 // deoptimization blob's unpack entry because of the presence of | |
1795 // adapter frames in C2. | |
1796 Label caller_not_deoptimized; | |
304 | 1797 __ movptr(c_rarg1, Address(rbp, frame::return_addr_offset * wordSize)); |
0 | 1798 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1799 InterpreterRuntime::interpreter_contains), c_rarg1); | |
1800 __ testl(rax, rax); | |
1801 __ jcc(Assembler::notZero, caller_not_deoptimized); | |
1802 | |
1803 // Compute size of arguments for saving when returning to | |
1804 // deoptimized caller | |
1805 __ get_method(rax); | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1806 __ movptr(rax, Address(rax, Method::const_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7199
diff
changeset
|
1807 __ load_unsigned_short(rax, Address(rax, in_bytes(ConstMethod:: |
0 | 1808 size_of_parameters_offset()))); |
1506 | 1809 __ shll(rax, Interpreter::logStackElementSize); |
0 | 1810 __ restore_locals(); // XXX do we need this? |
304 | 1811 __ subptr(r14, rax); |
1812 __ addptr(r14, wordSize); | |
0 | 1813 // Save these arguments |
1814 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, | |
1815 Deoptimization:: | |
1816 popframe_preserve_args), | |
1817 r15_thread, rax, r14); | |
1818 | |
1819 __ remove_activation(vtos, rdx, | |
1820 /* throw_monitor_exception */ false, | |
1821 /* install_monitor_exception */ false, | |
1822 /* notify_jvmdi */ false); | |
1823 | |
1824 // Inform deoptimization that it is responsible for restoring | |
1825 // these arguments | |
1826 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), | |
1827 JavaThread::popframe_force_deopt_reexecution_bit); | |
1828 | |
1829 // Continue in deoptimization handler | |
1830 __ jmp(rdx); | |
1831 | |
1832 __ bind(caller_not_deoptimized); | |
1833 } | |
1834 | |
1835 __ remove_activation(vtos, rdx, /* rdx result (retaddr) is not used */ | |
1836 /* throw_monitor_exception */ false, | |
1837 /* install_monitor_exception */ false, | |
1838 /* notify_jvmdi */ false); | |
1839 | |
1840 // Finish with popframe handling | |
1841 // A previous I2C followed by a deoptimization might have moved the | |
1842 // outgoing arguments further up the stack. PopFrame expects the | |
1843 // mutations to those outgoing arguments to be preserved and other | |
1844 // constraints basically require this frame to look exactly as | |
1845 // though it had previously invoked an interpreted activation with | |
1846 // no space between the top of the expression stack (current | |
1847 // last_sp) and the top of stack. Rather than force deopt to | |
1848 // maintain this kind of invariant all the time we call a small | |
1849 // fixup routine to move the mutated arguments onto the top of our | |
1850 // expression stack if necessary. | |
304 | 1851 __ mov(c_rarg1, rsp); |
1852 __ movptr(c_rarg2, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); | |
0 | 1853 // PC must point into interpreter here |
1854 __ set_last_Java_frame(noreg, rbp, __ pc()); | |
1855 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), r15_thread, c_rarg1, c_rarg2); | |
1856 __ reset_last_Java_frame(true, true); | |
1857 // Restore the last_sp and null it out | |
304 | 1858 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1859 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); | |
0 | 1860 |
1861 __ restore_bcp(); // XXX do we need this? | |
1862 __ restore_locals(); // XXX do we need this? | |
1863 // The method data pointer was incremented already during | |
1864 // call profiling. We have to restore the mdp for the current bcp. | |
1865 if (ProfileInterpreter) { | |
1866 __ set_method_data_pointer_for_bcp(); | |
1867 } | |
1868 | |
1869 // Clear the popframe condition flag | |
1870 __ movl(Address(r15_thread, JavaThread::popframe_condition_offset()), | |
1871 JavaThread::popframe_inactive); | |
1872 | |
12010
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1873 #if INCLUDE_JVMTI |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1874 if (EnableInvokeDynamic) { |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1875 Label L_done; |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1876 const Register local0 = r14; |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1877 |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1878 __ cmpb(Address(r13, 0), Bytecodes::_invokestatic); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1879 __ jcc(Assembler::notEqual, L_done); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1880 |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1881 // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1882 // Detect such a case in the InterpreterRuntime function and return the member name argument, or NULL. |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1883 |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1884 __ get_method(rdx); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1885 __ movptr(rax, Address(local0, 0)); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1886 __ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::member_name_arg_or_null), rax, rdx, r13); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1887 |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1888 __ testptr(rax, rax); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1889 __ jcc(Assembler::zero, L_done); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1890 |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1891 __ movptr(Address(rbx, 0), rax); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1892 __ bind(L_done); |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1893 } |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1894 #endif // INCLUDE_JVMTI |
ca0165daa6ec
7187554: JSR 292: JVMTI PopFrame needs to handle appendix arguments
sspitsyn
parents:
11080
diff
changeset
|
1895 |
0 | 1896 __ dispatch_next(vtos); |
1897 // end of PopFrame support | |
1898 | |
1899 Interpreter::_remove_activation_entry = __ pc(); | |
1900 | |
1901 // preserve exception over this code sequence | |
1902 __ pop_ptr(rax); | |
304 | 1903 __ movptr(Address(r15_thread, JavaThread::vm_result_offset()), rax); |
0 | 1904 // remove the activation (without doing throws on illegalMonitorExceptions) |
1905 __ remove_activation(vtos, rdx, false, true, false); | |
1906 // restore exception | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1907 __ get_vm_result(rax, r15_thread); |
0 | 1908 |
1909 // In between activations - previous activation type unknown yet | |
1910 // compute continuation point - the continuation point expects the | |
1911 // following registers set up: | |
1912 // | |
1913 // rax: exception | |
1914 // rdx: return address/pc that threw exception | |
1915 // rsp: expression stack of caller | |
1916 // rbp: ebp of caller | |
304 | 1917 __ push(rax); // save exception |
1918 __ push(rdx); // save return address | |
0 | 1919 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, |
1920 SharedRuntime::exception_handler_for_return_address), | |
1295 | 1921 r15_thread, rdx); |
304 | 1922 __ mov(rbx, rax); // save exception handler |
1923 __ pop(rdx); // restore return address | |
1924 __ pop(rax); // restore exception | |
0 | 1925 // Note that an "issuing PC" is actually the next PC after the call |
1926 __ jmp(rbx); // jump to exception | |
1927 // handler of caller | |
1928 } | |
1929 | |
1930 | |
1931 // | |
1932 // JVMTI ForceEarlyReturn support | |
1933 // | |
1934 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { | |
1935 address entry = __ pc(); | |
1936 | |
1937 __ restore_bcp(); | |
1938 __ restore_locals(); | |
1939 __ empty_expression_stack(); | |
1940 __ load_earlyret_value(state); | |
1941 | |
304 | 1942 __ movptr(rdx, Address(r15_thread, JavaThread::jvmti_thread_state_offset())); |
0 | 1943 Address cond_addr(rdx, JvmtiThreadState::earlyret_state_offset()); |
1944 | |
1945 // Clear the earlyret state | |
1946 __ movl(cond_addr, JvmtiThreadState::earlyret_inactive); | |
1947 | |
1948 __ remove_activation(state, rsi, | |
1949 false, /* throw_monitor_exception */ | |
1950 false, /* install_monitor_exception */ | |
1951 true); /* notify_jvmdi */ | |
1952 __ jmp(rsi); | |
1953 | |
1954 return entry; | |
1955 } // end of ForceEarlyReturn support | |
1956 | |
1957 | |
1958 //----------------------------------------------------------------------------- | |
1959 // Helper for vtos entry point generation | |
1960 | |
1961 void TemplateInterpreterGenerator::set_vtos_entry_points(Template* t, | |
1962 address& bep, | |
1963 address& cep, | |
1964 address& sep, | |
1965 address& aep, | |
1966 address& iep, | |
1967 address& lep, | |
1968 address& fep, | |
1969 address& dep, | |
1970 address& vep) { | |
1971 assert(t->is_valid() && t->tos_in() == vtos, "illegal template"); | |
1972 Label L; | |
1973 aep = __ pc(); __ push_ptr(); __ jmp(L); | |
1974 fep = __ pc(); __ push_f(); __ jmp(L); | |
1975 dep = __ pc(); __ push_d(); __ jmp(L); | |
1976 lep = __ pc(); __ push_l(); __ jmp(L); | |
1977 bep = cep = sep = | |
1978 iep = __ pc(); __ push_i(); | |
1979 vep = __ pc(); | |
1980 __ bind(L); | |
1981 generate_and_dispatch(t); | |
1982 } | |
1983 | |
1984 | |
1985 //----------------------------------------------------------------------------- | |
1986 // Generation of individual instructions | |
1987 | |
1988 // helpers for generate_and_dispatch | |
1989 | |
1990 | |
1991 InterpreterGenerator::InterpreterGenerator(StubQueue* code) | |
1992 : TemplateInterpreterGenerator(code) { | |
1993 generate_all(); // down here so it can be "virtual" | |
1994 } | |
1995 | |
1996 //----------------------------------------------------------------------------- | |
1997 | |
1998 // Non-product code | |
1999 #ifndef PRODUCT | |
2000 address TemplateInterpreterGenerator::generate_trace_code(TosState state) { | |
2001 address entry = __ pc(); | |
2002 | |
2003 __ push(state); | |
304 | 2004 __ push(c_rarg0); |
2005 __ push(c_rarg1); | |
2006 __ push(c_rarg2); | |
2007 __ push(c_rarg3); | |
2008 __ mov(c_rarg2, rax); // Pass itos | |
0 | 2009 #ifdef _WIN64 |
2010 __ movflt(xmm3, xmm0); // Pass ftos | |
2011 #endif | |
2012 __ call_VM(noreg, | |
2013 CAST_FROM_FN_PTR(address, SharedRuntime::trace_bytecode), | |
2014 c_rarg1, c_rarg2, c_rarg3); | |
304 | 2015 __ pop(c_rarg3); |
2016 __ pop(c_rarg2); | |
2017 __ pop(c_rarg1); | |
2018 __ pop(c_rarg0); | |
0 | 2019 __ pop(state); |
2020 __ ret(0); // return from result handler | |
2021 | |
2022 return entry; | |
2023 } | |
2024 | |
2025 void TemplateInterpreterGenerator::count_bytecode() { | |
2026 __ incrementl(ExternalAddress((address) &BytecodeCounter::_counter_value)); | |
2027 } | |
2028 | |
2029 void TemplateInterpreterGenerator::histogram_bytecode(Template* t) { | |
2030 __ incrementl(ExternalAddress((address) &BytecodeHistogram::_counters[t->bytecode()])); | |
2031 } | |
2032 | |
2033 void TemplateInterpreterGenerator::histogram_bytecode_pair(Template* t) { | |
2034 __ mov32(rbx, ExternalAddress((address) &BytecodePairHistogram::_index)); | |
2035 __ shrl(rbx, BytecodePairHistogram::log2_number_of_codes); | |
2036 __ orl(rbx, | |
2037 ((int) t->bytecode()) << | |
2038 BytecodePairHistogram::log2_number_of_codes); | |
2039 __ mov32(ExternalAddress((address) &BytecodePairHistogram::_index), rbx); | |
2040 __ lea(rscratch1, ExternalAddress((address) BytecodePairHistogram::_counters)); | |
2041 __ incrementl(Address(rscratch1, rbx, Address::times_4)); | |
2042 } | |
2043 | |
2044 | |
2045 void TemplateInterpreterGenerator::trace_bytecode(Template* t) { | |
2046 // Call a little run-time stub to avoid blow-up for each bytecode. | |
2047 // The run-time runtime saves the right registers, depending on | |
2048 // the tosca in-state for the given template. | |
2049 | |
2050 assert(Interpreter::trace_code(t->tos_in()) != NULL, | |
2051 "entry must have been generated"); | |
1976
0fc262af204f
6780143: hs203t003 hits SIGSEGV/EXCEPTION_ACCESS_VIOLATION with -XX:+UseCompressedOops
coleenp
parents:
1972
diff
changeset
|
2052 __ mov(r12, rsp); // remember sp (can only use r12 if not using call_VM) |
304 | 2053 __ andptr(rsp, -16); // align stack as required by ABI |
0 | 2054 __ call(RuntimeAddress(Interpreter::trace_code(t->tos_in()))); |
304 | 2055 __ mov(rsp, r12); // restore sp |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
2056 __ reinit_heapbase(); |
0 | 2057 } |
2058 | |
2059 | |
2060 void TemplateInterpreterGenerator::stop_interpreter_at() { | |
2061 Label L; | |
2062 __ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value), | |
2063 StopInterpreterAt); | |
2064 __ jcc(Assembler::notEqual, L); | |
2065 __ int3(); | |
2066 __ bind(L); | |
2067 } | |
2068 #endif // !PRODUCT | |
304 | 2069 #endif // ! CC_INTERP |