src/hotspot/share/gc/g1/g1Allocator.inline.hpp
changeset 59061 df6f2350edfa
parent 59060 fce1fa1bdc91
equal deleted inserted replaced
59060:fce1fa1bdc91 59061:df6f2350edfa
    37 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) {
    37 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) {
    38   assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
    38   assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
    39   return &_mutator_alloc_regions[node_index];
    39   return &_mutator_alloc_regions[node_index];
    40 }
    40 }
    41 
    41 
    42 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() {
    42 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region(uint node_index) {
    43   return &_survivor_gc_alloc_region;
    43   assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
       
    44   return &_survivor_gc_alloc_regions[node_index];
    44 }
    45 }
    45 
    46 
    46 inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
    47 inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
    47   return &_old_gc_alloc_region;
    48   return &_old_gc_alloc_region;
    48 }
    49 }
    69 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
    70 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
    70   uint node_index = current_node_index();
    71   uint node_index = current_node_index();
    71   return mutator_alloc_region(node_index)->attempt_allocation_force(word_size);
    72   return mutator_alloc_region(node_index)->attempt_allocation_force(word_size);
    72 }
    73 }
    73 
    74 
    74 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest) {
    75 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest, uint node_index) const {
    75   assert(dest.is_valid(),
    76   assert(dest.is_valid(),
    76          "Allocation buffer index out of bounds: %s", dest.get_type_str());
    77          "Allocation buffer index out of bounds: %s", dest.get_type_str());
    77   assert(_alloc_buffers[dest.type()] != NULL,
    78   assert(_alloc_buffers[dest.type()] != NULL,
    78          "Allocation buffer is NULL: %s", dest.get_type_str());
    79          "Allocation buffer is NULL: %s", dest.get_type_str());
    79   return _alloc_buffers[dest.type()];
    80   return alloc_buffer(dest.type(), node_index);
       
    81 }
       
    82 
       
    83 inline PLAB* G1PLABAllocator::alloc_buffer(region_type_t dest, uint node_index) const {
       
    84   assert(dest < G1HeapRegionAttr::Num,
       
    85          "Allocation buffer index out of bounds: %u", dest);
       
    86 
       
    87   if (dest == G1HeapRegionAttr::Young) {
       
    88     assert(node_index < alloc_buffers_length(dest),
       
    89            "Allocation buffer index out of bounds: %u, %u", dest, node_index);
       
    90     return _alloc_buffers[dest][node_index];
       
    91   } else {
       
    92     return _alloc_buffers[dest][0];
       
    93   }
       
    94 }
       
    95 
       
    96 inline uint G1PLABAllocator::alloc_buffers_length(region_type_t dest) const {
       
    97   if (dest == G1HeapRegionAttr::Young) {
       
    98     return _allocator->num_nodes();
       
    99   } else {
       
   100     return 1;
       
   101   }
    80 }
   102 }
    81 
   103 
    82 inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
   104 inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
    83                                                 size_t word_sz) {
   105                                                 size_t word_sz,
    84   PLAB* buffer = alloc_buffer(dest);
   106                                                 uint node_index) {
       
   107   PLAB* buffer = alloc_buffer(dest, node_index);
    85   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
   108   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
    86     return buffer->allocate(word_sz);
   109     return buffer->allocate(word_sz);
    87   } else {
   110   } else {
    88     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
   111     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
    89   }
   112   }
    90 }
   113 }
    91 
   114 
    92 inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
   115 inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
    93                                            size_t word_sz,
   116                                            size_t word_sz,
    94                                            bool* refill_failed) {
   117                                            bool* refill_failed,
    95   HeapWord* const obj = plab_allocate(dest, word_sz);
   118                                            uint node_index) {
       
   119   HeapWord* const obj = plab_allocate(dest, word_sz, node_index);
    96   if (obj != NULL) {
   120   if (obj != NULL) {
    97     return obj;
   121     return obj;
    98   }
   122   }
    99   return allocate_direct_or_new_plab(dest, word_sz, refill_failed);
   123   return allocate_direct_or_new_plab(dest, word_sz, refill_failed, node_index);
   100 }
   124 }
   101 
   125 
   102 // Create the maps which is used to identify archive objects.
   126 // Create the maps which is used to identify archive objects.
   103 inline void G1ArchiveAllocator::enable_archive_object_check() {
   127 inline void G1ArchiveAllocator::enable_archive_object_check() {
   104   if (_archive_check_enabled) {
   128   if (_archive_check_enabled) {