hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp

Print this page




  55   // Size of committed space for the counts table
  56   size_t _committed_size;
  57 
  58   // CardTable bottom.
  59   const jbyte* _ct_bot;
  60 
  61   // Barrier set
  62   CardTableModRefBS* _ct_bs;
  63 
  64   // The virtual memory backing the counts table
  65   VirtualSpace _card_counts_storage;
  66 
  67   // Returns true if the card counts table has been reserved.
  68   bool has_reserved_count_table() { return _card_counts != NULL; }
  69 
  70   // Returns true if the card counts table has been reserved and committed.
  71   bool has_count_table() {
  72     return has_reserved_count_table() && _committed_max_card_num > 0;
  73   }
  74 
  75   void check_card_num(size_t card_num, const char* msg) {
  76     assert(card_num >= 0 && card_num < _committed_max_card_num, msg);

  77   }
  78 
  79   size_t ptr_2_card_num(const jbyte* card_ptr) {
  80     assert(card_ptr >= _ct_bot,
  81            err_msg("Inavalied card pointer: "
  82                    "card_ptr: " PTR_FORMAT ", "
  83                    "_ct_bot: " PTR_FORMAT,
  84                    card_ptr, _ct_bot));
  85     size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
  86     check_card_num(card_num,
  87                    err_msg("card pointer out of range: " PTR_FORMAT, card_ptr));
  88     return card_num;
  89   }
  90 
  91   jbyte* card_num_2_ptr(size_t card_num) {
  92     check_card_num(card_num,
  93                    err_msg("card num out of range: "SIZE_FORMAT, card_num));
  94     return (jbyte*) (_ct_bot + card_num);
  95   }
  96 
  97   // Helper routine.
  98   // Returns the number of cards that can be counted by the given committed
  99   // table size, with a maximum of the number of cards spanned by the max
 100   // capacity of the heap.
 101   size_t committed_to_card_num(size_t committed_size) {
 102     return MIN2(_reserved_max_card_num, committed_size / sizeof(jbyte));
 103   }
 104 
 105   // Clear the counts table for the given (exclusive) index range.
 106   void clear_range(size_t from_card_num, size_t to_card_num);
 107 
 108  public:
 109   G1CardCounts(G1CollectedHeap* g1h);
 110   ~G1CardCounts();
 111 
 112   void initialize();
 113 




  55   // Size of committed space for the counts table
  56   size_t _committed_size;
  57 
  58   // CardTable bottom.
  59   const jbyte* _ct_bot;
  60 
  61   // Barrier set
  62   CardTableModRefBS* _ct_bs;
  63 
  64   // The virtual memory backing the counts table
  65   VirtualSpace _card_counts_storage;
  66 
  67   // Returns true if the card counts table has been reserved.
  68   bool has_reserved_count_table() { return _card_counts != NULL; }
  69 
  70   // Returns true if the card counts table has been reserved and committed.
  71   bool has_count_table() {
  72     return has_reserved_count_table() && _committed_max_card_num > 0;
  73   }
  74 
  75   void check_card_num(size_t card_num) {
  76     assert(card_num >= 0 && card_num < _committed_max_card_num, 
  77             err_msg("card num out of range: "SIZE_FORMAT, card_num));
  78   }
  79 
  80   size_t ptr_2_card_num(const jbyte* card_ptr) {
  81     assert(card_ptr >= _ct_bot,
  82            err_msg("Inavalied card pointer: "
  83                    "card_ptr: " PTR_FORMAT ", "
  84                    "_ct_bot: " PTR_FORMAT,
  85                    card_ptr, _ct_bot));
  86     size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
  87     check_card_num(card_num);

  88     return card_num;
  89   }
  90 
  91   jbyte* card_num_2_ptr(size_t card_num) {
  92     check_card_num(card_num);

  93     return (jbyte*) (_ct_bot + card_num);
  94   }
  95 
  96   // Helper routine.
  97   // Returns the number of cards that can be counted by the given committed
  98   // table size, with a maximum of the number of cards spanned by the max
  99   // capacity of the heap.
 100   size_t committed_to_card_num(size_t committed_size) {
 101     return MIN2(_reserved_max_card_num, committed_size / sizeof(jbyte));
 102   }
 103 
 104   // Clear the counts table for the given (exclusive) index range.
 105   void clear_range(size_t from_card_num, size_t to_card_num);
 106 
 107  public:
 108   G1CardCounts(G1CollectedHeap* g1h);
 109   ~G1CardCounts();
 110 
 111   void initialize();
 112