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