1 #ifdef USE_PRAGMA_IDENT_HDR
2 #pragma ident "@(#)cppInterpreter_sparc.cpp 1.1 07/08/29 13:42:16 JVM"
3 #endif
4 /*
5 * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
145 __ srl(O0, 16, O0);
146 __ st(O0, L1_scratch, 0);
147 __ sub(L1_scratch, wordSize, L1_scratch);
148 break;
149
150 case T_BYTE :
151 __ sll(O0, 24, O0);
152 __ sra(O0, 24, O0);
153 __ st(O0, L1_scratch, 0);
154 __ sub(L1_scratch, wordSize, L1_scratch);
155 break;
156
157 case T_SHORT :
158 __ sll(O0, 16, O0);
159 __ sra(O0, 16, O0);
160 __ st(O0, L1_scratch, 0);
161 __ sub(L1_scratch, wordSize, L1_scratch);
162 break;
163 case T_LONG :
164 #ifndef _LP64
165 #if !defined(_LP64) && defined(COMPILER2)
166 // All return values are where we want them, except for Longs. C2 returns
167 // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1.
168 // Since the interpreter will return longs in G1 and O0/O1 in the 32bit
169 // build even if we are returning from interpreted we just do a little
170 // stupid shuffing.
171 // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to
172 // do this here. Unfortunately if we did a rethrow we'd see an machepilog node
173 // first which would move g1 -> O0/O1 and destroy the exception we were throwing.
174 __ stx(G1, L1_scratch, -wordSize);
175 #else
176 // native result is in O0, O1
177 __ st(O1, L1_scratch, 0); // Low order
178 __ st(O0, L1_scratch, -wordSize); // High order
179 #endif /* !_LP64 && COMPILER2 */
180 #else
181 __ stx(O0, L1_scratch, 0);
182 __ breakpoint_trap();
183 #endif
184 __ sub(L1_scratch, 2*wordSize, L1_scratch);
185 break;
186
187 case T_INT :
188 __ st(O0, L1_scratch, 0);
189 __ sub(L1_scratch, wordSize, L1_scratch);
190 break;
191
192 case T_VOID : /* nothing to do */
193 break;
194
195 case T_FLOAT :
196 __ stf(FloatRegisterImpl::S, F0, L1_scratch, 0);
197 __ sub(L1_scratch, wordSize, L1_scratch);
198 break;
199
200 case T_DOUBLE :
201 // Every stack slot is aligned on 64 bit, However is this
202 // the correct stack slot on 64bit?? QQQ
223 // The current interpreter activation in Lstate is for the method just returning its
224 // result. So we know that the result of this method is on the top of the current
225 // execution stack (which is pre-pushed) and will be return to the top of the caller
226 // stack. The top of the callers stack is the bottom of the locals of the current
227 // activation.
228 // Because of the way activation are managed by the frame manager the value of esp is
229 // below both the stack top of the current activation and naturally the stack top
230 // of the calling activation. This enable this routine to leave the return address
231 // to the frame manager on the stack and do a vanilla return.
232 //
233 // On entry: O0 - points to source (callee stack top)
234 // O1 - points to destination (caller stack top [i.e. free location])
235 // destroys O2, O3
236 //
237
238 address entry = __ pc();
239 switch (type) {
240 case T_VOID: break;
241 break;
242 case T_FLOAT :
243 __ breakpoint_trap(Assembler::zero);
244 case T_BOOLEAN:
245 case T_CHAR :
246 case T_BYTE :
247 case T_SHORT :
248 case T_INT :
249 // 1 word result
250 __ ld(O0, 0, O2);
251 __ st(O2, O1, 0);
252 __ sub(O1, wordSize, O1);
253 break;
254 case T_DOUBLE :
255 case T_LONG :
256 // return top two words on current expression stack to caller's expression stack
257 // The caller's expression stack is adjacent to the current frame manager's intepretState
258 // except we allocated one extra word for this intepretState so we won't overwrite it
259 // when we return a two word result.
260 #ifdef _LP64
261 __ breakpoint_trap();
262 // Hmm now that longs are in one entry should "_ptr" really be "x"?
263 __ ld_ptr(O0, 0, O2);
264 __ ld_ptr(O0, wordSize, O3);
265 __ st_ptr(O3, O1, 0);
266 __ st_ptr(O2, O1, -wordSize);
267 #else
268 __ ld(O0, 0, O2);
269 __ ld(O0, wordSize, O3);
270 __ st(O3, O1, 0);
271 __ st(O2, O1, -wordSize);
272 #endif
273 __ sub(O1, 2*wordSize, O1);
274 break;
275 case T_OBJECT :
276 __ ld_ptr(O0, 0, O2);
277 __ verify_oop(O2); // verify it
278 __ st_ptr(O2, O1, 0);
279 __ sub(O1, wordSize, O1);
280 break;
281 default : ShouldNotReachHere();
282 }
283 __ retl();
284 __ delayed()->nop(); // QQ schedule this better
285 return entry;
305 case T_FLOAT :
306 __ ldf(FloatRegisterImpl::S, O0, 0, F0);
307 break;
308 case T_BOOLEAN:
309 case T_CHAR :
310 case T_BYTE :
311 case T_SHORT :
312 case T_INT :
313 // 1 word result
314 __ ld(O0, 0, O0->after_save());
315 break;
316 case T_DOUBLE :
317 __ ldf(FloatRegisterImpl::D, O0, 0, F0);
318 break;
319 case T_LONG :
320 // return top two words on current expression stack to caller's expression stack
321 // The caller's expression stack is adjacent to the current frame manager's interpretState
322 // except we allocated one extra word for this intepretState so we won't overwrite it
323 // when we return a two word result.
324 #ifdef _LP64
325 __ breakpoint_trap();
326 // Hmm now that longs are in one entry should "_ptr" really be "x"?
327 __ ld_ptr(O0, 0, O0->after_save());
328 __ ld_ptr(O0, wordSize, O1->after_save());
329 #else
330 __ ld(O0, wordSize, O1->after_save());
331 __ ld(O0, 0, O0->after_save());
332 #endif
333 #if defined(COMPILER2) && !defined(_LP64)
334 // C2 expects long results in G1 we can't tell if we're returning to interpreted
335 // or compiled so just be safe use G1 and O0/O1
336
337 // Shift bits into high (msb) of G1
338 __ sllx(Otos_l1->after_save(), 32, G1);
339 // Zero extend low bits
340 __ srl (Otos_l2->after_save(), 0, Otos_l2->after_save());
341 __ or3 (Otos_l2->after_save(), G1, G1);
342 #endif /* COMPILER2 */
343 break;
344 case T_OBJECT :
345 __ ld_ptr(O0, 0, O0->after_save());
346 __ verify_oop(O0->after_save()); // verify it
347 break;
348 default : ShouldNotReachHere();
1359 __ sub(L2_scratch, entry_size, L2_scratch);
1360 __ st_ptr(L2_scratch, STATE(_stack_limit));
1361
1362 __ ld_ptr(STATE(_stack), L1_scratch); // Get current stack top
1363 __ sub(L1_scratch, entry_size, L1_scratch);
1364 __ st_ptr(L1_scratch, STATE(_stack));
1365 __ ba(false, entry);
1366 __ delayed()->add(L1_scratch, wordSize, L1_scratch); // first real entry (undo prepush)
1367
1368 // 2. move expression stack
1369
1370 __ bind(loop);
1371 __ st_ptr(L3_scratch, Address(L1_scratch, 0));
1372 __ add(L1_scratch, wordSize, L1_scratch);
1373 __ bind(entry);
1374 __ cmp(L1_scratch, L4_scratch);
1375 __ br(Assembler::notEqual, false, Assembler::pt, loop);
1376 __ delayed()->ld_ptr(L1_scratch, entry_size, L3_scratch);
1377
1378 // now zero the slot so we can find it.
1379 __ st(G0, L4_scratch, BasicObjectLock::obj_offset_in_bytes());
1380
1381 }
1382
1383 // Initial entry to C++ interpreter from the call_stub.
1384 // This entry point is called the frame manager since it handles the generation
1385 // of interpreter activation frames via requests directly from the vm (via call_stub)
1386 // and via requests from the interpreter. The requests from the call_stub happen
1387 // directly thru the entry point. Requests from the interpreter happen via returning
1388 // from the interpreter and examining the message the interpreter has returned to
1389 // the frame manager. The frame manager can take the following requests:
1390
1391 // NO_REQUEST - error, should never happen.
1392 // MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and
1393 // allocate a new monitor.
1394 // CALL_METHOD - setup a new activation to call a new method. Very similar to what
1395 // happens during entry during the entry via the call stub.
1396 // RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub.
1397 //
1398 // Arguments:
1399 //
1699 // stack is in the state that the calling convention left it.
1700 // Copy the result from native abi result and place it on java expression stack.
1701
1702 // Current interpreter state is present in Lstate
1703
1704 // Exception pending?
1705
1706 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1707 __ ld_ptr(exception_addr, Lscratch); // get any pending exception
1708 __ tst(Lscratch); // exception pending?
1709 __ brx(Assembler::notZero, false, Assembler::pt, return_with_exception);
1710 __ delayed()->nop();
1711
1712 // Process the native abi result to java expression stack
1713
1714 __ ld_ptr(STATE(_result._to_call._callee), L4_scratch); // called method
1715 __ ld_ptr(STATE(_stack), L1_scratch); // get top of java expr stack
1716 __ lduh(L4_scratch, in_bytes(methodOopDesc::size_of_parameters_offset()), L2_scratch); // get parameter size
1717 __ sll(L2_scratch, LogBytesPerWord, L2_scratch ); // parameter size in bytes
1718 __ add(L1_scratch, L2_scratch, L1_scratch); // stack destination for result
1719 __ ld_ptr(L4_scratch, in_bytes(methodOopDesc::result_index_offset()), L3_scratch); // called method result type index
1720
1721 // tosca is really just native abi
1722 __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch);
1723 __ sll(L3_scratch, LogBytesPerWord, L3_scratch);
1724 __ ld_ptr(L4_scratch, L3_scratch, Lscratch); // get typed result converter address
1725 __ jmpl(Lscratch, G0, O7); // and convert it
1726 __ delayed()->nop();
1727
1728 // L1_scratch points to top of stack (prepushed)
1729
1730 __ ba(false, resume_interpreter);
1731 __ delayed()->mov(L1_scratch, O1);
1732
1733 // An exception is being caught on return to a vanilla interpreter frame.
1734 // Empty the stack and resume interpreter
1735
1736 __ bind(return_with_exception);
1737
1738 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1739 __ ld_ptr(STATE(_stack_base), O1); // empty java expression stack
1743 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
1744 // interpreter call, or native) and unwind this interpreter activation.
1745 // All monitors should be unlocked.
1746
1747 __ bind(return_from_interpreted_method);
1748
1749 VALIDATE_STATE(G3_scratch, 7);
1750
1751 Label return_to_initial_caller;
1752
1753 // Interpreted result is on the top of the completed activation expression stack.
1754 // We must return it to the top of the callers stack if caller was interpreted
1755 // otherwise we convert to native abi result and return to call_stub/c1/c2
1756 // The caller's expression stack was truncated by the call however the current activation
1757 // has enough stuff on the stack that we have usable space there no matter what. The
1758 // other thing that makes it easy is that the top of the caller's stack is stored in STATE(_locals)
1759 // for the current activation
1760
1761 __ ld_ptr(STATE(_prev_link), L1_scratch);
1762 __ ld_ptr(STATE(_method), L2_scratch); // get method just executed
1763 __ ld_ptr(L2_scratch, in_bytes(methodOopDesc::result_index_offset()), L2_scratch);
1764 __ tst(L1_scratch);
1765 __ brx(Assembler::zero, false, Assembler::pt, return_to_initial_caller);
1766 __ delayed()->sll(L2_scratch, LogBytesPerWord, L2_scratch);
1767
1768 // Copy result to callers java stack
1769
1770 __ set((intptr_t)CppInterpreter::_stack_to_stack, L4_scratch);
1771 __ ld_ptr(L4_scratch, L2_scratch, Lscratch); // get typed result converter address
1772 __ ld_ptr(STATE(_stack), O0); // current top (prepushed)
1773 __ ld_ptr(STATE(_locals), O1); // stack destination
1774
1775 // O0 - will be source, O1 - will be destination (preserved)
1776 __ jmpl(Lscratch, G0, O7); // and convert it
1777 __ delayed()->add(O0, wordSize, O0); // get source (top of current expr stack)
1778
1779 // O1 == &locals[0]
1780
1781 // Result is now on caller's stack. Just unwind current activation and resume
1782
1783 Label unwind_recursive_activation;
1909
1910 // stack points to next free location and not top element on expression stack
1911 // method expects sp to be pointing to topmost element
1912
1913 __ ld_ptr(STATE(_thread), G2_thread);
1914 __ ld_ptr(STATE(_result._to_call._callee), G5_method);
1915
1916
1917 // SP already takes in to account the 2 extra words we use for slop
1918 // when we call a "static long no_params()" method. So if
1919 // we trim back sp by the amount of unused java expression stack
1920 // there will be automagically the 2 extra words we need.
1921 // We also have to worry about keeping SP aligned.
1922
1923 __ ld_ptr(STATE(_stack), Gargs);
1924 __ ld_ptr(STATE(_stack_limit), L1_scratch);
1925
1926 // compute the unused java stack size
1927 __ sub(Gargs, L1_scratch, L2_scratch); // compute unused space
1928
1929 // Round down the unused space to that stack is always aligned
1930 // by making the unused space a multiple of the size of a long.
1931
1932 __ and3(L2_scratch, -BytesPerLong, L2_scratch);
1933
1934 // Now trim the stack
1935 __ add(SP, L2_scratch, SP);
1936
1937
1938 // Now point to the final argument (account for prepush)
1939 __ add(Gargs, wordSize, Gargs);
1940 #ifdef ASSERT
1941 // Make sure we have space for the window
1942 __ sub(Gargs, SP, L1_scratch);
1943 __ cmp(L1_scratch, 16*wordSize);
1944 {
1945 Label skip;
1946 __ brx(Assembler::greaterEqual, false, Assembler::pt, skip);
1947 __ delayed()->nop();
1948 __ stop("killed stack");
1949 __ bind(skip);
1950 }
1951 #endif // ASSERT
1952
2162 // calculates the extra locals based on itself. Not what the callee does
2163 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2164 // as getting sender_sp correct.
2165
2166 int extra_locals_size = callee_locals_size - callee_param_size;
2167 int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
2168 int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2169 int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2170 int frame_words = is_top_frame ? full_frame_words : short_frame_words;
2171
2172
2173 /*
2174 if we actually have a frame to layout we must now fill in all the pieces. This means both
2175 the interpreterState and the registers.
2176 */
2177 if (interpreter_frame != NULL) {
2178
2179 // MUCHO HACK
2180
2181 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
2182
2183 /* Now fillin the interpreterState object */
2184
2185 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2186
2187
2188 intptr_t* locals;
2189
2190 // Calculate the postion of locals[0]. This is painful because of
2191 // stack alignment (same as ia64). The problem is that we can
2192 // not compute the location of locals from fp(). fp() will account
2193 // for the extra locals but it also accounts for aligning the stack
2194 // and we can't determine if the locals[0] was misaligned but max_locals
2195 // was enough to have the
2196 // calculate postion of locals. fp already accounts for extra locals.
2197 // +2 for the static long no_params() issue.
2198
2199 if (caller->is_interpreted_frame()) {
2200 // locals must agree with the caller because it will be used to set the
2201 // caller's tos when we return.
2227
2228
2229 BytecodeInterpreter::layout_interpreterState(cur_state,
2230 caller,
2231 interpreter_frame,
2232 method,
2233 locals,
2234 stack,
2235 stack_base,
2236 monitor_base,
2237 frame_bottom,
2238 is_top_frame);
2239
2240 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2241
2242 }
2243 return frame_words;
2244 }
2245
2246 #endif // CC_INTERP
2247
|
1 /*
2 * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
142 __ srl(O0, 16, O0);
143 __ st(O0, L1_scratch, 0);
144 __ sub(L1_scratch, wordSize, L1_scratch);
145 break;
146
147 case T_BYTE :
148 __ sll(O0, 24, O0);
149 __ sra(O0, 24, O0);
150 __ st(O0, L1_scratch, 0);
151 __ sub(L1_scratch, wordSize, L1_scratch);
152 break;
153
154 case T_SHORT :
155 __ sll(O0, 16, O0);
156 __ sra(O0, 16, O0);
157 __ st(O0, L1_scratch, 0);
158 __ sub(L1_scratch, wordSize, L1_scratch);
159 break;
160 case T_LONG :
161 #ifndef _LP64
162 #if defined(COMPILER2)
163 // All return values are where we want them, except for Longs. C2 returns
164 // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1.
165 // Since the interpreter will return longs in G1 and O0/O1 in the 32bit
166 // build even if we are returning from interpreted we just do a little
167 // stupid shuffing.
168 // Note: I tried to make c2 return longs in O0/O1 and G1 so we wouldn't have to
169 // do this here. Unfortunately if we did a rethrow we'd see an machepilog node
170 // first which would move g1 -> O0/O1 and destroy the exception we were throwing.
171 __ stx(G1, L1_scratch, -wordSize);
172 #else
173 // native result is in O0, O1
174 __ st(O1, L1_scratch, 0); // Low order
175 __ st(O0, L1_scratch, -wordSize); // High order
176 #endif /* COMPILER2 */
177 #else
178 __ stx(O0, L1_scratch, -wordSize);
179 #endif
180 __ sub(L1_scratch, 2*wordSize, L1_scratch);
181 break;
182
183 case T_INT :
184 __ st(O0, L1_scratch, 0);
185 __ sub(L1_scratch, wordSize, L1_scratch);
186 break;
187
188 case T_VOID : /* nothing to do */
189 break;
190
191 case T_FLOAT :
192 __ stf(FloatRegisterImpl::S, F0, L1_scratch, 0);
193 __ sub(L1_scratch, wordSize, L1_scratch);
194 break;
195
196 case T_DOUBLE :
197 // Every stack slot is aligned on 64 bit, However is this
198 // the correct stack slot on 64bit?? QQQ
219 // The current interpreter activation in Lstate is for the method just returning its
220 // result. So we know that the result of this method is on the top of the current
221 // execution stack (which is pre-pushed) and will be return to the top of the caller
222 // stack. The top of the callers stack is the bottom of the locals of the current
223 // activation.
224 // Because of the way activation are managed by the frame manager the value of esp is
225 // below both the stack top of the current activation and naturally the stack top
226 // of the calling activation. This enable this routine to leave the return address
227 // to the frame manager on the stack and do a vanilla return.
228 //
229 // On entry: O0 - points to source (callee stack top)
230 // O1 - points to destination (caller stack top [i.e. free location])
231 // destroys O2, O3
232 //
233
234 address entry = __ pc();
235 switch (type) {
236 case T_VOID: break;
237 break;
238 case T_FLOAT :
239 case T_BOOLEAN:
240 case T_CHAR :
241 case T_BYTE :
242 case T_SHORT :
243 case T_INT :
244 // 1 word result
245 __ ld(O0, 0, O2);
246 __ st(O2, O1, 0);
247 __ sub(O1, wordSize, O1);
248 break;
249 case T_DOUBLE :
250 case T_LONG :
251 // return top two words on current expression stack to caller's expression stack
252 // The caller's expression stack is adjacent to the current frame manager's intepretState
253 // except we allocated one extra word for this intepretState so we won't overwrite it
254 // when we return a two word result.
255 #ifdef _LP64
256 __ ld_ptr(O0, 0, O2);
257 __ st_ptr(O2, O1, -wordSize);
258 #else
259 __ ld(O0, 0, O2);
260 __ ld(O0, wordSize, O3);
261 __ st(O3, O1, 0);
262 __ st(O2, O1, -wordSize);
263 #endif
264 __ sub(O1, 2*wordSize, O1);
265 break;
266 case T_OBJECT :
267 __ ld_ptr(O0, 0, O2);
268 __ verify_oop(O2); // verify it
269 __ st_ptr(O2, O1, 0);
270 __ sub(O1, wordSize, O1);
271 break;
272 default : ShouldNotReachHere();
273 }
274 __ retl();
275 __ delayed()->nop(); // QQ schedule this better
276 return entry;
296 case T_FLOAT :
297 __ ldf(FloatRegisterImpl::S, O0, 0, F0);
298 break;
299 case T_BOOLEAN:
300 case T_CHAR :
301 case T_BYTE :
302 case T_SHORT :
303 case T_INT :
304 // 1 word result
305 __ ld(O0, 0, O0->after_save());
306 break;
307 case T_DOUBLE :
308 __ ldf(FloatRegisterImpl::D, O0, 0, F0);
309 break;
310 case T_LONG :
311 // return top two words on current expression stack to caller's expression stack
312 // The caller's expression stack is adjacent to the current frame manager's interpretState
313 // except we allocated one extra word for this intepretState so we won't overwrite it
314 // when we return a two word result.
315 #ifdef _LP64
316 __ ld_ptr(O0, 0, O0->after_save());
317 #else
318 __ ld(O0, wordSize, O1->after_save());
319 __ ld(O0, 0, O0->after_save());
320 #endif
321 #if defined(COMPILER2) && !defined(_LP64)
322 // C2 expects long results in G1 we can't tell if we're returning to interpreted
323 // or compiled so just be safe use G1 and O0/O1
324
325 // Shift bits into high (msb) of G1
326 __ sllx(Otos_l1->after_save(), 32, G1);
327 // Zero extend low bits
328 __ srl (Otos_l2->after_save(), 0, Otos_l2->after_save());
329 __ or3 (Otos_l2->after_save(), G1, G1);
330 #endif /* COMPILER2 */
331 break;
332 case T_OBJECT :
333 __ ld_ptr(O0, 0, O0->after_save());
334 __ verify_oop(O0->after_save()); // verify it
335 break;
336 default : ShouldNotReachHere();
1347 __ sub(L2_scratch, entry_size, L2_scratch);
1348 __ st_ptr(L2_scratch, STATE(_stack_limit));
1349
1350 __ ld_ptr(STATE(_stack), L1_scratch); // Get current stack top
1351 __ sub(L1_scratch, entry_size, L1_scratch);
1352 __ st_ptr(L1_scratch, STATE(_stack));
1353 __ ba(false, entry);
1354 __ delayed()->add(L1_scratch, wordSize, L1_scratch); // first real entry (undo prepush)
1355
1356 // 2. move expression stack
1357
1358 __ bind(loop);
1359 __ st_ptr(L3_scratch, Address(L1_scratch, 0));
1360 __ add(L1_scratch, wordSize, L1_scratch);
1361 __ bind(entry);
1362 __ cmp(L1_scratch, L4_scratch);
1363 __ br(Assembler::notEqual, false, Assembler::pt, loop);
1364 __ delayed()->ld_ptr(L1_scratch, entry_size, L3_scratch);
1365
1366 // now zero the slot so we can find it.
1367 __ st_ptr(G0, L4_scratch, BasicObjectLock::obj_offset_in_bytes());
1368
1369 }
1370
1371 // Initial entry to C++ interpreter from the call_stub.
1372 // This entry point is called the frame manager since it handles the generation
1373 // of interpreter activation frames via requests directly from the vm (via call_stub)
1374 // and via requests from the interpreter. The requests from the call_stub happen
1375 // directly thru the entry point. Requests from the interpreter happen via returning
1376 // from the interpreter and examining the message the interpreter has returned to
1377 // the frame manager. The frame manager can take the following requests:
1378
1379 // NO_REQUEST - error, should never happen.
1380 // MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and
1381 // allocate a new monitor.
1382 // CALL_METHOD - setup a new activation to call a new method. Very similar to what
1383 // happens during entry during the entry via the call stub.
1384 // RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub.
1385 //
1386 // Arguments:
1387 //
1687 // stack is in the state that the calling convention left it.
1688 // Copy the result from native abi result and place it on java expression stack.
1689
1690 // Current interpreter state is present in Lstate
1691
1692 // Exception pending?
1693
1694 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1695 __ ld_ptr(exception_addr, Lscratch); // get any pending exception
1696 __ tst(Lscratch); // exception pending?
1697 __ brx(Assembler::notZero, false, Assembler::pt, return_with_exception);
1698 __ delayed()->nop();
1699
1700 // Process the native abi result to java expression stack
1701
1702 __ ld_ptr(STATE(_result._to_call._callee), L4_scratch); // called method
1703 __ ld_ptr(STATE(_stack), L1_scratch); // get top of java expr stack
1704 __ lduh(L4_scratch, in_bytes(methodOopDesc::size_of_parameters_offset()), L2_scratch); // get parameter size
1705 __ sll(L2_scratch, LogBytesPerWord, L2_scratch ); // parameter size in bytes
1706 __ add(L1_scratch, L2_scratch, L1_scratch); // stack destination for result
1707 __ ld(L4_scratch, in_bytes(methodOopDesc::result_index_offset()), L3_scratch); // called method result type index
1708
1709 // tosca is really just native abi
1710 __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch);
1711 __ sll(L3_scratch, LogBytesPerWord, L3_scratch);
1712 __ ld_ptr(L4_scratch, L3_scratch, Lscratch); // get typed result converter address
1713 __ jmpl(Lscratch, G0, O7); // and convert it
1714 __ delayed()->nop();
1715
1716 // L1_scratch points to top of stack (prepushed)
1717
1718 __ ba(false, resume_interpreter);
1719 __ delayed()->mov(L1_scratch, O1);
1720
1721 // An exception is being caught on return to a vanilla interpreter frame.
1722 // Empty the stack and resume interpreter
1723
1724 __ bind(return_with_exception);
1725
1726 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1727 __ ld_ptr(STATE(_stack_base), O1); // empty java expression stack
1731 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
1732 // interpreter call, or native) and unwind this interpreter activation.
1733 // All monitors should be unlocked.
1734
1735 __ bind(return_from_interpreted_method);
1736
1737 VALIDATE_STATE(G3_scratch, 7);
1738
1739 Label return_to_initial_caller;
1740
1741 // Interpreted result is on the top of the completed activation expression stack.
1742 // We must return it to the top of the callers stack if caller was interpreted
1743 // otherwise we convert to native abi result and return to call_stub/c1/c2
1744 // The caller's expression stack was truncated by the call however the current activation
1745 // has enough stuff on the stack that we have usable space there no matter what. The
1746 // other thing that makes it easy is that the top of the caller's stack is stored in STATE(_locals)
1747 // for the current activation
1748
1749 __ ld_ptr(STATE(_prev_link), L1_scratch);
1750 __ ld_ptr(STATE(_method), L2_scratch); // get method just executed
1751 __ ld(L2_scratch, in_bytes(methodOopDesc::result_index_offset()), L2_scratch);
1752 __ tst(L1_scratch);
1753 __ brx(Assembler::zero, false, Assembler::pt, return_to_initial_caller);
1754 __ delayed()->sll(L2_scratch, LogBytesPerWord, L2_scratch);
1755
1756 // Copy result to callers java stack
1757
1758 __ set((intptr_t)CppInterpreter::_stack_to_stack, L4_scratch);
1759 __ ld_ptr(L4_scratch, L2_scratch, Lscratch); // get typed result converter address
1760 __ ld_ptr(STATE(_stack), O0); // current top (prepushed)
1761 __ ld_ptr(STATE(_locals), O1); // stack destination
1762
1763 // O0 - will be source, O1 - will be destination (preserved)
1764 __ jmpl(Lscratch, G0, O7); // and convert it
1765 __ delayed()->add(O0, wordSize, O0); // get source (top of current expr stack)
1766
1767 // O1 == &locals[0]
1768
1769 // Result is now on caller's stack. Just unwind current activation and resume
1770
1771 Label unwind_recursive_activation;
1897
1898 // stack points to next free location and not top element on expression stack
1899 // method expects sp to be pointing to topmost element
1900
1901 __ ld_ptr(STATE(_thread), G2_thread);
1902 __ ld_ptr(STATE(_result._to_call._callee), G5_method);
1903
1904
1905 // SP already takes in to account the 2 extra words we use for slop
1906 // when we call a "static long no_params()" method. So if
1907 // we trim back sp by the amount of unused java expression stack
1908 // there will be automagically the 2 extra words we need.
1909 // We also have to worry about keeping SP aligned.
1910
1911 __ ld_ptr(STATE(_stack), Gargs);
1912 __ ld_ptr(STATE(_stack_limit), L1_scratch);
1913
1914 // compute the unused java stack size
1915 __ sub(Gargs, L1_scratch, L2_scratch); // compute unused space
1916
1917 // Round down the unused space to that stack is always 16-byte aligned
1918 // by making the unused space a multiple of the size of two longs.
1919
1920 __ and3(L2_scratch, -2*BytesPerLong, L2_scratch);
1921
1922 // Now trim the stack
1923 __ add(SP, L2_scratch, SP);
1924
1925
1926 // Now point to the final argument (account for prepush)
1927 __ add(Gargs, wordSize, Gargs);
1928 #ifdef ASSERT
1929 // Make sure we have space for the window
1930 __ sub(Gargs, SP, L1_scratch);
1931 __ cmp(L1_scratch, 16*wordSize);
1932 {
1933 Label skip;
1934 __ brx(Assembler::greaterEqual, false, Assembler::pt, skip);
1935 __ delayed()->nop();
1936 __ stop("killed stack");
1937 __ bind(skip);
1938 }
1939 #endif // ASSERT
1940
2150 // calculates the extra locals based on itself. Not what the callee does
2151 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2152 // as getting sender_sp correct.
2153
2154 int extra_locals_size = callee_locals_size - callee_param_size;
2155 int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
2156 int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2157 int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2158 int frame_words = is_top_frame ? full_frame_words : short_frame_words;
2159
2160
2161 /*
2162 if we actually have a frame to layout we must now fill in all the pieces. This means both
2163 the interpreterState and the registers.
2164 */
2165 if (interpreter_frame != NULL) {
2166
2167 // MUCHO HACK
2168
2169 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
2170 // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
2171 assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
2172 frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
2173
2174 /* Now fillin the interpreterState object */
2175
2176 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2177
2178
2179 intptr_t* locals;
2180
2181 // Calculate the postion of locals[0]. This is painful because of
2182 // stack alignment (same as ia64). The problem is that we can
2183 // not compute the location of locals from fp(). fp() will account
2184 // for the extra locals but it also accounts for aligning the stack
2185 // and we can't determine if the locals[0] was misaligned but max_locals
2186 // was enough to have the
2187 // calculate postion of locals. fp already accounts for extra locals.
2188 // +2 for the static long no_params() issue.
2189
2190 if (caller->is_interpreted_frame()) {
2191 // locals must agree with the caller because it will be used to set the
2192 // caller's tos when we return.
2218
2219
2220 BytecodeInterpreter::layout_interpreterState(cur_state,
2221 caller,
2222 interpreter_frame,
2223 method,
2224 locals,
2225 stack,
2226 stack_base,
2227 monitor_base,
2228 frame_bottom,
2229 is_top_frame);
2230
2231 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2232
2233 }
2234 return frame_words;
2235 }
2236
2237 #endif // CC_INTERP
|