< prev index next >

src/share/vm/memory/heap.cpp

Print this page
rev 7793 : 8073315: Enable gcc -Wtype-limits and fix upcoming issues.


  35 
  36 // Implementation of Heap
  37 
  38 CodeHeap::CodeHeap(const char* name, const int code_blob_type)
  39   : _code_blob_type(code_blob_type) {
  40   _name                         = name;
  41   _number_of_committed_segments = 0;
  42   _number_of_reserved_segments  = 0;
  43   _segment_size                 = 0;
  44   _log2_segment_size            = 0;
  45   _next_segment                 = 0;
  46   _freelist                     = NULL;
  47   _freelist_segments            = 0;
  48   _freelist_length              = 0;
  49   _max_allocated_capacity       = 0;
  50   _was_full                     = false;
  51 }
  52 
  53 
  54 void CodeHeap::mark_segmap_as_free(size_t beg, size_t end) {
  55   assert(0   <= beg && beg <  _number_of_committed_segments, "interval begin out of bounds");
  56   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
  57   // setup _segmap pointers for faster indexing
  58   address p = (address)_segmap.low() + beg;
  59   address q = (address)_segmap.low() + end;
  60   // initialize interval
  61   while (p < q) *p++ = free_sentinel;
  62 }
  63 
  64 
  65 void CodeHeap::mark_segmap_as_used(size_t beg, size_t end) {
  66   assert(0   <= beg && beg <  _number_of_committed_segments, "interval begin out of bounds");
  67   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
  68   // setup _segmap pointers for faster indexing
  69   address p = (address)_segmap.low() + beg;
  70   address q = (address)_segmap.low() + end;
  71   // initialize interval
  72   int i = 0;
  73   while (p < q) {
  74     *p++ = i++;
  75     if (i == free_sentinel) i = 1;
  76   }
  77 }
  78 
  79 
  80 static size_t align_to_page_size(size_t size) {
  81   const size_t alignment = (size_t)os::vm_page_size();
  82   assert(is_power_of_2(alignment), "no kidding ???");
  83   return (size + alignment - 1) & ~(alignment - 1);
  84 }
  85 
  86 




  35 
  36 // Implementation of Heap
  37 
  38 CodeHeap::CodeHeap(const char* name, const int code_blob_type)
  39   : _code_blob_type(code_blob_type) {
  40   _name                         = name;
  41   _number_of_committed_segments = 0;
  42   _number_of_reserved_segments  = 0;
  43   _segment_size                 = 0;
  44   _log2_segment_size            = 0;
  45   _next_segment                 = 0;
  46   _freelist                     = NULL;
  47   _freelist_segments            = 0;
  48   _freelist_length              = 0;
  49   _max_allocated_capacity       = 0;
  50   _was_full                     = false;
  51 }
  52 
  53 
  54 void CodeHeap::mark_segmap_as_free(size_t beg, size_t end) {
  55   assert(              beg <  _number_of_committed_segments, "interval begin out of bounds");
  56   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
  57   // setup _segmap pointers for faster indexing
  58   address p = (address)_segmap.low() + beg;
  59   address q = (address)_segmap.low() + end;
  60   // initialize interval
  61   while (p < q) *p++ = free_sentinel;
  62 }
  63 
  64 
  65 void CodeHeap::mark_segmap_as_used(size_t beg, size_t end) {
  66   assert(              beg <  _number_of_committed_segments, "interval begin out of bounds");
  67   assert(beg <  end && end <= _number_of_committed_segments, "interval end   out of bounds");
  68   // setup _segmap pointers for faster indexing
  69   address p = (address)_segmap.low() + beg;
  70   address q = (address)_segmap.low() + end;
  71   // initialize interval
  72   int i = 0;
  73   while (p < q) {
  74     *p++ = i++;
  75     if (i == free_sentinel) i = 1;
  76   }
  77 }
  78 
  79 
  80 static size_t align_to_page_size(size_t size) {
  81   const size_t alignment = (size_t)os::vm_page_size();
  82   assert(is_power_of_2(alignment), "no kidding ???");
  83   return (size + alignment - 1) & ~(alignment - 1);
  84 }
  85 
  86 


< prev index next >