Print this page
rev 2722 : 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
Summary: Declare GrainBytes, GrainWords, and CardsPerRegion as size_t.
Reviewed-by:

Split Close
Expand all
Collapse all
          --- old/src/share/vm/gc_implementation/g1/heapRegion.cpp
          +++ new/src/share/vm/gc_implementation/g1/heapRegion.cpp
↓ open down ↓ 25 lines elided ↑ open up ↑
  26   26  #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
  27   27  #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  28   28  #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  29   29  #include "gc_implementation/g1/heapRegion.inline.hpp"
  30   30  #include "gc_implementation/g1/heapRegionRemSet.hpp"
  31   31  #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
  32   32  #include "memory/genOopClosures.inline.hpp"
  33   33  #include "memory/iterator.hpp"
  34   34  #include "oops/oop.inline.hpp"
  35   35  
  36      -int HeapRegion::LogOfHRGrainBytes = 0;
  37      -int HeapRegion::LogOfHRGrainWords = 0;
  38      -int HeapRegion::GrainBytes        = 0;
  39      -int HeapRegion::GrainWords        = 0;
  40      -int HeapRegion::CardsPerRegion    = 0;
       36 +int    HeapRegion::LogOfHRGrainBytes = 0;
       37 +int    HeapRegion::LogOfHRGrainWords = 0;
       38 +size_t HeapRegion::GrainBytes        = 0;
       39 +size_t HeapRegion::GrainWords        = 0;
       40 +size_t HeapRegion::CardsPerRegion    = 0;
  41   41  
  42   42  HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
  43   43                                   HeapRegion* hr, OopClosure* cl,
  44   44                                   CardTableModRefBS::PrecisionStyle precision,
  45   45                                   FilterKind fk) :
  46   46    ContiguousSpaceDCTOC(hr, cl, precision, NULL),
  47   47    _hr(hr), _fk(fk), _g1(g1)
  48   48  { }
  49   49  
  50   50  FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
↓ open down ↓ 291 lines elided ↑ open up ↑
 342  342    // Now, set up the globals.
 343  343    guarantee(LogOfHRGrainBytes == 0, "we should only set it once");
 344  344    LogOfHRGrainBytes = region_size_log;
 345  345  
 346  346    guarantee(LogOfHRGrainWords == 0, "we should only set it once");
 347  347    LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize;
 348  348  
 349  349    guarantee(GrainBytes == 0, "we should only set it once");
 350  350    // The cast to int is safe, given that we've bounded region_size by
 351  351    // MIN_REGION_SIZE and MAX_REGION_SIZE.
 352      -  GrainBytes = (int) region_size;
      352 +  GrainBytes = (size_t)region_size;
 353  353  
 354  354    guarantee(GrainWords == 0, "we should only set it once");
 355  355    GrainWords = GrainBytes >> LogHeapWordSize;
 356      -  guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity");
      356 +  guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
 357  357  
 358  358    guarantee(CardsPerRegion == 0, "we should only set it once");
 359  359    CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
 360  360  }
 361  361  
 362  362  void HeapRegion::reset_after_compaction() {
 363  363    G1OffsetTableContigSpace::reset_after_compaction();
 364  364    // After a compaction the mark bitmap is invalid, so we must
 365  365    // treat all objects as being inside the unmarked area.
 366  366    zero_marked_bytes();
↓ open down ↓ 32 lines elided ↑ open up ↑
 399  399    zero_marked_bytes();
 400  400    set_sort_index(-1);
 401  401  
 402  402    _offsets.resize(HeapRegion::GrainWords);
 403  403    init_top_at_mark_start();
 404  404    if (clear_space) clear(SpaceDecorator::Mangle);
 405  405  }
 406  406  
 407  407  void HeapRegion::par_clear() {
 408  408    assert(used() == 0, "the region should have been already cleared");
 409      -  assert(capacity() == (size_t) HeapRegion::GrainBytes,
 410      -         "should be back to normal");
      409 +  assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
 411  410    HeapRegionRemSet* hrrs = rem_set();
 412  411    hrrs->clear();
 413  412    CardTableModRefBS* ct_bs =
 414  413                     (CardTableModRefBS*)G1CollectedHeap::heap()->barrier_set();
 415  414    ct_bs->clear(MemRegion(bottom(), end()));
 416  415  }
 417  416  
 418  417  // <PREDICTION>
 419  418  void HeapRegion::calc_gc_efficiency() {
 420  419    G1CollectedHeap* g1h = G1CollectedHeap::heap();
↓ open down ↓ 35 lines elided ↑ open up ↑
 456  455      set_end(_orig_end);
 457  456      if (top() > end()) {
 458  457        // at least one "continues humongous" region after it
 459  458        set_top(end());
 460  459      }
 461  460    } else {
 462  461      // continues humongous
 463  462      assert(end() == _orig_end, "sanity");
 464  463    }
 465  464  
 466      -  assert(capacity() == (size_t) HeapRegion::GrainBytes, "pre-condition");
      465 +  assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
 467  466    _humongous_type = NotHumongous;
 468  467    _humongous_start_region = NULL;
 469  468  }
 470  469  
 471  470  bool HeapRegion::claimHeapRegion(jint claimValue) {
 472  471    jint current = _claimed;
 473  472    if (current != claimValue) {
 474  473      jint res = Atomic::cmpxchg(claimValue, &_claimed, current);
 475  474      if (res == current) {
 476  475        return true;
↓ open down ↓ 522 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX