diff --git a/src/cpu/zero/vm/stack_zero.cpp b/src/cpu/zero/vm/stack_zero.cpp index 33b0551b53978b37f0e3746bd88545fb410b15e4..747199f5492b8e520d3acb3e04ea56fd10c05778 100644 --- a/src/cpu/zero/vm/stack_zero.cpp +++ b/src/cpu/zero/vm/stack_zero.cpp @@ -30,7 +30,9 @@ int ZeroStack::suggest_size(Thread *thread) const { assert(needs_setup(), "already set up"); - return align_size_down(abi_stack_available(thread) / 2, wordSize); + int abi_available = abi_stack_available(thread); + assert(abi_available >= 0, "available abi stack must be >= 0"); + return align_size_down(abi_available / 2, wordSize); } void ZeroStack::handle_overflow(TRAPS) { diff --git a/src/cpu/zero/vm/stack_zero.inline.hpp b/src/cpu/zero/vm/stack_zero.inline.hpp index f0387bb7bfd1c1c585c2d1d713bf77e5d642b50a..0f868823f690f4c64f873a7634e3b303d25f88cd 100644 --- a/src/cpu/zero/vm/stack_zero.inline.hpp +++ b/src/cpu/zero/vm/stack_zero.inline.hpp @@ -48,9 +48,11 @@ inline void ZeroStack::overflow_check(int required_words, TRAPS) { // to use under normal circumstances. Note that the returned // value can be negative. inline int ZeroStack::abi_stack_available(Thread *thread) const { - int stack_used = thread->stack_base() - (address) &stack_used; + guarantee(Thread::current() == thread, "should run in the same thread"); + int stack_used = thread->stack_base() - (address) &stack_used + + (StackYellowPages+StackRedPages+StackShadowPages) * os::vm_page_size(); int stack_free = thread->stack_size() - stack_used; - return stack_free - shadow_pages_size(); + return stack_free; } #endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP