Print this page
8236073: G1: Use SoftMaxHeapSize to guide GC heuristics

Split Close
Expand all
Collapse all
          --- old/src/hotspot/share/gc/g1/heterogeneousHeapRegionManager.cpp
          +++ new/src/hotspot/share/gc/g1/heterogeneousHeapRegionManager.cpp
↓ open down ↓ 150 lines elided ↑ open up ↑
 151  151    uint num_regions = 0;
 152  152  
 153  153    uint cur = start_idx;
 154  154    while (cur <= end_idx && is_available(cur)) {
 155  155      cur++;
 156  156    }
 157  157    if (cur == end_idx + 1) {
 158  158      return num_regions;
 159  159    }
 160  160    *res_idx = cur;
 161      -  while (cur <= end_idx && !is_available(cur)) {
      161 +  while (cur <= end_idx && is_unavailable_for_allocation(cur)) {
 162  162      cur++;
 163  163    }
 164  164    num_regions = cur - *res_idx;
 165  165  
 166  166  #ifdef ASSERT
 167  167    for (uint i = *res_idx; i < (*res_idx + num_regions); i++) {
 168      -    assert(!is_available(i), "just checking");
      168 +    assert(is_unavailable_for_allocation(i), "just checking");
 169  169    }
 170  170    assert(cur == end_idx + 1 || num_regions == 0 || is_available(cur),
 171  171      "The region at the current position %u must be available or at the end", cur);
 172  172  #endif
 173  173    return num_regions;
 174  174  }
 175  175  
 176  176  uint HeterogeneousHeapRegionManager::expand_dram(uint num_regions, WorkGang* pretouch_workers) {
 177  177    return expand_in_range(start_index_of_dram(), end_index_of_dram(), num_regions, pretouch_workers);
 178  178  }
↓ open down ↓ 161 lines elided ↑ open up ↑
 340  340  }
 341  341  
 342  342  uint HeterogeneousHeapRegionManager::find_contiguous(size_t start, size_t end, size_t num, bool empty_only) {
 343  343    uint found = 0;
 344  344    size_t length_found = 0;
 345  345    uint cur = (uint)start;
 346  346    uint length_unavailable = 0;
 347  347  
 348  348    while (length_found < num && cur <= end) {
 349  349      HeapRegion* hr = _regions.get_by_index(cur);
 350      -    if ((!empty_only && !is_available(cur)) || (is_available(cur) && hr != NULL && hr->is_empty())) {
      350 +    if ((!empty_only && is_unavailable_for_allocation(cur)) || (is_available(cur) && hr != NULL && hr->is_empty())) {
 351  351        // This region is a potential candidate for allocation into.
 352      -      if (!is_available(cur)) {
      352 +      if (is_unavailable_for_allocation(cur)) {
 353  353          if(shrink_dram(1) == 1) {
 354  354            uint ret = expand_in_range(cur, cur, 1, NULL);
 355  355            assert(ret == 1, "We should be able to expand at this index");
 356  356          } else {
 357  357            length_unavailable++;
 358  358          }
 359  359        }
 360  360        length_found++;
 361  361      }
 362  362      else {
↓ open down ↓ 1 lines elided ↑ open up ↑
 364  364        found = cur + 1;
 365  365        length_found = 0;
 366  366      }
 367  367      cur++;
 368  368    }
 369  369  
 370  370    if (length_found == num) {
 371  371      for (uint i = found; i < (found + num); i++) {
 372  372        HeapRegion* hr = _regions.get_by_index(i);
 373  373        // sanity check
 374      -      guarantee((!empty_only && !is_available(i)) || (is_available(i) && hr != NULL && hr->is_empty()),
      374 +      guarantee((!empty_only && is_unavailable_for_allocation(i)) || (is_available(i) && hr != NULL && hr->is_empty()),
 375  375                  "Found region sequence starting at " UINT32_FORMAT ", length " SIZE_FORMAT
 376  376                  " that is not empty at " UINT32_FORMAT ". Hr is " PTR_FORMAT, found, num, i, p2i(hr));
 377  377      }
 378  378      if (!empty_only && length_unavailable > (max_expandable_length() - total_regions_committed())) {
 379  379        // if 'length_unavailable' number of regions will be made available, we will exceed max regions.
 380  380        return G1_NO_HRM_INDEX;
 381  381      }
 382  382      return found;
 383  383    }
 384  384    else {
↓ open down ↓ 139 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX