duke@435: /* duke@435: * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: # include "incls/_precompiled.incl" duke@435: # include "incls/_generationSpec.cpp.incl" duke@435: duke@435: Generation* GenerationSpec::init(ReservedSpace rs, int level, duke@435: GenRemSet* remset) { duke@435: switch (name()) { duke@435: case Generation::DefNew: duke@435: return new DefNewGeneration(rs, init_size(), level); duke@435: duke@435: case Generation::MarkSweepCompact: duke@435: return new TenuredGeneration(rs, init_size(), level, remset); duke@435: duke@435: #ifndef SERIALGC duke@435: case Generation::ParNew: duke@435: return new ParNewGeneration(rs, init_size(), level); duke@435: duke@435: case Generation::ASParNew: duke@435: return new ASParNewGeneration(rs, duke@435: init_size(), duke@435: init_size() /* min size */, duke@435: level); duke@435: duke@435: case Generation::ConcurrentMarkSweep: { duke@435: assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); duke@435: CardTableRS* ctrs = remset->as_CardTableRS(); duke@435: if (ctrs == NULL) { duke@435: vm_exit_during_initialization("Rem set incompatibility."); duke@435: } duke@435: // Otherwise duke@435: // The constructor creates the CMSCollector if needed, duke@435: // else registers with an existing CMSCollector duke@435: duke@435: ConcurrentMarkSweepGeneration* g = NULL; duke@435: g = new ConcurrentMarkSweepGeneration(rs, duke@435: init_size(), level, ctrs, UseCMSAdaptiveFreeLists, duke@435: (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); duke@435: duke@435: g->initialize_performance_counters(); duke@435: duke@435: return g; duke@435: } duke@435: duke@435: case Generation::ASConcurrentMarkSweep: { duke@435: assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); duke@435: CardTableRS* ctrs = remset->as_CardTableRS(); duke@435: if (ctrs == NULL) { duke@435: vm_exit_during_initialization("Rem set incompatibility."); duke@435: } duke@435: // Otherwise duke@435: // The constructor creates the CMSCollector if needed, duke@435: // else registers with an existing CMSCollector duke@435: duke@435: ASConcurrentMarkSweepGeneration* g = NULL; duke@435: g = new ASConcurrentMarkSweepGeneration(rs, duke@435: init_size(), level, ctrs, UseCMSAdaptiveFreeLists, duke@435: (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); duke@435: duke@435: g->initialize_performance_counters(); duke@435: duke@435: return g; duke@435: } duke@435: #endif // SERIALGC duke@435: duke@435: default: duke@435: guarantee(false, "unrecognized GenerationName"); duke@435: return NULL; duke@435: } duke@435: } duke@435: duke@435: duke@435: PermanentGenerationSpec::PermanentGenerationSpec(PermGen::Name name, duke@435: size_t init_size, size_t max_size, duke@435: size_t read_only_size, size_t read_write_size, duke@435: size_t misc_data_size, size_t misc_code_size) { duke@435: _name = name; duke@435: _init_size = init_size; duke@435: duke@435: if (UseSharedSpaces || DumpSharedSpaces) { duke@435: _enable_shared_spaces = true; duke@435: if (UseSharedSpaces) { duke@435: // Override shared space sizes from those in the file. duke@435: FileMapInfo* mapinfo = FileMapInfo::current_info(); duke@435: _read_only_size = mapinfo->space_capacity(CompactingPermGenGen::ro); duke@435: _read_write_size = mapinfo->space_capacity(CompactingPermGenGen::rw); duke@435: _misc_data_size = mapinfo->space_capacity(CompactingPermGenGen::md); duke@435: _misc_code_size = mapinfo->space_capacity(CompactingPermGenGen::mc); duke@435: } else { duke@435: _read_only_size = read_only_size; duke@435: _read_write_size = read_write_size; duke@435: _misc_data_size = misc_data_size; duke@435: _misc_code_size = misc_code_size; duke@435: } duke@435: } else { duke@435: _enable_shared_spaces = false; duke@435: _read_only_size = 0; duke@435: _read_write_size = 0; duke@435: _misc_data_size = 0; duke@435: _misc_code_size = 0; duke@435: } duke@435: duke@435: _max_size = max_size; duke@435: } duke@435: duke@435: duke@435: PermGen* PermanentGenerationSpec::init(ReservedSpace rs, duke@435: size_t init_size, duke@435: GenRemSet *remset) { duke@435: duke@435: // Break the reserved spaces into pieces for the permanent space duke@435: // and the shared spaces. duke@435: ReservedSpace perm_rs = rs.first_part(_max_size, UseSharedSpaces, duke@435: UseSharedSpaces); duke@435: ReservedSpace shared_rs = rs.last_part(_max_size); duke@435: duke@435: if (enable_shared_spaces()) { duke@435: if (!perm_rs.is_reserved() || duke@435: perm_rs.base() + perm_rs.size() != shared_rs.base()) { duke@435: FileMapInfo* mapinfo = FileMapInfo::current_info(); duke@435: mapinfo->fail_continue("Sharing disabled - unable to " duke@435: "reserve address space."); duke@435: shared_rs.release(); duke@435: disable_sharing(); duke@435: } duke@435: } duke@435: duke@435: switch (name()) { duke@435: case PermGen::MarkSweepCompact: duke@435: return new CompactingPermGen(perm_rs, shared_rs, init_size, remset, this); duke@435: duke@435: #ifndef SERIALGC duke@435: case PermGen::MarkSweep: duke@435: guarantee(false, "NYI"); duke@435: return NULL; duke@435: duke@435: case PermGen::ConcurrentMarkSweep: { duke@435: assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); duke@435: CardTableRS* ctrs = remset->as_CardTableRS(); duke@435: if (ctrs == NULL) { duke@435: vm_exit_during_initialization("RemSet/generation incompatibility."); duke@435: } duke@435: // XXXPERM duke@435: return new CMSPermGen(perm_rs, init_size, ctrs, duke@435: (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); duke@435: } duke@435: #endif // SERIALGC duke@435: default: duke@435: guarantee(false, "unrecognized GenerationName"); duke@435: return NULL; duke@435: } duke@435: } duke@435: duke@435: duke@435: // Alignment duke@435: void PermanentGenerationSpec::align(size_t alignment) { duke@435: _init_size = align_size_up(_init_size, alignment); duke@435: _max_size = align_size_up(_max_size, alignment); duke@435: _read_only_size = align_size_up(_read_only_size, alignment); duke@435: _read_write_size = align_size_up(_read_write_size, alignment); duke@435: _misc_data_size = align_size_up(_misc_data_size, alignment); duke@435: _misc_code_size = align_size_up(_misc_code_size, alignment); duke@435: duke@435: assert(enable_shared_spaces() || (_read_only_size + _read_write_size == 0), duke@435: "Shared space when disabled?"); duke@435: }