annotate src/cpu/x86/vm/interpreter_x86_64.cpp @ 71:3d62cb85208d

6662967: Optimize I2D conversion on new x86 Summary: Use CVTDQ2PS and CVTDQ2PD for integer values conversions to float and double values on new AMD cpu. Reviewed-by: sgoldman, never
author kvn
date Wed, 19 Mar 2008 15:33:25 -0700
parents a61af66fc99e
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_interpreter_x86_64.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
32 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // r14: pointer to locals
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // c_rarg3: first stack arg - wordSize
a61af66fc99e Initial load
duke
parents:
diff changeset
38 __ movq(c_rarg3, rsp);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // adjust rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
40 __ subq(rsp, 4 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 __ call_VM(noreg,
a61af66fc99e Initial load
duke
parents:
diff changeset
42 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
43 InterpreterRuntime::slow_signature_handler),
a61af66fc99e Initial load
duke
parents:
diff changeset
44 rbx, r14, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // rax: result handler
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Stack layout:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // rsp: 3 integer or float args (if static first is unused)
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // 1 float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // return address
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // stack args
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // expression stack bottom
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // bcp (NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Do FP first so we can use c_rarg3 as temp
a61af66fc99e Initial load
duke
parents:
diff changeset
59 __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 XMMRegister floatreg = as_XMMRegister(i+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 Label isfloatordouble, isdouble, next;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 __ testl(c_rarg3, 1 << (i*2)); // Float or Double?
a61af66fc99e Initial load
duke
parents:
diff changeset
66 __ jcc(Assembler::notZero, isfloatordouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Do Int register here
a61af66fc99e Initial load
duke
parents:
diff changeset
69 switch ( i ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 case 0:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 __ movl(rscratch1, Address(rbx, methodOopDesc::access_flags_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
72 __ testl(rscratch1, JVM_ACC_STATIC);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 __ cmovq(Assembler::zero, c_rarg1, Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
74 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 case 1:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 __ movq(c_rarg2, Address(rsp, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
77 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 case 2:
a61af66fc99e Initial load
duke
parents:
diff changeset
79 __ movq(c_rarg3, Address(rsp, 2 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
80 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 __ jmp (next);
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 __ bind(isfloatordouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 __ testl(c_rarg3, 1 << ((i*2)+1)); // Double?
a61af66fc99e Initial load
duke
parents:
diff changeset
89 __ jcc(Assembler::notZero, isdouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Do Float Here
a61af66fc99e Initial load
duke
parents:
diff changeset
92 __ movflt(floatreg, Address(rsp, i * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
93 __ jmp(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Do Double here
a61af66fc99e Initial load
duke
parents:
diff changeset
96 __ bind(isdouble);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 __ movdbl(floatreg, Address(rsp, i * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 __ bind(next);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // restore rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
104 __ addq(rsp, 4 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
111 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 address entry = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // r14: pointer to locals
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // c_rarg3: first stack arg - wordSize
a61af66fc99e Initial load
duke
parents:
diff changeset
117 __ movq(c_rarg3, rsp);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // adjust rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
119 __ subq(rsp, 14 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 __ call_VM(noreg,
a61af66fc99e Initial load
duke
parents:
diff changeset
121 CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
122 InterpreterRuntime::slow_signature_handler),
a61af66fc99e Initial load
duke
parents:
diff changeset
123 rbx, r14, c_rarg3);
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // rax: result handler
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Stack layout:
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // rsp: 5 integer args (if static first is unused)
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // 1 float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // 8 double args
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // return address
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // stack args
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // garbage
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // expression stack bottom
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // bcp (NULL)
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Do FP first so we can use c_rarg3 as temp
a61af66fc99e Initial load
duke
parents:
diff changeset
139 __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 const XMMRegister r = as_XMMRegister(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 Label d, done;
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 __ testl(c_rarg3, 1 << i);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 __ jcc(Assembler::notZero, d);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 __ movflt(r, Address(rsp, (6 + i) * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
149 __ jmp(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 __ bind(d);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 __ movdbl(r, Address(rsp, (6 + i) * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
152 __ bind(done);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Now handle integrals. Only do c_rarg1 if not static.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 __ movl(c_rarg3, Address(rbx, methodOopDesc::access_flags_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
157 __ testl(c_rarg3, JVM_ACC_STATIC);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 __ cmovq(Assembler::zero, c_rarg1, Address(rsp, 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 __ movq(c_rarg2, Address(rsp, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
161 __ movq(c_rarg3, Address(rsp, 2 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
162 __ movq(c_rarg4, Address(rsp, 3 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
163 __ movq(c_rarg5, Address(rsp, 4 * wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // restore rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
166 __ addq(rsp, 14 * wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 //
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Various method entries
a61af66fc99e Initial load
duke
parents:
diff changeset
177 //
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179 address InterpreterGenerator::generate_math_entry(
a61af66fc99e Initial load
duke
parents:
diff changeset
180 AbstractInterpreter::MethodKind kind) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 assert(kind == Interpreter::java_lang_math_sqrt,
a61af66fc99e Initial load
duke
parents:
diff changeset
186 "Other intrinsics are not special");
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // These don't need a safepoint check because they aren't virtually
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // callable. We won't enter these intrinsics from compiled code.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // If in the future we added an intrinsic which was virtually callable
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // we'd have to worry about how to safepoint so that this code is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // mathematical functions inlined by compiler
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // (interpreter must provide identical implementation
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // in order to avoid monotonicity bugs when switching
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // from interpreter to compiler in the middle of some
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // computation)
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // native methods. Interpreter::method_kind(...) does a check for
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // native methods first before checking for intrinsic methods and
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // thus will never select this entry point. Make sure it is not
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // called accidentally since the SharedRuntime entry points will
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // not work for JDK 1.2.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 //
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // We no longer need to check for JDK 1.2 since it's EOL'ed.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // The following check existed in pre 1.6 implementation,
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // if (Universe::is_jdk12x_version()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Universe::is_jdk12x_version() always returns false since
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // the JDK version is not yet determined when this method is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // This method is called during interpreter_init() whereas
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // JDK version is only determined when universe2_init() is called.
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // java methods. Interpreter::method_kind(...) will select
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // this entry point for the corresponding methods in JDK 1.3.
a61af66fc99e Initial load
duke
parents:
diff changeset
221 __ sqrtsd(xmm0, Address(rsp, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 __ movq(rsp, r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 __ jmp(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Abstract method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Attempt to execute abstract method. Throw exception
a61af66fc99e Initial load
duke
parents:
diff changeset
233 address InterpreterGenerator::generate_abstract_entry(void) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // r13: sender SP
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // abstract method entry
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // remove return address. Not really needed, since exception
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // handling throws away expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
242 __ popq(rbx);
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // adjust stack to what a normal return would do
a61af66fc99e Initial load
duke
parents:
diff changeset
245 __ movq(rsp, r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // throw exception
a61af66fc99e Initial load
duke
parents:
diff changeset
248 __ call_VM(noreg, CAST_FROM_FN_PTR(address,
a61af66fc99e Initial load
duke
parents:
diff changeset
249 InterpreterRuntime::throw_AbstractMethodError));
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // the call_VM checks for exception, so we should never return here.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 __ should_not_reach_here();
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // Empty method, generate a very fast return.
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 address InterpreterGenerator::generate_empty_entry(void) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // r13: sender sp must set sp to this value on return
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 if (!UseFastEmptyMethods) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // If we need a safepoint check, generate full interpreter entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Label slow_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
a61af66fc99e Initial load
duke
parents:
diff changeset
272 SafepointSynchronize::_not_synchronized);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 __ jcc(Assembler::notEqual, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // do nothing for empty methods (do not even increment invocation counter)
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // Code: _return
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // _return
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // return w/o popping parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
279 __ popq(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 __ movq(rsp, r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 __ jmp(rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 __ bind(slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 (void) generate_normal_entry(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // Call an accessor method (assuming it is resolved, otherwise drop
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // into vanilla (slow path) entry
a61af66fc99e Initial load
duke
parents:
diff changeset
291 address InterpreterGenerator::generate_accessor_entry(void) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 // rbx: methodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // r13: senderSP must preserver for slow path, set SP to it on fast path
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 address entry_point = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
297 Label xreturn_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // do fastpath for resolved accessor methods
a61af66fc99e Initial load
duke
parents:
diff changeset
300 if (UseFastAccessorMethods) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // thereof; parameter size = 1
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // Note: We can only use this code if the getfield has been resolved
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // and if we don't have a null-pointer exception => check for
a61af66fc99e Initial load
duke
parents:
diff changeset
305 // these conditions first and use slow path if necessary.
a61af66fc99e Initial load
duke
parents:
diff changeset
306 Label slow_path;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // If we need a safepoint check, generate full interpreter entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
308 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
a61af66fc99e Initial load
duke
parents:
diff changeset
309 SafepointSynchronize::_not_synchronized);
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 __ jcc(Assembler::notEqual, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
312 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
313 __ movq(rax, Address(rsp, wordSize));
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // check if local 0 != NULL and read field
a61af66fc99e Initial load
duke
parents:
diff changeset
316 __ testq(rax, rax);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 __ jcc(Assembler::zero, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 __ movq(rdi, Address(rbx, methodOopDesc::constants_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // read first instruction word and extract bytecode @ 1 and index @ 2
a61af66fc99e Initial load
duke
parents:
diff changeset
321 __ movq(rdx, Address(rbx, methodOopDesc::const_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
322 __ movl(rdx, Address(rdx, constMethodOopDesc::codes_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // Shift codes right to get the index on the right.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // The bytecode fetched looks like <index><0xb4><0x2a>
a61af66fc99e Initial load
duke
parents:
diff changeset
325 __ shrl(rdx, 2 * BitsPerByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 __ shll(rdx, exact_log2(in_words(ConstantPoolCacheEntry::size())));
a61af66fc99e Initial load
duke
parents:
diff changeset
327 __ movq(rdi, Address(rdi, constantPoolOopDesc::cache_offset_in_bytes()));
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // rax: local 0
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // rbx: method
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // rdx: constant pool cache index
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // rdi: constant pool cache
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 // check if getfield has been resolved and read constant pool cache entry
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // check the validity of the cache entry by testing whether _indices field
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // contains Bytecode::_getfield in b1 byte.
a61af66fc99e Initial load
duke
parents:
diff changeset
337 assert(in_words(ConstantPoolCacheEntry::size()) == 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
338 "adjust shift below");
a61af66fc99e Initial load
duke
parents:
diff changeset
339 __ movl(rcx,
a61af66fc99e Initial load
duke
parents:
diff changeset
340 Address(rdi,
a61af66fc99e Initial load
duke
parents:
diff changeset
341 rdx,
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
343 constantPoolCacheOopDesc::base_offset() +
a61af66fc99e Initial load
duke
parents:
diff changeset
344 ConstantPoolCacheEntry::indices_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
345 __ shrl(rcx, 2 * BitsPerByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 __ andl(rcx, 0xFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 __ cmpl(rcx, Bytecodes::_getfield);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 __ jcc(Assembler::notEqual, slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // Note: constant pool entry is not valid before bytecode is resolved
a61af66fc99e Initial load
duke
parents:
diff changeset
351 __ movq(rcx,
a61af66fc99e Initial load
duke
parents:
diff changeset
352 Address(rdi,
a61af66fc99e Initial load
duke
parents:
diff changeset
353 rdx,
a61af66fc99e Initial load
duke
parents:
diff changeset
354 Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
355 constantPoolCacheOopDesc::base_offset() +
a61af66fc99e Initial load
duke
parents:
diff changeset
356 ConstantPoolCacheEntry::f2_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // edx: flags
a61af66fc99e Initial load
duke
parents:
diff changeset
358 __ movl(rdx,
a61af66fc99e Initial load
duke
parents:
diff changeset
359 Address(rdi,
a61af66fc99e Initial load
duke
parents:
diff changeset
360 rdx,
a61af66fc99e Initial load
duke
parents:
diff changeset
361 Address::times_8,
a61af66fc99e Initial load
duke
parents:
diff changeset
362 constantPoolCacheOopDesc::base_offset() +
a61af66fc99e Initial load
duke
parents:
diff changeset
363 ConstantPoolCacheEntry::flags_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 Label notObj, notInt, notByte, notShort;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 const Address field_address(rax, rcx, Address::times_1);
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // Need to differentiate between igetfield, agetfield, bgetfield etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // because they are different sizes.
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // Use the type from the constant pool cache
a61af66fc99e Initial load
duke
parents:
diff changeset
371 __ shrl(rdx, ConstantPoolCacheEntry::tosBits);
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Make sure we don't need to mask edx for tosBits after the above shift
a61af66fc99e Initial load
duke
parents:
diff changeset
373 ConstantPoolCacheEntry::verify_tosBits();
a61af66fc99e Initial load
duke
parents:
diff changeset
374
a61af66fc99e Initial load
duke
parents:
diff changeset
375 __ cmpl(rdx, atos);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 __ jcc(Assembler::notEqual, notObj);
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // atos
a61af66fc99e Initial load
duke
parents:
diff changeset
378 __ movq(rax, field_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
379 __ jmp(xreturn_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 __ bind(notObj);
a61af66fc99e Initial load
duke
parents:
diff changeset
382 __ cmpl(rdx, itos);
a61af66fc99e Initial load
duke
parents:
diff changeset
383 __ jcc(Assembler::notEqual, notInt);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // itos
a61af66fc99e Initial load
duke
parents:
diff changeset
385 __ movl(rax, field_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 __ jmp(xreturn_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 __ bind(notInt);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 __ cmpl(rdx, btos);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 __ jcc(Assembler::notEqual, notByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // btos
a61af66fc99e Initial load
duke
parents:
diff changeset
392 __ load_signed_byte(rax, field_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
393 __ jmp(xreturn_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 __ bind(notByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 __ cmpl(rdx, stos);
a61af66fc99e Initial load
duke
parents:
diff changeset
397 __ jcc(Assembler::notEqual, notShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 // stos
a61af66fc99e Initial load
duke
parents:
diff changeset
399 __ load_signed_word(rax, field_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 __ jmp(xreturn_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 __ bind(notShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
404 Label okay;
a61af66fc99e Initial load
duke
parents:
diff changeset
405 __ cmpl(rdx, ctos);
a61af66fc99e Initial load
duke
parents:
diff changeset
406 __ jcc(Assembler::equal, okay);
a61af66fc99e Initial load
duke
parents:
diff changeset
407 __ stop("what type is this?");
a61af66fc99e Initial load
duke
parents:
diff changeset
408 __ bind(okay);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // ctos
a61af66fc99e Initial load
duke
parents:
diff changeset
411 __ load_unsigned_word(rax, field_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 __ bind(xreturn_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // _ireturn/_areturn
a61af66fc99e Initial load
duke
parents:
diff changeset
416 __ popq(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 __ movq(rsp, r13);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 __ jmp(rdi);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 __ ret(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // generate a vanilla interpreter entry as the slow path
a61af66fc99e Initial load
duke
parents:
diff changeset
422 __ bind(slow_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 (void) generate_normal_entry(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
424 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
425 (void) generate_normal_entry(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
426 }
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 return entry_point;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 }
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // This method tells the deoptimizer how big an interpreted frame must be:
a61af66fc99e Initial load
duke
parents:
diff changeset
432 int AbstractInterpreter::size_activation(methodOop method,
a61af66fc99e Initial load
duke
parents:
diff changeset
433 int tempcount,
a61af66fc99e Initial load
duke
parents:
diff changeset
434 int popframe_extra_args,
a61af66fc99e Initial load
duke
parents:
diff changeset
435 int moncount,
a61af66fc99e Initial load
duke
parents:
diff changeset
436 int callee_param_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
437 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
438 bool is_top_frame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 return layout_activation(method,
a61af66fc99e Initial load
duke
parents:
diff changeset
440 tempcount, popframe_extra_args, moncount,
a61af66fc99e Initial load
duke
parents:
diff changeset
441 callee_param_count, callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
442 (frame*) NULL, (frame*) NULL, is_top_frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // the days we had adapter frames. When we deoptimize a situation where a
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // compiled caller calls a compiled caller will have registers it expects
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // to survive the call to the callee. If we deoptimize the callee the only
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // way we can restore these registers is to have the oldest interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // frame that we create restore these values. That is what this routine
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // will accomplish.
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // At the moment we have modified c2 to not have any callee save registers
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // so this problem does not exist and this routine is just a place holder.
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 assert(f->is_interpreted_frame(), "must be interpreted");
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }