hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 f4b087cbb361
child 7920 298df61588a2
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
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
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2001, 2010, 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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "gc_implementation/g1/satbQueue.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/sharedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/thread.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    31
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    32
void ObjPtrQueue::apply_closure(ObjectClosure* cl) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
  if (_buf != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
    apply_closure_to_buffer(cl, _buf, _index, _sz);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
    _index = _sz;
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
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
void ObjPtrQueue::apply_closure_to_buffer(ObjectClosure* cl,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
                                          void** buf, size_t index, size_t sz) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
  if (cl == NULL) return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
  for (size_t i = index; i < sz; i += oopSize) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
    oop obj = (oop)buf[byte_index_to_index((int)i)];
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
    // There can be NULL entries because of destructors.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
    if (obj != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
      cl->do_object(obj);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
}
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    50
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    51
#ifdef ASSERT
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    52
void ObjPtrQueue::verify_oops_in_buffer() {
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    53
  if (_buf == NULL) return;
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    54
  for (size_t i = _index; i < _sz; i += oopSize) {
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    55
    oop obj = (oop)_buf[byte_index_to_index((int)i)];
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    56
    assert(obj != NULL && obj->is_oop(true /* ignore mark word */),
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    57
           "Not an oop");
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    58
  }
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    59
}
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    60
#endif
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    61
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    62
#ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
#endif // _MSC_VER
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
SATBMarkQueueSet::SATBMarkQueueSet() :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  PtrQueueSet(),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  _closure(NULL), _par_closures(NULL),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
  _shared_satb_queue(this, true /*perm*/)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
{}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
    74
                                  int process_completed_threshold,
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
                                  Mutex* lock) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
    76
  PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
  _shared_satb_queue.set_lock(lock);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
  if (ParallelGCThreads > 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
    _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
    85
  DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  t->satb_mark_queue().handle_zero_index();
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
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    89
#ifdef ASSERT
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    90
void SATBMarkQueueSet::dump_active_values(JavaThread* first,
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    91
                                          bool expected_active) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    92
  gclog_or_tty->print_cr("SATB queue active values for Java Threads");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    93
  gclog_or_tty->print_cr(" SATB queue set: active is %s",
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    94
                         (is_active()) ? "TRUE" : "FALSE");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    95
  gclog_or_tty->print_cr(" expected_active is %s",
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    96
                         (expected_active) ? "TRUE" : "FALSE");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    97
  for (JavaThread* t = first; t; t = t->next()) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    98
    bool active = t->satb_mark_queue().is_active();
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
    99
    gclog_or_tty->print_cr("  thread %s, active is %s",
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   100
                           t->name(), (active) ? "TRUE" : "FALSE");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   101
  }
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   102
}
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   103
#endif // ASSERT
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   104
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   105
void SATBMarkQueueSet::set_active_all_threads(bool b,
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   106
                                              bool expected_active) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   107
  assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   108
  JavaThread* first = Threads::first();
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   109
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   110
#ifdef ASSERT
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   111
  if (_all_active != expected_active) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   112
    dump_active_values(first, expected_active);
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   113
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   114
    // I leave this here as a guarantee, instead of an assert, so
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   115
    // that it will still be compiled in if we choose to uncomment
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   116
    // the #ifdef ASSERT in a product build. The whole block is
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   117
    // within an #ifdef ASSERT so the guarantee will not be compiled
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   118
    // in a product build anyway.
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   119
    guarantee(false,
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   120
              "SATB queue set has an unexpected active value");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   121
  }
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   122
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   123
  _all_active = b;
5082
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   124
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   125
  for (JavaThread* t = first; t; t = t->next()) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   126
#ifdef ASSERT
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   127
    bool active = t->satb_mark_queue().is_active();
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   128
    if (active != expected_active) {
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   129
      dump_active_values(first, expected_active);
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   130
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   131
      // I leave this here as a guarantee, instead of an assert, so
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   132
      // that it will still be compiled in if we choose to uncomment
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   133
      // the #ifdef ASSERT in a product build. The whole block is
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   134
      // within an #ifdef ASSERT so the guarantee will not be compiled
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   135
      // in a product build anyway.
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   136
      guarantee(false,
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   137
                "thread has an unexpected active value in its SATB queue");
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   138
    }
19e725a3d2eb 6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents: 4481
diff changeset
   139
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
    t->satb_mark_queue().set_active(b);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
  }
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
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   144
void SATBMarkQueueSet::set_closure(ObjectClosure* closure) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
  _closure = closure;
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 SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
  assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
  _par_closures[i] = par_closure;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
void SATBMarkQueueSet::iterate_closure_all_threads() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
  for(JavaThread* t = Threads::first(); t; t = t->next()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   155
    t->satb_mark_queue().apply_closure(_closure);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   156
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
  shared_satb_queue()->apply_closure(_closure);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   158
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  SharedHeap* sh = SharedHeap::heap();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
  int parity = sh->strong_roots_parity();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
  for(JavaThread* t = Threads::first(); t; t = t->next()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
    if (t->claim_oops_do(true, parity)) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
      t->satb_mark_queue().apply_closure(_par_closures[worker]);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
  // We'll have worker 0 do this one.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  if (worker == 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
    shared_satb_queue()->apply_closure(_par_closures[0]);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
                                                              int worker) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   177
  BufferNode* nd = NULL;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
    MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
    if (_completed_buffers_head != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
      nd = _completed_buffers_head;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   182
      _completed_buffers_head = nd->next();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
      if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   184
      _n_completed_buffers--;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   185
      if (_n_completed_buffers == 0) _process_completed = false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   186
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   187
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   188
  ObjectClosure* cl = (par ? _par_closures[worker] : _closure);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   189
  if (nd != NULL) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   190
    void **buf = BufferNode::make_buffer_from_node(nd);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   191
    ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   192
    deallocate_buffer(buf);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
    return true;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   194
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   195
    return false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
  }
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
void SATBMarkQueueSet::abandon_partial_marking() {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   200
  BufferNode* buffers_to_delete = NULL;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
  {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   202
    MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
    while (_completed_buffers_head != NULL) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   204
      BufferNode* nd = _completed_buffers_head;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   205
      _completed_buffers_head = nd->next();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   206
      nd->set_next(buffers_to_delete);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   207
      buffers_to_delete = nd;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   208
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
    _completed_buffers_tail = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
    _n_completed_buffers = 0;
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1374
diff changeset
   211
    DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
  while (buffers_to_delete != NULL) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   214
    BufferNode* nd = buffers_to_delete;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   215
    buffers_to_delete = nd->next();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 3262
diff changeset
   216
    deallocate_buffer(BufferNode::make_buffer_from_node(nd));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   217
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
  assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
  // So we can safely manipulate these queues.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
  for (JavaThread* t = Threads::first(); t; t = t->next()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   221
    t->satb_mark_queue().reset();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
  shared_satb_queue()->reset();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
}