1 /*
2 * Copyright (c) 2017, 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 *
60 }
61
62 inline void ThreadsSMRSupport::inc_tlh_cnt() {
63 Atomic::inc(&_tlh_cnt);
64 }
65
66 inline void ThreadsSMRSupport::update_tlh_time_max(uint new_value) {
67 while (true) {
68 uint cur_value = _tlh_time_max;
69 if (new_value <= cur_value) {
70 // No need to update max value so we're done.
71 break;
72 }
73 if (Atomic::cmpxchg(new_value, &_tlh_time_max, cur_value) == cur_value) {
74 // Updated max value so we're done. Otherwise try it all again.
75 break;
76 }
77 }
78 }
79
80
81 inline ThreadsList* ThreadsListSetter::list() {
82 ThreadsList *ret = _target->get_threads_hazard_ptr();
83 assert(ret != NULL, "hazard ptr should be set");
84 assert(!Thread::is_hazard_ptr_tagged(ret), "hazard ptr should be validated");
85 return ret;
86 }
87
88 inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
89 return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
90 }
91
92 inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
93 MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
94 return is_a_protected_JavaThread(thread);
95 }
96
97 inline void ThreadsSMRSupport::update_tlh_stats(uint millis) {
98 ThreadsSMRSupport::inc_tlh_cnt();
99 ThreadsSMRSupport::add_tlh_times(millis);
100 ThreadsSMRSupport::update_tlh_time_max(millis);
101 }
102
103 #endif // SHARE_VM_RUNTIME_THREADSMR_INLINE_HPP
|
1 /*
2 * Copyright (c) 2017, 2018, 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 *
60 }
61
62 inline void ThreadsSMRSupport::inc_tlh_cnt() {
63 Atomic::inc(&_tlh_cnt);
64 }
65
66 inline void ThreadsSMRSupport::update_tlh_time_max(uint new_value) {
67 while (true) {
68 uint cur_value = _tlh_time_max;
69 if (new_value <= cur_value) {
70 // No need to update max value so we're done.
71 break;
72 }
73 if (Atomic::cmpxchg(new_value, &_tlh_time_max, cur_value) == cur_value) {
74 // Updated max value so we're done. Otherwise try it all again.
75 break;
76 }
77 }
78 }
79
80 inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
81 return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
82 }
83
84 inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
85 MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
86 return is_a_protected_JavaThread(thread);
87 }
88
89 inline void ThreadsSMRSupport::update_tlh_stats(uint millis) {
90 ThreadsSMRSupport::inc_tlh_cnt();
91 ThreadsSMRSupport::add_tlh_times(millis);
92 ThreadsSMRSupport::update_tlh_time_max(millis);
93 }
94
95 #endif // SHARE_VM_RUNTIME_THREADSMR_INLINE_HPP
|