src/hotspot/share/gc/shared/ptrQueue.hpp
author kbarrett
Wed, 26 Jun 2019 13:18:38 -0400
changeset 55498 e64383344f14
parent 54970 76d3d96a8bc2
child 55752 8ae33203d600
permissions -rw-r--r--
8225255: Make SATB qset lock-free Summary: Refactor PtrQueueSet, use lock-free stack for SATB completed buffers Reviewed-by: tschatzl, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 53102
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5082
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5082
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5082
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
51441
2e91d927e00c 8154343: Make SATB related code available to other GCs
kbarrett
parents: 51332
diff changeset
    25
#ifndef SHARE_GC_SHARED_PTRQUEUE_HPP
2e91d927e00c 8154343: Make SATB related code available to other GCs
kbarrett
parents: 51332
diff changeset
    26
#define SHARE_GC_SHARED_PTRQUEUE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
    27
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
    28
#include "memory/padded.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    29
#include "utilities/align.hpp"
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
    30
#include "utilities/debug.hpp"
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
    31
#include "utilities/lockFreeStack.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
    32
#include "utilities/sizes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
    33
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
    34
class Mutex;
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 53102
diff changeset
    35
class Monitor;
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
    36
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
// There are various techniques that require threads to be able to log
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
// addresses.  For example, a generational write barrier might log
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
// the addresses of modified old-generation objects.  This type supports
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
// this operation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
    42
class BufferNode;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
class PtrQueueSet;
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
    44
