1 /*
2 * Copyright (c) 2012, 2014, 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 *
128 }
129
130 inline void JavaThread::set_thread_state(JavaThreadState s) {
131 OrderAccess::release_store((volatile jint*)&_thread_state, (jint)s);
132 }
133 #endif
134
135 inline void JavaThread::set_done_attaching_via_jni() {
136 _jni_attach_state = _attached_via_jni;
137 OrderAccess::fence();
138 }
139
140 inline bool JavaThread::stack_guard_zone_unused() {
141 return _stack_guard_state == stack_guard_unused;
142 }
143
144 inline bool JavaThread::stack_yellow_zone_disabled() {
145 return _stack_guard_state == stack_guard_yellow_disabled;
146 }
147
148 inline size_t JavaThread::stack_available(address cur_sp) {
149 // This code assumes java stacks grow down
150 address low_addr; // Limit on the address for deepest stack depth
151 if (_stack_guard_state == stack_guard_unused) {
152 low_addr = stack_base() - stack_size();
153 } else {
154 low_addr = stack_yellow_zone_base();
155 }
156 return cur_sp > low_addr ? cur_sp - low_addr : 0;
157 }
158
159 inline bool JavaThread::stack_yellow_zone_enabled() {
160 #ifdef ASSERT
161 if (os::uses_stack_guard_pages()) {
162 assert(_stack_guard_state != stack_guard_unused, "guard pages must be in use");
163 }
164 #endif
165 return _stack_guard_state == stack_guard_enabled;
166 }
167
168 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
|
1 /*
2 * Copyright (c) 2012, 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 *
128 }
129
130 inline void JavaThread::set_thread_state(JavaThreadState s) {
131 OrderAccess::release_store((volatile jint*)&_thread_state, (jint)s);
132 }
133 #endif
134
135 inline void JavaThread::set_done_attaching_via_jni() {
136 _jni_attach_state = _attached_via_jni;
137 OrderAccess::fence();
138 }
139
140 inline bool JavaThread::stack_guard_zone_unused() {
141 return _stack_guard_state == stack_guard_unused;
142 }
143
144 inline bool JavaThread::stack_yellow_zone_disabled() {
145 return _stack_guard_state == stack_guard_yellow_disabled;
146 }
147
148 inline bool JavaThread::stack_reserved_zone_disabled() {
149 return _stack_guard_state == stack_guard_reserved_disabled;
150 }
151
152 inline size_t JavaThread::stack_available(address cur_sp) {
153 // This code assumes java stacks grow down
154 address low_addr; // Limit on the address for deepest stack depth
155 if (_stack_guard_state == stack_guard_unused) {
156 low_addr = stack_base() - stack_size();
157 } else {
158 low_addr = stack_yellow_zone_base();
159 }
160 return cur_sp > low_addr ? cur_sp - low_addr : 0;
161 }
162
163 inline bool JavaThread::stack_guards_enabled() {
164 #ifdef ASSERT
165 if (os::uses_stack_guard_pages()) {
166 assert(_stack_guard_state != stack_guard_unused, "guard pages must be in use");
167 }
168 #endif
169 return _stack_guard_state == stack_guard_enabled;
170 }
171
172 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
|