< prev index next >

src/share/vm/gc/g1/g1ParScanThreadState.hpp

Print this page
rev 9080 : imported patch move-code
rev 9081 : imported patch rootclosureset
rev 9083 : imported patch erik-review


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_HPP
  26 #define SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_HPP
  27 
  28 #include "gc/g1/dirtyCardQueue.hpp"
  29 #include "gc/g1/g1CollectedHeap.hpp"
  30 #include "gc/g1/g1CollectorPolicy.hpp"
  31 #include "gc/g1/g1OopClosures.hpp"
  32 #include "gc/g1/g1RemSet.hpp"
  33 #include "gc/g1/g1RootClosureSet.hpp"
  34 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  35 #include "gc/shared/ageTable.hpp"
  36 #include "memory/allocation.hpp"
  37 #include "oops/oop.hpp"
  38 
  39 class G1PLABAllocator;
  40 class HeapRegion;
  41 class outputStream;
  42 
  43 class G1ParScanThreadState : public CHeapObj<mtGC> {
  44  private:
  45   G1CollectedHeap* _g1h;
  46   RefToScanQueue*  _refs;
  47   DirtyCardQueue   _dcq;
  48   G1SATBCardTableModRefBS* _ct_bs;
  49   G1EvacuationRootClosureSet* _closures;
  50 
  51   G1PLABAllocator*  _plab_allocator;
  52 
  53   ageTable          _age_table;
  54   InCSetState       _dest[InCSetState::Num];
  55   // Local tenuring threshold.
  56   uint              _tenuring_threshold;
  57   G1ParScanClosure  _scanner;
  58 
  59   int  _hash_seed;
  60   uint _worker_id;
  61 
  62   // Map from young-age-index (0 == not young, 1 is youngest) to
  63   // surviving words. base is what we get back from the malloc call
  64   size_t* _surviving_young_words_base;
  65   // this points into the array, as we use the first few entries for padding
  66   size_t* _surviving_young_words;
  67 
  68   // Indicates whether in the last generation (old) there is no more space
  69   // available for allocation.
  70   bool _old_gen_is_full;
  71 
  72 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
  73 
  74   DirtyCardQueue& dirty_card_queue()             { return _dcq;  }
  75   G1SATBCardTableModRefBS* ctbs()                { return _ct_bs; }
  76 
  77   InCSetState dest(InCSetState original) const {
  78     assert(original.is_valid(),
  79            "Original state invalid: " CSETSTATE_FORMAT, original.value());
  80     assert(_dest[original.value()].is_valid_gen(),
  81            "Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value());
  82     return _dest[original.value()];
  83   }
  84 
  85   G1EvacuationRootClosureSet* new_root_closure_set();
  86  public:
  87   G1ParScanThreadState(G1CollectedHeap* g1h, uint worker_id, size_t young_cset_length);
  88   ~G1ParScanThreadState();
  89 
  90   void set_ref_processor(ReferenceProcessor* rp) { _scanner.set_ref_processor(rp); }
  91 
  92 #ifdef ASSERT
  93   bool queue_is_empty() const { return _refs->is_empty(); }
  94 
  95   bool verify_ref(narrowOop* ref) const;
  96   bool verify_ref(oop* ref) const;
  97   bool verify_task(StarTask ref) const;
  98 #endif // ASSERT
  99 
 100   template <class T> void push_on_queue(T* ref);
 101 
 102   template <class T> void update_rs(HeapRegion* from, T* p, uint tid) {
 103     // If the new value of the field points to the same region or
 104     // is the to-space, we don't need to include it in the Rset updates.
 105     if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
 106       size_t card_index = ctbs()->index_for(p);
 107       // If the card hasn't been added to the buffer, do it.
 108       if (ctbs()->mark_card_deferred(card_index)) {
 109         dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
 110       }
 111     }
 112   }
 113 
 114   G1EvacuationRootClosureSet* closures() { return _closures; }
 115   uint worker_id() { return _worker_id; }
 116 
 117   // Returns the current amount of waste due to alignment or not being able to fit
 118   // objects within LABs and the undo waste.
 119   virtual void waste(size_t& wasted, size_t& undo_wasted);
 120 
 121   size_t* surviving_young_words() {
 122     // We add one to hide entry 0 which accumulates surviving words for
 123     // age -1 regions (i.e. non-young ones)
 124     return _surviving_young_words + 1;
 125   }
 126 
 127   void flush(size_t* surviving_young_words);
 128 
 129  private:
 130   #define G1_PARTIAL_ARRAY_MASK 0x2
 131 
 132   inline bool has_partial_array_mask(oop* ref) const {
 133     return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
 134   }




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_HPP
  26 #define SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_HPP
  27 
  28 #include "gc/g1/dirtyCardQueue.hpp"
  29 #include "gc/g1/g1CollectedHeap.hpp"
  30 #include "gc/g1/g1CollectorPolicy.hpp"
  31 #include "gc/g1/g1OopClosures.hpp"
  32 #include "gc/g1/g1RemSet.hpp"
  33 #include "gc/g1/g1RootClosures.hpp"
  34 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  35 #include "gc/shared/ageTable.hpp"
  36 #include "memory/allocation.hpp"
  37 #include "oops/oop.hpp"
  38 
  39 class G1PLABAllocator;
  40 class HeapRegion;
  41 class outputStream;
  42 
  43 class G1ParScanThreadState : public CHeapObj<mtGC> {
  44  private:
  45   G1CollectedHeap* _g1h;
  46   RefToScanQueue*  _refs;
  47   DirtyCardQueue   _dcq;
  48   G1SATBCardTableModRefBS* _ct_bs;
  49   G1EvacuationRootClosures* _closures;
  50 
  51   G1PLABAllocator*  _plab_allocator;
  52 
  53   ageTable          _age_table;
  54   InCSetState       _dest[InCSetState::Num];
  55   // Local tenuring threshold.
  56   uint              _tenuring_threshold;
  57   G1ParScanClosure  _scanner;
  58 
  59   int  _hash_seed;
  60   uint _worker_id;
  61 
  62   // Map from young-age-index (0 == not young, 1 is youngest) to
  63   // surviving words. base is what we get back from the malloc call
  64   size_t* _surviving_young_words_base;
  65   // this points into the array, as we use the first few entries for padding
  66   size_t* _surviving_young_words;
  67 
  68   // Indicates whether in the last generation (old) there is no more space
  69   // available for allocation.
  70   bool _old_gen_is_full;
  71 
  72 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
  73 
  74   DirtyCardQueue& dirty_card_queue()             { return _dcq;  }
  75   G1SATBCardTableModRefBS* ctbs()                { return _ct_bs; }
  76 
  77   InCSetState dest(InCSetState original) const {
  78     assert(original.is_valid(),
  79            "Original state invalid: " CSETSTATE_FORMAT, original.value());
  80     assert(_dest[original.value()].is_valid_gen(),
  81            "Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value());
  82     return _dest[original.value()];
  83   }
  84 
  85   G1EvacuationRootClosures* new_root_closures();
  86  public:
  87   G1ParScanThreadState(G1CollectedHeap* g1h, uint worker_id, size_t young_cset_length);
  88   ~G1ParScanThreadState();
  89 
  90   void set_ref_processor(ReferenceProcessor* rp) { _scanner.set_ref_processor(rp); }
  91 
  92 #ifdef ASSERT
  93   bool queue_is_empty() const { return _refs->is_empty(); }
  94 
  95   bool verify_ref(narrowOop* ref) const;
  96   bool verify_ref(oop* ref) const;
  97   bool verify_task(StarTask ref) const;
  98 #endif // ASSERT
  99 
 100   template <class T> void push_on_queue(T* ref);
 101 
 102   template <class T> void update_rs(HeapRegion* from, T* p, uint tid) {
 103     // If the new value of the field points to the same region or
 104     // is the to-space, we don't need to include it in the Rset updates.
 105     if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
 106       size_t card_index = ctbs()->index_for(p);
 107       // If the card hasn't been added to the buffer, do it.
 108       if (ctbs()->mark_card_deferred(card_index)) {
 109         dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
 110       }
 111     }
 112   }
 113 
 114   G1EvacuationRootClosures* closures() { return _closures; }
 115   uint worker_id() { return _worker_id; }
 116 
 117   // Returns the current amount of waste due to alignment or not being able to fit
 118   // objects within LABs and the undo waste.
 119   virtual void waste(size_t& wasted, size_t& undo_wasted);
 120 
 121   size_t* surviving_young_words() {
 122     // We add one to hide entry 0 which accumulates surviving words for
 123     // age -1 regions (i.e. non-young ones)
 124     return _surviving_young_words + 1;
 125   }
 126 
 127   void flush(size_t* surviving_young_words);
 128 
 129  private:
 130   #define G1_PARTIAL_ARRAY_MASK 0x2
 131 
 132   inline bool has_partial_array_mask(oop* ref) const {
 133     return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
 134   }


< prev index next >