src/share/vm/memory/genRemSet.hpp

Fri, 20 Sep 2013 10:53:28 +0200

author
stefank
date
Fri, 20 Sep 2013 10:53:28 +0200
changeset 5769
2c022e432e10
parent 5519
bd902affe102
child 6198
55fb97c4c58d
permissions
-rw-r--r--

8024974: Incorrect use of GC_locker::is_active()
Summary: SymbolTable and StringTable can make calls to GC_locker::is_active() outside a safepoint. This isn't safe because the GC_locker active state (lock count) is only updated at a safepoint and only remains valid as long as _needs_gc is true. However, outside a safepoint_needs_gc can change to false at any time, which makes it impossible to do a correct call to is_active() in that context. In this case these calls can just be removed since the input argument to basic_add() should never be on the heap and so there's no need to check the GC_locker state. This change also adjusts the assert() in is_active() to makes sure all calls to this function are always done under a safepoint.
Reviewed-by: brutisso, dcubed
Contributed-by: per.liden@oracle.com

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_MEMORY_GENREMSET_HPP
stefank@2314 26 #define SHARE_VM_MEMORY_GENREMSET_HPP
stefank@2314 27
stefank@2314 28 #include "oops/oop.hpp"
stefank@2314 29
duke@435 30 // A GenRemSet provides ways of iterating over pointers accross generations.
duke@435 31 // (This is especially useful for older-to-younger.)
duke@435 32
duke@435 33 class Generation;
duke@435 34 class BarrierSet;
duke@435 35 class OopsInGenClosure;
duke@435 36 class CardTableRS;
duke@435 37
coleenp@4037 38 // Helper to remember modified oops in all klasses.
coleenp@4037 39 class KlassRemSet {
coleenp@4037 40 bool _accumulate_modified_oops;
coleenp@4037 41 public:
coleenp@4037 42 KlassRemSet() : _accumulate_modified_oops(false) {}
coleenp@4037 43 void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }
coleenp@4037 44 bool accumulate_modified_oops() { return _accumulate_modified_oops; }
coleenp@4037 45 bool mod_union_is_clear();
coleenp@4037 46 void clear_mod_union();
coleenp@4037 47 };
coleenp@4037 48
zgu@3900 49 class GenRemSet: public CHeapObj<mtGC> {
duke@435 50 friend class Generation;
duke@435 51
duke@435 52 BarrierSet* _bs;
coleenp@4037 53 KlassRemSet _klass_rem_set;
duke@435 54
duke@435 55 public:
duke@435 56 enum Name {
duke@435 57 CardTable,
duke@435 58 Other
duke@435 59 };
duke@435 60
duke@435 61 GenRemSet(BarrierSet * bs) : _bs(bs) {}
ysr@777 62 GenRemSet() : _bs(NULL) {}
duke@435 63
duke@435 64 virtual Name rs_kind() = 0;
duke@435 65
duke@435 66 // These are for dynamic downcasts. Unfortunately that it names the
duke@435 67 // possible subtypes (but not that they are subtypes!) Return NULL if
duke@435 68 // the cast is invalide.
duke@435 69 virtual CardTableRS* as_CardTableRS() { return NULL; }
duke@435 70
duke@435 71 // Return the barrier set associated with "this."
duke@435 72 BarrierSet* bs() { return _bs; }
duke@435 73
ysr@777 74 // Set the barrier set.
ysr@777 75 void set_bs(BarrierSet* bs) { _bs = bs; }
ysr@777 76
coleenp@4037 77 KlassRemSet* klass_rem_set() { return &_klass_rem_set; }
coleenp@4037 78
duke@435 79 // Do any (sequential) processing necessary to prepare for (possibly
duke@435 80 // "parallel", if that arg is true) calls to younger_refs_iterate.
duke@435 81 virtual void prepare_for_younger_refs_iterate(bool parallel) = 0;
duke@435 82
duke@435 83 // Apply the "do_oop" method of "blk" to (exactly) all oop locations
duke@435 84 // 1) that are in objects allocated in "g" at the time of the last call
duke@435 85 // to "save_Marks", and
duke@435 86 // 2) that point to objects in younger generations.
duke@435 87 virtual void younger_refs_iterate(Generation* g, OopsInGenClosure* blk) = 0;
duke@435 88
duke@435 89 virtual void younger_refs_in_space_iterate(Space* sp,
duke@435 90 OopsInGenClosure* cl) = 0;
duke@435 91
duke@435 92 // This method is used to notify the remembered set that "new_val" has
duke@435 93 // been written into "field" by the garbage collector.
coleenp@548 94 void write_ref_field_gc(void* field, oop new_val);
duke@435 95 protected:
coleenp@548 96 virtual void write_ref_field_gc_work(void* field, oop new_val) = 0;
duke@435 97 public:
duke@435 98
duke@435 99 // A version of the above suitable for use by parallel collectors.
coleenp@548 100 virtual void write_ref_field_gc_par(void* field, oop new_val) = 0;
duke@435 101
duke@435 102 // Resize one of the regions covered by the remembered set.
duke@435 103 virtual void resize_covered_region(MemRegion new_region) = 0;
duke@435 104
duke@435 105 // If the rem set imposes any alignment restrictions on boundaries
duke@435 106 // within the heap, this function tells whether they are met.
duke@435 107 virtual bool is_aligned(HeapWord* addr) = 0;
duke@435 108
duke@435 109 // If the RS (or BS) imposes an aligment constraint on maximum heap size.
duke@435 110 // (This must be static, and dispatch on "nm", because it is called
duke@435 111 // before an RS is created.)
duke@435 112 static uintx max_alignment_constraint(Name nm);
duke@435 113
duke@435 114 virtual void verify() = 0;
duke@435 115
duke@435 116 // Verify that the remembered set has no entries for
jmasa@441 117 // the heap interval denoted by mr. If there are any
jmasa@441 118 // alignment constraints on the remembered set, only the
jmasa@441 119 // part of the region that is aligned is checked.
jmasa@441 120 //
jmasa@441 121 // alignment boundaries
jmasa@441 122 // +--------+-------+--------+-------+
jmasa@441 123 // [ region mr )
jmasa@441 124 // [ part checked )
jmasa@441 125 virtual void verify_aligned_region_empty(MemRegion mr) = 0;
duke@435 126
duke@435 127 // If appropriate, print some information about the remset on "tty".
duke@435 128 virtual void print() {}
duke@435 129
duke@435 130 // Informs the RS that the given memregion contains no references to
duke@435 131 // younger generations.
duke@435 132 virtual void clear(MemRegion mr) = 0;
duke@435 133
duke@435 134 // Informs the RS that there are no references to generations
duke@435 135 // younger than gen from generations gen and older.
duke@435 136 // The parameter clear_perm indicates if the perm_gen's
duke@435 137 // remembered set should also be processed/cleared.
brutisso@5519 138 virtual void clear_into_younger(Generation* old_gen) = 0;
duke@435 139
duke@435 140 // Informs the RS that refs in the given "mr" may have changed
duke@435 141 // arbitrarily, and therefore may contain old-to-young pointers.
ysr@777 142 // If "whole heap" is true, then this invalidation is part of an
ysr@777 143 // invalidation of the whole heap, which an implementation might
ysr@777 144 // handle differently than that of a sub-part of the heap.
ysr@777 145 virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;
duke@435 146
duke@435 147 // Informs the RS that refs in this generation
duke@435 148 // may have changed arbitrarily, and therefore may contain
brutisso@5516 149 // old-to-young pointers in arbitrary locations.
brutisso@5519 150 virtual void invalidate_or_clear(Generation* old_gen) = 0;
duke@435 151 };
stefank@2314 152
stefank@2314 153 #endif // SHARE_VM_MEMORY_GENREMSET_HPP

mercurial