Andreas Wacknitz
2024-01-27 9a6458b68a833ac3c968ac953949a8dc833c2b77
commit | author | age
d57137 1 --- a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp    Fri Oct 16 12:20:06 2020
NP 2 +++ b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp    Fri Oct 16 14:58:59 2020
3 @@ -224,42 +224,12 @@
4    return frame(sp, fp, epc);
5  }
6  
7 -bool os::Solaris::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
8 - address pc = (address) os::Solaris::ucontext_get_pc(uc);
9 -  if (Interpreter::contains(pc)) {
10 -    // interpreter performs stack banging after the fixed frame header has
11 -    // been generated while the compilers perform it before. To maintain
12 -    // semantic consistency between interpreted and compiled frames, the
13 -    // method returns the Java sender of the current frame.
14 -    *fr = os::fetch_frame_from_context(uc);
15 -    if (!fr->is_first_java_frame()) {
16 -      // get_frame_at_stack_banging_point() is only called when we
17 -      // have well defined stacks so java_sender() calls do not need
18 -      // to assert safe_for_sender() first.
19 -      *fr = fr->java_sender();
20 -    }
21 -  } else {
22 -    // more complex code with compiled code
23 -    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
24 -    CodeBlob* cb = CodeCache::find_blob(pc);
25 -    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
26 -      // Not sure where the pc points to, fallback to default
27 -      // stack overflow handling
28 -      return false;
29 -    } else {
30 -      // in compiled code, the stack banging is performed just after the return pc
31 -      // has been pushed on the stack
32 -      intptr_t* fp = os::Solaris::ucontext_get_fp(uc);
33 -      intptr_t* sp = os::Solaris::ucontext_get_sp(uc);
34 -      *fr = frame(sp + 1, fp, (address)*sp);
35 -      if (!fr->is_java_frame()) {
36 -        // See java_sender() comment above.
37 -        *fr = fr->java_sender();
38 -      }
39 -    }
40 -  }
41 -  assert(fr->is_java_frame(), "Safety check");
42 -  return true;
43 +frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
44 +  const ucontext_t* uc = (const ucontext_t*)ucVoid;
45 +  frame fr = os::fetch_frame_from_context(uc);
46 +  // in compiled code, the stack banging is performed just after the return pc
47 +  // has been pushed on the stack
48 +  return frame(fr.sp() + 1, fr.fp(), (address)*(fr.sp()));
49  }
50  
51  frame os::get_sender_for_C_frame(frame* fr) {
9a6458 52 @@ -459,39 +429,8 @@
d57137 53      // Handle ALL stack overflow variations here
NP 54      if (sig == SIGSEGV && info->si_code == SEGV_ACCERR) {
55        address addr = (address) info->si_addr;
56 -      if (thread->in_stack_yellow_reserved_zone(addr)) {
57 -        if (thread->thread_state() == _thread_in_Java) {
58 -          if (thread->in_stack_reserved_zone(addr)) {
59 -            frame fr;
60 -            if (os::Solaris::get_frame_at_stack_banging_point(thread, uc, &fr)) {
61 -              assert(fr.is_java_frame(), "Must be Java frame");
62 -              frame activation = SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
63 -              if (activation.sp() != NULL) {
64 -                thread->disable_stack_reserved_zone();
65 -                if (activation.is_interpreted_frame()) {
66 -                  thread->set_reserved_stack_activation((address)(
67 -                    activation.fp() + frame::interpreter_frame_initial_sp_offset));
68 -                } else {
69 -                  thread->set_reserved_stack_activation((address)activation.unextended_sp());
70 -                }
71 -                return true;
72 -              }
73 -            }
74 -          }
75 -          // Throw a stack overflow exception.  Guard pages will be reenabled
76 -          // while unwinding the stack.
77 -          thread->disable_stack_yellow_reserved_zone();
78 -          stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
79 -        } else {
80 -          // Thread was in the vm or native code.  Return and try to finish.
81 -          thread->disable_stack_yellow_reserved_zone();
82 -          return true;
83 -        }
84 -      } else if (thread->in_stack_red_zone(addr)) {
85 -        // Fatal red zone violation.  Disable the guard pages and fall through
86 -        // to handle_unexpected_exception way down below.
87 -        thread->disable_stack_red_zone();
88 -        tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
89 +      if (os::Posix::handle_stack_overflow(thread, addr, pc, uc, &stub)) {
90 +        return 1; // continue
91        }
92      }
93