6950178: Zero stack improvements

Moves the logic for determining the size of the Zero stack into the ZeroStack class.

Reviewed-by: twisti
This commit is contained in:
Gary Benson 2010-05-06 02:09:18 -07:00 committed by Christian Thalinger
parent 070ea7c310
commit 4d6c5d6fef
5 changed files with 24 additions and 10 deletions

View file

@ -25,19 +25,24 @@
// This function should match SharkStack::CreateStackOverflowCheck
inline void ZeroStack::overflow_check(int required_words, TRAPS) {
JavaThread *thread = (JavaThread *) THREAD;
// Check the Zero stack
if (required_words > available_words()) {
if (available_words() < required_words) {
handle_overflow(THREAD);
return;
}
// Check the ABI stack
address stack_top = thread->stack_base() - thread->stack_size();
int free_stack = ((address) &stack_top) - stack_top;
if (free_stack < shadow_pages_size()) {
if (abi_stack_available(THREAD) < 0) {
handle_overflow(THREAD);
return;
}
}
// This method returns the amount of ABI stack available for us
// 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;
int stack_free = thread->stack_size() - stack_used;
return stack_free - shadow_pages_size();
}