@@ -105,8 +105,14 @@ class HandlerImpl {
105105
106106 public:
107107
108+ static int emit_exception_handler(C2_MacroAssembler *masm);
108109 static int emit_deopt_handler(C2_MacroAssembler* masm);
109110
111+ static uint size_exception_handler() {
112+ return ( 3 * 4 );
113+ }
114+
115+
110116 static uint size_deopt_handler() {
111117 return ( 9 * 4 );
112118 }
@@ -870,6 +876,26 @@ uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
870876
871877//=============================================================================
872878
879+ // Emit exception handler code.
880+ int HandlerImpl::emit_exception_handler(C2_MacroAssembler* masm) {
881+ address base = __ start_a_stub(size_exception_handler());
882+ if (base == nullptr) {
883+ ciEnv::current()->record_failure("CodeCache is full");
884+ return 0; // CodeBuffer::expand failed
885+ }
886+
887+ int offset = __ offset();
888+
889+ // OK to trash LR, because exception blob will kill it
890+ __ jump(OptoRuntime::exception_blob()->entry_point(), relocInfo::runtime_call_type, LR_tmp);
891+
892+ assert(__ offset() - offset <= (int) size_exception_handler(), "overflow");
893+
894+ __ end_a_stub();
895+
896+ return offset;
897+ }
898+
873899int HandlerImpl::emit_deopt_handler(C2_MacroAssembler* masm) {
874900 // Can't use any of the current frame's registers as we may have deopted
875901 // at a poll and everything can be live.
@@ -880,26 +906,19 @@ int HandlerImpl::emit_deopt_handler(C2_MacroAssembler* masm) {
880906 }
881907
882908 int offset = __ offset();
909+ address deopt_pc = __ pc();
883910
884- Label start;
885- __ bind(start);
886-
911+ __ sub(SP, SP, wordSize); // make room for saved PC
912+ __ push(LR); // save LR that may be live when we get here
913+ __ mov_relative_address(LR, deopt_pc);
914+ __ str(LR, Address(SP, wordSize)); // save deopt PC
915+ __ pop(LR); // restore LR
887916 __ jump(SharedRuntime::deopt_blob()->unpack(), relocInfo::runtime_call_type, noreg);
888917
889- int entry_offset = __ offset();
890- address deopt_pc = __ pc();
891- // Preserve R0 and reserve space for the address of the entry point
892- __ push(RegisterSet(R0) | RegisterSet(R1));
893- // Store the entry point address
894- __ mov_relative_address(R0, deopt_pc);
895- __ str(R0, Address(SP, wordSize));
896- __ pop(R0); // restore R0
897- __ b(start);
898-
899918 assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow");
900919
901920 __ end_a_stub();
902- return entry_offset ;
921+ return offset ;
903922}
904923
905924bool Matcher::match_rule_supported(int opcode) {
0 commit comments