1 /*
2 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
186 // PLAB failed or not.
187 HeapWord* allocate_direct_or_new_plab(G1HeapRegionAttr dest,
188 size_t word_sz,
189 bool* plab_refill_failed,
190 uint node_index);
191
192 // Allocate word_sz words in the PLAB of dest. Returns the address of the
193 // allocated memory, NULL if not successful.
194 inline HeapWord* plab_allocate(G1HeapRegionAttr dest,
195 size_t word_sz,
196 uint node_index);
197
198 inline HeapWord* allocate(G1HeapRegionAttr dest,
199 size_t word_sz,
200 bool* refill_failed,
201 uint node_index);
202
203 void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index);
204 };
205
206 // G1ArchiveRegionMap is a boolean array used to mark G1 regions as
207 // archive regions. This allows a quick check for whether an object
208 // should not be marked because it is in an archive region.
209 class G1ArchiveRegionMap : public G1BiasedMappedArray<bool> {
210 protected:
211 bool default_value() const { return false; }
212 };
213
214 // G1ArchiveAllocator is used to allocate memory in archive
215 // regions. Such regions are not scavenged nor compacted by GC.
216 // There are two types of archive regions, which are
217 // differ in the kind of references allowed for the contained objects:
218 //
219 // - 'Closed' archive region contain no references outside of other
220 // closed archive regions. The region is immutable by GC. GC does
221 // not mark object header in 'closed' archive region.
222 // - An 'open' archive region allow references to any other regions,
223 // including closed archive, open archive and other java heap regions.
224 // GC can adjust pointers and mark object header in 'open' archive region.
225 class G1ArchiveAllocator : public CHeapObj<mtGC> {
226 protected:
227 bool _open; // Indicate if the region is 'open' archive.
228 G1CollectedHeap* _g1h;
229
230 // The current allocation region
231 HeapRegion* _allocation_region;
284 void clear_used() {
285 _summary_bytes_used = 0;
286 }
287
288 // Create the _archive_region_map which is used to identify archive objects.
289 static inline void enable_archive_object_check();
290
291 // Mark regions containing the specified address range as archive/non-archive.
292 static inline void set_range_archive(MemRegion range, bool open);
293 static inline void clear_range_archive(MemRegion range, bool open);
294
295 // Check if the object is in closed archive
296 static inline bool is_closed_archive_object(oop object);
297 // Check if the object is in open archive
298 static inline bool is_open_archive_object(oop object);
299 // Check if the object is either in closed archive or open archive
300 static inline bool is_archived_object(oop object);
301
302 private:
303 static bool _archive_check_enabled;
304 static G1ArchiveRegionMap _closed_archive_region_map;
305 static G1ArchiveRegionMap _open_archive_region_map;
306
307 // Check if an object is in a closed archive region using the _closed_archive_region_map.
308 static inline bool in_closed_archive_range(oop object);
309 // Check if an object is in open archive region using the _open_archive_region_map.
310 static inline bool in_open_archive_range(oop object);
311
312 // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
313 // unnecessarily.
314 static inline bool archive_check_enabled();
315 };
316
317 #endif // SHARE_GC_G1_G1ALLOCATOR_HPP
|
1 /*
2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 *
186 // PLAB failed or not.
187 HeapWord* allocate_direct_or_new_plab(G1HeapRegionAttr dest,
188 size_t word_sz,
189 bool* plab_refill_failed,
190 uint node_index);
191
192 // Allocate word_sz words in the PLAB of dest. Returns the address of the
193 // allocated memory, NULL if not successful.
194 inline HeapWord* plab_allocate(G1HeapRegionAttr dest,
195 size_t word_sz,
196 uint node_index);
197
198 inline HeapWord* allocate(G1HeapRegionAttr dest,
199 size_t word_sz,
200 bool* refill_failed,
201 uint node_index);
202
203 void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index);
204 };
205
206 // G1ArchiveRegionMap is an array used to mark G1 regions as
207 // archive regions. This allows a quick check for whether an object
208 // should not be marked because it is in an archive region.
209 class G1ArchiveRegionMap : public G1BiasedMappedArray<uint8_t> {
210 public:
211 static const uint8_t NoArchive = 0;
212 static const uint8_t OpenArchive = 1;
213 static const uint8_t ClosedArchive = 2;
214
215 protected:
216 uint8_t default_value() const { return NoArchive; }
217 };
218
219 // G1ArchiveAllocator is used to allocate memory in archive
220 // regions. Such regions are not scavenged nor compacted by GC.
221 // There are two types of archive regions, which are
222 // differ in the kind of references allowed for the contained objects:
223 //
224 // - 'Closed' archive region contain no references outside of other
225 // closed archive regions. The region is immutable by GC. GC does
226 // not mark object header in 'closed' archive region.
227 // - An 'open' archive region allow references to any other regions,
228 // including closed archive, open archive and other java heap regions.
229 // GC can adjust pointers and mark object header in 'open' archive region.
230 class G1ArchiveAllocator : public CHeapObj<mtGC> {
231 protected:
232 bool _open; // Indicate if the region is 'open' archive.
233 G1CollectedHeap* _g1h;
234
235 // The current allocation region
236 HeapRegion* _allocation_region;
289 void clear_used() {
290 _summary_bytes_used = 0;
291 }
292
293 // Create the _archive_region_map which is used to identify archive objects.
294 static inline void enable_archive_object_check();
295
296 // Mark regions containing the specified address range as archive/non-archive.
297 static inline void set_range_archive(MemRegion range, bool open);
298 static inline void clear_range_archive(MemRegion range, bool open);
299
300 // Check if the object is in closed archive
301 static inline bool is_closed_archive_object(oop object);
302 // Check if the object is in open archive
303 static inline bool is_open_archive_object(oop object);
304 // Check if the object is either in closed archive or open archive
305 static inline bool is_archived_object(oop object);
306
307 private:
308 static bool _archive_check_enabled;
309 static G1ArchiveRegionMap _archive_region_map;
310 static G1ArchiveRegionMap _open_archive_region_map;
311
312 // Check if an object is in a closed archive region using the _closed_archive_region_map.
313 static inline bool in_closed_archive_range(oop object);
314 // Check if an object is in open archive region using the _open_archive_region_map.
315 static inline bool in_open_archive_range(oop object);
316
317 // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
318 // unnecessarily.
319 static inline bool archive_check_enabled();
320 };
321
322 #endif // SHARE_GC_G1_G1ALLOCATOR_HPP
|