author | kbarrett |
Wed, 21 Nov 2018 09:40:19 -0500 | |
changeset 52637 | 0877040ec224 |
parent 52582 | 6df094be7f58 |
child 52726 | 9cfa2e273b77 |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
1374 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5082
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
51441
2e91d927e00c
8154343: Make SATB related code available to other GCs
kbarrett
parents:
51332
diff
changeset
|
25 |
#ifndef SHARE_GC_SHARED_PTRQUEUE_HPP |
2e91d927e00c
8154343: Make SATB related code available to other GCs
kbarrett
parents:
51332
diff
changeset
|
26 |
#define SHARE_GC_SHARED_PTRQUEUE_HPP |
7397 | 27 |
|
46625 | 28 |
#include "utilities/align.hpp" |
7397 | 29 |
#include "utilities/sizes.hpp" |
30 |
||
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
31 |
class Mutex; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
32 |
|
1374 | 33 |
// There are various techniques that require threads to be able to log |
34 |
// addresses. For example, a generational write barrier might log |
|
35 |
// the addresses of modified old-generation objects. This type supports |
|
36 |
// this operation. |
|
37 |
||
37065 | 38 |
class BufferNode; |
1374 | 39 |
class PtrQueueSet; |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
40 |
class PtrQueue { |
20011
d74937287461
8024760: add more types, fields and constants to VMStructs
twisti
parents:
11455
diff
changeset
|
41 |
friend class VMStructs; |
1374 | 42 |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
43 |
// Noncopyable - not defined. |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
44 |
PtrQueue(const PtrQueue&); |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
45 |
PtrQueue& operator=(const PtrQueue&); |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
46 |
|
1374 | 47 |
// The ptr queue set to which this queue belongs. |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
48 |
PtrQueueSet* const _qset; |
1374 | 49 |
|
50 |
// Whether updates should be logged. |
|
51 |
bool _active; |
|
52 |
||
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
53 |
// If true, the queue is permanent, and doesn't need to deallocate |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
54 |
// its buffer in the destructor (since that obtains a lock which may not |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
55 |
// be legally locked by then. |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
56 |
const bool _permanent; |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
57 |
|
46443 | 58 |
// The (byte) index at which an object was last enqueued. Starts at |
59 |
// capacity_in_bytes (indicating an empty buffer) and goes towards zero. |
|
60 |
// Value is always pointer-size aligned. |
|
61 |
size_t _index; |
|
62 |
||
63 |
// Size of the current buffer, in bytes. |
|
64 |
// Value is always pointer-size aligned. |
|
65 |
size_t _capacity_in_bytes; |
|
66 |
||
67 |
static const size_t _element_size = sizeof(void*); |
|
68 |
||
69 |
// Get the capacity, in bytes. The capacity must have been set. |
|
70 |
size_t capacity_in_bytes() const { |
|
71 |
assert(_capacity_in_bytes > 0, "capacity not set"); |
|
72 |
return _capacity_in_bytes; |
|
73 |
} |
|
74 |
||
75 |
void set_capacity(size_t entries) { |
|
76 |
size_t byte_capacity = index_to_byte_index(entries); |
|
77 |
assert(_capacity_in_bytes == 0 || _capacity_in_bytes == byte_capacity, |
|
78 |
"changing capacity " SIZE_FORMAT " -> " SIZE_FORMAT, |
|
79 |
_capacity_in_bytes, byte_capacity); |
|
80 |
_capacity_in_bytes = byte_capacity; |
|
81 |
} |
|
82 |
||
83 |
static size_t byte_index_to_index(size_t ind) { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46443
diff
changeset
|
84 |
assert(is_aligned(ind, _element_size), "precondition"); |
46443 | 85 |
return ind / _element_size; |
86 |
} |
|
87 |
||
88 |
static size_t index_to_byte_index(size_t ind) { |
|
89 |
return ind * _element_size; |
|
90 |
} |
|
91 |
||
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
92 |
protected: |
1374 | 93 |
// The buffer. |
94 |
void** _buf; |
|
46443 | 95 |
|
96 |
size_t index() const { |
|
97 |
return byte_index_to_index(_index); |
|
98 |
} |
|
1374 | 99 |
|
46443 | 100 |
void set_index(size_t new_index) { |
101 |
size_t byte_index = index_to_byte_index(new_index); |
|
102 |
assert(byte_index <= capacity_in_bytes(), "precondition"); |
|
103 |
_index = byte_index; |
|
104 |
} |
|
105 |
||
106 |
size_t capacity() const { |
|
107 |
return byte_index_to_index(capacity_in_bytes()); |
|
108 |
} |
|
1374 | 109 |
|
110 |
// If there is a lock associated with this buffer, this is that lock. |
|
111 |
Mutex* _lock; |
|
112 |
||
113 |
PtrQueueSet* qset() { return _qset; } |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
114 |
bool is_permanent() const { return _permanent; } |
28507 | 115 |
|
46305
bff6d23aa1e3
8175221: Cleanup DirtyCardQueueSet::concatenate_log
kbarrett
parents:
37065
diff
changeset
|
116 |
// Process queue entries and release resources. |
28507 | 117 |
void flush_impl(); |
1374 | 118 |
|
119 |
// Initialize this queue to contain a null buffer, and be part of the |
|
120 |
// given PtrQueueSet. |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
121 |
PtrQueue(PtrQueueSet* qset, bool permanent = false, bool active = false); |
28507 | 122 |
|
123 |
// Requires queue flushed or permanent. |
|
124 |
~PtrQueue(); |
|
1374 | 125 |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
126 |
public: |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
127 |
|
1374 | 128 |
// Associate a lock with a ptr queue. |
129 |
void set_lock(Mutex* lock) { _lock = lock; } |
|
130 |
||
46443 | 131 |
// Forcibly set empty. |
132 |
void reset() { |
|
133 |
if (_buf != NULL) { |
|
134 |
_index = capacity_in_bytes(); |
|
135 |
} |
|
136 |
} |
|
1374 | 137 |
|
20403
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20011
diff
changeset
|
138 |
void enqueue(volatile void* ptr) { |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20011
diff
changeset
|
139 |
enqueue((void*)(ptr)); |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20011
diff
changeset
|
140 |
} |
45a89fbcd8f7
8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents:
20011
diff
changeset
|
141 |
|
1374 | 142 |
// Enqueues the given "obj". |
143 |
void enqueue(void* ptr) { |
|
144 |
if (!_active) return; |
|
145 |
else enqueue_known_active(ptr); |
|
146 |
} |
|
147 |
||
7920 | 148 |
// This method is called when we're doing the zero index handling |
149 |
// and gives a chance to the queues to do any pre-enqueueing |
|
150 |
// processing they might want to do on the buffer. It should return |
|
151 |
// true if the buffer should be enqueued, or false if enough |
|
152 |
// entries were cleared from it so that it can be re-used. It should |
|
153 |
// not return false if the buffer is still full (otherwise we can |
|
154 |
// get into an infinite loop). |
|
155 |
virtual bool should_enqueue_buffer() { return true; } |
|
4481 | 156 |
void handle_zero_index(); |
1374 | 157 |
|
158 |
void enqueue_known_active(void* ptr); |
|
159 |
||
46443 | 160 |
// Return the size of the in-use region. |
161 |
size_t size() const { |
|
162 |
size_t result = 0; |
|
163 |
if (_buf != NULL) { |
|
164 |
assert(_index <= capacity_in_bytes(), "Invariant"); |
|
165 |
result = byte_index_to_index(capacity_in_bytes() - _index); |
|
166 |
} |
|
167 |
return result; |
|
1374 | 168 |
} |
169 |
||
46443 | 170 |
bool is_empty() const { |
171 |
return _buf == NULL || capacity_in_bytes() == _index; |
|
6768
71338ecb7813
6980838: G1: guarantee(false) failed: thread has an unexpected active value in its SATB queue
tonyp
parents:
5547
diff
changeset
|
172 |
} |
71338ecb7813
6980838: G1: guarantee(false) failed: thread has an unexpected active value in its SATB queue
tonyp
parents:
5547
diff
changeset
|
173 |
|
1374 | 174 |
// Set the "active" property of the queue to "b". An enqueue to an |
175 |
// inactive thread is a no-op. Setting a queue to inactive resets its |
|
176 |
// log to the empty state. |
|
177 |
void set_active(bool b) { |
|
178 |
_active = b; |
|
179 |
if (!b && _buf != NULL) { |
|
46443 | 180 |
reset(); |
1374 | 181 |
} else if (b && _buf != NULL) { |
46443 | 182 |
assert(index() == capacity(), |
183 |
"invariant: queues are empty when activated."); |
|
1374 | 184 |
} |
185 |
} |
|
186 |
||
46443 | 187 |
bool is_active() const { return _active; } |
37065 | 188 |
|
1374 | 189 |
// To support compiler. |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
190 |
|
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
191 |
protected: |
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
192 |
template<typename Derived> |
1374 | 193 |
static ByteSize byte_offset_of_index() { |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
194 |
return byte_offset_of(Derived, _index); |
1374 | 195 |
} |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
196 |
|
1374 | 197 |
static ByteSize byte_width_of_index() { return in_ByteSize(sizeof(size_t)); } |
198 |
||
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
199 |
template<typename Derived> |
1374 | 200 |
static ByteSize byte_offset_of_buf() { |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
201 |
return byte_offset_of(Derived, _buf); |
1374 | 202 |
} |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
203 |
|
46443 | 204 |
static ByteSize byte_width_of_buf() { return in_ByteSize(_element_size); } |
1374 | 205 |
|
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
206 |
template<typename Derived> |
1374 | 207 |
static ByteSize byte_offset_of_active() { |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
208 |
return byte_offset_of(Derived, _active); |
1374 | 209 |
} |
34148
6efbc7ffd767
8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents:
33761
diff
changeset
|
210 |
|
1374 | 211 |
static ByteSize byte_width_of_active() { return in_ByteSize(sizeof(bool)); } |
212 |
||
213 |
}; |
|
214 |
||
4481 | 215 |
class BufferNode { |
216 |
size_t _index; |
|
217 |
BufferNode* _next; |
|
36354 | 218 |
void* _buffer[1]; // Pseudo flexible array member. |
219 |
||
220 |
BufferNode() : _index(0), _next(NULL) { } |
|
221 |
~BufferNode() { } |
|
222 |
||
223 |
static size_t buffer_offset() { |
|
224 |
return offset_of(BufferNode, _buffer); |
|
225 |
} |
|
226 |
||
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
227 |
AIX_ONLY(public:) // xlC 12 on AIX doesn't implement C++ DR45. |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
228 |
// Allocate a new BufferNode with the "buffer" having size elements. |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
229 |
static BufferNode* allocate(size_t size); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
230 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
231 |
// Free a BufferNode. |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
232 |
static void deallocate(BufferNode* node); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
233 |
|
4481 | 234 |
public: |
235 |
BufferNode* next() const { return _next; } |
|
236 |
void set_next(BufferNode* n) { _next = n; } |
|
237 |
size_t index() const { return _index; } |
|
46443 | 238 |
void set_index(size_t i) { _index = i; } |
4481 | 239 |
|
37065 | 240 |
// Return the BufferNode containing the buffer, after setting its index. |
241 |
static BufferNode* make_node_from_buffer(void** buffer, size_t index) { |
|
242 |
BufferNode* node = |
|
243 |
reinterpret_cast<BufferNode*>( |
|
244 |
reinterpret_cast<char*>(buffer) - buffer_offset()); |
|
245 |
node->set_index(index); |
|
246 |
return node; |
|
4481 | 247 |
} |
248 |
||
36354 | 249 |
// Return the buffer for node. |
4481 | 250 |
static void** make_buffer_from_node(BufferNode *node) { |
36354 | 251 |
// &_buffer[0] might lead to index out of bounds warnings. |
252 |
return reinterpret_cast<void**>( |
|
253 |
reinterpret_cast<char*>(node) + buffer_offset()); |
|
4481 | 254 |
} |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
255 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
256 |
// Free-list based allocator. |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
257 |
class Allocator { |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
258 |
size_t _buffer_size; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
259 |
Mutex* _lock; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
260 |
BufferNode* _free_list; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
261 |
volatile size_t _free_count; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
262 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
263 |
public: |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
264 |
Allocator(size_t buffer_size, Mutex* lock); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
265 |
~Allocator(); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
266 |
|
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
267 |
size_t buffer_size() const { return _buffer_size; } |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
268 |
size_t free_count() const; |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
269 |
BufferNode* allocate(); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
270 |
void release(BufferNode* node); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
271 |
void reduce_free_list(); |
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
272 |
}; |
4481 | 273 |
}; |
274 |
||
1374 | 275 |
// A PtrQueueSet represents resources common to a set of pointer queues. |
276 |
// In particular, the individual queues allocate buffers from this shared |
|
277 |
// set, and return completed buffers to the set. |
|
278 |
// All these variables are are protected by the TLOQ_CBL_mon. XXX ??? |
|
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
47216
diff
changeset
|
279 |
class PtrQueueSet { |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
280 |
BufferNode::Allocator* _allocator; |
46443 | 281 |
|
1374 | 282 |
protected: |
283 |
Monitor* _cbl_mon; // Protects the fields below. |
|
4481 | 284 |
BufferNode* _completed_buffers_head; |
285 |
BufferNode* _completed_buffers_tail; |
|
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
286 |
size_t _n_completed_buffers; |
4481 | 287 |
int _process_completed_threshold; |
1374 | 288 |
volatile bool _process_completed; |
289 |
||
290 |
bool _all_active; |
|
291 |
||
292 |
// If true, notify_all on _cbl_mon when the threshold is reached. |
|
293 |
bool _notify_when_complete; |
|
294 |
||
295 |
// Maximum number of elements allowed on completed queue: after that, |
|
296 |
// enqueuer does the work itself. Zero indicates no maximum. |
|
297 |
int _max_completed_queue; |
|
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
298 |
size_t _completed_queue_padding; |
1374 | 299 |
|
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
300 |
size_t completed_buffers_list_length(); |
1374 | 301 |
void assert_completed_buffer_list_len_correct_locked(); |
302 |
void assert_completed_buffer_list_len_correct(); |
|
303 |
||
304 |
protected: |
|
305 |
// A mutator thread does the the work of processing a buffer. |
|
306 |
// Returns "true" iff the work is complete (and the buffer may be |
|
307 |
// deallocated). |
|
37065 | 308 |
virtual bool mut_process_buffer(BufferNode* node) { |
1374 | 309 |
ShouldNotReachHere(); |
310 |
return false; |
|
311 |
} |
|
312 |
||
313 |
// Create an empty ptr queue set. |
|
314 |
PtrQueueSet(bool notify_when_complete = false); |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
315 |
~PtrQueueSet(); |
1374 | 316 |
|
317 |
// Because of init-order concerns, we can't pass these as constructor |
|
318 |
// arguments. |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
319 |
void initialize(Monitor* cbl_mon, |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
320 |
BufferNode::Allocator* allocator, |
4481 | 321 |
int process_completed_threshold, |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
322 |
int max_completed_queue); |
1374 | 323 |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
324 |
public: |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
325 |
|
46443 | 326 |
// Return the buffer for a BufferNode of size buffer_size(). |
1374 | 327 |
void** allocate_buffer(); |
328 |
||
46443 | 329 |
// Return an empty buffer to the free list. The node is required |
330 |
// to have been allocated with a size of buffer_size(). |
|
37065 | 331 |
void deallocate_buffer(BufferNode* node); |
1374 | 332 |
|
333 |
// Declares that "buf" is a complete buffer. |
|
37065 | 334 |
void enqueue_complete_buffer(BufferNode* node); |
4481 | 335 |
|
336 |
// To be invoked by the mutator. |
|
37065 | 337 |
bool process_or_enqueue_complete_buffer(BufferNode* node); |
1374 | 338 |
|
339 |
bool completed_buffers_exist_dirty() { |
|
340 |
return _n_completed_buffers > 0; |
|
341 |
} |
|
342 |
||
343 |
bool process_completed_buffers() { return _process_completed; } |
|
4481 | 344 |
void set_process_completed(bool x) { _process_completed = x; } |
1374 | 345 |
|
5082
19e725a3d2eb
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
4481
diff
changeset
|
346 |
bool is_active() { return _all_active; } |
1374 | 347 |
|
46443 | 348 |
size_t buffer_size() const { |
52582
6df094be7f58
8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents:
51441
diff
changeset
|
349 |
return _allocator->buffer_size(); |
46443 | 350 |
} |
1374 | 351 |
|
4481 | 352 |
// Get/Set the number of completed buffers that triggers log processing. |
353 |
void set_process_completed_threshold(int sz) { _process_completed_threshold = sz; } |
|
354 |
int process_completed_threshold() const { return _process_completed_threshold; } |
|
1374 | 355 |
|
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
356 |
size_t completed_buffers_num() { return _n_completed_buffers; } |
2142
032f4652700c
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
2013
diff
changeset
|
357 |
|
032f4652700c
6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents:
2013
diff
changeset
|
358 |
void merge_bufferlists(PtrQueueSet* src); |
4481 | 359 |
|
360 |
void set_max_completed_queue(int m) { _max_completed_queue = m; } |
|
361 |
int max_completed_queue() { return _max_completed_queue; } |
|
362 |
||
36371
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
363 |
void set_completed_queue_padding(size_t padding) { _completed_queue_padding = padding; } |
fd81a4f0ea00
8139651: ConcurrentG1Refine uses ints for many of its members that should be unsigned types
jprovino
parents:
36354
diff
changeset
|
364 |
size_t completed_queue_padding() { return _completed_queue_padding; } |
4481 | 365 |
|
366 |
// Notify the consumer if the number of buffers crossed the threshold |
|
367 |
void notify_if_necessary(); |
|
1374 | 368 |
}; |
7397 | 369 |
|
51441
2e91d927e00c
8154343: Make SATB related code available to other GCs
kbarrett
parents:
51332
diff
changeset
|
370 |
#endif // SHARE_GC_SHARED_PTRQUEUE_HPP |