src/share/vm/memory/generationSpec.cpp

Wed, 18 Jan 2012 09:50:16 -0800

author
johnc
date
Wed, 18 Jan 2012 09:50:16 -0800
changeset 3538
d903bf750e9f
parent 2314
f95d63e2154a
child 3730
9f059abe8cf2
permissions
-rw-r--r--

7129514: time warp warnings after 7117303
Summary: Replace calls to os::javaTimeMillis() that are used to update the milliseconds since the last GC to an equivalent that uses a monotonically non-decreasing time source.
Reviewed-by: ysr, jmasa

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "memory/compactPermGen.hpp"
stefank@2314 27 #include "memory/defNewGeneration.hpp"
stefank@2314 28 #include "memory/filemap.hpp"
stefank@2314 29 #include "memory/genRemSet.hpp"
stefank@2314 30 #include "memory/generationSpec.hpp"
stefank@2314 31 #include "memory/tenuredGeneration.hpp"
stefank@2314 32 #include "runtime/java.hpp"
stefank@2314 33 #ifndef SERIALGC
stefank@2314 34 #include "gc_implementation/concurrentMarkSweep/cmsPermGen.hpp"
stefank@2314 35 #include "gc_implementation/parNew/asParNewGeneration.hpp"
stefank@2314 36 #include "gc_implementation/parNew/parNewGeneration.hpp"
stefank@2314 37 #endif
duke@435 38
duke@435 39 Generation* GenerationSpec::init(ReservedSpace rs, int level,
duke@435 40 GenRemSet* remset) {
duke@435 41 switch (name()) {
duke@435 42 case Generation::DefNew:
duke@435 43 return new DefNewGeneration(rs, init_size(), level);
duke@435 44
duke@435 45 case Generation::MarkSweepCompact:
duke@435 46 return new TenuredGeneration(rs, init_size(), level, remset);
duke@435 47
duke@435 48 #ifndef SERIALGC
duke@435 49 case Generation::ParNew:
duke@435 50 return new ParNewGeneration(rs, init_size(), level);
duke@435 51
duke@435 52 case Generation::ASParNew:
duke@435 53 return new ASParNewGeneration(rs,
duke@435 54 init_size(),
duke@435 55 init_size() /* min size */,
duke@435 56 level);
duke@435 57
duke@435 58 case Generation::ConcurrentMarkSweep: {
duke@435 59 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
duke@435 60 CardTableRS* ctrs = remset->as_CardTableRS();
duke@435 61 if (ctrs == NULL) {
duke@435 62 vm_exit_during_initialization("Rem set incompatibility.");
duke@435 63 }
duke@435 64 // Otherwise
duke@435 65 // The constructor creates the CMSCollector if needed,
duke@435 66 // else registers with an existing CMSCollector
duke@435 67
duke@435 68 ConcurrentMarkSweepGeneration* g = NULL;
duke@435 69 g = new ConcurrentMarkSweepGeneration(rs,
duke@435 70 init_size(), level, ctrs, UseCMSAdaptiveFreeLists,
duke@435 71 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
duke@435 72
duke@435 73 g->initialize_performance_counters();
duke@435 74
duke@435 75 return g;
duke@435 76 }
duke@435 77
duke@435 78 case Generation::ASConcurrentMarkSweep: {
duke@435 79 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
duke@435 80 CardTableRS* ctrs = remset->as_CardTableRS();
duke@435 81 if (ctrs == NULL) {
duke@435 82 vm_exit_during_initialization("Rem set incompatibility.");
duke@435 83 }
duke@435 84 // Otherwise
duke@435 85 // The constructor creates the CMSCollector if needed,
duke@435 86 // else registers with an existing CMSCollector
duke@435 87
duke@435 88 ASConcurrentMarkSweepGeneration* g = NULL;
duke@435 89 g = new ASConcurrentMarkSweepGeneration(rs,
duke@435 90 init_size(), level, ctrs, UseCMSAdaptiveFreeLists,
duke@435 91 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
duke@435 92
duke@435 93 g->initialize_performance_counters();
duke@435 94
duke@435 95 return g;
duke@435 96 }
duke@435 97 #endif // SERIALGC
duke@435 98
duke@435 99 default:
duke@435 100 guarantee(false, "unrecognized GenerationName");
duke@435 101 return NULL;
duke@435 102 }
duke@435 103 }
duke@435 104
duke@435 105
duke@435 106 PermanentGenerationSpec::PermanentGenerationSpec(PermGen::Name name,
duke@435 107 size_t init_size, size_t max_size,
duke@435 108 size_t read_only_size, size_t read_write_size,
duke@435 109 size_t misc_data_size, size_t misc_code_size) {
duke@435 110 _name = name;
duke@435 111 _init_size = init_size;
duke@435 112
duke@435 113 if (UseSharedSpaces || DumpSharedSpaces) {
duke@435 114 _enable_shared_spaces = true;
duke@435 115 if (UseSharedSpaces) {
duke@435 116 // Override shared space sizes from those in the file.
duke@435 117 FileMapInfo* mapinfo = FileMapInfo::current_info();
duke@435 118 _read_only_size = mapinfo->space_capacity(CompactingPermGenGen::ro);
duke@435 119 _read_write_size = mapinfo->space_capacity(CompactingPermGenGen::rw);
duke@435 120 _misc_data_size = mapinfo->space_capacity(CompactingPermGenGen::md);
duke@435 121 _misc_code_size = mapinfo->space_capacity(CompactingPermGenGen::mc);
duke@435 122 } else {
duke@435 123 _read_only_size = read_only_size;
duke@435 124 _read_write_size = read_write_size;
duke@435 125 _misc_data_size = misc_data_size;
duke@435 126 _misc_code_size = misc_code_size;
duke@435 127 }
duke@435 128 } else {
duke@435 129 _enable_shared_spaces = false;
duke@435 130 _read_only_size = 0;
duke@435 131 _read_write_size = 0;
duke@435 132 _misc_data_size = 0;
duke@435 133 _misc_code_size = 0;
duke@435 134 }
duke@435 135
duke@435 136 _max_size = max_size;
duke@435 137 }
duke@435 138
duke@435 139
duke@435 140 PermGen* PermanentGenerationSpec::init(ReservedSpace rs,
duke@435 141 size_t init_size,
duke@435 142 GenRemSet *remset) {
duke@435 143
duke@435 144 // Break the reserved spaces into pieces for the permanent space
duke@435 145 // and the shared spaces.
duke@435 146 ReservedSpace perm_rs = rs.first_part(_max_size, UseSharedSpaces,
duke@435 147 UseSharedSpaces);
duke@435 148 ReservedSpace shared_rs = rs.last_part(_max_size);
duke@435 149
duke@435 150 if (enable_shared_spaces()) {
duke@435 151 if (!perm_rs.is_reserved() ||
duke@435 152 perm_rs.base() + perm_rs.size() != shared_rs.base()) {
duke@435 153 FileMapInfo* mapinfo = FileMapInfo::current_info();
duke@435 154 mapinfo->fail_continue("Sharing disabled - unable to "
duke@435 155 "reserve address space.");
duke@435 156 shared_rs.release();
duke@435 157 disable_sharing();
duke@435 158 }
duke@435 159 }
duke@435 160
duke@435 161 switch (name()) {
duke@435 162 case PermGen::MarkSweepCompact:
duke@435 163 return new CompactingPermGen(perm_rs, shared_rs, init_size, remset, this);
duke@435 164
duke@435 165 #ifndef SERIALGC
duke@435 166 case PermGen::MarkSweep:
duke@435 167 guarantee(false, "NYI");
duke@435 168 return NULL;
duke@435 169
duke@435 170 case PermGen::ConcurrentMarkSweep: {
duke@435 171 assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set");
duke@435 172 CardTableRS* ctrs = remset->as_CardTableRS();
duke@435 173 if (ctrs == NULL) {
duke@435 174 vm_exit_during_initialization("RemSet/generation incompatibility.");
duke@435 175 }
duke@435 176 // XXXPERM
duke@435 177 return new CMSPermGen(perm_rs, init_size, ctrs,
duke@435 178 (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice);
duke@435 179 }
duke@435 180 #endif // SERIALGC
duke@435 181 default:
duke@435 182 guarantee(false, "unrecognized GenerationName");
duke@435 183 return NULL;
duke@435 184 }
duke@435 185 }
duke@435 186
duke@435 187
duke@435 188 // Alignment
duke@435 189 void PermanentGenerationSpec::align(size_t alignment) {
duke@435 190 _init_size = align_size_up(_init_size, alignment);
duke@435 191 _max_size = align_size_up(_max_size, alignment);
duke@435 192 _read_only_size = align_size_up(_read_only_size, alignment);
duke@435 193 _read_write_size = align_size_up(_read_write_size, alignment);
duke@435 194 _misc_data_size = align_size_up(_misc_data_size, alignment);
duke@435 195 _misc_code_size = align_size_up(_misc_code_size, alignment);
duke@435 196
duke@435 197 assert(enable_shared_spaces() || (_read_only_size + _read_write_size == 0),
duke@435 198 "Shared space when disabled?");
duke@435 199 }

mercurial