src/cpu/x86/vm/runtime_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6893081 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/runtime_x86_32.cpp

Print this page
rev 1081 : imported patch indy-cleanup-6893081.patch


  26 #include "incls/_precompiled.incl"
  27 #include "incls/_runtime_x86_32.cpp.incl"
  28 
  29 #define __ masm->
  30 
  31 ExceptionBlob*     OptoRuntime::_exception_blob;
  32 
  33 //------------------------------generate_exception_blob---------------------------
  34 // creates exception blob at the end
  35 // Using exception blob, this code is jumped from a compiled method.
  36 //
  37 // Given an exception pc at a call we call into the runtime for the
  38 // handler in this method. This handler might merely restore state
  39 // (i.e. callee save registers) unwind the frame and jump to the
  40 // exception handler for the nmethod if there is no Java level handler
  41 // for the nmethod.
  42 //
  43 // This code is entered with a jmp.
  44 //
  45 // Arguments:
  46 //   rax,: exception oop
  47 //   rdx: exception pc
  48 //
  49 // Results:
  50 //   rax,: exception oop
  51 //   rdx: exception pc in caller or ???
  52 //   destination: exception handler of caller
  53 //
  54 // Note: the exception pc MUST be at a call (precise debug information)
  55 //       Only register rax, rdx, rcx are not callee saved.
  56 //
  57 
  58 void OptoRuntime::generate_exception_blob() {
  59 
  60   // Capture info about frame layout
  61   enum layout {
  62     thread_off,                 // last_java_sp
  63     // The frame sender code expects that rbp will be in the "natural" place and
  64     // will override any oopMap setting for it. We must therefore force the layout
  65     // so that it agrees with the frame sender code.
  66     rbp_off,
  67     return_off,                 // slot for return address
  68     framesize
  69   };
  70 


  96   // If so, it returns the handler address.
  97   // If not, it prepares for stack-unwinding, restoring the callee-save
  98   // registers of the frame being removed.
  99   //
 100   __ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument
 101   __ set_last_Java_frame(rcx, noreg, noreg, NULL);
 102 
 103   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
 104 
 105   // No registers to map, rbp is known implicitly
 106   oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
 107   __ get_thread(rcx);
 108   __ reset_last_Java_frame(rcx, false, false);
 109 
 110   // Restore callee-saved registers
 111   __ movptr(rbp, Address(rsp, rbp_off * wordSize));
 112 
 113   __ addptr(rsp, return_off * wordSize);   // Epilog!
 114   __ pop(rdx); // Exception pc
 115 

 116 
 117   // rax,: exception handler for given <exception oop/exception pc>


 118 
 119   // We have a handler in rax, (could be deopt blob)
 120   // rdx - throwing pc, deopt blob will need it.
 121 
 122   __ push(rax);
 123 
 124   // rcx contains handler address
 125 
 126   __ get_thread(rcx);           // TLS
 127   // Get the exception
 128   __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset()));
 129   // Get the exception pc in case we are deoptimized
 130   __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset()));
 131 #ifdef ASSERT
 132   __ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), NULL_WORD);
 133   __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD);
 134 #endif
 135   // Clear the exception oop so GC no longer processes it as a root.
 136   __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD);
 137 
 138   __ pop(rcx);
 139 
 140   // rax,: exception oop
 141   // rcx: exception handler
 142   // rdx: exception pc
 143   __ jmp (rcx);
 144 
 145   // -------------
 146   // make sure all code is generated
 147   masm->flush();
 148 
 149   _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize);
 150 }


  26 #include "incls/_precompiled.incl"
  27 #include "incls/_runtime_x86_32.cpp.incl"
  28 
  29 #define __ masm->
  30 
  31 ExceptionBlob*     OptoRuntime::_exception_blob;
  32 
  33 //------------------------------generate_exception_blob---------------------------
  34 // creates exception blob at the end
  35 // Using exception blob, this code is jumped from a compiled method.
  36 //
  37 // Given an exception pc at a call we call into the runtime for the
  38 // handler in this method. This handler might merely restore state
  39 // (i.e. callee save registers) unwind the frame and jump to the
  40 // exception handler for the nmethod if there is no Java level handler
  41 // for the nmethod.
  42 //
  43 // This code is entered with a jmp.
  44 //
  45 // Arguments:
  46 //   rax: exception oop
  47 //   rdx: exception pc
  48 //
  49 // Results:
  50 //   rax: exception oop
  51 //   rdx: exception pc in caller or ???
  52 //   destination: exception handler of caller
  53 //
  54 // Note: the exception pc MUST be at a call (precise debug information)
  55 //       Only register rax, rdx, rcx are not callee saved.
  56 //
  57 
  58 void OptoRuntime::generate_exception_blob() {
  59 
  60   // Capture info about frame layout
  61   enum layout {
  62     thread_off,                 // last_java_sp
  63     // The frame sender code expects that rbp will be in the "natural" place and
  64     // will override any oopMap setting for it. We must therefore force the layout
  65     // so that it agrees with the frame sender code.
  66     rbp_off,
  67     return_off,                 // slot for return address
  68     framesize
  69   };
  70 


  96   // If so, it returns the handler address.
  97   // If not, it prepares for stack-unwinding, restoring the callee-save
  98   // registers of the frame being removed.
  99   //
 100   __ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument
 101   __ set_last_Java_frame(rcx, noreg, noreg, NULL);
 102 
 103   __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C)));
 104 
 105   // No registers to map, rbp is known implicitly
 106   oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
 107   __ get_thread(rcx);
 108   __ reset_last_Java_frame(rcx, false, false);
 109 
 110   // Restore callee-saved registers
 111   __ movptr(rbp, Address(rsp, rbp_off * wordSize));
 112 
 113   __ addptr(rsp, return_off * wordSize);   // Epilog!
 114   __ pop(rdx); // Exception pc
 115 
 116   // rax: exception handler for given <exception oop/exception pc>
 117 
 118   // Restore SP from BP if the exception PC is a MethodHandle call.
 119   __ cmpl(Address(rcx, JavaThread::is_method_handle_exception_offset()), 0);
 120   __ cmovptr(Assembler::notEqual, rsp, rbp);
 121 
 122   // We have a handler in rax, (could be deopt blob)
 123   // rdx - throwing pc, deopt blob will need it.
 124 
 125   __ push(rax);
 126 



 127   // Get the exception
 128   __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset()));
 129   // Get the exception pc in case we are deoptimized
 130   __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset()));
 131 #ifdef ASSERT
 132   __ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), NULL_WORD);
 133   __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD);
 134 #endif
 135   // Clear the exception oop so GC no longer processes it as a root.
 136   __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD);
 137 
 138   __ pop(rcx);
 139 
 140   // rax: exception oop
 141   // rcx: exception handler
 142   // rdx: exception pc
 143   __ jmp (rcx);
 144 
 145   // -------------
 146   // make sure all code is generated
 147   masm->flush();
 148 
 149   _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize);
 150 }
src/cpu/x86/vm/runtime_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File