OpenJDK / jdk / jdk
changeset 57584:9dee5a79065b
8214277: Use merged G1ArchiveRegionMap for open and closed archive heap regions
Reviewed-by: kbarrett, jiangli
author | tschatzl |
---|---|
date | Thu, 09 Jan 2020 21:57:18 +0100 |
parents | a6c0679606c3 |
children | 0bffcc9de0b1 |
files | src/hotspot/share/gc/g1/g1Allocator.cpp src/hotspot/share/gc/g1/g1Allocator.hpp src/hotspot/share/gc/g1/g1Allocator.inline.hpp src/hotspot/share/gc/g1/g1CollectedHeap.cpp src/hotspot/share/gc/g1/g1CollectedHeap.hpp src/hotspot/share/memory/filemap.cpp src/hotspot/share/memory/filemap.hpp |
diffstat | 7 files changed, 38 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/share/gc/g1/g1Allocator.cpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/gc/g1/g1Allocator.cpp Thu Jan 09 21:57:18 2020 +0100 @@ -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 @@ } 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
--- a/src/hotspot/share/gc/g1/g1Allocator.hpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/gc/g1/g1Allocator.hpp Thu Jan 09 21:57:18 2020 +0100 @@ -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 @@ 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 @@ // 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 @@ 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);
--- a/src/hotspot/share/gc/g1/g1Allocator.inline.hpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/gc/g1/g1Allocator.inline.hpp Thu Jan 09 21:57:18 2020 +0100 @@ -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 @@ _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 @@ 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_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
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp Thu Jan 09 21:57:18 2020 +0100 @@ -766,7 +766,7 @@ 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 @@ } // 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) {
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp Thu Jan 09 21:57:18 2020 +0100 @@ -723,7 +723,7 @@ // 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);
--- a/src/hotspot/share/memory/filemap.cpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/memory/filemap.cpp Thu Jan 09 21:57:18 2020 +0100 @@ -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 @@ 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 @@ 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 @@ } // 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 @@ // 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); }
--- a/src/hotspot/share/memory/filemap.hpp Thu Jan 09 10:01:01 2020 -0500 +++ b/src/hotspot/share/memory/filemap.hpp Thu Jan 09 21:57:18 2020 +0100 @@ -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 @@ 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);