< prev index next >

src/hotspot/share/gc/g1/g1Allocator.inline.hpp

Print this page
rev 57551 : imported patch 8214277-merge-open-closed-archive-map
   1 /*
   2  * Copyright (c) 2015, 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  *


 114 
 115 inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
 116                                            size_t word_sz,
 117                                            bool* refill_failed,
 118                                            uint node_index) {
 119   HeapWord* const obj = plab_allocate(dest, word_sz, node_index);
 120   if (obj != NULL) {
 121     return obj;
 122   }
 123   return allocate_direct_or_new_plab(dest, word_sz, refill_failed, node_index);
 124 }
 125 
 126 // Create the maps which is used to identify archive objects.
 127 inline void G1ArchiveAllocator::enable_archive_object_check() {
 128   if (_archive_check_enabled) {
 129     return;
 130   }
 131 
 132   _archive_check_enabled = true;
 133   size_t length = G1CollectedHeap::heap()->max_reserved_capacity();
 134   _closed_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
 135                                         G1CollectedHeap::heap()->base() + length,
 136                                         HeapRegion::GrainBytes);
 137   _open_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
 138                                       G1CollectedHeap::heap()->base() + length,
 139                                       HeapRegion::GrainBytes);
 140 }
 141 
 142 // Set the regions containing the specified address range as archive.
 143 inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool open) {
 144   assert(_archive_check_enabled, "archive range check not enabled");
 145   log_info(gc, cds)("Mark %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
 146                      open ? "open" : "closed",
 147                      p2i(range.start()),
 148                      p2i(range.last()));
 149   if (open) {
 150     _open_archive_region_map.set_by_address(range, true);
 151   } else {
 152     _closed_archive_region_map.set_by_address(range, true);
 153   }
 154 }
 155 
 156 // Clear the archive regions map containing the specified address range.
 157 inline void G1ArchiveAllocator::clear_range_archive(MemRegion range, bool open) {
 158   assert(_archive_check_enabled, "archive range check not enabled");
 159   log_info(gc, cds)("Clear %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
 160                     open ? "open" : "closed",
 161                     p2i(range.start()),
 162                     p2i(range.last()));
 163   if (open) {
 164     _open_archive_region_map.set_by_address(range, false);
 165   } else {
 166     _closed_archive_region_map.set_by_address(range, false);
 167   }
 168 }
 169 
 170 // Check if an object is in a closed archive region using the _archive_region_map.
 171 inline bool G1ArchiveAllocator::in_closed_archive_range(oop object) {
 172   // This is the out-of-line part of is_closed_archive_object test, done separately
 173   // to avoid additional performance impact when the check is not enabled.
 174   return _closed_archive_region_map.get_by_address((HeapWord*)object);
 175 }
 176 
 177 inline bool G1ArchiveAllocator::in_open_archive_range(oop object) {
 178   return _open_archive_region_map.get_by_address((HeapWord*)object);
 179 }
 180 
 181 // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
 182 // unnecessarily.
 183 inline bool G1ArchiveAllocator::archive_check_enabled() {
 184   return _archive_check_enabled;
 185 }
 186 
 187 inline bool G1ArchiveAllocator::is_closed_archive_object(oop object) {
 188   return (archive_check_enabled() && in_closed_archive_range(object));
 189 }
 190 
 191 inline bool G1ArchiveAllocator::is_open_archive_object(oop object) {
 192   return (archive_check_enabled() && in_open_archive_range(object));
 193 }
 194 
 195 inline bool G1ArchiveAllocator::is_archived_object(oop object) {
 196   return (archive_check_enabled() && (in_closed_archive_range(object) ||
 197                                       in_open_archive_range(object)));
 198 }
 199 
 200 #endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
   1 /*
   2  * Copyright (c) 2015, 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  *


 114 
 115 inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
 116                                            size_t word_sz,
 117                                            bool* refill_failed,
 118                                            uint node_index) {
 119   HeapWord* const obj = plab_allocate(dest, word_sz, node_index);
 120   if (obj != NULL) {
 121     return obj;
 122   }
 123   return allocate_direct_or_new_plab(dest, word_sz, refill_failed, node_index);
 124 }
 125 
 126 // Create the maps which is used to identify archive objects.
 127 inline void G1ArchiveAllocator::enable_archive_object_check() {
 128   if (_archive_check_enabled) {
 129     return;
 130   }
 131 
 132   _archive_check_enabled = true;
 133   size_t length = G1CollectedHeap::heap()->max_reserved_capacity();
 134   _archive_region_map.initialize(G1CollectedHeap::heap()->base(),



 135                                  G1CollectedHeap::heap()->base() + length,
 136                                  HeapRegion::GrainBytes);
 137 }
 138 
 139 // Set the regions containing the specified address range as archive.
 140 inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool open) {
 141   assert(_archive_check_enabled, "archive range check not enabled");
 142   log_info(gc, cds)("Mark %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
 143                      open ? "open" : "closed",
 144                      p2i(range.start()),
 145                      p2i(range.last()));
 146   uint8_t const value = open ? G1ArchiveRegionMap::OpenArchive : G1ArchiveRegionMap::ClosedArchive;
 147   _archive_region_map.set_by_address(range, value);



 148 }
 149 
 150 // Clear the archive regions map containing the specified address range.
 151 inline void G1ArchiveAllocator::clear_range_archive(MemRegion range, bool open) {
 152   assert(_archive_check_enabled, "archive range check not enabled");
 153   log_info(gc, cds)("Clear %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
 154                     open ? "open" : "closed",
 155                     p2i(range.start()),
 156                     p2i(range.last()));
 157   _archive_region_map.set_by_address(range, G1ArchiveRegionMap::NoArchive);




 158 }
 159 
 160 // Check if an object is in a closed archive region using the _archive_region_map.
 161 inline bool G1ArchiveAllocator::in_closed_archive_range(oop object) {
 162   // This is the out-of-line part of is_closed_archive_object test, done separately
 163   // to avoid additional performance impact when the check is not enabled.
 164   return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::ClosedArchive;
 165 }
 166 
 167 inline bool G1ArchiveAllocator::in_open_archive_range(oop object) {
 168   return _archive_region_map.get_by_address((HeapWord*)object) == G1ArchiveRegionMap::OpenArchive;
 169 }
 170 
 171 // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
 172 // unnecessarily.
 173 inline bool G1ArchiveAllocator::archive_check_enabled() {
 174   return _archive_check_enabled;
 175 }
 176 
 177 inline bool G1ArchiveAllocator::is_closed_archive_object(oop object) {
 178   return (archive_check_enabled() && in_closed_archive_range(object));
 179 }
 180 
 181 inline bool G1ArchiveAllocator::is_open_archive_object(oop object) {
 182   return (archive_check_enabled() && in_open_archive_range(object));
 183 }
 184 
 185 inline bool G1ArchiveAllocator::is_archived_object(oop object) {
 186   return (archive_check_enabled() &&
 187          (_archive_region_map.get_by_address((HeapWord*)object) != G1ArchiveRegionMap::NoArchive));
 188 }
 189 
 190 #endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
< prev index next >