src/hotspot/share/gc/g1/g1ParScanThreadState.hpp
changeset 54843 25c329958c70
parent 54110 f4f0dce5d0bb
child 55510 3e31a8beaae4
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54842:f9c8e16db3dd 54843:25c329958c70
    43 class HeapRegion;
    43 class HeapRegion;
    44 class outputStream;
    44 class outputStream;
    45 
    45 
    46 class G1ParScanThreadState : public CHeapObj<mtGC> {
    46 class G1ParScanThreadState : public CHeapObj<mtGC> {
    47   G1CollectedHeap* _g1h;
    47   G1CollectedHeap* _g1h;
    48   RefToScanQueue*  _refs;
    48   RefToScanQueue* _refs;
    49   G1DirtyCardQueue _dcq;
    49   G1DirtyCardQueue _dcq;
    50   G1CardTable*     _ct;
    50   G1CardTable* _ct;
    51   G1EvacuationRootClosures* _closures;
    51   G1EvacuationRootClosures* _closures;
    52 
    52 
    53   G1PLABAllocator*  _plab_allocator;
    53   G1PLABAllocator* _plab_allocator;
    54 
    54 
    55   AgeTable          _age_table;
    55   AgeTable _age_table;
    56   InCSetState       _dest[InCSetState::Num];
    56   G1HeapRegionAttr _dest[G1HeapRegionAttr::Num];
    57   // Local tenuring threshold.
    57   // Local tenuring threshold.
    58   uint              _tenuring_threshold;
    58   uint _tenuring_threshold;
    59   G1ScanEvacuatedObjClosure  _scanner;
    59   G1ScanEvacuatedObjClosure  _scanner;
    60 
    60 
    61   uint _worker_id;
    61   uint _worker_id;
    62 
    62 
    63   // Upper and lower threshold to start and end work queue draining.
    63   // Upper and lower threshold to start and end work queue draining.
    78 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
    78 #define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
    79 
    79 
    80   G1DirtyCardQueue& dirty_card_queue()           { return _dcq; }
    80   G1DirtyCardQueue& dirty_card_queue()           { return _dcq; }
    81   G1CardTable* ct()                              { return _ct; }
    81   G1CardTable* ct()                              { return _ct; }
    82 
    82 
    83   InCSetState dest(InCSetState original) const {
    83   G1HeapRegionAttr dest(G1HeapRegionAttr original) const {
    84     assert(original.is_valid(),
    84     assert(original.is_valid(),
    85            "Original state invalid: " CSETSTATE_FORMAT, original.value());
    85            "Original region attr invalid: %s", original.get_type_str());
    86     assert(_dest[original.value()].is_valid_gen(),
    86     assert(_dest[original.type()].is_valid_gen(),
    87            "Dest state is invalid: " CSETSTATE_FORMAT, _dest[original.value()].value());
    87            "Dest region attr is invalid: %s", _dest[original.type()].get_type_str());
    88     return _dest[original.value()];
    88     return _dest[original.type()];
    89   }
    89   }
    90 
    90 
    91   size_t _num_optional_regions;
    91   size_t _num_optional_regions;
    92   G1OopStarChunkedList* _oops_into_optional_regions;
    92   G1OopStarChunkedList* _oops_into_optional_regions;
    93 
    93 
   109 #endif // ASSERT
   109 #endif // ASSERT
   110 
   110 
   111   template <class T> void do_oop_ext(T* ref);
   111   template <class T> void do_oop_ext(T* ref);
   112   template <class T> void push_on_queue(T* ref);
   112   template <class T> void push_on_queue(T* ref);
   113 
   113 
   114   template <class T> void enqueue_card_if_tracked(T* p, oop o) {
   114   template <class T> void enqueue_card_if_tracked(G1HeapRegionAttr region_attr, T* p, oop o) {
   115     assert(!HeapRegion::is_in_same_region(p, o), "Should have filtered out cross-region references already.");
   115     assert(!HeapRegion::is_in_same_region(p, o), "Should have filtered out cross-region references already.");
   116     assert(!_g1h->heap_region_containing(p)->is_young(), "Should have filtered out from-young references already.");
   116     assert(!_g1h->heap_region_containing(p)->is_young(), "Should have filtered out from-young references already.");
   117     if (!_g1h->heap_region_containing((HeapWord*)o)->rem_set()->is_tracked()) {
   117 
       
   118 #ifdef ASSERT
       
   119     HeapRegion* const hr_obj = _g1h->heap_region_containing((HeapWord*)o);
       
   120     assert(region_attr.needs_remset_update() == hr_obj->rem_set()->is_tracked(),
       
   121            "State flag indicating remset tracking disagrees (%s) with actual remembered set (%s) for region %u",
       
   122            BOOL_TO_STR(region_attr.needs_remset_update()),
       
   123            BOOL_TO_STR(hr_obj->rem_set()->is_tracked()),
       
   124            hr_obj->hrm_index());
       
   125 #endif
       
   126     if (!region_attr.needs_remset_update()) {
   118       return;
   127       return;
   119     }
   128     }
   120     size_t card_index = ct()->index_for(p);
   129     size_t card_index = ct()->index_for(p);
   121     // If the card hasn't been added to the buffer, do it.
   130     // If the card hasn't been added to the buffer, do it.
   122     if (ct()->mark_card_deferred(card_index)) {
   131     if (ct()->mark_card_deferred(card_index)) {
   182   // that is allocated for. Previous_plab_refill_failed indicates whether previously
   191   // that is allocated for. Previous_plab_refill_failed indicates whether previously
   183   // a PLAB refill into "state" failed.
   192   // a PLAB refill into "state" failed.
   184   // Returns a non-NULL pointer if successful, and updates dest if required.
   193   // Returns a non-NULL pointer if successful, and updates dest if required.
   185   // Also determines whether we should continue to try to allocate into the various
   194   // Also determines whether we should continue to try to allocate into the various
   186   // generations or just end trying to allocate.
   195   // generations or just end trying to allocate.
   187   HeapWord* allocate_in_next_plab(InCSetState const state,
   196   HeapWord* allocate_in_next_plab(G1HeapRegionAttr const region_attr,
   188                                   InCSetState* dest,
   197                                   G1HeapRegionAttr* dest,
   189                                   size_t word_sz,
   198                                   size_t word_sz,
   190                                   bool previous_plab_refill_failed);
   199                                   bool previous_plab_refill_failed);
   191 
   200 
   192   inline InCSetState next_state(InCSetState const state, markOop const m, uint& age);
   201   inline G1HeapRegionAttr next_region_attr(G1HeapRegionAttr const region_attr, markOop const m, uint& age);
   193 
   202 
   194   void report_promotion_event(InCSetState const dest_state,
   203   void report_promotion_event(G1HeapRegionAttr const dest_attr,
   195                               oop const old, size_t word_sz, uint age,
   204                               oop const old, size_t word_sz, uint age,
   196                               HeapWord * const obj_ptr) const;
   205                               HeapWord * const obj_ptr) const;
   197 
   206 
   198   inline bool needs_partial_trimming() const;
   207   inline bool needs_partial_trimming() const;
   199   inline bool is_partially_trimmed() const;
   208   inline bool is_partially_trimmed() const;
   200 
   209 
   201   inline void trim_queue_to_threshold(uint threshold);
   210   inline void trim_queue_to_threshold(uint threshold);
   202 public:
   211 public:
   203   oop copy_to_survivor_space(InCSetState const state, oop const obj, markOop const old_mark);
   212   oop copy_to_survivor_space(G1HeapRegionAttr const region_attr, oop const obj, markOop const old_mark);
   204 
   213 
   205   void trim_queue();
   214   void trim_queue();
   206   void trim_queue_partially();
   215   void trim_queue_partially();
   207 
   216 
   208   Tickspan trim_ticks() const;
   217   Tickspan trim_ticks() const;