src/share/vm/memory/genRemSet.hpp

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

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
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_MEMORY_GENREMSET_HPP
aoqi@0 26 #define SHARE_VM_MEMORY_GENREMSET_HPP
aoqi@0 27
aoqi@0 28 #include "oops/oop.hpp"
aoqi@0 29
aoqi@0 30 // A GenRemSet provides ways of iterating over pointers accross generations.
aoqi@0 31 // (This is especially useful for older-to-younger.)
aoqi@0 32
aoqi@0 33 class Generation;
aoqi@0 34 class BarrierSet;
aoqi@0 35 class OopsInGenClosure;
aoqi@0 36 class CardTableRS;
aoqi@0 37
aoqi@0 38 // Helper to remember modified oops in all klasses.
aoqi@0 39 class KlassRemSet {
aoqi@0 40 bool _accumulate_modified_oops;
aoqi@0 41 public:
aoqi@0 42 KlassRemSet() : _accumulate_modified_oops(false) {}
aoqi@0 43 void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }
aoqi@0 44 bool accumulate_modified_oops() { return _accumulate_modified_oops; }
aoqi@0 45 bool mod_union_is_clear();
aoqi@0 46 void clear_mod_union();
aoqi@0 47 };
aoqi@0 48
aoqi@0 49 class GenRemSet: public CHeapObj<mtGC> {
aoqi@0 50 friend class Generation;
aoqi@0 51
aoqi@0 52 BarrierSet* _bs;
aoqi@0 53 KlassRemSet _klass_rem_set;
aoqi@0 54
aoqi@0 55 public:
aoqi@0 56 enum Name {
aoqi@0 57 CardTable,
aoqi@0 58 Other
aoqi@0 59 };
aoqi@0 60
aoqi@0 61 GenRemSet(BarrierSet * bs) : _bs(bs) {}
aoqi@0 62 GenRemSet() : _bs(NULL) {}
aoqi@0 63
aoqi@0 64 virtual Name rs_kind() = 0;
aoqi@0 65
aoqi@0 66 // These are for dynamic downcasts. Unfortunately that it names the
aoqi@0 67 // possible subtypes (but not that they are subtypes!) Return NULL if
aoqi@0 68 // the cast is invalide.
aoqi@0 69 virtual CardTableRS* as_CardTableRS() { return NULL; }
aoqi@0 70
aoqi@0 71 // Return the barrier set associated with "this."
aoqi@0 72 BarrierSet* bs() { return _bs; }
aoqi@0 73
aoqi@0 74 // Set the barrier set.
aoqi@0 75 void set_bs(BarrierSet* bs) { _bs = bs; }
aoqi@0 76
aoqi@0 77 KlassRemSet* klass_rem_set() { return &_klass_rem_set; }
aoqi@0 78
aoqi@0 79 // Do any (sequential) processing necessary to prepare for (possibly
aoqi@0 80 // "parallel", if that arg is true) calls to younger_refs_iterate.
aoqi@0 81 virtual void prepare_for_younger_refs_iterate(bool parallel) = 0;
aoqi@0 82
aoqi@0 83 // Apply the "do_oop" method of "blk" to (exactly) all oop locations
aoqi@0 84 // 1) that are in objects allocated in "g" at the time of the last call
aoqi@0 85 // to "save_Marks", and
aoqi@0 86 // 2) that point to objects in younger generations.
aoqi@0 87 virtual void younger_refs_iterate(Generation* g, OopsInGenClosure* blk) = 0;
aoqi@0 88
aoqi@0 89 virtual void younger_refs_in_space_iterate(Space* sp,
aoqi@0 90 OopsInGenClosure* cl) = 0;
aoqi@0 91
aoqi@0 92 // This method is used to notify the remembered set that "new_val" has
aoqi@0 93 // been written into "field" by the garbage collector.
aoqi@0 94 void write_ref_field_gc(void* field, oop new_val);
aoqi@0 95 protected:
aoqi@0 96 virtual void write_ref_field_gc_work(void* field, oop new_val) = 0;
aoqi@0 97 public:
aoqi@0 98
aoqi@0 99 // A version of the above suitable for use by parallel collectors.
aoqi@0 100 virtual void write_ref_field_gc_par(void* field, oop new_val) = 0;
aoqi@0 101
aoqi@0 102 // Resize one of the regions covered by the remembered set.
aoqi@0 103 virtual void resize_covered_region(MemRegion new_region) = 0;
aoqi@0 104
aoqi@0 105 // If the rem set imposes any alignment restrictions on boundaries
aoqi@0 106 // within the heap, this function tells whether they are met.
aoqi@0 107 virtual bool is_aligned(HeapWord* addr) = 0;
aoqi@0 108
aoqi@0 109 // If the RS (or BS) imposes an aligment constraint on maximum heap size.
aoqi@0 110 // (This must be static, and dispatch on "nm", because it is called
aoqi@0 111 // before an RS is created.)
aoqi@0 112 static uintx max_alignment_constraint(Name nm);
aoqi@0 113
aoqi@0 114 virtual void verify() = 0;
aoqi@0 115
aoqi@0 116 // Verify that the remembered set has no entries for
aoqi@0 117 // the heap interval denoted by mr. If there are any
aoqi@0 118 // alignment constraints on the remembered set, only the
aoqi@0 119 // part of the region that is aligned is checked.
aoqi@0 120 //
aoqi@0 121 // alignment boundaries
aoqi@0 122 // +--------+-------+--------+-------+
aoqi@0 123 // [ region mr )
aoqi@0 124 // [ part checked )
aoqi@0 125 virtual void verify_aligned_region_empty(MemRegion mr) = 0;
aoqi@0 126
aoqi@0 127 // If appropriate, print some information about the remset on "tty".
aoqi@0 128 virtual void print() {}
aoqi@0 129
aoqi@0 130 // Informs the RS that the given memregion contains no references to
aoqi@0 131 // younger generations.
aoqi@0 132 virtual void clear(MemRegion mr) = 0;
aoqi@0 133
aoqi@0 134 // Informs the RS that there are no references to generations
aoqi@0 135 // younger than gen from generations gen and older.
aoqi@0 136 // The parameter clear_perm indicates if the perm_gen's
aoqi@0 137 // remembered set should also be processed/cleared.
aoqi@0 138 virtual void clear_into_younger(Generation* old_gen) = 0;
aoqi@0 139
aoqi@0 140 // Informs the RS that refs in the given "mr" may have changed
aoqi@0 141 // arbitrarily, and therefore may contain old-to-young pointers.
aoqi@0 142 // If "whole heap" is true, then this invalidation is part of an
aoqi@0 143 // invalidation of the whole heap, which an implementation might
aoqi@0 144 // handle differently than that of a sub-part of the heap.
aoqi@0 145 virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;
aoqi@0 146
aoqi@0 147 // Informs the RS that refs in this generation
aoqi@0 148 // may have changed arbitrarily, and therefore may contain
aoqi@0 149 // old-to-young pointers in arbitrary locations.
aoqi@0 150 virtual void invalidate_or_clear(Generation* old_gen) = 0;
aoqi@0 151 };
aoqi@0 152
aoqi@0 153 #endif // SHARE_VM_MEMORY_GENREMSET_HPP

mercurial