src/cpu/sparc/vm/c1_Runtime1_sparc.cpp

changeset 2603
1b4e6a5d98e0
parent 2490
635b068a7224
child 3037
3d42f82cd811
     1.1 --- a/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Sat Feb 26 12:10:54 2011 -0800
     1.2 +++ b/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Mon Feb 28 06:07:12 2011 -0800
     1.3 @@ -148,7 +148,7 @@
     1.4  
     1.5  static OopMap* generate_oop_map(StubAssembler* sasm, bool save_fpu_registers) {
     1.6    assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words),
     1.7 -         " mismatch in calculation");
     1.8 +         "mismatch in calculation");
     1.9    sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
    1.10    int frame_size_in_slots = frame_size_in_bytes / sizeof(jint);
    1.11    OopMap* oop_map = new OopMap(frame_size_in_slots, 0);
    1.12 @@ -176,9 +176,8 @@
    1.13  
    1.14  static OopMap* save_live_registers(StubAssembler* sasm, bool save_fpu_registers = true) {
    1.15    assert(frame_size_in_bytes == __ total_frame_size_in_bytes(reg_save_size_in_words),
    1.16 -         " mismatch in calculation");
    1.17 +         "mismatch in calculation");
    1.18    __ save_frame_c1(frame_size_in_bytes);
    1.19 -  sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
    1.20  
    1.21    // Record volatile registers as callee-save values in an OopMap so their save locations will be
    1.22    // propagated to the caller frame's RegisterMap during StackFrameStream construction (needed for
    1.23 @@ -367,23 +366,7 @@
    1.24    switch (id) {
    1.25      case forward_exception_id:
    1.26        {
    1.27 -        // we're handling an exception in the context of a compiled
    1.28 -        // frame.  The registers have been saved in the standard
    1.29 -        // places.  Perform an exception lookup in the caller and
    1.30 -        // dispatch to the handler if found.  Otherwise unwind and
    1.31 -        // dispatch to the callers exception handler.
    1.32 -
    1.33 -        oop_maps = new OopMapSet();
    1.34 -        OopMap* oop_map = generate_oop_map(sasm, true);
    1.35 -
    1.36 -        // transfer the pending exception to the exception_oop
    1.37 -        __ ld_ptr(G2_thread, in_bytes(JavaThread::pending_exception_offset()), Oexception);
    1.38 -        __ ld_ptr(Oexception, 0, G0);
    1.39 -        __ st_ptr(G0, G2_thread, in_bytes(JavaThread::pending_exception_offset()));
    1.40 -        __ add(I7, frame::pc_return_offset, Oissuing_pc);
    1.41 -
    1.42 -        generate_handle_exception(sasm, oop_maps, oop_map);
    1.43 -        __ should_not_reach_here();
    1.44 +        oop_maps = generate_handle_exception(id, sasm);
    1.45        }
    1.46        break;
    1.47  
    1.48 @@ -671,15 +654,14 @@
    1.49        break;
    1.50  
    1.51      case handle_exception_id:
    1.52 -      {
    1.53 -        __ set_info("handle_exception", dont_gc_arguments);
    1.54 -        // make a frame and preserve the caller's caller-save registers
    1.55 +      { __ set_info("handle_exception", dont_gc_arguments);
    1.56 +        oop_maps = generate_handle_exception(id, sasm);
    1.57 +      }
    1.58 +      break;
    1.59  
    1.60 -        oop_maps = new OopMapSet();
    1.61 -        OopMap* oop_map = save_live_registers(sasm);
    1.62 -        __ mov(Oexception->after_save(),  Oexception);
    1.63 -        __ mov(Oissuing_pc->after_save(), Oissuing_pc);
    1.64 -        generate_handle_exception(sasm, oop_maps, oop_map);
    1.65 +    case handle_exception_from_callee_id:
    1.66 +      { __ set_info("handle_exception_from_callee", dont_gc_arguments);
    1.67 +        oop_maps = generate_handle_exception(id, sasm);
    1.68        }
    1.69        break;
    1.70  
    1.71 @@ -696,7 +678,7 @@
    1.72                          G2_thread, Oissuing_pc->after_save());
    1.73          __ verify_not_null_oop(Oexception->after_save());
    1.74  
    1.75 -        // Restore SP from L7 if the exception PC is a MethodHandle call site.
    1.76 +        // Restore SP from L7 if the exception PC is a method handle call site.
    1.77          __ mov(O0, G5);  // Save the target address.
    1.78          __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0);
    1.79          __ tst(L0);  // Condition codes are preserved over the restore.
    1.80 @@ -1006,48 +988,89 @@
    1.81  }
    1.82  
    1.83  
    1.84 -void Runtime1::generate_handle_exception(StubAssembler* sasm, OopMapSet* oop_maps, OopMap* oop_map, bool) {
    1.85 -  Label no_deopt;
    1.86 +OopMapSet* Runtime1::generate_handle_exception(StubID id, StubAssembler* sasm) {
    1.87 +  __ block_comment("generate_handle_exception");
    1.88 +
    1.89 +  // Save registers, if required.
    1.90 +  OopMapSet* oop_maps = new OopMapSet();
    1.91 +  OopMap* oop_map = NULL;
    1.92 +  switch (id) {
    1.93 +  case forward_exception_id:
    1.94 +    // We're handling an exception in the context of a compiled frame.
    1.95 +    // The registers have been saved in the standard places.  Perform
    1.96 +    // an exception lookup in the caller and dispatch to the handler
    1.97 +    // if found.  Otherwise unwind and dispatch to the callers
    1.98 +    // exception handler.
    1.99 +     oop_map = generate_oop_map(sasm, true);
   1.100 +
   1.101 +     // transfer the pending exception to the exception_oop
   1.102 +     __ ld_ptr(G2_thread, in_bytes(JavaThread::pending_exception_offset()), Oexception);
   1.103 +     __ ld_ptr(Oexception, 0, G0);
   1.104 +     __ st_ptr(G0, G2_thread, in_bytes(JavaThread::pending_exception_offset()));
   1.105 +     __ add(I7, frame::pc_return_offset, Oissuing_pc);
   1.106 +    break;
   1.107 +  case handle_exception_id:
   1.108 +    // At this point all registers MAY be live.
   1.109 +    oop_map = save_live_registers(sasm);
   1.110 +    __ mov(Oexception->after_save(),  Oexception);
   1.111 +    __ mov(Oissuing_pc->after_save(), Oissuing_pc);
   1.112 +    break;
   1.113 +  case handle_exception_from_callee_id:
   1.114 +    // At this point all registers except exception oop (Oexception)
   1.115 +    // and exception pc (Oissuing_pc) are dead.
   1.116 +    oop_map = new OopMap(frame_size_in_bytes / sizeof(jint), 0);
   1.117 +    sasm->set_frame_size(frame_size_in_bytes / BytesPerWord);
   1.118 +    __ save_frame_c1(frame_size_in_bytes);
   1.119 +    __ mov(Oexception->after_save(),  Oexception);
   1.120 +    __ mov(Oissuing_pc->after_save(), Oissuing_pc);
   1.121 +    break;
   1.122 +  default:  ShouldNotReachHere();
   1.123 +  }
   1.124  
   1.125    __ verify_not_null_oop(Oexception);
   1.126  
   1.127    // save the exception and issuing pc in the thread
   1.128 -  __ st_ptr(Oexception, G2_thread, in_bytes(JavaThread::exception_oop_offset()));
   1.129 +  __ st_ptr(Oexception,  G2_thread, in_bytes(JavaThread::exception_oop_offset()));
   1.130    __ st_ptr(Oissuing_pc, G2_thread, in_bytes(JavaThread::exception_pc_offset()));
   1.131  
   1.132 -  // save the real return address and use the throwing pc as the return address to lookup (has bci & oop map)
   1.133 -  __ mov(I7, L0);
   1.134 +  // use the throwing pc as the return address to lookup (has bci & oop map)
   1.135    __ mov(Oissuing_pc, I7);
   1.136    __ sub(I7, frame::pc_return_offset, I7);
   1.137    int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, exception_handler_for_pc));
   1.138 +  oop_maps->add_gc_map(call_offset, oop_map);
   1.139  
   1.140    // Note: if nmethod has been deoptimized then regardless of
   1.141    // whether it had a handler or not we will deoptimize
   1.142    // by entering the deopt blob with a pending exception.
   1.143  
   1.144 -#ifdef ASSERT
   1.145 -  Label done;
   1.146 -  __ tst(O0);
   1.147 -  __ br(Assembler::notZero, false, Assembler::pn, done);
   1.148 -  __ delayed()->nop();
   1.149 -  __ stop("should have found address");
   1.150 -  __ bind(done);
   1.151 -#endif
   1.152 +  // Restore the registers that were saved at the beginning, remove
   1.153 +  // the frame and jump to the exception handler.
   1.154 +  switch (id) {
   1.155 +  case forward_exception_id:
   1.156 +  case handle_exception_id:
   1.157 +    restore_live_registers(sasm);
   1.158 +    __ jmp(O0, 0);
   1.159 +    __ delayed()->restore();
   1.160 +    break;
   1.161 +  case handle_exception_from_callee_id:
   1.162 +    // Restore SP from L7 if the exception PC is a method handle call site.
   1.163 +    __ mov(O0, G5);  // Save the target address.
   1.164 +    __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0);
   1.165 +    __ tst(L0);  // Condition codes are preserved over the restore.
   1.166 +    __ restore();
   1.167  
   1.168 -  // restore the registers that were saved at the beginning and jump to the exception handler.
   1.169 -  restore_live_registers(sasm);
   1.170 +    __ jmp(G5, 0);  // jump to the exception handler
   1.171 +    __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP);  // Restore SP if required.
   1.172 +    break;
   1.173 +  default:  ShouldNotReachHere();
   1.174 +  }
   1.175  
   1.176 -  __ jmp(O0, 0);
   1.177 -  __ delayed()->restore();
   1.178 -
   1.179 -  oop_maps->add_gc_map(call_offset, oop_map);
   1.180 +  return oop_maps;
   1.181  }
   1.182  
   1.183  
   1.184  #undef __
   1.185  
   1.186 -#define __ masm->
   1.187 -
   1.188  const char *Runtime1::pd_name_for_address(address entry) {
   1.189    return "<unknown function>";
   1.190  }

mercurial