author | kbarrett |
Tue, 27 Feb 2018 18:17:57 -0500 | |
changeset 49177 | eebf559c9e0d |
parent 48382 | 0997d6959851 |
child 49192 | 6734eeef4283 |
permissions | -rw-r--r-- |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
1 |
/* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
4 |
* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
8 |
* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
13 |
* accompanied this code). |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
14 |
* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
18 |
* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
21 |
* questions. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
22 |
* |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
23 |
*/ |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
24 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
26 |
#include "logging/logStream.hpp" |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
27 |
#include "memory/allocation.inline.hpp" |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
28 |
#include "runtime/thread.inline.hpp" |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
29 |
#include "runtime/threadSMR.inline.hpp" |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
30 |
#include "services/threadService.hpp" |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
31 |
#include "utilities/globalDefinitions.hpp" |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
32 |
#include "utilities/resourceHash.hpp" |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
33 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
34 |
Monitor* ThreadsSMRSupport::_delete_lock = |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
35 |
new Monitor(Monitor::special, "Thread_SMR_delete_lock", |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
36 |
false /* allow_vm_block */, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
37 |
Monitor::_safepoint_check_never); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
38 |
// The '_cnt', '_max' and '_times" fields are enabled via |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
39 |
// -XX:+EnableThreadSMRStatistics: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
40 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
41 |
// # of parallel threads in _delete_lock->wait(). |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
42 |
// Impl note: Hard to imagine > 64K waiting threads so this could be 16-bit, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
43 |
// but there is no nice 16-bit _FORMAT support. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
44 |
uint ThreadsSMRSupport::_delete_lock_wait_cnt = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
45 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
46 |
// Max # of parallel threads in _delete_lock->wait(). |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
47 |
// Impl note: See _delete_lock_wait_cnt note. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
48 |
uint ThreadsSMRSupport::_delete_lock_wait_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
49 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
50 |
// Flag to indicate when an _delete_lock->notify() is needed. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
51 |
// Impl note: See _delete_lock_wait_cnt note. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
52 |
volatile uint ThreadsSMRSupport::_delete_notify = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
53 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
54 |
// # of threads deleted over VM lifetime. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
55 |
// Impl note: Atomically incremented over VM lifetime so use unsigned for more |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
56 |
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
57 |
// isn't available everywhere (or is it?). |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
58 |
volatile uint ThreadsSMRSupport::_deleted_thread_cnt = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
59 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
60 |
// Max time in millis to delete a thread. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
61 |
// Impl note: 16-bit might be too small on an overloaded machine. Use |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
62 |
// unsigned since this is a time value. Set via Atomic::cmpxchg() in a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
63 |
// loop for correctness. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
64 |
volatile uint ThreadsSMRSupport::_deleted_thread_time_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
65 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
66 |
// Cumulative time in millis to delete threads. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
67 |
// Impl note: Atomically added to over VM lifetime so use unsigned for more |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
68 |
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
69 |
// isn't available everywhere (or is it?). |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
70 |
volatile uint ThreadsSMRSupport::_deleted_thread_times = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
71 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
72 |
ThreadsList* volatile ThreadsSMRSupport::_java_thread_list = new ThreadsList(0); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
73 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
74 |
// # of ThreadsLists allocated over VM lifetime. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
75 |
// Impl note: We allocate a new ThreadsList for every thread create and |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
76 |
// every thread delete so we need a bigger type than the |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
77 |
// _deleted_thread_cnt field. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
78 |
uint64_t ThreadsSMRSupport::_java_thread_list_alloc_cnt = 1; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
79 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
80 |
// # of ThreadsLists freed over VM lifetime. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
81 |
// Impl note: See _java_thread_list_alloc_cnt note. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
82 |
uint64_t ThreadsSMRSupport::_java_thread_list_free_cnt = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
83 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
84 |
// Max size ThreadsList allocated. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
85 |
// Impl note: Max # of threads alive at one time should fit in unsigned 32-bit. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
86 |
uint ThreadsSMRSupport::_java_thread_list_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
87 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
88 |
// Max # of nested ThreadsLists for a thread. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
89 |
// Impl note: Hard to imagine > 64K nested ThreadsLists so this could be |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
90 |
// 16-bit, but there is no nice 16-bit _FORMAT support. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
91 |
uint ThreadsSMRSupport::_nested_thread_list_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
92 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
93 |
// # of ThreadsListHandles deleted over VM lifetime. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
94 |
// Impl note: Atomically incremented over VM lifetime so use unsigned for |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
95 |
// more range. There will be fewer ThreadsListHandles than threads so |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
96 |
// unsigned 32-bit should be fine. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
97 |
volatile uint ThreadsSMRSupport::_tlh_cnt = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
98 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
99 |
// Max time in millis to delete a ThreadsListHandle. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
100 |
// Impl note: 16-bit might be too small on an overloaded machine. Use |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
101 |
// unsigned since this is a time value. Set via Atomic::cmpxchg() in a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
102 |
// loop for correctness. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
103 |
volatile uint ThreadsSMRSupport::_tlh_time_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
104 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
105 |
// Cumulative time in millis to delete ThreadsListHandles. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
106 |
// Impl note: Atomically added to over VM lifetime so use unsigned for more |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
107 |
// range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
108 |
// isn't available everywhere (or is it?). |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
109 |
volatile uint ThreadsSMRSupport::_tlh_times = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
110 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
111 |
ThreadsList* ThreadsSMRSupport::_to_delete_list = NULL; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
112 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
113 |
// # of parallel ThreadsLists on the to-delete list. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
114 |
// Impl note: Hard to imagine > 64K ThreadsLists needing to be deleted so |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
115 |
// this could be 16-bit, but there is no nice 16-bit _FORMAT support. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
116 |
uint ThreadsSMRSupport::_to_delete_list_cnt = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
117 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
118 |
// Max # of parallel ThreadsLists on the to-delete list. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
119 |
// Impl note: See _to_delete_list_cnt note. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
120 |
uint ThreadsSMRSupport::_to_delete_list_max = 0; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
121 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
122 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
123 |
// 'inline' functions first so the definitions are before first use: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
124 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
125 |
inline void ThreadsSMRSupport::add_deleted_thread_times(uint add_value) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
126 |
Atomic::add(add_value, &_deleted_thread_times); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
127 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
128 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
129 |
inline void ThreadsSMRSupport::inc_deleted_thread_cnt() { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
130 |
Atomic::inc(&_deleted_thread_cnt); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
131 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
132 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
133 |
inline void ThreadsSMRSupport::inc_java_thread_list_alloc_cnt() { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
134 |
_java_thread_list_alloc_cnt++; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
135 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
136 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
137 |
inline void ThreadsSMRSupport::update_deleted_thread_time_max(uint new_value) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
138 |
while (true) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
139 |
uint cur_value = _deleted_thread_time_max; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
140 |
if (new_value <= cur_value) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
141 |
// No need to update max value so we're done. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
142 |
break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
143 |
} |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
144 |
if (Atomic::cmpxchg(new_value, &_deleted_thread_time_max, cur_value) == cur_value) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
145 |
// Updated max value so we're done. Otherwise try it all again. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
146 |
break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
147 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
148 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
149 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
150 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
151 |
inline void ThreadsSMRSupport::update_java_thread_list_max(uint new_value) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
152 |
if (new_value > _java_thread_list_max) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
153 |
_java_thread_list_max = new_value; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
154 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
155 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
156 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
157 |
inline ThreadsList* ThreadsSMRSupport::xchg_java_thread_list(ThreadsList* new_list) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
158 |
return (ThreadsList*)Atomic::xchg(new_list, &_java_thread_list); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
159 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
160 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
161 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
162 |
// Hash table of pointers found by a scan. Used for collecting hazard |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
163 |
// pointers (ThreadsList references). Also used for collecting JavaThreads |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
164 |
// that are indirectly referenced by hazard ptrs. An instance of this |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
165 |
// class only contains one type of pointer. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
166 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
167 |
class ThreadScanHashtable : public CHeapObj<mtThread> { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
168 |
private: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
169 |
static bool ptr_equals(void * const& s1, void * const& s2) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
170 |
return s1 == s2; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
171 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
172 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
173 |
static unsigned int ptr_hash(void * const& s1) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
174 |
// 2654435761 = 2^32 * Phi (golden ratio) |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
175 |
return (unsigned int)(((uint32_t)(uintptr_t)s1) * 2654435761u); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
176 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
177 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
178 |
int _table_size; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
179 |
// ResourceHashtable SIZE is specified at compile time so our |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
180 |
// dynamic _table_size is unused for now; 1031 is the first prime |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
181 |
// after 1024. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
182 |
typedef ResourceHashtable<void *, int, &ThreadScanHashtable::ptr_hash, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
183 |
&ThreadScanHashtable::ptr_equals, 1031, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
184 |
ResourceObj::C_HEAP, mtThread> PtrTable; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
185 |
PtrTable * _ptrs; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
186 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
187 |
public: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
188 |
// ResourceHashtable is passed to various functions and populated in |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
189 |
// different places so we allocate it using C_HEAP to make it immune |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
190 |
// from any ResourceMarks that happen to be in the code paths. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
191 |
ThreadScanHashtable(int table_size) : _table_size(table_size), _ptrs(new (ResourceObj::C_HEAP, mtThread) PtrTable()) {} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
192 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
193 |
~ThreadScanHashtable() { delete _ptrs; } |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
194 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
195 |
bool has_entry(void *pointer) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
196 |
int *val_ptr = _ptrs->get(pointer); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
197 |
return val_ptr != NULL && *val_ptr == 1; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
198 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
199 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
200 |
void add_entry(void *pointer) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
201 |
_ptrs->put(pointer, 1); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
202 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
203 |
}; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
204 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
205 |
// Closure to gather JavaThreads indirectly referenced by hazard ptrs |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
206 |
// (ThreadsList references) into a hash table. This closure handles part 2 |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
207 |
// of the dance - adding all the JavaThreads referenced by the hazard |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
208 |
// pointer (ThreadsList reference) to the hash table. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
209 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
210 |
class AddThreadHazardPointerThreadClosure : public ThreadClosure { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
211 |
private: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
212 |
ThreadScanHashtable *_table; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
213 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
214 |
public: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
215 |
AddThreadHazardPointerThreadClosure(ThreadScanHashtable *table) : _table(table) {} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
216 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
217 |
virtual void do_thread(Thread *thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
218 |
if (!_table->has_entry((void*)thread)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
219 |
// The same JavaThread might be on more than one ThreadsList or |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
220 |
// more than one thread might be using the same ThreadsList. In |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
221 |
// either case, we only need a single entry for a JavaThread. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
222 |
_table->add_entry((void*)thread); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
223 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
224 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
225 |
}; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
226 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
227 |
// Closure to gather JavaThreads indirectly referenced by hazard ptrs |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
228 |
// (ThreadsList references) into a hash table. This closure handles part 1 |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
229 |
// of the dance - hazard ptr chain walking and dispatch to another |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
230 |
// closure. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
231 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
232 |
class ScanHazardPtrGatherProtectedThreadsClosure : public ThreadClosure { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
233 |
private: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
234 |
ThreadScanHashtable *_table; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
235 |
public: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
236 |
ScanHazardPtrGatherProtectedThreadsClosure(ThreadScanHashtable *table) : _table(table) {} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
237 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
238 |
virtual void do_thread(Thread *thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
239 |
assert_locked_or_safepoint(Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
240 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
241 |
if (thread == NULL) return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
242 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
243 |
// This code races with ThreadsSMRSupport::acquire_stable_list() which |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
244 |
// is lock-free so we have to handle some special situations. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
245 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
246 |
ThreadsList *current_list = NULL; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
247 |
while (true) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
248 |
current_list = thread->get_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
249 |
// No hazard ptr so nothing more to do. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
250 |
if (current_list == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
251 |
assert(thread->get_nested_threads_hazard_ptr() == NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
252 |
"cannot have a nested hazard ptr with a NULL regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
253 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
254 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
255 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
256 |
// If the hazard ptr is verified as stable (since it is not tagged), |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
257 |
// then it is safe to use. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
258 |
if (!Thread::is_hazard_ptr_tagged(current_list)) break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
259 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
260 |
// The hazard ptr is tagged as not yet verified as being stable |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
261 |
// so we are racing with acquire_stable_list(). This exchange |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
262 |
// attempts to invalidate the hazard ptr. If we win the race, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
263 |
// then we can ignore this unstable hazard ptr and the other |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
264 |
// thread will retry the attempt to publish a stable hazard ptr. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
265 |
// If we lose the race, then we retry our attempt to look at the |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
266 |
// hazard ptr. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
267 |
if (thread->cmpxchg_threads_hazard_ptr(NULL, current_list) == current_list) return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
268 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
269 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
270 |
// The current JavaThread has a hazard ptr (ThreadsList reference) |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
271 |
// which might be _java_thread_list or it might be an older |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
272 |
// ThreadsList that has been removed but not freed. In either case, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
273 |
// the hazard ptr is protecting all the JavaThreads on that |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
274 |
// ThreadsList. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
275 |
AddThreadHazardPointerThreadClosure add_cl(_table); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
276 |
current_list->threads_do(&add_cl); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
277 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
278 |
// Any NestedThreadsLists are also protecting JavaThreads so |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
279 |
// gather those also; the ThreadsLists may be different. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
280 |
for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
281 |
node != NULL; node = node->next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
282 |
node->t_list()->threads_do(&add_cl); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
283 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
284 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
285 |
}; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
286 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
287 |
// Closure to gather hazard ptrs (ThreadsList references) into a hash table. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
288 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
289 |
class ScanHazardPtrGatherThreadsListClosure : public ThreadClosure { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
290 |
private: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
291 |
ThreadScanHashtable *_table; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
292 |
public: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
293 |
ScanHazardPtrGatherThreadsListClosure(ThreadScanHashtable *table) : _table(table) {} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
294 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
295 |
virtual void do_thread(Thread* thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
296 |
assert_locked_or_safepoint(Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
297 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
298 |
if (thread == NULL) return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
299 |
ThreadsList *threads = thread->get_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
300 |
if (threads == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
301 |
assert(thread->get_nested_threads_hazard_ptr() == NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
302 |
"cannot have a nested hazard ptr with a NULL regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
303 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
304 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
305 |
// In this closure we always ignore the tag that might mark this |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
306 |
// hazard ptr as not yet verified. If we happen to catch an |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
307 |
// unverified hazard ptr that is subsequently discarded (not |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
308 |
// published), then the only side effect is that we might keep a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
309 |
// to-be-deleted ThreadsList alive a little longer. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
310 |
threads = Thread::untag_hazard_ptr(threads); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
311 |
if (!_table->has_entry((void*)threads)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
312 |
_table->add_entry((void*)threads); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
313 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
314 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
315 |
// Any NestedThreadsLists are also protecting JavaThreads so |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
316 |
// gather those also; the ThreadsLists may be different. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
317 |
for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
318 |
node != NULL; node = node->next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
319 |
threads = node->t_list(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
320 |
if (!_table->has_entry((void*)threads)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
321 |
_table->add_entry((void*)threads); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
322 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
323 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
324 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
325 |
}; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
326 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
327 |
// Closure to print JavaThreads that have a hazard ptr (ThreadsList |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
328 |
// reference) that contains an indirect reference to a specific JavaThread. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
329 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
330 |
class ScanHazardPtrPrintMatchingThreadsClosure : public ThreadClosure { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
331 |
private: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
332 |
JavaThread *_thread; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
333 |
public: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
334 |
ScanHazardPtrPrintMatchingThreadsClosure(JavaThread *thread) : _thread(thread) {} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
335 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
336 |
virtual void do_thread(Thread *thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
337 |
assert_locked_or_safepoint(Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
338 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
339 |
if (thread == NULL) return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
340 |
ThreadsList *current_list = thread->get_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
341 |
if (current_list == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
342 |
assert(thread->get_nested_threads_hazard_ptr() == NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
343 |
"cannot have a nested hazard ptr with a NULL regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
344 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
345 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
346 |
// If the hazard ptr is unverified, then ignore it. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
347 |
if (Thread::is_hazard_ptr_tagged(current_list)) return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
348 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
349 |
// The current JavaThread has a hazard ptr (ThreadsList reference) |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
350 |
// which might be _java_thread_list or it might be an older |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
351 |
// ThreadsList that has been removed but not freed. In either case, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
352 |
// the hazard ptr is protecting all the JavaThreads on that |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
353 |
// ThreadsList, but we only care about matching a specific JavaThread. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
354 |
JavaThreadIterator jti(current_list); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
355 |
for (JavaThread *p = jti.first(); p != NULL; p = jti.next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
356 |
if (p == _thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
357 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread1=" INTPTR_FORMAT " has a hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
358 |
break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
359 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
360 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
361 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
362 |
// Any NestedThreadsLists are also protecting JavaThreads so |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
363 |
// check those also; the ThreadsLists may be different. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
364 |
for (NestedThreadsList* node = thread->get_nested_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
365 |
node != NULL; node = node->next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
366 |
JavaThreadIterator jti(node->t_list()); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
367 |
for (JavaThread *p = jti.first(); p != NULL; p = jti.next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
368 |
if (p == _thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
369 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread1=" INTPTR_FORMAT " has a nested hazard pointer for thread2=" INTPTR_FORMAT, os::current_thread_id(), p2i(thread), p2i(_thread)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
370 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
371 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
372 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
373 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
374 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
375 |
}; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
376 |
|
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
377 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
378 |
// 'entries + 1' so we always have at least one entry. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
379 |
ThreadsList::ThreadsList(int entries) : _length(entries), _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtThread)), _next_list(NULL) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
380 |
*(JavaThread**)(_threads + entries) = NULL; // Make sure the extra entry is NULL. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
381 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
382 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
383 |
ThreadsList::~ThreadsList() { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
384 |
FREE_C_HEAP_ARRAY(JavaThread*, _threads); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
385 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
386 |
|
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
387 |
// Add a JavaThread to a ThreadsList. The returned ThreadsList is a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
388 |
// new copy of the specified ThreadsList with the specified JavaThread |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
389 |
// appended to the end. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
390 |
ThreadsList *ThreadsList::add_thread(ThreadsList *list, JavaThread *java_thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
391 |
const uint index = list->_length; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
392 |
const uint new_length = index + 1; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
393 |
const uint head_length = index; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
394 |
ThreadsList *const new_list = new ThreadsList(new_length); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
395 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
396 |
if (head_length > 0) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
397 |
Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length); |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
398 |
} |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
399 |
*(JavaThread**)(new_list->_threads + index) = java_thread; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
400 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
401 |
return new_list; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
402 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
403 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
404 |
int ThreadsList::find_index_of_JavaThread(JavaThread *target) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
405 |
if (target == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
406 |
return -1; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
407 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
408 |
for (uint i = 0; i < length(); i++) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
409 |
if (target == thread_at(i)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
410 |
return (int)i; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
411 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
412 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
413 |
return -1; |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
414 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
415 |
|
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
416 |
JavaThread* ThreadsList::find_JavaThread_from_java_tid(jlong java_tid) const { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
417 |
for (uint i = 0; i < length(); i++) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
418 |
JavaThread* thread = thread_at(i); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
419 |
oop tobj = thread->threadObj(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
420 |
// Ignore the thread if it hasn't run yet, has exited |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
421 |
// or is starting to exit. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
422 |
if (tobj != NULL && !thread->is_exiting() && |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
423 |
java_tid == java_lang_Thread::thread_id(tobj)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
424 |
// found a match |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
425 |
return thread; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
426 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
427 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
428 |
return NULL; |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
429 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
430 |
|
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
431 |
bool ThreadsList::includes(const JavaThread * const p) const { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
432 |
if (p == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
433 |
return false; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
434 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
435 |
for (uint i = 0; i < length(); i++) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
436 |
if (thread_at(i) == p) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
437 |
return true; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
438 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
439 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
440 |
return false; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
441 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
442 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
443 |
// Remove a JavaThread from a ThreadsList. The returned ThreadsList is a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
444 |
// new copy of the specified ThreadsList with the specified JavaThread |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
445 |
// removed. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
446 |
ThreadsList *ThreadsList::remove_thread(ThreadsList* list, JavaThread* java_thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
447 |
assert(list->_length > 0, "sanity"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
448 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
449 |
uint i = (uint)list->find_index_of_JavaThread(java_thread); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
450 |
assert(i < list->_length, "did not find JavaThread on the list"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
451 |
const uint index = i; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
452 |
const uint new_length = list->_length - 1; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
453 |
const uint head_length = index; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
454 |
const uint tail_length = (new_length >= index) ? (new_length - index) : 0; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
455 |
ThreadsList *const new_list = new ThreadsList(new_length); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
456 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
457 |
if (head_length > 0) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
458 |
Copy::disjoint_words((HeapWord*)list->_threads, (HeapWord*)new_list->_threads, head_length); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
459 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
460 |
if (tail_length > 0) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
461 |
Copy::disjoint_words((HeapWord*)list->_threads + index + 1, (HeapWord*)new_list->_threads + index, tail_length); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
462 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
463 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
464 |
return new_list; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
465 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
466 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
467 |
ThreadsListHandle::ThreadsListHandle(Thread *self) : _list(ThreadsSMRSupport::acquire_stable_list(self, /* is_ThreadsListSetter */ false)), _self(self) { |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
468 |
assert(self == Thread::current(), "sanity check"); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
469 |
if (EnableThreadSMRStatistics) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
470 |
_timer.start(); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
471 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
472 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
473 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
474 |
ThreadsListHandle::~ThreadsListHandle() { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
475 |
ThreadsSMRSupport::release_stable_list(_self); |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
476 |
if (EnableThreadSMRStatistics) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
477 |
_timer.stop(); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
478 |
uint millis = (uint)_timer.milliseconds(); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
479 |
ThreadsSMRSupport::update_tlh_stats(millis); |
48105
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
480 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
481 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
482 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
483 |
// Convert an internal thread reference to a JavaThread found on the |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
484 |
// associated ThreadsList. This ThreadsListHandle "protects" the |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
485 |
// returned JavaThread *. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
486 |
// |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
487 |
// If thread_oop_p is not NULL, then the caller wants to use the oop |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
488 |
// after this call so the oop is returned. On success, *jt_pp is set |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
489 |
// to the converted JavaThread * and true is returned. On error, |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
490 |
// returns false. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
491 |
// |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
492 |
bool ThreadsListHandle::cv_internal_thread_to_JavaThread(jobject jthread, |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
493 |
JavaThread ** jt_pp, |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
494 |
oop * thread_oop_p) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
495 |
assert(this->list() != NULL, "must have a ThreadsList"); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
496 |
assert(jt_pp != NULL, "must have a return JavaThread pointer"); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
497 |
// thread_oop_p is optional so no assert() |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
498 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
499 |
// The JVM_* interfaces don't allow a NULL thread parameter; JVM/TI |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
500 |
// allows a NULL thread parameter to signify "current thread" which |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
501 |
// allows us to avoid calling cv_external_thread_to_JavaThread(). |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
502 |
// The JVM_* interfaces have no such leeway. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
503 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
504 |
oop thread_oop = JNIHandles::resolve_non_null(jthread); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
505 |
// Looks like an oop at this point. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
506 |
if (thread_oop_p != NULL) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
507 |
// Return the oop to the caller; the caller may still want |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
508 |
// the oop even if this function returns false. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
509 |
*thread_oop_p = thread_oop; |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
510 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
511 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
512 |
JavaThread *java_thread = java_lang_Thread::thread(thread_oop); |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
513 |
if (java_thread == NULL) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
514 |
// The java.lang.Thread does not contain a JavaThread * so it has |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
515 |
// not yet run or it has died. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
516 |
return false; |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
517 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
518 |
// Looks like a live JavaThread at this point. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
519 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
520 |
if (java_thread != JavaThread::current()) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
521 |
// jthread is not for the current JavaThread so have to verify |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
522 |
// the JavaThread * against the ThreadsList. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
523 |
if (EnableThreadSMRExtraValidityChecks && !includes(java_thread)) { |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
524 |
// Not on the JavaThreads list so it is not alive. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
525 |
return false; |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
526 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
527 |
} |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
528 |
|
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
529 |
// Return a live JavaThread that is "protected" by the |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
530 |
// ThreadsListHandle in the caller. |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
531 |
*jt_pp = java_thread; |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
532 |
return true; |
8d15b1369c7a
8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents:
diff
changeset
|
533 |
} |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
534 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
535 |
ThreadsListSetter::~ThreadsListSetter() { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
536 |
if (_target_needs_release) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
537 |
// The hazard ptr in the target needs to be released. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
538 |
ThreadsSMRSupport::release_stable_list(_target); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
539 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
540 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
541 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
542 |
void ThreadsListSetter::set() { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
543 |
assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
544 |
(void) ThreadsSMRSupport::acquire_stable_list(_target, /* is_ThreadsListSetter */ true); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
545 |
_target_needs_release = true; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
546 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
547 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
548 |
// Acquire a stable ThreadsList. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
549 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
550 |
ThreadsList *ThreadsSMRSupport::acquire_stable_list(Thread *self, bool is_ThreadsListSetter) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
551 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
552 |
// acquire_stable_list_nested_path() will grab the Threads_lock |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
553 |
// so let's make sure the ThreadsListHandle is in a safe place. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
554 |
// ThreadsListSetter cannot make this check on this code path. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
555 |
debug_only(if (!is_ThreadsListSetter && StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);) |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
556 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
557 |
if (self->get_threads_hazard_ptr() == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
558 |
// The typical case is first. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
559 |
return acquire_stable_list_fast_path(self); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
560 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
561 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
562 |
// The nested case is rare. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
563 |
return acquire_stable_list_nested_path(self); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
564 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
565 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
566 |
// Fast path (and lock free) way to acquire a stable ThreadsList. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
567 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
568 |
ThreadsList *ThreadsSMRSupport::acquire_stable_list_fast_path(Thread *self) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
569 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
570 |
assert(self->get_threads_hazard_ptr() == NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
571 |
assert(self->get_nested_threads_hazard_ptr() == NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
572 |
"cannot have a nested hazard ptr with a NULL regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
573 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
574 |
ThreadsList* threads; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
575 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
576 |
// Stable recording of a hazard ptr for SMR. This code does not use |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
577 |
// locks so its use of the _java_thread_list & _threads_hazard_ptr |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
578 |
// fields is racy relative to code that uses those fields with locks. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
579 |
// OrderAccess and Atomic functions are used to deal with those races. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
580 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
581 |
while (true) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
582 |
threads = get_java_thread_list(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
583 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
584 |
// Publish a tagged hazard ptr to denote that the hazard ptr is not |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
585 |
// yet verified as being stable. Due to the fence after the hazard |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
586 |
// ptr write, it will be sequentially consistent w.r.t. the |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
587 |
// sequentially consistent writes of the ThreadsList, even on |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
588 |
// non-multiple copy atomic machines where stores can be observed |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
589 |
// in different order from different observer threads. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
590 |
ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
591 |
self->set_threads_hazard_ptr(unverified_threads); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
592 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
593 |
// If _java_thread_list has changed, we have lost a race with |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
594 |
// Threads::add() or Threads::remove() and have to try again. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
595 |
if (get_java_thread_list() != threads) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
596 |
continue; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
597 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
598 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
599 |
// We try to remove the tag which will verify the hazard ptr as |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
600 |
// being stable. This exchange can race with a scanning thread |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
601 |
// which might invalidate the tagged hazard ptr to keep it from |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
602 |
// being followed to access JavaThread ptrs. If we lose the race, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
603 |
// we simply retry. If we win the race, then the stable hazard |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
604 |
// ptr is officially published. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
605 |
if (self->cmpxchg_threads_hazard_ptr(threads, unverified_threads) == unverified_threads) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
606 |
break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
607 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
608 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
609 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
610 |
// A stable hazard ptr has been published letting other threads know |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
611 |
// that the ThreadsList and the JavaThreads reachable from this list |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
612 |
// are protected and hence they should not be deleted until everyone |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
613 |
// agrees it is safe to do so. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
614 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
615 |
return threads; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
616 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
617 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
618 |
// Acquire a nested stable ThreadsList; this is rare so it uses |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
619 |
// Threads_lock. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
620 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
621 |
ThreadsList *ThreadsSMRSupport::acquire_stable_list_nested_path(Thread *self) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
622 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
623 |
assert(self->get_threads_hazard_ptr() != NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
624 |
"cannot have a NULL regular hazard ptr when acquiring a nested hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
625 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
626 |
// The thread already has a hazard ptr (ThreadsList ref) so we need |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
627 |
// to create a nested ThreadsListHandle with the current ThreadsList |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
628 |
// since it might be different than our current hazard ptr. The need |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
629 |
// for a nested ThreadsListHandle is rare so we do this while holding |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
630 |
// the Threads_lock so we don't race with the scanning code; the code |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
631 |
// is so much simpler this way. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
632 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
633 |
NestedThreadsList* node; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
634 |
{ |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
635 |
// Only grab the Threads_lock if we don't already own it. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
636 |
MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
637 |
node = new NestedThreadsList(get_java_thread_list()); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
638 |
// We insert at the front of the list to match up with the delete |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
639 |
// in release_stable_list(). |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
640 |
node->set_next(self->get_nested_threads_hazard_ptr()); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
641 |
self->set_nested_threads_hazard_ptr(node); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
642 |
if (EnableThreadSMRStatistics) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
643 |
self->inc_nested_threads_hazard_ptr_cnt(); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
644 |
if (self->nested_threads_hazard_ptr_cnt() > _nested_thread_list_max) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
645 |
_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
646 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
647 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
648 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
649 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::acquire_stable_list: add NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list())); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
650 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
651 |
return node->t_list(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
652 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
653 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
654 |
void ThreadsSMRSupport::add_thread(JavaThread *thread){ |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
655 |
ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_java_thread_list(), thread); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
656 |
if (EnableThreadSMRStatistics) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
657 |
ThreadsSMRSupport::inc_java_thread_list_alloc_cnt(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
658 |
ThreadsSMRSupport::update_java_thread_list_max(new_list->length()); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
659 |
} |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
660 |
// Initial _java_thread_list will not generate a "Threads::add" mesg. |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
661 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
662 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
663 |
ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
664 |
ThreadsSMRSupport::free_list(old_list); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
665 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
666 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
667 |
// set_delete_notify() and clear_delete_notify() are called |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
668 |
// under the protection of the delete_lock, but we also use an |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
669 |
// Atomic operation to ensure the memory update is seen earlier than |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
670 |
// when the delete_lock is dropped. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
671 |
// |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
672 |
void ThreadsSMRSupport::clear_delete_notify() { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
673 |
Atomic::dec(&_delete_notify); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
674 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
675 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
676 |
bool ThreadsSMRSupport::delete_notify() { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
677 |
// Use load_acquire() in order to see any updates to _delete_notify |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
678 |
// earlier than when delete_lock is grabbed. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
679 |
return (OrderAccess::load_acquire(&_delete_notify) != 0); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
680 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
681 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
682 |
// Safely free a ThreadsList after a Threads::add() or Threads::remove(). |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
683 |
// The specified ThreadsList may not get deleted during this call if it |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
684 |
// is still in-use (referenced by a hazard ptr). Other ThreadsLists |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
685 |
// in the chain may get deleted by this call if they are no longer in-use. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
686 |
void ThreadsSMRSupport::free_list(ThreadsList* threads) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
687 |
assert_locked_or_safepoint(Threads_lock); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
688 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
689 |
threads->set_next_list(_to_delete_list); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
690 |
_to_delete_list = threads; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
691 |
if (EnableThreadSMRStatistics) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
692 |
_to_delete_list_cnt++; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
693 |
if (_to_delete_list_cnt > _to_delete_list_max) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
694 |
_to_delete_list_max = _to_delete_list_cnt; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
695 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
696 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
697 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
698 |
// Hash table size should be first power of two higher than twice the length of the ThreadsList |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
699 |
int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
700 |
hash_table_size--; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
701 |
hash_table_size |= hash_table_size >> 1; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
702 |
hash_table_size |= hash_table_size >> 2; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
703 |
hash_table_size |= hash_table_size >> 4; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
704 |
hash_table_size |= hash_table_size >> 8; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
705 |
hash_table_size |= hash_table_size >> 16; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
706 |
hash_table_size++; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
707 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
708 |
// Gather a hash table of the current hazard ptrs: |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
709 |
ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
710 |
ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
711 |
Threads::threads_do(&scan_cl); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
712 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
713 |
// Walk through the linked list of pending freeable ThreadsLists |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
714 |
// and free the ones that are not referenced from hazard ptrs. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
715 |
ThreadsList* current = _to_delete_list; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
716 |
ThreadsList* prev = NULL; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
717 |
ThreadsList* next = NULL; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
718 |
bool threads_is_freed = false; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
719 |
while (current != NULL) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
720 |
next = current->next_list(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
721 |
if (!scan_table->has_entry((void*)current)) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
722 |
// This ThreadsList is not referenced by a hazard ptr. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
723 |
if (prev != NULL) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
724 |
prev->set_next_list(next); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
725 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
726 |
if (_to_delete_list == current) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
727 |
_to_delete_list = next; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
728 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
729 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
730 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current)); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
731 |
if (current == threads) threads_is_freed = true; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
732 |
delete current; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
733 |
if (EnableThreadSMRStatistics) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
734 |
_java_thread_list_free_cnt++; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
735 |
_to_delete_list_cnt--; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
736 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
737 |
} else { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
738 |
prev = current; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
739 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
740 |
current = next; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
741 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
742 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
743 |
if (!threads_is_freed) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
744 |
// Only report "is not freed" on the original call to |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
745 |
// free_list() for this ThreadsList. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
746 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads)); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
747 |
} |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
748 |
|
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
749 |
delete scan_table; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
750 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
751 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
752 |
// Return true if the specified JavaThread is protected by a hazard |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
753 |
// pointer (ThreadsList reference). Otherwise, returns false. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
754 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
755 |
bool ThreadsSMRSupport::is_a_protected_JavaThread(JavaThread *thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
756 |
assert_locked_or_safepoint(Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
757 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
758 |
// Hash table size should be first power of two higher than twice |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
759 |
// the length of the Threads list. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
760 |
int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
761 |
hash_table_size--; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
762 |
hash_table_size |= hash_table_size >> 1; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
763 |
hash_table_size |= hash_table_size >> 2; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
764 |
hash_table_size |= hash_table_size >> 4; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
765 |
hash_table_size |= hash_table_size >> 8; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
766 |
hash_table_size |= hash_table_size >> 16; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
767 |
hash_table_size++; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
768 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
769 |
// Gather a hash table of the JavaThreads indirectly referenced by |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
770 |
// hazard ptrs. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
771 |
ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
772 |
ScanHazardPtrGatherProtectedThreadsClosure scan_cl(scan_table); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
773 |
Threads::threads_do(&scan_cl); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
774 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
775 |
bool thread_is_protected = false; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
776 |
if (scan_table->has_entry((void*)thread)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
777 |
thread_is_protected = true; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
778 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
779 |
delete scan_table; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
780 |
return thread_is_protected; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
781 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
782 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
783 |
// Release a stable ThreadsList. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
784 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
785 |
void ThreadsSMRSupport::release_stable_list(Thread *self) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
786 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
787 |
// release_stable_list_nested_path() will grab the Threads_lock |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
788 |
// so let's make sure the ThreadsListHandle is in a safe place. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
789 |
debug_only(if (StrictSafepointChecks) self->check_for_valid_safepoint_state(/* potential_vm_operation */ false);) |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
790 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
791 |
if (self->get_nested_threads_hazard_ptr() == NULL) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
792 |
// The typical case is first. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
793 |
release_stable_list_fast_path(self); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
794 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
795 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
796 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
797 |
// The nested case is rare. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
798 |
release_stable_list_nested_path(self); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
799 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
800 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
801 |
// Fast path way to release a stable ThreadsList. The release portion |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
802 |
// is lock-free, but the wake up portion is not. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
803 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
804 |
void ThreadsSMRSupport::release_stable_list_fast_path(Thread *self) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
805 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
806 |
assert(self->get_threads_hazard_ptr() != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
807 |
assert(self->get_nested_threads_hazard_ptr() == NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
808 |
"cannot have a nested hazard ptr when releasing a regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
809 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
810 |
// After releasing the hazard ptr, other threads may go ahead and |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
811 |
// free up some memory temporarily used by a ThreadsList snapshot. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
812 |
self->set_threads_hazard_ptr(NULL); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
813 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
814 |
// We use double-check locking to reduce traffic on the system |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
815 |
// wide Thread-SMR delete_lock. |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
816 |
if (ThreadsSMRSupport::delete_notify()) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
817 |
// An exiting thread might be waiting in smr_delete(); we need to |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
818 |
// check with delete_lock to be sure. |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
819 |
release_stable_list_wake_up((char *) "regular hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
820 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
821 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
822 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
823 |
// Release a nested stable ThreadsList; this is rare so it uses |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
824 |
// Threads_lock. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
825 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
826 |
void ThreadsSMRSupport::release_stable_list_nested_path(Thread *self) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
827 |
assert(self != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
828 |
assert(self->get_nested_threads_hazard_ptr() != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
829 |
assert(self->get_threads_hazard_ptr() != NULL, |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
830 |
"must have a regular hazard ptr to have nested hazard ptrs"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
831 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
832 |
// We have a nested ThreadsListHandle so we have to release it first. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
833 |
// The need for a nested ThreadsListHandle is rare so we do this while |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
834 |
// holding the Threads_lock so we don't race with the scanning code; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
835 |
// the code is so much simpler this way. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
836 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
837 |
NestedThreadsList *node; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
838 |
{ |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
839 |
// Only grab the Threads_lock if we don't already own it. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
840 |
MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
841 |
// We remove from the front of the list to match up with the insert |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
842 |
// in acquire_stable_list(). |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
843 |
node = self->get_nested_threads_hazard_ptr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
844 |
self->set_nested_threads_hazard_ptr(node->next()); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
845 |
if (EnableThreadSMRStatistics) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
846 |
self->dec_nested_threads_hazard_ptr_cnt(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
847 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
848 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
849 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
850 |
// An exiting thread might be waiting in smr_delete(); we need to |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
851 |
// check with delete_lock to be sure. |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
852 |
release_stable_list_wake_up((char *) "nested hazard ptr"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
853 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
854 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list())); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
855 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
856 |
delete node; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
857 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
858 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
859 |
// Wake up portion of the release stable ThreadsList protocol; |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
860 |
// uses the delete_lock(). |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
861 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
862 |
void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
863 |
assert(log_str != NULL, "sanity check"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
864 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
865 |
// Note: delete_lock is held in smr_delete() for the entire |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
866 |
// hazard ptr search so that we do not lose this notify() if |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
867 |
// the exiting thread has to wait. That code path also holds |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
868 |
// Threads_lock (which was grabbed before delete_lock) so that |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
869 |
// threads_do() can be called. This means the system can't start a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
870 |
// safepoint which means this thread can't take too long to get to |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
871 |
// a safepoint because of being blocked on delete_lock. |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
872 |
// |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
873 |
MonitorLockerEx ml(ThreadsSMRSupport::delete_lock(), Monitor::_no_safepoint_check_flag); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
874 |
if (ThreadsSMRSupport::delete_notify()) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
875 |
// Notify any exiting JavaThreads that are waiting in smr_delete() |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
876 |
// that we've released a ThreadsList. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
877 |
ml.notify_all(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
878 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list notified %s", os::current_thread_id(), log_str); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
879 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
880 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
881 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
882 |
void ThreadsSMRSupport::remove_thread(JavaThread *thread) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
883 |
ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_java_thread_list(), thread); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
884 |
if (EnableThreadSMRStatistics) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
885 |
ThreadsSMRSupport::inc_java_thread_list_alloc_cnt(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
886 |
// This list is smaller so no need to check for a "longest" update. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
887 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
888 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
889 |
// Final _java_thread_list will not generate a "Threads::remove" mesg. |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
890 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::remove: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
891 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
892 |
ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
893 |
ThreadsSMRSupport::free_list(old_list); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
894 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
895 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
896 |
// See note for clear_delete_notify(). |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
897 |
// |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
898 |
void ThreadsSMRSupport::set_delete_notify() { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
899 |
Atomic::inc(&_delete_notify); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
900 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
901 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
902 |
// Safely delete a JavaThread when it is no longer in use by a |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
903 |
// ThreadsListHandle. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
904 |
// |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
905 |
void ThreadsSMRSupport::smr_delete(JavaThread *thread) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
906 |
assert(!Threads_lock->owned_by_self(), "sanity"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
907 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
908 |
bool has_logged_once = false; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
909 |
elapsedTimer timer; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
910 |
if (EnableThreadSMRStatistics) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
911 |
timer.start(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
912 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
913 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
914 |
while (true) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
915 |
{ |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
916 |
// No safepoint check because this JavaThread is not on the |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
917 |
// Threads list. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
918 |
MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
919 |
// Cannot use a MonitorLockerEx helper here because we have |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
920 |
// to drop the Threads_lock first if we wait. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
921 |
ThreadsSMRSupport::delete_lock()->lock_without_safepoint_check(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
922 |
// Set the delete_notify flag after we grab delete_lock |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
923 |
// and before we scan hazard ptrs because we're doing |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
924 |
// double-check locking in release_stable_list(). |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
925 |
ThreadsSMRSupport::set_delete_notify(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
926 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
927 |
if (!is_a_protected_JavaThread(thread)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
928 |
// This is the common case. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
929 |
ThreadsSMRSupport::clear_delete_notify(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
930 |
ThreadsSMRSupport::delete_lock()->unlock(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
931 |
break; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
932 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
933 |
if (!has_logged_once) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
934 |
has_logged_once = true; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
935 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is not deleted.", os::current_thread_id(), p2i(thread)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
936 |
if (log_is_enabled(Debug, os, thread)) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
937 |
ScanHazardPtrPrintMatchingThreadsClosure scan_cl(thread); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
938 |
Threads::threads_do(&scan_cl); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
939 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
940 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
941 |
} // We have to drop the Threads_lock to wait or delete the thread |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
942 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
943 |
if (EnableThreadSMRStatistics) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
944 |
_delete_lock_wait_cnt++; |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
945 |
if (_delete_lock_wait_cnt > _delete_lock_wait_max) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
946 |
_delete_lock_wait_max = _delete_lock_wait_cnt; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
947 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
948 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
949 |
// Wait for a release_stable_list() call before we check again. No |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
950 |
// safepoint check, no timeout, and not as suspend equivalent flag |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
951 |
// because this JavaThread is not on the Threads list. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
952 |
ThreadsSMRSupport::delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0, |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
953 |
!Mutex::_as_suspend_equivalent_flag); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
954 |
if (EnableThreadSMRStatistics) { |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
955 |
_delete_lock_wait_cnt--; |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
956 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
957 |
|
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
958 |
ThreadsSMRSupport::clear_delete_notify(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
959 |
ThreadsSMRSupport::delete_lock()->unlock(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
960 |
// Retry the whole scenario. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
961 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
962 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
963 |
if (ThreadLocalHandshakes) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
964 |
// The thread is about to be deleted so cancel any handshake. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
965 |
thread->cancel_handshake(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
966 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
967 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
968 |
delete thread; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
969 |
if (EnableThreadSMRStatistics) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
970 |
timer.stop(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
971 |
uint millis = (uint)timer.milliseconds(); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
972 |
ThreadsSMRSupport::inc_deleted_thread_cnt(); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
973 |
ThreadsSMRSupport::add_deleted_thread_times(millis); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
974 |
ThreadsSMRSupport::update_deleted_thread_time_max(millis); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
975 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
976 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
977 |
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
978 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
979 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
980 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
981 |
// Debug, logging, and printing stuff at the end: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
982 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
983 |
// Log Threads class SMR info. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
984 |
void ThreadsSMRSupport::log_statistics() { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
985 |
LogTarget(Info, thread, smr) log; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
986 |
if (log.is_enabled()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
987 |
LogStream out(log); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
988 |
print_info_on(&out); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
989 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
990 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
991 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
992 |
// Print Threads class SMR info. |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
993 |
void ThreadsSMRSupport::print_info_on(outputStream* st) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
994 |
// Only grab the Threads_lock if we don't already own it |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
995 |
// and if we are not reporting an error. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
996 |
MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
997 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
998 |
st->print_cr("Threads class SMR info:"); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
999 |
st->print_cr("_java_thread_list=" INTPTR_FORMAT ", length=%u, " |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1000 |
"elements={", p2i(_java_thread_list), |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1001 |
_java_thread_list->length()); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1002 |
print_info_elements_on(st, _java_thread_list); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1003 |
st->print_cr("}"); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1004 |
if (_to_delete_list != NULL) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1005 |
st->print_cr("_to_delete_list=" INTPTR_FORMAT ", length=%u, " |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1006 |
"elements={", p2i(_to_delete_list), |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1007 |
_to_delete_list->length()); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1008 |
print_info_elements_on(st, _to_delete_list); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1009 |
st->print_cr("}"); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1010 |
for (ThreadsList *t_list = _to_delete_list->next_list(); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1011 |
t_list != NULL; t_list = t_list->next_list()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1012 |
st->print("next-> " INTPTR_FORMAT ", length=%u, " |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1013 |
"elements={", p2i(t_list), t_list->length()); |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1014 |
print_info_elements_on(st, t_list); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1015 |
st->print_cr("}"); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1016 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1017 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1018 |
if (!EnableThreadSMRStatistics) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1019 |
return; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1020 |
} |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1021 |
st->print_cr("_java_thread_list_alloc_cnt=" UINT64_FORMAT "," |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1022 |
"_java_thread_list_free_cnt=" UINT64_FORMAT "," |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1023 |
"_java_thread_list_max=%u, " |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1024 |
"_nested_thread_list_max=%u", |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1025 |
_java_thread_list_alloc_cnt, |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1026 |
_java_thread_list_free_cnt, |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1027 |
_java_thread_list_max, |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1028 |
_nested_thread_list_max); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1029 |
if (_tlh_cnt > 0) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1030 |
st->print_cr("_tlh_cnt=%u" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1031 |
", _tlh_times=%u" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1032 |
", avg_tlh_time=%0.2f" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1033 |
", _tlh_time_max=%u", |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1034 |
_tlh_cnt, _tlh_times, |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1035 |
((double) _tlh_times / _tlh_cnt), |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1036 |
_tlh_time_max); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1037 |
} |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1038 |
if (_deleted_thread_cnt > 0) { |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1039 |
st->print_cr("_deleted_thread_cnt=%u" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1040 |
", _deleted_thread_times=%u" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1041 |
", avg_deleted_thread_time=%0.2f" |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1042 |
", _deleted_thread_time_max=%u", |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1043 |
_deleted_thread_cnt, _deleted_thread_times, |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1044 |
((double) _deleted_thread_times / _deleted_thread_cnt), |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1045 |
_deleted_thread_time_max); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1046 |
} |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1047 |
st->print_cr("_delete_lock_wait_cnt=%u, _delete_lock_wait_max=%u", |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1048 |
_delete_lock_wait_cnt, _delete_lock_wait_max); |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1049 |
st->print_cr("_to_delete_list_cnt=%u, _to_delete_list_max=%u", |
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1050 |
_to_delete_list_cnt, _to_delete_list_max); |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1051 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1052 |
|
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1053 |
// Print ThreadsList elements (4 per line). |
48382
0997d6959851
8193135: get rid of redundant _smr_ prefix/infix in ThreadSMRSupport stuff
dcubed
parents:
48312
diff
changeset
|
1054 |
void ThreadsSMRSupport::print_info_elements_on(outputStream* st, ThreadsList* t_list) { |
48312
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1055 |
uint cnt = 0; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1056 |
JavaThreadIterator jti(t_list); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1057 |
for (JavaThread *jt = jti.first(); jt != NULL; jt = jti.next()) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1058 |
st->print(INTPTR_FORMAT, p2i(jt)); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1059 |
if (cnt < t_list->length() - 1) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1060 |
// Separate with comma or comma-space except for the last one. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1061 |
if (((cnt + 1) % 4) == 0) { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1062 |
// Four INTPTR_FORMAT fit on an 80 column line so end the |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1063 |
// current line with just a comma. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1064 |
st->print_cr(","); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1065 |
} else { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1066 |
// Not the last one on the current line so use comma-space: |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1067 |
st->print(", "); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1068 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1069 |
} else { |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1070 |
// Last one so just end the current line. |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1071 |
st->cr(); |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1072 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1073 |
cnt++; |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1074 |
} |
2a1413298af0
8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
dcubed
parents:
48105
diff
changeset
|
1075 |
} |