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

changeset 3028
f44782f04dd4
parent 2715
abdfc822206f
child 3713
720b6a76dd9d
     1.1 --- a/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Thu Aug 11 11:36:29 2011 -0700
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp	Fri Aug 12 11:31:06 2011 -0400
     1.3 @@ -129,6 +129,7 @@
     1.4      // region in _alloc_region. This is the reason why an active region
     1.5      // can never be empty.
     1.6      _alloc_region = new_alloc_region;
     1.7 +    _count += 1;
     1.8      trace("region allocation successful");
     1.9      return result;
    1.10    } else {
    1.11 @@ -139,8 +140,8 @@
    1.12  }
    1.13  
    1.14  void G1AllocRegion::fill_in_ext_msg(ar_ext_msg* msg, const char* message) {
    1.15 -  msg->append("[%s] %s b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT,
    1.16 -              _name, message, BOOL_TO_STR(_bot_updates),
    1.17 +  msg->append("[%s] %s c: "SIZE_FORMAT" b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT,
    1.18 +              _name, message, _count, BOOL_TO_STR(_bot_updates),
    1.19                _alloc_region, _used_bytes_before);
    1.20  }
    1.21  
    1.22 @@ -148,16 +149,34 @@
    1.23    trace("initializing");
    1.24    assert(_alloc_region == NULL && _used_bytes_before == 0,
    1.25           ar_ext_msg(this, "pre-condition"));
    1.26 -  assert(_dummy_region != NULL, "should have been set");
    1.27 +  assert(_dummy_region != NULL, ar_ext_msg(this, "should have been set"));
    1.28    _alloc_region = _dummy_region;
    1.29 +  _count = 0;
    1.30    trace("initialized");
    1.31  }
    1.32  
    1.33 +void G1AllocRegion::set(HeapRegion* alloc_region) {
    1.34 +  trace("setting");
    1.35 +  // We explicitly check that the region is not empty to make sure we
    1.36 +  // maintain the "the alloc region cannot be empty" invariant.
    1.37 +  assert(alloc_region != NULL && !alloc_region->is_empty(),
    1.38 +         ar_ext_msg(this, "pre-condition"));
    1.39 +  assert(_alloc_region == _dummy_region &&
    1.40 +         _used_bytes_before == 0 && _count == 0,
    1.41 +         ar_ext_msg(this, "pre-condition"));
    1.42 +
    1.43 +  _used_bytes_before = alloc_region->used();
    1.44 +  _alloc_region = alloc_region;
    1.45 +  _count += 1;
    1.46 +  trace("set");
    1.47 +}
    1.48 +
    1.49  HeapRegion* G1AllocRegion::release() {
    1.50    trace("releasing");
    1.51    HeapRegion* alloc_region = _alloc_region;
    1.52    retire(false /* fill_up */);
    1.53 -  assert(_alloc_region == _dummy_region, "post-condition of retire()");
    1.54 +  assert(_alloc_region == _dummy_region,
    1.55 +         ar_ext_msg(this, "post-condition of retire()"));
    1.56    _alloc_region = NULL;
    1.57    trace("released");
    1.58    return (alloc_region == _dummy_region) ? NULL : alloc_region;
    1.59 @@ -196,7 +215,8 @@
    1.60        jio_snprintf(rest_buffer, buffer_length, "");
    1.61      }
    1.62  
    1.63 -    tty->print_cr("[%s] %s : %s %s", _name, hr_buffer, str, rest_buffer);
    1.64 +    tty->print_cr("[%s] "SIZE_FORMAT" %s : %s %s",
    1.65 +                  _name, _count, hr_buffer, str, rest_buffer);
    1.66    }
    1.67  }
    1.68  #endif // G1_ALLOC_REGION_TRACING
    1.69 @@ -204,5 +224,5 @@
    1.70  G1AllocRegion::G1AllocRegion(const char* name,
    1.71                               bool bot_updates)
    1.72    : _name(name), _bot_updates(bot_updates),
    1.73 -    _alloc_region(NULL), _used_bytes_before(0) { }
    1.74 +    _alloc_region(NULL), _count(0), _used_bytes_before(0) { }
    1.75  

mercurial