class PtrQueue {
20011
d74937287461 8024760: add more types, fields and constants to VMStructs
twisti
parents: 11455
diff changeset
    45
  friend class VMStructs;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    47
  // Noncopyable - not defined.
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    48
  PtrQueue(const PtrQueue&);
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    49
  PtrQueue& operator=(const PtrQueue&);
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    50
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
  // The ptr queue set to which this queue belongs.
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    52
  PtrQueueSet* const _qset;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
  // Whether updates should be logged.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
  bool _active;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    57
  // The (byte) index at which an object was last enqueued.  Starts at
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    58
  // capacity_in_bytes (indicating an empty buffer) and goes towards zero.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    59
  // Value is always pointer-size aligned.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    60
  size_t _index;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    61
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    62
  // Size of the current buffer, in bytes.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    63
  // Value is always pointer-size aligned.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    64
  size_t _capacity_in_bytes;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    65
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    66
  static const size_t _element_size = sizeof(void*);
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    67
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    68
  // Get the capacity, in bytes.  The capacity must have been set.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    69
  size_t capacity_in_bytes() const {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    70
    assert(_capacity_in_bytes > 0, "capacity not set");
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    71
    return _capacity_in_bytes;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    72
  }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    73
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    74
  static size_t byte_index_to_index(size_t ind) {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46443
diff changeset
    75
    assert(is_aligned(ind, _element_size), "precondition");
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    76
    return ind / _element_size;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    77
  }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    78
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    79
  static size_t index_to_byte_index(size_t ind) {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    80
    return ind * _element_size;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    81
  }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    82
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    83
protected:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
  // The buffer.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
  void** _buf;
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    86
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    87
  size_t index() const {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    88
    return byte_index_to_index(_index);
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    89
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    91
  void set_index(size_t new_index) {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    92
    size_t byte_index = index_to_byte_index(new_index);
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    93
    assert(byte_index <= capacity_in_bytes(), "precondition");
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    94
    _index = byte_index;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    95
  }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    96
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    97
  size_t capacity() const {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    98
    return byte_index_to_index(capacity_in_bytes());
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
    99
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
54970
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   101
  PtrQueueSet* qset() const { return _qset; }
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 22234
diff changeset
   102
46305
bff6d23aa1e3 8175221: Cleanup DirtyCardQueueSet::concatenate_log
kbarrett
parents: 37065
diff changeset
   103
  // Process queue entries and release resources.
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 22234
diff changeset
   104
  void flush_impl();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
54970
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   106
  // Process (some of) the buffer and leave it in place for further use,
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   107
  // or enqueue the buffer and allocate a new one.
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   108
  virtual void handle_completed_buffer() = 0;
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   109
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   110
  void allocate_buffer();
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   111
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   112
  // Enqueue the current buffer in the qset and allocate a new buffer.
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   113
  void enqueue_completed_buffer();
76d3d96a8bc2 8224167: Refactor PtrQueue completed buffer processing
kbarrett
parents: 54255
diff changeset
   114
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
  // Initialize this queue to contain a null buffer, and be part of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
  // given PtrQueueSet.
54255
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 53404
diff changeset
   117
  PtrQueue(PtrQueueSet* qset, bool active = false);
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 22234
diff changeset
   118
54255
c81fbf340ceb 8220240: Refactor shared dirty card queue
kbarrett
parents: 53404
diff changeset
   119
  // Requires queue flushed.
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 22234
diff changeset
   120
  ~PtrQueue();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   122
public:
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   123
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   124
  // Forcibly set empty.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   125
  void reset() {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   126
    if (_buf != NULL) {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   127
      _index = capacity_in_bytes();
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   128
    }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   129
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
20403
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 20011
diff changeset
   131
  void enqueue(volatile void* ptr) {
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 20011
diff changeset
   132
    enqueue((void*)(ptr));
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 20011
diff changeset
   133
  }
45a89fbcd8f7 8014555: G1: Memory ordering problem with Conc refinement and card marking
mgerdin
parents: 20011
diff changeset
   134
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  // Enqueues the given "obj".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  void enqueue(void* ptr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
    if (!_active) return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
    else enqueue_known_active(ptr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   141
  void handle_zero_index();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   143
  void enqueue_known_active(void* ptr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   144
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   145
  // Return the size of the in-use region.
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   146
  size_t size() const {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   147
    size_t result = 0;
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   148
    if (_buf != NULL) {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   149
      assert(_index <= capacity_in_bytes(), "Invariant");
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   150
      result = byte_index_to_index(capacity_in_bytes() - _index);
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   151
    }
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   152
    return result;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   155
  bool is_empty() const {
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   156
    return _buf == NULL || capacity_in_bytes() == _index;
6768
71338ecb7813 6980838: G1: guarantee(false) failed: thread has an unexpected active value in its SATB queue
tonyp
parents: 5547
diff changeset
   157
  }
71338ecb7813 6980838: G1: guarantee(false) failed: thread has an unexpected active value in its SATB queue
tonyp
parents: 5547
diff changeset
   158
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
  // Set the "active" property of the queue to "b".  An enqueue to an
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  // inactive thread is a no-op.  Setting a queue to inactive resets its
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  // log to the empty state.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
  void set_active(bool b) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
    _active = b;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
    if (!b && _buf != NULL) {
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   165
      reset();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
    } else if (b && _buf != NULL) {
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   167
      assert(index() == capacity(),
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   168
             "invariant: queues are empty when activated.");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   172
  bool is_active() const { return _active; }
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   173
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
  // To support compiler.
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   175
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   176
protected:
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   177
  template<typename Derived>
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  static ByteSize byte_offset_of_index() {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   179
    return byte_offset_of(Derived, _index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
  }
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   181
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
  static ByteSize byte_width_of_index() { return in_ByteSize(sizeof(size_t)); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   184
  template<typename Derived>
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   185
  static ByteSize byte_offset_of_buf() {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   186
    return byte_offset_of(Derived, _buf);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   187
  }
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   188
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   189
  static ByteSize byte_width_of_buf() { return in_ByteSize(_element_size); }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   190
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   191
  template<typename Derived>
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   192
  static ByteSize byte_offset_of_active() {
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   193
    return byte_offset_of(Derived, _active);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   194
  }
34148
6efbc7ffd767 8143014: Access PtrQueue member offsets through derived classes
kbarrett
parents: 33761
diff changeset
   195
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
  static ByteSize byte_width_of_active() { return in_ByteSize(sizeof(bool)); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   200
class BufferNode {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   201
  size_t _index;
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   202
  BufferNode* volatile _next;
36354
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   203
  void* _buffer[1];             // Pseudo flexible array member.
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   204
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   205
  BufferNode() : _index(0), _next(NULL) { }
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   206
  ~BufferNode() { }
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   207
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   208
  static size_t buffer_offset() {
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   209
    return offset_of(BufferNode, _buffer);
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   210
  }
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   211
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   212
  static BufferNode* volatile* next_ptr(BufferNode& bn) { return &bn._next; }
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   213
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   214
AIX_ONLY(public:)               // xlC 12 on AIX doesn't implement C++ DR45.
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   215
  // Allocate a new BufferNode with the "buffer" having size elements.
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   216
  static BufferNode* allocate(size_t size);
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   217
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   218
  // Free a BufferNode.
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   219
  static void deallocate(BufferNode* node);
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   220
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   221
public:
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   222
  typedef LockFreeStack<BufferNode, &next_ptr> Stack;
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   223
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   224
  BufferNode* next() const     { return _next;  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   225
  void set_next(BufferNode* n) { _next = n;     }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   226
  size_t index() const         { return _index; }
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   227
  void set_index(size_t i)     { _index = i; }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   228
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   229
  // Return the BufferNode containing the buffer, after setting its index.
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   230
  static BufferNode* make_node_from_buffer(void** buffer, size_t index) {
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   231
    BufferNode* node =
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   232
      reinterpret_cast<BufferNode*>(
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   233
        reinterpret_cast<char*>(buffer) - buffer_offset());
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   234
    node->set_index(index);
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   235
    return node;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   236
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   237
36354
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   238
  // Return the buffer for node.
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   239
  static void** make_buffer_from_node(BufferNode *node) {
36354
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   240
    // &_buffer[0] might lead to index out of bounds warnings.
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   241
    return reinterpret_cast<void**>(
28bbe66a0498 8150419: Cleanup BufferNode API
kbarrett
parents: 34148
diff changeset
   242
      reinterpret_cast<char*>(node) + buffer_offset());
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   243
  }
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   244
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   245
  class Allocator;              // Free-list based allocator.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   246
  class TestSupport;            // Unit test support.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   247
};
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   248
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   249
// Allocation is based on a lock-free free list of nodes, linked through
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   250
// BufferNode::_next (see BufferNode::Stack).  To solve the ABA problem,
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   251
// popping a node from the free list is performed within a GlobalCounter
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   252
// critical section, and pushing nodes onto the free list is done after
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   253
// a GlobalCounter synchronization associated with the nodes to be pushed.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   254
// This is documented behavior so that other parts of the node life-cycle
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   255
// can depend on and make use of it too.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   256
class BufferNode::Allocator {
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   257
  friend class TestSupport;
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   258
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   259
  // Since we don't expect many instances, and measured >15% speedup
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   260
  // on stress gtest, padding seems like a good tradeoff here.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   261
#define DECLARE_PADDED_MEMBER(Id, Type, Name) \
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   262
  Type Name; DEFINE_PAD_MINUS_SIZE(Id, DEFAULT_CACHE_LINE_SIZE, sizeof(Type))
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   263
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   264
  const size_t _buffer_size;
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   265
  char _name[DEFAULT_CACHE_LINE_SIZE - sizeof(size_t)]; // Use name as padding.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   266
  DECLARE_PADDED_MEMBER(1, Stack, _pending_list);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   267
  DECLARE_PADDED_MEMBER(2, Stack, _free_list);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   268
  DECLARE_PADDED_MEMBER(3, volatile size_t, _pending_count);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   269
  DECLARE_PADDED_MEMBER(4, volatile size_t, _free_count);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   270
  DECLARE_PADDED_MEMBER(5, volatile bool, _transfer_lock);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   271
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   272
#undef DECLARE_PADDED_MEMBER
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   273
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   274
  void delete_list(BufferNode* list);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   275
  bool try_transfer_pending();
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   276
53404
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   277
public:
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   278
  Allocator(const char* name, size_t buffer_size);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   279
  ~Allocator();
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   280
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   281
  const char* name() const { return _name; }
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   282
  size_t buffer_size() const { return _buffer_size; }
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   283
  size_t free_count() const;
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   284
  BufferNode* allocate();
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   285
  void release(BufferNode* node);
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   286
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   287
  // Deallocate some of the available buffers.  remove_goal is the target
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   288
  // number to remove.  Returns the number actually deallocated, which may
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   289
  // be less than the goal if there were fewer available.
9ff1e6cacac3 8212826: Make PtrQueue free list lock-free
kbarrett
parents: 53149
diff changeset
   290
  size_t reduce_free_list(size_t remove_goal);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   291
};
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 2154
diff changeset
   292
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   293
// A PtrQueueSet represents resources common to a set of pointer queues.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   294
// In particular, the individual queues allocate buffers from this shared
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   295
// set, and return completed buffers to the set.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
   296
class PtrQueueSet {
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   297
  BufferNode::Allocator* _allocator;
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   298
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   299
protected:
53102
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   300
  bool _all_active;
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   301
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   302
  // Create an empty ptr queue set.
55498
e64383344f14 8225255: Make SATB qset lock-free
kbarrett
parents: 54970
diff changeset
   303
  PtrQueueSet();
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   304
  ~PtrQueueSet();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   305
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   306
  // Because of init-order concerns, we can't pass these as constructor
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   307
  // arguments.
55498
e64383344f14 8225255: Make SATB qset lock-free
kbarrett
parents: 54970
diff changeset
   308
  void initialize(BufferNode::Allocator* allocator);
53102
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   309
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   310
public:
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   311
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   312
  // Return the buffer for a BufferNode of size buffer_size().
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   313
  void** allocate_buffer();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   314
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   315
  // Return an empty buffer to the free list.  The node is required
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   316
  // to have been allocated with a size of buffer_size().
37065
c00d1c2ffb7c 8150676: Use BufferNode index
kbarrett
parents: 36371
diff changeset
   317
  void deallocate_buffer(BufferNode* node);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   318
53102
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   319
  // A completed buffer is a buffer the mutator is finished with, and
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   320
  // is ready to be processed by the collector.  It need not be full.
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   321
35530ca3e0b2 8214201: Make PtrQueueSet completed buffer list private
kbarrett
parents: 52726
diff changeset
   322
  // Adds node to the completed buffer list.
55498
e64383344f14 8225255: Make SATB qset lock-free
kbarrett
parents: 54970
diff changeset
   323
  virtual void enqueue_completed_buffer(BufferNode* node) = 0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   324
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   325
  bool is_active() { return _all_active; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   326
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   327
  size_t buffer_size() const {
52582
6df094be7f58 8213352: Separate BufferNode allocation from PtrQueueSet
kbarrett
parents: 51441
diff changeset
   328
    return _allocator->buffer_size();
46443
cdb638b5ec53 8178836: Improve PtrQueue index abstraction
kbarrett
parents: 46305
diff changeset
   329
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   330
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6768
diff changeset
   331
51441
2e91d927e00c 8154343: Make SATB related code available to other GCs
kbarrett
parents: 51332
diff changeset
   332
#endif // SHARE_GC_SHARED_PTRQUEUE_HPP