author | sangheki |
Wed, 13 Nov 2019 10:49:32 -0800 | |
changeset 59061 | df6f2350edfa |
parent 59060 | fce1fa1bdc91 |
permissions | -rw-r--r-- |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
1 |
/* |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
4 |
* |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
8 |
* |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
13 |
* accompanied this code). |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
14 |
* |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
18 |
* |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
21 |
* questions. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
22 |
* |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
23 |
*/ |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
24 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/g1/g1AllocRegion.inline.hpp" |
34230
b9c64b7c06c9
8141570: Fix Zero interpreter build for --disable-precompiled-headers
coleenp
parents:
33105
diff
changeset
|
27 |
#include "gc/g1/g1EvacStats.inline.hpp" |
30764 | 28 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46625
diff
changeset
|
29 |
#include "logging/log.hpp" |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46625
diff
changeset
|
30 |
#include "logging/logStream.hpp" |
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
31 |
#include "memory/resourceArea.hpp" |
50429
83aec1d357d4
8204301: Make OrderAccess functions available to hpp rather than inline.hpp files
coleenp
parents:
49945
diff
changeset
|
32 |
#include "runtime/orderAccess.hpp" |
46625 | 33 |
#include "utilities/align.hpp" |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
34 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
35 |
G1CollectedHeap* G1AllocRegion::_g1h = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
36 |
HeapRegion* G1AllocRegion::_dummy_region = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
37 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
38 |
void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
39 |
assert(_dummy_region == NULL, "should be set once"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
40 |
assert(dummy_region != NULL, "pre-condition"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
41 |
assert(dummy_region->free() == 0, "pre-condition"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
42 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
43 |
// Make sure that any allocation attempt on this region will fail |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
44 |
// and will not trigger any asserts. |
48402
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
45 |
assert(dummy_region->allocate_no_bot_updates(1) == NULL, "should fail"); |
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
46 |
assert(dummy_region->allocate(1) == NULL, "should fail"); |
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
47 |
DEBUG_ONLY(size_t assert_tmp); |
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
48 |
assert(dummy_region->par_allocate_no_bot_updates(1, 1, &assert_tmp) == NULL, "should fail"); |
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
49 |
assert(dummy_region->par_allocate(1, 1, &assert_tmp) == NULL, "should fail"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
50 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
51 |
_g1h = g1h; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
52 |
_dummy_region = dummy_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
53 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
54 |
|
48402
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
55 |
size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region) { |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
56 |
assert(alloc_region != NULL && alloc_region != _dummy_region, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
57 |
"pre-condition"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
58 |
size_t result = 0; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
59 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
60 |
// Other threads might still be trying to allocate using a CAS out |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
61 |
// of the region we are trying to retire, as they can do so without |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
62 |
// holding the lock. So, we first have to make sure that noone else |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
63 |
// can allocate out of it by doing a maximal allocation. Even if our |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
64 |
// CAS attempt fails a few times, we'll succeed sooner or later |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
65 |
// given that failed CAS attempts mean that the region is getting |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
66 |
// closed to being full. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
67 |
size_t free_word_size = alloc_region->free() / HeapWordSize; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
68 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
69 |
// This is the minimum free chunk we can turn into a dummy |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
70 |
// object. If the free space falls below this, then noone can |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
71 |
// allocate in this region anyway (all allocation requests will be |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
72 |
// of a size larger than this) so we won't have to perform the dummy |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
73 |
// allocation. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
74 |
size_t min_word_size_to_fill = CollectedHeap::min_fill_size(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
75 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
76 |
while (free_word_size >= min_word_size_to_fill) { |
48402
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
77 |
HeapWord* dummy = par_allocate(alloc_region, free_word_size); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
78 |
if (dummy != NULL) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
79 |
// If the allocation was successful we should fill in the space. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
80 |
CollectedHeap::fill_with_object(dummy, free_word_size); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
81 |
alloc_region->set_pre_dummy_top(dummy); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
82 |
result += free_word_size * HeapWordSize; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
83 |
break; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
84 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
85 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
86 |
free_word_size = alloc_region->free() / HeapWordSize; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
87 |
// It's also possible that someone else beats us to the |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
88 |
// allocation and they fill up the region. In that case, we can |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
89 |
// just get out of the loop. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
90 |
} |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
91 |
result += alloc_region->free(); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
92 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
93 |
assert(alloc_region->free() / HeapWordSize < min_word_size_to_fill, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
94 |
"post-condition"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
95 |
return result; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
96 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
97 |
|
49945 | 98 |
size_t G1AllocRegion::retire_internal(HeapRegion* alloc_region, bool fill_up) { |
99 |
// We never have to check whether the active region is empty or not, |
|
100 |
// and potentially free it if it is, given that it's guaranteed that |
|
101 |
// it will never be empty. |
|
102 |
size_t waste = 0; |
|
103 |
assert_alloc_region(!alloc_region->is_empty(), |
|
104 |
"the alloc region should never be empty"); |
|
105 |
||
106 |
if (fill_up) { |
|
107 |
waste = fill_up_remaining_space(alloc_region); |
|
108 |
} |
|
109 |
||
110 |
assert_alloc_region(alloc_region->used() >= _used_bytes_before, "invariant"); |
|
111 |
size_t allocated_bytes = alloc_region->used() - _used_bytes_before; |
|
112 |
retire_region(alloc_region, allocated_bytes); |
|
113 |
_used_bytes_before = 0; |
|
114 |
||
115 |
return waste; |
|
116 |
} |
|
117 |
||
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
118 |
size_t G1AllocRegion::retire(bool fill_up) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
119 |
assert_alloc_region(_alloc_region != NULL, "not initialized properly"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
120 |
|
49945 | 121 |
size_t waste = 0; |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
122 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
123 |
trace("retiring"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
124 |
HeapRegion* alloc_region = _alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
125 |
if (alloc_region != _dummy_region) { |
49945 | 126 |
waste = retire_internal(alloc_region, fill_up); |
127 |
reset_alloc_region(); |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
128 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
129 |
trace("retired"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
130 |
|
49945 | 131 |
return waste; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
132 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
133 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
134 |
HeapWord* G1AllocRegion::new_alloc_region_and_allocate(size_t word_size, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
135 |
bool force) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
136 |
assert_alloc_region(_alloc_region == _dummy_region, "pre-condition"); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
137 |
assert_alloc_region(_used_bytes_before == 0, "pre-condition"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
138 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
139 |
trace("attempting region allocation"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
140 |
HeapRegion* new_alloc_region = allocate_new_region(word_size, force); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
141 |
if (new_alloc_region != NULL) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
142 |
new_alloc_region->reset_pre_dummy_top(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
143 |
// Need to do this before the allocation |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
144 |
_used_bytes_before = new_alloc_region->used(); |
48402
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
145 |
HeapWord* result = allocate(new_alloc_region, word_size); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
146 |
assert_alloc_region(result != NULL, "the allocation should succeeded"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
147 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
148 |
OrderAccess::storestore(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
149 |
// Note that we first perform the allocation and then we store the |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
150 |
// region in _alloc_region. This is the reason why an active region |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
151 |
// can never be empty. |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
152 |
update_alloc_region(new_alloc_region); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
153 |
trace("region allocation successful"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
154 |
return result; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
155 |
} else { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
156 |
trace("region allocation failed"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
157 |
return NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
158 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
159 |
ShouldNotReachHere(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
160 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
161 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
162 |
void G1AllocRegion::init() { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
163 |
trace("initializing"); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
164 |
assert_alloc_region(_alloc_region == NULL && _used_bytes_before == 0, "pre-condition"); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
165 |
assert_alloc_region(_dummy_region != NULL, "should have been set"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
166 |
_alloc_region = _dummy_region; |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
167 |
_count = 0; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
168 |
trace("initialized"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
169 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
170 |
|
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
171 |
void G1AllocRegion::set(HeapRegion* alloc_region) { |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
172 |
trace("setting"); |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
173 |
// We explicitly check that the region is not empty to make sure we |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
174 |
// maintain the "the alloc region cannot be empty" invariant. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
175 |
assert_alloc_region(alloc_region != NULL && !alloc_region->is_empty(), "pre-condition"); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
176 |
assert_alloc_region(_alloc_region == _dummy_region && |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
177 |
_used_bytes_before == 0 && _count == 0, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
178 |
"pre-condition"); |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
179 |
|
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
180 |
_used_bytes_before = alloc_region->used(); |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
181 |
_alloc_region = alloc_region; |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
182 |
_count += 1; |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
183 |
trace("set"); |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
184 |
} |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
185 |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
186 |
void G1AllocRegion::update_alloc_region(HeapRegion* alloc_region) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
187 |
trace("update"); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
188 |
// We explicitly check that the region is not empty to make sure we |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
189 |
// maintain the "the alloc region cannot be empty" invariant. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
190 |
assert_alloc_region(alloc_region != NULL && !alloc_region->is_empty(), "pre-condition"); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
191 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
192 |
_alloc_region = alloc_region; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
193 |
_count += 1; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
194 |
trace("updated"); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
195 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
196 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
197 |
HeapRegion* G1AllocRegion::release() { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
198 |
trace("releasing"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
199 |
HeapRegion* alloc_region = _alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
200 |
retire(false /* fill_up */); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
201 |
assert_alloc_region(_alloc_region == _dummy_region, "post-condition of retire()"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
202 |
_alloc_region = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
203 |
trace("released"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
204 |
return (alloc_region == _dummy_region) ? NULL : alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
205 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
206 |
|
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
207 |
#ifndef PRODUCT |
32389
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
208 |
void G1AllocRegion::trace(const char* str, size_t min_word_size, size_t desired_word_size, size_t actual_word_size, HeapWord* result) { |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
209 |
// All the calls to trace that set either just the size or the size |
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
210 |
// and the result are considered part of detailed tracing and are |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
211 |
// skipped during other tracing. |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
212 |
|
37242 | 213 |
Log(gc, alloc, region) log; |
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
214 |
|
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
215 |
if (!log.is_debug()) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
216 |
return; |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
217 |
} |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
218 |
|
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
219 |
bool detailed_info = log.is_trace(); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
220 |
|
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
221 |
if ((actual_word_size == 0 && result == NULL) || detailed_info) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
222 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46625
diff
changeset
|
223 |
LogStream ls_trace(log.trace()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46625
diff
changeset
|
224 |
LogStream ls_debug(log.debug()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46625
diff
changeset
|
225 |
outputStream* out = detailed_info ? &ls_trace : &ls_debug; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
226 |
|
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
227 |
out->print("%s: %u ", _name, _count); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
228 |
|
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
229 |
if (_alloc_region == NULL) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
230 |
out->print("NULL"); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
231 |
} else if (_alloc_region == _dummy_region) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
232 |
out->print("DUMMY"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
233 |
} else { |
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
234 |
out->print(HR_FORMAT, HR_FORMAT_PARAMS(_alloc_region)); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
235 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
236 |
|
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
237 |
out->print(" : %s", str); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
238 |
|
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
239 |
if (detailed_info) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
240 |
if (result != NULL) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
241 |
out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT, |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
242 |
min_word_size, desired_word_size, actual_word_size, p2i(result)); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
243 |
} else if (min_word_size != 0) { |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
244 |
out->print(" min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size); |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
245 |
} |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
246 |
} |
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
247 |
out->cr(); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
248 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
249 |
} |
37171
b968bbc6291c
8152300: Convert G1_ALLOC_REGION_TRACING to unified logging
brutisso
parents:
37159
diff
changeset
|
250 |
#endif // PRODUCT |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
251 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
252 |
G1AllocRegion::G1AllocRegion(const char* name, |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
253 |
bool bot_updates, |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
254 |
uint node_index) |
51332 | 255 |
: _alloc_region(NULL), |
256 |
_count(0), |
|
257 |
_used_bytes_before(0), |
|
258 |
_bot_updates(bot_updates), |
|
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
259 |
_name(name), |
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
260 |
_node_index(node_index) |
51332 | 261 |
{ } |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
262 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
263 |
HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size, |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
264 |
bool force) { |
59060
fce1fa1bdc91
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents:
51332
diff
changeset
|
265 |
return _g1h->new_mutator_alloc_region(word_size, force, _node_index); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
266 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
267 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
268 |
void MutatorAllocRegion::retire_region(HeapRegion* alloc_region, |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
269 |
size_t allocated_bytes) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
270 |
_g1h->retire_mutator_alloc_region(alloc_region, allocated_bytes); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
271 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
272 |
|
49945 | 273 |
void MutatorAllocRegion::init() { |
274 |
assert(_retained_alloc_region == NULL, "Pre-condition"); |
|
275 |
G1AllocRegion::init(); |
|
276 |
_wasted_bytes = 0; |
|
277 |
} |
|
278 |
||
279 |
bool MutatorAllocRegion::should_retain(HeapRegion* region) { |
|
280 |
size_t free_bytes = region->free(); |
|
281 |
if (free_bytes < MinTLABSize) { |
|
282 |
return false; |
|
283 |
} |
|
284 |
||
285 |
if (_retained_alloc_region != NULL && |
|
286 |
free_bytes < _retained_alloc_region->free()) { |
|
287 |
return false; |
|
288 |
} |
|
289 |
||
290 |
return true; |
|
291 |
} |
|
292 |
||
293 |
size_t MutatorAllocRegion::retire(bool fill_up) { |
|
294 |
size_t waste = 0; |
|
295 |
trace("retiring"); |
|
296 |
HeapRegion* current_region = get(); |
|
297 |
if (current_region != NULL) { |
|
298 |
// Retain the current region if it fits a TLAB and has more |
|
299 |
// free than the currently retained region. |
|
300 |
if (should_retain(current_region)) { |
|
301 |
trace("mutator retained"); |
|
302 |
if (_retained_alloc_region != NULL) { |
|
303 |
waste = retire_internal(_retained_alloc_region, true); |
|
304 |
} |
|
305 |
_retained_alloc_region = current_region; |
|
306 |
} else { |
|
307 |
waste = retire_internal(current_region, fill_up); |
|
308 |
} |
|
309 |
reset_alloc_region(); |
|
310 |
} |
|
311 |
||
312 |
_wasted_bytes += waste; |
|
313 |
trace("retired"); |
|
314 |
return waste; |
|
315 |
} |
|
316 |
||
317 |
size_t MutatorAllocRegion::used_in_alloc_regions() { |
|
318 |
size_t used = 0; |
|
319 |
HeapRegion* hr = get(); |
|
320 |
if (hr != NULL) { |
|
321 |
used += hr->used(); |
|
322 |
} |
|
323 |
||
324 |
hr = _retained_alloc_region; |
|
325 |
if (hr != NULL) { |
|
326 |
used += hr->used(); |
|
327 |
} |
|
328 |
return used; |
|
329 |
} |
|
330 |
||
331 |
HeapRegion* MutatorAllocRegion::release() { |
|
332 |
HeapRegion* ret = G1AllocRegion::release(); |
|
333 |
||
334 |
// The retained alloc region must be retired and this must be |
|
335 |
// done after the above call to release the mutator alloc region, |
|
336 |
// since it might update the _retained_alloc_region member. |
|
337 |
if (_retained_alloc_region != NULL) { |
|
338 |
_wasted_bytes += retire_internal(_retained_alloc_region, false); |
|
339 |
_retained_alloc_region = NULL; |
|
340 |
} |
|
341 |
log_debug(gc, alloc, region)("Mutator Allocation stats, regions: %u, wasted size: " SIZE_FORMAT "%s (%4.1f%%)", |
|
342 |
count(), |
|
343 |
byte_size_in_proper_unit(_wasted_bytes), |
|
344 |
proper_unit_for_byte_size(_wasted_bytes), |
|
345 |
percent_of(_wasted_bytes, count() * HeapRegion::GrainBytes)); |
|
346 |
return ret; |
|
347 |
} |
|
348 |
||
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
349 |
HeapRegion* G1GCAllocRegion::allocate_new_region(size_t word_size, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
350 |
bool force) { |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
351 |
assert(!force, "not supported for GC alloc regions"); |
59061
df6f2350edfa
8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents:
59060
diff
changeset
|
352 |
return _g1h->new_gc_alloc_region(word_size, _purpose, _node_index); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
353 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
354 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
355 |
void G1GCAllocRegion::retire_region(HeapRegion* alloc_region, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
356 |
size_t allocated_bytes) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
357 |
_g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, _purpose); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
358 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
359 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
360 |
size_t G1GCAllocRegion::retire(bool fill_up) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
361 |
HeapRegion* retired = get(); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
362 |
size_t end_waste = G1AllocRegion::retire(fill_up); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
363 |
// Do not count retirement of the dummy allocation region. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
364 |
if (retired != NULL) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
365 |
_stats->add_region_end_waste(end_waste / HeapWordSize); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
366 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
367 |
return end_waste; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
368 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
369 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
370 |
HeapRegion* OldGCAllocRegion::release() { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
371 |
HeapRegion* cur = get(); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
372 |
if (cur != NULL) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
373 |
// Determine how far we are from the next card boundary. If it is smaller than |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
374 |
// the minimum object size we can allocate into, expand into the next card. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
375 |
HeapWord* top = cur->top(); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46618
diff
changeset
|
376 |
HeapWord* aligned_top = align_up(top, BOTConstants::N_bytes); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
377 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
378 |
size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
379 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
380 |
if (to_allocate_words != 0) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
381 |
// We are not at a card boundary. Fill up, possibly into the next, taking the |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
382 |
// end of the region and the minimum object size into account. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
383 |
to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize), |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
384 |
MAX2(to_allocate_words, G1CollectedHeap::min_fill_size())); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
385 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
386 |
// Skip allocation if there is not enough space to allocate even the smallest |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
387 |
// possible object. In this case this region will not be retained, so the |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
388 |
// original problem cannot occur. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
389 |
if (to_allocate_words >= G1CollectedHeap::min_fill_size()) { |
48402
945332d45710
8133805: Remove the bot_updates parameter from G1Allocator's allocation methods
lkorinth
parents:
47216
diff
changeset
|
390 |
HeapWord* dummy = attempt_allocation(to_allocate_words); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
391 |
CollectedHeap::fill_with_object(dummy, to_allocate_words); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
392 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
393 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
394 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
395 |
return G1AllocRegion::release(); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
396 |
} |