--- a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp	Fri Oct 16 12:20:06 2020
+++ b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp	Fri Oct 16 14:58:59 2020
@@ -224,42 +224,12 @@
   return frame(sp, fp, epc);
 }
 
-bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
- address pc = (address) os::Solaris::ucontext_get_pc(uc);
-  if (Interpreter::contains(pc)) {
-    // interpreter performs stack banging after the fixed frame header has
-    // been generated while the compilers perform it before. To maintain
-    // semantic consistency between interpreted and compiled frames, the
-    // method returns the Java sender of the current frame.
-    *fr = os::fetch_frame_from_context(uc);
-    if (!fr->is_first_java_frame()) {
-      // get_frame_at_stack_banging_point() is only called when we
-      // have well defined stacks so java_sender() calls do not need
-      // to assert safe_for_sender() first.
-      *fr = fr->java_sender();
-    }
-  } else {
-    // more complex code with compiled code
-    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
-    CodeBlob* cb = CodeCache::find_blob(pc);
-    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
-      // Not sure where the pc points to, fallback to default
-      // stack overflow handling
-      return false;
-    } else {
-      // in compiled code, the stack banging is performed just after the return pc
-      // has been pushed on the stack
-      intptr_t* fp = os::Solaris::ucontext_get_fp(uc);
-      intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
-      *fr = frame(sp + 1, fp, (address)*sp);
-      if (!fr->is_java_frame()) {
-        // See java_sender() comment above.
-        *fr = fr->java_sender();
-      }
-    }
-  }
-  assert(fr->is_java_frame(), "Safety check");
-  return true;
+frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
+  const ucontext_t* uc = (const ucontext_t*)ucVoid;
+  frame fr = os::fetch_frame_from_context(uc);
+  // in compiled code, the stack banging is performed just after the return pc
+  // has been pushed on the stack
+  return frame(fr.sp() + 1, fr.fp(), (address)*(fr.sp()));
 }
 
 frame os::get_sender_for_C_frame(frame* fr) {
@@ -459,39 +429,8 @@
     // Handle ALL stack overflow variations here
     if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) {
       address addr = (address) info->si_addr;
-      if (thread->in_stack_yellow_reserved_zone(addr)) {
-        if (thread->thread_state() == _thread_in_Java) {
-          if (thread->in_stack_reserved_zone(addr)) {
-            frame fr;
-            if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) {
-              assert(fr.is_java_frame(), "Must be Java frame");
-              frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
-              if (activation.sp() != NULL) {
-                thread->disable_stack_reserved_zone();
-                if (activation.is_interpreted_frame()) {
-                  thread->set_reserved_stack_activation((address)(
-                    activation.fp() + frame::interpreter_frame_initial_sp_offset));
-                } else {
-                  thread->set_reserved_stack_activation((address)activation.unextended_sp());
-                }
-                return true;
-              }
-            }
-          }
-          // Throw a stack overflow exception.  Guard pages will be reenabled
-          // while unwinding the stack.
-          thread->disable_stack_yellow_reserved_zone();
-          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
-        } else {
-          // Thread was in the vm or native code.  Return and try to finish.
-          thread->disable_stack_yellow_reserved_zone();
-          return true;
-        }
-      } else if (thread->in_stack_red_zone(addr)) {
-        // Fatal red zone violation.  Disable the guard pages and fall through
-        // to handle_unexpected_exception way down below.
-        thread->disable_stack_red_zone();
-        tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
+      if (os::Posix::handle_stack_overflow(thread, addr, pc, uc, &stub)) {
+        return 1; // continue
       }
     }
 
