hotspot/src/share/vm/gc/g1/ptrQueue.cpp
author kbarrett
Wed, 04 Nov 2015 13:09:57 -0500
changeset 33761 329db4b51480
parent 30764 fec48bf5a827
child 36354 28bbe66a0498
permissions -rw-r--r--
6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp Summary: Simplify indexing, address obsolete code, improve access/type checking. Reviewed-by: tschatzl, pliden
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
/*
29580
a67a581cfe11 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents: 28507
diff changeset
     2
 * Copyright (c) 2001, 2015, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29580
diff changeset
    26
#include "gc/g1/ptrQueue.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/mutex.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/mutexLocker.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 13963
diff changeset
    31
#include "runtime/thread.inline.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    32
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    33
PtrQueue::PtrQueue(PtrQueueSet* qset, bool permanent, bool active) :
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27880
diff changeset
    34
  _qset(qset), _buf(NULL), _index(0), _sz(0), _active(active),
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    35
  _permanent(permanent), _lock(NULL)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
{}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27880
diff changeset
    38
PtrQueue::~PtrQueue() {
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    39
  assert(_permanent || (_buf == NULL), "queue must be flushed before delete");
28507
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27880
diff changeset
    40
}
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27880
diff changeset
    41
354ef83ee258 8048949: Requeue queue implementation
tschatzl
parents: 27880
diff changeset
    42
void PtrQueue::flush_impl() {
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    43
  if (!_permanent && _buf != NULL) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
    if (_index == _sz) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
      // No work to do.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
      qset()->deallocate_buffer(_buf);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
      // We must NULL out the unused entries, then enqueue.
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    49
      size_t limit = byte_index_to_index(_index);
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    50
      for (size_t i = 0; i < limit; ++i) {
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    51
        _buf[i] = NULL;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
      qset()->enqueue_complete_buffer(_buf);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
    }
1560
1b328492b7f8 6770608: G1: Mutator thread can flush barrier and satb queues during safepoint
iveresov
parents: 1374
diff changeset
    55
    _buf = NULL;
1b328492b7f8 6770608: G1: Mutator thread can flush barrier and satb queues during safepoint
iveresov
parents: 1374
diff changeset
    56
    _index = 0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
void PtrQueue::enqueue_known_active(void* ptr) {
29580
a67a581cfe11 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents: 28507
diff changeset
    62
  assert(_index <= _sz, "Invariant.");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
  assert(_index == 0 || _buf != NULL, "invariant");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
  while (_index == 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
    handle_zero_index();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
  }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
    68
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  assert(_index > 0, "postcondition");
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    70
  _index -= sizeof(void*);
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
    71
  _buf[byte_index_to_index(_index)] = ptr;
29580
a67a581cfe11 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
goetz
parents: 28507
diff changeset
    72
  assert(_index <= _sz, "Invariant.");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
void PtrQueue::locking_enqueue_completed_buffer(void** buf) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
  assert(_lock->owned_by_self(), "Required.");
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
    77
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
    78
  // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
    79
  // we acquire DirtyCardQ_CBL_mon inside enqueue_complete_buffer as they
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
    80
  // have the same rank and we may get the "possible deadlock" message
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
  _lock->unlock();
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
    82
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
  qset()->enqueue_complete_buffer(buf);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
  // We must relock only because the caller will unlock, for the normal
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
  // case.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  _lock->lock_without_safepoint_check();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
PtrQueueSet::PtrQueueSet(bool notify_when_complete) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
  _max_completed_queue(0),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  _cbl_mon(NULL), _fl_lock(NULL),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    93
  _notify_when_complete(notify_when_complete),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    94
  _sz(0),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
  _completed_buffers_head(NULL),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
  _completed_buffers_tail(NULL),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
  _n_completed_buffers(0),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
  _process_completed_threshold(0), _process_completed(false),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
  _buf_free_list(NULL), _buf_free_list_sz(0)
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   100
{
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   101
  _fl_owner = this;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   102
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   104
PtrQueueSet::~PtrQueueSet() {
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   105
  // There are presently only a couple (derived) instances ever
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   106
  // created, and they are permanent, so no harm currently done by
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   107
  // doing nothing here.
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   108
}
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   109
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   110
void PtrQueueSet::initialize(Monitor* cbl_mon,
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   111
                             Mutex* fl_lock,
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   112
                             int process_completed_threshold,
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   113
                             int max_completed_queue,
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   114
                             PtrQueueSet *fl_owner) {
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   115
  _max_completed_queue = max_completed_queue;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   116
  _process_completed_threshold = process_completed_threshold;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   117
  _completed_queue_padding = 0;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   118
  assert(cbl_mon != NULL && fl_lock != NULL, "Init order issue?");
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   119
  _cbl_mon = cbl_mon;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   120
  _fl_lock = fl_lock;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   121
  _fl_owner = (fl_owner != NULL) ? fl_owner : this;
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   122
}
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   123
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   124
void** PtrQueueSet::allocate_buffer() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
  assert(_sz > 0, "Didn't set a buffer size.");
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   126
  MutexLockerEx x(_fl_owner->_fl_lock, Mutex::_no_safepoint_check_flag);
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   127
  if (_fl_owner->_buf_free_list != NULL) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   128
    void** res = BufferNode::make_buffer_from_node(_fl_owner->_buf_free_list);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   129
    _fl_owner->_buf_free_list = _fl_owner->_buf_free_list->next();
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   130
    _fl_owner->_buf_free_list_sz--;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
    return res;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
  } else {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   133
    // Allocate space for the BufferNode in front of the buffer.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10565
diff changeset
   134
    char *b =  NEW_C_HEAP_ARRAY(char, _sz + BufferNode::aligned_size(), mtGC);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   135
    return BufferNode::make_buffer_from_block(b);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
void PtrQueueSet::deallocate_buffer(void** buf) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  assert(_sz > 0, "Didn't set a buffer size.");
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   141
  MutexLockerEx x(_fl_owner->_fl_lock, Mutex::_no_safepoint_check_flag);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   142
  BufferNode *node = BufferNode::make_node_from_buffer(buf);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   143
  node->set_next(_fl_owner->_buf_free_list);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   144
  _fl_owner->_buf_free_list = node;
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   145
  _fl_owner->_buf_free_list_sz++;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
void PtrQueueSet::reduce_free_list() {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   149
  assert(_fl_owner == this, "Free list reduction is allowed only for the owner");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
  // For now we'll adopt the strategy of deleting half.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
  MutexLockerEx x(_fl_lock, Mutex::_no_safepoint_check_flag);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
  size_t n = _buf_free_list_sz / 2;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  while (n > 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
    assert(_buf_free_list != NULL, "_buf_free_list_sz must be wrong.");
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   155
    void* b = BufferNode::make_block_from_node(_buf_free_list);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   156
    _buf_free_list = _buf_free_list->next();
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 22551
diff changeset
   157
    FREE_C_HEAP_ARRAY(char, b);
4454
d27c981064b4 6895788: G1: SATB and update buffer allocation code allocates too much space
johnc
parents: 3261
diff changeset
   158
    _buf_free_list_sz --;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
    n--;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   163
void PtrQueue::handle_zero_index() {
7920
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   164
  assert(_index == 0, "Precondition.");
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   165
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   166
  // This thread records the full buffer and allocates a new one (while
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   167
  // holding the lock if there is one).
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   168
  if (_buf != NULL) {
7920
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   169
    if (!should_enqueue_buffer()) {
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   170
      assert(_index > 0, "the buffer can only be re-used if it's not full");
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   171
      return;
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   172
    }
298df61588a2 7011379: G1: overly long concurrent marking cycles
tonyp
parents: 7397
diff changeset
   173
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   174
    if (_lock) {
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   175
      assert(_lock->owned_by_self(), "Required.");
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   176
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   177
      // The current PtrQ may be the shared dirty card queue and
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   178
      // may be being manipulated by more than one worker thread
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   179
      // during a pause. Since the enqueueing of the completed
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   180
      // buffer unlocks the Shared_DirtyCardQ_lock more than one
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   181
      // worker thread can 'race' on reading the shared queue attributes
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   182
      // (_buf and _index) and multiple threads can call into this
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   183
      // routine for the same buffer. This will cause the completed
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   184
      // buffer to be added to the CBL multiple times.
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   185
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   186
      // We "claim" the current buffer by caching value of _buf in
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   187
      // a local and clearing the field while holding _lock. When
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   188
      // _lock is released (while enqueueing the completed buffer)
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   189
      // the thread that acquires _lock will skip this code,
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   190
      // preventing the subsequent the multiple enqueue, and
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   191
      // install a newly allocated buffer below.
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   192
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   193
      void** buf = _buf;   // local pointer to completed buffer
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   194
      _buf = NULL;         // clear shared _buf field
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   195
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   196
      locking_enqueue_completed_buffer(buf);  // enqueue completed buffer
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   197
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   198
      // While the current thread was enqueueing the buffer another thread
4640
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   199
      // may have a allocated a new buffer and inserted it into this pointer
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   200
      // queue. If that happens then we just return so that the current
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   201
      // thread doesn't overwrite the buffer allocated by the other thread
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   202
      // and potentially losing some dirtied cards.
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   203
b5edb9b319e4 6915005: G1: Hang in PtrQueueSet::completed_buffers_list_length with gcl001
johnc
parents: 4481
diff changeset
   204
      if (_buf != NULL) return;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   205
    } else {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   206
      if (qset()->process_or_enqueue_complete_buffer(_buf)) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   207
        // Recycle the buffer. No allocation.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   208
        _sz = qset()->buffer_size();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   209
        _index = _sz;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   210
        return;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   211
      }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   212
    }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   213
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   214
  // Reallocate the buffer
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   215
  _buf = qset()->allocate_buffer();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   216
  _sz = qset()->buffer_size();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   217
  _index = _sz;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   218
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   220
bool PtrQueueSet::process_or_enqueue_complete_buffer(void** buf) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   221
  if (Thread::current()->is_Java_thread()) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   222
    // We don't lock. It is fine to be epsilon-precise here.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   223
    if (_max_completed_queue == 0 || _max_completed_queue > 0 &&
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   224
        _n_completed_buffers >= _max_completed_queue + _completed_queue_padding) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   225
      bool b = mut_process_buffer(buf);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   226
      if (b) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   227
        // True here means that the buffer hasn't been deallocated and the caller may reuse it.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   228
        return true;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   229
      }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
    }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   231
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   232
  // The buffer will be enqueued. The caller will have to get a new one.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   233
  enqueue_complete_buffer(buf);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   234
  return false;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   235
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   237
void PtrQueueSet::enqueue_complete_buffer(void** buf, size_t index) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   238
  MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   239
  BufferNode* cbn = BufferNode::new_from_buffer(buf);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   240
  cbn->set_index(index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
  if (_completed_buffers_tail == NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   242
    assert(_completed_buffers_head == NULL, "Well-formedness");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   243
    _completed_buffers_head = cbn;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   244
    _completed_buffers_tail = cbn;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
  } else {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   246
    _completed_buffers_tail->set_next(cbn);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   247
    _completed_buffers_tail = cbn;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   248
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   249
  _n_completed_buffers++;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   251
  if (!_process_completed && _process_completed_threshold >= 0 &&
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2142
diff changeset
   252
      _n_completed_buffers >= _process_completed_threshold) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
    _process_completed = true;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   254
    if (_notify_when_complete)
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   255
      _cbl_mon->notify();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   256
  }
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   257
  DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   258
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   259
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   260
int PtrQueueSet::completed_buffers_list_length() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   261
  int n = 0;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   262
  BufferNode* cbn = _completed_buffers_head;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   263
  while (cbn != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   264
    n++;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   265
    cbn = cbn->next();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   266
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   267
  return n;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   268
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   269
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   270
void PtrQueueSet::assert_completed_buffer_list_len_correct() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   271
  MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   272
  assert_completed_buffer_list_len_correct_locked();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   273
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   274
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   275
void PtrQueueSet::assert_completed_buffer_list_len_correct_locked() {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   276
  guarantee(completed_buffers_list_length() ==  _n_completed_buffers,
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   277
            "Completed buffer length is wrong.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   278
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   279
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   280
void PtrQueueSet::set_buffer_size(size_t sz) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   281
  assert(_sz == 0 && sz > 0, "Should be called only once.");
33761
329db4b51480 6899049: G1: Clean up code in ptrQueue.[ch]pp and ptrQueue.inline.hpp
kbarrett
parents: 30764
diff changeset
   282
  _sz = sz * sizeof(void*);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   283
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   285
// Merge lists of buffers. Notify the processing threads.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   286
// The source queue is emptied as a result. The queues
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   287
// must share the monitor.
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   288
void PtrQueueSet::merge_bufferlists(PtrQueueSet *src) {
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   289
  assert(_cbl_mon == src->_cbl_mon, "Should share the same lock");
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   290
  MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   291
  if (_completed_buffers_tail == NULL) {
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   292
    assert(_completed_buffers_head == NULL, "Well-formedness");
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   293
    _completed_buffers_head = src->_completed_buffers_head;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   294
    _completed_buffers_tail = src->_completed_buffers_tail;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   295
  } else {
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   296
    assert(_completed_buffers_head != NULL, "Well formedness");
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   297
    if (src->_completed_buffers_head != NULL) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   298
      _completed_buffers_tail->set_next(src->_completed_buffers_head);
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   299
      _completed_buffers_tail = src->_completed_buffers_tail;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   300
    }
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   301
  }
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   302
  _n_completed_buffers += src->_n_completed_buffers;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   303
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   304
  src->_n_completed_buffers = 0;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   305
  src->_completed_buffers_head = NULL;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   306
  src->_completed_buffers_tail = NULL;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   307
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   308
  assert(_completed_buffers_head == NULL && _completed_buffers_tail == NULL ||
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   309
         _completed_buffers_head != NULL && _completed_buffers_tail != NULL,
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   310
         "Sanity");
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   311
}
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   312
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   313
void PtrQueueSet::notify_if_necessary() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   314
  MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   315
  if (_n_completed_buffers >= _process_completed_threshold || _max_completed_queue == 0) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   316
    _process_completed = true;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   317
    if (_notify_when_complete)
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4454
diff changeset
   318
      _cbl_mon->notify();
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   319
  }
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 1623
diff changeset
   320
}