1 /*
2 * Copyright (c) 2017, 2019, 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 *
112 static uint64_t _java_thread_list_free_cnt;
113 static uint _java_thread_list_max;
114 static uint _nested_thread_list_max;
115 static volatile uint _tlh_cnt;
116 static volatile uint _tlh_time_max;
117 static volatile uint _tlh_times;
118 static ThreadsList* _to_delete_list;
119 static uint _to_delete_list_cnt;
120 static uint _to_delete_list_max;
121
122 static ThreadsList *acquire_stable_list_fast_path(Thread *self);
123 static ThreadsList *acquire_stable_list_nested_path(Thread *self);
124 static void add_deleted_thread_times(uint add_value);
125 static void add_tlh_times(uint add_value);
126 static void clear_delete_notify();
127 static bool delete_notify();
128 static void free_list(ThreadsList* threads);
129 static void inc_deleted_thread_cnt();
130 static void inc_java_thread_list_alloc_cnt();
131 static void inc_tlh_cnt();
132 static bool is_a_protected_JavaThread(JavaThread *thread);
133 static void release_stable_list_wake_up(bool is_nested);
134 static void set_delete_notify();
135 static void threads_do(ThreadClosure *tc);
136 static void threads_do(ThreadClosure *tc, ThreadsList *list);
137 static void update_deleted_thread_time_max(uint new_value);
138 static void update_java_thread_list_max(uint new_value);
139 static void update_tlh_time_max(uint new_value);
140 static void verify_hazard_ptr_scanned(Thread *self, ThreadsList *threads);
141 static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
142
143 public:
144 static void add_thread(JavaThread *thread);
145 static ThreadsList* get_java_thread_list();
146 static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
147 static bool is_bootstrap_list(ThreadsList* list);
148 static void remove_thread(JavaThread *thread);
149 static void smr_delete(JavaThread *thread);
150 static void update_tlh_stats(uint millis);
151
152 // Logging and printing support:
153 static void log_statistics();
154 static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
155 static void print_info_on(outputStream* st);
156 static void print_info_on(const Thread* thread, outputStream* st);
157 };
158
159 // A fast list of JavaThreads.
160 //
161 class ThreadsList : public CHeapObj<mtThread> {
162 friend class VMStructs;
163 friend class SafeThreadsListPtr; // for {dec,inc}_nested_handle_cnt() access
164 friend class ThreadsSMRSupport; // for _nested_handle_cnt, {add,remove}_thread(), {,set_}next_list() access
165
|
1 /*
2 * Copyright (c) 2017, 2020, 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 *
112 static uint64_t _java_thread_list_free_cnt;
113 static uint _java_thread_list_max;
114 static uint _nested_thread_list_max;
115 static volatile uint _tlh_cnt;
116 static volatile uint _tlh_time_max;
117 static volatile uint _tlh_times;
118 static ThreadsList* _to_delete_list;
119 static uint _to_delete_list_cnt;
120 static uint _to_delete_list_max;
121
122 static ThreadsList *acquire_stable_list_fast_path(Thread *self);
123 static ThreadsList *acquire_stable_list_nested_path(Thread *self);
124 static void add_deleted_thread_times(uint add_value);
125 static void add_tlh_times(uint add_value);
126 static void clear_delete_notify();
127 static bool delete_notify();
128 static void free_list(ThreadsList* threads);
129 static void inc_deleted_thread_cnt();
130 static void inc_java_thread_list_alloc_cnt();
131 static void inc_tlh_cnt();
132 static void release_stable_list_wake_up(bool is_nested);
133 static void set_delete_notify();
134 static void threads_do(ThreadClosure *tc);
135 static void threads_do(ThreadClosure *tc, ThreadsList *list);
136 static void update_deleted_thread_time_max(uint new_value);
137 static void update_java_thread_list_max(uint new_value);
138 static void update_tlh_time_max(uint new_value);
139 static void verify_hazard_ptr_scanned(Thread *self, ThreadsList *threads);
140 static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
141
142 public:
143 static void add_thread(JavaThread *thread);
144 static ThreadsList* get_java_thread_list();
145 static bool is_a_protected_JavaThread(JavaThread *thread);
146 static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
147 static bool is_bootstrap_list(ThreadsList* list);
148 static void remove_thread(JavaThread *thread);
149 static void smr_delete(JavaThread *thread);
150 static void update_tlh_stats(uint millis);
151
152 // Logging and printing support:
153 static void log_statistics();
154 static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
155 static void print_info_on(outputStream* st);
156 static void print_info_on(const Thread* thread, outputStream* st);
157 };
158
159 // A fast list of JavaThreads.
160 //
161 class ThreadsList : public CHeapObj<mtThread> {
162 friend class VMStructs;
163 friend class SafeThreadsListPtr; // for {dec,inc}_nested_handle_cnt() access
164 friend class ThreadsSMRSupport; // for _nested_handle_cnt, {add,remove}_thread(), {,set_}next_list() access
165
|