hotspot/src/share/vm/runtime/thread.inline.hpp
author jmasa
Sun, 19 Oct 2014 20:23:12 -0700
changeset 29870 ea8305ce32fa
parent 29186 d5e61d9743aa
child 34633 2a6c7c7b30a7
permissions -rw-r--r--
8059064: Better G1 log caching Reviewed-by: jmasa, ahgross Contributed-by: sangheon.kim@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     1
/*
25468
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     4
 *
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     8
 *
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    13
 * accompanied this code).
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    14
 *
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    18
 *
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    21
 * questions.
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    22
 *
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    23
 */
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    24
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    26
#define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    27
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    28
#define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    29
25351
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    30
#include "runtime/atomic.inline.hpp"
25468
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
    31
#include "runtime/os.inline.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    32
#include "runtime/thread.hpp"
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    33
#ifdef TARGET_OS_FAMILY_linux
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    34
# include "thread_linux.inline.hpp"
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    35
#endif
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    36
#ifdef TARGET_OS_FAMILY_solaris
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    37
# include "thread_solaris.inline.hpp"
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    38
#endif
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    39
#ifdef TARGET_OS_FAMILY_windows
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    40
# include "thread_windows.inline.hpp"
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    41
#endif
22827
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
    42
#ifdef TARGET_OS_FAMILY_aix
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
    43
# include "thread_aix.inline.hpp"
07d991d45a51 8023033: PPC64 (part 13): basic changes for AIX
goetz
parents: 14583
diff changeset
    44
#endif
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    45
#ifdef TARGET_OS_FAMILY_bsd
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    46
# include "thread_bsd.inline.hpp"
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    47
#endif
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    48
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    49
#undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
    50
25351
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    51
inline void Thread::set_suspend_flag(SuspendFlags f) {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    52
  assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    53
  uint32_t flags;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    54
  do {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    55
    flags = _suspend_flags;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    56
  }
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    57
  while (Atomic::cmpxchg((jint)(flags | f),
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    58
                         (volatile jint*)&_suspend_flags,
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    59
                         (jint)flags) != (jint)flags);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    60
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    61
inline void Thread::clear_suspend_flag(SuspendFlags f) {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    62
  assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    63
  uint32_t flags;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    64
  do {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    65
    flags = _suspend_flags;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    66
  }
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    67
  while (Atomic::cmpxchg((jint)(flags & ~f),
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    68
                         (volatile jint*)&_suspend_flags,
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    69
                         (jint)flags) != (jint)flags);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    70
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    71
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    72
inline void Thread::set_has_async_exception() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    73
  set_suspend_flag(_has_async_exception);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    74
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    75
inline void Thread::clear_has_async_exception() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    76
  clear_suspend_flag(_has_async_exception);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    77
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    78
inline void Thread::set_critical_native_unlock() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    79
  set_suspend_flag(_critical_native_unlock);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    80
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    81
inline void Thread::clear_critical_native_unlock() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    82
  clear_suspend_flag(_critical_native_unlock);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    83
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    84
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    85
inline jlong Thread::cooked_allocated_bytes() {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    86
  jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes);
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    87
  if (UseTLAB) {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    88
    size_t used_bytes = tlab().used_bytes();
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    89
    if ((ssize_t)used_bytes > 0) {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    90
      // More-or-less valid tlab. The load_acquire above should ensure
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    91
      // that the result of the add is <= the instantaneous value.
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    92
      return allocated_bytes + used_bytes;
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    93
    }
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    94
  }
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    95
  return allocated_bytes;
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    96
}
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
    97
25351
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    98
inline void JavaThread::set_ext_suspended() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
    99
  set_suspend_flag (_ext_suspended);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   100
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   101
inline void JavaThread::clear_ext_suspended() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   102
  clear_suspend_flag(_ext_suspended);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   103
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   104
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   105
inline void JavaThread::set_external_suspend() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   106
  set_suspend_flag(_external_suspend);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   107
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   108
inline void JavaThread::clear_external_suspend() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   109
  clear_suspend_flag(_external_suspend);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   110
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   111
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   112
inline void JavaThread::set_deopt_suspend() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   113
  set_suspend_flag(_deopt_suspend);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   114
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   115
inline void JavaThread::clear_deopt_suspend() {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   116
  clear_suspend_flag(_deopt_suspend);
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   117
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   118
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   119
inline void JavaThread::set_pending_async_exception(oop e) {
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   120
  _pending_async_exception = e;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   121
  _special_runtime_exit_condition = _async_exception;
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   122
  set_has_async_exception();
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   123
}
7c198a690050 8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents: 24351
diff changeset
   124
29186
d5e61d9743aa 8069593: Changes to JavaThread::_thread_state must use acquire and release
aph
parents: 25468
diff changeset
   125
#if defined(PPC64) || defined (AARCH64)
24351
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   126
inline JavaThreadState JavaThread::thread_state() const    {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   127
  return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state);
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   128
}
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   129
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   130
inline void JavaThread::set_thread_state(JavaThreadState s) {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   131
  OrderAccess::release_store((volatile jint*)&_thread_state, (jint)s);
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   132
}
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   133
#endif
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   134
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   135
inline void JavaThread::set_done_attaching_via_jni() {
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   136
  _jni_attach_state = _attached_via_jni;
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   137
  OrderAccess::fence();
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   138
}
61b33cc6d3cf 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 22827
diff changeset
   139
25468
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   140
inline bool JavaThread::stack_guard_zone_unused() {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   141
  return _stack_guard_state == stack_guard_unused;
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   142
}
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   143
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   144
inline bool JavaThread::stack_yellow_zone_disabled() {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   145
  return _stack_guard_state == stack_guard_yellow_disabled;
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   146
}
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   147
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   148
inline size_t JavaThread::stack_available(address cur_sp) {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   149
  // This code assumes java stacks grow down
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   150
  address low_addr; // Limit on the address for deepest stack depth
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   151
  if (_stack_guard_state == stack_guard_unused) {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   152
    low_addr =  stack_base() - stack_size();
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   153
  } else {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   154
    low_addr = stack_yellow_zone_base();
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   155
  }
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   156
  return cur_sp > low_addr ? cur_sp - low_addr : 0;
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   157
}
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   158
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   159
inline bool JavaThread::stack_yellow_zone_enabled() {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   160
#ifdef ASSERT
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   161
  if (os::uses_stack_guard_pages()) {
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   162
    assert(_stack_guard_state != stack_guard_unused, "guard pages must be in use");
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   163
  }
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   164
#endif
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   165
  return _stack_guard_state == stack_guard_enabled;
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   166
}
5331df506290 8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents: 25351
diff changeset
   167
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
diff changeset
   168
#endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP