1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Mar 25 15:50:17 2015 +0100 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Dec 19 09:21:06 2014 +0100 1.3 @@ -32,6 +32,7 @@ 1.4 #include "gc_implementation/g1/g1AllocRegion.hpp" 1.5 #include "gc_implementation/g1/g1BiasedArray.hpp" 1.6 #include "gc_implementation/g1/g1HRPrinter.hpp" 1.7 +#include "gc_implementation/g1/g1InCSetState.hpp" 1.8 #include "gc_implementation/g1/g1MonitoringSupport.hpp" 1.9 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" 1.10 #include "gc_implementation/g1/g1YCTypes.hpp" 1.11 @@ -546,15 +547,9 @@ 1.12 // allocation region, either by picking one or expanding the 1.13 // heap, and then allocate a block of the given size. The block 1.14 // may not be a humongous - it must fit into a single heap region. 1.15 - HeapWord* par_allocate_during_gc(GCAllocPurpose purpose, 1.16 - size_t word_size, 1.17 - AllocationContext_t context); 1.18 - 1.19 - HeapWord* allocate_during_gc_slow(GCAllocPurpose purpose, 1.20 - HeapRegion* alloc_region, 1.21 - bool par, 1.22 - size_t word_size); 1.23 - 1.24 + inline HeapWord* par_allocate_during_gc(InCSetState dest, 1.25 + size_t word_size, 1.26 + AllocationContext_t context); 1.27 // Ensure that no further allocations can happen in "r", bearing in mind 1.28 // that parallel threads might be attempting allocations. 1.29 void par_allocate_remaining_space(HeapRegion* r); 1.30 @@ -576,9 +571,9 @@ 1.31 1.32 // For GC alloc regions. 1.33 HeapRegion* new_gc_alloc_region(size_t word_size, uint count, 1.34 - GCAllocPurpose ap); 1.35 + InCSetState dest); 1.36 void retire_gc_alloc_region(HeapRegion* alloc_region, 1.37 - size_t allocated_bytes, GCAllocPurpose ap); 1.38 + size_t allocated_bytes, InCSetState dest); 1.39 1.40 // - if explicit_gc is true, the GC is for a System.gc() or a heap 1.41 // inspection request and should collect the entire heap 1.42 @@ -639,26 +634,11 @@ 1.43 // (Rounds up to a HeapRegion boundary.) 1.44 bool expand(size_t expand_bytes); 1.45 1.46 - // Returns the PLAB statistics given a purpose. 1.47 - PLABStats* stats_for_purpose(GCAllocPurpose purpose) { 1.48 - PLABStats* stats = NULL; 1.49 + // Returns the PLAB statistics for a given destination. 1.50 + inline PLABStats* alloc_buffer_stats(InCSetState dest); 1.51 1.52 - switch (purpose) { 1.53 - case GCAllocForSurvived: 1.54 - stats = &_survivor_plab_stats; 1.55 - break; 1.56 - case GCAllocForTenured: 1.57 - stats = &_old_plab_stats; 1.58 - break; 1.59 - default: 1.60 - assert(false, "unrecognized GCAllocPurpose"); 1.61 - } 1.62 - 1.63 - return stats; 1.64 - } 1.65 - 1.66 - // Determines PLAB size for a particular allocation purpose. 1.67 - size_t desired_plab_sz(GCAllocPurpose purpose); 1.68 + // Determines PLAB size for a given destination. 1.69 + inline size_t desired_plab_sz(InCSetState dest); 1.70 1.71 inline AllocationContextStats& allocation_context_stats(); 1.72 1.73 @@ -682,8 +662,11 @@ 1.74 void register_humongous_regions_with_in_cset_fast_test(); 1.75 // We register a region with the fast "in collection set" test. We 1.76 // simply set to true the array slot corresponding to this region. 1.77 - void register_region_with_in_cset_fast_test(HeapRegion* r) { 1.78 - _in_cset_fast_test.set_in_cset(r->hrm_index()); 1.79 + void register_young_region_with_in_cset_fast_test(HeapRegion* r) { 1.80 + _in_cset_fast_test.set_in_young(r->hrm_index()); 1.81 + } 1.82 + void register_old_region_with_in_cset_fast_test(HeapRegion* r) { 1.83 + _in_cset_fast_test.set_in_old(r->hrm_index()); 1.84 } 1.85 1.86 // This is a fast test on whether a reference points into the 1.87 @@ -1183,6 +1166,9 @@ 1.88 // appropriate error messages and crash. 1.89 void check_bitmaps(const char* caller) PRODUCT_RETURN; 1.90 1.91 + // Do sanity check on the contents of the in-cset fast test table. 1.92 + bool check_cset_fast_test() PRODUCT_RETURN_( return true; ); 1.93 + 1.94 // verify_region_sets() performs verification over the region 1.95 // lists. It will be compiled in the product code to be used when 1.96 // necessary (i.e., during heap verification). 1.97 @@ -1278,53 +1264,15 @@ 1.98 1.99 inline bool is_in_cset_or_humongous(const oop obj); 1.100 1.101 - enum in_cset_state_t { 1.102 - InNeither, // neither in collection set nor humongous 1.103 - InCSet, // region is in collection set only 1.104 - IsHumongous // region is a humongous start region 1.105 - }; 1.106 private: 1.107 - // Instances of this class are used for quick tests on whether a reference points 1.108 - // into the collection set or is a humongous object (points into a humongous 1.109 - // object). 1.110 - // Each of the array's elements denotes whether the corresponding region is in 1.111 - // the collection set or a humongous region. 1.112 - // We use this to quickly reclaim humongous objects: by making a humongous region 1.113 - // succeed this test, we sort-of add it to the collection set. During the reference 1.114 - // iteration closures, when we see a humongous region, we simply mark it as 1.115 - // referenced, i.e. live. 1.116 - class G1FastCSetBiasedMappedArray : public G1BiasedMappedArray<char> { 1.117 - protected: 1.118 - char default_value() const { return G1CollectedHeap::InNeither; } 1.119 - public: 1.120 - void set_humongous(uintptr_t index) { 1.121 - assert(get_by_index(index) != InCSet, "Should not overwrite InCSet values"); 1.122 - set_by_index(index, G1CollectedHeap::IsHumongous); 1.123 - } 1.124 - 1.125 - void clear_humongous(uintptr_t index) { 1.126 - set_by_index(index, G1CollectedHeap::InNeither); 1.127 - } 1.128 - 1.129 - void set_in_cset(uintptr_t index) { 1.130 - assert(get_by_index(index) != G1CollectedHeap::IsHumongous, "Should not overwrite IsHumongous value"); 1.131 - set_by_index(index, G1CollectedHeap::InCSet); 1.132 - } 1.133 - 1.134 - bool is_in_cset_or_humongous(HeapWord* addr) const { return get_by_address(addr) != G1CollectedHeap::InNeither; } 1.135 - bool is_in_cset(HeapWord* addr) const { return get_by_address(addr) == G1CollectedHeap::InCSet; } 1.136 - G1CollectedHeap::in_cset_state_t at(HeapWord* addr) const { return (G1CollectedHeap::in_cset_state_t)get_by_address(addr); } 1.137 - void clear() { G1BiasedMappedArray<char>::clear(); } 1.138 - }; 1.139 - 1.140 // This array is used for a quick test on whether a reference points into 1.141 // the collection set or not. Each of the array's elements denotes whether the 1.142 // corresponding region is in the collection set or not. 1.143 - G1FastCSetBiasedMappedArray _in_cset_fast_test; 1.144 + G1InCSetStateFastTestBiasedMappedArray _in_cset_fast_test; 1.145 1.146 public: 1.147 1.148 - inline in_cset_state_t in_cset_state(const oop obj); 1.149 + inline InCSetState in_cset_state(const oop obj); 1.150 1.151 // Return "TRUE" iff the given object address is in the reserved 1.152 // region of g1.