annotate src/hotspot/share/gc/shared/barrierSet.hpp @ 48073:5caa1d5f74c1

8186571: Implementation: JEP 307: Parallel Full GC for G1 Summary: Improve G1 worst-case latencies by making the full GC parallel. Reviewed-by: tschatzl, sangheki, ehelin
author sjohanss
date Tue, 14 Nov 2017 11:33:23 +0100
parents c2b7fb8e5144
children fb0275c320a0
rev   line source
duke@1 1 /*
eosterlund@47813 2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
pliden@30764 25 #ifndef SHARE_VM_GC_SHARED_BARRIERSET_HPP
pliden@30764 26 #define SHARE_VM_GC_SHARED_BARRIERSET_HPP
stefank@7397 27
stefank@7397 28 #include "memory/memRegion.hpp"
stefank@7397 29 #include "oops/oopsHierarchy.hpp"
kbarrett@29325 30 #include "utilities/fakeRttiSupport.hpp"
stefank@7397 31
duke@1 32 // This class provides the interface between a barrier implementation and
duke@1 33 // the rest of the system.
duke@1 34
zgu@13195 35 class BarrierSet: public CHeapObj<mtGC> {
duke@1 36 friend class VMStructs;
duke@1 37 public:
kbarrett@29325 38 // Fake RTTI support. For a derived class T to participate
kbarrett@29325 39 // - T must have a corresponding Name entry.
kbarrett@29325 40 // - GetName<T> must be specialized to return the corresponding Name
kbarrett@29325 41 // entry.
kbarrett@29325 42 // - If T is a base class, the constructor must have a FakeRtti
kbarrett@29325 43 // parameter and pass it up to its base class, with the tag set
kbarrett@29325 44 // augmented with the corresponding Name entry.
kbarrett@29325 45 // - If T is a concrete class, the constructor must create a
kbarrett@29325 46 // FakeRtti object whose tag set includes the corresponding Name
kbarrett@29325 47 // entry, and pass it up to its base class.
kbarrett@29325 48
kbarrett@29325 49 enum Name { // associated class
kbarrett@29325 50 ModRef, // ModRefBarrierSet
kbarrett@29325 51 CardTableModRef, // CardTableModRefBS
kbarrett@29325 52 CardTableForRS, // CardTableModRefBSForCTRS
kbarrett@29325 53 CardTableExtension, // CardTableExtension
kbarrett@29325 54 G1SATBCT, // G1SATBCardTableModRefBS
kbarrett@29325 55 G1SATBCTLogging // G1SATBCardTableLoggingModRefBS
duke@1 56 };
duke@1 57
kbarrett@29325 58 protected:
kbarrett@29325 59 typedef FakeRttiSupport<BarrierSet, Name> FakeRtti;
kbarrett@29325 60
kbarrett@29325 61 private:
kbarrett@29325 62 FakeRtti _fake_rtti;
kbarrett@29325 63
kbarrett@29325 64 // Metafunction mapping a class derived from BarrierSet to the
kbarrett@29325 65 // corresponding Name enum tag.
kbarrett@29325 66 template<typename T> struct GetName;
kbarrett@29325 67
kbarrett@29325 68 // Downcast argument to a derived barrier set type.
kbarrett@29325 69 // The cast is checked in a debug build.
kbarrett@29325 70 // T must have a specialization for BarrierSet::GetName<T>.
jwilhelm@29331 71 template<typename T> friend T* barrier_set_cast(BarrierSet* bs);
kbarrett@29325 72
kbarrett@29325 73 public:
kbarrett@29325 74 // Note: This is not presently the Name corresponding to the
kbarrett@29325 75 // concrete class of this object.
kbarrett@29325 76 BarrierSet::Name kind() const { return _fake_rtti.concrete_tag(); }
kbarrett@29325 77
kbarrett@29325 78 // Test whether this object is of the type corresponding to bsn.
kbarrett@29325 79 bool is_a(BarrierSet::Name bsn) const { return _fake_rtti.has_tag(bsn); }
kbarrett@29325 80
kbarrett@29325 81 // End of fake RTTI support.
kbarrett@29325 82
duke@1 83 protected:
kbarrett@29325 84 BarrierSet(const FakeRtti& fake_rtti) : _fake_rtti(fake_rtti) { }
jprovino@28830 85 ~BarrierSet() { }
jprovino@28830 86
duke@1 87 public:
duke@1 88 // Invoke the barrier, if any, necessary when writing "new_val" into the
duke@1 89 // ref field at "offset" in "obj".
duke@1 90 // (For efficiency reasons, this operation is specialized for certain
duke@1 91 // barrier types. Semantically, it should be thought of as a call to the
duke@1 92 // virtual "_work" function below, which must implement the barrier.)
ysr@1374 93 // First the pre-write versions...
ysr@3262 94 template <class T> inline void write_ref_field_pre(T* field, oop new_val);
kbarrett@32596 95
eosterlund@47813 96 // ...then the post-write version.
eosterlund@47813 97 inline void write_ref_field(void* field, oop new_val, bool release = false);
eosterlund@47813 98
ysr@1374 99 protected:
ysr@3262 100 virtual void write_ref_field_pre_work( oop* field, oop new_val) {};
ysr@3262 101 virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {};
eosterlund@47813 102 virtual void write_ref_field_work(void* field, oop new_val, bool release) = 0;
eosterlund@47813 103
ysr@1374 104 public:
duke@1 105 // Operations on arrays, or general regions (e.g., for "clone") may be
duke@1 106 // optimized by some barriers.
duke@1 107
ysr@4461 108 // Below length is the # array elements being written
iveresov@8498 109 virtual void write_ref_array_pre(oop* dst, int length,
iveresov@8498 110 bool dest_uninitialized = false) {}
iveresov@8498 111 virtual void write_ref_array_pre(narrowOop* dst, int length,
iveresov@8498 112 bool dest_uninitialized = false) {}
ysr@4461 113 // Below count is the # array elements being written, starting
ysr@4461 114 // at the address "start", which may not necessarily be HeapWord-aligned
ysr@4461 115 inline void write_ref_array(HeapWord* start, size_t count);
ysr@1374 116
ysr@4461 117 // Static versions, suitable for calling from generated code;
ysr@4461 118 // count is # array elements being written, starting with "start",
ysr@4461 119 // which may not necessarily be HeapWord-aligned.
ysr@1374 120 static void static_write_ref_array_pre(HeapWord* start, size_t count);
ysr@1374 121 static void static_write_ref_array_post(HeapWord* start, size_t count);
ysr@1374 122
duke@1 123 protected:
duke@1 124 virtual void write_ref_array_work(MemRegion mr) = 0;
eosterlund@47813 125
duke@1 126 public:
duke@1 127 // (For efficiency reasons, this operation is specialized for certain
duke@1 128 // barrier types. Semantically, it should be thought of as a call to the
duke@1 129 // virtual "_work" function below, which must implement the barrier.)
stefank@29081 130 void write_region(MemRegion mr);
eosterlund@47813 131
duke@1 132 protected:
duke@1 133 virtual void write_region_work(MemRegion mr) = 0;
eosterlund@47813 134
duke@1 135 public:
duke@1 136 // Inform the BarrierSet that the the covered heap region that starts
duke@1 137 // with "base" has been changed to have the given size (possibly from 0,
duke@1 138 // for initialization.)
duke@1 139 virtual void resize_covered_region(MemRegion new_region) = 0;
duke@1 140
duke@1 141 // If the barrier set imposes any alignment restrictions on boundaries
duke@1 142 // within the heap, this function tells whether they are met.
duke@1 143 virtual bool is_aligned(HeapWord* addr) = 0;
duke@1 144
never@12268 145 // Print a description of the memory for the barrier set
never@12268 146 virtual void print_on(outputStream* st) const = 0;
duke@1 147 };
stefank@7397 148
jwilhelm@29331 149 template<typename T>
jwilhelm@29331 150 inline T* barrier_set_cast(BarrierSet* bs) {
jwilhelm@29331 151 assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set");
jwilhelm@29331 152 return static_cast<T*>(bs);
jwilhelm@29331 153 }
jwilhelm@29331 154
pliden@30764 155 #endif // SHARE_VM_GC_SHARED_BARRIERSET_HPP