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 #include "memory/universe.hpp" |
31 #include "memory/universe.hpp" |
32 |
32 |
33 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region() { |
33 inline uint G1Allocator::current_node_index() const { |
34 return &_mutator_alloc_region; |
34 return _numa->index_of_current_thread(); |
|
35 } |
|
36 |
|
37 inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) { |
|
38 assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index); |
|
39 return &_mutator_alloc_regions[node_index]; |
35 } |
40 } |
36 |
41 |
37 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() { |
42 inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() { |
38 return &_survivor_gc_alloc_region; |
43 return &_survivor_gc_alloc_region; |
39 } |
44 } |
43 } |
48 } |
44 |
49 |
45 inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size, |
50 inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size, |
46 size_t desired_word_size, |
51 size_t desired_word_size, |
47 size_t* actual_word_size) { |
52 size_t* actual_word_size) { |
48 HeapWord* result = mutator_alloc_region()->attempt_retained_allocation(min_word_size, desired_word_size, 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); |
49 if (result != NULL) { |
55 if (result != NULL) { |
50 return result; |
56 return result; |
51 } |
57 } |
52 return mutator_alloc_region()->attempt_allocation(min_word_size, desired_word_size, actual_word_size); |
58 return mutator_alloc_region(node_index)->attempt_allocation(min_word_size, desired_word_size, actual_word_size); |
53 } |
59 } |
54 |
60 |
55 inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) { |
61 inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) { |
56 HeapWord* result = mutator_alloc_region()->attempt_allocation_locked(word_size); |
62 uint node_index = current_node_index(); |
57 assert(result != NULL || mutator_alloc_region()->get() == NULL, |
63 HeapWord* result = mutator_alloc_region(node_index)->attempt_allocation_locked(word_size); |
58 "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region()->get())); |
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())); |
59 return result; |
66 return result; |
60 } |
67 } |
61 |
68 |
62 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) { |
69 inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) { |
63 return mutator_alloc_region()->attempt_allocation_force(word_size); |
70 uint node_index = current_node_index(); |
|
71 return mutator_alloc_region(node_index)->attempt_allocation_force(word_size); |
64 } |
72 } |
65 |
73 |
66 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest) { |
74 inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest) { |
67 assert(dest.is_valid(), |
75 assert(dest.is_valid(), |
68 "Allocation buffer index out of bounds: %s", dest.get_type_str()); |
76 "Allocation buffer index out of bounds: %s", dest.get_type_str()); |