src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp

Print this page
rev 6322 : 8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
Summary: The test incorrectly assumed that it had been started with no other previous compilation activity. Fix this by allowing multiple code root free chunk lists, and use one separate from the global one to perform the test.
Reviewed-by: brutisso
rev 6324 : 8037344: Use the "next" field to iterate over fine remembered instead of using the hash table
Summary: After changes to the PerRegionTable where all these PRTs are linked together in an additional field, simplify iterating over all PRTs by using these links instead of walki
Reviewed-by: mgerdin, jwilhelm, brutisso


 415 #endif
 416 
 417   static void record(HeapRegion* hr, OopOrNarrowOopStar f);
 418   static void print_recorded();
 419   static void record_event(Event evnt);
 420 
 421   // These are wrappers for the similarly-named methods on
 422   // SparsePRT. Look at sparsePRT.hpp for more details.
 423   static void reset_for_cleanup_tasks();
 424   void do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task);
 425   static void finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task);
 426 
 427   // Run unit tests.
 428 #ifndef PRODUCT
 429   static void test_prt();
 430   static void test();
 431 #endif
 432 };
 433 
 434 class HeapRegionRemSetIterator : public StackObj {
 435 
 436   // The region RSet over which we're iterating.
 437   HeapRegionRemSet* _hrrs;
 438 
 439   // Local caching of HRRS fields.
 440   const BitMap*             _coarse_map;
 441   PerRegionTable**          _fine_grain_regions;
 442 
 443   G1BlockOffsetSharedArray* _bosa;
 444   G1CollectedHeap*          _g1h;
 445 
 446   // The number yielded since initialization.
 447   size_t _n_yielded_fine;
 448   size_t _n_yielded_coarse;
 449   size_t _n_yielded_sparse;
 450 
 451   // Indicates what granularity of table that we're currently iterating over.
 452   // We start iterating over the sparse table, progress to the fine grain
 453   // table, and then finish with the coarse table.
 454   // See HeapRegionRemSetIterator::has_next().
 455   enum IterState {
 456     Sparse,
 457     Fine,
 458     Coarse
 459   };
 460   IterState _is;
 461 
 462   // In both kinds of iteration, heap offset of first card of current
 463   // region.
 464   size_t _cur_region_card_offset;
 465   // Card offset within cur region.
 466   size_t _cur_region_cur_card;
 467 
 468   // Coarse table iteration fields:
 469 
 470   // Current region index;
 471   int    _coarse_cur_region_index;
 472   size_t _coarse_cur_region_cur_card;
 473 
 474   bool coarse_has_next(size_t& card_index);
 475 
 476   // Fine table iteration fields:
 477 
 478   // Index of bucket-list we're working on.
 479   int _fine_array_index;
 480 
 481   // Per Region Table we're doing within current bucket list.
 482   PerRegionTable* _fine_cur_prt;


 483 
 484   /* SparsePRT::*/ SparsePRTIter _sparse_iter;
 485 
 486   void fine_find_next_non_null_prt();
 487 
 488   bool fine_has_next();
 489   bool fine_has_next(size_t& card_index);
 490 
 491 public:
 492   // We require an iterator to be initialized before use, so the
 493   // constructor does little.

 494   HeapRegionRemSetIterator(HeapRegionRemSet* hrrs);
 495 
 496   // If there remains one or more cards to be yielded, returns true and
 497   // sets "card_index" to one of those cards (which is then considered
 498   // yielded.)   Otherwise, returns false (and leaves "card_index"
 499   // undefined.)
 500   bool has_next(size_t& card_index);
 501 
 502   size_t n_yielded_fine() { return _n_yielded_fine; }
 503   size_t n_yielded_coarse() { return _n_yielded_coarse; }
 504   size_t n_yielded_sparse() { return _n_yielded_sparse; }
 505   size_t n_yielded() {
 506     return n_yielded_fine() + n_yielded_coarse() + n_yielded_sparse();
 507   }
 508 };
 509 
 510 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONREMSET_HPP


 415 #endif
 416 
 417   static void record(HeapRegion* hr, OopOrNarrowOopStar f);
 418   static void print_recorded();
 419   static void record_event(Event evnt);
 420 
 421   // These are wrappers for the similarly-named methods on
 422   // SparsePRT. Look at sparsePRT.hpp for more details.
 423   static void reset_for_cleanup_tasks();
 424   void do_cleanup_work(HRRSCleanupTask* hrrs_cleanup_task);
 425   static void finish_cleanup_task(HRRSCleanupTask* hrrs_cleanup_task);
 426 
 427   // Run unit tests.
 428 #ifndef PRODUCT
 429   static void test_prt();
 430   static void test();
 431 #endif
 432 };
 433 
 434 class HeapRegionRemSetIterator : public StackObj {
 435  private:
 436   // The region RSet over which we are iterating.
 437   HeapRegionRemSet* _hrrs;
 438 
 439   // Local caching of HRRS fields.
 440   const BitMap*             _coarse_map;

 441 
 442   G1BlockOffsetSharedArray* _bosa;
 443   G1CollectedHeap*          _g1h;
 444 
 445   // The number of cards yielded since initialization.
 446   size_t _n_yielded_fine;
 447   size_t _n_yielded_coarse;
 448   size_t _n_yielded_sparse;
 449 
 450   // Indicates what granularity of table that we are currently iterating over.
 451   // We start iterating over the sparse table, progress to the fine grain
 452   // table, and then finish with the coarse table.

 453   enum IterState {
 454     Sparse,
 455     Fine,
 456     Coarse
 457   };
 458   IterState _is;
 459 
 460   // For both Coarse and Fine remembered set iteration this contains the
 461   // first card number of the heap region we currently iterate over.
 462   size_t _cur_region_card_offset;




 463 
 464   // Current region index for the Coarse remembered set iteration.
 465   int    _coarse_cur_region_index;
 466   size_t _coarse_cur_region_cur_card;
 467 
 468   bool coarse_has_next(size_t& card_index);
 469 
 470   // The PRT we are currently iterating over.





 471   PerRegionTable* _fine_cur_prt;
 472   // Card offset within the current PRT.
 473   size_t _cur_card_in_prt;
 474 
 475   // Update internal variables when switching to the given PRT.
 476   void switch_to_prt(PerRegionTable* prt);


 477   bool fine_has_next();
 478   bool fine_has_next(size_t& card_index);
 479 
 480   // The Sparse remembered set iterator.
 481   SparsePRTIter _sparse_iter;
 482 
 483  public:
 484   HeapRegionRemSetIterator(HeapRegionRemSet* hrrs);
 485 
 486   // If there remains one or more cards to be yielded, returns true and
 487   // sets "card_index" to one of those cards (which is then considered
 488   // yielded.)   Otherwise, returns false (and leaves "card_index"
 489   // undefined.)
 490   bool has_next(size_t& card_index);
 491 
 492   size_t n_yielded_fine() { return _n_yielded_fine; }
 493   size_t n_yielded_coarse() { return _n_yielded_coarse; }
 494   size_t n_yielded_sparse() { return _n_yielded_sparse; }
 495   size_t n_yielded() {
 496     return n_yielded_fine() + n_yielded_coarse() + n_yielded_sparse();
 497   }
 498 };
 499 
 500 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONREMSET_HPP