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

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6503
a9becfeecd1b
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2013, 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_G1SATBCARDTABLEMODREFBS_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/cardTableModRefBS.hpp"
aoqi@0 29 #include "memory/memRegion.hpp"
aoqi@0 30 #include "oops/oop.inline.hpp"
aoqi@0 31 #include "utilities/macros.hpp"
aoqi@0 32
aoqi@0 33 #if INCLUDE_ALL_GCS
aoqi@0 34
aoqi@0 35 class DirtyCardQueueSet;
aoqi@0 36
aoqi@0 37 // This barrier is specialized to use a logging barrier to support
aoqi@0 38 // snapshot-at-the-beginning marking.
aoqi@0 39
aoqi@0 40 class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS {
aoqi@0 41 protected:
aoqi@0 42 enum G1CardValues {
aoqi@0 43 g1_young_gen = CT_MR_BS_last_reserved << 1
aoqi@0 44 };
aoqi@0 45
aoqi@0 46 public:
aoqi@0 47 static int g1_young_card_val() { return g1_young_gen; }
aoqi@0 48
aoqi@0 49 // Add "pre_val" to a set of objects that may have been disconnected from the
aoqi@0 50 // pre-marking object graph.
aoqi@0 51 static void enqueue(oop pre_val);
aoqi@0 52
aoqi@0 53 G1SATBCardTableModRefBS(MemRegion whole_heap,
aoqi@0 54 int max_covered_regions);
aoqi@0 55
aoqi@0 56 bool is_a(BarrierSet::Name bsn) {
aoqi@0 57 return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn);
aoqi@0 58 }
aoqi@0 59
aoqi@0 60 virtual bool has_write_ref_pre_barrier() { return true; }
aoqi@0 61
aoqi@0 62 // This notes that we don't need to access any BarrierSet data
aoqi@0 63 // structures, so this can be called from a static context.
aoqi@0 64 template <class T> static void write_ref_field_pre_static(T* field, oop newVal) {
aoqi@0 65 T heap_oop = oopDesc::load_heap_oop(field);
aoqi@0 66 if (!oopDesc::is_null(heap_oop)) {
aoqi@0 67 enqueue(oopDesc::decode_heap_oop(heap_oop));
aoqi@0 68 }
aoqi@0 69 }
aoqi@0 70
aoqi@0 71 // We export this to make it available in cases where the static
aoqi@0 72 // type of the barrier set is known. Note that it is non-virtual.
aoqi@0 73 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
aoqi@0 74 write_ref_field_pre_static(field, newVal);
aoqi@0 75 }
aoqi@0 76
aoqi@0 77 // These are the more general virtual versions.
aoqi@0 78 virtual void write_ref_field_pre_work(oop* field, oop new_val) {
aoqi@0 79 inline_write_ref_field_pre(field, new_val);
aoqi@0 80 }
aoqi@0 81 virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {
aoqi@0 82 inline_write_ref_field_pre(field, new_val);
aoqi@0 83 }
aoqi@0 84 virtual void write_ref_field_pre_work(void* field, oop new_val) {
aoqi@0 85 guarantee(false, "Not needed");
aoqi@0 86 }
aoqi@0 87
aoqi@0 88 template <class T> void write_ref_array_pre_work(T* dst, int count);
aoqi@0 89 virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) {
aoqi@0 90 if (!dest_uninitialized) {
aoqi@0 91 write_ref_array_pre_work(dst, count);
aoqi@0 92 }
aoqi@0 93 }
aoqi@0 94 virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) {
aoqi@0 95 if (!dest_uninitialized) {
aoqi@0 96 write_ref_array_pre_work(dst, count);
aoqi@0 97 }
aoqi@0 98 }
aoqi@0 99
aoqi@0 100 /*
aoqi@0 101 Claimed and deferred bits are used together in G1 during the evacuation
aoqi@0 102 pause. These bits can have the following state transitions:
aoqi@0 103 1. The claimed bit can be put over any other card state. Except that
aoqi@0 104 the "dirty -> dirty and claimed" transition is checked for in
aoqi@0 105 G1 code and is not used.
aoqi@0 106 2. Deferred bit can be set only if the previous state of the card
aoqi@0 107 was either clean or claimed. mark_card_deferred() is wait-free.
aoqi@0 108 We do not care if the operation is be successful because if
aoqi@0 109 it does not it will only result in duplicate entry in the update
aoqi@0 110 buffer because of the "cache-miss". So it's not worth spinning.
aoqi@0 111 */
aoqi@0 112
aoqi@0 113 bool is_card_claimed(size_t card_index) {
aoqi@0 114 jbyte val = _byte_map[card_index];
aoqi@0 115 return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val();
aoqi@0 116 }
aoqi@0 117
aoqi@0 118 void set_card_claimed(size_t card_index) {
aoqi@0 119 jbyte val = _byte_map[card_index];
aoqi@0 120 if (val == clean_card_val()) {
aoqi@0 121 val = (jbyte)claimed_card_val();
aoqi@0 122 } else {
aoqi@0 123 val |= (jbyte)claimed_card_val();
aoqi@0 124 }
aoqi@0 125 _byte_map[card_index] = val;
aoqi@0 126 }
aoqi@0 127
aoqi@0 128 void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
aoqi@0 129 void g1_mark_as_young(const MemRegion& mr);
aoqi@0 130
aoqi@0 131 bool mark_card_deferred(size_t card_index);
aoqi@0 132
aoqi@0 133 bool is_card_deferred(size_t card_index) {
aoqi@0 134 jbyte val = _byte_map[card_index];
aoqi@0 135 return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 };
aoqi@0 139
aoqi@0 140 // Adds card-table logging to the post-barrier.
aoqi@0 141 // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.
aoqi@0 142 class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {
aoqi@0 143 private:
aoqi@0 144 DirtyCardQueueSet& _dcqs;
aoqi@0 145 public:
aoqi@0 146 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
aoqi@0 147 int max_covered_regions);
aoqi@0 148
aoqi@0 149 bool is_a(BarrierSet::Name bsn) {
aoqi@0 150 return bsn == BarrierSet::G1SATBCTLogging ||
aoqi@0 151 G1SATBCardTableModRefBS::is_a(bsn);
aoqi@0 152 }
aoqi@0 153
aoqi@0 154 void write_ref_field_work(void* field, oop new_val, bool release = false);
aoqi@0 155
aoqi@0 156 // Can be called from static contexts.
aoqi@0 157 static void write_ref_field_static(void* field, oop new_val);
aoqi@0 158
aoqi@0 159 // NB: if you do a whole-heap invalidation, the "usual invariant" defined
aoqi@0 160 // above no longer applies.
aoqi@0 161 void invalidate(MemRegion mr, bool whole_heap = false);
aoqi@0 162
aoqi@0 163 void write_region_work(MemRegion mr) { invalidate(mr); }
aoqi@0 164 void write_ref_array_work(MemRegion mr) { invalidate(mr); }
aoqi@0 165
aoqi@0 166
aoqi@0 167 };
aoqi@0 168
aoqi@0 169
aoqi@0 170 #endif // INCLUDE_ALL_GCS
aoqi@0 171
aoqi@0 172 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP

mercurial