src/share/vm/memory/modRefBarrierSet.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/modRefBarrierSet.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,104 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2012, 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_MODREFBARRIERSET_HPP
    1.29 +#define SHARE_VM_MEMORY_MODREFBARRIERSET_HPP
    1.30 +
    1.31 +#include "memory/barrierSet.hpp"
    1.32 +
    1.33 +// This kind of "BarrierSet" allows a "CollectedHeap" to detect and
    1.34 +// enumerate ref fields that have been modified (since the last
    1.35 +// enumeration), using a card table.
    1.36 +
    1.37 +class OopClosure;
    1.38 +class Generation;
    1.39 +
    1.40 +class ModRefBarrierSet: public BarrierSet {
    1.41 +public:
    1.42 +
    1.43 +  ModRefBarrierSet() { _kind = BarrierSet::ModRef; }
    1.44 +
    1.45 +  bool is_a(BarrierSet::Name bsn) {
    1.46 +    return bsn == BarrierSet::ModRef;
    1.47 +  }
    1.48 +
    1.49 +  // Barriers only on ref writes.
    1.50 +  bool has_read_ref_barrier() { return false; }
    1.51 +  bool has_read_prim_barrier() { return false; }
    1.52 +  bool has_write_ref_barrier() { return true; }
    1.53 +  bool has_write_prim_barrier() { return false; }
    1.54 +
    1.55 +  bool read_ref_needs_barrier(void* field) { return false; }
    1.56 +  bool read_prim_needs_barrier(HeapWord* field, size_t bytes) { return false; }
    1.57 +  bool write_prim_needs_barrier(HeapWord* field, size_t bytes,
    1.58 +                                juint val1, juint val2) { return false; }
    1.59 +
    1.60 +  void write_prim_field(oop obj, size_t offset, size_t bytes,
    1.61 +                        juint val1, juint val2) {}
    1.62 +
    1.63 +  void read_ref_field(void* field) {}
    1.64 +  void read_prim_field(HeapWord* field, size_t bytes) {}
    1.65 +protected:
    1.66 +  virtual void write_ref_field_work(void* field, oop new_val, bool release = false) = 0;
    1.67 +public:
    1.68 +  void write_prim_field(HeapWord* field, size_t bytes,
    1.69 +                        juint val1, juint val2) {}
    1.70 +
    1.71 +  bool has_read_ref_array_opt() { return false; }
    1.72 +  bool has_read_prim_array_opt() { return false; }
    1.73 +  bool has_write_prim_array_opt() { return false; }
    1.74 +
    1.75 +  bool has_read_region_opt() { return false; }
    1.76 +
    1.77 +
    1.78 +  // These operations should assert false unless the correponding operation
    1.79 +  // above returns true.
    1.80 +  void read_ref_array(MemRegion mr) {
    1.81 +    assert(false, "can't call");
    1.82 +  }
    1.83 +  void read_prim_array(MemRegion mr) {
    1.84 +    assert(false, "can't call");
    1.85 +  }
    1.86 +  void write_prim_array(MemRegion mr) {
    1.87 +    assert(false, "can't call");
    1.88 +  }
    1.89 +  void read_region(MemRegion mr) {
    1.90 +    assert(false, "can't call");
    1.91 +  }
    1.92 +
    1.93 +  // Causes all refs in "mr" to be assumed to be modified.  If "whole_heap"
    1.94 +  // is true, the caller asserts that the entire heap is being invalidated,
    1.95 +  // which may admit an optimized implementation for some barriers.
    1.96 +  virtual void invalidate(MemRegion mr, bool whole_heap = false) = 0;
    1.97 +
    1.98 +  // The caller guarantees that "mr" contains no references.  (Perhaps it's
    1.99 +  // objects have been moved elsewhere.)
   1.100 +  virtual void clear(MemRegion mr) = 0;
   1.101 +
   1.102 +  // Pass along the argument to the superclass.
   1.103 +  ModRefBarrierSet(int max_covered_regions) :
   1.104 +    BarrierSet(max_covered_regions) {}
   1.105 +};
   1.106 +
   1.107 +#endif // SHARE_VM_MEMORY_MODREFBARRIERSET_HPP

mercurial