src/hotspot/share/gc/g1/g1Allocator.inline.hpp
changeset 49713 456e51e56ea2
parent 49323 565336327354
child 49945 9425445633cf
equal deleted inserted replaced
49712:9e059253786b 49713:456e51e56ea2
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    27 
    27 
    28 #include "gc/g1/g1Allocator.hpp"
    28 #include "gc/g1/g1Allocator.hpp"
    29 #include "gc/g1/g1AllocRegion.inline.hpp"
    29 #include "gc/g1/g1AllocRegion.inline.hpp"
    30 #include "gc/shared/plab.inline.hpp"
    30 #include "gc/shared/plab.inline.hpp"
    31 
    31 
    32 HeapWord* G1Allocator::attempt_allocation(size_t word_size) {
    32 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region() {
       
    33   return &_mutator_alloc_region;
       
    34 }
       
    35 
       
    36 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() {
       
    37   return &_survivor_gc_alloc_region;
       
    38 }
       
    39 
       
    40 inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
       
    41   return &_old_gc_alloc_region;
       
    42 }
       
    43 
       
    44 inline HeapWord* G1Allocator::attempt_allocation(size_t word_size) {
    33   return mutator_alloc_region()->attempt_allocation(word_size);
    45   return mutator_alloc_region()->attempt_allocation(word_size);
    34 }
    46 }
    35 
    47 
    36 HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
    48 inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
    37   HeapWord* result = mutator_alloc_region()->attempt_allocation_locked(word_size);
    49   HeapWord* result = mutator_alloc_region()->attempt_allocation_locked(word_size);
    38   assert(result != NULL || mutator_alloc_region()->get() == NULL,
    50   assert(result != NULL || mutator_alloc_region()->get() == NULL,
    39          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region()->get()));
    51          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region()->get()));
    40   return result;
    52   return result;
    41 }
    53 }
    42 
    54 
    43 HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
    55 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
    44   return mutator_alloc_region()->attempt_allocation_force(word_size);
    56   return mutator_alloc_region()->attempt_allocation_force(word_size);
       
    57 }
       
    58 
       
    59 inline PLAB* G1PLABAllocator::alloc_buffer(InCSetState dest) {
       
    60   assert(dest.is_valid(),
       
    61          "Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value());
       
    62   assert(_alloc_buffers[dest.value()] != NULL,
       
    63          "Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value());
       
    64   return _alloc_buffers[dest.value()];
    45 }
    65 }
    46 
    66 
    47 inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest,
    67 inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest,
    48                                                 size_t word_sz) {
    68                                                 size_t word_sz) {
    49   PLAB* buffer = alloc_buffer(dest);
    69   PLAB* buffer = alloc_buffer(dest);
    50   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
    70   if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
    51     return buffer->allocate(word_sz);
    71     return buffer->allocate(word_sz);
    52   } else {
    72   } else {
    53     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
    73     return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
    54   }
    74   }
       
    75 }
       
    76 
       
    77 inline HeapWord* G1PLABAllocator::allocate(InCSetState dest,
       
    78                                            size_t word_sz,
       
    79                                            bool* refill_failed) {
       
    80   HeapWord* const obj = plab_allocate(dest, word_sz);
       
    81   if (obj != NULL) {
       
    82     return obj;
       
    83   }
       
    84   return allocate_direct_or_new_plab(dest, word_sz, refill_failed);
    55 }
    85 }
    56 
    86 
    57 // Create the maps which is used to identify archive objects.
    87 // Create the maps which is used to identify archive objects.
    58 inline void G1ArchiveAllocator::enable_archive_object_check() {
    88 inline void G1ArchiveAllocator::enable_archive_object_check() {
    59   if (_archive_check_enabled) {
    89   if (_archive_check_enabled) {