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