author | drchase |
Fri, 09 May 2014 16:50:54 -0400 | |
changeset 24424 | 2658d7834c6e |
parent 23203 | 76c2a23e2537 |
child 25715 | d5a8dbdc5150 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23203
diff
changeset
|
2 |
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4478
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4478
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4478
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "asm/macroAssembler.hpp" |
7397 | 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" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
33 |
#include "oops/methodData.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
34 |
#include "oops/method.hpp" |
7397 | 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 |
|
1 | 51 |
|
52 |
#define __ _masm-> |
|
53 |
||
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23203
diff
changeset
|
54 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
1 | 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 |
|
1066 | 63 |
__ mov(c_rarg3, rsp); |
1 | 64 |
// adjust rsp |
1066 | 65 |
__ subptr(rsp, 4 * wordSize); |
1 | 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: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
96 |
__ movl(rscratch1, Address(rbx, Method::access_flags_offset())); |
1 | 97 |
__ testl(rscratch1, JVM_ACC_STATIC); |
1066 | 98 |
__ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); |
1 | 99 |
break; |
100 |
case 1: |
|
1066 | 101 |
__ movptr(c_rarg2, Address(rsp, wordSize)); |
1 | 102 |
break; |
103 |
case 2: |
|
1066 | 104 |
__ movptr(c_rarg3, Address(rsp, 2 * wordSize)); |
1 | 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 |
|
1066 | 129 |
__ addptr(rsp, 4 * wordSize); |
1 | 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 |
|
1066 | 142 |
__ mov(c_rarg3, rsp); |
1 | 143 |
// adjust rsp |
1066 | 144 |
__ subptr(rsp, 14 * wordSize); |
1 | 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. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
181 |
__ movl(c_rarg3, Address(rbx, Method::access_flags_offset())); |
1 | 182 |
__ testl(c_rarg3, JVM_ACC_STATIC); |
1066 | 183 |
__ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0)); |
1 | 184 |
|
1066 | 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)); |
|
1 | 189 |
|
190 |
// restore rsp |
|
1066 | 191 |
__ addptr(rsp, 14 * wordSize); |
1 | 192 |
|
193 |
__ ret(0); |
|
194 |
||
195 |
return entry; |
|
196 |
} |
|
197 |
#endif |
|
198 |
||
199 |
||
200 |
// |
|
201 |
// Various method entries |
|
202 |
// |
|
203 |
||
1066 | 204 |
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) { |
205 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
206 |
// rbx,: Method* |
1066 | 207 |
// rcx: scratrch |
208 |
// r13: sender sp |
|
1 | 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) |
|
1066 | 224 |
// |
225 |
// stack: [ ret adr ] <-- rsp |
|
226 |
// [ lo(arg) ] |
|
227 |
// [ hi(arg) ] |
|
228 |
// |
|
1 | 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. |
|
1066 | 250 |
// get argument |
1 | 251 |
|
1066 | 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; |
|
12739
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
275 |
case Interpreter::java_lang_math_pow: |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
276 |
__ fld_d(Address(rsp, 3*wordSize)); // second argument (one |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
277 |
// empty stack slot) |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
278 |
__ pow_with_fallback(0); |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
279 |
break; |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
280 |
case Interpreter::java_lang_math_exp: |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
281 |
__ exp_with_fallback(0); |
09f26b73ae66
7133857: exp() and pow() should use the x87 ISA on x86
roland
parents:
9636
diff
changeset
|
282 |
break; |
1066 | 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); |
|
1 | 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) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
307 |
// rbx: Method* |
1 | 308 |
// r13: sender SP |
309 |
||
310 |
address entry_point = __ pc(); |
|
311 |
||
312 |
// abstract method entry |
|
313 |
||
23203 | 314 |
#ifndef CC_INTERP |
4478 | 315 |
// pop return address, reset last_sp to NULL |
316 |
__ empty_expression_stack(); |
|
317 |
__ restore_bcp(); // rsi must be correct for exception handler (was destroyed) |
|
318 |
__ restore_locals(); // make sure locals pointer is correct as well (was destroyed) |
|
23203 | 319 |
#endif |
1 | 320 |
|
321 |
// throw exception |
|
322 |
__ call_VM(noreg, CAST_FROM_FN_PTR(address, |
|
323 |
InterpreterRuntime::throw_AbstractMethodError)); |
|
324 |
// the call_VM checks for exception, so we should never return here. |
|
325 |
__ should_not_reach_here(); |
|
326 |
||
327 |
return entry_point; |
|
328 |
} |
|
329 |
||
330 |
||
331 |
// Empty method, generate a very fast return. |
|
332 |
||
333 |
address InterpreterGenerator::generate_empty_entry(void) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
334 |
// rbx: Method* |
1 | 335 |
// r13: sender sp must set sp to this value on return |
336 |
||
337 |
if (!UseFastEmptyMethods) { |
|
338 |
return NULL; |
|
339 |
} |
|
340 |
||
341 |
address entry_point = __ pc(); |
|
342 |
||
343 |
// If we need a safepoint check, generate full interpreter entry. |
|
344 |
Label slow_path; |
|
345 |
__ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()), |
|
346 |
SafepointSynchronize::_not_synchronized); |
|
347 |
__ jcc(Assembler::notEqual, slow_path); |
|
348 |
||
349 |
// do nothing for empty methods (do not even increment invocation counter) |
|
350 |
// Code: _return |
|
351 |
// _return |
|
352 |
// return w/o popping parameters |
|
1066 | 353 |
__ pop(rax); |
354 |
__ mov(rsp, r13); |
|
1 | 355 |
__ jmp(rax); |
356 |
||
357 |
__ bind(slow_path); |
|
358 |
(void) generate_normal_entry(false); |
|
359 |
return entry_point; |
|
360 |
||
361 |
} |
|
362 |
||
363 |
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { |
|
364 |
||
365 |
// This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in |
|
366 |
// the days we had adapter frames. When we deoptimize a situation where a |
|
367 |
// compiled caller calls a compiled caller will have registers it expects |
|
368 |
// to survive the call to the callee. If we deoptimize the callee the only |
|
369 |
// way we can restore these registers is to have the oldest interpreter |
|
370 |
// frame that we create restore these values. That is what this routine |
|
371 |
// will accomplish. |
|
372 |
||
373 |
// At the moment we have modified c2 to not have any callee save registers |
|
374 |
// so this problem does not exist and this routine is just a place holder. |
|
375 |
||
376 |
assert(f->is_interpreted_frame(), "must be interpreted"); |
|
377 |
} |