annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.cpp @ 2149:7e37af9d69ef

7011379: G1: overly long concurrent marking cycles Summary: This changeset introduces filtering of SATB buffers at the point when they are about to be enqueued. If this filtering clears enough entries on each buffer, the buffer can then be re-used and not enqueued. This cuts down the number of SATB buffers that need to be processed by the concurrent marking threads. Reviewed-by: johnc, ysr
author tonyp
date Wed, 19 Jan 2011 09:35:17 -0500
parents f95d63e2154a
children c63b928b212b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 196
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: 196
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/parallelScavenge/psPromotionLAB.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/shared/mutableSpace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
31 size_t PSPromotionLAB::filler_header_size;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // This is the shared initialization code. It sets up the basic pointers,
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // and allows enough extra space for a filler object. We call a virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // method, "lab_is_valid()" to handle the different asserts the old/young
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // labs require.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 void PSPromotionLAB::initialize(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 assert(lab_is_valid(lab), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 HeapWord* bottom = lab.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 HeapWord* end = lab.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 set_bottom(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 set_end(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 set_top(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
46
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
47 // Initialize after VM starts up because header_size depends on compressed
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
48 // oops.
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
49 filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
50
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // We can be initialized to a zero size!
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if (free() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (ZapUnusedHeapArea) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // NOTE! We need to allow space for a filler object.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 assert(lab.word_size() >= filler_header_size, "lab is too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 end = end - filler_header_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 set_end(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _state = needs_flush;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _state = zero_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 assert(this->top() <= this->end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Fill all remaining lab space with an unreachable object.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // The goal is to leave a contiguous parseable span of objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void PSPromotionLAB::flush() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 assert(_state != flushed, "Attempt to flush PLAB twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert(top() <= end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // If we were initialized to a zero sized lab, there is
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // nothing to flush
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (_state == zero_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // PLAB's never allocate the last aligned_header_size
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // so they can always fill with an array.
a61af66fc99e Initial load
duke
parents:
diff changeset
83 HeapWord* tlab_end = end() + filler_header_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 typeArrayOop filler_oop = (typeArrayOop) top();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 filler_oop->set_mark(markOopDesc::prototype());
a61af66fc99e Initial load
duke
parents:
diff changeset
86 filler_oop->set_klass(Universe::intArrayKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
87 const size_t array_length =
a61af66fc99e Initial load
duke
parents:
diff changeset
88 pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Note that we actually DO NOT want to use the aligned header size!
a61af66fc99e Initial load
duke
parents:
diff changeset
94 HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 set_bottom(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 set_end(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 set_top(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _state = flushed;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool PSPromotionLAB::unallocate_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(Universe::heap()->is_in(obj), "Object outside heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (contains(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 HeapWord* object_end = (HeapWord*)obj + obj->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert(object_end <= top(), "Object crosses promotion LAB boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (object_end == top()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 set_top((HeapWord*)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Fill all remaining lab space with an unreachable object.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // The goal is to leave a contiguous parseable span of objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 void PSOldPromotionLAB::flush() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 assert(_state != flushed, "Attempt to flush PLAB twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(top() <= end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 if (_state == zero_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 HeapWord* obj = top();
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 PSPromotionLAB::flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert(_start_array != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 _start_array->allocate_block(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 MutableSpace* to_space = heap->young_gen()->to_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 MemRegion used = to_space->used_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 if (used.contains(lab)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 assert(_start_array->covered_region().contains(lab), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 PSOldGen* old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 MemRegion used = old_gen->object_space()->used_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (used.contains(lab)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 #endif /* ASSERT */