1 /*
2 * Copyright (c) 2012, 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 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP
26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
27
28 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
29
30 #include "runtime/atomic.inline.hpp"
31 #include "runtime/thread.hpp"
32 #ifdef TARGET_OS_FAMILY_linux
33 # include "thread_linux.inline.hpp"
34 #endif
35 #ifdef TARGET_OS_FAMILY_solaris
36 # include "thread_solaris.inline.hpp"
37 #endif
38 #ifdef TARGET_OS_FAMILY_windows
39 # include "thread_windows.inline.hpp"
40 #endif
41 #ifdef TARGET_OS_FAMILY_aix
42 # include "thread_aix.inline.hpp"
43 #endif
44 #ifdef TARGET_OS_FAMILY_bsd
45 # include "thread_bsd.inline.hpp"
46 #endif
47
48 #undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
49
50 inline void Thread::set_suspend_flag(SuspendFlags f) {
119 _pending_async_exception = e;
120 _special_runtime_exit_condition = _async_exception;
121 set_has_async_exception();
122 }
123
124 #ifdef PPC64
125 inline JavaThreadState JavaThread::thread_state() const {
126 return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state);
127 }
128
129 inline void JavaThread::set_thread_state(JavaThreadState s) {
130 OrderAccess::release_store((volatile jint*)&_thread_state, (jint)s);
131 }
132 #endif
133
134 inline void JavaThread::set_done_attaching_via_jni() {
135 _jni_attach_state = _attached_via_jni;
136 OrderAccess::fence();
137 }
138
139 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
|
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 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP
26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
27
28 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
29
30 #include "runtime/atomic.inline.hpp"
31 #include "runtime/os.inline.hpp"
32 #include "runtime/thread.hpp"
33 #ifdef TARGET_OS_FAMILY_linux
34 # include "thread_linux.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "thread_solaris.inline.hpp"
38 #endif
39 #ifdef TARGET_OS_FAMILY_windows
40 # include "thread_windows.inline.hpp"
41 #endif
42 #ifdef TARGET_OS_FAMILY_aix
43 # include "thread_aix.inline.hpp"
44 #endif
45 #ifdef TARGET_OS_FAMILY_bsd
46 # include "thread_bsd.inline.hpp"
47 #endif
48
49 #undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE
50
51 inline void Thread::set_suspend_flag(SuspendFlags f) {
120 _pending_async_exception = e;
121 _special_runtime_exit_condition = _async_exception;
122 set_has_async_exception();
123 }
124
125 #ifdef PPC64
126 inline JavaThreadState JavaThread::thread_state() const {
127 return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state);
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
|