--- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2014-07-22 14:59:04.743390835 +0200 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2014-07-22 14:59:04.662388497 +0200 @@ -197,40 +197,6 @@ bool do_object_b(oop p); }; -// Instances of this class are used for quick tests on whether a reference points -// into the collection set or is a humongous object (points into a humongous -// object). -// Each of the array's elements denotes whether the corresponding region is in -// the collection set or a humongous region. -// We use this to quickly reclaim humongous objects: by making a humongous region -// succeed this test, we sort-of add it to the collection set which objects are -// supposed to be evacuated. However, since the region is humongous, evacuation -// will automatically fail the test to allocate it into a PLAB. We catch this -// condition (in this slow-path), and mark that region as "live" in a side table. -// At the end of GC, we use this information, among other, to determine whether -// we can reclaim the humongous object or not. -class G1FastCSetBiasedMappedArray : public G1BiasedMappedArray { - private: - enum { - InNeither, // neither in collection set nor humongous - InCSet, // region is in collection set only - IsHumongous // region is a humongous start region - }; - protected: - char default_value() const { return InNeither; } - public: - void set_humongous(uintptr_t index) { assert(get_by_index(index) != InCSet, "Should not overwrite InCSet values"); set_by_index(index, IsHumongous); } - void clear_humongous(uintptr_t index) { - set_by_index(index, InNeither); - } - void set_in_cset(uintptr_t index) { assert(get_by_index(index) != IsHumongous, "Should not overwrite InCSetOrHumongous value"); set_by_index(index, InCSet); } - - bool is_in_cset_or_humongous(HeapWord* addr) const { return get_by_address(addr) != InNeither; } - bool is_in_cset_and_humongous(HeapWord* addr) const { return get_by_address(addr) == IsHumongous; } - bool is_in_cset(HeapWord* addr) const { return get_by_address(addr) == InCSet; } - void clear() { G1BiasedMappedArray::clear(); } -}; - class RefineCardTableEntryClosure; class G1CollectedHeap : public SharedHeap { @@ -395,11 +361,6 @@ // than the current allocation region. size_t _summary_bytes_used; - // This array is used for a quick test on whether a reference points into - // the collection set or not. Each of the array's elements denotes whether the - // corresponding region is in the collection set or not. - G1FastCSetBiasedMappedArray _in_cset_fast_test; - // Records whether the region at the given index is kept live by roots or // references from the young generation. class HumongousIsLiveBiasedMappedArray : public G1BiasedMappedArray { @@ -746,7 +707,7 @@ // Returns whether the given region (which must be a humongous (start) region) // is to be considered conservatively live regardless of any other conditions. - bool humongous_region_is_always_live(HeapRegion* region); + bool humongous_region_is_always_live(uint index); // Register the given region to be part of the collection set. inline void register_humongous_region_with_in_cset_fast_test(uint index); // Register regions with humongous objects (actually on the start region) in @@ -1352,7 +1313,53 @@ inline bool is_in_cset_or_humongous(const oop obj); - inline bool is_in_cset_and_humongous(const oop obj); + enum in_cset_state_t { + InNeither, // neither in collection set nor humongous + InCSet, // region is in collection set only + IsHumongous // region is a humongous start region + }; + private: + // Instances of this class are used for quick tests on whether a reference points + // into the collection set or is a humongous object (points into a humongous + // object). + // Each of the array's elements denotes whether the corresponding region is in + // the collection set or a humongous region. + // We use this to quickly reclaim humongous objects: by making a humongous region + // succeed this test, we sort-of add it to the collection set. During the reference + // iteration closures, when we see a humongous region, we simply mark it as + // referenced, i.e. live. + class G1FastCSetBiasedMappedArray : public G1BiasedMappedArray { + protected: + char default_value() const { return G1CollectedHeap::InNeither; } + public: + void set_humongous(uintptr_t index) { + assert(get_by_index(index) != InCSet, "Should not overwrite InCSet values"); + set_by_index(index, G1CollectedHeap::IsHumongous); + } + + void clear_humongous(uintptr_t index) { + set_by_index(index, G1CollectedHeap::InNeither); + } + + void set_in_cset(uintptr_t index) { + assert(get_by_index(index) != G1CollectedHeap::IsHumongous, "Should not overwrite IsHumongous value"); + set_by_index(index, G1CollectedHeap::InCSet); + } + + bool is_in_cset_or_humongous(HeapWord* addr) const { return get_by_address(addr) != G1CollectedHeap::InNeither; } + bool is_in_cset(HeapWord* addr) const { return get_by_address(addr) == G1CollectedHeap::InCSet; } + G1CollectedHeap::in_cset_state_t at(HeapWord* addr) const { return (G1CollectedHeap::in_cset_state_t)get_by_address(addr); } + void clear() { G1BiasedMappedArray::clear(); } + }; + + // This array is used for a quick test on whether a reference points into + // the collection set or not. Each of the array's elements denotes whether the + // corresponding region is in the collection set or not. + G1FastCSetBiasedMappedArray _in_cset_fast_test; + + public: + + inline in_cset_state_t in_cset_state(const oop obj); // Return "TRUE" iff the given object address is in the reserved // region of g1.