Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/satbQueue.cpp @ 1111:44f61c24ddab
6862387: tune concurrent refinement further
Summary: Reworked the concurrent refinement: threads activation, feedback-based threshold adjustment, other miscellaneous fixes.
Reviewed-by: apetrusenko, tonyp
author | iveresov |
---|---|
date | Wed, 16 Dec 2009 15:12:51 -0800 |
parents | df6caf649ff7 |
children | d4197f8d516a |
rev | line source |
---|---|
342 | 1 /* |
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_satbQueue.cpp.incl" | |
27 | |
28 void ObjPtrQueue::apply_closure(ObjectClosure* cl) { | |
29 if (_buf != NULL) { | |
30 apply_closure_to_buffer(cl, _buf, _index, _sz); | |
31 _index = _sz; | |
32 } | |
33 } | |
34 | |
35 void ObjPtrQueue::apply_closure_to_buffer(ObjectClosure* cl, | |
36 void** buf, size_t index, size_t sz) { | |
37 if (cl == NULL) return; | |
38 for (size_t i = index; i < sz; i += oopSize) { | |
39 oop obj = (oop)buf[byte_index_to_index((int)i)]; | |
40 // There can be NULL entries because of destructors. | |
41 if (obj != NULL) { | |
42 cl->do_object(obj); | |
43 } | |
44 } | |
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 | 58 #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away |
59 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list | |
60 #endif // _MSC_VER | |
61 | |
62 | |
63 SATBMarkQueueSet::SATBMarkQueueSet() : | |
64 PtrQueueSet(), | |
65 _closure(NULL), _par_closures(NULL), | |
66 _shared_satb_queue(this, true /*perm*/) | |
67 {} | |
68 | |
69 void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock, | |
1111 | 70 int process_completed_threshold, |
342 | 71 Mutex* lock) { |
1111 | 72 PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1); |
342 | 73 _shared_satb_queue.set_lock(lock); |
74 if (ParallelGCThreads > 0) { | |
75 _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads); | |
76 } | |
77 } | |
78 | |
79 | |
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 | 82 t->satb_mark_queue().handle_zero_index(); |
83 } | |
84 | |
85 void SATBMarkQueueSet::set_active_all_threads(bool b) { | |
86 _all_active = b; | |
87 for(JavaThread* t = Threads::first(); t; t = t->next()) { | |
88 t->satb_mark_queue().set_active(b); | |
89 } | |
90 } | |
91 | |
92 void SATBMarkQueueSet::set_closure(ObjectClosure* closure) { | |
93 _closure = closure; | |
94 } | |
95 | |
96 void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { | |
97 assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); | |
98 _par_closures[i] = par_closure; | |
99 } | |
100 | |
101 void SATBMarkQueueSet::iterate_closure_all_threads() { | |
102 for(JavaThread* t = Threads::first(); t; t = t->next()) { | |
103 t->satb_mark_queue().apply_closure(_closure); | |
104 } | |
105 shared_satb_queue()->apply_closure(_closure); | |
106 } | |
107 | |
108 void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) { | |
109 SharedHeap* sh = SharedHeap::heap(); | |
110 int parity = sh->strong_roots_parity(); | |
111 | |
112 for(JavaThread* t = Threads::first(); t; t = t->next()) { | |
113 if (t->claim_oops_do(true, parity)) { | |
114 t->satb_mark_queue().apply_closure(_par_closures[worker]); | |
115 } | |
116 } | |
117 // We'll have worker 0 do this one. | |
118 if (worker == 0) { | |
119 shared_satb_queue()->apply_closure(_par_closures[0]); | |
120 } | |
121 } | |
122 | |
123 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, | |
124 int worker) { | |
1111 | 125 BufferNode* nd = NULL; |
342 | 126 { |
127 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); | |
128 if (_completed_buffers_head != NULL) { | |
129 nd = _completed_buffers_head; | |
1111 | 130 _completed_buffers_head = nd->next(); |
342 | 131 if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; |
132 _n_completed_buffers--; | |
133 if (_n_completed_buffers == 0) _process_completed = false; | |
134 } | |
135 } | |
136 ObjectClosure* cl = (par ? _par_closures[worker] : _closure); | |
137 if (nd != NULL) { | |
1111 | 138 void **buf = BufferNode::make_buffer_from_node(nd); |
139 ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); | |
140 deallocate_buffer(buf); | |
342 | 141 return true; |
142 } else { | |
143 return false; | |
144 } | |
145 } | |
146 | |
147 void SATBMarkQueueSet::abandon_partial_marking() { | |
1111 | 148 BufferNode* buffers_to_delete = NULL; |
342 | 149 { |
150 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); | |
151 while (_completed_buffers_head != NULL) { | |
1111 | 152 BufferNode* nd = _completed_buffers_head; |
153 _completed_buffers_head = nd->next(); | |
154 nd->set_next(buffers_to_delete); | |
342 | 155 buffers_to_delete = nd; |
156 } | |
157 _completed_buffers_tail = NULL; | |
158 _n_completed_buffers = 0; | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
159 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
342 | 160 } |
161 while (buffers_to_delete != NULL) { | |
1111 | 162 BufferNode* nd = buffers_to_delete; |
163 buffers_to_delete = nd->next(); | |
164 deallocate_buffer(BufferNode::make_buffer_from_node(nd)); | |
342 | 165 } |
166 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); | |
167 // So we can safely manipulate these queues. | |
168 for (JavaThread* t = Threads::first(); t; t = t->next()) { | |
169 t->satb_mark_queue().reset(); | |
170 } | |
171 shared_satb_queue()->reset(); | |
172 } |