annotate src/hotspot/share/runtime/threadSMR.inline.hpp @ 54526:ee29b516a36a

revert changes
author jlaskey
date Wed, 23 Jan 2019 16:09:20 -0400
parents a87f2e7a527c
children 1126f0607c70
rev   line source
dcubed@48321 1 /*
coleenp@54304 2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
dcubed@48321 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dcubed@48321 4 *
dcubed@48321 5 * This code is free software; you can redistribute it and/or modify it
dcubed@48321 6 * under the terms of the GNU General Public License version 2 only, as
dcubed@48321 7 * published by the Free Software Foundation.
dcubed@48321 8 *
dcubed@48321 9 * This code is distributed in the hope that it will be useful, but WITHOUT
dcubed@48321 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dcubed@48321 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dcubed@48321 12 * version 2 for more details (a copy is included in the LICENSE file that
dcubed@48321 13 * accompanied this code).
dcubed@48321 14 *
dcubed@48321 15 * You should have received a copy of the GNU General Public License version
dcubed@48321 16 * 2 along with this work; if not, write to the Free Software Foundation,
dcubed@48321 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dcubed@48321 18 *
dcubed@48321 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dcubed@48321 20 * or visit www.oracle.com if you need additional information or have any
dcubed@48321 21 * questions.
dcubed@48321 22 *
dcubed@48321 23 */
dcubed@48321 24
coleenp@54304 25 #ifndef SHARE_RUNTIME_THREADSMR_INLINE_HPP
coleenp@54304 26 #define SHARE_RUNTIME_THREADSMR_INLINE_HPP
dcubed@48321 27
dcubed@48321 28 #include "runtime/atomic.hpp"
dcubed@48321 29 #include "runtime/prefetch.inline.hpp"
dcubed@48321 30 #include "runtime/thread.inline.hpp"
dcubed@48321 31 #include "runtime/threadSMR.hpp"
dcubed@48321 32
dcubed@48321 33 // Devirtualize known thread closure types.
dcubed@48321 34 template <class T>
dcubed@48321 35 inline void ThreadsList::threads_do_dispatch(T *cl, JavaThread *const thread) const {
dcubed@48321 36 cl->T::do_thread(thread);
dcubed@48321 37 }
dcubed@48321 38
dcubed@48321 39 template <>
dcubed@48321 40 inline void ThreadsList::threads_do_dispatch<ThreadClosure>(ThreadClosure *cl, JavaThread *const thread) const {
dcubed@48321 41 cl->do_thread(thread);
dcubed@48321 42 }
dcubed@48321 43
dcubed@48321 44 template <class T>
dcubed@48321 45 inline void ThreadsList::threads_do(T *cl) const {
dcubed@48321 46 const intx scan_interval = PrefetchScanIntervalInBytes;
dcubed@48321 47 JavaThread *const *const end = _threads + _length;
dcubed@48321 48 for (JavaThread *const *current_p = _threads; current_p != end; current_p++) {
dcubed@48321 49 Prefetch::read((void*)current_p, scan_interval);
dcubed@48321 50 JavaThread *const current = *current_p;
dcubed@48321 51 threads_do_dispatch(cl, current);
dcubed@48321 52 }
dcubed@48321 53 }
dcubed@48321 54
dcubed@48552 55 // These three inlines are private to ThreadsSMRSupport, but
dcubed@48653 56 // they are called by public inline update_tlh_stats() below:
dcubed@48552 57
dcubed@48653 58 inline void ThreadsSMRSupport::add_tlh_times(uint add_value) {
dcubed@48653 59 Atomic::add(add_value, &_tlh_times);
dcubed@48552 60 }
dcubed@48552 61
dcubed@48653 62 inline void ThreadsSMRSupport::inc_tlh_cnt() {
dcubed@48653 63 Atomic::inc(&_tlh_cnt);
dcubed@48552 64 }
dcubed@48552 65
dcubed@48653 66 inline void ThreadsSMRSupport::update_tlh_time_max(uint new_value) {
dcubed@48552 67 while (true) {
dcubed@48653 68 uint cur_value = _tlh_time_max;
dcubed@48552 69 if (new_value <= cur_value) {
dcubed@48552 70 // No need to update max value so we're done.
dcubed@48552 71 break;
dcubed@48552 72 }
dcubed@48653 73 if (Atomic::cmpxchg(new_value, &_tlh_time_max, cur_value) == cur_value) {
dcubed@48552 74 // Updated max value so we're done. Otherwise try it all again.
dcubed@48552 75 break;
dcubed@48552 76 }
dcubed@48552 77 }
dcubed@48552 78 }
dcubed@48552 79
dcubed@48653 80 inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
dcubed@48653 81 return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
dcubed@48552 82 }
dcubed@48552 83
dcubed@48552 84 inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
dcubed@48552 85 MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
dcubed@48552 86 return is_a_protected_JavaThread(thread);
dcubed@48552 87 }
dcubed@48552 88
dcubed@48653 89 inline void ThreadsSMRSupport::update_tlh_stats(uint millis) {
dcubed@48653 90 ThreadsSMRSupport::inc_tlh_cnt();
dcubed@48653 91 ThreadsSMRSupport::add_tlh_times(millis);
dcubed@48653 92 ThreadsSMRSupport::update_tlh_time_max(millis);
dcubed@48552 93 }
dcubed@48552 94
coleenp@54304 95 #endif // SHARE_RUNTIME_THREADSMR_INLINE_HPP