annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.cpp @ 10:28372612af5e

6362677: Change parallel GC collector default number of parallel GC threads. Summary: Use the same default number of GC threads as used by ParNewGC and ConcMarkSweepGC (i.e., the 5/8th rule). Reviewed-by: ysr, tonyp
author jmasa
date Fri, 22 Feb 2008 17:17:14 -0800
parents a61af66fc99e
children ba764ed4b6f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_psPromotionLAB.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 const size_t PSPromotionLAB::filler_header_size = align_object_size(typeArrayOopDesc::header_size(T_INT));
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // This is the shared initialization code. It sets up the basic pointers,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // and allows enough extra space for a filler object. We call a virtual
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // method, "lab_is_valid()" to handle the different asserts the old/young
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // labs require.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 void PSPromotionLAB::initialize(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert(lab_is_valid(lab), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 HeapWord* bottom = lab.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 HeapWord* end = lab.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 set_bottom(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 set_end(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 set_top(bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // We can be initialized to a zero size!
a61af66fc99e Initial load
duke
parents:
diff changeset
45 if (free() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if (ZapUnusedHeapArea) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 debug_only(Copy::fill_to_words(top(), free()/HeapWordSize, badHeapWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // NOTE! We need to allow space for a filler object.
a61af66fc99e Initial load
duke
parents:
diff changeset
51 assert(lab.word_size() >= filler_header_size, "lab is too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 end = end - filler_header_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 set_end(end);
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _state = needs_flush;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _state = zero_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 assert(this->top() <= this->end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Fill all remaining lab space with an unreachable object.
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // The goal is to leave a contiguous parseable span of objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void PSPromotionLAB::flush() {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 assert(_state != flushed, "Attempt to flush PLAB twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 assert(top() <= end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // If we were initialized to a zero sized lab, there is
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // nothing to flush
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (_state == zero_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // PLAB's never allocate the last aligned_header_size
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // so they can always fill with an array.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 HeapWord* tlab_end = end() + filler_header_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 typeArrayOop filler_oop = (typeArrayOop) top();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 filler_oop->set_mark(markOopDesc::prototype());
a61af66fc99e Initial load
duke
parents:
diff changeset
79 filler_oop->set_klass(Universe::intArrayKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
80 const size_t array_length =
a61af66fc99e Initial load
duke
parents:
diff changeset
81 pointer_delta(tlab_end, top()) - typeArrayOopDesc::header_size(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 assert( (array_length * (HeapWordSize/sizeof(jint))) < (size_t)max_jint, "array too big in PSPromotionLAB");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 filler_oop->set_length((int)(array_length * (HeapWordSize/sizeof(jint))));
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Note that we actually DO NOT want to use the aligned header size!
a61af66fc99e Initial load
duke
parents:
diff changeset
87 HeapWord* elt_words = ((HeapWord*)filler_oop) + typeArrayOopDesc::header_size(T_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Copy::fill_to_words(elt_words, array_length, 0xDEAABABE);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 set_bottom(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 set_end(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 set_top(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _state = flushed;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 bool PSPromotionLAB::unallocate_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 assert(Universe::heap()->is_in(obj), "Object outside heap");
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (contains(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 HeapWord* object_end = (HeapWord*)obj + obj->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert(object_end <= top(), "Object crosses promotion LAB boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (object_end == top()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 set_top((HeapWord*)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Fill all remaining lab space with an unreachable object.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // The goal is to leave a contiguous parseable span of objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void PSOldPromotionLAB::flush() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 assert(_state != flushed, "Attempt to flush PLAB twice");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 assert(top() <= end(), "pointers out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (_state == zero_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 HeapWord* obj = top();
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 PSPromotionLAB::flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 assert(_start_array != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _start_array->allocate_block(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 bool PSYoungPromotionLAB::lab_is_valid(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 MutableSpace* to_space = heap->young_gen()->to_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 MemRegion used = to_space->used_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (used.contains(lab)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 bool PSOldPromotionLAB::lab_is_valid(MemRegion lab) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
149 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert(_start_array->covered_region().contains(lab), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 PSOldGen* old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
153 MemRegion used = old_gen->object_space()->used_region();
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (used.contains(lab)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 #endif /* ASSERT */