author | tschatzl |
Wed, 25 Nov 2015 14:43:29 +0100 | |
changeset 34300 | 6075c1e0e913 |
parent 34230 | b9c64b7c06c9 |
child 35461 | 1068dcb8d315 |
permissions | -rw-r--r-- |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
1 |
/* |
30764 | 2 |
* Copyright (c) 2011, 2015, 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" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
12381
diff
changeset
|
29 |
#include "runtime/orderAccess.inline.hpp" |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
30 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
31 |
G1CollectedHeap* G1AllocRegion::_g1h = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
32 |
HeapRegion* G1AllocRegion::_dummy_region = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
33 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
34 |
void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
35 |
assert(_dummy_region == NULL, "should be set once"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
36 |
assert(dummy_region != NULL, "pre-condition"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
37 |
assert(dummy_region->free() == 0, "pre-condition"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
38 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
39 |
// 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
|
40 |
// and will not trigger any asserts. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
41 |
assert(allocate(dummy_region, 1, false) == NULL, "should fail"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
42 |
assert(par_allocate(dummy_region, 1, false) == NULL, "should fail"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
43 |
assert(allocate(dummy_region, 1, true) == NULL, "should fail"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
44 |
assert(par_allocate(dummy_region, 1, true) == NULL, "should fail"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
45 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
46 |
_g1h = g1h; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
47 |
_dummy_region = dummy_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
48 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
49 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
50 |
size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
51 |
bool bot_updates) { |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
52 |
assert(alloc_region != NULL && alloc_region != _dummy_region, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
53 |
"pre-condition"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
54 |
size_t result = 0; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
55 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
56 |
// 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
|
57 |
// 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
|
58 |
// 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
|
59 |
// 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
|
60 |
// 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
|
61 |
// 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
|
62 |
// closed to being full. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
63 |
size_t free_word_size = alloc_region->free() / HeapWordSize; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
64 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
65 |
// 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
|
66 |
// 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
|
67 |
// 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
|
68 |
// 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
|
69 |
// allocation. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
70 |
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
|
71 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
72 |
while (free_word_size >= min_word_size_to_fill) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
73 |
HeapWord* dummy = par_allocate(alloc_region, free_word_size, bot_updates); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
74 |
if (dummy != NULL) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
75 |
// 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
|
76 |
CollectedHeap::fill_with_object(dummy, free_word_size); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
77 |
alloc_region->set_pre_dummy_top(dummy); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
78 |
result += free_word_size * HeapWordSize; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
79 |
break; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
80 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
81 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
82 |
free_word_size = alloc_region->free() / HeapWordSize; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
83 |
// 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
|
84 |
// 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
|
85 |
// just get out of the loop. |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
86 |
} |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
87 |
result += alloc_region->free(); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
88 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
89 |
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
|
90 |
"post-condition"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
91 |
return result; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
92 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
93 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
94 |
size_t G1AllocRegion::retire(bool fill_up) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
95 |
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
|
96 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
97 |
size_t result = 0; |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
98 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
99 |
trace("retiring"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
100 |
HeapRegion* alloc_region = _alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
101 |
if (alloc_region != _dummy_region) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
102 |
// We never have to check whether the active region is empty or not, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
103 |
// and potentially free it if it is, given that it's guaranteed that |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
104 |
// it will never be empty. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
105 |
assert_alloc_region(!alloc_region->is_empty(), |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
106 |
"the alloc region should never be empty"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
107 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
108 |
if (fill_up) { |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
109 |
result = fill_up_remaining_space(alloc_region, _bot_updates); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
110 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
111 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
112 |
assert_alloc_region(alloc_region->used() >= _used_bytes_before, "invariant"); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
113 |
size_t allocated_bytes = alloc_region->used() - _used_bytes_before; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
114 |
retire_region(alloc_region, allocated_bytes); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
115 |
_used_bytes_before = 0; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
116 |
_alloc_region = _dummy_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
117 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
118 |
trace("retired"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
119 |
|
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
120 |
return result; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
121 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
122 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
123 |
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
|
124 |
bool force) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
125 |
assert_alloc_region(_alloc_region == _dummy_region, "pre-condition"); |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
126 |
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
|
127 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
128 |
trace("attempting region allocation"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
129 |
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
|
130 |
if (new_alloc_region != NULL) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
131 |
new_alloc_region->reset_pre_dummy_top(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
132 |
// Need to do this before the allocation |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
133 |
_used_bytes_before = new_alloc_region->used(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
134 |
HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
135 |
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
|
136 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
137 |
OrderAccess::storestore(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
138 |
// 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
|
139 |
// 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
|
140 |
// can never be empty. |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
141 |
update_alloc_region(new_alloc_region); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
142 |
trace("region allocation successful"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
143 |
return result; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
144 |
} else { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
145 |
trace("region allocation failed"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
146 |
return NULL; |
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 |
ShouldNotReachHere(); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
149 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
150 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
151 |
void G1AllocRegion::init() { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
152 |
trace("initializing"); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
_alloc_region = _dummy_region; |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
156 |
_count = 0; |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
157 |
trace("initialized"); |
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 |
|
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
160 |
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
|
161 |
trace("setting"); |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
162 |
// 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
|
163 |
// maintain the "the alloc region cannot be empty" invariant. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
164 |
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
|
165 |
assert_alloc_region(_alloc_region == _dummy_region && |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
166 |
_used_bytes_before == 0 && _count == 0, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
167 |
"pre-condition"); |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
168 |
|
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
169 |
_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
|
170 |
_alloc_region = alloc_region; |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
171 |
_count += 1; |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
172 |
trace("set"); |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
173 |
} |
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
174 |
|
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
175 |
void G1AllocRegion::update_alloc_region(HeapRegion* alloc_region) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
176 |
trace("update"); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
177 |
// 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
|
178 |
// maintain the "the alloc region cannot be empty" invariant. |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
179 |
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
|
180 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
181 |
_alloc_region = alloc_region; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
182 |
_alloc_region->set_allocation_context(allocation_context()); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
183 |
_count += 1; |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
184 |
trace("updated"); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
185 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
186 |
|
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
187 |
HeapRegion* G1AllocRegion::release() { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
188 |
trace("releasing"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
189 |
HeapRegion* alloc_region = _alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
190 |
retire(false /* fill_up */); |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32389
diff
changeset
|
191 |
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
|
192 |
_alloc_region = NULL; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
193 |
trace("released"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
194 |
return (alloc_region == _dummy_region) ? NULL : alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
195 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
196 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
197 |
#if G1_ALLOC_REGION_TRACING |
32389
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
198 |
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
|
199 |
// All the calls to trace that set either just the size or the size |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
200 |
// and the result are considered part of level 2 tracing and are |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
201 |
// skipped during level 1 tracing. |
32389
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
202 |
if ((actual_word_size == 0 && result == NULL) || (G1_ALLOC_REGION_TRACING > 1)) { |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
203 |
const size_t buffer_length = 128; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
204 |
char hr_buffer[buffer_length]; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
205 |
char rest_buffer[buffer_length]; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
206 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
207 |
HeapRegion* alloc_region = _alloc_region; |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
208 |
if (alloc_region == NULL) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
209 |
jio_snprintf(hr_buffer, buffer_length, "NULL"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
210 |
} else if (alloc_region == _dummy_region) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
211 |
jio_snprintf(hr_buffer, buffer_length, "DUMMY"); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
212 |
} else { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
213 |
jio_snprintf(hr_buffer, buffer_length, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
214 |
HR_FORMAT, HR_FORMAT_PARAMS(alloc_region)); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
215 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
216 |
|
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
217 |
if (G1_ALLOC_REGION_TRACING > 1) { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
218 |
if (result != NULL) { |
32389
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
219 |
jio_snprintf(rest_buffer, buffer_length, "min " SIZE_FORMAT " desired " SIZE_FORMAT " actual " SIZE_FORMAT " " PTR_FORMAT, |
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
220 |
min_word_size, desired_word_size, actual_word_size, result); |
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
221 |
} else if (min_word_size != 0) { |
626f27450e12
8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents:
32379
diff
changeset
|
222 |
jio_snprintf(rest_buffer, buffer_length, "min " SIZE_FORMAT " desired " SIZE_FORMAT, min_word_size, desired_word_size); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
223 |
} else { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
224 |
jio_snprintf(rest_buffer, buffer_length, ""); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
225 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
226 |
} else { |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
227 |
jio_snprintf(rest_buffer, buffer_length, ""); |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
228 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
229 |
|
12381
1438e0fbfa27
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
10243
diff
changeset
|
230 |
tty->print_cr("[%s] %u %s : %s %s", |
10243
d00a21009f1f
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
8928
diff
changeset
|
231 |
_name, _count, hr_buffer, str, rest_buffer); |
8928
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
232 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
233 |
} |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
234 |
#endif // G1_ALLOC_REGION_TRACING |
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 |
G1AllocRegion::G1AllocRegion(const char* name, |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
237 |
bool bot_updates) |
e5c53268bef5
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
238 |
: _name(name), _bot_updates(bot_updates), |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
239 |
_alloc_region(NULL), _count(0), _used_bytes_before(0), |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
240 |
_allocation_context(AllocationContext::system()) { } |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
241 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
242 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
243 |
HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size, |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
244 |
bool force) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
245 |
return _g1h->new_mutator_alloc_region(word_size, force); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
246 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
247 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
248 |
void MutatorAllocRegion::retire_region(HeapRegion* alloc_region, |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
249 |
size_t allocated_bytes) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
250 |
_g1h->retire_mutator_alloc_region(alloc_region, allocated_bytes); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
251 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
252 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
253 |
HeapRegion* G1GCAllocRegion::allocate_new_region(size_t word_size, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
254 |
bool force) { |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
255 |
assert(!force, "not supported for GC alloc regions"); |
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
256 |
return _g1h->new_gc_alloc_region(word_size, count(), _purpose); |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
257 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
258 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
259 |
void G1GCAllocRegion::retire_region(HeapRegion* alloc_region, |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
260 |
size_t allocated_bytes) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
261 |
_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
|
262 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
263 |
|
32379
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
264 |
size_t G1GCAllocRegion::retire(bool fill_up) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
265 |
HeapRegion* retired = get(); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
266 |
size_t end_waste = G1AllocRegion::retire(fill_up); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
267 |
// Do not count retirement of the dummy allocation region. |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
268 |
if (retired != NULL) { |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
269 |
_stats->add_region_end_waste(end_waste / HeapWordSize); |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
270 |
} |
aa14adafaf0f
8073013: Add detailed information about PLAB memory usage
tschatzl
parents:
32185
diff
changeset
|
271 |
return end_waste; |
26837
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
272 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
273 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
274 |
HeapRegion* OldGCAllocRegion::release() { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
275 |
HeapRegion* cur = get(); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
276 |
if (cur != NULL) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
277 |
// 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
|
278 |
// 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
|
279 |
HeapWord* top = cur->top(); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
280 |
HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
281 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
282 |
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
|
283 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
284 |
if (to_allocate_words != 0) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
285 |
// 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
|
286 |
// 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
|
287 |
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
|
288 |
MAX2(to_allocate_words, G1CollectedHeap::min_fill_size())); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
289 |
|
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
290 |
// 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
|
291 |
// 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
|
292 |
// original problem cannot occur. |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
293 |
if (to_allocate_words >= G1CollectedHeap::min_fill_size()) { |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
294 |
HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
295 |
CollectedHeap::fill_with_object(dummy, to_allocate_words); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
296 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
297 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
298 |
} |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
299 |
return G1AllocRegion::release(); |
72a43d3841e7
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
24424
diff
changeset
|
300 |
} |