< prev index next >

src/share/vm/gc/g1/g1CollectedHeap.inline.hpp

Print this page




  50 size_t G1CollectedHeap::desired_plab_sz(InCSetState dest) {
  51   size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz(G1CollectedHeap::heap()->workers()->active_workers());
  52   // Prevent humongous PLAB sizes for two reasons:
  53   // * PLABs are allocated using a similar paths as oops, but should
  54   //   never be in a humongous region
  55   // * Allowing humongous PLABs needlessly churns the region free lists
  56   return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
  57 }
  58 
  59 // Inline functions for G1CollectedHeap
  60 
  61 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
  62   return _allocation_context_stats;
  63 }
  64 
  65 // Return the region with the given index. It assumes the index is valid.
  66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
  67 
  68 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  69   assert(is_in_reserved(addr),
  70          err_msg("Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
  71                  p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end())));
  72   return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  73 }
  74 
  75 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  76   return _hrm.reserved().start() + index * HeapRegion::GrainWords;
  77 }
  78 
  79 template <class T>
  80 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const {
  81   assert(addr != NULL, "invariant");
  82   assert(is_in_g1_reserved((const void*) addr),
  83       err_msg("Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
  84           p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end())));
  85   return _hrm.addr_to_region((HeapWord*) addr);
  86 }
  87 
  88 template <class T>
  89 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  90   HeapRegion* hr = heap_region_containing_raw(addr);
  91   if (hr->is_continues_humongous()) {
  92     return hr->humongous_start_region();
  93   }
  94   return hr;
  95 }
  96 
  97 inline void G1CollectedHeap::reset_gc_time_stamp() {
  98   _gc_time_stamp = 0;
  99   OrderAccess::fence();
 100   // Clear the cached CSet starting regions and time stamps.
 101   // Their validity is dependent on the GC timestamp.
 102   clear_cset_start_regions();
 103 }
 104 




  50 size_t G1CollectedHeap::desired_plab_sz(InCSetState dest) {
  51   size_t gclab_word_size = alloc_buffer_stats(dest)->desired_plab_sz(G1CollectedHeap::heap()->workers()->active_workers());
  52   // Prevent humongous PLAB sizes for two reasons:
  53   // * PLABs are allocated using a similar paths as oops, but should
  54   //   never be in a humongous region
  55   // * Allowing humongous PLABs needlessly churns the region free lists
  56   return MIN2(_humongous_object_threshold_in_words, gclab_word_size);
  57 }
  58 
  59 // Inline functions for G1CollectedHeap
  60 
  61 inline AllocationContextStats& G1CollectedHeap::allocation_context_stats() {
  62   return _allocation_context_stats;
  63 }
  64 
  65 // Return the region with the given index. It assumes the index is valid.
  66 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrm.at(index); }
  67 
  68 inline uint G1CollectedHeap::addr_to_region(HeapWord* addr) const {
  69   assert(is_in_reserved(addr),
  70          "Cannot calculate region index for address " PTR_FORMAT " that is outside of the heap [" PTR_FORMAT ", " PTR_FORMAT ")",
  71          p2i(addr), p2i(reserved_region().start()), p2i(reserved_region().end()));
  72   return (uint)(pointer_delta(addr, reserved_region().start(), sizeof(uint8_t)) >> HeapRegion::LogOfHRGrainBytes);
  73 }
  74 
  75 inline HeapWord* G1CollectedHeap::bottom_addr_for_region(uint index) const {
  76   return _hrm.reserved().start() + index * HeapRegion::GrainWords;
  77 }
  78 
  79 template <class T>
  80 inline HeapRegion* G1CollectedHeap::heap_region_containing_raw(const T addr) const {
  81   assert(addr != NULL, "invariant");
  82   assert(is_in_g1_reserved((const void*) addr),
  83          "Address " PTR_FORMAT " is outside of the heap ranging from [" PTR_FORMAT " to " PTR_FORMAT ")",
  84          p2i((void*)addr), p2i(g1_reserved().start()), p2i(g1_reserved().end()));
  85   return _hrm.addr_to_region((HeapWord*) addr);
  86 }
  87 
  88 template <class T>
  89 inline HeapRegion* G1CollectedHeap::heap_region_containing(const T addr) const {
  90   HeapRegion* hr = heap_region_containing_raw(addr);
  91   if (hr->is_continues_humongous()) {
  92     return hr->humongous_start_region();
  93   }
  94   return hr;
  95 }
  96 
  97 inline void G1CollectedHeap::reset_gc_time_stamp() {
  98   _gc_time_stamp = 0;
  99   OrderAccess::fence();
 100   // Clear the cached CSet starting regions and time stamps.
 101   // Their validity is dependent on the GC timestamp.
 102   clear_cset_start_regions();
 103 }
 104 


< prev index next >