Mercurial > hg > graal-compiler
annotate src/cpu/sparc/vm/interpreter_sparc.cpp @ 1333:3f12a94552cc
Added tag jdk7-b88 for changeset 4b60f23c4223
author | mikejwre |
---|---|
date | Thu, 08 Apr 2010 17:02:41 -0700 |
parents | ddb7834449d0 |
children | c640000b7cc1 |
rev | line source |
---|---|
0 | 1 /* |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
2 * Copyright 1997-2010 Sun Microsystems, Inc. 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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_interpreter_sparc.cpp.incl" | |
27 | |
28 | |
29 | |
30 // Generation of Interpreter | |
31 // | |
32 // The InterpreterGenerator generates the interpreter into Interpreter::_code. | |
33 | |
34 | |
35 #define __ _masm-> | |
36 | |
37 | |
38 //---------------------------------------------------------------------------------------------------- | |
39 | |
40 | |
41 | |
42 | |
43 int AbstractInterpreter::BasicType_as_index(BasicType type) { | |
44 int i = 0; | |
45 switch (type) { | |
46 case T_BOOLEAN: i = 0; break; | |
47 case T_CHAR : i = 1; break; | |
48 case T_BYTE : i = 2; break; | |
49 case T_SHORT : i = 3; break; | |
50 case T_INT : i = 4; break; | |
51 case T_LONG : i = 5; break; | |
52 case T_VOID : i = 6; break; | |
53 case T_FLOAT : i = 7; break; | |
54 case T_DOUBLE : i = 8; break; | |
55 case T_OBJECT : i = 9; break; | |
56 case T_ARRAY : i = 9; break; | |
57 default : ShouldNotReachHere(); | |
58 } | |
59 assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds"); | |
60 return i; | |
61 } | |
62 | |
63 | |
64 #ifndef _LP64 | |
65 address AbstractInterpreterGenerator::generate_slow_signature_handler() { | |
66 address entry = __ pc(); | |
67 Argument argv(0, true); | |
68 | |
69 // We are in the jni transition frame. Save the last_java_frame corresponding to the | |
70 // outer interpreter frame | |
71 // | |
72 __ set_last_Java_frame(FP, noreg); | |
73 // make sure the interpreter frame we've pushed has a valid return pc | |
74 __ mov(O7, I7); | |
75 __ mov(Lmethod, G3_scratch); | |
76 __ mov(Llocals, G4_scratch); | |
77 __ save_frame(0); | |
78 __ mov(G2_thread, L7_thread_cache); | |
79 __ add(argv.address_in_frame(), O3); | |
80 __ mov(G2_thread, O0); | |
81 __ mov(G3_scratch, O1); | |
82 __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type); | |
83 __ delayed()->mov(G4_scratch, O2); | |
84 __ mov(L7_thread_cache, G2_thread); | |
85 __ reset_last_Java_frame(); | |
86 | |
87 // load the register arguments (the C code packed them as varargs) | |
88 for (Argument ldarg = argv.successor(); ldarg.is_register(); ldarg = ldarg.successor()) { | |
89 __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register()); | |
90 } | |
91 __ ret(); | |
92 __ delayed()-> | |
93 restore(O0, 0, Lscratch); // caller's Lscratch gets the result handler | |
94 return entry; | |
95 } | |
96 | |
97 | |
98 #else | |
99 // LP64 passes floating point arguments in F1, F3, F5, etc. instead of | |
100 // O0, O1, O2 etc.. | |
101 // Doubles are passed in D0, D2, D4 | |
102 // We store the signature of the first 16 arguments in the first argument | |
103 // slot because it will be overwritten prior to calling the native | |
104 // function, with the pointer to the JNIEnv. | |
105 // If LP64 there can be up to 16 floating point arguments in registers | |
106 // or 6 integer registers. | |
107 address AbstractInterpreterGenerator::generate_slow_signature_handler() { | |
108 | |
109 enum { | |
110 non_float = 0, | |
111 float_sig = 1, | |
112 double_sig = 2, | |
113 sig_mask = 3 | |
114 }; | |
115 | |
116 address entry = __ pc(); | |
117 Argument argv(0, true); | |
118 | |
119 // We are in the jni transition frame. Save the last_java_frame corresponding to the | |
120 // outer interpreter frame | |
121 // | |
122 __ set_last_Java_frame(FP, noreg); | |
123 // make sure the interpreter frame we've pushed has a valid return pc | |
124 __ mov(O7, I7); | |
125 __ mov(Lmethod, G3_scratch); | |
126 __ mov(Llocals, G4_scratch); | |
127 __ save_frame(0); | |
128 __ mov(G2_thread, L7_thread_cache); | |
129 __ add(argv.address_in_frame(), O3); | |
130 __ mov(G2_thread, O0); | |
131 __ mov(G3_scratch, O1); | |
132 __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type); | |
133 __ delayed()->mov(G4_scratch, O2); | |
134 __ mov(L7_thread_cache, G2_thread); | |
135 __ reset_last_Java_frame(); | |
136 | |
137 | |
138 // load the register arguments (the C code packed them as varargs) | |
139 Address Sig = argv.address_in_frame(); // Argument 0 holds the signature | |
140 __ ld_ptr( Sig, G3_scratch ); // Get register argument signature word into G3_scratch | |
141 __ mov( G3_scratch, G4_scratch); | |
142 __ srl( G4_scratch, 2, G4_scratch); // Skip Arg 0 | |
143 Label done; | |
144 for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) { | |
145 Label NonFloatArg; | |
146 Label LoadFloatArg; | |
147 Label LoadDoubleArg; | |
148 Label NextArg; | |
149 Address a = ldarg.address_in_frame(); | |
150 __ andcc(G4_scratch, sig_mask, G3_scratch); | |
151 __ br(Assembler::zero, false, Assembler::pt, NonFloatArg); | |
152 __ delayed()->nop(); | |
153 | |
154 __ cmp(G3_scratch, float_sig ); | |
155 __ br(Assembler::equal, false, Assembler::pt, LoadFloatArg); | |
156 __ delayed()->nop(); | |
157 | |
158 __ cmp(G3_scratch, double_sig ); | |
159 __ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg); | |
160 __ delayed()->nop(); | |
161 | |
162 __ bind(NonFloatArg); | |
163 // There are only 6 integer register arguments! | |
164 if ( ldarg.is_register() ) | |
165 __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register()); | |
166 else { | |
167 // Optimization, see if there are any more args and get out prior to checking | |
168 // all 16 float registers. My guess is that this is rare. | |
169 // If is_register is false, then we are done the first six integer args. | |
170 __ tst(G4_scratch); | |
171 __ brx(Assembler::zero, false, Assembler::pt, done); | |
172 __ delayed()->nop(); | |
173 | |
174 } | |
175 __ ba(false, NextArg); | |
176 __ delayed()->srl( G4_scratch, 2, G4_scratch ); | |
177 | |
178 __ bind(LoadFloatArg); | |
179 __ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4); | |
180 __ ba(false, NextArg); | |
181 __ delayed()->srl( G4_scratch, 2, G4_scratch ); | |
182 | |
183 __ bind(LoadDoubleArg); | |
184 __ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() ); | |
185 __ ba(false, NextArg); | |
186 __ delayed()->srl( G4_scratch, 2, G4_scratch ); | |
187 | |
188 __ bind(NextArg); | |
189 | |
190 } | |
191 | |
192 __ bind(done); | |
193 __ ret(); | |
194 __ delayed()-> | |
195 restore(O0, 0, Lscratch); // caller's Lscratch gets the result handler | |
196 return entry; | |
197 } | |
198 #endif | |
199 | |
200 void InterpreterGenerator::generate_counter_overflow(Label& Lcontinue) { | |
201 | |
202 // Generate code to initiate compilation on the counter overflow. | |
203 | |
204 // InterpreterRuntime::frequency_counter_overflow takes two arguments, | |
205 // the first indicates if the counter overflow occurs at a backwards branch (NULL bcp) | |
206 // and the second is only used when the first is true. We pass zero for both. | |
207 // The call returns the address of the verified entry point for the method or NULL | |
208 // if the compilation did not complete (either went background or bailed out). | |
209 __ set((int)false, O2); | |
210 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O2, O2, true); | |
211 // returns verified_entry_point or NULL | |
212 // we ignore it in any case | |
213 __ ba(false, Lcontinue); | |
214 __ delayed()->nop(); | |
215 | |
216 } | |
217 | |
218 | |
219 // End of helpers | |
220 | |
221 // Various method entries | |
222 | |
223 // Abstract method entry | |
224 // Attempt to execute abstract method. Throw exception | |
225 // | |
226 address InterpreterGenerator::generate_abstract_entry(void) { | |
227 address entry = __ pc(); | |
228 // abstract method entry | |
229 // throw exception | |
230 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError)); | |
231 // the call_VM checks for exception, so we should never return here. | |
232 __ should_not_reach_here(); | |
233 return entry; | |
234 | |
235 } | |
236 | |
237 | |
710 | 238 |
239 // Method handle invoker | |
240 // Dispatch a method of the form java.dyn.MethodHandles::invoke(...) | |
241 address InterpreterGenerator::generate_method_handle_entry(void) { | |
242 if (!EnableMethodHandles) { | |
243 return generate_abstract_entry(); | |
244 } | |
245 return generate_abstract_entry(); //6815692// | |
246 } | |
247 | |
248 | |
249 | |
250 | |
0 | 251 //---------------------------------------------------------------------------------------------------- |
252 // Entry points & stack frame layout | |
253 // | |
254 // Here we generate the various kind of entries into the interpreter. | |
255 // The two main entry type are generic bytecode methods and native call method. | |
256 // These both come in synchronized and non-synchronized versions but the | |
257 // frame layout they create is very similar. The other method entry | |
258 // types are really just special purpose entries that are really entry | |
259 // and interpretation all in one. These are for trivial methods like | |
260 // accessor, empty, or special math methods. | |
261 // | |
262 // When control flow reaches any of the entry types for the interpreter | |
263 // the following holds -> | |
264 // | |
265 // C2 Calling Conventions: | |
266 // | |
267 // The entry code below assumes that the following registers are set | |
268 // when coming in: | |
269 // G5_method: holds the methodOop of the method to call | |
270 // Lesp: points to the TOS of the callers expression stack | |
271 // after having pushed all the parameters | |
272 // | |
273 // The entry code does the following to setup an interpreter frame | |
274 // pop parameters from the callers stack by adjusting Lesp | |
275 // set O0 to Lesp | |
276 // compute X = (max_locals - num_parameters) | |
277 // bump SP up by X to accomadate the extra locals | |
278 // compute X = max_expression_stack | |
279 // + vm_local_words | |
280 // + 16 words of register save area | |
281 // save frame doing a save sp, -X, sp growing towards lower addresses | |
282 // set Lbcp, Lmethod, LcpoolCache | |
283 // set Llocals to i0 | |
284 // set Lmonitors to FP - rounded_vm_local_words | |
285 // set Lesp to Lmonitors - 4 | |
286 // | |
287 // The frame has now been setup to do the rest of the entry code | |
288 | |
289 // Try this optimization: Most method entries could live in a | |
290 // "one size fits all" stack frame without all the dynamic size | |
291 // calculations. It might be profitable to do all this calculation | |
292 // statically and approximately for "small enough" methods. | |
293 | |
294 //----------------------------------------------------------------------------------------------- | |
295 | |
296 // C1 Calling conventions | |
297 // | |
298 // Upon method entry, the following registers are setup: | |
299 // | |
300 // g2 G2_thread: current thread | |
301 // g5 G5_method: method to activate | |
302 // g4 Gargs : pointer to last argument | |
303 // | |
304 // | |
305 // Stack: | |
306 // | |
307 // +---------------+ <--- sp | |
308 // | | | |
309 // : reg save area : | |
310 // | | | |
311 // +---------------+ <--- sp + 0x40 | |
312 // | | | |
313 // : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) | |
314 // | | | |
315 // +---------------+ <--- sp + 0x5c | |
316 // | | | |
317 // : free : | |
318 // | | | |
319 // +---------------+ <--- Gargs | |
320 // | | | |
321 // : arguments : | |
322 // | | | |
323 // +---------------+ | |
324 // | | | |
325 // | |
326 // | |
327 // | |
328 // AFTER FRAME HAS BEEN SETUP for method interpretation the stack looks like: | |
329 // | |
330 // +---------------+ <--- sp | |
331 // | | | |
332 // : reg save area : | |
333 // | | | |
334 // +---------------+ <--- sp + 0x40 | |
335 // | | | |
336 // : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) | |
337 // | | | |
338 // +---------------+ <--- sp + 0x5c | |
339 // | | | |
340 // : : | |
341 // | | <--- Lesp | |
342 // +---------------+ <--- Lmonitors (fp - 0x18) | |
343 // | VM locals | | |
344 // +---------------+ <--- fp | |
345 // | | | |
346 // : reg save area : | |
347 // | | | |
348 // +---------------+ <--- fp + 0x40 | |
349 // | | | |
350 // : extra 7 slots : note: these slots are not really needed for the interpreter (fix later) | |
351 // | | | |
352 // +---------------+ <--- fp + 0x5c | |
353 // | | | |
354 // : free : | |
355 // | | | |
356 // +---------------+ | |
357 // | | | |
358 // : nonarg locals : | |
359 // | | | |
360 // +---------------+ | |
361 // | | | |
362 // : arguments : | |
363 // | | <--- Llocals | |
364 // +---------------+ <--- Gargs | |
365 // | | | |
366 | |
367 address AbstractInterpreterGenerator::generate_method_entry(AbstractInterpreter::MethodKind kind) { | |
368 // determine code generation flags | |
369 bool synchronized = false; | |
370 address entry_point = NULL; | |
371 | |
372 switch (kind) { | |
373 case Interpreter::zerolocals : break; | |
374 case Interpreter::zerolocals_synchronized: synchronized = true; break; | |
375 case Interpreter::native : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false); break; | |
376 case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true); break; | |
377 case Interpreter::empty : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry(); break; | |
378 case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break; | |
379 case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break; | |
710 | 380 case Interpreter::method_handle : entry_point = ((InterpreterGenerator*)this)->generate_method_handle_entry(); break; |
0 | 381 case Interpreter::java_lang_math_sin : break; |
382 case Interpreter::java_lang_math_cos : break; | |
383 case Interpreter::java_lang_math_tan : break; | |
384 case Interpreter::java_lang_math_sqrt : break; | |
385 case Interpreter::java_lang_math_abs : break; | |
386 case Interpreter::java_lang_math_log : break; | |
387 case Interpreter::java_lang_math_log10 : break; | |
388 default : ShouldNotReachHere(); break; | |
389 } | |
390 | |
391 if (entry_point) return entry_point; | |
392 | |
393 return ((InterpreterGenerator*)this)->generate_normal_entry(synchronized); | |
394 } | |
395 | |
396 | |
1174
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
397 bool AbstractInterpreter::can_be_compiled(methodHandle m) { |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
398 // No special entry points that preclude compilation |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
399 return true; |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
400 } |
ddb7834449d0
6849984: Value methods for platform dependent math functions constant fold incorrectly
never
parents:
710
diff
changeset
|
401 |
0 | 402 // This method tells the deoptimizer how big an interpreted frame must be: |
403 int AbstractInterpreter::size_activation(methodOop method, | |
404 int tempcount, | |
405 int popframe_extra_args, | |
406 int moncount, | |
407 int callee_param_count, | |
408 int callee_locals, | |
409 bool is_top_frame) { | |
410 return layout_activation(method, | |
411 tempcount, | |
412 popframe_extra_args, | |
413 moncount, | |
414 callee_param_count, | |
415 callee_locals, | |
416 (frame*)NULL, | |
417 (frame*)NULL, | |
418 is_top_frame); | |
419 } | |
420 | |
421 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) { | |
422 | |
423 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in | |
424 // the days we had adapter frames. When we deoptimize a situation where a | |
425 // compiled caller calls a compiled caller will have registers it expects | |
426 // to survive the call to the callee. If we deoptimize the callee the only | |
427 // way we can restore these registers is to have the oldest interpreter | |
428 // frame that we create restore these values. That is what this routine | |
429 // will accomplish. | |
430 | |
431 // At the moment we have modified c2 to not have any callee save registers | |
432 // so this problem does not exist and this routine is just a place holder. | |
433 | |
434 assert(f->is_interpreted_frame(), "must be interpreted"); | |
435 } | |
436 | |
437 | |
438 //---------------------------------------------------------------------------------------------------- | |
439 // Exceptions |