--- old/src/share/vm/gc/g1/g1Allocator.cpp 2017-02-20 11:09:10.956227855 +0100 +++ new/src/share/vm/gc/g1/g1Allocator.cpp 2017-02-20 11:09:10.836227259 +0100 @@ -27,7 +27,6 @@ #include "gc/g1/g1AllocRegion.inline.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1MarkSweep.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionSet.inline.hpp" @@ -333,11 +332,14 @@ } } +bool G1ArchiveAllocator::_archive_check_enabled = false; +G1ArchiveRegionMap G1ArchiveAllocator::_archive_region_map; + G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h) { // Create the archive allocator, and also enable archive object checking // in mark-sweep, since we will be creating archive regions. G1ArchiveAllocator* result = new G1ArchiveAllocator(g1h); - G1MarkSweep::enable_archive_object_check(); + enable_archive_object_check(); return result; } @@ -362,7 +364,7 @@ _max = _bottom + HeapRegion::min_region_size_in_words(); // Tell mark-sweep that objects in this region are not to be marked. - G1MarkSweep::set_range_archive(MemRegion(_bottom, HeapRegion::GrainWords), true); + set_range_archive(MemRegion(_bottom, HeapRegion::GrainWords), true); // Since we've modified the old set, call update_sizes. _g1h->g1mm()->update_sizes(); --- old/src/share/vm/gc/g1/g1Allocator.hpp 2017-02-20 11:09:11.632231207 +0100 +++ new/src/share/vm/gc/g1/g1Allocator.hpp 2017-02-20 11:09:11.508230592 +0100 @@ -312,12 +312,19 @@ virtual void waste(size_t& wasted, size_t& undo_wasted); }; +// G1ArchiveRegionMap is a boolean 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 { +protected: + bool default_value() const { return false; } +}; + // 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, class G1ArchiveAllocator : public CHeapObj { - protected: G1CollectedHeap* _g1h; @@ -378,6 +385,24 @@ _summary_bytes_used = 0; } + // Create the _archive_region_map which is used to identify archive objects. + 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 bool is_archive_object(oop object); + +private: + static bool _archive_check_enabled; + static G1ArchiveRegionMap _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 archive object checking is enabled, to avoid calling in_archive_range + // unnecessarily. + static inline bool archive_check_enabled(); }; #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP --- old/src/share/vm/gc/g1/g1Allocator.inline.hpp 2017-02-20 11:09:12.248234261 +0100 +++ new/src/share/vm/gc/g1/g1Allocator.inline.hpp 2017-02-20 11:09:12.124233646 +0100 @@ -55,4 +55,37 @@ } } +// Create the _archive_region_map which is used to identify archive objects. +inline void G1ArchiveAllocator::enable_archive_object_check() { + assert(!_archive_check_enabled, "archive range check already enabled"); + _archive_check_enabled = true; + size_t length = Universe::heap()->max_capacity(); + _archive_region_map.initialize((HeapWord*)Universe::heap()->base(), + (HeapWord*)Universe::heap()->base() + length, + HeapRegion::GrainBytes); +} + +// Set the regions containing the specified address range as archive/non-archive. +inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool is_archive) { + assert(_archive_check_enabled, "archive range check not enabled"); + _archive_region_map.set_by_address(range, is_archive); +} + +// Check if an object is in an archive region using the _archive_region_map. +inline bool G1ArchiveAllocator::in_archive_range(oop object) { + // This is the out-of-line part of is_archive_object test, done separately + // to avoid additional performance impact when the check is not enabled. + return _archive_region_map.get_by_address((HeapWord*)object); +} + +// Check if archive object checking is enabled, to avoid calling in_archive_range +// unnecessarily. +inline bool G1ArchiveAllocator::archive_check_enabled() { + return _archive_check_enabled; +} + +inline bool G1ArchiveAllocator::is_archive_object(oop object) { + return (archive_check_enabled() && in_archive_range(object)); +} + #endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP --- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-02-20 11:09:12.892237455 +0100 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-02-20 11:09:12.756236780 +0100 @@ -699,9 +699,9 @@ // when mmap'ing archived heap data in, so pre-touching is wasted. FlagSetting fs(AlwaysPreTouch, false); - // Enable archive object checking in G1MarkSweep. We have to let it know + // Enable archive object checking used by G1MarkSweep. We have to let it know // about each archive range, so that objects in those ranges aren't marked. - G1MarkSweep::enable_archive_object_check(); + G1ArchiveAllocator::enable_archive_object_check(); // For each specified MemRegion range, allocate the corresponding G1 // regions and mark them as archive regions. We expect the ranges in @@ -773,7 +773,7 @@ } // Notify mark-sweep of the archive range. - G1MarkSweep::set_range_archive(curr_range, true); + G1ArchiveAllocator::set_range_archive(curr_range, true); } return true; } @@ -924,7 +924,7 @@ } // Notify mark-sweep that this is no longer an archive range. - G1MarkSweep::set_range_archive(ranges[i], false); + G1ArchiveAllocator::set_range_archive(ranges[i], false); } if (uncommitted_regions != 0) { --- old/src/share/vm/gc/g1/g1HeapVerifier.cpp 2017-02-20 11:09:13.588240906 +0100 +++ new/src/share/vm/gc/g1/g1HeapVerifier.cpp 2017-02-20 11:09:13.452240232 +0100 @@ -25,10 +25,10 @@ #include "precompiled.hpp" #include "logging/log.hpp" #include "gc/g1/concurrentMarkThread.hpp" +#include "gc/g1/g1Allocator.inline.hpp" #include "gc/g1/g1CollectedHeap.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1HeapVerifier.hpp" -#include "gc/g1/g1MarkSweep.hpp" #include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1RootProcessor.hpp" @@ -239,7 +239,7 @@ template void do_oop_work(T *p) { oop obj = oopDesc::load_decode_heap_oop(p); - guarantee(obj == NULL || G1MarkSweep::in_archive_range(obj), + guarantee(obj == NULL || G1ArchiveAllocator::is_archive_object(obj), "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT, p2i(p), p2i(obj)); } --- old/src/share/vm/gc/g1/g1MarkSweep.cpp 2017-02-20 11:09:14.272244298 +0100 +++ new/src/share/vm/gc/g1/g1MarkSweep.cpp 2017-02-20 11:09:14.140243643 +0100 @@ -56,9 +56,6 @@ class HeapRegion; -bool G1MarkSweep::_archive_check_enabled = false; -G1ArchiveRegionMap G1MarkSweep::_archive_region_map; - void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_softrefs) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); @@ -314,26 +311,6 @@ } -void G1MarkSweep::enable_archive_object_check() { - assert(!_archive_check_enabled, "archive range check already enabled"); - _archive_check_enabled = true; - size_t length = Universe::heap()->max_capacity(); - _archive_region_map.initialize((HeapWord*)Universe::heap()->base(), - (HeapWord*)Universe::heap()->base() + length, - HeapRegion::GrainBytes); -} - -void G1MarkSweep::set_range_archive(MemRegion range, bool is_archive) { - assert(_archive_check_enabled, "archive range check not enabled"); - _archive_region_map.set_by_address(range, is_archive); -} - -bool G1MarkSweep::in_archive_range(oop object) { - // This is the out-of-line part of is_archive_object test, done separately - // to avoid additional performance impact when the check is not enabled. - return _archive_region_map.get_by_address((HeapWord*)object); -} - void G1MarkSweep::prepare_compaction_work(G1PrepareCompactClosure* blk) { G1CollectedHeap* g1h = G1CollectedHeap::heap(); g1h->heap_region_iterate(blk); --- old/src/share/vm/gc/g1/g1MarkSweep.hpp 2017-02-20 11:09:14.908247452 +0100 +++ new/src/share/vm/gc/g1/g1MarkSweep.hpp 2017-02-20 11:09:14.780246817 +0100 @@ -55,23 +55,7 @@ static STWGCTimer* gc_timer() { return GenMarkSweep::_gc_timer; } static SerialOldTracer* gc_tracer() { return GenMarkSweep::_gc_tracer; } - // Create the _archive_region_map which is used to identify archive objects. - static void enable_archive_object_check(); - - // Set the regions containing the specified address range as archive/non-archive. - static void set_range_archive(MemRegion range, bool is_archive); - - // Check if an object is in an archive region using the _archive_region_map. - static bool in_archive_range(oop object); - - // Check if archive object checking is enabled, to avoid calling in_archive_range - // unnecessarily. - static bool archive_check_enabled() { return G1MarkSweep::_archive_check_enabled; } - - private: - static bool _archive_check_enabled; - static G1ArchiveRegionMap _archive_region_map; - +private: // Mark live objects static void mark_sweep_phase1(bool& marked_for_deopt, bool clear_all_softrefs); @@ -109,12 +93,4 @@ bool doHeapRegion(HeapRegion* hr); }; -// G1ArchiveRegionMap is a boolean 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 { -protected: - bool default_value() const { return false; } -}; - #endif // SHARE_VM_GC_G1_G1MARKSWEEP_HPP --- old/src/share/vm/gc/serial/markSweep.inline.hpp 2017-02-20 11:09:15.588250824 +0100 +++ new/src/share/vm/gc/serial/markSweep.inline.hpp 2017-02-20 11:09:15.448250129 +0100 @@ -30,13 +30,12 @@ #include "oops/markOop.inline.hpp" #include "oops/oop.inline.hpp" #if INCLUDE_ALL_GCS -#include "gc/g1/g1MarkSweep.hpp" +#include "gc/g1/g1Allocator.inline.hpp" #endif // INCLUDE_ALL_GCS inline bool MarkSweep::is_archive_object(oop object) { #if INCLUDE_ALL_GCS - return (G1MarkSweep::archive_check_enabled() && - G1MarkSweep::in_archive_range(object)); + return G1ArchiveAllocator::is_archive_object(object); #else return false; #endif