8214277: Use merged G1ArchiveRegionMap for open and closed archive heap regions
Reviewed-by: kbarrett, jiangli
This commit is contained in:
parent
682af8be65
commit
fab3122111
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -412,8 +412,7 @@ size_t G1PLABAllocator::undo_waste() const {
|
||||
}
|
||||
|
||||
bool G1ArchiveAllocator::_archive_check_enabled = false;
|
||||
G1ArchiveRegionMap G1ArchiveAllocator::_closed_archive_region_map;
|
||||
G1ArchiveRegionMap G1ArchiveAllocator::_open_archive_region_map;
|
||||
G1ArchiveRegionMap G1ArchiveAllocator::_archive_region_map;
|
||||
|
||||
G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) {
|
||||
// Create the archive allocator, and also enable archive object checking
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -203,12 +203,17 @@ public:
|
||||
void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index);
|
||||
};
|
||||
|
||||
// G1ArchiveRegionMap is a boolean array used to mark G1 regions as
|
||||
// G1ArchiveRegionMap is an array used to mark G1 regions as
|
||||
// archive regions. This allows a quick check for whether an object
|
||||
// should not be marked because it is in an archive region.
|
||||
class G1ArchiveRegionMap : public G1BiasedMappedArray<bool> {
|
||||
class G1ArchiveRegionMap : public G1BiasedMappedArray<uint8_t> {
|
||||
public:
|
||||
static const uint8_t NoArchive = 0;
|
||||
static const uint8_t OpenArchive = 1;
|
||||
static const uint8_t ClosedArchive = 2;
|
||||
|
||||
protected:
|
||||
bool default_value() const { return false; }
|
||||
uint8_t default_value() const { return NoArchive; }
|
||||
};
|
||||
|
||||
// G1ArchiveAllocator is used to allocate memory in archive
|
||||
@ -290,7 +295,7 @@ public:
|
||||
|
||||
// Mark regions containing the specified address range as archive/non-archive.
|
||||
static inline void set_range_archive(MemRegion range, bool open);
|
||||
static inline void clear_range_archive(MemRegion range, bool open);
|
||||
static inline void clear_range_archive(MemRegion range);
|
||||
|
||||
// Check if the object is in closed archive
|
||||
static inline bool is_closed_archive_object(oop object);
|
||||
@ -301,8 +306,7 @@ public:
|
||||
|
||||
private:
|
||||
static bool _archive_check_enabled;
|
||||
static G1ArchiveRegionMap _closed_archive_region_map;
|
||||
static G1ArchiveRegionMap _open_archive_region_map;
|
||||
static G1ArchiveRegionMap _archive_region_map;
|
||||
|
||||
// Check if an object is in a closed archive region using the _closed_archive_region_map.
|
||||
static inline bool in_closed_archive_range(oop object);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -131,12 +131,9 @@ inline void G1ArchiveAllocator::enable_archive_object_check() {
|
||||
|
||||
_archive_check_enabled = true;
|
||||
size_t length = G1CollectedHeap::heap()->max_reserved_capacity();
|
||||
_closed_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
|
||||
G1CollectedHeap::heap()->base() + length,
|
||||
HeapRegion::GrainBytes);
|
||||
_open_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
|
||||
G1CollectedHeap::heap()->base() + length,
|
||||
HeapRegion::GrainBytes);
|
||||
_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
|
||||
G1CollectedHeap::heap()->base() + length,
|
||||
HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
// Set the regions containing the specified address range as archive.
|
||||
@ -146,36 +143,26 @@ inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool open) {
|
||||
open ? "open" : "closed",
|
||||
p2i(range.start()),
|
||||
p2i(range.last()));
|
||||
if (open) {
|
||||
_open_archive_region_map.set_by_address(range, true);
|
||||
} else {
|
||||
_closed_archive_region_map.set_by_address(range, true);
|
||||
}
|
||||
uint8_t const value = open ? G1ArchiveRegionMap::OpenArchive : G1ArchiveRegionMap::ClosedArchive;
|
||||
_archive_region_map.set_by_address(range, value);
|
||||
}
|
||||
|
||||
// Clear the archive regions map containing the specified address range.
|
||||
inline void G1ArchiveAllocator::clear_range_archive(MemRegion range, bool open) {
|
||||
inline void G1ArchiveAllocator::clear_range_archive(MemRegion range) {
|
||||
assert(_archive_check_enabled, "archive range check not enabled");
|
||||
log_info(gc, cds)("Clear %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
|
||||
open ? "open" : "closed",
|
||||
log_info(gc, cds)("Clear archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
|
||||
p2i(range.start()),
|
||||
p2i(range.last()));
|
||||
if (open) {
|
||||
_open_archive_region_map.set_by_address(range, false);
|
||||
} else {
|
||||
_closed_archive_region_map.set_by_address(range, false);
|
||||
}
|
||||
_archive_region_map.set_by_address(range, G1ArchiveRegionMap::NoArchive);
|
||||
}
|
||||
|
||||
// Check if an object is in a closed archive region using the _archive_region_map.
|
||||
inline bool G1ArchiveAllocator::in_closed_archive_range(oop object) {
|
||||
// This is the out-of-line part of is_closed_archive_object test, done separately
|
||||
// to avoid additional performance impact when the check is not enabled.
|
||||
return _closed_archive_region_map.get_by_address((HeapWord*)object);
|
||||
return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::ClosedArchive;
|
||||
}
|
||||
|
||||
inline bool G1ArchiveAllocator::in_open_archive_range(oop object) {
|
||||
return _open_archive_region_map.get_by_address((HeapWord*)object);
|
||||
return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::OpenArchive;
|
||||
}
|
||||
|
||||
// Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
|
||||
@ -193,8 +180,8 @@ inline bool G1ArchiveAllocator::is_open_archive_object(oop object) {
|
||||
}
|
||||
|
||||
inline bool G1ArchiveAllocator::is_archived_object(oop object) {
|
||||
return (archive_check_enabled() && (in_closed_archive_range(object) ||
|
||||
in_open_archive_range(object)));
|
||||
return archive_check_enabled() &&
|
||||
(_archive_region_map.get_by_address((HeapWord*)object) != G1ArchiveRegionMap::NoArchive);
|
||||
}
|
||||
|
||||
#endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
|
||||
|
@ -766,7 +766,7 @@ inline HeapWord* G1CollectedHeap::attempt_allocation(size_t min_word_size,
|
||||
return result;
|
||||
}
|
||||
|
||||
void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count, bool is_open) {
|
||||
void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count) {
|
||||
assert(!is_init_completed(), "Expect to be called at JVM init time");
|
||||
assert(ranges != NULL, "MemRegion array NULL");
|
||||
assert(count != 0, "No MemRegions provided");
|
||||
@ -828,7 +828,7 @@ void G1CollectedHeap::dealloc_archive_regions(MemRegion* ranges, size_t count, b
|
||||
}
|
||||
|
||||
// Notify mark-sweep that this is no longer an archive range.
|
||||
G1ArchiveAllocator::clear_range_archive(ranges[i], is_open);
|
||||
G1ArchiveAllocator::clear_range_archive(ranges[i]);
|
||||
}
|
||||
|
||||
if (uncommitted_regions != 0) {
|
||||
|
@ -723,7 +723,7 @@ public:
|
||||
// which had been allocated by alloc_archive_regions. This should be called
|
||||
// rather than fill_archive_regions at JVM init time if the archive file
|
||||
// mapping failed, with the same non-overlapping and sorted MemRegion array.
|
||||
void dealloc_archive_regions(MemRegion* range, size_t count, bool is_open);
|
||||
void dealloc_archive_regions(MemRegion* range, size_t count);
|
||||
|
||||
oop materialize_archived_object(oop obj);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1790,7 +1790,7 @@ bool FileMapInfo::map_heap_data(MemRegion **heap_mem, int first,
|
||||
si->allow_exec());
|
||||
if (base == NULL || base != addr) {
|
||||
// dealloc the regions from java heap
|
||||
dealloc_archive_heap_regions(regions, region_num, is_open_archive);
|
||||
dealloc_archive_heap_regions(regions, region_num);
|
||||
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
|
||||
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
|
||||
p2i(addr), regions[i].byte_size());
|
||||
@ -1799,7 +1799,7 @@ bool FileMapInfo::map_heap_data(MemRegion **heap_mem, int first,
|
||||
|
||||
if (VerifySharedSpaces && !region_crc_check(addr, regions[i].byte_size(), si->crc())) {
|
||||
// dealloc the regions from java heap
|
||||
dealloc_archive_heap_regions(regions, region_num, is_open_archive);
|
||||
dealloc_archive_heap_regions(regions, region_num);
|
||||
log_info(cds)("UseSharedSpaces: mapped heap regions are corrupt");
|
||||
return false;
|
||||
}
|
||||
@ -1855,10 +1855,10 @@ void FileMapInfo::fixup_mapped_heap_regions() {
|
||||
}
|
||||
|
||||
// dealloc the archive regions from java heap
|
||||
void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) {
|
||||
void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num) {
|
||||
if (num > 0) {
|
||||
assert(regions != NULL, "Null archive ranges array with non-zero count");
|
||||
G1CollectedHeap::heap()->dealloc_archive_regions(regions, num, is_open);
|
||||
G1CollectedHeap::heap()->dealloc_archive_regions(regions, num);
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS_JAVA_HEAP
|
||||
@ -2075,11 +2075,9 @@ void FileMapInfo::stop_sharing_and_unmap(const char* msg) {
|
||||
// Dealloc the archive heap regions only without unmapping. The regions are part
|
||||
// of the java heap. Unmapping of the heap regions are managed by GC.
|
||||
map_info->dealloc_archive_heap_regions(open_archive_heap_ranges,
|
||||
num_open_archive_heap_ranges,
|
||||
true);
|
||||
num_open_archive_heap_ranges);
|
||||
map_info->dealloc_archive_heap_regions(closed_archive_heap_ranges,
|
||||
num_closed_archive_heap_ranges,
|
||||
false);
|
||||
num_closed_archive_heap_ranges);
|
||||
} else if (DumpSharedSpaces) {
|
||||
fail_stop("%s", msg);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -538,7 +538,7 @@ public:
|
||||
bool map_heap_data(MemRegion **heap_mem, int first, int max, int* num,
|
||||
bool is_open = false) NOT_CDS_JAVA_HEAP_RETURN_(false);
|
||||
bool region_crc_check(char* buf, size_t size, int expected_crc) NOT_CDS_RETURN_(false);
|
||||
void dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) NOT_CDS_JAVA_HEAP_RETURN;
|
||||
void dealloc_archive_heap_regions(MemRegion* regions, int num) NOT_CDS_JAVA_HEAP_RETURN;
|
||||
void map_heap_regions_impl() NOT_CDS_JAVA_HEAP_RETURN;
|
||||
char* map_relocation_bitmap(size_t& bitmap_size);
|
||||
MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
|
||||
|
Loading…
Reference in New Issue
Block a user