< prev index next >
src/share/vm/memory/filemap.cpp
Print this page
*** 467,494 ****
// than one GC regions allocated for shared strings. The first/bottom GC region might
// be a partial GC region with the empty portion at the higher address within that region.
// The non-empty portion of the first region is written into the archive as one string
// region. The rest are consecutive full GC regions if they exist, which can be written
// out in one chunk as another string region.
! void FileMapInfo::write_string_regions(GrowableArray<MemRegion> *regions) {
for (int i = MetaspaceShared::first_string;
i < MetaspaceShared::first_string + MetaspaceShared::max_strings; i++) {
char* start = NULL;
size_t size = 0;
! if (regions->is_nonempty()) {
if (i == MetaspaceShared::first_string) {
MemRegion first = regions->first();
start = (char*)first.start();
size = first.byte_size();
} else {
! int len = regions->length();
if (len > 1) {
start = (char*)regions->at(1).start();
size = (char*)regions->at(len - 1).end() - start;
}
}
}
write_region(i, start, size, false, false);
}
}
--- 467,531 ----
// than one GC regions allocated for shared strings. The first/bottom GC region might
// be a partial GC region with the empty portion at the higher address within that region.
// The non-empty portion of the first region is written into the archive as one string
// region. The rest are consecutive full GC regions if they exist, which can be written
// out in one chunk as another string region.
! //
! // Here's the mapping from (GrowableArray<MemRegion> *regions) -> (metaspace string regions).
! // + We have 1 or more heap regions: r0, r1, r2 ..... rn
! // + We have 2 metaspace string regions: s0 and s1
! //
! // If there's a single heap region (r0), then s0 == r0, and s1 is empty.
! // Otherwise:
! //
! // "X" represented space that's occupied by heap objects.
! // "_" represented unused spaced in the heap region.
! //
! //
! // |r0 | r1 | r2 | ...... | rn |
! // |XXXXXX|__ |XXXXX|XXXX|XXXXXXXX|XXXX|
! // |<-s0->| |<- s1 ----------------->|
! // ^^^
! // |
! // +-- unmapped space
! void FileMapInfo::write_string_regions(GrowableArray<MemRegion> *regions,
! char** st0_start, char** st0_top, char** st0_end,
! char** st1_start, char** st1_top, char** st1_end) {
! *st0_start = *st0_top = *st0_end = NULL;
! *st1_start = *st1_top = *st1_end = NULL;
!
! assert(MetaspaceShared::max_strings == 2, "this loop doesn't work for any other value");
for (int i = MetaspaceShared::first_string;
i < MetaspaceShared::first_string + MetaspaceShared::max_strings; i++) {
char* start = NULL;
size_t size = 0;
! int len = regions->length();
! if (len > 0) {
if (i == MetaspaceShared::first_string) {
MemRegion first = regions->first();
start = (char*)first.start();
size = first.byte_size();
+ *st0_start = start;
+ *st0_top = start + size;
+ if (len > 1) {
+ *st0_end = (char*)regions->at(1).start();
} else {
! *st0_end = start + size;
! }
! } else {
! assert(i == MetaspaceShared::first_string + 1, "must be");
if (len > 1) {
start = (char*)regions->at(1).start();
size = (char*)regions->at(len - 1).end() - start;
+ *st1_start = start;
+ *st1_top = start + size;
+ *st1_end = start + size;
}
}
}
+ log_info(cds)("String region %d " INTPTR_FORMAT " - " INTPTR_FORMAT " = " SIZE_FORMAT_W(8) " bytes",
+ i, p2i(start), p2i(start + size), size);
write_region(i, start, size, false, false);
}
}
< prev index next >