changeset 6474:f2f5a053bd0d

8017313: PPC64 (part 6): stack handling improvements Summary: Precompute limit for stack overflow check Reviewed-by: kvn, coleenp
author goetz
date Fri, 07 Feb 2014 16:07:53 +0100
parents ccc95eb5ca55
children 53986bf097ad
files src/cpu/ppc/vm/cppInterpreter_ppc.cpp src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp src/share/vm/runtime/thread.cpp src/share/vm/runtime/thread.hpp
diffstat 5 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/ppc/vm/cppInterpreter_ppc.cpp	Fri Feb 07 15:08:10 2014 +0100
+++ b/src/cpu/ppc/vm/cppInterpreter_ppc.cpp	Fri Feb 07 16:07:53 2014 +0100
@@ -422,8 +422,8 @@
     __ addi(max_stack, max_stack, methodOopDesc::extra_stack_entries());
   }
 
-  // mem_stack_limit = thread->memory_stack_limit();
-  __ ld(mem_stack_limit, thread_(memory_stack_limit));
+  // mem_stack_limit = thread->stack_limit();
+  __ ld(mem_stack_limit, thread_(stack_overflow_limit));
 
   // Point locals at the first argument. Method's locals are the
   // parameters on top of caller's expression stack.
--- a/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Fri Feb 07 15:08:10 2014 +0100
+++ b/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Fri Feb 07 16:07:53 2014 +0100
@@ -94,7 +94,6 @@
   // Initialize the memory stack limit.
   address mem_stk_limit = ((JavaThread *)thread)->stack_yellow_zone_base() +
     (os::vm_page_size() * StackShadowPages);
-  thread->set_memory_stack_limit(mem_stk_limit);
 }
 
 // Frame information (pc, sp, fp) retrieved via ucontext
--- a/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Fri Feb 07 15:08:10 2014 +0100
+++ b/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Fri Feb 07 16:07:53 2014 +0100
@@ -106,8 +106,6 @@
   // Initialize the memory stack limit.
   address mem_stk_limit = thread->stack_base() - thread->stack_size() +
     ((StackShadowPages + StackYellowPages + StackRedPages) * os::vm_page_size());
-
-  thread->set_memory_stack_limit(mem_stk_limit);
 }
 
 // Frame information (pc, sp, fp) retrieved via ucontext
--- a/src/share/vm/runtime/thread.cpp	Fri Feb 07 15:08:10 2014 +0100
+++ b/src/share/vm/runtime/thread.cpp	Fri Feb 07 16:07:53 2014 +0100
@@ -315,6 +315,9 @@
 void Thread::record_stack_base_and_size() {
   set_stack_base(os::current_stack_base());
   set_stack_size(os::current_stack_size());
+  if (is_Java_thread()) {
+    ((JavaThread*) this)->set_stack_overflow_limit();
+  }
   // CR 7190089: on Solaris, primordial thread's stack is adjusted
   // in initialize_thread(). Without the adjustment, stack size is
   // incorrect if stack is set to unlimited (ulimit -s unlimited).
--- a/src/share/vm/runtime/thread.hpp	Fri Feb 07 15:08:10 2014 +0100
+++ b/src/share/vm/runtime/thread.hpp	Fri Feb 07 16:07:53 2014 +0100
@@ -41,6 +41,7 @@
 #include "runtime/stubRoutines.hpp"
 #include "runtime/threadLocalStorage.hpp"
 #include "runtime/unhandledOops.hpp"
+#include "utilities/macros.hpp"
 #include "services/memRecorder.hpp"
 #include "trace/traceBackend.hpp"
 #include "trace/traceMacros.hpp"
@@ -544,19 +545,6 @@
     return (_stack_base >= adr && adr >= (_stack_base - _stack_size));
   }
 
-#ifdef CC_INTERP
-  // The cppInterpreter does not support implicit checks, thus we check
-  // stack overflow by comparison. We precompute the limit of the stack
-  // and load it from here to simplify the check in assembly.
- protected:
-  address _memory_stack_limit;
-
- public:
-  address memory_stack_limit()                { return _memory_stack_limit;    }
-  void set_memory_stack_limit(address limit)  { _memory_stack_limit = limit;   }
-  static ByteSize memory_stack_limit_offset() { return byte_offset_of(Thread, _memory_stack_limit); }
-#endif
-
   uintptr_t self_raw_id()                    { return _self_raw_id; }
   void      set_self_raw_id(uintptr_t value) { _self_raw_id = value; }
 
@@ -908,7 +896,11 @@
 
  private:
 
-  StackGuardState        _stack_guard_state;
+  StackGuardState  _stack_guard_state;
+
+  // Precompute the limit of the stack as used in stack overflow checks.
+  // We load it from here to simplify the stack overflow check in assembly.
+  address          _stack_overflow_limit;
 
   // Compiler exception handling (NOTE: The _exception_oop is *NOT* the same as _pending_exception. It is
   // used to temp. parsing values into and out of the runtime system during exception handling for compiled
@@ -1325,6 +1317,14 @@
   // and reguard if possible.
   bool reguard_stack(void);
 
+  address stack_overflow_limit() { return _stack_overflow_limit; }
+  void set_stack_overflow_limit() {
+    _stack_overflow_limit = _stack_base - _stack_size +
+                            ((StackShadowPages +
+                              StackYellowPages +
+                              StackRedPages) * os::vm_page_size());
+  }
+
   // Misc. accessors/mutators
   void set_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = true; }
   void clr_do_not_unlock(void)                   { _do_not_unlock_if_synchronized = false; }
@@ -1359,6 +1359,7 @@
   static ByteSize exception_oop_offset()         { return byte_offset_of(JavaThread, _exception_oop       ); }
   static ByteSize exception_pc_offset()          { return byte_offset_of(JavaThread, _exception_pc        ); }
   static ByteSize exception_handler_pc_offset()  { return byte_offset_of(JavaThread, _exception_handler_pc); }
+  static ByteSize stack_overflow_limit_offset()  { return byte_offset_of(JavaThread, _stack_overflow_limit); }
   static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); }
   static ByteSize stack_guard_state_offset()     { return byte_offset_of(JavaThread, _stack_guard_state   ); }
   static ByteSize suspend_flags_offset()         { return byte_offset_of(JavaThread, _suspend_flags       ); }