src/share/vm/gc_implementation/g1/satbQueue.hpp

Thu, 12 Oct 2017 21:27:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 21:27:07 +0800
changeset 7535
7ae4e26cb1e0
parent 7476
c2844108a708
parent 6876
710a3c8b516e
child 7994
04ff2f6cd0eb
permissions
-rw-r--r--

merge

aoqi@0 1 /*
tschatzl@7445 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/g1/ptrQueue.hpp"
aoqi@0 29
aoqi@0 30 class ObjectClosure;
aoqi@0 31 class JavaThread;
aoqi@0 32 class SATBMarkQueueSet;
aoqi@0 33
aoqi@0 34 // A ptrQueue whose elements are "oops", pointers to object heads.
aoqi@0 35 class ObjPtrQueue: public PtrQueue {
stefank@6992 36 friend class Threads;
aoqi@0 37 friend class SATBMarkQueueSet;
stefank@6992 38 friend class G1RemarkThreadsClosure;
aoqi@0 39
aoqi@0 40 private:
aoqi@0 41 // Filter out unwanted entries from the buffer.
aoqi@0 42 void filter();
aoqi@0 43
aoqi@0 44 // Apply the closure to all elements.
aoqi@0 45 void apply_closure(ObjectClosure* cl);
aoqi@0 46
aoqi@0 47 // Apply the closure to all elements and empty the buffer;
aoqi@0 48 void apply_closure_and_empty(ObjectClosure* cl);
aoqi@0 49
aoqi@0 50 // Apply the closure to all elements of "buf", down to "index" (inclusive.)
aoqi@0 51 static void apply_closure_to_buffer(ObjectClosure* cl,
aoqi@0 52 void** buf, size_t index, size_t sz);
aoqi@0 53
aoqi@0 54 public:
aoqi@0 55 ObjPtrQueue(PtrQueueSet* qset, bool perm = false) :
aoqi@0 56 // SATB queues are only active during marking cycles. We create
aoqi@0 57 // them with their active field set to false. If a thread is
aoqi@0 58 // created during a cycle and its SATB queue needs to be activated
aoqi@0 59 // before the thread starts running, we'll need to set its active
aoqi@0 60 // field to true. This is done in JavaThread::initialize_queues().
aoqi@0 61 PtrQueue(qset, perm, false /* active */) { }
aoqi@0 62
tschatzl@7445 63 // Process queue entries and free resources.
tschatzl@7445 64 void flush();
aoqi@0 65
aoqi@0 66 // Overrides PtrQueue::should_enqueue_buffer(). See the method's
aoqi@0 67 // definition for more information.
aoqi@0 68 virtual bool should_enqueue_buffer();
aoqi@0 69
aoqi@0 70 #ifndef PRODUCT
aoqi@0 71 // Helpful for debugging
aoqi@0 72 void print(const char* name);
aoqi@0 73 static void print(const char* name, void** buf, size_t index, size_t sz);
aoqi@0 74 #endif // PRODUCT
aoqi@0 75
aoqi@0 76 void verify_oops_in_buffer() NOT_DEBUG_RETURN;
aoqi@0 77 };
aoqi@0 78
aoqi@0 79 class SATBMarkQueueSet: public PtrQueueSet {
aoqi@0 80 ObjectClosure* _closure;
aoqi@0 81 ObjectClosure** _par_closures; // One per ParGCThread.
aoqi@0 82
aoqi@0 83 ObjPtrQueue _shared_satb_queue;
aoqi@0 84
aoqi@0 85 // Utility function to support sequential and parallel versions. If
aoqi@0 86 // "par" is true, then "worker" is the par thread id; if "false", worker
aoqi@0 87 // is ignored.
aoqi@0 88 bool apply_closure_to_completed_buffer_work(bool par, uint worker);
aoqi@0 89
aoqi@0 90 #ifdef ASSERT
aoqi@0 91 void dump_active_states(bool expected_active);
aoqi@0 92 void verify_active_states(bool expected_active);
aoqi@0 93 #endif // ASSERT
aoqi@0 94
aoqi@0 95 public:
aoqi@0 96 SATBMarkQueueSet();
aoqi@0 97
aoqi@0 98 void initialize(Monitor* cbl_mon, Mutex* fl_lock,
aoqi@0 99 int process_completed_threshold,
aoqi@0 100 Mutex* lock);
aoqi@0 101
aoqi@0 102 static void handle_zero_index_for_thread(JavaThread* t);
aoqi@0 103
aoqi@0 104 // Apply "set_active(active)" to all SATB queues in the set. It should be
aoqi@0 105 // called only with the world stopped. The method will assert that the
aoqi@0 106 // SATB queues of all threads it visits, as well as the SATB queue
aoqi@0 107 // set itself, has an active value same as expected_active.
aoqi@0 108 void set_active_all_threads(bool active, bool expected_active);
aoqi@0 109
aoqi@0 110 // Filter all the currently-active SATB buffers.
aoqi@0 111 void filter_thread_buffers();
aoqi@0 112
aoqi@0 113 // Register "blk" as "the closure" for all queues. Only one such closure
aoqi@0 114 // is allowed. The "apply_closure_to_completed_buffer" method will apply
aoqi@0 115 // this closure to a completed buffer, and "iterate_closure_all_threads"
aoqi@0 116 // applies it to partially-filled buffers (the latter should only be done
aoqi@0 117 // with the world stopped).
aoqi@0 118 void set_closure(ObjectClosure* closure);
aoqi@0 119 // Set the parallel closures: pointer is an array of pointers to
aoqi@0 120 // closures, one for each parallel GC thread.
aoqi@0 121 void set_par_closure(int i, ObjectClosure* closure);
aoqi@0 122
aoqi@0 123 // If there exists some completed buffer, pop it, then apply the
aoqi@0 124 // registered closure to all its elements, and return true. If no
aoqi@0 125 // completed buffers exist, return false.
aoqi@0 126 bool apply_closure_to_completed_buffer() {
aoqi@0 127 return apply_closure_to_completed_buffer_work(false, 0);
aoqi@0 128 }
aoqi@0 129 // Parallel version of the above.
aoqi@0 130 bool par_apply_closure_to_completed_buffer(uint worker) {
aoqi@0 131 return apply_closure_to_completed_buffer_work(true, worker);
aoqi@0 132 }
aoqi@0 133
aoqi@0 134 // Apply the given closure on enqueued and currently-active buffers
aoqi@0 135 // respectively. Both methods are read-only, i.e., they do not
aoqi@0 136 // modify any of the buffers.
aoqi@0 137 void iterate_completed_buffers_read_only(ObjectClosure* cl);
aoqi@0 138 void iterate_thread_buffers_read_only(ObjectClosure* cl);
aoqi@0 139
aoqi@0 140 #ifndef PRODUCT
aoqi@0 141 // Helpful for debugging
aoqi@0 142 void print_all(const char* msg);
aoqi@0 143 #endif // PRODUCT
aoqi@0 144
aoqi@0 145 ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; }
aoqi@0 146
aoqi@0 147 // If a marking is being abandoned, reset any unprocessed log buffers.
aoqi@0 148 void abandon_partial_marking();
aoqi@0 149 };
aoqi@0 150
aoqi@0 151 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP

mercurial