comparison src/cpu/sparc/vm/templateInterpreter_sparc.cpp @ 4743:dca455dea3a7

7116216: StackOverflow GC crash Summary: GC crash for explicit stack overflow checks after a C2I transition. Reviewed-by: coleenp, never Contributed-by: yang02.wang@sap.com, bertrand.delsart@oracle.com
author bdelsart
date Tue, 20 Dec 2011 12:33:05 +0100
parents 3d42f82cd811
children 22cee0ee8927
comparison
equal deleted inserted replaced
4742:8fdf463085e1 4743:dca455dea3a7
394 394
395 void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rframe_size, 395 void TemplateInterpreterGenerator::generate_stack_overflow_check(Register Rframe_size,
396 Register Rscratch, 396 Register Rscratch,
397 Register Rscratch2) { 397 Register Rscratch2) {
398 const int page_size = os::vm_page_size(); 398 const int page_size = os::vm_page_size();
399 Address saved_exception_pc(G2_thread, JavaThread::saved_exception_pc_offset());
400 Label after_frame_check; 399 Label after_frame_check;
401 400
402 assert_different_registers(Rframe_size, Rscratch, Rscratch2); 401 assert_different_registers(Rframe_size, Rscratch, Rscratch2);
403 402
404 __ set(page_size, Rscratch); 403 __ set(page_size, Rscratch);
434 433
435 // the frame is greater than one page in size, so check against 434 // the frame is greater than one page in size, so check against
436 // the bottom of the stack 435 // the bottom of the stack
437 __ cmp_and_brx_short(SP, Rscratch, Assembler::greater, Assembler::pt, after_frame_check); 436 __ cmp_and_brx_short(SP, Rscratch, Assembler::greater, Assembler::pt, after_frame_check);
438 437
439 // Save the return address as the exception pc
440 __ st_ptr(O7, saved_exception_pc);
441
442 // the stack will overflow, throw an exception 438 // the stack will overflow, throw an exception
443 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError)); 439
440 // Note that SP is restored to sender's sp (in the delay slot). This
441 // is necessary if the sender's frame is an extended compiled frame
442 // (see gen_c2i_adapter()) and safer anyway in case of JSR292
443 // adaptations.
444
445 // Note also that the restored frame is not necessarily interpreted.
446 // Use the shared runtime version of the StackOverflowError.
447 assert(StubRoutines::throw_StackOverflowError_entry() != NULL, "stub not yet generated");
448 AddressLiteral stub(StubRoutines::throw_StackOverflowError_entry());
449 __ jump_to(stub, Rscratch);
450 __ delayed()->mov(O5_savedSP, SP);
444 451
445 // if you get to here, then there is enough stack space 452 // if you get to here, then there is enough stack space
446 __ bind( after_frame_check ); 453 __ bind( after_frame_check );
447 } 454 }
448 455