src/share/vm/gc_implementation/g1/heapRegionSeq.cpp

changeset 3713
720b6a76dd9d
parent 2963
c3f1170908be
child 3900
d2a62e0f25eb
     1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Wed Apr 11 16:18:45 2012 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp	Wed Apr 18 07:21:15 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -31,16 +31,15 @@
    1.11  
    1.12  // Private
    1.13  
    1.14 -size_t HeapRegionSeq::find_contiguous_from(size_t from, size_t num) {
    1.15 -  size_t len = length();
    1.16 +uint HeapRegionSeq::find_contiguous_from(uint from, uint num) {
    1.17 +  uint len = length();
    1.18    assert(num > 1, "use this only for sequences of length 2 or greater");
    1.19    assert(from <= len,
    1.20 -         err_msg("from: "SIZE_FORMAT" should be valid and <= than "SIZE_FORMAT,
    1.21 -                 from, len));
    1.22 +         err_msg("from: %u should be valid and <= than %u", from, len));
    1.23  
    1.24 -  size_t curr = from;
    1.25 -  size_t first = G1_NULL_HRS_INDEX;
    1.26 -  size_t num_so_far = 0;
    1.27 +  uint curr = from;
    1.28 +  uint first = G1_NULL_HRS_INDEX;
    1.29 +  uint num_so_far = 0;
    1.30    while (curr < len && num_so_far < num) {
    1.31      if (at(curr)->is_empty()) {
    1.32        if (first == G1_NULL_HRS_INDEX) {
    1.33 @@ -60,7 +59,7 @@
    1.34      // we found enough space for the humongous object
    1.35      assert(from <= first && first < len, "post-condition");
    1.36      assert(first < curr && (curr - first) == num, "post-condition");
    1.37 -    for (size_t i = first; i < first + num; ++i) {
    1.38 +    for (uint i = first; i < first + num; ++i) {
    1.39        assert(at(i)->is_empty(), "post-condition");
    1.40      }
    1.41      return first;
    1.42 @@ -73,10 +72,10 @@
    1.43  // Public
    1.44  
    1.45  void HeapRegionSeq::initialize(HeapWord* bottom, HeapWord* end,
    1.46 -                               size_t max_length) {
    1.47 -  assert((size_t) bottom % HeapRegion::GrainBytes == 0,
    1.48 +                               uint max_length) {
    1.49 +  assert((uintptr_t) bottom % HeapRegion::GrainBytes == 0,
    1.50           "bottom should be heap region aligned");
    1.51 -  assert((size_t) end % HeapRegion::GrainBytes == 0,
    1.52 +  assert((uintptr_t) end % HeapRegion::GrainBytes == 0,
    1.53           "end should be heap region aligned");
    1.54  
    1.55    _length = 0;
    1.56 @@ -88,8 +87,8 @@
    1.57    _max_length = max_length;
    1.58  
    1.59    _regions = NEW_C_HEAP_ARRAY(HeapRegion*, max_length);
    1.60 -  memset(_regions, 0, max_length * sizeof(HeapRegion*));
    1.61 -  _regions_biased = _regions - ((size_t) bottom >> _region_shift);
    1.62 +  memset(_regions, 0, (size_t) max_length * sizeof(HeapRegion*));
    1.63 +  _regions_biased = _regions - ((uintx) bottom >> _region_shift);
    1.64  
    1.65    assert(&_regions[0] == &_regions_biased[addr_to_index_biased(bottom)],
    1.66           "bottom should be included in the region with index 0");
    1.67 @@ -105,7 +104,7 @@
    1.68    assert(_heap_bottom <= next_bottom, "invariant");
    1.69    while (next_bottom < new_end) {
    1.70      assert(next_bottom < _heap_end, "invariant");
    1.71 -    size_t index = length();
    1.72 +    uint index = length();
    1.73  
    1.74      assert(index < _max_length, "otherwise we cannot expand further");
    1.75      if (index == 0) {
    1.76 @@ -139,9 +138,9 @@
    1.77    return MemRegion(old_end, next_bottom);
    1.78  }
    1.79  
    1.80 -size_t HeapRegionSeq::free_suffix() {
    1.81 -  size_t res = 0;
    1.82 -  size_t index = length();
    1.83 +uint HeapRegionSeq::free_suffix() {
    1.84 +  uint res = 0;
    1.85 +  uint index = length();
    1.86    while (index > 0) {
    1.87      index -= 1;
    1.88      if (!at(index)->is_empty()) {
    1.89 @@ -152,27 +151,24 @@
    1.90    return res;
    1.91  }
    1.92  
    1.93 -size_t HeapRegionSeq::find_contiguous(size_t num) {
    1.94 +uint HeapRegionSeq::find_contiguous(uint num) {
    1.95    assert(num > 1, "use this only for sequences of length 2 or greater");
    1.96    assert(_next_search_index <= length(),
    1.97 -         err_msg("_next_search_indeex: "SIZE_FORMAT" "
    1.98 -                 "should be valid and <= than "SIZE_FORMAT,
    1.99 +         err_msg("_next_search_index: %u should be valid and <= than %u",
   1.100                   _next_search_index, length()));
   1.101  
   1.102 -  size_t start = _next_search_index;
   1.103 -  size_t res = find_contiguous_from(start, num);
   1.104 +  uint start = _next_search_index;
   1.105 +  uint res = find_contiguous_from(start, num);
   1.106    if (res == G1_NULL_HRS_INDEX && start > 0) {
   1.107      // Try starting from the beginning. If _next_search_index was 0,
   1.108      // no point in doing this again.
   1.109      res = find_contiguous_from(0, num);
   1.110    }
   1.111    if (res != G1_NULL_HRS_INDEX) {
   1.112 -    assert(res < length(),
   1.113 -           err_msg("res: "SIZE_FORMAT" should be valid", res));
   1.114 +    assert(res < length(), err_msg("res: %u should be valid", res));
   1.115      _next_search_index = res + num;
   1.116      assert(_next_search_index <= length(),
   1.117 -           err_msg("_next_search_indeex: "SIZE_FORMAT" "
   1.118 -                   "should be valid and <= than "SIZE_FORMAT,
   1.119 +           err_msg("_next_search_index: %u should be valid and <= than %u",
   1.120                     _next_search_index, length()));
   1.121    }
   1.122    return res;
   1.123 @@ -183,20 +179,20 @@
   1.124  }
   1.125  
   1.126  void HeapRegionSeq::iterate_from(HeapRegion* hr, HeapRegionClosure* blk) const {
   1.127 -  size_t hr_index = 0;
   1.128 +  uint hr_index = 0;
   1.129    if (hr != NULL) {
   1.130 -    hr_index = (size_t) hr->hrs_index();
   1.131 +    hr_index = hr->hrs_index();
   1.132    }
   1.133  
   1.134 -  size_t len = length();
   1.135 -  for (size_t i = hr_index; i < len; i += 1) {
   1.136 +  uint len = length();
   1.137 +  for (uint i = hr_index; i < len; i += 1) {
   1.138      bool res = blk->doHeapRegion(at(i));
   1.139      if (res) {
   1.140        blk->incomplete();
   1.141        return;
   1.142      }
   1.143    }
   1.144 -  for (size_t i = 0; i < hr_index; i += 1) {
   1.145 +  for (uint i = 0; i < hr_index; i += 1) {
   1.146      bool res = blk->doHeapRegion(at(i));
   1.147      if (res) {
   1.148        blk->incomplete();
   1.149 @@ -206,7 +202,7 @@
   1.150  }
   1.151  
   1.152  MemRegion HeapRegionSeq::shrink_by(size_t shrink_bytes,
   1.153 -                                   size_t* num_regions_deleted) {
   1.154 +                                   uint* num_regions_deleted) {
   1.155    // Reset this in case it's currently pointing into the regions that
   1.156    // we just removed.
   1.157    _next_search_index = 0;
   1.158 @@ -218,7 +214,7 @@
   1.159    assert(_allocated_length > 0, "we should have at least one region committed");
   1.160  
   1.161    // around the loop, i will be the next region to be removed
   1.162 -  size_t i = length() - 1;
   1.163 +  uint i = length() - 1;
   1.164    assert(i > 0, "we should never remove all regions");
   1.165    // [last_start, end) is the MemRegion that covers the regions we will remove.
   1.166    HeapWord* end = at(i)->end();
   1.167 @@ -249,29 +245,24 @@
   1.168  #ifndef PRODUCT
   1.169  void HeapRegionSeq::verify_optional() {
   1.170    guarantee(_length <= _allocated_length,
   1.171 -            err_msg("invariant: _length: "SIZE_FORMAT" "
   1.172 -                    "_allocated_length: "SIZE_FORMAT,
   1.173 +            err_msg("invariant: _length: %u _allocated_length: %u",
   1.174                      _length, _allocated_length));
   1.175    guarantee(_allocated_length <= _max_length,
   1.176 -            err_msg("invariant: _allocated_length: "SIZE_FORMAT" "
   1.177 -                    "_max_length: "SIZE_FORMAT,
   1.178 +            err_msg("invariant: _allocated_length: %u _max_length: %u",
   1.179                      _allocated_length, _max_length));
   1.180    guarantee(_next_search_index <= _length,
   1.181 -            err_msg("invariant: _next_search_index: "SIZE_FORMAT" "
   1.182 -                    "_length: "SIZE_FORMAT,
   1.183 +            err_msg("invariant: _next_search_index: %u _length: %u",
   1.184                      _next_search_index, _length));
   1.185  
   1.186    HeapWord* prev_end = _heap_bottom;
   1.187 -  for (size_t i = 0; i < _allocated_length; i += 1) {
   1.188 +  for (uint i = 0; i < _allocated_length; i += 1) {
   1.189      HeapRegion* hr = _regions[i];
   1.190 -    guarantee(hr != NULL, err_msg("invariant: i: "SIZE_FORMAT, i));
   1.191 +    guarantee(hr != NULL, err_msg("invariant: i: %u", i));
   1.192      guarantee(hr->bottom() == prev_end,
   1.193 -              err_msg("invariant i: "SIZE_FORMAT" "HR_FORMAT" "
   1.194 -                      "prev_end: "PTR_FORMAT,
   1.195 +              err_msg("invariant i: %u "HR_FORMAT" prev_end: "PTR_FORMAT,
   1.196                        i, HR_FORMAT_PARAMS(hr), prev_end));
   1.197      guarantee(hr->hrs_index() == i,
   1.198 -              err_msg("invariant: i: "SIZE_FORMAT" hrs_index(): "SIZE_FORMAT,
   1.199 -                      i, hr->hrs_index()));
   1.200 +              err_msg("invariant: i: %u hrs_index(): %u", i, hr->hrs_index()));
   1.201      if (i < _length) {
   1.202        // Asserts will fire if i is >= _length
   1.203        HeapWord* addr = hr->bottom();
   1.204 @@ -290,8 +281,8 @@
   1.205        prev_end = hr->end();
   1.206      }
   1.207    }
   1.208 -  for (size_t i = _allocated_length; i < _max_length; i += 1) {
   1.209 -    guarantee(_regions[i] == NULL, err_msg("invariant i: "SIZE_FORMAT, i));
   1.210 +  for (uint i = _allocated_length; i < _max_length; i += 1) {
   1.211 +    guarantee(_regions[i] == NULL, err_msg("invariant i: %u", i));
   1.212    }
   1.213  }
   1.214  #endif // PRODUCT

mercurial