Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/g1/g1Allocator.inline.hpp
40961 views
1
/*
2
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
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
30
#include "gc/g1/g1AllocRegion.inline.hpp"
31
#include "gc/shared/plab.inline.hpp"
32
#include "memory/universe.hpp"
33
34
inline uint G1Allocator::current_node_index() const {
35
return _numa->index_of_current_thread();
36
}
37
38
inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) {
39
assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
40
return &_mutator_alloc_regions[node_index];
41
}
42
43
inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region(uint node_index) {
44
assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
45
return &_survivor_gc_alloc_regions[node_index];
46
}
47
48
inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
49
return &_old_gc_alloc_region;
50
}
51
52
inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size,
53
size_t desired_word_size,
54
size_t* actual_word_size) {
55
uint node_index = current_node_index();
56
HeapWord* result = mutator_alloc_region(node_index)->attempt_retained_allocation(min_word_size, desired_word_size, actual_word_size);
57
if (result != NULL) {
58
return result;
59
}
60
return mutator_alloc_region(node_index)->attempt_allocation(min_word_size, desired_word_size, actual_word_size);
61
}
62
63
inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
64
uint node_index = current_node_index();
65
HeapWord* result = mutator_alloc_region(node_index)->attempt_allocation_locked(word_size);
66
assert(result != NULL || mutator_alloc_region(node_index)->get() == NULL,
67
"Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(node_index)->get()));
68
return result;
69
}
70
71
inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
72
uint node_index = current_node_index();
73
return mutator_alloc_region(node_index)->attempt_allocation_force(word_size);
74
}
75
76
inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest, uint node_index) const {
77
assert(dest.is_valid(),
78
"Allocation buffer index out of bounds: %s", dest.get_type_str());
79
assert(_alloc_buffers[dest.type()] != NULL,
80
"Allocation buffer is NULL: %s", dest.get_type_str());
81
return alloc_buffer(dest.type(), node_index);
82
}
83
84
inline PLAB* G1PLABAllocator::alloc_buffer(region_type_t dest, uint node_index) const {
85
assert(dest < G1HeapRegionAttr::Num,
86
"Allocation buffer index out of bounds: %u", dest);
87
88
if (dest == G1HeapRegionAttr::Young) {
89
assert(node_index < alloc_buffers_length(dest),
90
"Allocation buffer index out of bounds: %u, %u", dest, node_index);
91
return _alloc_buffers[dest][node_index];
92
} else {
93
return _alloc_buffers[dest][0];
94
}
95
}
96
97
inline uint G1PLABAllocator::alloc_buffers_length(region_type_t dest) const {
98
if (dest == G1HeapRegionAttr::Young) {
99
return _allocator->num_nodes();
100
} else {
101
return 1;
102
}
103
}
104
105
inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
106
size_t word_sz,
107
uint node_index) {
108
PLAB* buffer = alloc_buffer(dest, node_index);
109
return buffer->allocate(word_sz);
110
}
111
112
inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
113
size_t word_sz,
114
bool* refill_failed,
115
uint node_index) {
116
HeapWord* const obj = plab_allocate(dest, word_sz, node_index);
117
if (obj != NULL) {
118
return obj;
119
}
120
return allocate_direct_or_new_plab(dest, word_sz, refill_failed, node_index);
121
}
122
123
#endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
124
125