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(_LP64) && 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 /* !_LP64 && COMPILER2 */
177 #else
178 __ stx(O0, L1_scratch, 0);
179 __ breakpoint_trap();
180 #endif
181 __ sub(L1_scratch, 2*wordSize, L1_scratch);
182 break;
183
184 case T_INT :
185 __ st(O0, L1_scratch, 0);
186 __ sub(L1_scratch, wordSize, L1_scratch);
187 break;
188
189 case T_VOID : /* nothing to do */
190 break;
191
192 case T_FLOAT :
193 __ stf(FloatRegisterImpl::S, F0, L1_scratch, 0);
194 __ sub(L1_scratch, wordSize, L1_scratch);
195 break;
196
197 case T_DOUBLE :
198 // Every stack slot is aligned on 64 bit, However is this
199 // the correct stack slot on 64bit?? QQQ
220 // The current interpreter activation in Lstate is for the method just returning its
221 // result. So we know that the result of this method is on the top of the current
222 // execution stack (which is pre-pushed) and will be return to the top of the caller
223 // stack. The top of the callers stack is the bottom of the locals of the current
224 // activation.
225 // Because of the way activation are managed by the frame manager the value of esp is
226 // below both the stack top of the current activation and naturally the stack top
227 // of the calling activation. This enable this routine to leave the return address
228 // to the frame manager on the stack and do a vanilla return.
229 //
230 // On entry: O0 - points to source (callee stack top)
231 // O1 - points to destination (caller stack top [i.e. free location])
232 // destroys O2, O3
233 //
234
235 address entry = __ pc();
236 switch (type) {
237 case T_VOID: break;
238 break;
239 case T_FLOAT :
240 __ breakpoint_trap(Assembler::zero);
241 case T_BOOLEAN:
242 case T_CHAR :
243 case T_BYTE :
244 case T_SHORT :
245 case T_INT :
246 // 1 word result
247 __ ld(O0, 0, O2);
248 __ st(O2, O1, 0);
249 __ sub(O1, wordSize, O1);
250 break;
251 case T_DOUBLE :
252 case T_LONG :
253 // return top two words on current expression stack to caller's expression stack
254 // The caller's expression stack is adjacent to the current frame manager's intepretState
255 // except we allocated one extra word for this intepretState so we won't overwrite it
256 // when we return a two word result.
257 #ifdef _LP64
258 __ breakpoint_trap();
259 // Hmm now that longs are in one entry should "_ptr" really be "x"?
260 __ ld_ptr(O0, 0, O2);
261 __ ld_ptr(O0, wordSize, O3);
262 __ st_ptr(O3, O1, 0);
263 __ st_ptr(O2, O1, -wordSize);
264 #else
265 __ ld(O0, 0, O2);
266 __ ld(O0, wordSize, O3);
267 __ st(O3, O1, 0);
268 __ st(O2, O1, -wordSize);
269 #endif
270 __ sub(O1, 2*wordSize, O1);
271 break;
272 case T_OBJECT :
273 __ ld_ptr(O0, 0, O2);
274 __ verify_oop(O2); // verify it
275 __ st_ptr(O2, O1, 0);
276 __ sub(O1, wordSize, O1);
277 break;
278 default : ShouldNotReachHere();
279 }
280 __ retl();
281 __ delayed()->nop(); // QQ schedule this better
282 return entry;
302 case T_FLOAT :
303 __ ldf(FloatRegisterImpl::S, O0, 0, F0);
304 break;
305 case T_BOOLEAN:
306 case T_CHAR :
307 case T_BYTE :
308 case T_SHORT :
309 case T_INT :
310 // 1 word result
311 __ ld(O0, 0, O0->after_save());
312 break;
313 case T_DOUBLE :
314 __ ldf(FloatRegisterImpl::D, O0, 0, F0);
315 break;
316 case T_LONG :
317 // return top two words on current expression stack to caller's expression stack
318 // The caller's expression stack is adjacent to the current frame manager's interpretState
319 // except we allocated one extra word for this intepretState so we won't overwrite it
320 // when we return a two word result.
321 #ifdef _LP64
322 __ breakpoint_trap();
323 // Hmm now that longs are in one entry should "_ptr" really be "x"?
324 __ ld_ptr(O0, 0, O0->after_save());
325 __ ld_ptr(O0, wordSize, O1->after_save());
326 #else
327 __ ld(O0, wordSize, O1->after_save());
328 __ ld(O0, 0, O0->after_save());
329 #endif
330 #if defined(COMPILER2) && !defined(_LP64)
331 // C2 expects long results in G1 we can't tell if we're returning to interpreted
332 // or compiled so just be safe use G1 and O0/O1
333
334 // Shift bits into high (msb) of G1
335 __ sllx(Otos_l1->after_save(), 32, G1);
336 // Zero extend low bits
337 __ srl (Otos_l2->after_save(), 0, Otos_l2->after_save());
338 __ or3 (Otos_l2->after_save(), G1, G1);
339 #endif /* COMPILER2 */
340 break;
341 case T_OBJECT :
342 __ ld_ptr(O0, 0, O0->after_save());
343 __ verify_oop(O0->after_save()); // verify it
344 break;
345 default : ShouldNotReachHere();
1356 __ sub(L2_scratch, entry_size, L2_scratch);
1357 __ st_ptr(L2_scratch, STATE(_stack_limit));
1358
1359 __ ld_ptr(STATE(_stack), L1_scratch); // Get current stack top
1360 __ sub(L1_scratch, entry_size, L1_scratch);
1361 __ st_ptr(L1_scratch, STATE(_stack));
1362 __ ba(false, entry);
1363 __ delayed()->add(L1_scratch, wordSize, L1_scratch); // first real entry (undo prepush)
1364
1365 // 2. move expression stack
1366
1367 __ bind(loop);
1368 __ st_ptr(L3_scratch, Address(L1_scratch, 0));
1369 __ add(L1_scratch, wordSize, L1_scratch);
1370 __ bind(entry);
1371 __ cmp(L1_scratch, L4_scratch);
1372 __ br(Assembler::notEqual, false, Assembler::pt, loop);
1373 __ delayed()->ld_ptr(L1_scratch, entry_size, L3_scratch);
1374
1375 // now zero the slot so we can find it.
1376 __ st(G0, L4_scratch, BasicObjectLock::obj_offset_in_bytes());
1377
1378 }
1379
1380 // Initial entry to C++ interpreter from the call_stub.
1381 // This entry point is called the frame manager since it handles the generation
1382 // of interpreter activation frames via requests directly from the vm (via call_stub)
1383 // and via requests from the interpreter. The requests from the call_stub happen
1384 // directly thru the entry point. Requests from the interpreter happen via returning
1385 // from the interpreter and examining the message the interpreter has returned to
1386 // the frame manager. The frame manager can take the following requests:
1387
1388 // NO_REQUEST - error, should never happen.
1389 // MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and
1390 // allocate a new monitor.
1391 // CALL_METHOD - setup a new activation to call a new method. Very similar to what
1392 // happens during entry during the entry via the call stub.
1393 // RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub.
1394 //
1395 // Arguments:
1396 //
1696 // stack is in the state that the calling convention left it.
1697 // Copy the result from native abi result and place it on java expression stack.
1698
1699 // Current interpreter state is present in Lstate
1700
1701 // Exception pending?
1702
1703 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1704 __ ld_ptr(exception_addr, Lscratch); // get any pending exception
1705 __ tst(Lscratch); // exception pending?
1706 __ brx(Assembler::notZero, false, Assembler::pt, return_with_exception);
1707 __ delayed()->nop();
1708
1709 // Process the native abi result to java expression stack
1710
1711 __ ld_ptr(STATE(_result._to_call._callee), L4_scratch); // called method
1712 __ ld_ptr(STATE(_stack), L1_scratch); // get top of java expr stack
1713 __ lduh(L4_scratch, in_bytes(methodOopDesc::size_of_parameters_offset()), L2_scratch); // get parameter size
1714 __ sll(L2_scratch, LogBytesPerWord, L2_scratch ); // parameter size in bytes
1715 __ add(L1_scratch, L2_scratch, L1_scratch); // stack destination for result
1716 __ ld_ptr(L4_scratch, in_bytes(methodOopDesc::result_index_offset()), L3_scratch); // called method result type index
1717
1718 // tosca is really just native abi
1719 __ set((intptr_t)CppInterpreter::_tosca_to_stack, L4_scratch);
1720 __ sll(L3_scratch, LogBytesPerWord, L3_scratch);
1721 __ ld_ptr(L4_scratch, L3_scratch, Lscratch); // get typed result converter address
1722 __ jmpl(Lscratch, G0, O7); // and convert it
1723 __ delayed()->nop();
1724
1725 // L1_scratch points to top of stack (prepushed)
1726
1727 __ ba(false, resume_interpreter);
1728 __ delayed()->mov(L1_scratch, O1);
1729
1730 // An exception is being caught on return to a vanilla interpreter frame.
1731 // Empty the stack and resume interpreter
1732
1733 __ bind(return_with_exception);
1734
1735 __ ld_ptr(STATE(_frame_bottom), SP); // restore to full stack frame
1736 __ ld_ptr(STATE(_stack_base), O1); // empty java expression stack
1740 // Return from interpreted method we return result appropriate to the caller (i.e. "recursive"
1741 // interpreter call, or native) and unwind this interpreter activation.
1742 // All monitors should be unlocked.
1743
1744 __ bind(return_from_interpreted_method);
1745
1746 VALIDATE_STATE(G3_scratch, 7);
1747
1748 Label return_to_initial_caller;
1749
1750 // Interpreted result is on the top of the completed activation expression stack.
1751 // We must return it to the top of the callers stack if caller was interpreted
1752 // otherwise we convert to native abi result and return to call_stub/c1/c2
1753 // The caller's expression stack was truncated by the call however the current activation
1754 // has enough stuff on the stack that we have usable space there no matter what. The
1755 // other thing that makes it easy is that the top of the caller's stack is stored in STATE(_locals)
1756 // for the current activation
1757
1758 __ ld_ptr(STATE(_prev_link), L1_scratch);
1759 __ ld_ptr(STATE(_method), L2_scratch); // get method just executed
1760 __ ld_ptr(L2_scratch, in_bytes(methodOopDesc::result_index_offset()), L2_scratch);
1761 __ tst(L1_scratch);
1762 __ brx(Assembler::zero, false, Assembler::pt, return_to_initial_caller);
1763 __ delayed()->sll(L2_scratch, LogBytesPerWord, L2_scratch);
1764
1765 // Copy result to callers java stack
1766
1767 __ set((intptr_t)CppInterpreter::_stack_to_stack, L4_scratch);
1768 __ ld_ptr(L4_scratch, L2_scratch, Lscratch); // get typed result converter address
1769 __ ld_ptr(STATE(_stack), O0); // current top (prepushed)
1770 __ ld_ptr(STATE(_locals), O1); // stack destination
1771
1772 // O0 - will be source, O1 - will be destination (preserved)
1773 __ jmpl(Lscratch, G0, O7); // and convert it
1774 __ delayed()->add(O0, wordSize, O0); // get source (top of current expr stack)
1775
1776 // O1 == &locals[0]
1777
1778 // Result is now on caller's stack. Just unwind current activation and resume
1779
1780 Label unwind_recursive_activation;
1906
1907 // stack points to next free location and not top element on expression stack
1908 // method expects sp to be pointing to topmost element
1909
1910 __ ld_ptr(STATE(_thread), G2_thread);
1911 __ ld_ptr(STATE(_result._to_call._callee), G5_method);
1912
1913
1914 // SP already takes in to account the 2 extra words we use for slop
1915 // when we call a "static long no_params()" method. So if
1916 // we trim back sp by the amount of unused java expression stack
1917 // there will be automagically the 2 extra words we need.
1918 // We also have to worry about keeping SP aligned.
1919
1920 __ ld_ptr(STATE(_stack), Gargs);
1921 __ ld_ptr(STATE(_stack_limit), L1_scratch);
1922
1923 // compute the unused java stack size
1924 __ sub(Gargs, L1_scratch, L2_scratch); // compute unused space
1925
1926 // Round down the unused space to that stack is always aligned
1927 // by making the unused space a multiple of the size of a long.
1928
1929 __ and3(L2_scratch, -BytesPerLong, L2_scratch);
1930
1931 // Now trim the stack
1932 __ add(SP, L2_scratch, SP);
1933
1934
1935 // Now point to the final argument (account for prepush)
1936 __ add(Gargs, wordSize, Gargs);
1937 #ifdef ASSERT
1938 // Make sure we have space for the window
1939 __ sub(Gargs, SP, L1_scratch);
1940 __ cmp(L1_scratch, 16*wordSize);
1941 {
1942 Label skip;
1943 __ brx(Assembler::greaterEqual, false, Assembler::pt, skip);
1944 __ delayed()->nop();
1945 __ stop("killed stack");
1946 __ bind(skip);
1947 }
1948 #endif // ASSERT
1949
2159 // calculates the extra locals based on itself. Not what the callee does
2160 // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2161 // as getting sender_sp correct.
2162
2163 int extra_locals_size = callee_locals_size - callee_param_size;
2164 int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
2165 int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2166 int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
2167 int frame_words = is_top_frame ? full_frame_words : short_frame_words;
2168
2169
2170 /*
2171 if we actually have a frame to layout we must now fill in all the pieces. This means both
2172 the interpreterState and the registers.
2173 */
2174 if (interpreter_frame != NULL) {
2175
2176 // MUCHO HACK
2177
2178 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
2179
2180 /* Now fillin the interpreterState object */
2181
2182 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2183
2184
2185 intptr_t* locals;
2186
2187 // Calculate the postion of locals[0]. This is painful because of
2188 // stack alignment (same as ia64). The problem is that we can
2189 // not compute the location of locals from fp(). fp() will account
2190 // for the extra locals but it also accounts for aligning the stack
2191 // and we can't determine if the locals[0] was misaligned but max_locals
2192 // was enough to have the
2193 // calculate postion of locals. fp already accounts for extra locals.
2194 // +2 for the static long no_params() issue.
2195
2196 if (caller->is_interpreted_frame()) {
2197 // locals must agree with the caller because it will be used to set the
2198 // caller's tos when we return.
|
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. (vs)
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. (vs)
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.
|