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