< prev index next >

src/hotspot/share/gc/g1/g1Allocator.inline.hpp

Print this page
rev 56323 : imported patch 8220310.mut.0


  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 #ifndef SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
  26 #define SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
  27 
  28 #include "gc/g1/g1Allocator.hpp"
  29 #include "gc/g1/g1AllocRegion.inline.hpp"
  30 #include "gc/shared/plab.inline.hpp"
  31 #include "memory/universe.hpp"
  32 
  33 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region() {
  34   return &_mutator_alloc_region;

  35 }
  36 
  37 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() {
  38   return &_survivor_gc_alloc_region;
  39 }
  40 
  41 inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
  42   return &_old_gc_alloc_region;
  43 }
  44 
  45 inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size,
  46                                                  size_t desired_word_size,
  47                                                  size_t* actual_word_size) {
  48   HeapWord* result = mutator_alloc_region()->attempt_retained_allocation(min_word_size, desired_word_size, actual_word_size);

  49   if (result != NULL) {
  50     return result;
  51   }
  52   return mutator_alloc_region()->attempt_allocation(min_word_size, desired_word_size, actual_word_size);
  53 }
  54 
  55 inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
  56   HeapWord* result = mutator_alloc_region()->attempt_allocation_locked(word_size);
  57   assert(result != NULL || mutator_alloc_region()->get() == NULL,
  58          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region()->get()));

  59   return result;
  60 }
  61 
  62 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
  63   return mutator_alloc_region()->attempt_allocation_force(word_size);

  64 }
  65 
  66 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest) {
  67   assert(dest.is_valid(),
  68          "Allocation buffer index out of bounds: %s", dest.get_type_str());
  69   assert(_alloc_buffers[dest.type()] != NULL,
  70          "Allocation buffer is NULL: %s", dest.get_type_str());
  71   return _alloc_buffers[dest.type()];
  72 }
  73 
  74 inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
  75                                                 size_t word_sz) {
  76   PLAB* buffer = alloc_buffer(dest);
  77   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
  78     return buffer->allocate(word_sz);
  79   } else {
  80     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
  81   }
  82 }
  83 




  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 #ifndef SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
  26 #define SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
  27 
  28 #include "gc/g1/g1Allocator.hpp"
  29 #include "gc/g1/g1AllocRegion.inline.hpp"
  30 #include "gc/shared/plab.inline.hpp"
  31 #include "memory/universe.hpp"
  32 
  33 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) {
  34   assert(_g1h->mem_node_mgr()->is_valid_node_index(node_index), "Invariant, index %u", node_index);
  35   return &_mutator_alloc_region[node_index];
  36 }
  37 
  38 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() {
  39   return &_survivor_gc_alloc_region;
  40 }
  41 
  42 inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
  43   return &_old_gc_alloc_region;
  44 }
  45 
  46 inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size,
  47                                                  size_t desired_word_size,
  48                                                  size_t* actual_word_size) {
  49   uint node_index = _g1h->mem_node_mgr()->index_of_current_thread();
  50   HeapWord* result = mutator_alloc_region(node_index)->attempt_retained_allocation(min_word_size, desired_word_size, actual_word_size);
  51   if (result != NULL) {
  52     return result;
  53   }
  54   return mutator_alloc_region(node_index)->attempt_allocation(min_word_size, desired_word_size, actual_word_size);
  55 }
  56 
  57 inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
  58   uint node_index = _g1h->mem_node_mgr()->index_of_current_thread();
  59   HeapWord* result = mutator_alloc_region(node_index)->attempt_allocation_locked(word_size);
  60   assert(result != NULL || mutator_alloc_region(node_index)->get() == NULL,
  61          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(node_index)->get()));
  62   return result;
  63 }
  64 
  65 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
  66   uint node_index = _g1h->mem_node_mgr()->index_of_current_thread();
  67   return mutator_alloc_region(node_index)->attempt_allocation_force(word_size);
  68 }
  69 
  70 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest) {
  71   assert(dest.is_valid(),
  72          "Allocation buffer index out of bounds: %s", dest.get_type_str());
  73   assert(_alloc_buffers[dest.type()] != NULL,
  74          "Allocation buffer is NULL: %s", dest.get_type_str());
  75   return _alloc_buffers[dest.type()];
  76 }
  77 
  78 inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
  79                                                 size_t word_sz) {
  80   PLAB* buffer = alloc_buffer(dest);
  81   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
  82     return buffer->allocate(word_sz);
  83   } else {
  84     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
  85   }
  86 }
  87 


< prev index next >