8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
26 #define SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
27
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/cardTableRS.hpp"
30 #include "gc/shared/generationSpec.hpp"
31 #include "memory/allocation.hpp"
32 #include "utilities/macros.hpp"
33
34 // This class (or more correctly, subtypes of this class)
35 // are used to define global garbage collector attributes.
36 // This includes initialization of generations and any other
37 // shared resources they may need.
38 //
39 // In general, all flag adjustment and validation should be
40 // done in initialize_flags(), which is called prior to
41 // initialize_size_info().
42 //
43 // This class is not fully developed yet. As more collector(s)
44 // are added, it is expected that we will come across further
45 // behavior that requires global attention. The correct place
46 // to deal with those issues is this class.
47
48 // Forward declarations.
115 void set_all_soft_refs_clear(bool v) { _all_soft_refs_clear = v; }
116
117 // Called by the GC after Soft Refs have been cleared to indicate
118 // that the request in _should_clear_all_soft_refs has been fulfilled.
119 void cleared_all_soft_refs();
120
121 // Identification methods.
122 virtual GenCollectorPolicy* as_generation_policy() { return NULL; }
123 virtual MarkSweepPolicy* as_mark_sweep_policy() { return NULL; }
124 #if INCLUDE_ALL_GCS
125 virtual ConcurrentMarkSweepPolicy* as_concurrent_mark_sweep_policy() { return NULL; }
126 #endif // INCLUDE_ALL_GCS
127 // Note that these are not virtual.
128 bool is_generation_policy() { return as_generation_policy() != NULL; }
129 bool is_mark_sweep_policy() { return as_mark_sweep_policy() != NULL; }
130 #if INCLUDE_ALL_GCS
131 bool is_concurrent_mark_sweep_policy() { return as_concurrent_mark_sweep_policy() != NULL; }
132 #else // INCLUDE_ALL_GCS
133 bool is_concurrent_mark_sweep_policy() { return false; }
134 #endif // INCLUDE_ALL_GCS
135
136
137 virtual CardTableRS* create_rem_set(MemRegion reserved);
138
139 MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
140 size_t size,
141 Metaspace::MetadataType mdtype);
142 };
143
144 class ClearedAllSoftRefs : public StackObj {
145 bool _clear_all_soft_refs;
146 CollectorPolicy* _collector_policy;
147 public:
148 ClearedAllSoftRefs(bool clear_all_soft_refs,
149 CollectorPolicy* collector_policy) :
150 _clear_all_soft_refs(clear_all_soft_refs),
151 _collector_policy(collector_policy) {}
152
153 ~ClearedAllSoftRefs() {
154 if (_clear_all_soft_refs) {
155 _collector_policy->cleared_all_soft_refs();
156 }
157 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
26 #define SHARE_VM_GC_SHARED_COLLECTORPOLICY_HPP
27
28 #include "gc/shared/cardTableRS.hpp"
29 #include "gc/shared/generationSpec.hpp"
30 #include "memory/allocation.hpp"
31 #include "utilities/macros.hpp"
32
33 // This class (or more correctly, subtypes of this class)
34 // are used to define global garbage collector attributes.
35 // This includes initialization of generations and any other
36 // shared resources they may need.
37 //
38 // In general, all flag adjustment and validation should be
39 // done in initialize_flags(), which is called prior to
40 // initialize_size_info().
41 //
42 // This class is not fully developed yet. As more collector(s)
43 // are added, it is expected that we will come across further
44 // behavior that requires global attention. The correct place
45 // to deal with those issues is this class.
46
47 // Forward declarations.
114 void set_all_soft_refs_clear(bool v) { _all_soft_refs_clear = v; }
115
116 // Called by the GC after Soft Refs have been cleared to indicate
117 // that the request in _should_clear_all_soft_refs has been fulfilled.
118 void cleared_all_soft_refs();
119
120 // Identification methods.
121 virtual GenCollectorPolicy* as_generation_policy() { return NULL; }
122 virtual MarkSweepPolicy* as_mark_sweep_policy() { return NULL; }
123 #if INCLUDE_ALL_GCS
124 virtual ConcurrentMarkSweepPolicy* as_concurrent_mark_sweep_policy() { return NULL; }
125 #endif // INCLUDE_ALL_GCS
126 // Note that these are not virtual.
127 bool is_generation_policy() { return as_generation_policy() != NULL; }
128 bool is_mark_sweep_policy() { return as_mark_sweep_policy() != NULL; }
129 #if INCLUDE_ALL_GCS
130 bool is_concurrent_mark_sweep_policy() { return as_concurrent_mark_sweep_policy() != NULL; }
131 #else // INCLUDE_ALL_GCS
132 bool is_concurrent_mark_sweep_policy() { return false; }
133 #endif // INCLUDE_ALL_GCS
134
135 MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
136 size_t size,
137 Metaspace::MetadataType mdtype);
138 };
139
140 class ClearedAllSoftRefs : public StackObj {
141 bool _clear_all_soft_refs;
142 CollectorPolicy* _collector_policy;
143 public:
144 ClearedAllSoftRefs(bool clear_all_soft_refs,
145 CollectorPolicy* collector_policy) :
146 _clear_all_soft_refs(clear_all_soft_refs),
147 _collector_policy(collector_policy) {}
148
149 ~ClearedAllSoftRefs() {
150 if (_clear_all_soft_refs) {
151 _collector_policy->cleared_all_soft_refs();
152 }
153 }
|