Mercurial > hg > graal-jvmci-8
annotate src/cpu/sparc/vm/cppInterpreter_sparc.cpp @ 24183:db221c0a423e jdk8u131-b08
Added tag jdk8u131-b07 for changeset 5b3cb4fbdbc7
author | asaha |
---|---|
date | Mon, 13 Feb 2017 11:58:54 -0800 |
parents | 32b682649973 |
children |
rev | line source |
---|---|
0 | 1 /* |
23614 | 2 * Copyright (c) 2007, 2016, 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:
710
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
710
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:
710
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | |
27 #include "interpreter/bytecodeHistogram.hpp" | |
28 #include "interpreter/cppInterpreter.hpp" | |
29 #include "interpreter/interpreter.hpp" | |
30 #include "interpreter/interpreterGenerator.hpp" | |
31 #include "interpreter/interpreterRuntime.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 "runtime/arguments.hpp" | |
39 #include "runtime/deoptimization.hpp" | |
40 #include "runtime/frame.inline.hpp" | |
41 #include "runtime/interfaceSupport.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" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7476
diff
changeset
|
48 #include "utilities/macros.hpp" |
1972 | 49 #ifdef SHARK |
50 #include "shark/shark_globals.hpp" | |
51 #endif | |
0 | 52 |
53 #ifdef CC_INTERP | |
54 | |
55 // Routine exists to make tracebacks look decent in debugger | |
56 // while "shadow" interpreter frames are on stack. It is also | |
57 // used to distinguish interpreter frames. | |
58 | |
59 extern "C" void RecursiveInterpreterActivation(interpreterState istate) { | |
60 ShouldNotReachHere(); | |
61 } | |
62 | |
63 bool CppInterpreter::contains(address pc) { | |
64 return ( _code->contains(pc) || | |
65 ( pc == (CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation) + frame::pc_return_offset))); | |
66 } | |
67 | |
68 #define STATE(field_name) Lstate, in_bytes(byte_offset_of(BytecodeInterpreter, field_name)) | |
69 #define __ _masm-> | |
70 | |
71 Label frame_manager_entry; | |
72 Label fast_accessor_slow_entry_path; // fast accessor methods need to be able to jmp to unsynchronized | |
73 // c++ interpreter entry point this holds that entry point label. | |
74 | |
75 static address unctrap_frame_manager_entry = NULL; | |
76 | |
77 static address interpreter_return_address = NULL; | |
78 static address deopt_frame_manager_return_atos = NULL; | |
79 static address deopt_frame_manager_return_btos = NULL; | |
80 static address deopt_frame_manager_return_itos = NULL; | |
81 static address deopt_frame_manager_return_ltos = NULL; | |
82 static address deopt_frame_manager_return_ftos = NULL; | |
83 static address deopt_frame_manager_return_dtos = NULL; | |
84 static address deopt_frame_manager_return_vtos = NULL; | |
85 | |
86 const Register prevState = G1_scratch; | |
87 | |
88 void InterpreterGenerator::save_native_result(void) { | |
89 // result potentially in O0/O1: save it across calls | |
90 __ stf(FloatRegisterImpl::D, F0, STATE(_native_fresult)); | |
91 #ifdef _LP64 | |
92 __ stx(O0, STATE(_native_lresult)); | |
93 #else | |
94 __ std(O0, STATE(_native_lresult)); | |
95 #endif | |
96 } | |
97 | |
98 void InterpreterGenerator::restore_native_result(void) { | |
99 | |
100 // Restore any method result value | |
101 __ ldf(FloatRegisterImpl::D, STATE(_native_fresult), F0); | |
102 #ifdef _LP64 | |
103 __ ldx(STATE(_native_lresult), O0); | |
104 #else | |
105 __ ldd(STATE(_native_lresult), O0); | |
106 #endif | |
107 } | |
108 | |
109 // A result handler converts/unboxes a native call result into | |
110 // a java interpreter/compiler result. The current frame is an | |
111 // interpreter frame. The activation frame unwind code must be | |
112 // consistent with that of TemplateTable::_return(...). In the | |
113 // case of native methods, the caller's SP was not modified. | |
114 address CppInterpreterGenerator::generate_result_handler_for(BasicType type) { | |
115 address entry = __ pc(); | |
116 Register Itos_i = Otos_i ->after_save(); | |
117 Register Itos_l = Otos_l ->after_save(); | |
118 Register Itos_l1 = Otos_l1->after_save(); | |
119 Register Itos_l2 = Otos_l2->after_save(); | |
120 switch (type) { | |
121 case T_BOOLEAN: __ subcc(G0, O0, G0); __ addc(G0, 0, Itos_i); break; // !0 => true; 0 => false | |
122 case T_CHAR : __ sll(O0, 16, O0); __ srl(O0, 16, Itos_i); break; // cannot use and3, 0xFFFF too big as immediate value! | |
123 case T_BYTE : __ sll(O0, 24, O0); __ sra(O0, 24, Itos_i); break; | |
124 case T_SHORT : __ sll(O0, 16, O0); __ sra(O0, 16, Itos_i); break; | |
125 case T_LONG : | |
126 #ifndef _LP64 | |
127 __ mov(O1, Itos_l2); // move other half of long | |
128 #endif // ifdef or no ifdef, fall through to the T_INT case | |
129 case T_INT : __ mov(O0, Itos_i); break; | |
130 case T_VOID : /* nothing to do */ break; | |
131 case T_FLOAT : assert(F0 == Ftos_f, "fix this code" ); break; | |
132 case T_DOUBLE : assert(F0 == Ftos_d, "fix this code" ); break; | |
133 case T_OBJECT : | |
134 __ ld_ptr(STATE(_oop_temp), Itos_i); | |
135 __ verify_oop(Itos_i); | |
136 break; | |
137 default : ShouldNotReachHere(); | |
138 } | |
139 __ ret(); // return from interpreter activation | |
140 __ delayed()->restore(I5_savedSP, G0, SP); // remove interpreter frame | |
7476
ffa87474d7a4
8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents:
7402
diff
changeset
|
141 NOT_PRODUCT(__ emit_int32(0);) // marker for disassembly |
0 | 142 return entry; |
143 } | |
144 | |
145 // tosca based result to c++ interpreter stack based result. | |
146 // Result goes to address in L1_scratch | |
147 | |
148 address CppInterpreterGenerator::generate_tosca_to_stack_converter(BasicType type) { | |
149 // A result is in the native abi result register from a native method call. | |
150 // We need to return this result to the interpreter by pushing the result on the interpreter's | |
151 // stack. This is relatively simple the destination is in L1_scratch | |
152 // i.e. L1_scratch is the first free element on the stack. If we "push" a return value we must | |
153 // adjust L1_scratch | |
154 address entry = __ pc(); | |
155 switch (type) { | |
156 case T_BOOLEAN: | |
157 // !0 => true; 0 => false | |
158 __ subcc(G0, O0, G0); | |
159 __ addc(G0, 0, O0); | |
160 __ st(O0, L1_scratch, 0); | |
161 __ sub(L1_scratch, wordSize, L1_scratch); | |
162 break; | |
163 | |
164 // cannot use and3, 0xFFFF too big as immediate value! | |
165 case T_CHAR : | |
166 __ sll(O0, 16, O0); | |
167 __ srl(O0, 16, O0); | |
168 __ st(O0, L1_scratch, 0); | |
169 __ sub(L1_scratch, wordSize, L1_scratch); | |
170 break; | |
171 | |
172 case T_BYTE : | |
173 __ sll(O0, 24, O0); | |
174 __ sra(O0, 24, O0); | |
175 __ st(O0, L1_scratch, 0); | |
176 __ sub(L1_scratch, wordSize, L1_scratch); | |
177 break; | |
178 | |
179 case T_SHORT : | |
180 __ sll(O0, 16, O0); | |
181 __ sra(O0, 16, O0); | |
182 __ st(O0, L1_scratch, 0); | |
183 __ sub(L1_scratch, wordSize, L1_scratch); | |
184 break; | |
185 case T_LONG : | |
186 #ifndef _LP64 | |
123 | 187 #if defined(COMPILER2) |
0 | 188 // All return values are where we want them, except for Longs. C2 returns |
189 // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1. | |
190 // Since the interpreter will return longs in G1 and O0/O1 in the 32bit | |
191 // build even if we are returning from interpreted we just do a little | |
192 // stupid shuffing. | |
193 // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to | |
194 // do this here. Unfortunately if we did a rethrow we'd see an machepilog node | |
195 // first which would move g1 -> O0/O1 and destroy the exception we were throwing. | |
196 __ stx(G1, L1_scratch, -wordSize); | |
197 #else | |
198 // native result is in O0, O1 | |
199 __ st(O1, L1_scratch, 0); // Low order | |
200 __ st(O0, L1_scratch, -wordSize); // High order | |
123 | 201 #endif /* COMPILER2 */ |
0 | 202 #else |
123 | 203 __ stx(O0, L1_scratch, -wordSize); |
0 | 204 #endif |
205 __ sub(L1_scratch, 2*wordSize, L1_scratch); | |
206 break; | |
207 | |
208 case T_INT : | |
209 __ st(O0, L1_scratch, 0); | |
210 __ sub(L1_scratch, wordSize, L1_scratch); | |
211 break; | |
212 | |
213 case T_VOID : /* nothing to do */ | |
214 break; | |
215 | |
216 case T_FLOAT : | |
217 __ stf(FloatRegisterImpl::S, F0, L1_scratch, 0); | |
218 __ sub(L1_scratch, wordSize, L1_scratch); | |
219 break; | |
220 | |
221 case T_DOUBLE : | |
222 // Every stack slot is aligned on 64 bit, However is this | |
223 // the correct stack slot on 64bit?? QQQ | |
224 __ stf(FloatRegisterImpl::D, F0, L1_scratch, -wordSize); | |
225 __ sub(L1_scratch, 2*wordSize, L1_scratch); | |
226 break; | |
227 case T_OBJECT : | |
228 __ verify_oop(O0); | |
229 __ st_ptr(O0, L1_scratch, 0); | |
230 __ sub(L1_scratch, wordSize, L1_scratch); | |
231 break; | |
232 default : ShouldNotReachHere(); | |
233 } | |
234 __ retl(); // return from interpreter activation | |
235 __ delayed()->nop(); // schedule this better | |
7476
ffa87474d7a4
8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents:
7402
diff
changeset
|
236 NOT_PRODUCT(__ emit_int32(0);) // marker for disassembly |
0 | 237 return entry; |
238 } | |
239 | |
240 address CppInterpreterGenerator::generate_stack_to_stack_converter(BasicType type) { | |
241 // A result is in the java expression stack of the interpreted method that has just | |
242 // returned. Place this result on the java expression stack of the caller. | |
243 // | |
244 // The current interpreter activation in Lstate is for the method just returning its | |
245 // result. So we know that the result of this method is on the top of the current | |
246 // execution stack (which is pre-pushed) and will be return to the top of the caller | |
247 // stack. The top of the callers stack is the bottom of the locals of the current | |
248 // activation. | |
249 // Because of the way activation are managed by the frame manager the value of esp is | |
250 // below both the stack top of the current activation and naturally the stack top | |
251 // of the calling activation. This enable this routine to leave the return address | |
252 // to the frame manager on the stack and do a vanilla return. | |
253 // | |
254 // On entry: O0 - points to source (callee stack top) | |
255 // O1 - points to destination (caller stack top [i.e. free location]) | |
256 // destroys O2, O3 | |
257 // | |
258 | |
259 address entry = __ pc(); | |
260 switch (type) { | |
261 case T_VOID: break; | |
262 break; | |
263 case T_FLOAT : | |
264 case T_BOOLEAN: | |
265 case T_CHAR : | |
266 case T_BYTE : | |
267 case T_SHORT : | |
268 case T_INT : | |
269 // 1 word result | |
270 __ ld(O0, 0, O2); | |
271 __ st(O2, O1, 0); | |
272 __ sub(O1, wordSize, O1); | |
273 break; | |
274 case T_DOUBLE : | |
275 case T_LONG : | |
276 // return top two words on current expression stack to caller's expression stack | |
277 // The caller's expression stack is adjacent to the current frame manager's intepretState | |
278 // except we allocated one extra word for this intepretState so we won't overwrite it | |
279 // when we return a two word result. | |
280 #ifdef _LP64 | |
281 __ ld_ptr(O0, 0, O2); | |
282 __ st_ptr(O2, O1, -wordSize); | |
283 #else | |
284 __ ld(O0, 0, O2); | |
285 __ ld(O0, wordSize, O3); | |
286 __ st(O3, O1, 0); | |
287 __ st(O2, O1, -wordSize); | |
288 #endif | |
289 __ sub(O1, 2*wordSize, O1); | |
290 break; | |
291 case T_OBJECT : | |
292 __ ld_ptr(O0, 0, O2); | |
293 __ verify_oop(O2); // verify it | |
294 __ st_ptr(O2, O1, 0); | |
295 __ sub(O1, wordSize, O1); | |
296 break; | |
297 default : ShouldNotReachHere(); | |
298 } | |
299 __ retl(); | |
300 __ delayed()->nop(); // QQ schedule this better | |
301 return entry; | |
302 } | |
303 | |
304 address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicType type) { | |
305 // A result is in the java expression stack of the interpreted method that has just | |
306 // returned. Place this result in the native abi that the caller expects. | |
307 // We are in a new frame registers we set must be in caller (i.e. callstub) frame. | |
308 // | |
309 // Similar to generate_stack_to_stack_converter above. Called at a similar time from the | |
310 // frame manager execept in this situation the caller is native code (c1/c2/call_stub) | |
311 // and so rather than return result onto caller's java expression stack we return the | |
312 // result in the expected location based on the native abi. | |
313 // On entry: O0 - source (stack top) | |
314 // On exit result in expected output register | |
315 // QQQ schedule this better | |
316 | |
317 address entry = __ pc(); | |
318 switch (type) { | |
319 case T_VOID: break; | |
320 break; | |
321 case T_FLOAT : | |
322 __ ldf(FloatRegisterImpl::S, O0, 0, F0); | |
323 break; | |
324 case T_BOOLEAN: | |
325 case T_CHAR : | |
326 case T_BYTE : | |
327 case T_SHORT : | |
328 case T_INT : | |
329 // 1 word result | |
330 __ ld(O0, 0, O0->after_save()); | |
331 break; | |
332 case T_DOUBLE : | |
333 __ ldf(FloatRegisterImpl::D, O0, 0, F0); | |
334 break; | |
335 case T_LONG : | |
336 // return top two words on current expression stack to caller's expression stack | |
337 // The caller's expression stack is adjacent to the current frame manager's interpretState | |
338 // except we allocated one extra word for this intepretState so we won't overwrite it | |
339 // when we return a two word result. | |
340 #ifdef _LP64 | |
341 __ ld_ptr(O0, 0, O0->after_save()); | |
342 #else | |
343 __ ld(O0, wordSize, O1->after_save()); | |
344 __ ld(O0, 0, O0->after_save()); | |
345 #endif | |
346 #if defined(COMPILER2) && !defined(_LP64) | |
347 // C2 expects long results in G1 we can't tell if we're returning to interpreted | |
348 // or compiled so just be safe use G1 and O0/O1 | |
349 | |
350 // Shift bits into high (msb) of G1 | |
351 __ sllx(Otos_l1->after_save(), 32, G1); | |
352 // Zero extend low bits | |
353 __ srl (Otos_l2->after_save(), 0, Otos_l2->after_save()); | |
354 __ or3 (Otos_l2->after_save(), G1, G1); | |
355 #endif /* COMPILER2 */ | |
356 break; | |
357 case T_OBJECT : | |
358 __ ld_ptr(O0, 0, O0->after_save()); | |
359 __ verify_oop(O0->after_save()); // verify it | |
360 break; | |
361 default : ShouldNotReachHere(); | |
362 } | |
363 __ retl(); | |
364 __ delayed()->nop(); | |
365 return entry; | |
366 } | |
367 | |
13010
bd3237e0e18d
8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents:
10393
diff
changeset
|
368 address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { |
0 | 369 // make it look good in the debugger |
370 return CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation) + frame::pc_return_offset; | |
371 } | |
372 | |
373 address CppInterpreter::deopt_entry(TosState state, int length) { | |
374 address ret = NULL; | |
375 if (length != 0) { | |
376 switch (state) { | |
377 case atos: ret = deopt_frame_manager_return_atos; break; | |
378 case btos: ret = deopt_frame_manager_return_btos; break; | |
379 case ctos: | |
380 case stos: | |
381 case itos: ret = deopt_frame_manager_return_itos; break; | |
382 case ltos: ret = deopt_frame_manager_return_ltos; break; | |
383 case ftos: ret = deopt_frame_manager_return_ftos; break; | |
384 case dtos: ret = deopt_frame_manager_return_dtos; break; | |
385 case vtos: ret = deopt_frame_manager_return_vtos; break; | |
386 } | |
387 } else { | |
388 ret = unctrap_frame_manager_entry; // re-execute the bytecode ( e.g. uncommon trap) | |
389 } | |
390 assert(ret != NULL, "Not initialized"); | |
391 return ret; | |
392 } | |
393 | |
394 // | |
395 // Helpers for commoning out cases in the various type of method entries. | |
396 // | |
397 | |
398 // increment invocation count & check for overflow | |
399 // | |
400 // Note: checking for negative value instead of overflow | |
401 // so we have a 'sticky' overflow test | |
402 // | |
403 // Lmethod: method | |
404 // ??: invocation counter | |
405 // | |
406 void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) { | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
407 Label done; |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
408 const Register Rcounters = G3_scratch; |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
409 |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
410 __ ld_ptr(STATE(_method), G5_method); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
411 __ get_method_counters(G5_method, Rcounters, done); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
412 |
0 | 413 // Update standard invocation counters |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
414 __ increment_invocation_counter(Rcounters, O0, G4_scratch); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
415 if (ProfileInterpreter) { |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
416 Address interpreter_invocation_counter(Rcounters, 0, |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
417 in_bytes(MethodCounters::interpreter_invocation_counter_offset())); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
418 __ ld(interpreter_invocation_counter, G4_scratch); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
419 __ inc(G4_scratch); |
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
420 __ st(G4_scratch, interpreter_invocation_counter); |
0 | 421 } |
422 | |
423 Address invocation_limit(G3_scratch, (address)&InvocationCounter::InterpreterInvocationLimit); | |
424 __ sethi(invocation_limit); | |
425 __ ld(invocation_limit, G3_scratch); | |
426 __ cmp(O0, G3_scratch); | |
427 __ br(Assembler::greaterEqualUnsigned, false, Assembler::pn, *overflow); | |
428 __ delayed()->nop(); | |
10105
aeaca88565e6
8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents:
8727
diff
changeset
|
429 __ bind(done); |
0 | 430 } |
431 | |
432 address InterpreterGenerator::generate_empty_entry(void) { | |
433 | |
434 // A method that does nothing but return... | |
435 | |
436 address entry = __ pc(); | |
437 Label slow_path; | |
438 | |
439 // do nothing for empty methods (do not even increment invocation counter) | |
440 if ( UseFastEmptyMethods) { | |
441 // If we need a safepoint check, generate full interpreter entry. | |
442 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); | |
443 __ load_contents(sync_state, G3_scratch); | |
444 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); | |
445 __ br(Assembler::notEqual, false, Assembler::pn, frame_manager_entry); | |
446 __ delayed()->nop(); | |
447 | |
448 // Code: _return | |
449 __ retl(); | |
450 __ delayed()->mov(O5_savedSP, SP); | |
451 return entry; | |
452 } | |
453 return NULL; | |
454 } | |
455 | |
456 // Call an accessor method (assuming it is resolved, otherwise drop into | |
457 // vanilla (slow path) entry | |
458 | |
459 // Generates code to elide accessor methods | |
460 // Uses G3_scratch and G1_scratch as scratch | |
461 address InterpreterGenerator::generate_accessor_entry(void) { | |
462 | |
463 // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; | |
464 // parameter size = 1 | |
465 // Note: We can only use this code if the getfield has been resolved | |
466 // and if we don't have a null-pointer exception => check for | |
467 // these conditions first and use slow path if necessary. | |
468 address entry = __ pc(); | |
469 Label slow_path; | |
470 | |
471 if ( UseFastAccessorMethods) { | |
472 // Check if we need to reach a safepoint and generate full interpreter | |
473 // frame if so. | |
474 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); | |
475 __ load_contents(sync_state, G3_scratch); | |
476 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); | |
477 __ br(Assembler::notEqual, false, Assembler::pn, slow_path); | |
478 __ delayed()->nop(); | |
479 | |
480 // Check if local 0 != NULL | |
481 __ ld_ptr(Gargs, G0, Otos_i ); // get local 0 | |
482 __ tst(Otos_i); // check if local 0 == NULL and go the slow path | |
483 __ brx(Assembler::zero, false, Assembler::pn, slow_path); | |
484 __ delayed()->nop(); | |
485 | |
486 | |
487 // read first instruction word and extract bytecode @ 1 and index @ 2 | |
488 // get first 4 bytes of the bytecodes (big endian!) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
489 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::const_offset())), G1_scratch); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
490 __ ld(Address(G1_scratch, 0, in_bytes(ConstMethod::codes_offset())), G1_scratch); |
0 | 491 |
492 // move index @ 2 far left then to the right most two bytes. | |
493 __ sll(G1_scratch, 2*BitsPerByte, G1_scratch); | |
494 __ srl(G1_scratch, 2*BitsPerByte - exact_log2(in_words( | |
495 ConstantPoolCacheEntry::size()) * BytesPerWord), G1_scratch); | |
496 | |
497 // get constant pool cache | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
498 __ ld_ptr(G5_method, in_bytes(Method::const_offset()), G3_scratch); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
499 __ ld_ptr(G3_scratch, in_bytes(ConstMethod::constants_offset()), G3_scratch); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
500 __ ld_ptr(G3_scratch, ConstantPool::cache_offset_in_bytes(), G3_scratch); |
0 | 501 |
502 // get specific constant pool cache entry | |
503 __ add(G3_scratch, G1_scratch, G3_scratch); | |
504 | |
505 // Check the constant Pool cache entry to see if it has been resolved. | |
506 // If not, need the slow path. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
507 ByteSize cp_base_offset = ConstantPoolCache::base_offset(); |
0 | 508 __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::indices_offset()), G1_scratch); |
509 __ srl(G1_scratch, 2*BitsPerByte, G1_scratch); | |
510 __ and3(G1_scratch, 0xFF, G1_scratch); | |
511 __ cmp(G1_scratch, Bytecodes::_getfield); | |
512 __ br(Assembler::notEqual, false, Assembler::pn, slow_path); | |
513 __ delayed()->nop(); | |
514 | |
515 // Get the type and return field offset from the constant pool cache | |
516 __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::flags_offset()), G1_scratch); | |
517 __ ld_ptr(G3_scratch, in_bytes(cp_base_offset + ConstantPoolCacheEntry::f2_offset()), G3_scratch); | |
518 | |
519 Label xreturn_path; | |
520 // Need to differentiate between igetfield, agetfield, bgetfield etc. | |
521 // because they are different sizes. | |
522 // Get the type from the constant pool cache | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
523 __ srl(G1_scratch, ConstantPoolCacheEntry::tos_state_shift, G1_scratch); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
524 // Make sure we don't need to mask G1_scratch after the above shift |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6123
diff
changeset
|
525 ConstantPoolCacheEntry::verify_tos_state_shift(); |
0 | 526 __ cmp(G1_scratch, atos ); |
527 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
528 __ delayed()->ld_ptr(Otos_i, G3_scratch, Otos_i); | |
529 __ cmp(G1_scratch, itos); | |
530 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
531 __ delayed()->ld(Otos_i, G3_scratch, Otos_i); | |
532 __ cmp(G1_scratch, stos); | |
533 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
534 __ delayed()->ldsh(Otos_i, G3_scratch, Otos_i); | |
535 __ cmp(G1_scratch, ctos); | |
536 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
537 __ delayed()->lduh(Otos_i, G3_scratch, Otos_i); | |
538 #ifdef ASSERT | |
539 __ cmp(G1_scratch, btos); | |
540 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
541 __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i); | |
23614 | 542 __ cmp(G1_scratch, ztos); |
543 __ br(Assembler::equal, true, Assembler::pt, xreturn_path); | |
544 __ delayed()->ldsb(Otos_i, G3_scratch, Otos_i); | |
0 | 545 __ should_not_reach_here(); |
546 #endif | |
547 __ ldsb(Otos_i, G3_scratch, Otos_i); | |
548 __ bind(xreturn_path); | |
549 | |
550 // _ireturn/_areturn | |
551 __ retl(); // return from leaf routine | |
552 __ delayed()->mov(O5_savedSP, SP); | |
553 | |
554 // Generate regular method entry | |
555 __ bind(slow_path); | |
3839 | 556 __ ba(fast_accessor_slow_entry_path); |
0 | 557 __ delayed()->nop(); |
558 return entry; | |
559 } | |
560 return NULL; | |
561 } | |
562 | |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
563 address InterpreterGenerator::generate_Reference_get_entry(void) { |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7476
diff
changeset
|
564 #if INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
565 if (UseG1GC) { |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
566 // We need to generate have a routine that generates code to: |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
567 // * load the value in the referent field |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
568 // * passes that value to the pre-barrier. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
569 // |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
570 // In the case of G1 this will record the value of the |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
571 // referent in an SATB buffer if marking is active. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
572 // This will cause concurrent marking to mark the referent |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
573 // field as live. |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
574 Unimplemented(); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
575 } |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7476
diff
changeset
|
576 #endif // INCLUDE_ALL_GCS |
3249
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
577 |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
578 // If G1 is not enabled then attempt to go through the accessor entry point |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
579 // Reference.get is an accessor |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
580 return generate_accessor_entry(); |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
581 } |
e1162778c1c8
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
2357
diff
changeset
|
582 |
0 | 583 // |
584 // Interpreter stub for calling a native method. (C++ interpreter) | |
585 // This sets up a somewhat different looking stack for calling the native method | |
586 // than the typical interpreter frame setup. | |
587 // | |
588 | |
589 address InterpreterGenerator::generate_native_entry(bool synchronized) { | |
590 address entry = __ pc(); | |
591 | |
592 // the following temporary registers are used during frame creation | |
593 const Register Gtmp1 = G3_scratch ; | |
594 const Register Gtmp2 = G1_scratch; | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
595 const Register RconstMethod = Gtmp1; |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
596 const Address constMethod(G5_method, 0, in_bytes(Method::const_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
597 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); |
0 | 598 |
599 bool inc_counter = UseCompiler || CountCompiledCalls; | |
600 | |
601 // make sure registers are different! | |
602 assert_different_registers(G2_thread, G5_method, Gargs, Gtmp1, Gtmp2); | |
603 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
604 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); |
0 | 605 |
606 Label Lentry; | |
607 __ bind(Lentry); | |
608 | |
609 const Register Glocals_size = G3; | |
610 assert_different_registers(Glocals_size, G4_scratch, Gframe_size); | |
611 | |
612 // make sure method is native & not abstract | |
613 // rethink these assertions - they can be simplified and shared (gri 2/25/2000) | |
614 #ifdef ASSERT | |
615 __ ld(access_flags, Gtmp1); | |
616 { | |
617 Label L; | |
618 __ btst(JVM_ACC_NATIVE, Gtmp1); | |
619 __ br(Assembler::notZero, false, Assembler::pt, L); | |
620 __ delayed()->nop(); | |
621 __ stop("tried to execute non-native method as native"); | |
622 __ bind(L); | |
623 } | |
624 { Label L; | |
625 __ btst(JVM_ACC_ABSTRACT, Gtmp1); | |
626 __ br(Assembler::zero, false, Assembler::pt, L); | |
627 __ delayed()->nop(); | |
628 __ stop("tried to execute abstract method as non-abstract"); | |
629 __ bind(L); | |
630 } | |
631 #endif // ASSERT | |
632 | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
633 __ ld_ptr(constMethod, RconstMethod); |
0 | 634 __ lduh(size_of_parameters, Gtmp1); |
635 __ sll(Gtmp1, LogBytesPerWord, Gtmp2); // parameter size in bytes | |
636 __ add(Gargs, Gtmp2, Gargs); // points to first local + BytesPerWord | |
637 // NEW | |
638 __ add(Gargs, -wordSize, Gargs); // points to first local[0] | |
639 // generate the code to allocate the interpreter stack frame | |
640 // NEW FRAME ALLOCATED HERE | |
641 // save callers original sp | |
642 // __ mov(SP, I5_savedSP->after_restore()); | |
643 | |
644 generate_compute_interpreter_state(Lstate, G0, true); | |
645 | |
646 // At this point Lstate points to new interpreter state | |
647 // | |
648 | |
649 const Address do_not_unlock_if_synchronized(G2_thread, 0, | |
650 in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); | |
651 // Since at this point in the method invocation the exception handler | |
652 // would try to exit the monitor of synchronized methods which hasn't | |
653 // been entered yet, we set the thread local variable | |
654 // _do_not_unlock_if_synchronized to true. If any exception was thrown by | |
655 // runtime, exception handling i.e. unlock_if_synchronized_method will | |
656 // check this thread local flag. | |
657 // This flag has two effects, one is to force an unwind in the topmost | |
658 // interpreter frame and not perform an unlock while doing so. | |
659 | |
660 __ movbool(true, G3_scratch); | |
661 __ stbool(G3_scratch, do_not_unlock_if_synchronized); | |
662 | |
663 | |
664 // increment invocation counter and check for overflow | |
665 // | |
666 // Note: checking for negative value instead of overflow | |
667 // so we have a 'sticky' overflow test (may be of | |
668 // importance as soon as we have true MT/MP) | |
669 Label invocation_counter_overflow; | |
670 if (inc_counter) { | |
671 generate_counter_incr(&invocation_counter_overflow, NULL, NULL); | |
672 } | |
673 Label Lcontinue; | |
674 __ bind(Lcontinue); | |
675 | |
676 bang_stack_shadow_pages(true); | |
677 // reset the _do_not_unlock_if_synchronized flag | |
678 __ stbool(G0, do_not_unlock_if_synchronized); | |
679 | |
680 // check for synchronized methods | |
681 // Must happen AFTER invocation_counter check, so method is not locked | |
682 // if counter overflows. | |
683 | |
684 if (synchronized) { | |
685 lock_method(); | |
686 // Don't see how G2_thread is preserved here... | |
687 // __ verify_thread(); QQQ destroys L0,L1 can't use | |
688 } else { | |
689 #ifdef ASSERT | |
690 { Label ok; | |
691 __ ld_ptr(STATE(_method), G5_method); | |
692 __ ld(access_flags, O0); | |
693 __ btst(JVM_ACC_SYNCHRONIZED, O0); | |
694 __ br( Assembler::zero, false, Assembler::pt, ok); | |
695 __ delayed()->nop(); | |
696 __ stop("method needs synchronization"); | |
697 __ bind(ok); | |
698 } | |
699 #endif // ASSERT | |
700 } | |
701 | |
702 // start execution | |
703 | |
704 // __ verify_thread(); kills L1,L2 can't use at the moment | |
705 | |
706 // jvmti/jvmpi support | |
707 __ notify_method_entry(); | |
708 | |
709 // native call | |
710 | |
711 // (note that O0 is never an oop--at most it is a handle) | |
712 // It is important not to smash any handles created by this call, | |
713 // until any oop handle in O0 is dereferenced. | |
714 | |
715 // (note that the space for outgoing params is preallocated) | |
716 | |
717 // get signature handler | |
718 | |
719 Label pending_exception_present; | |
720 | |
721 { Label L; | |
722 __ ld_ptr(STATE(_method), G5_method); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
723 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::signature_handler_offset())), G3_scratch); |
0 | 724 __ tst(G3_scratch); |
725 __ brx(Assembler::notZero, false, Assembler::pt, L); | |
726 __ delayed()->nop(); | |
727 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::prepare_native_call), G5_method, false); | |
728 __ ld_ptr(STATE(_method), G5_method); | |
729 | |
730 Address exception_addr(G2_thread, 0, in_bytes(Thread::pending_exception_offset())); | |
731 __ ld_ptr(exception_addr, G3_scratch); | |
3839 | 732 __ br_notnull_short(G3_scratch, Assembler::pn, pending_exception_present); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
733 __ ld_ptr(Address(G5_method, 0, in_bytes(Method::signature_handler_offset())), G3_scratch); |
0 | 734 __ bind(L); |
735 } | |
736 | |
737 // Push a new frame so that the args will really be stored in | |
738 // Copy a few locals across so the new frame has the variables | |
739 // we need but these values will be dead at the jni call and | |
740 // therefore not gc volatile like the values in the current | |
741 // frame (Lstate in particular) | |
742 | |
743 // Flush the state pointer to the register save area | |
744 // Which is the only register we need for a stack walk. | |
745 __ st_ptr(Lstate, SP, (Lstate->sp_offset_in_saved_window() * wordSize) + STACK_BIAS); | |
746 | |
747 __ mov(Lstate, O1); // Need to pass the state pointer across the frame | |
748 | |
749 // Calculate current frame size | |
750 __ sub(SP, FP, O3); // Calculate negative of current frame size | |
751 __ save(SP, O3, SP); // Allocate an identical sized frame | |
752 | |
753 __ mov(I1, Lstate); // In the "natural" register. | |
754 | |
755 // Note I7 has leftover trash. Slow signature handler will fill it in | |
756 // should we get there. Normal jni call will set reasonable last_Java_pc | |
757 // below (and fix I7 so the stack trace doesn't have a meaningless frame | |
758 // in it). | |
759 | |
760 | |
761 // call signature handler | |
762 __ ld_ptr(STATE(_method), Lmethod); | |
763 __ ld_ptr(STATE(_locals), Llocals); | |
764 | |
765 __ callr(G3_scratch, 0); | |
766 __ delayed()->nop(); | |
767 __ ld_ptr(STATE(_thread), G2_thread); // restore thread (shouldn't be needed) | |
768 | |
769 { Label not_static; | |
770 | |
771 __ ld_ptr(STATE(_method), G5_method); | |
772 __ ld(access_flags, O0); | |
773 __ btst(JVM_ACC_STATIC, O0); | |
774 __ br( Assembler::zero, false, Assembler::pt, not_static); | |
775 __ delayed()-> | |
776 // get native function entry point(O0 is a good temp until the very end) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
777 ld_ptr(Address(G5_method, 0, in_bytes(Method::native_function_offset())), O0); |
0 | 778 // for static methods insert the mirror argument |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
3839
diff
changeset
|
779 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); |
0 | 780 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
781 __ ld_ptr(Address(G5_method, 0, in_bytes(Method:: const_offset())), O1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
782 __ ld_ptr(Address(O1, 0, in_bytes(ConstMethod::constants_offset())), O1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
783 __ ld_ptr(Address(O1, 0, ConstantPool::pool_holder_offset_in_bytes()), O1); |
0 | 784 __ ld_ptr(O1, mirror_offset, O1); |
785 // where the mirror handle body is allocated: | |
786 #ifdef ASSERT | |
787 if (!PrintSignatureHandlers) // do not dirty the output with this | |
788 { Label L; | |
789 __ tst(O1); | |
790 __ brx(Assembler::notZero, false, Assembler::pt, L); | |
791 __ delayed()->nop(); | |
792 __ stop("mirror is missing"); | |
793 __ bind(L); | |
794 } | |
795 #endif // ASSERT | |
796 __ st_ptr(O1, STATE(_oop_temp)); | |
797 __ add(STATE(_oop_temp), O1); // this is really an LEA not an add | |
798 __ bind(not_static); | |
799 } | |
800 | |
801 // At this point, arguments have been copied off of stack into | |
802 // their JNI positions, which are O1..O5 and SP[68..]. | |
803 // Oops are boxed in-place on the stack, with handles copied to arguments. | |
804 // The result handler is in Lscratch. O0 will shortly hold the JNIEnv*. | |
805 | |
806 #ifdef ASSERT | |
807 { Label L; | |
808 __ tst(O0); | |
809 __ brx(Assembler::notZero, false, Assembler::pt, L); | |
810 __ delayed()->nop(); | |
811 __ stop("native entry point is missing"); | |
812 __ bind(L); | |
813 } | |
814 #endif // ASSERT | |
815 | |
816 // | |
817 // setup the java frame anchor | |
818 // | |
819 // The scavenge function only needs to know that the PC of this frame is | |
820 // in the interpreter method entry code, it doesn't need to know the exact | |
821 // PC and hence we can use O7 which points to the return address from the | |
822 // previous call in the code stream (signature handler function) | |
823 // | |
824 // The other trick is we set last_Java_sp to FP instead of the usual SP because | |
825 // we have pushed the extra frame in order to protect the volatile register(s) | |
826 // in that frame when we return from the jni call | |
827 // | |
828 | |
829 | |
830 __ set_last_Java_frame(FP, O7); | |
831 __ mov(O7, I7); // make dummy interpreter frame look like one above, | |
832 // not meaningless information that'll confuse me. | |
833 | |
834 // flush the windows now. We don't care about the current (protection) frame | |
835 // only the outer frames | |
836 | |
837 __ flush_windows(); | |
838 | |
839 // mark windows as flushed | |
840 Address flags(G2_thread, | |
841 0, | |
842 in_bytes(JavaThread::frame_anchor_offset()) + in_bytes(JavaFrameAnchor::flags_offset())); | |
843 __ set(JavaFrameAnchor::flushed, G3_scratch); | |
844 __ st(G3_scratch, flags); | |
845 | |
846 // Transition from _thread_in_Java to _thread_in_native. We are already safepoint ready. | |
847 | |
848 Address thread_state(G2_thread, 0, in_bytes(JavaThread::thread_state_offset())); | |
849 #ifdef ASSERT | |
850 { Label L; | |
851 __ ld(thread_state, G3_scratch); | |
852 __ cmp(G3_scratch, _thread_in_Java); | |
853 __ br(Assembler::equal, false, Assembler::pt, L); | |
854 __ delayed()->nop(); | |
855 __ stop("Wrong thread state in native stub"); | |
856 __ bind(L); | |
857 } | |
858 #endif // ASSERT | |
859 __ set(_thread_in_native, G3_scratch); | |
860 __ st(G3_scratch, thread_state); | |
861 | |
862 // Call the jni method, using the delay slot to set the JNIEnv* argument. | |
863 __ callr(O0, 0); | |
864 __ delayed()-> | |
865 add(G2_thread, in_bytes(JavaThread::jni_environment_offset()), O0); | |
866 __ ld_ptr(STATE(_thread), G2_thread); // restore thread | |
867 | |
868 // must we block? | |
869 | |
870 // Block, if necessary, before resuming in _thread_in_Java state. | |
871 // In order for GC to work, don't clear the last_Java_sp until after blocking. | |
872 { Label no_block; | |
873 Address sync_state(G3_scratch, SafepointSynchronize::address_of_state()); | |
874 | |
875 // Switch thread to "native transition" state before reading the synchronization state. | |
876 // This additional state is necessary because reading and testing the synchronization | |
877 // state is not atomic w.r.t. GC, as this scenario demonstrates: | |
878 // Java thread A, in _thread_in_native state, loads _not_synchronized and is preempted. | |
879 // VM thread changes sync state to synchronizing and suspends threads for GC. | |
880 // Thread A is resumed to finish this native method, but doesn't block here since it | |
881 // didn't see any synchronization is progress, and escapes. | |
882 __ set(_thread_in_native_trans, G3_scratch); | |
883 __ st(G3_scratch, thread_state); | |
884 if(os::is_MP()) { | |
885 // Write serialization page so VM thread can do a pseudo remote membar. | |
886 // We use the current thread pointer to calculate a thread specific | |
887 // offset to write to within the page. This minimizes bus traffic | |
888 // due to cache line collision. | |
889 __ serialize_memory(G2_thread, G1_scratch, G3_scratch); | |
890 } | |
891 __ load_contents(sync_state, G3_scratch); | |
892 __ cmp(G3_scratch, SafepointSynchronize::_not_synchronized); | |
893 | |
894 | |
895 Label L; | |
896 Address suspend_state(G2_thread, 0, in_bytes(JavaThread::suspend_flags_offset())); | |
897 __ br(Assembler::notEqual, false, Assembler::pn, L); | |
898 __ delayed()-> | |
899 ld(suspend_state, G3_scratch); | |
900 __ cmp(G3_scratch, 0); | |
901 __ br(Assembler::equal, false, Assembler::pt, no_block); | |
902 __ delayed()->nop(); | |
903 __ bind(L); | |
904 | |
905 // Block. Save any potential method result value before the operation and | |
906 // use a leaf call to leave the last_Java_frame setup undisturbed. | |
907 save_native_result(); | |
908 __ call_VM_leaf(noreg, | |
909 CAST_FROM_FN_PTR(address, JavaThread::check_safepoint_and_suspend_for_native_trans), | |
910 G2_thread); | |
911 __ ld_ptr(STATE(_thread), G2_thread); // restore thread | |
912 // Restore any method result value | |
913 restore_native_result(); | |
914 __ bind(no_block); | |
915 } | |
916 | |
917 // Clear the frame anchor now | |
918 | |
919 __ reset_last_Java_frame(); | |
920 | |
921 // Move the result handler address | |
922 __ mov(Lscratch, G3_scratch); | |
923 // return possible result to the outer frame | |
924 #ifndef __LP64 | |
925 __ mov(O0, I0); | |
926 __ restore(O1, G0, O1); | |
927 #else | |
928 __ restore(O0, G0, O0); | |
929 #endif /* __LP64 */ | |
930 | |
931 // Move result handler to expected register | |
932 __ mov(G3_scratch, Lscratch); | |
933 | |
934 | |
935 // thread state is thread_in_native_trans. Any safepoint blocking has | |
936 // happened in the trampoline we are ready to switch to thread_in_Java. | |
937 | |
938 __ set(_thread_in_Java, G3_scratch); | |
939 __ st(G3_scratch, thread_state); | |
940 | |
941 // If we have an oop result store it where it will be safe for any further gc | |
942 // until we return now that we've released the handle it might be protected by | |
943 | |
944 { | |
945 Label no_oop, store_result; | |
946 | |
947 __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch); | |
948 __ cmp(G3_scratch, Lscratch); | |
949 __ brx(Assembler::notEqual, false, Assembler::pt, no_oop); | |
950 __ delayed()->nop(); | |
951 __ addcc(G0, O0, O0); | |
952 __ brx(Assembler::notZero, true, Assembler::pt, store_result); // if result is not NULL: | |
953 __ delayed()->ld_ptr(O0, 0, O0); // unbox it | |
954 __ mov(G0, O0); | |
955 | |
956 __ bind(store_result); | |
957 // Store it where gc will look for it and result handler expects it. | |
958 __ st_ptr(O0, STATE(_oop_temp)); | |
959 | |
960 __ bind(no_oop); | |
961 | |
962 } | |
963 | |
964 // reset handle block | |
965 __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), G3_scratch); | |
17850
2100bf712e2a
8039146: Fix 64-bit store to int JNIHandleBlock::_top
goetz
parents:
13010
diff
changeset
|
966 __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes()); |
0 | 967 |
968 | |
969 // handle exceptions (exception handling will handle unlocking!) | |
970 { Label L; | |
971 Address exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); | |
972 | |
973 __ ld_ptr(exception_addr, Gtemp); | |
974 __ tst(Gtemp); | |
975 __ brx(Assembler::equal, false, Assembler::pt, L); | |
976 __ delayed()->nop(); | |
977 __ bind(pending_exception_present); | |
978 // With c++ interpreter we just leave it pending caller will do the correct thing. However... | |
979 // Like x86 we ignore the result of the native call and leave the method locked. This | |
980 // seems wrong to leave things locked. | |
981 | |
982 __ br(Assembler::always, false, Assembler::pt, StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type); | |
983 __ delayed()->restore(I5_savedSP, G0, SP); // remove interpreter frame | |
984 | |
985 __ bind(L); | |
986 } | |
987 | |
988 // jvmdi/jvmpi support (preserves thread register) | |
989 __ notify_method_exit(true, ilgl, InterpreterMacroAssembler::NotifyJVMTI); | |
990 | |
991 if (synchronized) { | |
992 // save and restore any potential method result value around the unlocking operation | |
993 save_native_result(); | |
994 | |
995 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
996 // Get the initial monitor we allocated | |
997 __ sub(Lstate, entry_size, O1); // initial monitor | |
998 __ unlock_object(O1); | |
999 restore_native_result(); | |
1000 } | |
1001 | |
1002 #if defined(COMPILER2) && !defined(_LP64) | |
1003 | |
1004 // C2 expects long results in G1 we can't tell if we're returning to interpreted | |
1005 // or compiled so just be safe. | |
1006 | |
1007 __ sllx(O0, 32, G1); // Shift bits into high G1 | |
1008 __ srl (O1, 0, O1); // Zero extend O1 | |
1009 __ or3 (O1, G1, G1); // OR 64 bits into G1 | |
1010 | |
1011 #endif /* COMPILER2 && !_LP64 */ | |
1012 | |
1013 #ifdef ASSERT | |
1014 { | |
1015 Label ok; | |
1016 __ cmp(I5_savedSP, FP); | |
1017 __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, ok); | |
1018 __ delayed()->nop(); | |
1019 __ stop("bad I5_savedSP value"); | |
1020 __ should_not_reach_here(); | |
1021 __ bind(ok); | |
1022 } | |
1023 #endif | |
1024 // Calls result handler which POPS FRAME | |
1025 if (TraceJumps) { | |
1026 // Move target to register that is recordable | |
1027 __ mov(Lscratch, G3_scratch); | |
1028 __ JMP(G3_scratch, 0); | |
1029 } else { | |
1030 __ jmp(Lscratch, 0); | |
1031 } | |
1032 __ delayed()->nop(); | |
1033 | |
1034 if (inc_counter) { | |
1035 // handle invocation counter overflow | |
1036 __ bind(invocation_counter_overflow); | |
1037 generate_counter_overflow(Lcontinue); | |
1038 } | |
1039 | |
1040 | |
1041 return entry; | |
1042 } | |
1043 | |
1044 void CppInterpreterGenerator::generate_compute_interpreter_state(const Register state, | |
1045 const Register prev_state, | |
1046 bool native) { | |
1047 | |
1048 // On entry | |
1049 // G5_method - caller's method | |
1050 // Gargs - points to initial parameters (i.e. locals[0]) | |
1051 // G2_thread - valid? (C1 only??) | |
1052 // "prev_state" - contains any previous frame manager state which we must save a link | |
1053 // | |
1054 // On return | |
1055 // "state" is a pointer to the newly allocated state object. We must allocate and initialize | |
1056 // a new interpretState object and the method expression stack. | |
1057 | |
1058 assert_different_registers(state, prev_state); | |
1059 assert_different_registers(prev_state, G3_scratch); | |
1060 const Register Gtmp = G3_scratch; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1061 const Address constMethod (G5_method, 0, in_bytes(Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1062 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); |
0 | 1063 |
1064 // slop factor is two extra slots on the expression stack so that | |
1065 // we always have room to store a result when returning from a call without parameters | |
1066 // that returns a result. | |
1067 | |
1068 const int slop_factor = 2*wordSize; | |
1069 | |
1070 const int fixed_size = ((sizeof(BytecodeInterpreter) + slop_factor) >> LogBytesPerWord) + // what is the slop factor? | |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10105
diff
changeset
|
1071 Method::extra_stack_entries() + // extra stack for jsr 292 |
0 | 1072 frame::memory_parameter_word_sp_offset + // register save area + param window |
1073 (native ? frame::interpreter_frame_extra_outgoing_argument_words : 0); // JNI, class | |
1074 | |
1075 // XXX G5_method valid | |
1076 | |
1077 // Now compute new frame size | |
1078 | |
1079 if (native) { | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1080 const Register RconstMethod = Gtmp; |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1081 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1082 __ ld_ptr(constMethod, RconstMethod); |
0 | 1083 __ lduh( size_of_parameters, Gtmp ); |
1084 __ calc_mem_param_words(Gtmp, Gtmp); // space for native call parameters passed on the stack in words | |
1085 } else { | |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1086 // Full size expression stack |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1087 __ ld_ptr(constMethod, Gtmp); |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1088 __ lduh(Gtmp, in_bytes(ConstMethod::max_stack_offset()), Gtmp); |
0 | 1089 } |
1090 __ add(Gtmp, fixed_size, Gtmp); // plus the fixed portion | |
1091 | |
1092 __ neg(Gtmp); // negative space for stack/parameters in words | |
1093 __ and3(Gtmp, -WordsPerLong, Gtmp); // make multiple of 2 (SP must be 2-word aligned) | |
1094 __ sll(Gtmp, LogBytesPerWord, Gtmp); // negative space for frame in bytes | |
1095 | |
1096 // Need to do stack size check here before we fault on large frames | |
1097 | |
1098 Label stack_ok; | |
1099 | |
1100 const int max_pages = StackShadowPages > (StackRedPages+StackYellowPages) ? StackShadowPages : | |
1101 (StackRedPages+StackYellowPages); | |
1102 | |
1103 | |
1104 __ ld_ptr(G2_thread, in_bytes(Thread::stack_base_offset()), O0); | |
1105 __ ld_ptr(G2_thread, in_bytes(Thread::stack_size_offset()), O1); | |
1106 // compute stack bottom | |
1107 __ sub(O0, O1, O0); | |
1108 | |
1109 // Avoid touching the guard pages | |
1110 // Also a fudge for frame size of BytecodeInterpreter::run | |
1111 // It varies from 1k->4k depending on build type | |
1112 const int fudge = 6 * K; | |
1113 | |
1114 __ set(fudge + (max_pages * os::vm_page_size()), O1); | |
1115 | |
1116 __ add(O0, O1, O0); | |
1117 __ sub(O0, Gtmp, O0); | |
1118 __ cmp(SP, O0); | |
1119 __ brx(Assembler::greaterUnsigned, false, Assembler::pt, stack_ok); | |
1120 __ delayed()->nop(); | |
1121 | |
1122 // throw exception return address becomes throwing pc | |
1123 | |
1124 __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError)); | |
1125 __ stop("never reached"); | |
1126 | |
1127 __ bind(stack_ok); | |
1128 | |
1129 __ save(SP, Gtmp, SP); // setup new frame and register window | |
1130 | |
1131 // New window I7 call_stub or previous activation | |
1132 // O6 - register save area, BytecodeInterpreter just below it, args/locals just above that | |
1133 // | |
1134 __ sub(FP, sizeof(BytecodeInterpreter), state); // Point to new Interpreter state | |
1135 __ add(state, STACK_BIAS, state ); // Account for 64bit bias | |
1136 | |
1137 #define XXX_STATE(field_name) state, in_bytes(byte_offset_of(BytecodeInterpreter, field_name)) | |
1138 | |
1139 // Initialize a new Interpreter state | |
1140 // orig_sp - caller's original sp | |
1141 // G2_thread - thread | |
1142 // Gargs - &locals[0] (unbiased?) | |
1143 // G5_method - method | |
1144 // SP (biased) - accounts for full size java stack, BytecodeInterpreter object, register save area, and register parameter save window | |
1145 | |
1146 | |
1147 __ set(0xdead0004, O1); | |
1148 | |
1149 | |
1150 __ st_ptr(Gargs, XXX_STATE(_locals)); | |
1151 __ st_ptr(G0, XXX_STATE(_oop_temp)); | |
1152 | |
1153 __ st_ptr(state, XXX_STATE(_self_link)); // point to self | |
1154 __ st_ptr(prev_state->after_save(), XXX_STATE(_prev_link)); // Chain interpreter states | |
1155 __ st_ptr(G2_thread, XXX_STATE(_thread)); // Store javathread | |
1156 | |
1157 if (native) { | |
1158 __ st_ptr(G0, XXX_STATE(_bcp)); | |
1159 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1160 __ ld_ptr(G5_method, in_bytes(Method::const_offset()), O2); // get ConstMethod* |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1161 __ add(O2, in_bytes(ConstMethod::codes_offset()), O2); // get bcp |
0 | 1162 __ st_ptr(O2, XXX_STATE(_bcp)); |
1163 } | |
1164 | |
1165 __ st_ptr(G0, XXX_STATE(_mdx)); | |
1166 __ st_ptr(G5_method, XXX_STATE(_method)); | |
1167 | |
1168 __ set((int) BytecodeInterpreter::method_entry, O1); | |
1169 __ st(O1, XXX_STATE(_msg)); | |
1170 | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
5923
diff
changeset
|
1171 __ ld_ptr(constMethod, O3); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1172 __ ld_ptr(O3, in_bytes(ConstMethod::constants_offset()), O3); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1173 __ ld_ptr(O3, ConstantPool::cache_offset_in_bytes(), O2); |
0 | 1174 __ st_ptr(O2, XXX_STATE(_constants)); |
1175 | |
1176 __ st_ptr(G0, XXX_STATE(_result._to_call._callee)); | |
1177 | |
1178 // Monitor base is just start of BytecodeInterpreter object; | |
1179 __ mov(state, O2); | |
1180 __ st_ptr(O2, XXX_STATE(_monitor_base)); | |
1181 | |
1182 // Do we need a monitor for synchonized method? | |
1183 { | |
1184 __ ld(access_flags, O1); | |
1185 Label done; | |
1186 Label got_obj; | |
1187 __ btst(JVM_ACC_SYNCHRONIZED, O1); | |
1188 __ br( Assembler::zero, false, Assembler::pt, done); | |
1189 | |
4762
069ab3f976d3
7118863: Move sizeof(klassOopDesc) into the *Klass::*_offset_in_bytes() functions
stefank
parents:
3839
diff
changeset
|
1190 const int mirror_offset = in_bytes(Klass::java_mirror_offset()); |
0 | 1191 __ delayed()->btst(JVM_ACC_STATIC, O1); |
1192 __ ld_ptr(XXX_STATE(_locals), O1); | |
1193 __ br( Assembler::zero, true, Assembler::pt, got_obj); | |
1194 __ delayed()->ld_ptr(O1, 0, O1); // get receiver for not-static case | |
6123
2fe087c3e814
7172967: Eliminate constMethod's _method backpointer to methodOop.
jiangli
parents:
5923
diff
changeset
|
1195 __ ld_ptr(constMethod, O1); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1196 __ ld_ptr( O1, in_bytes(ConstMethod::constants_offset()), O1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1197 __ ld_ptr( O1, ConstantPool::pool_holder_offset_in_bytes(), O1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1198 // lock the mirror, not the Klass* |
0 | 1199 __ ld_ptr( O1, mirror_offset, O1); |
1200 | |
1201 __ bind(got_obj); | |
1202 | |
1203 #ifdef ASSERT | |
1204 __ tst(O1); | |
5923 | 1205 __ breakpoint_trap(Assembler::zero, Assembler::ptr_cc); |
0 | 1206 #endif // ASSERT |
1207 | |
1208 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
1209 __ sub(SP, entry_size, SP); // account for initial monitor | |
1210 __ sub(O2, entry_size, O2); // initial monitor | |
1211 __ st_ptr(O1, O2, BasicObjectLock::obj_offset_in_bytes()); // and allocate it for interpreter use | |
1212 __ bind(done); | |
1213 } | |
1214 | |
1215 // Remember initial frame bottom | |
1216 | |
1217 __ st_ptr(SP, XXX_STATE(_frame_bottom)); | |
1218 | |
1219 __ st_ptr(O2, XXX_STATE(_stack_base)); | |
1220 | |
1221 __ sub(O2, wordSize, O2); // prepush | |
1222 __ st_ptr(O2, XXX_STATE(_stack)); // PREPUSH | |
1223 | |
7183
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1224 // Full size expression stack |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1225 __ ld_ptr(constMethod, O3); |
b2dbd323c668
8003848: Make ConstMethod::generic_signature_index optional and move Method::_max_stack to ConstMethod.
jiangli
parents:
6725
diff
changeset
|
1226 __ lduh(O3, in_bytes(ConstMethod::max_stack_offset()), O3); |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10105
diff
changeset
|
1227 __ inc(O3, Method::extra_stack_entries()); |
0 | 1228 __ sll(O3, LogBytesPerWord, O3); |
1229 __ sub(O2, O3, O3); | |
1230 // __ sub(O3, wordSize, O3); // so prepush doesn't look out of bounds | |
1231 __ st_ptr(O3, XXX_STATE(_stack_limit)); | |
1232 | |
1233 if (!native) { | |
1234 // | |
1235 // Code to initialize locals | |
1236 // | |
1237 Register init_value = noreg; // will be G0 if we must clear locals | |
1238 // Now zero locals | |
1239 if (true /* zerolocals */ || ClearInterpreterLocals) { | |
1240 // explicitly initialize locals | |
1241 init_value = G0; | |
1242 } else { | |
1243 #ifdef ASSERT | |
1244 // initialize locals to a garbage pattern for better debugging | |
1245 init_value = O3; | |
1246 __ set( 0x0F0F0F0F, init_value ); | |
1247 #endif // ASSERT | |
1248 } | |
1249 if (init_value != noreg) { | |
1250 Label clear_loop; | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1251 const Register RconstMethod = O1; |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1252 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1253 const Address size_of_locals (RconstMethod, 0, in_bytes(ConstMethod::size_of_locals_offset())); |
0 | 1254 |
1255 // NOTE: If you change the frame layout, this code will need to | |
1256 // be updated! | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1257 __ ld_ptr( constMethod, RconstMethod ); |
0 | 1258 __ lduh( size_of_locals, O2 ); |
1259 __ lduh( size_of_parameters, O1 ); | |
1260 __ sll( O2, LogBytesPerWord, O2); | |
1261 __ sll( O1, LogBytesPerWord, O1 ); | |
1262 __ ld_ptr(XXX_STATE(_locals), L2_scratch); | |
1263 __ sub( L2_scratch, O2, O2 ); | |
1264 __ sub( L2_scratch, O1, O1 ); | |
1265 | |
1266 __ bind( clear_loop ); | |
1267 __ inc( O2, wordSize ); | |
1268 | |
1269 __ cmp( O2, O1 ); | |
1270 __ br( Assembler::lessEqualUnsigned, true, Assembler::pt, clear_loop ); | |
1271 __ delayed()->st_ptr( init_value, O2, 0 ); | |
1272 } | |
1273 } | |
1274 } | |
1275 // Find preallocated monitor and lock method (C++ interpreter) | |
1276 // | |
1277 void InterpreterGenerator::lock_method(void) { | |
1278 // Lock the current method. | |
1279 // Destroys registers L2_scratch, L3_scratch, O0 | |
1280 // | |
1281 // Find everything relative to Lstate | |
1282 | |
1283 #ifdef ASSERT | |
1284 __ ld_ptr(STATE(_method), L2_scratch); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1285 __ ld(L2_scratch, in_bytes(Method::access_flags_offset()), O0); |
0 | 1286 |
1287 { Label ok; | |
1288 __ btst(JVM_ACC_SYNCHRONIZED, O0); | |
1289 __ br( Assembler::notZero, false, Assembler::pt, ok); | |
1290 __ delayed()->nop(); | |
1291 __ stop("method doesn't need synchronization"); | |
1292 __ bind(ok); | |
1293 } | |
1294 #endif // ASSERT | |
1295 | |
1296 // monitor is already allocated at stack base | |
1297 // and the lockee is already present | |
1298 __ ld_ptr(STATE(_stack_base), L2_scratch); | |
1299 __ ld_ptr(L2_scratch, BasicObjectLock::obj_offset_in_bytes(), O0); // get object | |
1300 __ lock_object(L2_scratch, O0); | |
1301 | |
1302 } | |
1303 | |
1304 // Generate code for handling resuming a deopted method | |
1305 void CppInterpreterGenerator::generate_deopt_handling() { | |
1306 | |
1307 Label return_from_deopt_common; | |
1308 | |
1309 // deopt needs to jump to here to enter the interpreter (return a result) | |
1310 deopt_frame_manager_return_atos = __ pc(); | |
1311 | |
1312 // O0/O1 live | |
3839 | 1313 __ ba(return_from_deopt_common); |
0 | 1314 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_OBJECT), L3_scratch); // Result stub address array index |
1315 | |
1316 | |
1317 // deopt needs to jump to here to enter the interpreter (return a result) | |
1318 deopt_frame_manager_return_btos = __ pc(); | |
1319 | |
1320 // O0/O1 live | |
3839 | 1321 __ ba(return_from_deopt_common); |
0 | 1322 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_BOOLEAN), L3_scratch); // Result stub address array index |
1323 | |
1324 // deopt needs to jump to here to enter the interpreter (return a result) | |
1325 deopt_frame_manager_return_itos = __ pc(); | |
1326 | |
1327 // O0/O1 live | |
3839 | 1328 __ ba(return_from_deopt_common); |
0 | 1329 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_INT), L3_scratch); // Result stub address array index |
1330 | |
1331 // deopt needs to jump to here to enter the interpreter (return a result) | |
1332 | |
1333 deopt_frame_manager_return_ltos = __ pc(); | |
1334 #if !defined(_LP64) && defined(COMPILER2) | |
1335 // All return values are where we want them, except for Longs. C2 returns | |
1336 // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1. | |
1337 // Since the interpreter will return longs in G1 and O0/O1 in the 32bit | |
1338 // build even if we are returning from interpreted we just do a little | |
1339 // stupid shuffing. | |
1340 // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to | |
1341 // do this here. Unfortunately if we did a rethrow we'd see an machepilog node | |
1342 // first which would move g1 -> O0/O1 and destroy the exception we were throwing. | |
1343 | |
1344 __ srl (G1, 0,O1); | |
1345 __ srlx(G1,32,O0); | |
1346 #endif /* !_LP64 && COMPILER2 */ | |
1347 // O0/O1 live | |
3839 | 1348 __ ba(return_from_deopt_common); |
0 | 1349 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_LONG), L3_scratch); // Result stub address array index |
1350 | |
1351 // deopt needs to jump to here to enter the interpreter (return a result) | |
1352 | |
1353 deopt_frame_manager_return_ftos = __ pc(); | |
1354 // O0/O1 live | |
3839 | 1355 __ ba(return_from_deopt_common); |
0 | 1356 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_FLOAT), L3_scratch); // Result stub address array index |
1357 | |
1358 // deopt needs to jump to here to enter the interpreter (return a result) | |
1359 deopt_frame_manager_return_dtos = __ pc(); | |
1360 | |
1361 // O0/O1 live | |
3839 | 1362 __ ba(return_from_deopt_common); |
0 | 1363 __ delayed()->set(AbstractInterpreter::BasicType_as_index(T_DOUBLE), L3_scratch); // Result stub address array index |
1364 | |
1365 // deopt needs to jump to here to enter the interpreter (return a result) | |
1366 deopt_frame_manager_return_vtos = __ pc(); | |
1367 | |
1368 // O0/O1 live | |
1369 __ set(AbstractInterpreter::BasicType_as_index(T_VOID), L3_scratch); | |
1370 | |
1371 // Deopt return common | |
1372 // an index is present that lets us move any possible result being | |
1373 // return to the interpreter's stack | |
1374 // | |
1375 __ bind(return_from_deopt_common); | |
1376 | |
1377 // Result if any is in native abi result (O0..O1/F0..F1). The java expression | |
1378 // stack is in the state that the calling convention left it. | |
1379 // Copy the result from native abi result and place it on java expression stack. | |
1380 | |
1381 // Current interpreter state is present in Lstate | |
1382 | |
1383 // Get current pre-pushed top of interpreter stack | |
1384 // Any result (if any) is in native abi | |
1385 // result type index is in L3_scratch | |
1386 | |
1387 __ ld_ptr(STATE(_stack), L1_scratch); // get top of java expr stack | |
1388 | |
1389 __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch); | |
1390 __ sll(L3_scratch, LogBytesPerWord, L3_scratch); | |
1391 __ ld_ptr(L4_scratch, L3_scratch, Lscratch); // get typed result converter address | |
1392 __ jmpl(Lscratch, G0, O7); // and convert it | |
1393 __ delayed()->nop(); | |
1394 | |
1395 // L1_scratch points to top of stack (prepushed) | |
1396 __ st_ptr(L1_scratch, STATE(_stack)); | |
1397 } | |
1398 | |
1399 // Generate the code to handle a more_monitors message from the c++ interpreter | |
1400 void CppInterpreterGenerator::generate_more_monitors() { | |
1401 | |
1402 Label entry, loop; | |
1403 const int entry_size = frame::interpreter_frame_monitor_size() * wordSize; | |
1404 // 1. compute new pointers // esp: old expression stack top | |
1405 __ delayed()->ld_ptr(STATE(_stack_base), L4_scratch); // current expression stack bottom | |
1406 __ sub(L4_scratch, entry_size, L4_scratch); | |
1407 __ st_ptr(L4_scratch, STATE(_stack_base)); | |
1408 | |
1409 __ sub(SP, entry_size, SP); // Grow stack | |
1410 __ st_ptr(SP, STATE(_frame_bottom)); | |
1411 | |
1412 __ ld_ptr(STATE(_stack_limit), L2_scratch); | |
1413 __ sub(L2_scratch, entry_size, L2_scratch); | |
1414 __ st_ptr(L2_scratch, STATE(_stack_limit)); | |
1415 | |
1416 __ ld_ptr(STATE(_stack), L1_scratch); // Get current stack top | |
1417 __ sub(L1_scratch, entry_size, L1_scratch); | |
1418 __ st_ptr(L1_scratch, STATE(_stack)); | |
3839 | 1419 __ ba(entry); |
0 | 1420 __ delayed()->add(L1_scratch, wordSize, L1_scratch); // first real entry (undo prepush) |
1421 | |
1422 // 2. move expression stack | |
1423 | |
1424 __ bind(loop); | |
1425 __ st_ptr(L3_scratch, Address(L1_scratch, 0)); | |
1426 __ add(L1_scratch, wordSize, L1_scratch); | |
1427 __ bind(entry); | |
1428 __ cmp(L1_scratch, L4_scratch); | |
1429 __ br(Assembler::notEqual, false, Assembler::pt, loop); | |
1430 __ delayed()->ld_ptr(L1_scratch, entry_size, L3_scratch); | |
1431 | |
1432 // now zero the slot so we can find it. | |
123 | 1433 __ st_ptr(G0, L4_scratch, BasicObjectLock::obj_offset_in_bytes()); |
0 | 1434 |
1435 } | |
1436 | |
1437 // Initial entry to C++ interpreter from the call_stub. | |
1438 // This entry point is called the frame manager since it handles the generation | |
1439 // of interpreter activation frames via requests directly from the vm (via call_stub) | |
1440 // and via requests from the interpreter. The requests from the call_stub happen | |
1441 // directly thru the entry point. Requests from the interpreter happen via returning | |
1442 // from the interpreter and examining the message the interpreter has returned to | |
1443 // the frame manager. The frame manager can take the following requests: | |
1444 | |
1445 // NO_REQUEST - error, should never happen. | |
1446 // MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and | |
1447 // allocate a new monitor. | |
1448 // CALL_METHOD - setup a new activation to call a new method. Very similar to what | |
1449 // happens during entry during the entry via the call stub. | |
1450 // RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub. | |
1451 // | |
1452 // Arguments: | |
1453 // | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1454 // ebx: Method* |
0 | 1455 // ecx: receiver - unused (retrieved from stack as needed) |
1456 // esi: previous frame manager state (NULL from the call_stub/c1/c2) | |
1457 // | |
1458 // | |
1459 // Stack layout at entry | |
1460 // | |
1461 // [ return address ] <--- esp | |
1462 // [ parameter n ] | |
1463 // ... | |
1464 // [ parameter 1 ] | |
1465 // [ expression stack ] | |
1466 // | |
1467 // | |
1468 // We are free to blow any registers we like because the call_stub which brought us here | |
1469 // initially has preserved the callee save registers already. | |
1470 // | |
1471 // | |
1472 | |
1473 static address interpreter_frame_manager = NULL; | |
1474 | |
1475 #ifdef ASSERT | |
1476 #define VALIDATE_STATE(scratch, marker) \ | |
1477 { \ | |
1478 Label skip; \ | |
1479 __ ld_ptr(STATE(_self_link), scratch); \ | |
1480 __ cmp(Lstate, scratch); \ | |
1481 __ brx(Assembler::equal, false, Assembler::pt, skip); \ | |
1482 __ delayed()->nop(); \ | |
1483 __ breakpoint_trap(); \ | |
7476
ffa87474d7a4
8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents:
7402
diff
changeset
|
1484 __ emit_int32(marker); \ |
0 | 1485 __ bind(skip); \ |
1486 } | |
1487 #else | |
1488 #define VALIDATE_STATE(scratch, marker) | |
1489 #endif /* ASSERT */ | |
1490 | |
1491 void CppInterpreterGenerator::adjust_callers_stack(Register args) { | |
1492 // | |
1493 // Adjust caller's stack so that all the locals can be contiguous with | |
1494 // the parameters. | |
1495 // Worries about stack overflow make this a pain. | |
1496 // | |
1497 // Destroys args, G3_scratch, G3_scratch | |
1498 // In/Out O5_savedSP (sender's original SP) | |
1499 // | |
1500 // assert_different_registers(state, prev_state); | |
1501 const Register Gtmp = G3_scratch; | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1502 const RconstMethod = G3_scratch; |
0 | 1503 const Register tmp = O2; |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1504 const Address constMethod(G5_method, 0, in_bytes(Method::const_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1505 const Address size_of_parameters(RconstMethod, 0, in_bytes(ConstMethod::size_of_parameters_offset())); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1506 const Address size_of_locals (RconstMethod, 0, in_bytes(ConstMethod::size_of_locals_offset())); |
0 | 1507 |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1508 __ ld_ptr(constMethod, RconstMethod); |
0 | 1509 __ lduh(size_of_parameters, tmp); |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1510 __ sll(tmp, LogBytesPerWord, Gargs); // parameter size in bytes |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1511 __ add(args, Gargs, Gargs); // points to first local + BytesPerWord |
0 | 1512 // NEW |
1513 __ add(Gargs, -wordSize, Gargs); // points to first local[0] | |
1514 // determine extra space for non-argument locals & adjust caller's SP | |
1515 // Gtmp1: parameter size in words | |
1516 __ lduh(size_of_locals, Gtmp); | |
1517 __ compute_extra_locals_size_in_bytes(tmp, Gtmp, Gtmp); | |
1518 | |
1519 #if 1 | |
1520 // c2i adapters place the final interpreter argument in the register save area for O0/I0 | |
1521 // the call_stub will place the final interpreter argument at | |
1522 // frame::memory_parameter_word_sp_offset. This is mostly not noticable for either asm | |
1523 // or c++ interpreter. However with the c++ interpreter when we do a recursive call | |
1524 // and try to make it look good in the debugger we will store the argument to | |
1525 // RecursiveInterpreterActivation in the register argument save area. Without allocating | |
1526 // extra space for the compiler this will overwrite locals in the local array of the | |
1527 // interpreter. | |
1528 // QQQ still needed with frameless adapters??? | |
1529 | |
1530 const int c2i_adjust_words = frame::memory_parameter_word_sp_offset - frame::callee_register_argument_save_area_sp_offset; | |
1531 | |
1532 __ add(Gtmp, c2i_adjust_words*wordSize, Gtmp); | |
1533 #endif // 1 | |
1534 | |
1535 | |
1536 __ sub(SP, Gtmp, SP); // just caller's frame for the additional space we need. | |
1537 } | |
1538 | |
1539 address InterpreterGenerator::generate_normal_entry(bool synchronized) { | |
1540 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1541 // G5_method: Method* |
0 | 1542 // G2_thread: thread (unused) |
1543 // Gargs: bottom of args (sender_sp) | |
1544 // O5: sender's sp | |
1545 | |
1546 // A single frame manager is plenty as we don't specialize for synchronized. We could and | |
1547 // the code is pretty much ready. Would need to change the test below and for good measure | |
1548 // modify generate_interpreter_state to only do the (pre) sync stuff stuff for synchronized | |
1549 // routines. Not clear this is worth it yet. | |
1550 | |
1551 if (interpreter_frame_manager) { | |
1552 return interpreter_frame_manager; | |
1553 } | |
1554 | |
1555 __ bind(frame_manager_entry); | |
1556 | |
1557 // the following temporary registers are used during frame creation | |
1558 const Register Gtmp1 = G3_scratch; | |
1559 // const Register Lmirror = L1; // native mirror (native calls only) | |
1560 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1561 const Address constMethod (G5_method, 0, in_bytes(Method::const_offset())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1562 const Address access_flags (G5_method, 0, in_bytes(Method::access_flags_offset())); |
0 | 1563 |
1564 address entry_point = __ pc(); | |
1565 __ mov(G0, prevState); // no current activation | |
1566 | |
1567 | |
1568 Label re_dispatch; | |
1569 | |
1570 __ bind(re_dispatch); | |
1571 | |
1572 // Interpreter needs to have locals completely contiguous. In order to do that | |
1573 // We must adjust the caller's stack pointer for any locals beyond just the | |
1574 // parameters | |
1575 adjust_callers_stack(Gargs); | |
1576 | |
1577 // O5_savedSP still contains sender's sp | |
1578 | |
1579 // NEW FRAME | |
1580 | |
1581 generate_compute_interpreter_state(Lstate, prevState, false); | |
1582 | |
1583 // At this point a new interpreter frame and state object are created and initialized | |
1584 // Lstate has the pointer to the new activation | |
1585 // Any stack banging or limit check should already be done. | |
1586 | |
1587 Label call_interpreter; | |
1588 | |
1589 __ bind(call_interpreter); | |
1590 | |
1591 | |
1592 #if 1 | |
1593 __ set(0xdead002, Lmirror); | |
1594 __ set(0xdead002, L2_scratch); | |
1595 __ set(0xdead003, L3_scratch); | |
1596 __ set(0xdead004, L4_scratch); | |
1597 __ set(0xdead005, Lscratch); | |
1598 __ set(0xdead006, Lscratch2); | |
1599 __ set(0xdead007, L7_scratch); | |
1600 | |
1601 __ set(0xdeaf002, O2); | |
1602 __ set(0xdeaf003, O3); | |
1603 __ set(0xdeaf004, O4); | |
1604 __ set(0xdeaf005, O5); | |
1605 #endif | |
1606 | |
1607 // Call interpreter (stack bang complete) enter here if message is | |
1608 // set and we know stack size is valid | |
1609 | |
1610 Label call_interpreter_2; | |
1611 | |
1612 __ bind(call_interpreter_2); | |
1613 | |
1614 #ifdef ASSERT | |
1615 { | |
1616 Label skip; | |
1617 __ ld_ptr(STATE(_frame_bottom), G3_scratch); | |
1618 __ cmp(G3_scratch, SP); | |
1619 __ brx(Assembler::equal, false, Assembler::pt, skip); | |
1620 __ delayed()->nop(); | |
1621 __ stop("SP not restored to frame bottom"); | |
1622 __ bind(skip); | |
1623 } | |
1624 #endif | |
1625 | |
1626 VALIDATE_STATE(G3_scratch, 4); | |
1627 __ set_last_Java_frame(SP, noreg); | |
1628 __ mov(Lstate, O0); // (arg) pointer to current state | |
1629 | |
1630 __ call(CAST_FROM_FN_PTR(address, | |
1631 JvmtiExport::can_post_interpreter_events() ? | |
1632 BytecodeInterpreter::runWithChecks | |
1633 : BytecodeInterpreter::run), | |
1634 relocInfo::runtime_call_type); | |
1635 | |
1636 __ delayed()->nop(); | |
1637 | |
1638 __ ld_ptr(STATE(_thread), G2_thread); | |
1639 __ reset_last_Java_frame(); | |
1640 | |
1641 // examine msg from interpreter to determine next action | |
1642 __ ld_ptr(STATE(_thread), G2_thread); // restore G2_thread | |
1643 | |
1644 __ ld(STATE(_msg), L1_scratch); // Get new message | |
1645 | |
1646 Label call_method; | |
1647 Label return_from_interpreted_method; | |
1648 Label throw_exception; | |
1649 Label do_OSR; | |
1650 Label bad_msg; | |
1651 Label resume_interpreter; | |
1652 | |
1653 __ cmp(L1_scratch, (int)BytecodeInterpreter::call_method); | |
1654 __ br(Assembler::equal, false, Assembler::pt, call_method); | |
1655 __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::return_from_method); | |
1656 __ br(Assembler::equal, false, Assembler::pt, return_from_interpreted_method); | |
1657 __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::throwing_exception); | |
1658 __ br(Assembler::equal, false, Assembler::pt, throw_exception); | |
1659 __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::do_osr); | |
1660 __ br(Assembler::equal, false, Assembler::pt, do_OSR); | |
1661 __ delayed()->cmp(L1_scratch, (int)BytecodeInterpreter::more_monitors); | |
1662 __ br(Assembler::notEqual, false, Assembler::pt, bad_msg); | |
1663 | |
1664 // Allocate more monitor space, shuffle expression stack.... | |
1665 | |
1666 generate_more_monitors(); | |
1667 | |
1668 // new monitor slot allocated, resume the interpreter. | |
1669 | |
1670 __ set((int)BytecodeInterpreter::got_monitors, L1_scratch); | |
1671 VALIDATE_STATE(G3_scratch, 5); | |
3839 | 1672 __ ba(call_interpreter); |
0 | 1673 __ delayed()->st(L1_scratch, STATE(_msg)); |
1674 | |
1675 // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode) | |
1676 unctrap_frame_manager_entry = __ pc(); | |
1677 | |
1678 // QQQ what message do we send | |
1679 | |
3839 | 1680 __ ba(call_interpreter); |
0 | 1681 __ delayed()->ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame |
1682 | |
1683 //============================================================================= | |
1684 // Returning from a compiled method into a deopted method. The bytecode at the | |
1685 // bcp has completed. The result of the bytecode is in the native abi (the tosca | |
1686 // for the template based interpreter). Any stack space that was used by the | |
1687 // bytecode that has completed has been removed (e.g. parameters for an invoke) | |
1688 // so all that we have to do is place any pending result on the expression stack | |
1689 // and resume execution on the next bytecode. | |
1690 | |
1691 generate_deopt_handling(); | |
1692 | |
1693 // ready to resume the interpreter | |
1694 | |
1695 __ set((int)BytecodeInterpreter::deopt_resume, L1_scratch); | |
3839 | 1696 __ ba(call_interpreter); |
0 | 1697 __ delayed()->st(L1_scratch, STATE(_msg)); |
1698 | |
1699 // Current frame has caught an exception we need to dispatch to the | |
1700 // handler. We can get here because a native interpreter frame caught | |
1701 // an exception in which case there is no handler and we must rethrow | |
1702 // If it is a vanilla interpreted frame the we simply drop into the | |
1703 // interpreter and let it do the lookup. | |
1704 | |
1705 Interpreter::_rethrow_exception_entry = __ pc(); | |
1706 | |
1707 Label return_with_exception; | |
1708 Label unwind_and_forward; | |
1709 | |
1710 // O0: exception | |
1711 // O7: throwing pc | |
1712 | |
1713 // We want exception in the thread no matter what we ultimately decide about frame type. | |
1714 | |
1715 Address exception_addr (G2_thread, 0, in_bytes(Thread::pending_exception_offset())); | |
1716 __ verify_thread(); | |
1717 __ st_ptr(O0, exception_addr); | |
1718 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1719 // get the Method* |
0 | 1720 __ ld_ptr(STATE(_method), G5_method); |
1721 | |
1722 // if this current frame vanilla or native? | |
1723 | |
1724 __ ld(access_flags, Gtmp1); | |
1725 __ btst(JVM_ACC_NATIVE, Gtmp1); | |
1726 __ br(Assembler::zero, false, Assembler::pt, return_with_exception); // vanilla interpreted frame handle directly | |
1727 __ delayed()->nop(); | |
1728 | |
1729 // We drop thru to unwind a native interpreted frame with a pending exception | |
1730 // We jump here for the initial interpreter frame with exception pending | |
1731 // We unwind the current acivation and forward it to our caller. | |
1732 | |
1733 __ bind(unwind_and_forward); | |
1734 | |
1735 // Unwind frame and jump to forward exception. unwinding will place throwing pc in O7 | |
1736 // as expected by forward_exception. | |
1737 | |
1738 __ restore(FP, G0, SP); // unwind interpreter state frame | |
1739 __ br(Assembler::always, false, Assembler::pt, StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type); | |
1740 __ delayed()->mov(I5_savedSP->after_restore(), SP); | |
1741 | |
1742 // Return point from a call which returns a result in the native abi | |
1743 // (c1/c2/jni-native). This result must be processed onto the java | |
1744 // expression stack. | |
1745 // | |
1746 // A pending exception may be present in which case there is no result present | |
1747 | |
1748 address return_from_native_method = __ pc(); | |
1749 | |
1750 VALIDATE_STATE(G3_scratch, 6); | |
1751 | |
1752 // Result if any is in native abi result (O0..O1/F0..F1). The java expression | |
1753 // stack is in the state that the calling convention left it. | |
1754 // Copy the result from native abi result and place it on java expression stack. | |
1755 | |
1756 // Current interpreter state is present in Lstate | |
1757 | |
1758 // Exception pending? | |
1759 | |
1760 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame | |
1761 __ ld_ptr(exception_addr, Lscratch); // get any pending exception | |
1762 __ tst(Lscratch); // exception pending? | |
1763 __ brx(Assembler::notZero, false, Assembler::pt, return_with_exception); | |
1764 __ delayed()->nop(); | |
1765 | |
1766 // Process the native abi result to java expression stack | |
1767 | |
1768 __ ld_ptr(STATE(_result._to_call._callee), L4_scratch); // called method | |
1769 __ ld_ptr(STATE(_stack), L1_scratch); // get top of java expr stack | |
7402
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1770 // get parameter size |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1771 __ ld_ptr(L4_scratch, in_bytes(Method::const_offset()), L2_scratch); |
fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
jiangli
parents:
7183
diff
changeset
|
1772 __ lduh(L2_scratch, in_bytes(ConstMethod::size_of_parameters_offset()), L2_scratch); |
0 | 1773 __ sll(L2_scratch, LogBytesPerWord, L2_scratch ); // parameter size in bytes |
1774 __ add(L1_scratch, L2_scratch, L1_scratch); // stack destination for result | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1775 __ ld(L4_scratch, in_bytes(Method::result_index_offset()), L3_scratch); // called method result type index |
0 | 1776 |
1777 // tosca is really just native abi | |
1778 __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch); | |
1779 __ sll(L3_scratch, LogBytesPerWord, L3_scratch); | |
1780 __ ld_ptr(L4_scratch, L3_scratch, Lscratch); // get typed result converter address | |
1781 __ jmpl(Lscratch, G0, O7); // and convert it | |
1782 __ delayed()->nop(); | |
1783 | |
1784 // L1_scratch points to top of stack (prepushed) | |
1785 | |
3839 | 1786 __ ba(resume_interpreter); |
0 | 1787 __ delayed()->mov(L1_scratch, O1); |
1788 | |
1789 // An exception is being caught on return to a vanilla interpreter frame. | |
1790 // Empty the stack and resume interpreter | |
1791 | |
1792 __ bind(return_with_exception); | |
1793 | |
1794 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame | |
1795 __ ld_ptr(STATE(_stack_base), O1); // empty java expression stack | |
3839 | 1796 __ ba(resume_interpreter); |
0 | 1797 __ delayed()->sub(O1, wordSize, O1); // account for prepush |
1798 | |
1799 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive" | |
1800 // interpreter call, or native) and unwind this interpreter activation. | |
1801 // All monitors should be unlocked. | |
1802 | |
1803 __ bind(return_from_interpreted_method); | |
1804 | |
1805 VALIDATE_STATE(G3_scratch, 7); | |
1806 | |
1807 Label return_to_initial_caller; | |
1808 | |
1809 // Interpreted result is on the top of the completed activation expression stack. | |
1810 // We must return it to the top of the callers stack if caller was interpreted | |
1811 // otherwise we convert to native abi result and return to call_stub/c1/c2 | |
1812 // The caller's expression stack was truncated by the call however the current activation | |
1813 // has enough stuff on the stack that we have usable space there no matter what. The | |
1814 // other thing that makes it easy is that the top of the caller's stack is stored in STATE(_locals) | |
1815 // for the current activation | |
1816 | |
1817 __ ld_ptr(STATE(_prev_link), L1_scratch); | |
1818 __ ld_ptr(STATE(_method), L2_scratch); // get method just executed | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1819 __ ld(L2_scratch, in_bytes(Method::result_index_offset()), L2_scratch); |
0 | 1820 __ tst(L1_scratch); |
1821 __ brx(Assembler::zero, false, Assembler::pt, return_to_initial_caller); | |
1822 __ delayed()->sll(L2_scratch, LogBytesPerWord, L2_scratch); | |
1823 | |
1824 // Copy result to callers java stack | |
1825 | |
1826 __ set((intptr_t)CppInterpreter::_stack_to_stack, L4_scratch); | |
1827 __ ld_ptr(L4_scratch, L2_scratch, Lscratch); // get typed result converter address | |
1828 __ ld_ptr(STATE(_stack), O0); // current top (prepushed) | |
1829 __ ld_ptr(STATE(_locals), O1); // stack destination | |
1830 | |
1831 // O0 - will be source, O1 - will be destination (preserved) | |
1832 __ jmpl(Lscratch, G0, O7); // and convert it | |
1833 __ delayed()->add(O0, wordSize, O0); // get source (top of current expr stack) | |
1834 | |
1835 // O1 == &locals[0] | |
1836 | |
1837 // Result is now on caller's stack. Just unwind current activation and resume | |
1838 | |
1839 Label unwind_recursive_activation; | |
1840 | |
1841 | |
1842 __ bind(unwind_recursive_activation); | |
1843 | |
1844 // O1 == &locals[0] (really callers stacktop) for activation now returning | |
1845 // returning to interpreter method from "recursive" interpreter call | |
1846 // result converter left O1 pointing to top of the( prepushed) java stack for method we are returning | |
1847 // to. Now all we must do is unwind the state from the completed call | |
1848 | |
1849 // Must restore stack | |
1850 VALIDATE_STATE(G3_scratch, 8); | |
1851 | |
1852 // Return to interpreter method after a method call (interpreted/native/c1/c2) has completed. | |
1853 // Result if any is already on the caller's stack. All we must do now is remove the now dead | |
1854 // frame and tell interpreter to resume. | |
1855 | |
1856 | |
1857 __ mov(O1, I1); // pass back new stack top across activation | |
1858 // POP FRAME HERE ================================== | |
1859 __ restore(FP, G0, SP); // unwind interpreter state frame | |
1860 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame | |
1861 | |
1862 | |
1863 // Resume the interpreter. The current frame contains the current interpreter | |
1864 // state object. | |
1865 // | |
1866 // O1 == new java stack pointer | |
1867 | |
1868 __ bind(resume_interpreter); | |
1869 VALIDATE_STATE(G3_scratch, 10); | |
1870 | |
1871 // A frame we have already used before so no need to bang stack so use call_interpreter_2 entry | |
1872 | |
1873 __ set((int)BytecodeInterpreter::method_resume, L1_scratch); | |
1874 __ st(L1_scratch, STATE(_msg)); | |
3839 | 1875 __ ba(call_interpreter_2); |
0 | 1876 __ delayed()->st_ptr(O1, STATE(_stack)); |
1877 | |
1878 | |
1879 // Fast accessor methods share this entry point. | |
1880 // This works because frame manager is in the same codelet | |
1881 // This can either be an entry via call_stub/c1/c2 or a recursive interpreter call | |
1882 // we need to do a little register fixup here once we distinguish the two of them | |
1883 if (UseFastAccessorMethods && !synchronized) { | |
1884 // Call stub_return address still in O7 | |
1885 __ bind(fast_accessor_slow_entry_path); | |
1886 __ set((intptr_t)return_from_native_method - 8, Gtmp1); | |
1887 __ cmp(Gtmp1, O7); // returning to interpreter? | |
1888 __ brx(Assembler::equal, true, Assembler::pt, re_dispatch); // yep | |
1889 __ delayed()->nop(); | |
3839 | 1890 __ ba(re_dispatch); |
1891 __ delayed()->mov(G0, prevState); // initial entry | |
0 | 1892 |
1893 } | |
1894 | |
1895 // interpreter returning to native code (call_stub/c1/c2) | |
1896 // convert result and unwind initial activation | |
1897 // L2_scratch - scaled result type index | |
1898 | |
1899 __ bind(return_to_initial_caller); | |
1900 | |
1901 __ set((intptr_t)CppInterpreter::_stack_to_native_abi, L4_scratch); | |
1902 __ ld_ptr(L4_scratch, L2_scratch, Lscratch); // get typed result converter address | |
1903 __ ld_ptr(STATE(_stack), O0); // current top (prepushed) | |
1904 __ jmpl(Lscratch, G0, O7); // and convert it | |
1905 __ delayed()->add(O0, wordSize, O0); // get source (top of current expr stack) | |
1906 | |
1907 Label unwind_initial_activation; | |
1908 __ bind(unwind_initial_activation); | |
1909 | |
1910 // RETURN TO CALL_STUB/C1/C2 code (result if any in I0..I1/(F0/..F1) | |
1911 // we can return here with an exception that wasn't handled by interpreted code | |
1912 // how does c1/c2 see it on return? | |
1913 | |
1914 // compute resulting sp before/after args popped depending upon calling convention | |
1915 // __ ld_ptr(STATE(_saved_sp), Gtmp1); | |
1916 // | |
1917 // POP FRAME HERE ================================== | |
1918 __ restore(FP, G0, SP); | |
1919 __ retl(); | |
1920 __ delayed()->mov(I5_savedSP->after_restore(), SP); | |
1921 | |
1922 // OSR request, unwind the current frame and transfer to the OSR entry | |
1923 // and enter OSR nmethod | |
1924 | |
1925 __ bind(do_OSR); | |
1926 Label remove_initial_frame; | |
1927 __ ld_ptr(STATE(_prev_link), L1_scratch); | |
1928 __ ld_ptr(STATE(_result._osr._osr_buf), G1_scratch); | |
1929 | |
1930 // We are going to pop this frame. Is there another interpreter frame underneath | |
1931 // it or is it callstub/compiled? | |
1932 | |
1933 __ tst(L1_scratch); | |
1934 __ brx(Assembler::zero, false, Assembler::pt, remove_initial_frame); | |
1935 __ delayed()->ld_ptr(STATE(_result._osr._osr_entry), G3_scratch); | |
1936 | |
1937 // Frame underneath is an interpreter frame simply unwind | |
1938 // POP FRAME HERE ================================== | |
1939 __ restore(FP, G0, SP); // unwind interpreter state frame | |
1940 __ mov(I5_savedSP->after_restore(), SP); | |
1941 | |
1942 // Since we are now calling native need to change our "return address" from the | |
1943 // dummy RecursiveInterpreterActivation to a return from native | |
1944 | |
1945 __ set((intptr_t)return_from_native_method - 8, O7); | |
1946 | |
1947 __ jmpl(G3_scratch, G0, G0); | |
1948 __ delayed()->mov(G1_scratch, O0); | |
1949 | |
1950 __ bind(remove_initial_frame); | |
1951 | |
1952 // POP FRAME HERE ================================== | |
1953 __ restore(FP, G0, SP); | |
1954 __ mov(I5_savedSP->after_restore(), SP); | |
1955 __ jmpl(G3_scratch, G0, G0); | |
1956 __ delayed()->mov(G1_scratch, O0); | |
1957 | |
1958 // Call a new method. All we do is (temporarily) trim the expression stack | |
1959 // push a return address to bring us back to here and leap to the new entry. | |
1960 // At this point we have a topmost frame that was allocated by the frame manager | |
1961 // which contains the current method interpreted state. We trim this frame | |
1962 // of excess java expression stack entries and then recurse. | |
1963 | |
1964 __ bind(call_method); | |
1965 | |
1966 // stack points to next free location and not top element on expression stack | |
1967 // method expects sp to be pointing to topmost element | |
1968 | |
1969 __ ld_ptr(STATE(_thread), G2_thread); | |
1970 __ ld_ptr(STATE(_result._to_call._callee), G5_method); | |
1971 | |
1972 | |
1973 // SP already takes in to account the 2 extra words we use for slop | |
1974 // when we call a "static long no_params()" method. So if | |
1975 // we trim back sp by the amount of unused java expression stack | |
1976 // there will be automagically the 2 extra words we need. | |
1977 // We also have to worry about keeping SP aligned. | |
1978 | |
1979 __ ld_ptr(STATE(_stack), Gargs); | |
1980 __ ld_ptr(STATE(_stack_limit), L1_scratch); | |
1981 | |
1982 // compute the unused java stack size | |
1983 __ sub(Gargs, L1_scratch, L2_scratch); // compute unused space | |
1984 | |
123 | 1985 // Round down the unused space to that stack is always 16-byte aligned |
1986 // by making the unused space a multiple of the size of two longs. | |
0 | 1987 |
123 | 1988 __ and3(L2_scratch, -2*BytesPerLong, L2_scratch); |
0 | 1989 |
1990 // Now trim the stack | |
1991 __ add(SP, L2_scratch, SP); | |
1992 | |
1993 | |
1994 // Now point to the final argument (account for prepush) | |
1995 __ add(Gargs, wordSize, Gargs); | |
1996 #ifdef ASSERT | |
1997 // Make sure we have space for the window | |
1998 __ sub(Gargs, SP, L1_scratch); | |
1999 __ cmp(L1_scratch, 16*wordSize); | |
2000 { | |
2001 Label skip; | |
2002 __ brx(Assembler::greaterEqual, false, Assembler::pt, skip); | |
2003 __ delayed()->nop(); | |
2004 __ stop("killed stack"); | |
2005 __ bind(skip); | |
2006 } | |
2007 #endif // ASSERT | |
2008 | |
2009 // Create a new frame where we can store values that make it look like the interpreter | |
2010 // really recursed. | |
2011 | |
2012 // prepare to recurse or call specialized entry | |
2013 | |
2014 // First link the registers we need | |
2015 | |
2016 // make the pc look good in debugger | |
2017 __ set(CAST_FROM_FN_PTR(intptr_t, RecursiveInterpreterActivation), O7); | |
2018 // argument too | |
2019 __ mov(Lstate, I0); | |
2020 | |
2021 // Record our sending SP | |
2022 __ mov(SP, O5_savedSP); | |
2023 | |
2024 __ ld_ptr(STATE(_result._to_call._callee_entry_point), L2_scratch); | |
2025 __ set((intptr_t) entry_point, L1_scratch); | |
2026 __ cmp(L1_scratch, L2_scratch); | |
2027 __ brx(Assembler::equal, false, Assembler::pt, re_dispatch); | |
2028 __ delayed()->mov(Lstate, prevState); // link activations | |
2029 | |
2030 // method uses specialized entry, push a return so we look like call stub setup | |
2031 // this path will handle fact that result is returned in registers and not | |
2032 // on the java stack. | |
2033 | |
2034 __ set((intptr_t)return_from_native_method - 8, O7); | |
2035 __ jmpl(L2_scratch, G0, G0); // Do specialized entry | |
2036 __ delayed()->nop(); | |
2037 | |
2038 // | |
2039 // Bad Message from interpreter | |
2040 // | |
2041 __ bind(bad_msg); | |
2042 __ stop("Bad message from interpreter"); | |
2043 | |
2044 // Interpreted method "returned" with an exception pass it on... | |
2045 // Pass result, unwind activation and continue/return to interpreter/call_stub | |
2046 // We handle result (if any) differently based on return to interpreter or call_stub | |
2047 | |
2048 __ bind(throw_exception); | |
2049 __ ld_ptr(STATE(_prev_link), L1_scratch); | |
2050 __ tst(L1_scratch); | |
2051 __ brx(Assembler::zero, false, Assembler::pt, unwind_and_forward); | |
2052 __ delayed()->nop(); | |
2053 | |
3839 | 2054 __ ld_ptr(STATE(_locals), O1); // get result of popping callee's args |
2055 __ ba(unwind_recursive_activation); | |
0 | 2056 __ delayed()->nop(); |
2057 | |
2058 interpreter_frame_manager = entry_point; | |
2059 return entry_point; | |
2060 } | |
2061 | |
2062 InterpreterGenerator::InterpreterGenerator(StubQueue* code) | |
2063 : CppInterpreterGenerator(code) { | |
2064 generate_all(); // down here so it can be "virtual" | |
2065 } | |
2066 | |
2067 | |
2068 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) { | |
2069 | |
2070 // Figure out the size of an interpreter frame (in words) given that we have a fully allocated | |
2071 // expression stack, the callee will have callee_extra_locals (so we can account for | |
2072 // frame extension) and monitor_size for monitors. Basically we need to calculate | |
2073 // this exactly like generate_fixed_frame/generate_compute_interpreter_state. | |
2074 // | |
2075 // | |
2076 // The big complicating thing here is that we must ensure that the stack stays properly | |
2077 // aligned. This would be even uglier if monitor size wasn't modulo what the stack | |
2078 // needs to be aligned for). We are given that the sp (fp) is already aligned by | |
2079 // the caller so we must ensure that it is properly aligned for our callee. | |
2080 // | |
2081 // Ths c++ interpreter always makes sure that we have a enough extra space on the | |
2082 // stack at all times to deal with the "stack long no_params()" method issue. This | |
2083 // is "slop_factor" here. | |
2084 const int slop_factor = 2; | |
2085 | |
2086 const int fixed_size = sizeof(BytecodeInterpreter)/wordSize + // interpreter state object | |
2087 frame::memory_parameter_word_sp_offset; // register save area + param window | |
2088 return (round_to(max_stack + | |
2089 slop_factor + | |
2090 fixed_size + | |
2091 monitor_size + | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2092 (callee_extra_locals * Interpreter::stackElementWords), WordsPerLong)); |
0 | 2093 |
2094 } | |
2095 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2096 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
0 | 2097 |
2098 // See call_stub code | |
2099 int call_stub_size = round_to(7 + frame::memory_parameter_word_sp_offset, | |
2100 WordsPerLong); // 7 + register save area | |
2101 | |
2102 // Save space for one monitor to get into the interpreted method in case | |
2103 // the method is synchronized | |
2104 int monitor_size = method->is_synchronized() ? | |
2105 1*frame::interpreter_frame_monitor_size() : 0; | |
2106 return size_activation_helper(method->max_locals(), method->max_stack(), | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2107 monitor_size) + call_stub_size; |
0 | 2108 } |
2109 | |
2110 void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, | |
2111 frame* caller, | |
2112 frame* current, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2113 Method* method, |
0 | 2114 intptr_t* locals, |
2115 intptr_t* stack, | |
2116 intptr_t* stack_base, | |
2117 intptr_t* monitor_base, | |
2118 intptr_t* frame_bottom, | |
2119 bool is_top_frame | |
2120 ) | |
2121 { | |
2122 // What about any vtable? | |
2123 // | |
2124 to_fill->_thread = JavaThread::current(); | |
2125 // This gets filled in later but make it something recognizable for now | |
2126 to_fill->_bcp = method->code_base(); | |
2127 to_fill->_locals = locals; | |
2128 to_fill->_constants = method->constants()->cache(); | |
2129 to_fill->_method = method; | |
2130 to_fill->_mdx = NULL; | |
2131 to_fill->_stack = stack; | |
2132 if (is_top_frame && JavaThread::current()->popframe_forcing_deopt_reexecution() ) { | |
2133 to_fill->_msg = deopt_resume2; | |
2134 } else { | |
2135 to_fill->_msg = method_resume; | |
2136 } | |
2137 to_fill->_result._to_call._bcp_advance = 0; | |
2138 to_fill->_result._to_call._callee_entry_point = NULL; // doesn't matter to anyone | |
2139 to_fill->_result._to_call._callee = NULL; // doesn't matter to anyone | |
2140 to_fill->_prev_link = NULL; | |
2141 | |
2142 // Fill in the registers for the frame | |
2143 | |
2144 // Need to install _sender_sp. Actually not too hard in C++! | |
2145 // When the skeletal frames are layed out we fill in a value | |
2146 // for _sender_sp. That value is only correct for the oldest | |
2147 // skeletal frame constructed (because there is only a single | |
2148 // entry for "caller_adjustment". While the skeletal frames | |
2149 // exist that is good enough. We correct that calculation | |
2150 // here and get all the frames correct. | |
2151 | |
2152 // to_fill->_sender_sp = locals - (method->size_of_parameters() - 1); | |
2153 | |
2154 *current->register_addr(Lstate) = (intptr_t) to_fill; | |
2155 // skeletal already places a useful value here and this doesn't account | |
2156 // for alignment so don't bother. | |
2157 // *current->register_addr(I5_savedSP) = (intptr_t) locals - (method->size_of_parameters() - 1); | |
2158 | |
2159 if (caller->is_interpreted_frame()) { | |
2160 interpreterState prev = caller->get_interpreterState(); | |
2161 to_fill->_prev_link = prev; | |
2162 // Make the prev callee look proper | |
2163 prev->_result._to_call._callee = method; | |
2164 if (*prev->_bcp == Bytecodes::_invokeinterface) { | |
2165 prev->_result._to_call._bcp_advance = 5; | |
2166 } else { | |
2167 prev->_result._to_call._bcp_advance = 3; | |
2168 } | |
2169 } | |
2170 to_fill->_oop_temp = NULL; | |
2171 to_fill->_stack_base = stack_base; | |
2172 // Need +1 here because stack_base points to the word just above the first expr stack entry | |
2173 // and stack_limit is supposed to point to the word just below the last expr stack entry. | |
2174 // See generate_compute_interpreter_state. | |
10393
603ca7e51354
8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
roland
parents:
10105
diff
changeset
|
2175 to_fill->_stack_limit = stack_base - (method->max_stack() + 1); |
0 | 2176 to_fill->_monitor_base = (BasicObjectLock*) monitor_base; |
2177 | |
2178 // sparc specific | |
2179 to_fill->_frame_bottom = frame_bottom; | |
2180 to_fill->_self_link = to_fill; | |
2181 #ifdef ASSERT | |
2182 to_fill->_native_fresult = 123456.789; | |
2183 to_fill->_native_lresult = CONST64(0xdeadcafedeafcafe); | |
2184 #endif | |
2185 } | |
2186 | |
2187 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) { | |
2188 istate->_last_Java_pc = (intptr_t*) last_Java_pc; | |
2189 } | |
2190 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2191 static int frame_size_helper(int max_stack, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2192 int moncount, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2193 int callee_param_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2194 int callee_locals_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2195 bool is_top_frame, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2196 int& monitor_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2197 int& full_frame_words) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2198 int extra_locals_size = callee_locals_size - callee_param_size; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2199 monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2200 full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2201 int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2202 int frame_words = is_top_frame ? full_frame_words : short_frame_words; |
0 | 2203 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2204 return frame_words; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2205 } |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2206 |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2207 int AbstractInterpreter::size_activation(int max_stack, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2208 int tempcount, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2209 int extra_args, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2210 int moncount, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2211 int callee_param_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2212 int callee_locals_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2213 bool is_top_frame) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2214 assert(extra_args == 0, "NEED TO FIX"); |
0 | 2215 // NOTE: return size is in words not bytes |
2216 // Calculate the amount our frame will be adjust by the callee. For top frame | |
2217 // this is zero. | |
2218 | |
2219 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it | |
2220 // calculates the extra locals based on itself. Not what the callee does | |
2221 // to it. So it ignores last_frame_adjust value. Seems suspicious as far | |
2222 // as getting sender_sp correct. | |
2223 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2224 int unused_monitor_size = 0; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2225 int unused_full_frame_words = 0; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2226 return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2227 unused_monitor_size, unused_full_frame_words); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2228 } |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2229 void AbstractInterpreter::layout_activation(Method* method, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2230 int tempcount, // Number of slots on java expression stack in use |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2231 int popframe_extra_args, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2232 int moncount, // Number of active monitors |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2233 int caller_actual_parameters, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2234 int callee_param_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2235 int callee_locals_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2236 frame* caller, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2237 frame* interpreter_frame, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2238 bool is_top_frame, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2239 bool is_bottom_frame) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2240 assert(popframe_extra_args == 0, "NEED TO FIX"); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2241 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2242 // does as far as allocating an interpreter frame. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2243 // Set up the method, locals, and monitors. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2244 // The frame interpreter_frame is guaranteed to be the right size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2245 // as determined by a previous call to the size_activation() method. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2246 // It is also guaranteed to be walkable even though it is in a skeletal state |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2247 // NOTE: tempcount is the current size of the java expression stack. For top most |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2248 // frames we will allocate a full sized expression stack and not the curback |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2249 // version that non-top frames have. |
0 | 2250 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2251 int monitor_size = 0; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2252 int full_frame_words = 0; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2253 int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2254 is_top_frame, monitor_size, full_frame_words); |
0 | 2255 |
2256 /* | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2257 We must now fill in all the pieces of the frame. This means both |
0 | 2258 the interpreterState and the registers. |
2259 */ | |
2260 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2261 // MUCHO HACK |
0 | 2262 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2263 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2264 // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2265 assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation"); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2266 frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS); |
0 | 2267 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2268 /* Now fillin the interpreterState object */ |
0 | 2269 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2270 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter)); |
0 | 2271 |
2272 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2273 intptr_t* locals; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2274 |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2275 // Calculate the postion of locals[0]. This is painful because of |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2276 // stack alignment (same as ia64). The problem is that we can |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2277 // not compute the location of locals from fp(). fp() will account |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2278 // for the extra locals but it also accounts for aligning the stack |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2279 // and we can't determine if the locals[0] was misaligned but max_locals |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2280 // was enough to have the |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2281 // calculate postion of locals. fp already accounts for extra locals. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2282 // +2 for the static long no_params() issue. |
0 | 2283 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2284 if (caller->is_interpreted_frame()) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2285 // locals must agree with the caller because it will be used to set the |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2286 // caller's tos when we return. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2287 interpreterState prev = caller->get_interpreterState(); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2288 // stack() is prepushed. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2289 locals = prev->stack() + method->size_of_parameters(); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2290 } else { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2291 // Lay out locals block in the caller adjacent to the register window save area. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2292 // |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2293 // Compiled frames do not allocate a varargs area which is why this if |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2294 // statement is needed. |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2295 // |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2296 intptr_t* fp = interpreter_frame->fp(); |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2297 int local_words = method->max_locals() * Interpreter::stackElementWords; |
0 | 2298 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2299 if (caller->is_compiled_frame()) { |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2300 locals = fp + frame::register_save_words + local_words - 1; |
0 | 2301 } else { |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2302 locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2303 } |
0 | 2304 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2305 } |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2306 // END MUCHO HACK |
0 | 2307 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2308 intptr_t* monitor_base = (intptr_t*) cur_state; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2309 intptr_t* stack_base = monitor_base - monitor_size; |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2310 /* +1 because stack is always prepushed */ |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2311 intptr_t* stack = stack_base - (tempcount + 1); |
0 | 2312 |
2313 | |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2314 BytecodeInterpreter::layout_interpreterState(cur_state, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2315 caller, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2316 interpreter_frame, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2317 method, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2318 locals, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2319 stack, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2320 stack_base, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2321 monitor_base, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2322 frame_bottom, |
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2323 is_top_frame); |
0 | 2324 |
17980
0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents:
17850
diff
changeset
|
2325 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); |
0 | 2326 } |
2327 | |
2328 #endif // CC_INTERP |