hotspot/src/share/vm/gc/shared/plab.hpp
author tschatzl
Wed, 19 Aug 2015 13:50:50 +0200
changeset 32378 8dd0e7359751
parent 31632 d041b34dd3e7
child 32379 aa14adafaf0f
permissions -rw-r--r--
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file Summary: Fix include file dependencies according to general guidelines for plab.hpp Reviewed-by: ehelin, mgerdin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     1
/*
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     2
 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     4
 *
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     7
 * published by the Free Software Foundation.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     8
 *
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    13
 * accompanied this code).
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    14
 *
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    18
 *
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    21
 * questions.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    22
 *
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    23
 */
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_PLAB_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    26
#define SHARE_VM_GC_SHARED_PLAB_HPP
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    28
#include "gc/shared/gcUtil.hpp"
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    29
#include "memory/allocation.hpp"
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    30
#include "runtime/atomic.hpp"
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    32
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    33
// Forward declarations.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    34
class PLABStats;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    35
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    36
// A per-thread allocation buffer used during GC.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    37
class PLAB: public CHeapObj<mtGC> {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    38
protected:
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    39
  char      head[32];
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    40
  size_t    _word_sz;          // In HeapWord units
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    41
  HeapWord* _bottom;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    42
  HeapWord* _top;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    43
  HeapWord* _end;           // Last allocatable address + 1
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    44
  HeapWord* _hard_end;      // _end + AlignmentReserve
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    45
  // In support of ergonomic sizing of PLAB's
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    46
  size_t    _allocated;     // in HeapWord units
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    47
  size_t    _wasted;        // in HeapWord units
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    48
  size_t    _undo_wasted;
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    49
  char      tail[32];
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    50
  static size_t AlignmentReserve;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    51
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    52
  // Force future allocations to fail and queries for contains()
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    53
  // to return false. Returns the amount of unused space in this PLAB.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    54
  size_t invalidate() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    55
    _end    = _hard_end;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    56
    size_t remaining = pointer_delta(_end, _top);  // Calculate remaining space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    57
    _top    = _end;      // Force future allocations to fail.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    58
    _bottom = _end;      // Force future contains() queries to return false.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    59
    return remaining;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    60
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    61
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    62
  // Fill in remaining space with a dummy object and invalidate the PLAB. Returns
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    63
  // the amount of remaining space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    64
  size_t retire_internal();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    65
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    66
  void add_undo_waste(HeapWord* obj, size_t word_sz);
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    67
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    68
  // Undo the last allocation in the buffer, which is required to be of the
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    69
  // "obj" of the given "word_sz".
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    70
  void undo_last_allocation(HeapWord* obj, size_t word_sz);
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    71
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    72
public:
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    73
  // Initializes the buffer to be empty, but with the given "word_sz".
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    74
  // Must get initialized with "set_buf" for an allocation to succeed.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    75
  PLAB(size_t word_sz);
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    76
  virtual ~PLAB() {}
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    77
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    78
  // Minimum PLAB size.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    79
  static size_t min_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    80
  // Maximum PLAB size.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    81
  static size_t max_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    82
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    83
  // If an allocation of the given "word_sz" can be satisfied within the
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    84
  // buffer, do the allocation, returning a pointer to the start of the
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    85
  // allocated block.  If the allocation request cannot be satisfied,
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    86
  // return NULL.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    87
  HeapWord* allocate(size_t word_sz) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    88
    HeapWord* res = _top;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    89
    if (pointer_delta(_end, _top) >= word_sz) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    90
      _top = _top + word_sz;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    91
      return res;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    92
    } else {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    93
      return NULL;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    94
    }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    95
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    96
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    97
  // Allocate the object aligned to "alignment_in_bytes".
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
    98
  inline HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    99
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   100
  // Undo any allocation in the buffer, which is required to be of the
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   101
  // "obj" of the given "word_sz".
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   102
  void undo_allocation(HeapWord* obj, size_t word_sz);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   103
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   104
  // The total (word) size of the buffer, including both allocated and
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   105
  // unallocated space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   106
  size_t word_sz() { return _word_sz; }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   107
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   108
  size_t waste() { return _wasted; }
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   109
  size_t undo_waste() { return _undo_wasted; }
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   110
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   111
  // Should only be done if we are about to reset with a new buffer of the
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   112
  // given size.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   113
  void set_word_size(size_t new_word_sz) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   114
    assert(new_word_sz > AlignmentReserve, "Too small");
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   115
    _word_sz = new_word_sz;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   116
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   117
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   118
  // The number of words of unallocated space remaining in the buffer.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   119
  size_t words_remaining() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   120
    assert(_end >= _top, "Negative buffer");
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   121
    return pointer_delta(_end, _top, HeapWordSize);
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   122
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   123
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   124
  bool contains(void* addr) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   125
    return (void*)_bottom <= addr && addr < (void*)_hard_end;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   126
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   127
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   128
  // Sets the space of the buffer to be [buf, space+word_sz()).
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   129
  virtual void set_buf(HeapWord* buf) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   130
    _bottom   = buf;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   131
    _top      = _bottom;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   132
    _hard_end = _bottom + word_sz();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   133
    _end      = _hard_end - AlignmentReserve;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   134
    assert(_end >= _top, "Negative buffer");
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   135
    // In support of ergonomic sizing
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   136
    _allocated += word_sz();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   137
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   138
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   139
  // Flush allocation statistics into the given PLABStats supporting ergonomic
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   140
  // sizing of PLAB's and retire the current buffer. To be called at the end of
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   141
  // GC.
