annotate src/share/vm/memory/generationSpec.cpp @ 453:c96030fff130

6684579: SoftReference processing can be made more efficient Summary: For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not. Reviewed-by: jmasa
author ysr
date Thu, 20 Nov 2008 16:56:09 -0800
parents a61af66fc99e
children c18cbe5936b8
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 2001-2005 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/_generationSpec.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 Generation* GenerationSpec::init(ReservedSpace rs, int level,
a61af66fc99e Initial load
duke
parents:
diff changeset
29 GenRemSet* remset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 switch (name()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 case Generation::DefNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 return new DefNewGeneration(rs, init_size(), level);
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 case Generation::MarkSweepCompact:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 return new TenuredGeneration(rs, init_size(), level, remset);
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
38 case Generation::ParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 return new ParNewGeneration(rs, init_size(), level);
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 case Generation::ASParNew:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return new ASParNewGeneration(rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
43 init_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
44 init_size() /* min size */,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 level);
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 case Generation::ConcurrentMarkSweep: {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
49 CardTableRS* ctrs = remset->as_CardTableRS();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (ctrs == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 vm_exit_during_initialization("Rem set incompatibility.");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Otherwise
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // The constructor creates the CMSCollector if needed,
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // else registers with an existing CMSCollector
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 ConcurrentMarkSweepGeneration* g = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 g = new ConcurrentMarkSweepGeneration(rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 init_size(), level, ctrs, UseCMSAdaptiveFreeLists,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 g->initialize_performance_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return g;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 case Generation::ASConcurrentMarkSweep: {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 CardTableRS* ctrs = remset->as_CardTableRS();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 if (ctrs == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 vm_exit_during_initialization("Rem set incompatibility.");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Otherwise
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // The constructor creates the CMSCollector if needed,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // else registers with an existing CMSCollector
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 ASConcurrentMarkSweepGeneration* g = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 g = new ASConcurrentMarkSweepGeneration(rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 init_size(), level, ctrs, UseCMSAdaptiveFreeLists,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 g->initialize_performance_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return g;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 guarantee(false, "unrecognized GenerationName");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 PermanentGenerationSpec::PermanentGenerationSpec(PermGen::Name name,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 size_t init_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 size_t read_only_size, size_t read_write_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
98 size_t misc_data_size, size_t misc_code_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 _init_size = init_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (UseSharedSpaces || DumpSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _enable_shared_spaces = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (UseSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Override shared space sizes from those in the file.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 FileMapInfo* mapinfo = FileMapInfo::current_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _read_only_size = mapinfo->space_capacity(CompactingPermGenGen::ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _read_write_size = mapinfo->space_capacity(CompactingPermGenGen::rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _misc_data_size = mapinfo->space_capacity(CompactingPermGenGen::md);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _misc_code_size = mapinfo->space_capacity(CompactingPermGenGen::mc);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _read_only_size = read_only_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 _read_write_size = read_write_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _misc_data_size = misc_data_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _misc_code_size = misc_code_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 _enable_shared_spaces = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _read_only_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _read_write_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _misc_data_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _misc_code_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 _max_size = max_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 PermGen* PermanentGenerationSpec::init(ReservedSpace rs,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 size_t init_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
131 GenRemSet *remset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Break the reserved spaces into pieces for the permanent space
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // and the shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ReservedSpace perm_rs = rs.first_part(_max_size, UseSharedSpaces,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 UseSharedSpaces);
a61af66fc99e Initial load
duke
parents:
diff changeset
137 ReservedSpace shared_rs = rs.last_part(_max_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (enable_shared_spaces()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 if (!perm_rs.is_reserved() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
141 perm_rs.base() + perm_rs.size() != shared_rs.base()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 FileMapInfo* mapinfo = FileMapInfo::current_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 mapinfo->fail_continue("Sharing disabled - unable to "
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "reserve address space.");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 shared_rs.release();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 disable_sharing();
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 switch (name()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 case PermGen::MarkSweepCompact:
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return new CompactingPermGen(perm_rs, shared_rs, init_size, remset, this);
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
155 case PermGen::MarkSweep:
a61af66fc99e Initial load
duke
parents:
diff changeset
156 guarantee(false, "NYI");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 case PermGen::ConcurrentMarkSweep: {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 CardTableRS* ctrs = remset->as_CardTableRS();
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (ctrs == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 vm_exit_during_initialization("RemSet/generation incompatibility.");
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // XXXPERM
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return new CMSPermGen(perm_rs, init_size, ctrs,
a61af66fc99e Initial load
duke
parents:
diff changeset
167 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
170 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
171 guarantee(false, "unrecognized GenerationName");
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void PermanentGenerationSpec::align(size_t alignment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 _init_size = align_size_up(_init_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 _max_size = align_size_up(_max_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _read_only_size = align_size_up(_read_only_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _read_write_size = align_size_up(_read_write_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 _misc_data_size = align_size_up(_misc_data_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 _misc_code_size = align_size_up(_misc_code_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 assert(enable_shared_spaces() || (_read_only_size + _read_write_size == 0),
a61af66fc99e Initial load
duke
parents:
diff changeset
187 "Shared space when disabled?");
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }