--- a/hotspot/src/share/vm/gc/g1/g1Allocator.hpp Mon Aug 14 16:48:44 2017 +0200
+++ b/hotspot/src/share/vm/gc/g1/g1Allocator.hpp Mon Aug 14 14:32:17 2017 -0400
@@ -321,11 +321,19 @@
};
// G1ArchiveAllocator is used to allocate memory in archive
-// regions. Such regions are not modifiable by GC, being neither
-// scavenged nor compacted, or even marked in the object header.
-// They can contain no pointers to non-archive heap regions,
+// regions. Such regions are not scavenged nor compacted by GC.
+// There are two types of archive regions, which are
+// differ in the kind of references allowed for the contained objects:
+//
+// - 'Closed' archive region contain no references outside of other
+// closed archive regions. The region is immutable by GC. GC does
+// not mark object header in 'closed' archive region.
+// - An 'open' archive region allow references to any other regions,
+// including closed archive, open archive and other java heap regions.
+// GC can adjust pointers and mark object header in 'open' archive region.
class G1ArchiveAllocator : public CHeapObj<mtGC> {
protected:
+ bool _open; // Indicate if the region is 'open' archive.
G1CollectedHeap* _g1h;
// The current allocation region
@@ -347,7 +355,7 @@
bool alloc_new_region();
public:
- G1ArchiveAllocator(G1CollectedHeap* g1h) :
+ G1ArchiveAllocator(G1CollectedHeap* g1h, bool open) :
_g1h(g1h),
_allocation_region(NULL),
_allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions,
@@ -356,13 +364,14 @@
_summary_bytes_used(0),
_bottom(NULL),
_top(NULL),
- _max(NULL) { }
+ _max(NULL),
+ _open(open) { }
virtual ~G1ArchiveAllocator() {
assert(_allocation_region == NULL, "_allocation_region not NULL");
}
- static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h);
+ static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h, bool open);
// Allocate memory for an individual object.
HeapWord* archive_mem_allocate(size_t word_size);
@@ -389,18 +398,26 @@
static inline void enable_archive_object_check();
// Set the regions containing the specified address range as archive/non-archive.
- static inline void set_range_archive(MemRegion range, bool is_archive);
+ static inline void set_range_archive(MemRegion range, bool open);
+ // Check if the object is in closed archive
+ static inline bool is_closed_archive_object(oop object);
+ // Check if the object is in open archive
+ static inline bool is_open_archive_object(oop object);
+ // Check if the object is either in closed archive or open archive
static inline bool is_archive_object(oop object);
private:
static bool _archive_check_enabled;
- static G1ArchiveRegionMap _archive_region_map;
+ static G1ArchiveRegionMap _closed_archive_region_map;
+ static G1ArchiveRegionMap _open_archive_region_map;
- // Check if an object is in an archive region using the _archive_region_map.
- static inline bool in_archive_range(oop object);
+ // 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);
+ // Check if an object is in open archive region using the _open_archive_region_map.
+ static inline bool in_open_archive_range(oop object);
- // Check if archive object checking is enabled, to avoid calling in_archive_range
+ // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
// unnecessarily.
static inline bool archive_check_enabled();
};