annotate src/hotspot/share/gc/shared/collectorPolicy.hpp @ 52321:31b159f30fb2

8180193: Make marking bitmap code available to other GCs Reviewed-by: shade, stefank
author rkennke
date Wed, 29 Aug 2018 20:15:09 +0200
parents 170c7b36aea6
children 9807daeb47c4
rev   line source
duke@1 1 /*
pliden@49452 2 * Copyright (c) 2001, 2018, 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_COLLECTORPOLICY_HPP
pliden@30764 26 #define SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
stefank@7397 27
pliden@30764 28 #include "gc/shared/barrierSet.hpp"
david@33212 29 #include "gc/shared/cardTableRS.hpp"
pliden@30764 30 #include "gc/shared/generationSpec.hpp"
coleenp@13728 31 #include "memory/allocation.hpp"
jprovino@15482 32 #include "utilities/macros.hpp"
stefank@7397 33
duke@1 34 // This class (or more correctly, subtypes of this class)
duke@1 35 // are used to define global garbage collector attributes.
duke@1 36 // This includes initialization of generations and any other
duke@1 37 // shared resources they may need.
duke@1 38 //
duke@1 39 // In general, all flag adjustment and validation should be
duke@1 40 // done in initialize_flags(), which is called prior to
duke@1 41 // initialize_size_info().
duke@1 42 //
duke@1 43 // This class is not fully developed yet. As more collector(s)
duke@1 44 // are added, it is expected that we will come across further
duke@1 45 // behavior that requires global attention. The correct place
duke@1 46 // to deal with those issues is this class.
duke@1 47
duke@1 48 // Forward declarations.
duke@1 49 class GenCollectorPolicy;
ysr@1374 50 class AdaptiveSizePolicy;
duke@1 51 class ConcurrentMarkSweepPolicy;
ysr@1374 52 class G1CollectorPolicy;
duke@1 53 class MarkSweepPolicy;
duke@1 54
zgu@13195 55 class CollectorPolicy : public CHeapObj<mtGC> {
duke@1 56 protected:
jwilhelm@21561 57 virtual void initialize_alignments() = 0;
duke@1 58 virtual void initialize_flags();
ysr@1374 59 virtual void initialize_size_info();
duke@1 60
jwilhelm@21561 61 DEBUG_ONLY(virtual void assert_flags();)
jwilhelm@21561 62 DEBUG_ONLY(virtual void assert_size_info();)
jwilhelm@21561 63
duke@1 64 size_t _initial_heap_byte_size;
duke@1 65 size_t _max_heap_byte_size;
duke@1 66 size_t _min_heap_byte_size;
duke@1 67
jwilhelm@21561 68 size_t _space_alignment;
jwilhelm@21561 69 size_t _heap_alignment;
jwilhelm@21561 70
jwilhelm@21561 71 CollectorPolicy();
duke@1 72
duke@1 73 public:
stefank@49480 74 void initialize_all() {
jwilhelm@21561 75 initialize_alignments();
jwilhelm@21561 76 initialize_flags();
jwilhelm@21561 77 initialize_size_info();
jwilhelm@21561 78 }
jwilhelm@21561 79
jwilhelm@22551 80 // Return maximum heap alignment that may be imposed by the policy.
jwilhelm@21561 81 static size_t compute_heap_alignment();
tschatzl@19986 82
jwilhelm@21561 83 size_t space_alignment() { return _space_alignment; }
jwilhelm@21561 84 size_t heap_alignment() { return _heap_alignment; }
duke@1 85
duke@1 86 size_t initial_heap_byte_size() { return _initial_heap_byte_size; }
duke@1 87 size_t max_heap_byte_size() { return _max_heap_byte_size; }
duke@1 88 size_t min_heap_byte_size() { return _min_heap_byte_size; }
jmasa@5343 89 };
jmasa@5343 90
duke@1 91 class GenCollectorPolicy : public CollectorPolicy {
jwilhelm@29794 92 friend class TestGenCollectorPolicy;
jwilhelm@29794 93 friend class VMStructs;
rkennke@46657 94
rkennke@46657 95 protected:
jwilhelm@24941 96 size_t _min_young_size;
jwilhelm@24941 97 size_t _initial_young_size;
jwilhelm@24941 98 size_t _max_young_size;
jwilhelm@24941 99 size_t _min_old_size;
jwilhelm@24941 100 size_t _initial_old_size;
jwilhelm@24941 101 size_t _max_old_size;
duke@1 102
jwilhelm@21561 103 // _gen_alignment and _space_alignment will have the same value most of the
jwilhelm@21561 104 // time. When using large pages they can differ.
jwilhelm@21561 105 size_t _gen_alignment;
jwilhelm@21561 106
duke@1 107 void initialize_flags();
duke@1 108 void initialize_size_info();
duke@1 109
jwilhelm@21561 110 DEBUG_ONLY(void assert_flags();)
jwilhelm@21561 111 DEBUG_ONLY(void assert_size_info();)
jwilhelm@21561 112
jwilhelm@22551 113 // Compute max heap alignment.
jwilhelm@21561 114 size_t compute_max_alignment();
jwilhelm@21561 115
sjohanss@23851 116 // Scale the base_size by NewRatio according to
sjohanss@23851 117 // result = base_size / (NewRatio + 1)
sjohanss@23851 118 // and align by min_alignment()
sjohanss@23851 119 size_t scale_by_NewRatio_aligned(size_t base_size);
jmasa@186 120
sjohanss@23851 121 // Bound the value by the given maximum minus the min_alignment.
sjohanss@23851 122 size_t bound_minus_alignment(size_t desired_size, size_t maximum_size);
duke@1 123
duke@1 124 public:
jwilhelm@21561 125 GenCollectorPolicy();
jwilhelm@21561 126
jmasa@186 127 // Accessors
jwilhelm@24941 128 size_t min_young_size() { return _min_young_size; }
jwilhelm@24941 129 size_t initial_young_size() { return _initial_young_size; }
jwilhelm@24941 130 size_t max_young_size() { return _max_young_size; }
jwilhelm@24941 131 size_t gen_alignment() { return _gen_alignment; }
jwilhelm@24941 132 size_t min_old_size() { return _min_old_size; }
jwilhelm@24941 133 size_t initial_old_size() { return _initial_old_size; }
jwilhelm@24941 134 size_t max_old_size() { return _max_old_size; }
jmasa@186 135
jwilhelm@21561 136 size_t young_gen_size_lower_bound();
jwilhelm@21561 137
david@32362 138 size_t old_gen_size_lower_bound();
duke@1 139 };
duke@1 140
jwilhelm@24353 141 class MarkSweepPolicy : public GenCollectorPolicy {
duke@1 142 protected:
jwilhelm@21561 143 void initialize_alignments();
duke@1 144
duke@1 145 public:
jwilhelm@21561 146 MarkSweepPolicy() {}
duke@1 147 };
stefank@7397 148
pliden@30764 149 #endif // SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP