hotspot/src/share/vm/memory/compactingPermGenGen.cpp
CompactingPermGenGen::CompactingPermGenGen(ReservedSpace rs,
ReservedSpace shared_rs,
size_t initial_byte_size,
int level, GenRemSet* remset,
ContiguousSpace* space,
PermanentGenerationSpec* spec_) :
{- -------------------------------------------
(1) スーパークラスの初期化
---------------------------------------- -}
OneContigSpaceCardGeneration(rs, initial_byte_size, MinPermHeapExpansion,
level, remset, space) {
{- -------------------------------------------
(1) フィールドの初期化
---------------------------------------- -}
set_spec(spec_);
if (!UseSharedSpaces && !DumpSharedSpaces) {
spec()->disable_sharing();
}
// Break virtual space into address ranges for all spaces.
if (spec()->enable_shared_spaces()) {
shared_end = (HeapWord*)(shared_rs.base() + shared_rs.size());
misccode_end = shared_end;
misccode_bottom = misccode_end - heap_word_size(spec()->misc_code_size());
miscdata_end = misccode_bottom;
miscdata_bottom = miscdata_end - heap_word_size(spec()->misc_data_size());
readwrite_end = miscdata_bottom;
readwrite_bottom =
readwrite_end - heap_word_size(spec()->read_write_size());
readonly_end = readwrite_bottom;
readonly_bottom =
readonly_end - heap_word_size(spec()->read_only_size());
shared_bottom = readonly_bottom;
unshared_end = shared_bottom;
assert((char*)shared_bottom == shared_rs.base(), "shared space mismatch");
} else {
shared_end = (HeapWord*)(rs.base() + rs.size());
misccode_end = shared_end;
misccode_bottom = shared_end;
miscdata_end = shared_end;
miscdata_bottom = shared_end;
readwrite_end = shared_end;
readwrite_bottom = shared_end;
readonly_end = shared_end;
readonly_bottom = shared_end;
shared_bottom = shared_end;
unshared_end = shared_bottom;
}
unshared_bottom = (HeapWord*) rs.base();
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
// Verify shared and unshared spaces adjacent.
assert((char*)shared_bottom == rs.base()+rs.size(), "shared space mismatch");
assert(unshared_end > unshared_bottom, "shared space mismatch");
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
// Split reserved memory into pieces.
ReservedSpace ro_rs = shared_rs.first_part(spec()->read_only_size(),
UseSharedSpaces);
ReservedSpace tmp_rs1 = shared_rs.last_part(spec()->read_only_size());
ReservedSpace rw_rs = tmp_rs1.first_part(spec()->read_write_size(),
UseSharedSpaces);
ReservedSpace tmp_rs2 = tmp_rs1.last_part(spec()->read_write_size());
ReservedSpace md_rs = tmp_rs2.first_part(spec()->misc_data_size(),
UseSharedSpaces);
ReservedSpace mc_rs = tmp_rs2.last_part(spec()->misc_data_size());
{- -------------------------------------------
(1) フィールドの初期化
---------------------------------------- -}
_shared_space_size = spec()->read_only_size()
+ spec()->read_write_size()
+ spec()->misc_data_size()
+ spec()->misc_code_size();
// Allocate the unshared (default) space.
_the_space = new ContigPermSpace(_bts,
MemRegion(unshared_bottom, heap_word_size(initial_byte_size)));
if (_the_space == NULL)
vm_exit_during_initialization("Could not allocate an unshared"
" CompactingPermGen Space");
// Allocate shared spaces
if (spec()->enable_shared_spaces()) {
// If mapping a shared file, the space is not committed, don't
// mangle.
NOT_PRODUCT(bool old_ZapUnusedHeapArea = ZapUnusedHeapArea;)
NOT_PRODUCT(if (UseSharedSpaces) ZapUnusedHeapArea = false;)
// Commit the memory behind the shared spaces if dumping (not
// mapping).
if (DumpSharedSpaces) {
_ro_vs.initialize(ro_rs, spec()->read_only_size());
_rw_vs.initialize(rw_rs, spec()->read_write_size());
_md_vs.initialize(md_rs, spec()->misc_data_size());
_mc_vs.initialize(mc_rs, spec()->misc_code_size());
}
// Allocate the shared spaces.
_ro_bts = new BlockOffsetSharedArray(
MemRegion(readonly_bottom,
heap_word_size(spec()->read_only_size())),
heap_word_size(spec()->read_only_size()));
_ro_space = new OffsetTableContigSpace(_ro_bts,
MemRegion(readonly_bottom, readonly_end));
_rw_bts = new BlockOffsetSharedArray(
MemRegion(readwrite_bottom,
heap_word_size(spec()->read_write_size())),
heap_word_size(spec()->read_write_size()));
_rw_space = new OffsetTableContigSpace(_rw_bts,
MemRegion(readwrite_bottom, readwrite_end));
// Restore mangling flag.
NOT_PRODUCT(ZapUnusedHeapArea = old_ZapUnusedHeapArea;)
if (_ro_space == NULL || _rw_space == NULL)
vm_exit_during_initialization("Could not allocate a shared space");
// Cover both shared spaces entirely with cards.
_rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end));
if (UseSharedSpaces) {
// Map in the regions in the shared file.
FileMapInfo* mapinfo = FileMapInfo::current_info();
size_t image_alignment = mapinfo->alignment();
CollectedHeap* ch = Universe::heap();
if ((!mapinfo->map_space(ro, ro_rs, _ro_space)) ||
(!mapinfo->map_space(rw, rw_rs, _rw_space)) ||
(!mapinfo->map_space(md, md_rs, NULL)) ||
(!mapinfo->map_space(mc, mc_rs, NULL)) ||
// check the alignment constraints
(ch == NULL || ch->kind() != CollectedHeap::GenCollectedHeap ||
image_alignment !=
((GenCollectedHeap*)ch)->gen_policy()->max_alignment())) {
// Base addresses didn't match; skip sharing, but continue
shared_rs.release();
spec()->disable_sharing();
// If -Xshare:on is specified, print out the error message and exit VM,
// otherwise, set UseSharedSpaces to false and continue.
if (RequireSharedSpaces) {
vm_exit_during_initialization("Unable to use shared archive.", NULL);
} else {
FLAG_SET_DEFAULT(UseSharedSpaces, false);
}
// Note: freeing the block offset array objects does not
// currently free up the underlying storage.
delete _ro_bts;
_ro_bts = NULL;
delete _ro_space;
_ro_space = NULL;
delete _rw_bts;
_rw_bts = NULL;
delete _rw_space;
_rw_space = NULL;
shared_end = (HeapWord*)(rs.base() + rs.size());
_rs->resize_covered_region(MemRegion(shared_bottom, shared_bottom));
}
}
// Reserved region includes shared spaces for oop.is_in_reserved().
_reserved.set_end(shared_end);
} else {
_ro_space = NULL;
_rw_space = NULL;
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.