Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/g1AllocRegion.cpp @ 21205:f34ae5c01864
include reexecute, rethrow_exception and return_oop info when disassembling debug scopes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 04 May 2015 10:39:12 +0200 |
parents | 227a9e5e4b4a |
children |
rev | line source |
---|---|
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6010
diff
changeset
|
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
2433
abdfc822206f
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. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
4 * |
abdfc822206f
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 |
abdfc822206f
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 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
8 * |
abdfc822206f
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 |
abdfc822206f
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 |
abdfc822206f
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 |
abdfc822206f
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 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
13 * accompanied this code). |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
14 * |
abdfc822206f
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 |
abdfc822206f
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, |
abdfc822206f
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. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
18 * |
abdfc822206f
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 |
abdfc822206f
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 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
21 * questions. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
22 * |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
23 */ |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
24 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
26 #include "gc_implementation/g1/g1AllocRegion.inline.hpp" |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
27 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
20197
ce8f6bb717c9
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
17937
diff
changeset
|
28 #include "runtime/orderAccess.inline.hpp" |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
29 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
30 G1CollectedHeap* G1AllocRegion::_g1h = NULL; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
31 HeapRegion* G1AllocRegion::_dummy_region = NULL; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
32 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
33 void G1AllocRegion::setup(G1CollectedHeap* g1h, HeapRegion* dummy_region) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
34 assert(_dummy_region == NULL, "should be set once"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
35 assert(dummy_region != NULL, "pre-condition"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
36 assert(dummy_region->free() == 0, "pre-condition"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
37 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
38 // Make sure that any allocation attempt on this region will fail |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
39 // and will not trigger any asserts. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
40 assert(allocate(dummy_region, 1, false) == NULL, "should fail"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
41 assert(par_allocate(dummy_region, 1, false) == NULL, "should fail"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
42 assert(allocate(dummy_region, 1, true) == NULL, "should fail"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
43 assert(par_allocate(dummy_region, 1, true) == NULL, "should fail"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
44 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
45 _g1h = g1h; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
46 _dummy_region = dummy_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
47 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
48 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
49 void G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
50 bool bot_updates) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
51 assert(alloc_region != NULL && alloc_region != _dummy_region, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
52 "pre-condition"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
53 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
54 // Other threads might still be trying to allocate using a CAS out |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
55 // of the region we are trying to retire, as they can do so without |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
56 // holding the lock. So, we first have to make sure that noone else |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
57 // can allocate out of it by doing a maximal allocation. Even if our |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
58 // CAS attempt fails a few times, we'll succeed sooner or later |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
59 // given that failed CAS attempts mean that the region is getting |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
60 // closed to being full. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
61 size_t free_word_size = alloc_region->free() / HeapWordSize; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
62 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
63 // This is the minimum free chunk we can turn into a dummy |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
64 // object. If the free space falls below this, then noone can |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
65 // allocate in this region anyway (all allocation requests will be |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
66 // of a size larger than this) so we won't have to perform the dummy |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
67 // allocation. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
68 size_t min_word_size_to_fill = CollectedHeap::min_fill_size(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
69 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
70 while (free_word_size >= min_word_size_to_fill) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
71 HeapWord* dummy = par_allocate(alloc_region, free_word_size, bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
72 if (dummy != NULL) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
73 // If the allocation was successful we should fill in the space. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
74 CollectedHeap::fill_with_object(dummy, free_word_size); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
75 alloc_region->set_pre_dummy_top(dummy); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
76 break; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
77 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
78 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
79 free_word_size = alloc_region->free() / HeapWordSize; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
80 // It's also possible that someone else beats us to the |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
81 // allocation and they fill up the region. In that case, we can |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
82 // just get out of the loop. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
83 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
84 assert(alloc_region->free() / HeapWordSize < min_word_size_to_fill, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
85 "post-condition"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
86 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
87 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
88 void G1AllocRegion::retire(bool fill_up) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
89 assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
90 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
91 trace("retiring"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
92 HeapRegion* alloc_region = _alloc_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
93 if (alloc_region != _dummy_region) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
94 // We never have to check whether the active region is empty or not, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
95 // and potentially free it if it is, given that it's guaranteed that |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
96 // it will never be empty. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
97 assert(!alloc_region->is_empty(), |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
98 ar_ext_msg(this, "the alloc region should never be empty")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
99 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
100 if (fill_up) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
101 fill_up_remaining_space(alloc_region, _bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
102 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
103 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
104 assert(alloc_region->used() >= _used_bytes_before, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
105 ar_ext_msg(this, "invariant")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
106 size_t allocated_bytes = alloc_region->used() - _used_bytes_before; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
107 retire_region(alloc_region, allocated_bytes); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
108 _used_bytes_before = 0; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
109 _alloc_region = _dummy_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
110 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
111 trace("retired"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
112 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
113 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
114 HeapWord* G1AllocRegion::new_alloc_region_and_allocate(size_t word_size, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
115 bool force) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
116 assert(_alloc_region == _dummy_region, ar_ext_msg(this, "pre-condition")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
117 assert(_used_bytes_before == 0, ar_ext_msg(this, "pre-condition")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
118 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
119 trace("attempting region allocation"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
120 HeapRegion* new_alloc_region = allocate_new_region(word_size, force); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
121 if (new_alloc_region != NULL) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
122 new_alloc_region->reset_pre_dummy_top(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
123 // Need to do this before the allocation |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
124 _used_bytes_before = new_alloc_region->used(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
125 HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
126 assert(result != NULL, ar_ext_msg(this, "the allocation should succeeded")); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
127 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
128 OrderAccess::storestore(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
129 // Note that we first perform the allocation and then we store the |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
130 // region in _alloc_region. This is the reason why an active region |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
131 // can never be empty. |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
132 update_alloc_region(new_alloc_region); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
133 trace("region allocation successful"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
134 return result; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
135 } else { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
136 trace("region allocation failed"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
137 return NULL; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
138 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
139 ShouldNotReachHere(); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
140 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
141 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
142 void G1AllocRegion::fill_in_ext_msg(ar_ext_msg* msg, const char* message) { |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3830
diff
changeset
|
143 msg->append("[%s] %s c: %u b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT, |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
144 _name, message, _count, BOOL_TO_STR(_bot_updates), |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6010
diff
changeset
|
145 p2i(_alloc_region), _used_bytes_before); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
146 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
147 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
148 void G1AllocRegion::init() { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
149 trace("initializing"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
150 assert(_alloc_region == NULL && _used_bytes_before == 0, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
151 ar_ext_msg(this, "pre-condition")); |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
152 assert(_dummy_region != NULL, ar_ext_msg(this, "should have been set")); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
153 _alloc_region = _dummy_region; |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
154 _count = 0; |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
155 trace("initialized"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
156 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
157 |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
158 void G1AllocRegion::set(HeapRegion* alloc_region) { |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
159 trace("setting"); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
160 // We explicitly check that the region is not empty to make sure we |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
161 // maintain the "the alloc region cannot be empty" invariant. |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
162 assert(alloc_region != NULL && !alloc_region->is_empty(), |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
163 ar_ext_msg(this, "pre-condition")); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
164 assert(_alloc_region == _dummy_region && |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
165 _used_bytes_before == 0 && _count == 0, |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
166 ar_ext_msg(this, "pre-condition")); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
167 |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
168 _used_bytes_before = alloc_region->used(); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
169 _alloc_region = alloc_region; |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
170 _count += 1; |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
171 trace("set"); |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
172 } |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
173 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
174 void G1AllocRegion::update_alloc_region(HeapRegion* alloc_region) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
175 trace("update"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
176 // We explicitly check that the region is not empty to make sure we |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
177 // maintain the "the alloc region cannot be empty" invariant. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
178 assert(alloc_region != NULL && !alloc_region->is_empty(), |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
179 ar_ext_msg(this, "pre-condition")); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
180 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
181 _alloc_region = alloc_region; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
182 _alloc_region->set_allocation_context(allocation_context()); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
183 _count += 1; |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
184 trace("updated"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
185 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
186 |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
187 HeapRegion* G1AllocRegion::release() { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
188 trace("releasing"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
189 HeapRegion* alloc_region = _alloc_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
190 retire(false /* fill_up */); |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
191 assert(_alloc_region == _dummy_region, |
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
192 ar_ext_msg(this, "post-condition of retire()")); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
193 _alloc_region = NULL; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
194 trace("released"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
195 return (alloc_region == _dummy_region) ? NULL : alloc_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
196 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
197 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
198 #if G1_ALLOC_REGION_TRACING |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
199 void G1AllocRegion::trace(const char* str, size_t word_size, HeapWord* result) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
200 // All the calls to trace that set either just the size or the size |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
201 // and the result are considered part of level 2 tracing and are |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
202 // skipped during level 1 tracing. |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
203 if ((word_size == 0 && result == NULL) || (G1_ALLOC_REGION_TRACING > 1)) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
204 const size_t buffer_length = 128; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
205 char hr_buffer[buffer_length]; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
206 char rest_buffer[buffer_length]; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
207 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
208 HeapRegion* alloc_region = _alloc_region; |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
209 if (alloc_region == NULL) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
210 jio_snprintf(hr_buffer, buffer_length, "NULL"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
211 } else if (alloc_region == _dummy_region) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
212 jio_snprintf(hr_buffer, buffer_length, "DUMMY"); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
213 } else { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
214 jio_snprintf(hr_buffer, buffer_length, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
215 HR_FORMAT, HR_FORMAT_PARAMS(alloc_region)); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
216 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
217 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
218 if (G1_ALLOC_REGION_TRACING > 1) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
219 if (result != NULL) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
220 jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT" "PTR_FORMAT, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
221 word_size, result); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
222 } else if (word_size != 0) { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
223 jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT, word_size); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
224 } else { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
225 jio_snprintf(rest_buffer, buffer_length, ""); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
226 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
227 } else { |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
228 jio_snprintf(rest_buffer, buffer_length, ""); |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
229 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
230 |
6010
720b6a76dd9d
7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents:
3830
diff
changeset
|
231 tty->print_cr("[%s] %u %s : %s %s", |
3830
f44782f04dd4
7039627: G1: avoid BOT updates for survivor allocations and dirty survivor regions incrementally
tonyp
parents:
2433
diff
changeset
|
232 _name, _count, hr_buffer, str, rest_buffer); |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
233 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
234 } |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
235 #endif // G1_ALLOC_REGION_TRACING |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
236 |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
237 G1AllocRegion::G1AllocRegion(const char* name, |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
238 bool bot_updates) |
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
239 : _name(name), _bot_updates(bot_updates), |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
240 _alloc_region(NULL), _count(0), _used_bytes_before(0), |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
241 _allocation_context(AllocationContext::system()) { } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
242 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
243 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
244 HeapRegion* MutatorAllocRegion::allocate_new_region(size_t word_size, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
245 bool force) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
246 return _g1h->new_mutator_alloc_region(word_size, force); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
247 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
248 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
249 void MutatorAllocRegion::retire_region(HeapRegion* alloc_region, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
250 size_t allocated_bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
251 _g1h->retire_mutator_alloc_region(alloc_region, allocated_bytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
252 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
253 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
254 HeapRegion* SurvivorGCAllocRegion::allocate_new_region(size_t word_size, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
255 bool force) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
256 assert(!force, "not supported for GC alloc regions"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
257 return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForSurvived); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
258 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
259 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
260 void SurvivorGCAllocRegion::retire_region(HeapRegion* alloc_region, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
261 size_t allocated_bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
262 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
263 GCAllocForSurvived); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
264 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
265 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
266 HeapRegion* OldGCAllocRegion::allocate_new_region(size_t word_size, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
267 bool force) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
268 assert(!force, "not supported for GC alloc regions"); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
269 return _g1h->new_gc_alloc_region(word_size, count(), GCAllocForTenured); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
270 } |
2433
abdfc822206f
7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff
changeset
|
271 |
20404
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
272 void OldGCAllocRegion::retire_region(HeapRegion* alloc_region, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
273 size_t allocated_bytes) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
274 _g1h->retire_gc_alloc_region(alloc_region, allocated_bytes, |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
275 GCAllocForTenured); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
276 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
277 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
278 HeapRegion* OldGCAllocRegion::release() { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
279 HeapRegion* cur = get(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
280 if (cur != NULL) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
281 // Determine how far we are from the next card boundary. If it is smaller than |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
282 // the minimum object size we can allocate into, expand into the next card. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
283 HeapWord* top = cur->top(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
284 HeapWord* aligned_top = (HeapWord*)align_ptr_up(top, G1BlockOffsetSharedArray::N_bytes); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
285 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
286 size_t to_allocate_words = pointer_delta(aligned_top, top, HeapWordSize); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
287 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
288 if (to_allocate_words != 0) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
289 // We are not at a card boundary. Fill up, possibly into the next, taking the |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
290 // end of the region and the minimum object size into account. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
291 to_allocate_words = MIN2(pointer_delta(cur->end(), cur->top(), HeapWordSize), |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
292 MAX2(to_allocate_words, G1CollectedHeap::min_fill_size())); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
293 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
294 // Skip allocation if there is not enough space to allocate even the smallest |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
295 // possible object. In this case this region will not be retained, so the |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
296 // original problem cannot occur. |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
297 if (to_allocate_words >= G1CollectedHeap::min_fill_size()) { |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
298 HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
299 CollectedHeap::fill_with_object(dummy, to_allocate_words); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
300 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
301 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
302 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
303 return G1AllocRegion::release(); |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
304 } |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
305 |
227a9e5e4b4a
8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
20197
diff
changeset
|
306 |