src/hotspot/share/gc/shared/plab.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46290 hotspot/src/share/vm/gc/shared/plab.hpp@3c4c1591507d
child 48963 7e09b699f7b6
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
46290
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
30275
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 "utilities/globalDefinitions.hpp"
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    31
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    32
// Forward declarations.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    33
class PLABStats;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    34
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    35
// A per-thread allocation buffer used during GC.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    36
class PLAB: public CHeapObj<mtGC> {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    37
protected:
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    38
  char      head[32];
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    39
  size_t    _word_sz;          // In HeapWord units
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    40
  HeapWord* _bottom;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    41
  HeapWord* _top;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    42
  HeapWord* _end;           // Last allocatable address + 1
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    43
  HeapWord* _hard_end;      // _end + AlignmentReserve
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    44
  // In support of ergonomic sizing of PLAB's
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    45
  size_t    _allocated;     // in HeapWord units
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    46
  size_t    _wasted;        // in HeapWord units
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    47
  size_t    _undo_wasted;
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    48
  char      tail[32];
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    49
  static size_t AlignmentReserve;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    50
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    51
  // Force future allocations to fail and queries for contains()
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    52
  // 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
    53
  size_t invalidate() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    54
    _end    = _hard_end;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    55
    size_t remaining = pointer_delta(_end, _top);  // Calculate remaining space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    56
    _top    = _end;      // Force future allocations to fail.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    57
    _bottom = _end;      // Force future contains() queries to return false.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    58
    return remaining;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    59
  }
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
  // 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
    62
  // the amount of remaining space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    63
  size_t retire_internal();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    64
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    65
  void add_undo_waste(HeapWord* obj, size_t word_sz);
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    66
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    67
  // 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
    68
  // "obj" of the given "word_sz".
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    69
  void undo_last_allocation(HeapWord* obj, size_t word_sz);
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
    70
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    71
public:
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    72
  // 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
    73
  // Must get initialized with "set_buf" for an allocation to succeed.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    74
  PLAB(size_t word_sz);
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    75
  virtual ~PLAB() {}
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    76
32383
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
    77
  static size_t size_required_for_allocation(size_t word_size) { return word_size + AlignmentReserve; }
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
    78
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    79
  // Minimum PLAB size.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    80
  static size_t min_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    81
  // Maximum PLAB size.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    82
  static size_t max_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    83
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    84
  // 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
    85
  // 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
    86
  // allocated block.  If the allocation request cannot be satisfied,
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    87
  // return NULL.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    88
  HeapWord* allocate(size_t word_sz) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    89
    HeapWord* res = _top;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    90
    if (pointer_delta(_end, _top) >= word_sz) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    91
      _top = _top + word_sz;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    92
      return res;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    93
    } else {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    94
      return NULL;
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
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
    98
  // 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
    99
  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
   100
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   101
  // 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
   102
  // "obj" of the given "word_sz".
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   103
  void undo_allocation(HeapWord* obj, size_t word_sz);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   104
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   105
  // The total (word) size of the buffer, including both allocated and
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   106
  // unallocated space.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   107
  size_t word_sz() { return _word_sz; }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   108
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   109
  size_t waste() { return _wasted; }
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   110
  size_t undo_waste() { return _undo_wasted; }
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   111
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   112
  // The number of words of unallocated space remaining in the buffer.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   113
  size_t words_remaining() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   114
    assert(_end >= _top, "Negative buffer");
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   115
    return pointer_delta(_end, _top, HeapWordSize);
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
  bool contains(void* addr) {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   119
    return (void*)_bottom <= addr && addr < (void*)_hard_end;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   120
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   121
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   122
  // Sets the space of the buffer to be [buf, space+word_sz()).
32383
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
   123
  virtual void set_buf(HeapWord* buf, size_t new_word_sz) {
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
   124
    assert(new_word_sz > AlignmentReserve, "Too small");
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
   125
    _word_sz = new_word_sz;
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
   126
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   127
    _bottom   = buf;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   128
    _top      = _bottom;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   129
    _hard_end = _bottom + word_sz();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   130
    _end      = _hard_end - AlignmentReserve;
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   131
    assert(_end >= _top, "Negative buffer");
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   132
    // In support of ergonomic sizing
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   133
    _allocated += word_sz();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   134
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   135
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   136
  // Flush allocation statistics into the given PLABStats supporting ergonomic
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   137
  // 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
   138
  // GC.
30278
928bec4e217f 8077836: Make sure G1ParGCAllocBuffer are marked as retired
sjohanss
parents: 30276
diff changeset
   139
  virtual void flush_and_retire_stats(PLABStats* stats);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   140
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   141
  // 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
   142
  // statistics. To be called during GC.
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   143
  virtual void retire();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   144
};
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   145
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   146
// PLAB book-keeping.
32379
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   147
class PLABStats : public CHeapObj<mtGC> {
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   148
 protected:
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   149
  const char* _description;   // Identifying string.
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   150
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
   151
  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
   152
  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
   153
  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
   154
  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
   155
  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
   156
  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
   157
         _filter;             // Integrator with decay
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   158
32379
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   159
  virtual void reset() {
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   160
    _allocated   = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   161
    _wasted      = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   162
    _undo_wasted = 0;
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   163
    _unused      = 0;
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   164
  }
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   165
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   166
  virtual void log_plab_allocation();
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   167
  virtual void log_sizing(size_t calculated, size_t net_desired);
46290
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
   168
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
   169
  // helper for adjust_desired_plab_sz().
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
   170
  virtual size_t compute_desired_plab_sz();
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
   171
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   172
 public:
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   173
  PLABStats(const char* description, size_t desired_net_plab_sz_, unsigned wt) :
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   174
    _description(description),
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   175
    _allocated(0),
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   176
    _wasted(0),
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   177
    _undo_wasted(0),
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   178
    _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
   179
    _desired_net_plab_sz(desired_net_plab_sz_),
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   180
    _filter(wt)
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   181
  { }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   182
32379
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   183
  virtual ~PLABStats() { }
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   184
36390
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   185
  size_t allocated() const { return _allocated; }
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   186
  size_t wasted() const { return _wasted; }
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   187
  size_t unused() const { return _unused; }
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   188
  size_t used() const { return allocated() - (wasted() + unused()); }
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   189
  size_t undo_wasted() const { return _undo_wasted; }
a2d991d1d628 8141141: Young and Old gen PLAB stats are similar in output with -XX:+PrintPLAB
tschatzl
parents: 35061
diff changeset
   190
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   191
  static const size_t min_size() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   192
    return PLAB::min_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   193
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   194
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   195
  static const size_t max_size() {
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   196
    return PLAB::max_size();
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   197
  }
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   198
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
   199
  // 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
   200
  size_t desired_plab_sz(uint no_of_gc_workers);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   201
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
   202
  // 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
   203
  // updates _desired_plab_sz and clears sensor accumulators.
46290
3c4c1591507d 8151045: Remove code duplication in PLABStats/G1EvacStats::adjust_desired_plab_sz
aharlap
parents: 36390
diff changeset
   204
  void adjust_desired_plab_sz();
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   205
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   206
  inline void add_allocated(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   207
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   208
  inline void add_unused(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   209
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   210
  inline void add_wasted(size_t v);
30564
a37d98a1eb54 8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents: 30278
diff changeset
   211
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 31632
diff changeset
   212
  inline void add_undo_wasted(size_t v);
30275
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   213
};
41fef3a62cc8 8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff changeset
   214
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
   215
#endif // SHARE_VM_GC_SHARED_PLAB_HPP