Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/memory/genRemSet.hpp
32285 views
/*1* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_MEMORY_GENREMSET_HPP25#define SHARE_VM_MEMORY_GENREMSET_HPP2627#include "oops/oop.hpp"2829// A GenRemSet provides ways of iterating over pointers accross generations.30// (This is especially useful for older-to-younger.)3132class Generation;33class BarrierSet;34class OopsInGenClosure;35class CardTableRS;3637// Helper to remember modified oops in all klasses.38class KlassRemSet {39bool _accumulate_modified_oops;40public:41KlassRemSet() : _accumulate_modified_oops(false) {}42void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }43bool accumulate_modified_oops() { return _accumulate_modified_oops; }44bool mod_union_is_clear();45void clear_mod_union();46};4748class GenRemSet: public CHeapObj<mtGC> {49friend class Generation;5051BarrierSet* _bs;52KlassRemSet _klass_rem_set;5354public:55enum Name {56CardTable,57Other58};5960GenRemSet(BarrierSet * bs) : _bs(bs) {}61GenRemSet() : _bs(NULL) {}6263virtual Name rs_kind() = 0;6465// These are for dynamic downcasts. Unfortunately that it names the66// possible subtypes (but not that they are subtypes!) Return NULL if67// the cast is invalide.68virtual CardTableRS* as_CardTableRS() { return NULL; }6970// Return the barrier set associated with "this."71BarrierSet* bs() { return _bs; }7273// Set the barrier set.74void set_bs(BarrierSet* bs) { _bs = bs; }7576KlassRemSet* klass_rem_set() { return &_klass_rem_set; }7778// Do any (sequential) processing necessary to prepare for (possibly79// "parallel", if that arg is true) calls to younger_refs_iterate.80virtual void prepare_for_younger_refs_iterate(bool parallel) = 0;8182// Apply the "do_oop" method of "blk" to (exactly) all oop locations83// 1) that are in objects allocated in "g" at the time of the last call84// to "save_Marks", and85// 2) that point to objects in younger generations.86virtual void younger_refs_iterate(Generation* g, OopsInGenClosure* blk) = 0;8788virtual void younger_refs_in_space_iterate(Space* sp,89OopsInGenClosure* cl) = 0;9091// This method is used to notify the remembered set that "new_val" has92// been written into "field" by the garbage collector.93void write_ref_field_gc(void* field, oop new_val);94protected:95virtual void write_ref_field_gc_work(void* field, oop new_val) = 0;96public:9798// A version of the above suitable for use by parallel collectors.99virtual void write_ref_field_gc_par(void* field, oop new_val) = 0;100101// Resize one of the regions covered by the remembered set.102virtual void resize_covered_region(MemRegion new_region) = 0;103104// If the rem set imposes any alignment restrictions on boundaries105// within the heap, this function tells whether they are met.106virtual bool is_aligned(HeapWord* addr) = 0;107108// If the RS (or BS) imposes an aligment constraint on maximum heap size.109// (This must be static, and dispatch on "nm", because it is called110// before an RS is created.)111static uintx max_alignment_constraint(Name nm);112113virtual void verify() = 0;114115// Verify that the remembered set has no entries for116// the heap interval denoted by mr. If there are any117// alignment constraints on the remembered set, only the118// part of the region that is aligned is checked.119//120// alignment boundaries121// +--------+-------+--------+-------+122// [ region mr )123// [ part checked )124virtual void verify_aligned_region_empty(MemRegion mr) = 0;125126// If appropriate, print some information about the remset on "tty".127virtual void print() {}128129// Informs the RS that the given memregion contains no references to130// younger generations.131virtual void clear(MemRegion mr) = 0;132133// Informs the RS that there are no references to generations134// younger than gen from generations gen and older.135// The parameter clear_perm indicates if the perm_gen's136// remembered set should also be processed/cleared.137virtual void clear_into_younger(Generation* old_gen) = 0;138139// Informs the RS that refs in the given "mr" may have changed140// arbitrarily, and therefore may contain old-to-young pointers.141// If "whole heap" is true, then this invalidation is part of an142// invalidation of the whole heap, which an implementation might143// handle differently than that of a sub-part of the heap.144virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;145146// Informs the RS that refs in this generation147// may have changed arbitrarily, and therefore may contain148// old-to-young pointers in arbitrary locations.149virtual void invalidate_or_clear(Generation* old_gen) = 0;150};151152#endif // SHARE_VM_MEMORY_GENREMSET_HPP153154155