< prev index next >

src/hotspot/share/gc/shared/cardGeneration.cpp

Print this page
rev 47957 : 8191564: Refactor GC related servicability code into GC specific subclasses
   1 /*
   2  * Copyright (c) 2014, 2016, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shared/blockOffsetTable.inline.hpp"
  28 #include "gc/shared/cardGeneration.inline.hpp"
  29 #include "gc/shared/cardTableRS.hpp"
  30 #include "gc/shared/gcLocker.hpp"
  31 #include "gc/shared/genOopClosures.inline.hpp"
  32 #include "gc/shared/generationSpec.hpp"
  33 #include "gc/shared/space.inline.hpp"
  34 #include "memory/iterator.hpp"
  35 #include "memory/memRegion.hpp"
  36 #include "logging/log.hpp"
  37 #include "runtime/java.hpp"
  38 
  39 CardGeneration::CardGeneration(ReservedSpace rs,
  40                                size_t initial_byte_size,

  41                                CardTableRS* remset) :
  42   Generation(rs, initial_byte_size), _rs(remset),
  43   _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
  44   _used_at_prologue()
  45 {
  46   HeapWord* start = (HeapWord*)rs.base();
  47   size_t reserved_byte_size = rs.size();
  48   assert((uintptr_t(start) & 3) == 0, "bad alignment");
  49   assert((reserved_byte_size & 3) == 0, "bad alignment");
  50   MemRegion reserved_mr(start, heap_word_size(reserved_byte_size));
  51   _bts = new BlockOffsetSharedArray(reserved_mr,
  52                                     heap_word_size(initial_byte_size));
  53   MemRegion committed_mr(start, heap_word_size(initial_byte_size));
  54   _rs->resize_covered_region(committed_mr);
  55   if (_bts == NULL) {
  56     vm_exit_during_initialization("Could not allocate a BlockOffsetArray");
  57   }
  58 
  59   // Verify that the start and end of this generation is the start of a card.
  60   // If this wasn't true, a single card could span more than on generation,
  61   // which would cause problems when we commit/uncommit memory, and when we
  62   // clear and dirty cards.


   1 /*
   2  * Copyright (c) 2014, 2017, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shared/blockOffsetTable.inline.hpp"
  28 #include "gc/shared/cardGeneration.inline.hpp"
  29 #include "gc/shared/cardTableRS.hpp"
  30 #include "gc/shared/gcLocker.hpp"
  31 #include "gc/shared/genOopClosures.inline.hpp"
  32 #include "gc/shared/generationSpec.hpp"
  33 #include "gc/shared/space.inline.hpp"
  34 #include "memory/iterator.hpp"
  35 #include "memory/memRegion.hpp"
  36 #include "logging/log.hpp"
  37 #include "runtime/java.hpp"
  38 
  39 CardGeneration::CardGeneration(ReservedSpace rs,
  40                                size_t initial_byte_size,
  41                                GCMemoryManager* mem_mgr,
  42                                CardTableRS* remset) :
  43   Generation(rs, initial_byte_size, mem_mgr), _rs(remset),
  44   _shrink_factor(0), _min_heap_delta_bytes(), _capacity_at_prologue(),
  45   _used_at_prologue()
  46 {
  47   HeapWord* start = (HeapWord*)rs.base();
  48   size_t reserved_byte_size = rs.size();
  49   assert((uintptr_t(start) & 3) == 0, "bad alignment");
  50   assert((reserved_byte_size & 3) == 0, "bad alignment");
  51   MemRegion reserved_mr(start, heap_word_size(reserved_byte_size));
  52   _bts = new BlockOffsetSharedArray(reserved_mr,
  53                                     heap_word_size(initial_byte_size));
  54   MemRegion committed_mr(start, heap_word_size(initial_byte_size));
  55   _rs->resize_covered_region(committed_mr);
  56   if (_bts == NULL) {
  57     vm_exit_during_initialization("Could not allocate a BlockOffsetArray");
  58   }
  59 
  60   // Verify that the start and end of this generation is the start of a card.
  61   // If this wasn't true, a single card could span more than on generation,
  62   // which would cause problems when we commit/uncommit memory, and when we
  63   // clear and dirty cards.


< prev index next >