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