< prev index next >

src/hotspot/share/gc/g1/g1Allocator.cpp

Print this page
rev 57551 : imported patch 8214277-merge-open-closed-archive-map
   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  *


 395       }
 396     }
 397   }
 398   return result;
 399 }
 400 
 401 size_t G1PLABAllocator::undo_waste() const {
 402   size_t result = 0;
 403   for (region_type_t state = 0; state < G1HeapRegionAttr::Num; state++) {
 404     for (uint node_index = 0; node_index < alloc_buffers_length(state); node_index++) {
 405       PLAB* const buf = alloc_buffer(state, node_index);
 406       if (buf != NULL) {
 407         result += buf->undo_waste();
 408       }
 409     }
 410   }
 411   return result;
 412 }
 413 
 414 bool G1ArchiveAllocator::_archive_check_enabled = false;
 415 G1ArchiveRegionMap G1ArchiveAllocator::_closed_archive_region_map;
 416 G1ArchiveRegionMap G1ArchiveAllocator::_open_archive_region_map;
 417 
 418 G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) {
 419   // Create the archive allocator, and also enable archive object checking
 420   // in mark-sweep, since we will be creating archive regions.
 421   G1ArchiveAllocator* result =  new G1ArchiveAllocator(g1h, open);
 422   enable_archive_object_check();
 423   return result;
 424 }
 425 
 426 bool G1ArchiveAllocator::alloc_new_region() {
 427   // Allocate the highest free region in the reserved heap,
 428   // and add it to our list of allocated regions. It is marked
 429   // archive and added to the old set.
 430   HeapRegion* hr = _g1h->alloc_highest_free_region();
 431   if (hr == NULL) {
 432     return false;
 433   }
 434   assert(hr->is_empty(), "expected empty region (index %u)", hr->hrm_index());
 435   if (_open) {


   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  *


 395       }
 396     }
 397   }
 398   return result;
 399 }
 400 
 401 size_t G1PLABAllocator::undo_waste() const {
 402   size_t result = 0;
 403   for (region_type_t state = 0; state < G1HeapRegionAttr::Num; state++) {
 404     for (uint node_index = 0; node_index < alloc_buffers_length(state); node_index++) {
 405       PLAB* const buf = alloc_buffer(state, node_index);
 406       if (buf != NULL) {
 407         result += buf->undo_waste();
 408       }
 409     }
 410   }
 411   return result;
 412 }
 413 
 414 bool G1ArchiveAllocator::_archive_check_enabled = false;
 415 G1ArchiveRegionMap G1ArchiveAllocator::_archive_region_map;
 416 G1ArchiveRegionMap G1ArchiveAllocator::_open_archive_region_map;
 417 
 418 G1ArchiveAllocator* G1ArchiveAllocator::create_allocator(G1CollectedHeap* g1h, bool open) {
 419   // Create the archive allocator, and also enable archive object checking
 420   // in mark-sweep, since we will be creating archive regions.
 421   G1ArchiveAllocator* result =  new G1ArchiveAllocator(g1h, open);
 422   enable_archive_object_check();
 423   return result;
 424 }
 425 
 426 bool G1ArchiveAllocator::alloc_new_region() {
 427   // Allocate the highest free region in the reserved heap,
 428   // and add it to our list of allocated regions. It is marked
 429   // archive and added to the old set.
 430   HeapRegion* hr = _g1h->alloc_highest_free_region();
 431   if (hr == NULL) {
 432     return false;
 433   }
 434   assert(hr->is_empty(), "expected empty region (index %u)", hr->hrm_index());
 435   if (_open) {


< prev index next >