--- old/src/hotspot/share/gc/g1/g1Allocator.cpp 2020-01-08 10:47:56.324169116 +0100 +++ new/src/hotspot/share/gc/g1/g1Allocator.cpp 2020-01-08 10:47:56.144166572 +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,7 +412,7 @@ } bool G1ArchiveAllocator::_archive_check_enabled = false; -G1ArchiveRegionMap G1ArchiveAllocator::_closed_archive_region_map; +G1ArchiveRegionMap G1ArchiveAllocator::_archive_region_map; G1ArchiveRegionMap G1ArchiveAllocator::_open_archive_region_map; G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) { --- old/src/hotspot/share/gc/g1/g1Allocator.hpp 2020-01-08 10:47:56.820176122 +0100 +++ new/src/hotspot/share/gc/g1/g1Allocator.hpp 2020-01-08 10:47:56.644173636 +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 { +class G1ArchiveRegionMap : public G1BiasedMappedArray { +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 @@ -301,7 +306,7 @@ private: static bool _archive_check_enabled; - static G1ArchiveRegionMap _closed_archive_region_map; + static G1ArchiveRegionMap _archive_region_map; static G1ArchiveRegionMap _open_archive_region_map; // Check if an object is in a closed archive region using the _closed_archive_region_map. --- old/src/hotspot/share/gc/g1/g1Allocator.inline.hpp 2020-01-08 10:47:57.336183407 +0100 +++ new/src/hotspot/share/gc/g1/g1Allocator.inline.hpp 2020-01-08 10:47:57.160180921 +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,11 +143,8 @@ 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. @@ -160,22 +154,18 @@ open ? "open" : "closed", 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 +183,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