annotate src/share/vm/gc_implementation/g1/satbQueue.cpp @ 1886:72a161e62cc4

6991377: G1: race between concurrent refinement and humongous object allocation Summary: There is a race between the concurrent refinement threads and the humongous object allocation that can cause the concurrent refinement threads to corrupt the part of the BOT that it is being initialized by the humongous object allocation operation. The solution is to do the humongous object allocation in careful steps to ensure that the concurrent refinement threads always have a consistent view over the BOT, region contents, and top. The fix includes some very minor tidying up in sparsePRT. Reviewed-by: jcoomes, johnc, ysr
author tonyp
date Sat, 16 Oct 2010 17:12:19 -0400
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1317
diff changeset
2 * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1317
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1317
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1317
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
25 # include "incls/_precompiled.incl"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
26 # include "incls/_satbQueue.cpp.incl"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
27
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
28 void ObjPtrQueue::apply_closure(ObjectClosure* cl) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
29 if (_buf != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
30 apply_closure_to_buffer(cl, _buf, _index, _sz);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
31 _index = _sz;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 void ObjPtrQueue::apply_closure_to_buffer(ObjectClosure* cl,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 void** buf, size_t index, size_t sz) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 if (cl == NULL) return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
38 for (size_t i = index; i < sz; i += oopSize) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 oop obj = (oop)buf[byte_index_to_index((int)i)];
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 // There can be NULL entries because of destructors.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 if (obj != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 cl->do_object(obj);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 }
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
46
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
47 #ifdef ASSERT
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
48 void ObjPtrQueue::verify_oops_in_buffer() {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
49 if (_buf == NULL) return;
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
50 for (size_t i = _index; i < _sz; i += oopSize) {
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
51 oop obj = (oop)_buf[byte_index_to_index((int)i)];
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
52 assert(obj != NULL && obj->is_oop(true /* ignore mark word */),
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
53 "Not an oop");
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
54 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
55 }
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
56 #endif
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
57
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
59 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
60 #endif // _MSC_VER
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
61
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
62
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
63 SATBMarkQueueSet::SATBMarkQueueSet() :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
64 PtrQueueSet(),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
65 _closure(NULL), _par_closures(NULL),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
66 _shared_satb_queue(this, true /*perm*/)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67 {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
68
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
70 int process_completed_threshold,
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71 Mutex* lock) {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
72 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73 _shared_satb_queue.set_lock(lock);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 if (ParallelGCThreads > 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
77 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80 void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
81 DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();)
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
82 t->satb_mark_queue().handle_zero_index();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84
1317
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
85 #ifdef ASSERT
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
86 void SATBMarkQueueSet::dump_active_values(JavaThread* first,
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
87 bool expected_active) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
88 gclog_or_tty->print_cr("SATB queue active values for Java Threads");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
89 gclog_or_tty->print_cr(" SATB queue set: active is %s",
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
90 (is_active()) ? "TRUE" : "FALSE");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
91 gclog_or_tty->print_cr(" expected_active is %s",
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
92 (expected_active) ? "TRUE" : "FALSE");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
93 for (JavaThread* t = first; t; t = t->next()) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
94 bool active = t->satb_mark_queue().is_active();
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
95 gclog_or_tty->print_cr(" thread %s, active is %s",
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
96 t->name(), (active) ? "TRUE" : "FALSE");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
97 }
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
98 }
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
99 #endif // ASSERT
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
100
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
101 void SATBMarkQueueSet::set_active_all_threads(bool b,
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
102 bool expected_active) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
103 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
104 JavaThread* first = Threads::first();
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
105
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
106 #ifdef ASSERT
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
107 if (_all_active != expected_active) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
108 dump_active_values(first, expected_active);
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
109
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
110 // I leave this here as a guarantee, instead of an assert, so
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
111 // that it will still be compiled in if we choose to uncomment
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
112 // the #ifdef ASSERT in a product build. The whole block is
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
113 // within an #ifdef ASSERT so the guarantee will not be compiled
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
114 // in a product build anyway.
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
115 guarantee(false,
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
116 "SATB queue set has an unexpected active value");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
117 }
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
118 #endif // ASSERT
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
119 _all_active = b;
1317
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
120
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
121 for (JavaThread* t = first; t; t = t->next()) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
122 #ifdef ASSERT
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
123 bool active = t->satb_mark_queue().is_active();
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
124 if (active != expected_active) {
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
125 dump_active_values(first, expected_active);
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
126
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
127 // I leave this here as a guarantee, instead of an assert, so
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
128 // that it will still be compiled in if we choose to uncomment
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
129 // the #ifdef ASSERT in a product build. The whole block is
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
130 // within an #ifdef ASSERT so the guarantee will not be compiled
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
131 // in a product build anyway.
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
132 guarantee(false,
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
133 "thread has an unexpected active value in its SATB queue");
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
134 }
d4197f8d516a 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 1111
diff changeset
135 #endif // ASSERT
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136 t->satb_mark_queue().set_active(b);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140 void SATBMarkQueueSet::set_closure(ObjectClosure* closure) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 _closure = closure;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 _par_closures[i] = par_closure;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 void SATBMarkQueueSet::iterate_closure_all_threads() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 for(JavaThread* t = Threads::first(); t; t = t->next()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
151 t->satb_mark_queue().apply_closure(_closure);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153 shared_satb_queue()->apply_closure(_closure);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
154 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
156 void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
157 SharedHeap* sh = SharedHeap::heap();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
158 int parity = sh->strong_roots_parity();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 for(JavaThread* t = Threads::first(); t; t = t->next()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161 if (t->claim_oops_do(true, parity)) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
162 t->satb_mark_queue().apply_closure(_par_closures[worker]);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
164 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165 // We'll have worker 0 do this one.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 if (worker == 0) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 shared_satb_queue()->apply_closure(_par_closures[0]);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 int worker) {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
173 BufferNode* nd = NULL;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 if (_completed_buffers_head != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177 nd = _completed_buffers_head;
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
178 _completed_buffers_head = nd->next();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180 _n_completed_buffers--;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 if (_n_completed_buffers == 0) _process_completed = false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 ObjectClosure* cl = (par ? _par_closures[worker] : _closure);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 if (nd != NULL) {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
186 void **buf = BufferNode::make_buffer_from_node(nd);
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
187 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
188 deallocate_buffer(buf);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 return true;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
190 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
191 return false;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
192 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195 void SATBMarkQueueSet::abandon_partial_marking() {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
196 BufferNode* buffers_to_delete = NULL;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199 while (_completed_buffers_head != NULL) {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
200 BufferNode* nd = _completed_buffers_head;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
201 _completed_buffers_head = nd->next();
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
202 nd->set_next(buffers_to_delete);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 buffers_to_delete = nd;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205 _completed_buffers_tail = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 _n_completed_buffers = 0;
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 342
diff changeset
207 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
208 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209 while (buffers_to_delete != NULL) {
1111
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
210 BufferNode* nd = buffers_to_delete;
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
211 buffers_to_delete = nd->next();
44f61c24ddab 6862387: tune concurrent refinement further
iveresov
parents: 845
diff changeset
212 deallocate_buffer(BufferNode::make_buffer_from_node(nd));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
215 // So we can safely manipulate these queues.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216 for (JavaThread* t = Threads::first(); t; t = t->next()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
217 t->satb_mark_queue().reset();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
218 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219 shared_satb_queue()->reset();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
220 }