Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp
66644 views
1
/*
2
* Copyright (c) 2011, 2019, 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_G1ALLOCREGION_INLINE_HPP
26
#define SHARE_GC_G1_G1ALLOCREGION_INLINE_HPP
27
28
#include "gc/g1/g1AllocRegion.hpp"
29
30
#include "gc/g1/heapRegion.inline.hpp"
31
32
#define assert_alloc_region(p, message) \
33
do { \
34
assert((p), "[%s] %s c: %u b: %s r: " PTR_FORMAT " u: " SIZE_FORMAT, \
35
_name, (message), _count, BOOL_TO_STR(_bot_updates), \
36
p2i(_alloc_region), _used_bytes_before); \
37
} while (0)
38
39
40
inline void G1AllocRegion::reset_alloc_region() {
41
_alloc_region = _dummy_region;
42
}
43
44
inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
45
size_t word_size) {
46
assert(alloc_region != NULL, "pre-condition");
47
48
if (!_bot_updates) {
49
return alloc_region->allocate_no_bot_updates(word_size);
50
} else {
51
return alloc_region->allocate(word_size);
52
}
53
}
54
55
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
56
size_t temp;
57
return par_allocate(alloc_region, word_size, word_size, &temp);
58
}
59
60
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
61
size_t min_word_size,
62
size_t desired_word_size,
63
size_t* actual_word_size) {
64
assert(alloc_region != NULL, "pre-condition");
65
assert(!alloc_region->is_empty(), "pre-condition");
66
67
if (!_bot_updates) {
68
return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
69
} else {
70
return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
71
}
72
}
73
74
inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size) {
75
size_t temp;
76
return attempt_allocation(word_size, word_size, &temp);
77
}
78
79
inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
80
size_t desired_word_size,
81
size_t* actual_word_size) {
82
HeapRegion* alloc_region = _alloc_region;
83
assert_alloc_region(alloc_region != NULL, "not initialized properly");
84
85
HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size);
86
if (result != NULL) {
87
trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
88
return result;
89
}
90
trace("alloc failed", min_word_size, desired_word_size);
91
return NULL;
92
}
93
94
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size) {
95
size_t temp;
96
return attempt_allocation_locked(word_size, word_size, &temp);
97
}
98
99
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
100
size_t desired_word_size,
101
size_t* actual_word_size) {
102
HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size);
103
if (result != NULL) {
104
return result;
105
}
106
107
return attempt_allocation_using_new_region(min_word_size, desired_word_size, actual_word_size);
108
}
109
110
inline HeapWord* G1AllocRegion::attempt_allocation_using_new_region(size_t min_word_size,
111
size_t desired_word_size,
112
size_t* actual_word_size) {
113
retire(true /* fill_up */);
114
HeapWord* result = new_alloc_region_and_allocate(desired_word_size, false /* force */);
115
if (result != NULL) {
116
*actual_word_size = desired_word_size;
117
trace("alloc locked (second attempt)", min_word_size, desired_word_size, *actual_word_size, result);
118
return result;
119
}
120
trace("alloc locked failed", min_word_size, desired_word_size);
121
return NULL;
122
}
123
124
inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
125
assert_alloc_region(_alloc_region != NULL, "not initialized properly");
126
127
trace("forcing alloc", word_size, word_size);
128
HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
129
if (result != NULL) {
130
trace("alloc forced", word_size, word_size, word_size, result);
131
return result;
132
}
133
trace("alloc forced failed", word_size, word_size);
134
return NULL;
135
}
136
137
inline HeapWord* MutatorAllocRegion::attempt_retained_allocation(size_t min_word_size,
138
size_t desired_word_size,
139
size_t* actual_word_size) {
140
if (_retained_alloc_region != NULL) {
141
HeapWord* result = par_allocate(_retained_alloc_region, min_word_size, desired_word_size, actual_word_size);
142
if (result != NULL) {
143
trace("alloc retained", min_word_size, desired_word_size, *actual_word_size, result);
144
return result;
145
}
146
}
147
return NULL;
148
}
149
150
#endif // SHARE_GC_G1_G1ALLOCREGION_INLINE_HPP
151
152