hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeList.hpp
author ysr
Fri, 29 Feb 2008 14:42:56 -0800
changeset 185 cda2a1eb4be5
parent 1 489c9b5090e2
child 578 862a85ed20db
permissions -rw-r--r--
6668743: CMS: Consolidate block statistics reporting code Summary: Reduce the amount of related code replication and improve pretty printing. Reviewed-by: jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
class CompactibleFreeListSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// A class for maintaining a free list of FreeChunk's.  The FreeList
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// maintains a the structure of the list (head, tail, etc.) plus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// statistics for allocations from the list.  The links between items
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// are not part of FreeList.  The statistics are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// used to make decisions about coalescing FreeChunk's when they
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// are swept during collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// See the corresponding .cpp file for a description of the specifics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// for that implementation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class Mutex;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class FreeList VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  friend class CompactibleFreeListSpace;
185
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
    41
  friend class printTreeCensusClosure;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  FreeChunk*    _head;          // List of free chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  FreeChunk*    _tail;          // Tail of list of free chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  size_t        _size;          // Size in Heap words of each chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  ssize_t       _count;         // Number of entries in list
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  size_t        _hint;          // next larger size list with a positive surplus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  AllocationStats _allocation_stats;            // statistics for smart allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  Mutex*        _protecting_lock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Asserts false if the protecting lock (if any) is not held.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  void assert_proper_lock_protection_work() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void assert_proper_lock_protection() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    if (_protecting_lock != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      assert_proper_lock_protection_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Initialize the allocation statistics.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  void init_statistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void set_count(ssize_t v) { _count = v;}
185
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
    67
  void increment_count()    { _count++; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  void decrement_count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _count--;
185
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
    70
    assert(_count >= 0, "Count should not be negative");
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
    71
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Construct a list without any entries.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  FreeList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Construct a list with "fc" as the first (and lone) entry in the list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  FreeList(FreeChunk* fc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Construct a list which will have a FreeChunk at address "addr" and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // of size "size" as the first (and lone) entry in the list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  FreeList(HeapWord* addr, size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // Reset the head, tail, hint, and count of a free list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  void reset(size_t hint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Declare the current free list to be protected by the given lock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  void set_protecting_lock(Mutex* protecting_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    _protecting_lock = protecting_lock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // Accessors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  FreeChunk* head() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    return _head;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  void set_head(FreeChunk* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    _head = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    assert(!_head || _head->size() == _size, "bad chunk size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Set the head of the list and set the prev field of non-null
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // values to NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void link_head(FreeChunk* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    set_head(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    // If this method is not used (just set the head instead),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    // this check can be avoided.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    if (v != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      v->linkPrev(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  FreeChunk* tail() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    return _tail;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void set_tail(FreeChunk* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    _tail = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    assert(!_tail || _tail->size() == _size, "bad chunk size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // Set the tail of the list and set the next field of non-null
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // values to NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  void link_tail(FreeChunk* v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    set_tail(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    if (v != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      v->clearNext();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // No locking checks in read-accessors: lock-free reads (only) are benign.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Readers are expected to have the lock if they are doing work that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // requires atomicity guarantees in sections of code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  size_t size() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    return _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  void set_size(size_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    _size = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  ssize_t count() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    return _count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  size_t hint() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    return _hint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  void set_hint(size_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    assert(v == 0 || _size < v, "Bad hint"); _hint = v;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  // Accessors for statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  AllocationStats* allocation_stats() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    return &_allocation_stats;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  ssize_t desired() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    return _allocation_stats.desired();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  }
185
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   164
  void set_desired(ssize_t v) {
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   165
    assert_proper_lock_protection();
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   166
    _allocation_stats.set_desired(v);
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   167
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  void compute_desired(float inter_sweep_current,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
                       float inter_sweep_estimate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    _allocation_stats.compute_desired(_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
                                      inter_sweep_current,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
                                      inter_sweep_estimate);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  ssize_t coalDesired() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return _allocation_stats.coalDesired();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void set_coalDesired(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    _allocation_stats.set_coalDesired(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  ssize_t surplus() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    return _allocation_stats.surplus();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  void set_surplus(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    _allocation_stats.set_surplus(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  void increment_surplus() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    _allocation_stats.increment_surplus();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void decrement_surplus() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    _allocation_stats.decrement_surplus();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  ssize_t bfrSurp() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    return _allocation_stats.bfrSurp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  void set_bfrSurp(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    _allocation_stats.set_bfrSurp(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  ssize_t prevSweep() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    return _allocation_stats.prevSweep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  void set_prevSweep(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    _allocation_stats.set_prevSweep(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  ssize_t beforeSweep() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    return _allocation_stats.beforeSweep();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  void set_beforeSweep(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    _allocation_stats.set_beforeSweep(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  ssize_t coalBirths() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    return _allocation_stats.coalBirths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  void set_coalBirths(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    _allocation_stats.set_coalBirths(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  void increment_coalBirths() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    _allocation_stats.increment_coalBirths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  ssize_t coalDeaths() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    return _allocation_stats.coalDeaths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  void set_coalDeaths(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    _allocation_stats.set_coalDeaths(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void increment_coalDeaths() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    _allocation_stats.increment_coalDeaths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  ssize_t splitBirths() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    return _allocation_stats.splitBirths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  void set_splitBirths(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    _allocation_stats.set_splitBirths(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  void increment_splitBirths() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    _allocation_stats.increment_splitBirths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  ssize_t splitDeaths() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    return _allocation_stats.splitDeaths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  void set_splitDeaths(ssize_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    _allocation_stats.set_splitDeaths(v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  void increment_splitDeaths() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    assert_proper_lock_protection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    _allocation_stats.increment_splitDeaths();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  NOT_PRODUCT(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    // For debugging.  The "_returnedBytes" in all the lists are summed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    // and compared with the total number of bytes swept during a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    // collection.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    size_t returnedBytes() const { return _allocation_stats.returnedBytes(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    void set_returnedBytes(size_t v) { _allocation_stats.set_returnedBytes(v); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    void increment_returnedBytes_by(size_t v) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      _allocation_stats.set_returnedBytes(_allocation_stats.returnedBytes() + v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  // Unlink head of list and return it.  Returns NULL if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // the list is empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  FreeChunk* getChunkAtHead();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // Remove the first "n" or "count", whichever is smaller, chunks from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // list, setting "fl", which is required to be empty, to point to them.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  void getFirstNChunksFromList(size_t n, FreeList* fl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // Unlink this chunk from it's free list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  void removeChunk(FreeChunk* fc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // Add this chunk to this free list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  void returnChunkAtHead(FreeChunk* fc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  void returnChunkAtTail(FreeChunk* fc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // Similar to returnChunk* but also records some diagnostic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  void returnChunkAtHead(FreeChunk* fc, bool record_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  void returnChunkAtTail(FreeChunk* fc, bool record_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // Prepend "fl" (whose size is required to be the same as that of "this")
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // to the front of "this" list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  void prepend(FreeList* fl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // Verify that the chunk is in the list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // found.  Return NULL if "fc" is not found.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  bool verifyChunkInFreeLists(FreeChunk* fc) const;
185
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   307
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   308
  // Printing support
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   309
  static void print_labels_on(outputStream* st, const char* c);
cda2a1eb4be5 6668743: CMS: Consolidate block statistics reporting code
ysr
parents: 1
diff changeset
   310
  void print_on(outputStream* st, const char* c = NULL) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
};