src/share/vm/memory/genRemSet.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/memory/genRemSet.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,153 @@
     1.4 +/*
     1.5 + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_MEMORY_GENREMSET_HPP
    1.29 +#define SHARE_VM_MEMORY_GENREMSET_HPP
    1.30 +
    1.31 +#include "oops/oop.hpp"
    1.32 +
    1.33 +// A GenRemSet provides ways of iterating over pointers accross generations.
    1.34 +// (This is especially useful for older-to-younger.)
    1.35 +
    1.36 +class Generation;
    1.37 +class BarrierSet;
    1.38 +class OopsInGenClosure;
    1.39 +class CardTableRS;
    1.40 +
    1.41 +// Helper to remember modified oops in all klasses.
    1.42 +class KlassRemSet {
    1.43 +  bool _accumulate_modified_oops;
    1.44 + public:
    1.45 +  KlassRemSet() : _accumulate_modified_oops(false) {}
    1.46 +  void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }
    1.47 +  bool accumulate_modified_oops() { return _accumulate_modified_oops; }
    1.48 +  bool mod_union_is_clear();
    1.49 +  void clear_mod_union();
    1.50 +};
    1.51 +
    1.52 +class GenRemSet: public CHeapObj<mtGC> {
    1.53 +  friend class Generation;
    1.54 +
    1.55 +  BarrierSet* _bs;
    1.56 +  KlassRemSet _klass_rem_set;
    1.57 +
    1.58 +public:
    1.59 +  enum Name {
    1.60 +    CardTable,
    1.61 +    Other
    1.62 +  };
    1.63 +
    1.64 +  GenRemSet(BarrierSet * bs) : _bs(bs) {}
    1.65 +  GenRemSet() : _bs(NULL) {}
    1.66 +
    1.67 +  virtual Name rs_kind() = 0;
    1.68 +
    1.69 +  // These are for dynamic downcasts.  Unfortunately that it names the
    1.70 +  // possible subtypes (but not that they are subtypes!)  Return NULL if
    1.71 +  // the cast is invalide.
    1.72 +  virtual CardTableRS* as_CardTableRS() { return NULL; }
    1.73 +
    1.74 +  // Return the barrier set associated with "this."
    1.75 +  BarrierSet* bs() { return _bs; }
    1.76 +
    1.77 +  // Set the barrier set.
    1.78 +  void set_bs(BarrierSet* bs) { _bs = bs; }
    1.79 +
    1.80 +  KlassRemSet* klass_rem_set() { return &_klass_rem_set; }
    1.81 +
    1.82 +  // Do any (sequential) processing necessary to prepare for (possibly
    1.83 +  // "parallel", if that arg is true) calls to younger_refs_iterate.
    1.84 +  virtual void prepare_for_younger_refs_iterate(bool parallel) = 0;
    1.85 +
    1.86 +  // Apply the "do_oop" method of "blk" to (exactly) all oop locations
    1.87 +  //  1) that are in objects allocated in "g" at the time of the last call
    1.88 +  //     to "save_Marks", and
    1.89 +  //  2) that point to objects in younger generations.
    1.90 +  virtual void younger_refs_iterate(Generation* g, OopsInGenClosure* blk) = 0;
    1.91 +
    1.92 +  virtual void younger_refs_in_space_iterate(Space* sp,
    1.93 +                                             OopsInGenClosure* cl) = 0;
    1.94 +
    1.95 +  // This method is used to notify the remembered set that "new_val" has
    1.96 +  // been written into "field" by the garbage collector.
    1.97 +  void write_ref_field_gc(void* field, oop new_val);
    1.98 +protected:
    1.99 +  virtual void write_ref_field_gc_work(void* field, oop new_val) = 0;
   1.100 +public:
   1.101 +
   1.102 +  // A version of the above suitable for use by parallel collectors.
   1.103 +  virtual void write_ref_field_gc_par(void* field, oop new_val) = 0;
   1.104 +
   1.105 +  // Resize one of the regions covered by the remembered set.
   1.106 +  virtual void resize_covered_region(MemRegion new_region) = 0;
   1.107 +
   1.108 +  // If the rem set imposes any alignment restrictions on boundaries
   1.109 +  // within the heap, this function tells whether they are met.
   1.110 +  virtual bool is_aligned(HeapWord* addr) = 0;
   1.111 +
   1.112 +  // If the RS (or BS) imposes an aligment constraint on maximum heap size.
   1.113 +  // (This must be static, and dispatch on "nm", because it is called
   1.114 +  // before an RS is created.)
   1.115 +  static uintx max_alignment_constraint(Name nm);
   1.116 +
   1.117 +  virtual void verify() = 0;
   1.118 +
   1.119 +  // Verify that the remembered set has no entries for
   1.120 +  // the heap interval denoted by mr.  If there are any
   1.121 +  // alignment constraints on the remembered set, only the
   1.122 +  // part of the region that is aligned is checked.
   1.123 +  //
   1.124 +  //   alignment boundaries
   1.125 +  //   +--------+-------+--------+-------+
   1.126 +  //         [ region mr              )
   1.127 +  //            [ part checked   )
   1.128 +  virtual void verify_aligned_region_empty(MemRegion mr) = 0;
   1.129 +
   1.130 +  // If appropriate, print some information about the remset on "tty".
   1.131 +  virtual void print() {}
   1.132 +
   1.133 +  // Informs the RS that the given memregion contains no references to
   1.134 +  // younger generations.
   1.135 +  virtual void clear(MemRegion mr) = 0;
   1.136 +
   1.137 +  // Informs the RS that there are no references to generations
   1.138 +  // younger than gen from generations gen and older.
   1.139 +  // The parameter clear_perm indicates if the perm_gen's
   1.140 +  // remembered set should also be processed/cleared.
   1.141 +  virtual void clear_into_younger(Generation* old_gen) = 0;
   1.142 +
   1.143 +  // Informs the RS that refs in the given "mr" may have changed
   1.144 +  // arbitrarily, and therefore may contain old-to-young pointers.
   1.145 +  // If "whole heap" is true, then this invalidation is part of an
   1.146 +  // invalidation of the whole heap, which an implementation might
   1.147 +  // handle differently than that of a sub-part of the heap.
   1.148 +  virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;
   1.149 +
   1.150 +  // Informs the RS that refs in this generation
   1.151 +  // may have changed arbitrarily, and therefore may contain
   1.152 +  // old-to-young pointers in arbitrary locations.
   1.153 +  virtual void invalidate_or_clear(Generation* old_gen) = 0;
   1.154 +};
   1.155 +
   1.156 +#endif // SHARE_VM_MEMORY_GENREMSET_HPP

mercurial