< prev index next >

src/hotspot/share/runtime/thread.inline.hpp

Print this page

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

115 inline void JavaThread::clear_trace_flag() {
116   clear_suspend_flag(_trace_flag);
117 }
118 inline void JavaThread::set_obj_deopt_flag() {
119   set_suspend_flag(_obj_deopt);
120 }
121 inline void JavaThread::clear_obj_deopt_flag() {
122   clear_suspend_flag(_obj_deopt);
123 }
124 
125 inline void JavaThread::set_pending_async_exception(oop e) {
126   _pending_async_exception = e;
127   set_async_exception_condition(_async_exception);
128   // Set _suspend_flags too so we save a comparison in the transition from native to Java
129   // in the native wrappers. It will be cleared in check_and_handle_async_exceptions()
130   // when we actually install the exception.
131   set_suspend_flag(_has_async_exception);
132 }
133 
134 inline JavaThreadState JavaThread::thread_state() const    {
135 #if defined(PPC64) || defined (AARCH64)
136   // Use membars when accessing volatile _thread_state. See
137   // Threads::create_vm() for size checks.
138   return (JavaThreadState) Atomic::load_acquire((volatile jint*)&_thread_state);
139 #else
140   return _thread_state;
141 #endif
142 }
143 
144 inline void JavaThread::set_thread_state(JavaThreadState s) {
145   assert(current_or_null() == NULL || current_or_null() == this,
146          "state change should only be called by the current thread");
147 #if defined(PPC64) || defined (AARCH64)
148   // Use membars when accessing volatile _thread_state. See
149   // Threads::create_vm() for size checks.
150   Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
151 #else
152   _thread_state = s;
153 #endif
154 }
155 
156 inline void JavaThread::set_thread_state_fence(JavaThreadState s) {
157   set_thread_state(s);
158   OrderAccess::fence();
159 }
160 
161 ThreadSafepointState* JavaThread::safepoint_state() const  {
162   return _safepoint_state;
163 }
164 
165 void JavaThread::set_safepoint_state(ThreadSafepointState *state) {
166   _safepoint_state = state;
167 }

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

115 inline void JavaThread::clear_trace_flag() {
116   clear_suspend_flag(_trace_flag);
117 }
118 inline void JavaThread::set_obj_deopt_flag() {
119   set_suspend_flag(_obj_deopt);
120 }
121 inline void JavaThread::clear_obj_deopt_flag() {
122   clear_suspend_flag(_obj_deopt);
123 }
124 
125 inline void JavaThread::set_pending_async_exception(oop e) {
126   _pending_async_exception = e;
127   set_async_exception_condition(_async_exception);
128   // Set _suspend_flags too so we save a comparison in the transition from native to Java
129   // in the native wrappers. It will be cleared in check_and_handle_async_exceptions()
130   // when we actually install the exception.
131   set_suspend_flag(_has_async_exception);
132 }
133 
134 inline JavaThreadState JavaThread::thread_state() const    {
135 #if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
136   // Use membars when accessing volatile _thread_state. See
137   // Threads::create_vm() for size checks.
138   return (JavaThreadState) Atomic::load_acquire((volatile jint*)&_thread_state);
139 #else
140   return _thread_state;
141 #endif
142 }
143 
144 inline void JavaThread::set_thread_state(JavaThreadState s) {
145   assert(current_or_null() == NULL || current_or_null() == this,
146          "state change should only be called by the current thread");
147 #if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
148   // Use membars when accessing volatile _thread_state. See
149   // Threads::create_vm() for size checks.
150   Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
151 #else
152   _thread_state = s;
153 #endif
154 }
155 
156 inline void JavaThread::set_thread_state_fence(JavaThreadState s) {
157   set_thread_state(s);
158   OrderAccess::fence();
159 }
160 
161 ThreadSafepointState* JavaThread::safepoint_state() const  {
162   return _safepoint_state;
163 }
164 
165 void JavaThread::set_safepoint_state(ThreadSafepointState *state) {
166   _safepoint_state = state;
167 }
< prev index next >