Mercurial > hg > truffle
annotate src/cpu/x86/vm/interpreter_x86_64.cpp @ 17874:2c7132f3f1e6
Merge
author | iignatyev |
---|---|
date | Mon, 14 Apr 2014 22:53:29 +0400 |
parents | cd3d6a6b95d9 |
children | d3f14809b051 78bbf4d43a14 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1108
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1108
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:
1108
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 "prims/methodHandles.hpp" | |
39 #include "runtime/arguments.hpp" | |
40 #include "runtime/deoptimization.hpp" | |
41 #include "runtime/frame.inline.hpp" | |
42 #include "runtime/sharedRuntime.hpp" | |
43 #include "runtime/stubRoutines.hpp" | |
44 #include "runtime/synchronizer.hpp" | |
45 #include "runtime/timer.hpp" | |
46 #include "runtime/vframeArray.hpp" | |
47 #include "utilities/debug.hpp" | |
48 #ifdef COMPILER1 | |
49 #include "c1/c1_Runtime1.hpp" | |
50 #endif | |
0 | 51 |
52 #define __ _masm-> | |
53 | |
54 | |
55 #ifdef _WIN64 | |
56 address AbstractInterpreterGenerator::generate_slow_signature_handler() { | |
57 address entry = __ pc(); | |
58 | |
59 // rbx: method | |
60 // r14: pointer to locals | |
61 // c_rarg3: first stack arg - wordSize | |
304 | 62 __ mov(c_rarg3, rsp); |
0 | 63 // adjust rsp |
304 | 64 __ subptr(rsp, 4 * wordSize); |
0 | 65 __ call_VM(noreg, |
66 CAST_FROM_FN_PTR(address, | |
67 InterpreterRuntime::slow_signature_handler), | |
68 rbx, r14, c_rarg3); | |
69 | |
70 // rax: result handler | |
71 | |
72 // Stack layout: | |
73 // rsp: 3 integer or float args (if static first is unused) | |
74 // 1 float/double identifiers | |
75 // return address | |
76 // stack args | |
77 // garbage | |
78 // expression stack bottom | |
79 // bcp (NULL) | |
80 // ... | |
81 | |
82 // Do FP first so we can use c_rarg3 as temp | |
83 __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers | |
84 | |
85 for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) { | |
86 XMMRegister floatreg = as_XMMRegister(i+1); | |
87 Label isfloatordouble, isdouble, next; | |
88 | |
89 __ testl(c_rarg3, 1 << (i*2)); // Float or Double? | |
90 __ jcc(Assembler::notZero, isfloatordouble); | |
91 | |
92 // Do Int register here | |
93 switch ( i ) { | |
94 case 0: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
95 __ movl(rscratch1, Address(rbx, Method::access_flags_offset())); |
0 | 96 __ testl(rscratch1, JVM_ACC_STATIC); |
304 | 97 __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); |
0 | 98 break; |
99 case 1: | |
304 | 100 __ movptr(c_rarg2, Address(rsp, wordSize)); |
0 | 101 break; |
102 case 2: | |
304 | 103 __ movptr(c_rarg3, Address(rsp, 2 * wordSize)); |
0 | 104 break; |
105 default: | |
106 break; | |
107 } | |
108 | |
109 __ jmp (next); | |
110 | |
111 __ bind(isfloatordouble); | |
112 __ testl(c_rarg3, 1 << ((i*2)+1)); // Double? | |
113 __ jcc(Assembler::notZero, isdouble); | |
114 | |
115 // Do Float Here | |
116 __ movflt(floatreg, Address(rsp, i * wordSize)); | |
117 __ jmp(next); | |
118 | |
119 // Do Double here | |
120 __ bind(isdouble); | |
121 __ movdbl(floatreg, Address(rsp, i * wordSize)); | |
122 | |
123 __ bind(next); | |
124 } | |
125 | |
126 | |
127 // restore rsp | |
304 | 128 __ addptr(rsp, 4 * wordSize); |
0 | 129 |
130 __ ret(0); | |
131 | |
132 return entry; | |
133 } | |
134 #else | |
135 address AbstractInterpreterGenerator::generate_slow_signature_handler() { | |
136 address entry = __ pc(); | |
137 | |
138 // rbx: method | |
139 // r14: pointer to locals | |
140 // c_rarg3: first stack arg - wordSize | |
304 | 141 __ mov(c_rarg3, rsp); |
0 | 142 // adjust rsp |
304 | 143 __ subptr(rsp, 14 * wordSize); |
0 | 144 __ call_VM(noreg, |
145 CAST_FROM_FN_PTR(address, | |
146 InterpreterRuntime::slow_signature_handler), | |
147 rbx, r14, c_rarg3); | |
148 | |
149 // rax: result handler | |
150 | |
151 // Stack layout: | |
152 // rsp: 5 integer args (if static first is unused) | |
153 // 1 float/double identifiers | |
154 // 8 double args | |
155 // return address | |
156 // stack args | |
157 // garbage | |
158 // expression stack bottom | |
159 // bcp (NULL) | |
160 // ... | |
161 | |
162 // Do FP first so we can use c_rarg3 as temp | |
163 __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers | |
164 | |
165 for (int i = 0; i < Argument::n_float_register_parameters_c; i++) { | |
166 const XMMRegister r = as_XMMRegister(i); | |
167 | |
168 Label d, done; | |
169 | |
170 __ testl(c_rarg3, 1 << i); | |
171 __ jcc(Assembler::notZero, d); | |
172 __ movflt(r, Address(rsp, (6 + i) * wordSize)); | |
173 __ jmp(done); | |
174 __ bind(d); | |
175 __ movdbl(r, Address(rsp, (6 + i) * wordSize)); | |
176 __ bind(done); | |
177 } | |
178 | |
179 // Now handle integrals. Only do c_rarg1 if not static. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
180 __ movl(c_rarg3, Address(rbx, Method::access_flags_offset())); |
0 | 181 __ testl(c_rarg3, JVM_ACC_STATIC); |
304 | 182 __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); |
0 | 183 |
304 | 184 __ movptr(c_rarg2, Address(rsp, wordSize)); |
185 __ movptr(c_rarg3, Address(rsp, 2 * wordSize)); | |
186 __ movptr(c_rarg4, Address(rsp, 3 * wordSize)); | |
187 __ movptr(c_rarg5, Address(rsp, 4 * wordSize)); | |
0 | 188 |
189 // restore rsp | |
304 | 190 __ addptr(rsp, 14 * wordSize); |
0 | 191 |
192 __ ret(0); | |
193 | |
194 return entry; | |
195 } | |
196 #endif | |
197 | |
198 | |
199 // | |
200 // Various method entries | |
201 // | |
202 | |
304 | 203 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { |
204 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
205 // rbx,: Method* |
304 | 206 // rcx: scratrch |
207 // r13: sender sp | |
0 | 208 |
209 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry | |
210 | |
211 address entry_point = __ pc(); | |
212 | |
213 // These don't need a safepoint check because they aren't virtually | |
214 // callable. We won't enter these intrinsics from compiled code. | |
215 // If in the future we added an intrinsic which was virtually callable | |
216 // we'd have to worry about how to safepoint so that this code is used. | |
217 | |
218 // mathematical functions inlined by compiler | |
219 // (interpreter must provide identical implementation | |
220 // in order to avoid monotonicity bugs when switching | |
221 // from interpreter to compiler in the middle of some | |
222 // computation) | |
304 | 223 // |
224 // stack: [ ret adr ] <-- rsp | |
225 // [ lo(arg) ] | |
226 // [ hi(arg) ] | |
227 // | |
0 | 228 |
229 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are | |
230 // native methods. Interpreter::method_kind(...) does a check for | |
231 // native methods first before checking for intrinsic methods and | |
232 // thus will never select this entry point. Make sure it is not | |
233 // called accidentally since the SharedRuntime entry points will | |
234 // not work for JDK 1.2. | |
235 // | |
236 // We no longer need to check for JDK 1.2 since it's EOL'ed. | |
237 // The following check existed in pre 1.6 implementation, | |
238 // if (Universe::is_jdk12x_version()) { | |
239 // __ should_not_reach_here(); | |
240 // } | |
241 // Universe::is_jdk12x_version() always returns false since | |
242 // the JDK version is not yet determined when this method is called. | |
243 // This method is called during interpreter_init() whereas | |
244 // JDK version is only determined when universe2_init() is called. | |
245 | |
246 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are | |
247 // java methods. Interpreter::method_kind(...) will select | |
248 // this entry point for the corresponding methods in JDK 1.3. | |
304 | 249 // get argument |
0 | 250 |
304 | 251 if (kind == Interpreter::java_lang_math_sqrt) { |
252 __ sqrtsd(xmm0, Address(rsp, wordSize)); | |
253 } else { | |
254 __ fld_d(Address(rsp, wordSize)); | |
255 switch (kind) { | |
256 case Interpreter::java_lang_math_sin : | |
257 __ trigfunc('s'); | |
258 break; | |
259 case Interpreter::java_lang_math_cos : | |
260 __ trigfunc('c'); | |
261 break; | |
262 case Interpreter::java_lang_math_tan : | |
263 __ trigfunc('t'); | |
264 break; | |
265 case Interpreter::java_lang_math_abs: | |
266 __ fabs(); | |
267 break; | |
268 case Interpreter::java_lang_math_log: | |
269 __ flog(); | |
270 break; | |
271 case Interpreter::java_lang_math_log10: | |
272 __ flog10(); | |
273 break; | |
6084
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
274 case Interpreter::java_lang_math_pow: |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
275 __ fld_d(Address(rsp, 3*wordSize)); // second argument (one |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
276 // empty stack slot) |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
277 __ pow_with_fallback(0); |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
278 break; |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
279 case Interpreter::java_lang_math_exp: |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
280 __ exp_with_fallback(0); |
6759698e3140
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
3369
diff
changeset
|
281 break; |
304 | 282 default : |
283 ShouldNotReachHere(); | |
284 } | |
285 | |
286 // return double result in xmm0 for interpreter and compilers. | |
287 __ subptr(rsp, 2*wordSize); | |
288 // Round to 64bit precision | |
289 __ fstp_d(Address(rsp, 0)); | |
290 __ movdbl(xmm0, Address(rsp, 0)); | |
291 __ addptr(rsp, 2*wordSize); | |
292 } | |
293 | |
294 | |
295 __ pop(rax); | |
296 __ mov(rsp, r13); | |
0 | 297 __ jmp(rax); |
298 | |
299 return entry_point; | |
300 } | |
301 | |
302 | |
303 // Abstract method entry | |
304 // Attempt to execute abstract method. Throw exception | |
305 address InterpreterGenerator::generate_abstract_entry(void) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
306 // rbx: Method* |
0 | 307 // r13: sender SP |
308 | |
309 address entry_point = __ pc(); | |
310 | |
311 // abstract method entry | |
312 | |
1108 | 313 // pop return address, reset last_sp to NULL |
314 __ empty_expression_stack(); | |
315 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) | |
316 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) | |
0 | 317 |
318 // throw exception | |
319 __ call_VM(noreg, CAST_FROM_FN_PTR(address, | |
320 InterpreterRuntime::throw_AbstractMethodError)); | |
321 // the call_VM checks for exception, so we should never return here. | |
322 __ should_not_reach_here(); | |
323 | |
324 return entry_point; | |
325 } | |
326 | |
327 | |
328 // Empty method, generate a very fast return. | |
329 | |
330 address InterpreterGenerator::generate_empty_entry(void) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
331 // rbx: Method* |
0 | 332 // r13: sender sp must set sp to this value on return |
333 | |
334 if (!UseFastEmptyMethods) { | |
335 return NULL; | |
336 } | |
337 | |
338 address entry_point = __ pc(); | |
339 | |
340 // If we need a safepoint check, generate full interpreter entry. | |
341 Label slow_path; | |
342 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), | |
343 SafepointSynchronize::_not_synchronized); | |
344 __ jcc(Assembler::notEqual, slow_path); | |
345 | |
346 // do nothing for empty methods (do not even increment invocation counter) | |
347 // Code: _return | |
348 // _return | |
349 // return w/o popping parameters | |
304 | 350 __ pop(rax); |
351 __ mov(rsp, r13); | |
0 | 352 __ jmp(rax); |
353 | |
354 __ bind(slow_path); | |
355 (void) generate_normal_entry(false); | |
356 return entry_point; | |
357 | |
358 } | |
359 | |
360 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { | |
361 | |
362 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in | |
363 // the days we had adapter frames. When we deoptimize a situation where a | |
364 // compiled caller calls a compiled caller will have registers it expects | |
365 // to survive the call to the callee. If we deoptimize the callee the only | |
366 // way we can restore these registers is to have the oldest interpreter | |
367 // frame that we create restore these values. That is what this routine | |
368 // will accomplish. | |
369 | |
370 // At the moment we have modified c2 to not have any callee save registers | |
371 // so this problem does not exist and this routine is just a place holder. | |
372 | |
373 assert(f->is_interpreted_frame(), "must be interpreted"); | |
374 } |