Thu, 12 Jun 2008 13:50:55 -0700
Merge
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 2001-2005 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | # include "incls/_precompiled.incl" |
duke@435 | 26 | # include "incls/_generationSpec.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | Generation* GenerationSpec::init(ReservedSpace rs, int level, |
duke@435 | 29 | GenRemSet* remset) { |
duke@435 | 30 | switch (name()) { |
duke@435 | 31 | case Generation::DefNew: |
duke@435 | 32 | return new DefNewGeneration(rs, init_size(), level); |
duke@435 | 33 | |
duke@435 | 34 | case Generation::MarkSweepCompact: |
duke@435 | 35 | return new TenuredGeneration(rs, init_size(), level, remset); |
duke@435 | 36 | |
duke@435 | 37 | #ifndef SERIALGC |
duke@435 | 38 | case Generation::ParNew: |
duke@435 | 39 | return new ParNewGeneration(rs, init_size(), level); |
duke@435 | 40 | |
duke@435 | 41 | case Generation::ASParNew: |
duke@435 | 42 | return new ASParNewGeneration(rs, |
duke@435 | 43 | init_size(), |
duke@435 | 44 | init_size() /* min size */, |
duke@435 | 45 | level); |
duke@435 | 46 | |
duke@435 | 47 | case Generation::ConcurrentMarkSweep: { |
duke@435 | 48 | assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); |
duke@435 | 49 | CardTableRS* ctrs = remset->as_CardTableRS(); |
duke@435 | 50 | if (ctrs == NULL) { |
duke@435 | 51 | vm_exit_during_initialization("Rem set incompatibility."); |
duke@435 | 52 | } |
duke@435 | 53 | // Otherwise |
duke@435 | 54 | // The constructor creates the CMSCollector if needed, |
duke@435 | 55 | // else registers with an existing CMSCollector |
duke@435 | 56 | |
duke@435 | 57 | ConcurrentMarkSweepGeneration* g = NULL; |
duke@435 | 58 | g = new ConcurrentMarkSweepGeneration(rs, |
duke@435 | 59 | init_size(), level, ctrs, UseCMSAdaptiveFreeLists, |
duke@435 | 60 | (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); |
duke@435 | 61 | |
duke@435 | 62 | g->initialize_performance_counters(); |
duke@435 | 63 | |
duke@435 | 64 | return g; |
duke@435 | 65 | } |
duke@435 | 66 | |
duke@435 | 67 | case Generation::ASConcurrentMarkSweep: { |
duke@435 | 68 | assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); |
duke@435 | 69 | CardTableRS* ctrs = remset->as_CardTableRS(); |
duke@435 | 70 | if (ctrs == NULL) { |
duke@435 | 71 | vm_exit_during_initialization("Rem set incompatibility."); |
duke@435 | 72 | } |
duke@435 | 73 | // Otherwise |
duke@435 | 74 | // The constructor creates the CMSCollector if needed, |
duke@435 | 75 | // else registers with an existing CMSCollector |
duke@435 | 76 | |
duke@435 | 77 | ASConcurrentMarkSweepGeneration* g = NULL; |
duke@435 | 78 | g = new ASConcurrentMarkSweepGeneration(rs, |
duke@435 | 79 | init_size(), level, ctrs, UseCMSAdaptiveFreeLists, |
duke@435 | 80 | (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); |
duke@435 | 81 | |
duke@435 | 82 | g->initialize_performance_counters(); |
duke@435 | 83 | |
duke@435 | 84 | return g; |
duke@435 | 85 | } |
duke@435 | 86 | #endif // SERIALGC |
duke@435 | 87 | |
duke@435 | 88 | default: |
duke@435 | 89 | guarantee(false, "unrecognized GenerationName"); |
duke@435 | 90 | return NULL; |
duke@435 | 91 | } |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | |
duke@435 | 95 | PermanentGenerationSpec::PermanentGenerationSpec(PermGen::Name name, |
duke@435 | 96 | size_t init_size, size_t max_size, |
duke@435 | 97 | size_t read_only_size, size_t read_write_size, |
duke@435 | 98 | size_t misc_data_size, size_t misc_code_size) { |
duke@435 | 99 | _name = name; |
duke@435 | 100 | _init_size = init_size; |
duke@435 | 101 | |
duke@435 | 102 | if (UseSharedSpaces || DumpSharedSpaces) { |
duke@435 | 103 | _enable_shared_spaces = true; |
duke@435 | 104 | if (UseSharedSpaces) { |
duke@435 | 105 | // Override shared space sizes from those in the file. |
duke@435 | 106 | FileMapInfo* mapinfo = FileMapInfo::current_info(); |
duke@435 | 107 | _read_only_size = mapinfo->space_capacity(CompactingPermGenGen::ro); |
duke@435 | 108 | _read_write_size = mapinfo->space_capacity(CompactingPermGenGen::rw); |
duke@435 | 109 | _misc_data_size = mapinfo->space_capacity(CompactingPermGenGen::md); |
duke@435 | 110 | _misc_code_size = mapinfo->space_capacity(CompactingPermGenGen::mc); |
duke@435 | 111 | } else { |
duke@435 | 112 | _read_only_size = read_only_size; |
duke@435 | 113 | _read_write_size = read_write_size; |
duke@435 | 114 | _misc_data_size = misc_data_size; |
duke@435 | 115 | _misc_code_size = misc_code_size; |
duke@435 | 116 | } |
duke@435 | 117 | } else { |
duke@435 | 118 | _enable_shared_spaces = false; |
duke@435 | 119 | _read_only_size = 0; |
duke@435 | 120 | _read_write_size = 0; |
duke@435 | 121 | _misc_data_size = 0; |
duke@435 | 122 | _misc_code_size = 0; |
duke@435 | 123 | } |
duke@435 | 124 | |
duke@435 | 125 | _max_size = max_size; |
duke@435 | 126 | } |
duke@435 | 127 | |
duke@435 | 128 | |
duke@435 | 129 | PermGen* PermanentGenerationSpec::init(ReservedSpace rs, |
duke@435 | 130 | size_t init_size, |
duke@435 | 131 | GenRemSet *remset) { |
duke@435 | 132 | |
duke@435 | 133 | // Break the reserved spaces into pieces for the permanent space |
duke@435 | 134 | // and the shared spaces. |
duke@435 | 135 | ReservedSpace perm_rs = rs.first_part(_max_size, UseSharedSpaces, |
duke@435 | 136 | UseSharedSpaces); |
duke@435 | 137 | ReservedSpace shared_rs = rs.last_part(_max_size); |
duke@435 | 138 | |
duke@435 | 139 | if (enable_shared_spaces()) { |
duke@435 | 140 | if (!perm_rs.is_reserved() || |
duke@435 | 141 | perm_rs.base() + perm_rs.size() != shared_rs.base()) { |
duke@435 | 142 | FileMapInfo* mapinfo = FileMapInfo::current_info(); |
duke@435 | 143 | mapinfo->fail_continue("Sharing disabled - unable to " |
duke@435 | 144 | "reserve address space."); |
duke@435 | 145 | shared_rs.release(); |
duke@435 | 146 | disable_sharing(); |
duke@435 | 147 | } |
duke@435 | 148 | } |
duke@435 | 149 | |
duke@435 | 150 | switch (name()) { |
duke@435 | 151 | case PermGen::MarkSweepCompact: |
duke@435 | 152 | return new CompactingPermGen(perm_rs, shared_rs, init_size, remset, this); |
duke@435 | 153 | |
duke@435 | 154 | #ifndef SERIALGC |
duke@435 | 155 | case PermGen::MarkSweep: |
duke@435 | 156 | guarantee(false, "NYI"); |
duke@435 | 157 | return NULL; |
duke@435 | 158 | |
duke@435 | 159 | case PermGen::ConcurrentMarkSweep: { |
duke@435 | 160 | assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); |
duke@435 | 161 | CardTableRS* ctrs = remset->as_CardTableRS(); |
duke@435 | 162 | if (ctrs == NULL) { |
duke@435 | 163 | vm_exit_during_initialization("RemSet/generation incompatibility."); |
duke@435 | 164 | } |
duke@435 | 165 | // XXXPERM |
duke@435 | 166 | return new CMSPermGen(perm_rs, init_size, ctrs, |
duke@435 | 167 | (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); |
duke@435 | 168 | } |
duke@435 | 169 | #endif // SERIALGC |
duke@435 | 170 | default: |
duke@435 | 171 | guarantee(false, "unrecognized GenerationName"); |
duke@435 | 172 | return NULL; |
duke@435 | 173 | } |
duke@435 | 174 | } |
duke@435 | 175 | |
duke@435 | 176 | |
duke@435 | 177 | // Alignment |
duke@435 | 178 | void PermanentGenerationSpec::align(size_t alignment) { |
duke@435 | 179 | _init_size = align_size_up(_init_size, alignment); |
duke@435 | 180 | _max_size = align_size_up(_max_size, alignment); |
duke@435 | 181 | _read_only_size = align_size_up(_read_only_size, alignment); |
duke@435 | 182 | _read_write_size = align_size_up(_read_write_size, alignment); |
duke@435 | 183 | _misc_data_size = align_size_up(_misc_data_size, alignment); |
duke@435 | 184 | _misc_code_size = align_size_up(_misc_code_size, alignment); |
duke@435 | 185 | |
duke@435 | 186 | assert(enable_shared_spaces() || (_read_only_size + _read_write_size == 0), |
duke@435 | 187 | "Shared space when disabled?"); |
duke@435 | 188 | } |