duke@435: /* mikael@6198: * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_MEMORY_GENREMSET_HPP stefank@2314: #define SHARE_VM_MEMORY_GENREMSET_HPP stefank@2314: stefank@2314: #include "oops/oop.hpp" stefank@2314: duke@435: // A GenRemSet provides ways of iterating over pointers accross generations. duke@435: // (This is especially useful for older-to-younger.) duke@435: duke@435: class Generation; duke@435: class BarrierSet; duke@435: class OopsInGenClosure; duke@435: class CardTableRS; duke@435: coleenp@4037: // Helper to remember modified oops in all klasses. coleenp@4037: class KlassRemSet { coleenp@4037: bool _accumulate_modified_oops; coleenp@4037: public: coleenp@4037: KlassRemSet() : _accumulate_modified_oops(false) {} coleenp@4037: void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; } coleenp@4037: bool accumulate_modified_oops() { return _accumulate_modified_oops; } coleenp@4037: bool mod_union_is_clear(); coleenp@4037: void clear_mod_union(); coleenp@4037: }; coleenp@4037: zgu@3900: class GenRemSet: public CHeapObj { duke@435: friend class Generation; duke@435: duke@435: BarrierSet* _bs; coleenp@4037: KlassRemSet _klass_rem_set; duke@435: duke@435: public: duke@435: enum Name { duke@435: CardTable, duke@435: Other duke@435: }; duke@435: duke@435: GenRemSet(BarrierSet * bs) : _bs(bs) {} ysr@777: GenRemSet() : _bs(NULL) {} duke@435: duke@435: virtual Name rs_kind() = 0; duke@435: duke@435: // These are for dynamic downcasts. Unfortunately that it names the duke@435: // possible subtypes (but not that they are subtypes!) Return NULL if duke@435: // the cast is invalide. duke@435: virtual CardTableRS* as_CardTableRS() { return NULL; } duke@435: duke@435: // Return the barrier set associated with "this." duke@435: BarrierSet* bs() { return _bs; } duke@435: ysr@777: // Set the barrier set. ysr@777: void set_bs(BarrierSet* bs) { _bs = bs; } ysr@777: coleenp@4037: KlassRemSet* klass_rem_set() { return &_klass_rem_set; } coleenp@4037: duke@435: // Do any (sequential) processing necessary to prepare for (possibly duke@435: // "parallel", if that arg is true) calls to younger_refs_iterate. duke@435: virtual void prepare_for_younger_refs_iterate(bool parallel) = 0; duke@435: duke@435: // Apply the "do_oop" method of "blk" to (exactly) all oop locations duke@435: // 1) that are in objects allocated in "g" at the time of the last call duke@435: // to "save_Marks", and duke@435: // 2) that point to objects in younger generations. duke@435: virtual void younger_refs_iterate(Generation* g, OopsInGenClosure* blk) = 0; duke@435: duke@435: virtual void younger_refs_in_space_iterate(Space* sp, duke@435: OopsInGenClosure* cl) = 0; duke@435: duke@435: // This method is used to notify the remembered set that "new_val" has duke@435: // been written into "field" by the garbage collector. coleenp@548: void write_ref_field_gc(void* field, oop new_val); duke@435: protected: coleenp@548: virtual void write_ref_field_gc_work(void* field, oop new_val) = 0; duke@435: public: duke@435: duke@435: // A version of the above suitable for use by parallel collectors. coleenp@548: virtual void write_ref_field_gc_par(void* field, oop new_val) = 0; duke@435: duke@435: // Resize one of the regions covered by the remembered set. duke@435: virtual void resize_covered_region(MemRegion new_region) = 0; duke@435: duke@435: // If the rem set imposes any alignment restrictions on boundaries duke@435: // within the heap, this function tells whether they are met. duke@435: virtual bool is_aligned(HeapWord* addr) = 0; duke@435: duke@435: // If the RS (or BS) imposes an aligment constraint on maximum heap size. duke@435: // (This must be static, and dispatch on "nm", because it is called duke@435: // before an RS is created.) duke@435: static uintx max_alignment_constraint(Name nm); duke@435: duke@435: virtual void verify() = 0; duke@435: duke@435: // Verify that the remembered set has no entries for jmasa@441: // the heap interval denoted by mr. If there are any jmasa@441: // alignment constraints on the remembered set, only the jmasa@441: // part of the region that is aligned is checked. jmasa@441: // jmasa@441: // alignment boundaries jmasa@441: // +--------+-------+--------+-------+ jmasa@441: // [ region mr ) jmasa@441: // [ part checked ) jmasa@441: virtual void verify_aligned_region_empty(MemRegion mr) = 0; duke@435: duke@435: // If appropriate, print some information about the remset on "tty". duke@435: virtual void print() {} duke@435: duke@435: // Informs the RS that the given memregion contains no references to duke@435: // younger generations. duke@435: virtual void clear(MemRegion mr) = 0; duke@435: duke@435: // Informs the RS that there are no references to generations duke@435: // younger than gen from generations gen and older. duke@435: // The parameter clear_perm indicates if the perm_gen's duke@435: // remembered set should also be processed/cleared. brutisso@5519: virtual void clear_into_younger(Generation* old_gen) = 0; duke@435: duke@435: // Informs the RS that refs in the given "mr" may have changed duke@435: // arbitrarily, and therefore may contain old-to-young pointers. ysr@777: // If "whole heap" is true, then this invalidation is part of an ysr@777: // invalidation of the whole heap, which an implementation might ysr@777: // handle differently than that of a sub-part of the heap. ysr@777: virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0; duke@435: duke@435: // Informs the RS that refs in this generation duke@435: // may have changed arbitrarily, and therefore may contain brutisso@5516: // old-to-young pointers in arbitrary locations. brutisso@5519: virtual void invalidate_or_clear(Generation* old_gen) = 0; duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_MEMORY_GENREMSET_HPP