src/hotspot/share/gc/g1/g1RedirtyCardsQueue.cpp
author kbarrett
Fri, 16 Aug 2019 14:46:52 -0400
changeset 57785 8d9362f3b8aa
parent 57507 f6b30bd6804e
child 57890 6bb824c45df1
permissions -rw-r--r--
8229044: G1RedirtyCardsQueueSet should be local to a collection Summary: Stack allocate redirty qsets in do_collection_pause_at_safepoint. Reviewed-by: tschatzl, sangheki
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     1
/*
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     4
 *
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     8
 *
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    14
 *
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    18
 *
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    21
 * questions.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    22
 *
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    23
 */
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    24
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    25
#include "precompiled.hpp"
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    26
#include "gc/g1/g1RedirtyCardsQueue.hpp"
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    27
#include "runtime/atomic.hpp"
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    28
#include "utilities/debug.hpp"
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    29
#include "utilities/macros.hpp"
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    30
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    31
// G1RedirtyCardsBufferList
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    32
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    33
G1RedirtyCardsBufferList::G1RedirtyCardsBufferList() :
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    34
  _head(NULL), _tail(NULL), _entry_count(0) {}
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    35
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    36
G1RedirtyCardsBufferList::G1RedirtyCardsBufferList(BufferNode* head,
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    37
                                                   BufferNode* tail,
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    38
                                                   size_t entry_count) :
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    39
  _head(head), _tail(tail), _entry_count(entry_count)
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    40
{
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    41
  assert((_head == NULL) == (_tail == NULL), "invariant");
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    42
  assert((_head == NULL) == (_entry_count == 0), "invariant");
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    43
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    44
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    45
// G1RedirtyCardsQueueBase::LocalQSet
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    46
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    47
G1RedirtyCardsQueueBase::LocalQSet::LocalQSet(G1RedirtyCardsQueueSet* shared_qset) :
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    48
  PtrQueueSet(),
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    49
  _shared_qset(shared_qset),
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    50
  _buffers()
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    51
{
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    52
  PtrQueueSet::initialize(_shared_qset->allocator());
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    53
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    54
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    55
G1RedirtyCardsQueueBase::LocalQSet::~LocalQSet() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    56
  assert(_buffers._head == NULL, "unflushed qset");
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    57
  assert(_buffers._tail == NULL, "invariant");
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    58
  assert(_buffers._entry_count == 0, "invariant");
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    59
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    60
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    61
void G1RedirtyCardsQueueBase::LocalQSet::enqueue_completed_buffer(BufferNode* node) {
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    62
  _buffers._entry_count += buffer_size() - node->index();
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    63
  node->set_next(_buffers._head);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    64
  _buffers._head = node;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    65
  if (_buffers._tail == NULL) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    66
    _buffers._tail = node;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    67
  }
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    68
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    69
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
    70
G1RedirtyCardsBufferList G1RedirtyCardsQueueBase::LocalQSet::take_all_completed_buffers() {
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    71
  G1RedirtyCardsBufferList result = _buffers;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    72
  _buffers = G1RedirtyCardsBufferList();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    73
  return result;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    74
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    75
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    76
void G1RedirtyCardsQueueBase::LocalQSet::flush() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    77
  _shared_qset->merge_bufferlist(this);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    78
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    79
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    80
// G1RedirtyCardsQueue
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    81
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    82
G1RedirtyCardsQueue::G1RedirtyCardsQueue(G1RedirtyCardsQueueSet* qset) :
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    83
  G1RedirtyCardsQueueBase(qset), // Init _local_qset before passing to PtrQueue.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    84
  PtrQueue(&_local_qset, true /* active (always) */)
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    85
{}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    86
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    87
G1RedirtyCardsQueue::~G1RedirtyCardsQueue() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    88
  flush();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    89
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    90
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    91
void G1RedirtyCardsQueue::handle_completed_buffer() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    92
  enqueue_completed_buffer();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    93
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    94
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    95
void G1RedirtyCardsQueue::flush() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    96
  flush_impl();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    97
  _local_qset.flush();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    98
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
    99
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   100
// G1RedirtyCardsQueueSet
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   101
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57507
diff changeset
   102
G1RedirtyCardsQueueSet::G1RedirtyCardsQueueSet(BufferNode::Allocator* allocator) :
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   103
  PtrQueueSet(),
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   104
  _list(),
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   105
  _entry_count(0),
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   106
  _tail(NULL)
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   107
  DEBUG_ONLY(COMMA _collecting(true))
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57507
diff changeset
   108
{
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57507
diff changeset
   109
  initialize(allocator);
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57507
diff changeset
   110
}
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   111
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   112
G1RedirtyCardsQueueSet::~G1RedirtyCardsQueueSet() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   113
  verify_empty();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   114
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   115
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   116
#ifdef ASSERT
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   117
void G1RedirtyCardsQueueSet::verify_empty() const {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   118
  assert(_list.empty(), "precondition");
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   119
  assert(_tail == NULL, "invariant");
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   120
  assert(_entry_count == 0, "invariant");
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   121
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   122
#endif // ASSERT
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   123
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   124
BufferNode* G1RedirtyCardsQueueSet::all_completed_buffers() const {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   125
  DEBUG_ONLY(_collecting = false;)
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   126
  return _list.top();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   127
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   128
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   129
G1RedirtyCardsBufferList G1RedirtyCardsQueueSet::take_all_completed_buffers() {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   130
  DEBUG_ONLY(_collecting = false;)
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   131
  G1RedirtyCardsBufferList result(_list.pop_all(), _tail, _entry_count);
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   132
  _tail = NULL;
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   133
  _entry_count = 0;
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   134
  DEBUG_ONLY(_collecting = true;)
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   135
  return result;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   136
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   137
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   138
void G1RedirtyCardsQueueSet::update_tail(BufferNode* node) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   139
  // Node is the tail of a (possibly single element) list just prepended to
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   140
  // _list.  If, after that prepend, node's follower is NULL, then node is
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   141
  // also the tail of _list, so record it as such.
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   142
  if (node->next() == NULL) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   143
    assert(_tail == NULL, "invariant");
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   144
    _tail = node;
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   145
  }
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   146
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   147
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   148
void G1RedirtyCardsQueueSet::enqueue_completed_buffer(BufferNode* node) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   149
  assert(_collecting, "precondition");
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   150
  Atomic::add(buffer_size() - node->index(), &_entry_count);
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   151
  _list.push(*node);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   152
  update_tail(node);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   153
}
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   154
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   155
void G1RedirtyCardsQueueSet::merge_bufferlist(LocalQSet* src) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   156
  assert(_collecting, "precondition");
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   157
  const G1RedirtyCardsBufferList from = src->take_all_completed_buffers();
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   158
  if (from._head != NULL) {
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   159
    assert(from._tail != NULL, "invariant");
57507
f6b30bd6804e 8227719: G1 Pending cards estimation too conservative in cost prediction
tschatzl
parents: 55752
diff changeset
   160
    Atomic::add(from._entry_count, &_entry_count);
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   161
    _list.prepend(*from._head, *from._tail);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   162
    update_tail(from._tail);
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   163
  }
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents:
diff changeset
   164
}