30278
928bec4e217f 8077836: Make sure G1ParGCAllocBuffer are marked as retired
sjohanss
parents: 30276
diff changeset
   142
  virtual void flush_and_retire_stats(PLABStats* stats);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   143
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   144
  // Fills in the unallocated portion of the buffer with a garbage object and updates
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   145
  // statistics. To be called during GC.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   146
  virtual void retire();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   147
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   148
  void print() PRODUCT_RETURN;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   149
};
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   150
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   151
// PLAB book-keeping.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   152
class PLABStats VALUE_OBJ_CLASS_SPEC {
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   153
  size_t _allocated;          // Total allocated
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   154
  size_t _wasted;             // of which wasted (internal fragmentation)
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   155
  size_t _undo_wasted;        // of which wasted on undo (is not used for calculation of PLAB size)
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   156
  size_t _unused;             // Unused in last buffer
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   157
  size_t _desired_net_plab_sz;// Output of filter (below), suitably trimmed and quantized
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   158
  AdaptiveWeightedAverage
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   159
         _filter;             // Integrator with decay
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   160
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   161
  void reset() {
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   162
    _allocated   = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   163
    _wasted      = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   164
    _undo_wasted = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   165
    _unused      = 0;
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   166
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   167
 public:
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   168
  PLABStats(size_t desired_net_plab_sz_, unsigned wt) :
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   169
    _allocated(0),
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   170
    _wasted(0),
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   171
    _undo_wasted(0),
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   172
    _unused(0),
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   173
    _desired_net_plab_sz(desired_net_plab_sz_),
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   174
    _filter(wt)
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   175
  { }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   176
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   177
  static const size_t min_size() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   178
    return PLAB::min_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   179
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   180
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   181
  static const size_t max_size() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   182
    return PLAB::max_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   183
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   184
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   185
  // Calculates plab size for current number of gc worker threads.
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   186
  size_t desired_plab_sz(uint no_of_gc_workers);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   187
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   188
  // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread,
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   189
  // updates _desired_plab_sz and clears sensor accumulators.
31632
d041b34dd3e7 8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents: 30764
diff changeset
   190
  void adjust_desired_plab_sz();
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   191
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   192
  inline void add_allocated(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   193
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   194
  inline void add_unused(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   195
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   196
  inline void add_wasted(size_t v);
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   197
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   198
  inline void add_undo_wasted(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   199
};
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   200
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
   201
#endif // SHARE_VM_GC_SHARED_PLAB_HPP