src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp

Print this page




  37 #endif
  38 #ifdef TARGET_OS_FAMILY_windows
  39 # include "os_windows.inline.hpp"
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_bsd
  42 # include "os_bsd.inline.hpp"
  43 #endif
  44 
  45 bool
  46 ParMarkBitMap::initialize(MemRegion covered_region)
  47 {
  48   const idx_t bits = bits_required(covered_region);
  49   // The bits will be divided evenly between two bitmaps; each of them should be
  50   // an integral number of words.
  51   assert(bits % (BitsPerWord * 2) == 0, "region size unaligned");
  52 
  53   const size_t words = bits / BitsPerWord;
  54   const size_t raw_bytes = words * sizeof(idx_t);
  55   const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
  56   const size_t granularity = os::vm_allocation_granularity();
  57   const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
  58 
  59   const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
  60     MAX2(page_sz, granularity);
  61   ReservedSpace rs(bytes, rs_align, rs_align > 0);
  62   os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
  63                        rs.base(), rs.size());
  64 
  65   MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
  66 
  67   _virtual_space = new PSVirtualSpace(rs, page_sz);
  68   if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) {
  69     _region_start = covered_region.start();
  70     _region_size = covered_region.word_size();
  71     idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
  72     _beg_bits.set_map(map);
  73     _beg_bits.set_size(bits / 2);
  74     _end_bits.set_map(map + words / 2);
  75     _end_bits.set_size(bits / 2);
  76     return true;
  77   }
  78 
  79   _region_start = 0;
  80   _region_size = 0;
  81   if (_virtual_space != NULL) {
  82     delete _virtual_space;
  83     _virtual_space = NULL;
  84     // Release memory reserved in the space.
  85     rs.release();
  86   }
  87   return false;
  88 }




  37 #endif
  38 #ifdef TARGET_OS_FAMILY_windows
  39 # include "os_windows.inline.hpp"
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_bsd
  42 # include "os_bsd.inline.hpp"
  43 #endif
  44 
  45 bool
  46 ParMarkBitMap::initialize(MemRegion covered_region)
  47 {
  48   const idx_t bits = bits_required(covered_region);
  49   // The bits will be divided evenly between two bitmaps; each of them should be
  50   // an integral number of words.
  51   assert(bits % (BitsPerWord * 2) == 0, "region size unaligned");
  52 
  53   const size_t words = bits / BitsPerWord;
  54   const size_t raw_bytes = words * sizeof(idx_t);
  55   const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
  56   const size_t granularity = os::vm_allocation_granularity();
  57   _reserved_byte_size = align_size_up(raw_bytes, MAX2(page_sz, granularity));
  58 
  59   const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
  60     MAX2(page_sz, granularity);
  61   ReservedSpace rs(_reserved_byte_size, rs_align, rs_align > 0);
  62   os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
  63                        rs.base(), rs.size());
  64 
  65   MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
  66 
  67   _virtual_space = new PSVirtualSpace(rs, page_sz);
  68   if (_virtual_space != NULL && _virtual_space->expand_by(_reserved_byte_size)) {
  69     _region_start = covered_region.start();
  70     _region_size = covered_region.word_size();
  71     idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
  72     _beg_bits.set_map(map);
  73     _beg_bits.set_size(bits / 2);
  74     _end_bits.set_map(map + words / 2);
  75     _end_bits.set_size(bits / 2);
  76     return true;
  77   }
  78 
  79   _region_start = 0;
  80   _region_size = 0;
  81   if (_virtual_space != NULL) {
  82     delete _virtual_space;
  83     _virtual_space = NULL;
  84     // Release memory reserved in the space.
  85     rs.release();
  86   }
  87   return false;
  88 }