# HG changeset patch # User Stefan Anzinger # Date 1406215170 25200 # Node ID 422eda5267b3ae709f9a153918c7cfd6caa3ee9d # Parent 0058b4af625de917bc5646007a4fc14939daac2c [SPARC] Temporary fix to get the stack for deoptimization right when exception is thrown diff -r 0058b4af625d -r 422eda5267b3 src/cpu/sparc/vm/sharedRuntime_sparc.cpp --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Thu Jul 24 08:13:55 2014 -0700 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Thu Jul 24 08:19:30 2014 -0700 @@ -3561,11 +3561,39 @@ int exception_in_tls_offset = __ offset() - start; // No need to update oop_map as each call to save_live_registers will produce identical oopmap + // Opens a new stack frame (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_words); // Restore G2_thread __ get_thread(); +#ifdef GRAAL + // load throwing pc from JavaThread and patch it as the return address + // of the current frame. Then clear the field in JavaThread + __ block_comment("load throwing pc and patch return"); + Address exception_pc(G2_thread, JavaThread::exception_pc_offset()); + Label has_no_pc; + // TODO: Remove this weird check if we should patch the return pc + // This is because when graal decides to deoptimize and the ExceptionHandlerStub.java + // jumps back to this code and the I7 register contains the pc pointing to the begin + // of this code. If this is the case (PC within a certain range) then we need to patch + // the return pc. + // THIS NEEDS REWORK! (sa) + __ rdpc(L0); + __ sub(L0, I7, L0); + __ cmp(L0, 0xFFF); + __ br(Assembler::greater, false, Assembler::pt, has_no_pc); + __ delayed() -> nop(); + __ cmp(L0, -0xFFF); + __ br(Assembler::less, false, Assembler::pt, has_no_pc); + __ delayed() -> nop(); + __ ld_ptr(exception_pc, I7); + __ sub(I7, 8, I7); + __ st_ptr(G0, exception_pc); + __ bind(has_no_pc); + __ block_comment("/load throwing pc and patch return"); +#endif // GAAL + #ifdef ASSERT { // verify that there is really an exception oop in exception_oop @@ -3592,7 +3620,10 @@ // Reexecute entry, similar to c2 uncommon trap // int reexecute_offset = __ offset() - start; - +#if defined(COMPILERGRAAL) && !defined(COMPILER1) + // Graal does not use this kind of deoptimization + __ should_not_reach_here(); +#endif // No need to update oop_map as each call to save_live_registers will produce identical oopmap (void) RegisterSaver::save_live_registers(masm, 0, &frame_size_words);