author | aharlap |
Mon, 11 Jan 2016 14:26:00 -0500 | |
changeset 35481 | 53825bdb41a0 |
parent 35465 | 34ab60aee787 |
child 35882 | 98c7219214df |
permissions | -rw-r--r-- |
1374 | 1 |
/* |
30764 | 2 |
* Copyright (c) 2001, 2015, 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:
4481
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4481
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:
4481
diff
changeset
|
21 |
* questions. |
1374 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/dirtyCardQueue.hpp" |
27 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
|
28 |
#include "gc/g1/heapRegionRemSet.hpp" |
|
29 |
#include "gc/shared/workgroup.hpp" |
|
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24104
diff
changeset
|
30 |
#include "runtime/atomic.inline.hpp" |
7397 | 31 |
#include "runtime/mutexLocker.hpp" |
32 |
#include "runtime/safepoint.hpp" |
|
14583
d70ee55535f4
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
10565
diff
changeset
|
33 |
#include "runtime/thread.inline.hpp" |
1374 | 34 |
|
35465 | 35 |
// Represents a set of free small integer ids. |
36 |
class FreeIdSet : public CHeapObj<mtGC> { |
|
37 |
enum { |
|
38 |
end_of_list = UINT_MAX, |
|
39 |
claimed = UINT_MAX - 1 |
|
40 |
}; |
|
41 |
||
42 |
uint _size; |
|
43 |
Monitor* _mon; |
|
44 |
||
45 |
uint* _ids; |
|
46 |
uint _hd; |
|
47 |
uint _waiters; |
|
48 |
uint _claimed; |
|
49 |
||
50 |
public: |
|
51 |
FreeIdSet(uint size, Monitor* mon); |
|
52 |
~FreeIdSet(); |
|
53 |
||
54 |
// Returns an unclaimed parallel id (waiting for one to be released if |
|
55 |
// necessary). |
|
56 |
uint claim_par_id(); |
|
57 |
||
58 |
void release_par_id(uint id); |
|
59 |
}; |
|
60 |
||
61 |
FreeIdSet::FreeIdSet(uint size, Monitor* mon) : |
|
62 |
_size(size), _mon(mon), _hd(0), _waiters(0), _claimed(0) |
|
63 |
{ |
|
64 |
guarantee(size != 0, "must be"); |
|
65 |
_ids = NEW_C_HEAP_ARRAY(uint, size, mtGC); |
|
66 |
for (uint i = 0; i < size - 1; i++) { |
|
67 |
_ids[i] = i+1; |
|
68 |
} |
|
69 |
_ids[size-1] = end_of_list; // end of list. |
|
70 |
} |
|
71 |
||
72 |
FreeIdSet::~FreeIdSet() { |
|
73 |
FREE_C_HEAP_ARRAY(uint, _ids); |
|
74 |
} |
|
75 |
||
76 |
uint FreeIdSet::claim_par_id() { |
|
77 |
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag); |
|
78 |
while (_hd == end_of_list) { |
|
79 |
_waiters++; |
|
80 |
_mon->wait(Mutex::_no_safepoint_check_flag); |
|
81 |
_waiters--; |
|
82 |
} |
|
83 |
uint res = _hd; |
|
84 |
_hd = _ids[res]; |
|
85 |
_ids[res] = claimed; // For debugging. |
|
86 |
_claimed++; |
|
87 |
return res; |
|
88 |
} |
|
89 |
||
90 |
void FreeIdSet::release_par_id(uint id) { |
|
91 |
MutexLockerEx x(_mon, Mutex::_no_safepoint_check_flag); |
|
92 |
assert(_ids[id] == claimed, "Precondition."); |
|
93 |
_ids[id] = _hd; |
|
94 |
_hd = id; |
|
95 |
_claimed--; |
|
96 |
if (_waiters > 0) { |
|
97 |
_mon->notify_all(); |
|
98 |
} |
|
99 |
} |
|
100 |
||
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
101 |
DirtyCardQueue::DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent) : |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
102 |
// Dirty card queues are always active, so we create them with their |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
103 |
// active field set to true. |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
104 |
PtrQueue(qset, permanent, true /* active */) |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
105 |
{ } |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
106 |
|
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
107 |
DirtyCardQueue::~DirtyCardQueue() { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
108 |
if (!is_permanent()) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
109 |
flush(); |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
110 |
} |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
111 |
} |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
112 |
|
1374 | 113 |
bool DirtyCardQueue::apply_closure(CardTableEntryClosure* cl, |
114 |
bool consume, |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
115 |
uint worker_i) { |
1374 | 116 |
bool res = true; |
117 |
if (_buf != NULL) { |
|
118 |
res = apply_closure_to_buffer(cl, _buf, _index, _sz, |
|
119 |
consume, |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
120 |
worker_i); |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
121 |
if (res && consume) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
122 |
_index = _sz; |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
123 |
} |
1374 | 124 |
} |
125 |
return res; |
|
126 |
} |
|
127 |
||
128 |
bool DirtyCardQueue::apply_closure_to_buffer(CardTableEntryClosure* cl, |
|
129 |
void** buf, |
|
130 |
size_t index, size_t sz, |
|
131 |
bool consume, |
|
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
132 |
uint worker_i) { |
1374 | 133 |
if (cl == NULL) return true; |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
134 |
size_t limit = byte_index_to_index(sz); |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
135 |
for (size_t i = byte_index_to_index(index); i < limit; ++i) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
136 |
jbyte* card_ptr = static_cast<jbyte*>(buf[i]); |
1374 | 137 |
if (card_ptr != NULL) { |
138 |
// Set the entry to null, so we don't do it again (via the test |
|
139 |
// above) if we reconsider this buffer. |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
140 |
if (consume) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
141 |
buf[i] = NULL; |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
142 |
} |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
143 |
if (!cl->do_card_ptr(card_ptr, worker_i)) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
144 |
return false; |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
145 |
} |
1374 | 146 |
} |
147 |
} |
|
148 |
return true; |
|
149 |
} |
|
150 |
||
4481 | 151 |
DirtyCardQueueSet::DirtyCardQueueSet(bool notify_when_complete) : |
152 |
PtrQueueSet(notify_when_complete), |
|
24104
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
153 |
_mut_process_closure(NULL), |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
154 |
_shared_dirty_card_queue(this, true /* permanent */), |
1374 | 155 |
_free_ids(NULL), |
156 |
_processed_buffers_mut(0), _processed_buffers_rs_thread(0) |
|
157 |
{ |
|
158 |
_all_active = true; |
|
159 |
} |
|
160 |
||
2882
d508a8bac491
6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents:
2881
diff
changeset
|
161 |
// Determines how many mutator threads can process the buffers in parallel. |
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
162 |
uint DirtyCardQueueSet::num_par_ids() { |
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
163 |
return (uint)os::processor_count(); |
1374 | 164 |
} |
165 |
||
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
166 |
void DirtyCardQueueSet::initialize(CardTableEntryClosure* cl, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
167 |
Monitor* cbl_mon, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
168 |
Mutex* fl_lock, |
4481 | 169 |
int process_completed_threshold, |
1374 | 170 |
int max_completed_queue, |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
171 |
Mutex* lock, |
35465 | 172 |
DirtyCardQueueSet* fl_owner, |
173 |
bool init_free_ids) { |
|
24104
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
174 |
_mut_process_closure = cl; |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
175 |
PtrQueueSet::initialize(cbl_mon, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
176 |
fl_lock, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
177 |
process_completed_threshold, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
178 |
max_completed_queue, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
179 |
fl_owner); |
3583
805584e16d0f
6864886: G1: rename -XX parameters related to update buffers
tonyp
parents:
2882
diff
changeset
|
180 |
set_buffer_size(G1UpdateBufferSize); |
1374 | 181 |
_shared_dirty_card_queue.set_lock(lock); |
35465 | 182 |
if (init_free_ids) { |
183 |
_free_ids = new FreeIdSet(num_par_ids(), _cbl_mon); |
|
184 |
} |
|
1374 | 185 |
} |
186 |
||
187 |
void DirtyCardQueueSet::handle_zero_index_for_thread(JavaThread* t) { |
|
188 |
t->dirty_card_queue().handle_zero_index(); |
|
189 |
} |
|
190 |
||
191 |
bool DirtyCardQueueSet::mut_process_buffer(void** buf) { |
|
35465 | 192 |
guarantee(_free_ids != NULL, "must be"); |
1374 | 193 |
|
35481
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
194 |
// claim a par id |
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
195 |
uint worker_i = _free_ids->claim_par_id(); |
1374 | 196 |
|
35481
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
197 |
bool b = DirtyCardQueue::apply_closure_to_buffer(_mut_process_closure, buf, 0, |
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
198 |
_sz, true, worker_i); |
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
199 |
if (b) { |
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
200 |
Atomic::inc(&_processed_buffers_mut); |
1374 | 201 |
} |
202 |
||
35481
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
203 |
// release the id |
53825bdb41a0
8145038: Simplify mut_process_buffer worker id management
aharlap
parents:
35465
diff
changeset
|
204 |
_free_ids->release_par_id(worker_i); |
1374 | 205 |
|
206 |
return b; |
|
207 |
} |
|
208 |
||
4481 | 209 |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
210 |
BufferNode* DirtyCardQueueSet::get_completed_buffer(int stop_at) { |
4481 | 211 |
BufferNode* nd = NULL; |
1374 | 212 |
MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
213 |
||
214 |
if ((int)_n_completed_buffers <= stop_at) { |
|
215 |
_process_completed = false; |
|
216 |
return NULL; |
|
217 |
} |
|
218 |
||
219 |
if (_completed_buffers_head != NULL) { |
|
220 |
nd = _completed_buffers_head; |
|
4481 | 221 |
_completed_buffers_head = nd->next(); |
1374 | 222 |
if (_completed_buffers_head == NULL) |
223 |
_completed_buffers_tail = NULL; |
|
224 |
_n_completed_buffers--; |
|
4481 | 225 |
assert(_n_completed_buffers >= 0, "Invariant"); |
1374 | 226 |
} |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
227 |
DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
1374 | 228 |
return nd; |
229 |
} |
|
230 |
||
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
231 |
bool DirtyCardQueueSet::apply_closure_to_completed_buffer_helper(CardTableEntryClosure* cl, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
232 |
uint worker_i, |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
233 |
BufferNode* nd) { |
1374 | 234 |
if (nd != NULL) { |
4481 | 235 |
void **buf = BufferNode::make_buffer_from_node(nd); |
236 |
size_t index = nd->index(); |
|
1374 | 237 |
bool b = |
6247 | 238 |
DirtyCardQueue::apply_closure_to_buffer(cl, buf, |
4481 | 239 |
index, _sz, |
1374 | 240 |
true, worker_i); |
241 |
if (b) { |
|
242 |
deallocate_buffer(buf); |
|
243 |
return true; // In normal case, go on to next buffer. |
|
244 |
} else { |
|
4481 | 245 |
enqueue_complete_buffer(buf, index); |
1374 | 246 |
return false; |
247 |
} |
|
248 |
} else { |
|
249 |
return false; |
|
250 |
} |
|
251 |
} |
|
252 |
||
6247 | 253 |
bool DirtyCardQueueSet::apply_closure_to_completed_buffer(CardTableEntryClosure* cl, |
23855
c4574075402c
8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents:
23543
diff
changeset
|
254 |
uint worker_i, |
6247 | 255 |
int stop_at, |
256 |
bool during_pause) { |
|
257 |
assert(!during_pause || stop_at == 0, "Should not leave any completed buffers during a pause"); |
|
258 |
BufferNode* nd = get_completed_buffer(stop_at); |
|
259 |
bool res = apply_closure_to_completed_buffer_helper(cl, worker_i, nd); |
|
260 |
if (res) Atomic::inc(&_processed_buffers_rs_thread); |
|
261 |
return res; |
|
262 |
} |
|
263 |
||
24104
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
264 |
void DirtyCardQueueSet::apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { |
4481 | 265 |
BufferNode* nd = _completed_buffers_head; |
1374 | 266 |
while (nd != NULL) { |
267 |
bool b = |
|
24104
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
268 |
DirtyCardQueue::apply_closure_to_buffer(cl, |
4481 | 269 |
BufferNode::make_buffer_from_node(nd), |
270 |
0, _sz, false); |
|
1374 | 271 |
guarantee(b, "Should not stop early."); |
4481 | 272 |
nd = nd->next(); |
1374 | 273 |
} |
274 |
} |
|
275 |
||
24104
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
276 |
void DirtyCardQueueSet::par_apply_closure_to_all_completed_buffers(CardTableEntryClosure* cl) { |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
277 |
BufferNode* nd = _cur_par_buffer_node; |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
278 |
while (nd != NULL) { |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
279 |
BufferNode* next = (BufferNode*)nd->next(); |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
280 |
BufferNode* actual = (BufferNode*)Atomic::cmpxchg_ptr((void*)next, (volatile void*)&_cur_par_buffer_node, (void*)nd); |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
281 |
if (actual == nd) { |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
282 |
bool b = |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
283 |
DirtyCardQueue::apply_closure_to_buffer(cl, |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
284 |
BufferNode::make_buffer_from_node(actual), |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
285 |
0, _sz, false); |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
286 |
guarantee(b, "Should not stop early."); |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
287 |
nd = next; |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
288 |
} else { |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
289 |
nd = actual; |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
290 |
} |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
291 |
} |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
292 |
} |
febf9363fb68
8019342: G1: High "Other" time most likely due to card redirtying
tschatzl
parents:
23855
diff
changeset
|
293 |
|
6247 | 294 |
// Deallocates any completed log buffers |
295 |
void DirtyCardQueueSet::clear() { |
|
4481 | 296 |
BufferNode* buffers_to_delete = NULL; |
1374 | 297 |
{ |
298 |
MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
|
299 |
while (_completed_buffers_head != NULL) { |
|
4481 | 300 |
BufferNode* nd = _completed_buffers_head; |
301 |
_completed_buffers_head = nd->next(); |
|
302 |
nd->set_next(buffers_to_delete); |
|
1374 | 303 |
buffers_to_delete = nd; |
304 |
} |
|
305 |
_n_completed_buffers = 0; |
|
306 |
_completed_buffers_tail = NULL; |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
307 |
DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
1374 | 308 |
} |
309 |
while (buffers_to_delete != NULL) { |
|
4481 | 310 |
BufferNode* nd = buffers_to_delete; |
311 |
buffers_to_delete = nd->next(); |
|
312 |
deallocate_buffer(BufferNode::make_buffer_from_node(nd)); |
|
1374 | 313 |
} |
6247 | 314 |
|
315 |
} |
|
316 |
||
317 |
void DirtyCardQueueSet::abandon_logs() { |
|
318 |
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
|
319 |
clear(); |
|
1374 | 320 |
// Since abandon is done only at safepoints, we can safely manipulate |
321 |
// these queues. |
|
322 |
for (JavaThread* t = Threads::first(); t; t = t->next()) { |
|
323 |
t->dirty_card_queue().reset(); |
|
324 |
} |
|
325 |
shared_dirty_card_queue()->reset(); |
|
326 |
} |
|
327 |
||
328 |
||
329 |
void DirtyCardQueueSet::concatenate_logs() { |
|
330 |
// Iterate over all the threads, if we find a partial log add it to |
|
331 |
// the global list of logs. Temporarily turn off the limit on the number |
|
332 |
// of outstanding buffers. |
|
333 |
int save_max_completed_queue = _max_completed_queue; |
|
334 |
_max_completed_queue = max_jint; |
|
335 |
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
|
336 |
for (JavaThread* t = Threads::first(); t; t = t->next()) { |
|
337 |
DirtyCardQueue& dcq = t->dirty_card_queue(); |
|
338 |
if (dcq.size() != 0) { |
|
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
339 |
void** buf = dcq.get_buf(); |
1374 | 340 |
// We must NULL out the unused entries, then enqueue. |
33761
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
341 |
size_t limit = dcq.byte_index_to_index(dcq.get_index()); |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
342 |
for (size_t i = 0; i < limit; ++i) { |
329db4b51480
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents:
30764
diff
changeset
|
343 |
buf[i] = NULL; |
1374 | 344 |
} |
345 |
enqueue_complete_buffer(dcq.get_buf(), dcq.get_index()); |
|
346 |
dcq.reinitialize(); |
|
347 |
} |
|
348 |
} |
|
349 |
if (_shared_dirty_card_queue.size() != 0) { |
|
350 |
enqueue_complete_buffer(_shared_dirty_card_queue.get_buf(), |
|
351 |
_shared_dirty_card_queue.get_index()); |
|
352 |
_shared_dirty_card_queue.reinitialize(); |
|
353 |
} |
|
354 |
// Restore the completed buffer queue limit. |
|
355 |
_max_completed_queue = save_max_completed_queue; |
|
356 |
} |