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

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 7834
399885e13e90
parent 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
kbarrett@7831 2 * Copyright (c) 2001, 2015, 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
kbarrett@7834 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "gc_implementation/g1/ptrQueue.hpp"
aoqi@0 30
aoqi@0 31 class JavaThread;
aoqi@0 32 class SATBMarkQueueSet;
aoqi@0 33
kbarrett@7834 34 // Base class for processing the contents of a SATB buffer.
kbarrett@7834 35 class SATBBufferClosure : public StackObj {
kbarrett@7834 36 protected:
kbarrett@7834 37 ~SATBBufferClosure() { }
kbarrett@7834 38
kbarrett@7834 39 public:
kbarrett@7834 40 // Process the SATB entries in the designated buffer range.
kbarrett@7834 41 virtual void do_buffer(void** buffer, size_t size) = 0;
kbarrett@7834 42 };
kbarrett@7834 43
aoqi@0 44 // A ptrQueue whose elements are "oops", pointers to object heads.
aoqi@0 45 class ObjPtrQueue: public PtrQueue {
aoqi@0 46 friend class SATBMarkQueueSet;
aoqi@0 47
aoqi@0 48 private:
aoqi@0 49 // Filter out unwanted entries from the buffer.
aoqi@0 50 void filter();
aoqi@0 51
aoqi@0 52 public:
aoqi@0 53 ObjPtrQueue(PtrQueueSet* qset, bool perm = false) :
aoqi@0 54 // SATB queues are only active during marking cycles. We create
aoqi@0 55 // them with their active field set to false. If a thread is
aoqi@0 56 // created during a cycle and its SATB queue needs to be activated
aoqi@0 57 // before the thread starts running, we'll need to set its active
aoqi@0 58 // field to true. This is done in JavaThread::initialize_queues().
aoqi@0 59 PtrQueue(qset, perm, false /* active */) { }
aoqi@0 60
tschatzl@7445 61 // Process queue entries and free resources.
tschatzl@7445 62 void flush();
aoqi@0 63
kbarrett@7834 64 // Apply cl to the active part of the buffer.
kbarrett@7834 65 // Prerequisite: Must be at a safepoint.
kbarrett@7834 66 void apply_closure_and_empty(SATBBufferClosure* cl);
kbarrett@7834 67
aoqi@0 68 // Overrides PtrQueue::should_enqueue_buffer(). See the method's
aoqi@0 69 // definition for more information.
aoqi@0 70 virtual bool should_enqueue_buffer();
aoqi@0 71
aoqi@0 72 #ifndef PRODUCT
aoqi@0 73 // Helpful for debugging
aoqi@0 74 void print(const char* name);
aoqi@0 75 static void print(const char* name, void** buf, size_t index, size_t sz);
aoqi@0 76 #endif // PRODUCT
aoqi@0 77 };
aoqi@0 78
aoqi@0 79 class SATBMarkQueueSet: public PtrQueueSet {
aoqi@0 80 ObjPtrQueue _shared_satb_queue;
aoqi@0 81
aoqi@0 82 #ifdef ASSERT
aoqi@0 83 void dump_active_states(bool expected_active);
aoqi@0 84 void verify_active_states(bool expected_active);
aoqi@0 85 #endif // ASSERT
aoqi@0 86
aoqi@0 87 public:
aoqi@0 88 SATBMarkQueueSet();
aoqi@0 89
aoqi@0 90 void initialize(Monitor* cbl_mon, Mutex* fl_lock,
aoqi@0 91 int process_completed_threshold,
aoqi@0 92 Mutex* lock);
aoqi@0 93
aoqi@0 94 static void handle_zero_index_for_thread(JavaThread* t);
aoqi@0 95
aoqi@0 96 // Apply "set_active(active)" to all SATB queues in the set. It should be
aoqi@0 97 // called only with the world stopped. The method will assert that the
aoqi@0 98 // SATB queues of all threads it visits, as well as the SATB queue
aoqi@0 99 // set itself, has an active value same as expected_active.
aoqi@0 100 void set_active_all_threads(bool active, bool expected_active);
aoqi@0 101
aoqi@0 102 // Filter all the currently-active SATB buffers.
aoqi@0 103 void filter_thread_buffers();
aoqi@0 104
kbarrett@7834 105 // If there exists some completed buffer, pop and process it, and
kbarrett@7834 106 // return true. Otherwise return false. Processing a buffer
kbarrett@7834 107 // consists of applying the closure to the buffer range starting
kbarrett@7834 108 // with the first non-NULL entry to the end of the buffer; the
kbarrett@7834 109 // leading entries may be NULL due to filtering.
kbarrett@7834 110 bool apply_closure_to_completed_buffer(SATBBufferClosure* cl);
aoqi@0 111
aoqi@0 112 #ifndef PRODUCT
aoqi@0 113 // Helpful for debugging
aoqi@0 114 void print_all(const char* msg);
aoqi@0 115 #endif // PRODUCT
aoqi@0 116
aoqi@0 117 ObjPtrQueue* shared_satb_queue() { return &_shared_satb_queue; }
aoqi@0 118
aoqi@0 119 // If a marking is being abandoned, reset any unprocessed log buffers.
aoqi@0 120 void abandon_partial_marking();
aoqi@0 121 };
aoqi@0 122
aoqi@0 123 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SATBQUEUE_HPP

mercurial