src/share/vm/memory/cardTableModRefBS.cpp

Print this page




   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 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
  26 // enumerate ref fields that have been modified (since the last
  27 // enumeration.)
  28 
  29 # include "incls/_precompiled.incl"
  30 # include "incls/_cardTableModRefBS.cpp.incl"
  31 
  32 size_t CardTableModRefBS::cards_required(size_t covered_words)
  33 {
  34   // Add one for a guard card, used to detect errors.
  35   const size_t words = align_size_up(covered_words, card_size_in_words);
  36   return words / card_size_in_words + 1;
  37 }
  38 
  39 size_t CardTableModRefBS::compute_byte_map_size()
  40 {
  41   assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
  42                                         "unitialized, check declaration order");
  43   assert(_page_size != 0, "unitialized, check declaration order");
  44   const size_t granularity = os::vm_allocation_granularity();
  45   return align_size_up(_guard_index + 1, MAX2(_page_size, granularity));
  46 }
  47 
  48 CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap,
  49                                      int max_covered_regions):
  50   ModRefBarrierSet(max_covered_regions),
  51   _whole_heap(whole_heap),




   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 #include "memory/allocation.inline.hpp"
  27 #include "memory/cardTableModRefBS.hpp"
  28 #include "memory/cardTableRS.hpp"
  29 #include "memory/sharedHeap.hpp"
  30 #include "memory/space.hpp"
  31 #include "memory/space.inline.hpp"
  32 #include "memory/universe.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/mutexLocker.hpp"
  35 #include "runtime/virtualspace.hpp"
  36 #ifdef COMPILER1
  37 #include "c1/c1_LIR.hpp"
  38 #include "c1/c1_LIRGenerator.hpp"
  39 #endif
  40 
  41 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
  42 // enumerate ref fields that have been modified (since the last
  43 // enumeration.)
  44 



  45 size_t CardTableModRefBS::cards_required(size_t covered_words)
  46 {
  47   // Add one for a guard card, used to detect errors.
  48   const size_t words = align_size_up(covered_words, card_size_in_words);
  49   return words / card_size_in_words + 1;
  50 }
  51 
  52 size_t CardTableModRefBS::compute_byte_map_size()
  53 {
  54   assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
  55                                         "unitialized, check declaration order");
  56   assert(_page_size != 0, "unitialized, check declaration order");
  57   const size_t granularity = os::vm_allocation_granularity();
  58   return align_size_up(_guard_index + 1, MAX2(_page_size, granularity));
  59 }
  60 
  61 CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap,
  62                                      int max_covered_regions):
  63   ModRefBarrierSet(max_covered_regions),
  64   _whole_heap(whole_heap),