< prev index next >

src/share/vm/runtime/thread.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1784   Thread* thread = ThreadLocalStorage::thread();
1785   assert(thread != NULL && thread->is_Java_thread(), "just checking");
1786   return (JavaThread*)thread;
1787 }
1788 
1789 inline CompilerThread* JavaThread::as_CompilerThread() {
1790   assert(is_Compiler_thread(), "just checking");
1791   return (CompilerThread*)this;
1792 }
1793 
1794 inline bool JavaThread::stack_guard_zone_unused() {
1795   return _stack_guard_state == stack_guard_unused;
1796 }
1797 
1798 inline bool JavaThread::stack_yellow_zone_disabled() {
1799   return _stack_guard_state == stack_guard_yellow_disabled;
1800 }
1801 
1802 inline bool JavaThread::stack_yellow_zone_enabled() {
1803 #ifdef ASSERT
1804   if (os::uses_stack_guard_pages()) {

1805     assert(_stack_guard_state != stack_guard_unused, "guard pages must be in use");
1806   }
1807 #endif
1808     return _stack_guard_state == stack_guard_enabled;
1809 }
1810 
1811 inline size_t JavaThread::stack_available(address cur_sp) {
1812   // This code assumes java stacks grow down
1813   address low_addr; // Limit on the address for deepest stack depth
1814   if ( _stack_guard_state == stack_guard_unused) {
1815     low_addr =  stack_base() - stack_size();
1816   } else {
1817     low_addr = stack_yellow_zone_base();
1818   }
1819   return cur_sp > low_addr ? cur_sp - low_addr : 0;
1820 }
1821 
1822 // A thread used for Compilation.
1823 class CompilerThread : public JavaThread {
1824   friend class VMStructs;


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1784   Thread* thread = ThreadLocalStorage::thread();
1785   assert(thread != NULL && thread->is_Java_thread(), "just checking");
1786   return (JavaThread*)thread;
1787 }
1788 
1789 inline CompilerThread* JavaThread::as_CompilerThread() {
1790   assert(is_Compiler_thread(), "just checking");
1791   return (CompilerThread*)this;
1792 }
1793 
1794 inline bool JavaThread::stack_guard_zone_unused() {
1795   return _stack_guard_state == stack_guard_unused;
1796 }
1797 
1798 inline bool JavaThread::stack_yellow_zone_disabled() {
1799   return _stack_guard_state == stack_guard_yellow_disabled;
1800 }
1801 
1802 inline bool JavaThread::stack_yellow_zone_enabled() {
1803 #ifdef ASSERT
1804   if (os::uses_stack_guard_pages() &&
1805       !(DisablePrimordialThreadGuardPages && os::is_primordial_thread())) {
1806     assert(_stack_guard_state != stack_guard_unused, "guard pages must be in use");
1807   }
1808 #endif
1809     return _stack_guard_state == stack_guard_enabled;
1810 }
1811 
1812 inline size_t JavaThread::stack_available(address cur_sp) {
1813   // This code assumes java stacks grow down
1814   address low_addr; // Limit on the address for deepest stack depth
1815   if ( _stack_guard_state == stack_guard_unused) {
1816     low_addr =  stack_base() - stack_size();
1817   } else {
1818     low_addr = stack_yellow_zone_base();
1819   }
1820   return cur_sp > low_addr ? cur_sp - low_addr : 0;
1821 }
1822 
1823 // A thread used for Compilation.
1824 class CompilerThread : public JavaThread {
1825   friend class VMStructs;


< prev index next >