twisti@1818: /* stefank@2314: * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. twisti@1818: * Copyright 2010 Red Hat, Inc. twisti@1818: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. twisti@1818: * twisti@1818: * This code is free software; you can redistribute it and/or modify it twisti@1818: * under the terms of the GNU General Public License version 2 only, as twisti@1818: * published by the Free Software Foundation. twisti@1818: * twisti@1818: * This code is distributed in the hope that it will be useful, but WITHOUT twisti@1818: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or twisti@1818: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License twisti@1818: * version 2 for more details (a copy is included in the LICENSE file that twisti@1818: * accompanied this code). twisti@1818: * twisti@1818: * You should have received a copy of the GNU General Public License version twisti@1818: * 2 along with this work; if not, write to the Free Software Foundation, twisti@1818: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. twisti@1818: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. twisti@1818: * twisti@1818: */ twisti@1818: stefank@2314: #ifndef CPU_ZERO_VM_STACK_ZERO_INLINE_HPP stefank@2314: #define CPU_ZERO_VM_STACK_ZERO_INLINE_HPP stefank@2314: stefank@2314: #include "runtime/thread.hpp" stefank@2314: #include "stack_zero.hpp" stefank@2314: twisti@1818: // This function should match SharkStack::CreateStackOverflowCheck twisti@1818: inline void ZeroStack::overflow_check(int required_words, TRAPS) { twisti@1818: // Check the Zero stack twisti@1866: if (available_words() < required_words) { twisti@1818: handle_overflow(THREAD); twisti@1818: return; twisti@1818: } twisti@1818: twisti@1818: // Check the ABI stack twisti@1866: if (abi_stack_available(THREAD) < 0) { twisti@1818: handle_overflow(THREAD); twisti@1818: return; twisti@1818: } twisti@1818: } twisti@1866: twisti@1866: // This method returns the amount of ABI stack available for us twisti@1866: // to use under normal circumstances. Note that the returned twisti@1866: // value can be negative. twisti@1866: inline int ZeroStack::abi_stack_available(Thread *thread) const { simonis@7599: guarantee(Thread::current() == thread, "should run in the same thread"); simonis@7599: int stack_used = thread->stack_base() - (address) &stack_used simonis@7599: + (StackYellowPages+StackRedPages+StackShadowPages) * os::vm_page_size(); twisti@1866: int stack_free = thread->stack_size() - stack_used; simonis@7599: return stack_free; twisti@1866: } stefank@2314: stefank@2314: #endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP