25 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP |
25 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP |
26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP |
26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP |
27 |
27 |
28 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE |
28 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE |
29 |
29 |
|
30 #include "runtime/atomic.inline.hpp" |
30 #include "runtime/thread.hpp" |
31 #include "runtime/thread.hpp" |
31 #ifdef TARGET_OS_FAMILY_linux |
32 #ifdef TARGET_OS_FAMILY_linux |
32 # include "thread_linux.inline.hpp" |
33 # include "thread_linux.inline.hpp" |
33 #endif |
34 #endif |
34 #ifdef TARGET_OS_FAMILY_solaris |
35 #ifdef TARGET_OS_FAMILY_solaris |
44 # include "thread_bsd.inline.hpp" |
45 # include "thread_bsd.inline.hpp" |
45 #endif |
46 #endif |
46 |
47 |
47 #undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE |
48 #undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE |
48 |
49 |
|
50 inline void Thread::set_suspend_flag(SuspendFlags f) { |
|
51 assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); |
|
52 uint32_t flags; |
|
53 do { |
|
54 flags = _suspend_flags; |
|
55 } |
|
56 while (Atomic::cmpxchg((jint)(flags | f), |
|
57 (volatile jint*)&_suspend_flags, |
|
58 (jint)flags) != (jint)flags); |
|
59 } |
|
60 inline void Thread::clear_suspend_flag(SuspendFlags f) { |
|
61 assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); |
|
62 uint32_t flags; |
|
63 do { |
|
64 flags = _suspend_flags; |
|
65 } |
|
66 while (Atomic::cmpxchg((jint)(flags & ~f), |
|
67 (volatile jint*)&_suspend_flags, |
|
68 (jint)flags) != (jint)flags); |
|
69 } |
|
70 |
|
71 inline void Thread::set_has_async_exception() { |
|
72 set_suspend_flag(_has_async_exception); |
|
73 } |
|
74 inline void Thread::clear_has_async_exception() { |
|
75 clear_suspend_flag(_has_async_exception); |
|
76 } |
|
77 inline void Thread::set_critical_native_unlock() { |
|
78 set_suspend_flag(_critical_native_unlock); |
|
79 } |
|
80 inline void Thread::clear_critical_native_unlock() { |
|
81 clear_suspend_flag(_critical_native_unlock); |
|
82 } |
|
83 |
49 inline jlong Thread::cooked_allocated_bytes() { |
84 inline jlong Thread::cooked_allocated_bytes() { |
50 jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes); |
85 jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes); |
51 if (UseTLAB) { |
86 if (UseTLAB) { |
52 size_t used_bytes = tlab().used_bytes(); |
87 size_t used_bytes = tlab().used_bytes(); |
53 if ((ssize_t)used_bytes > 0) { |
88 if ((ssize_t)used_bytes > 0) { |
55 // that the result of the add is <= the instantaneous value. |
90 // that the result of the add is <= the instantaneous value. |
56 return allocated_bytes + used_bytes; |
91 return allocated_bytes + used_bytes; |
57 } |
92 } |
58 } |
93 } |
59 return allocated_bytes; |
94 return allocated_bytes; |
|
95 } |
|
96 |
|
97 inline void JavaThread::set_ext_suspended() { |
|
98 set_suspend_flag (_ext_suspended); |
|
99 } |
|
100 inline void JavaThread::clear_ext_suspended() { |
|
101 clear_suspend_flag(_ext_suspended); |
|
102 } |
|
103 |
|
104 inline void JavaThread::set_external_suspend() { |
|
105 set_suspend_flag(_external_suspend); |
|
106 } |
|
107 inline void JavaThread::clear_external_suspend() { |
|
108 clear_suspend_flag(_external_suspend); |
|
109 } |
|
110 |
|
111 inline void JavaThread::set_deopt_suspend() { |
|
112 set_suspend_flag(_deopt_suspend); |
|
113 } |
|
114 inline void JavaThread::clear_deopt_suspend() { |
|
115 clear_suspend_flag(_deopt_suspend); |
|
116 } |
|
117 |
|
118 inline void JavaThread::set_pending_async_exception(oop e) { |
|
119 _pending_async_exception = e; |
|
120 _special_runtime_exit_condition = _async_exception; |
|
121 set_has_async_exception(); |
60 } |
122 } |
61 |
123 |
62 #ifdef PPC64 |
124 #ifdef PPC64 |
63 inline JavaThreadState JavaThread::thread_state() const { |
125 inline JavaThreadState JavaThread::thread_state() const { |
64 return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state); |
126 return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state); |