Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @ 2132:4947ee68d19c
7008136: CMS: assert((HeapWord*)nextChunk <= _limit) failed: sweep invariant
Summary: The recorded _sweep_limit may not necessarily remain a block boundary as the old generation expands during a concurrent cycle. Terminal actions inside the sweep closure need to be aware of this as they cross over the limit.
Reviewed-by: johnc, minqi
author | ysr |
---|---|
date | Thu, 06 Jan 2011 23:50:02 -0800 |
parents | 016a3628c885 |
children | b158bed62ef5 |
rev | line source |
---|---|
342 | 1 /* |
1972 | 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
342 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
752
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
752
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
752
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP | |
27 | |
28 #include "gc_implementation/g1/concurrentMark.hpp" | |
29 #include "gc_implementation/g1/g1CollectedHeap.hpp" | |
1973 | 30 #include "gc_implementation/g1/g1CollectorPolicy.hpp" |
1972 | 31 #include "gc_implementation/g1/heapRegionSeq.hpp" |
32 #include "utilities/taskqueue.hpp" | |
33 | |
342 | 34 // Inline functions for G1CollectedHeap |
35 | |
36 inline HeapRegion* | |
37 G1CollectedHeap::heap_region_containing(const void* addr) const { | |
38 HeapRegion* hr = _hrs->addr_to_region(addr); | |
39 // hr can be null if addr in perm_gen | |
40 if (hr != NULL && hr->continuesHumongous()) { | |
41 hr = hr->humongous_start_region(); | |
42 } | |
43 return hr; | |
44 } | |
45 | |
46 inline HeapRegion* | |
47 G1CollectedHeap::heap_region_containing_raw(const void* addr) const { | |
526 | 48 assert(_g1_reserved.contains(addr), "invariant"); |
752
a2957df801a1
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
579
diff
changeset
|
49 size_t index = pointer_delta(addr, _g1_reserved.start(), 1) |
a2957df801a1
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
579
diff
changeset
|
50 >> HeapRegion::LogOfHRGrainBytes; |
a2957df801a1
6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents:
579
diff
changeset
|
51 |
526 | 52 HeapRegion* res = _hrs->at(index); |
53 assert(res == _hrs->addr_to_region(addr), "sanity"); | |
342 | 54 return res; |
55 } | |
56 | |
57 inline bool G1CollectedHeap::obj_in_cs(oop obj) { | |
58 HeapRegion* r = _hrs->addr_to_region(obj); | |
59 return r != NULL && r->in_collection_set(); | |
60 } | |
61 | |
1973 | 62 // See the comment in the .hpp file about the locking protocol and |
63 // assumptions of this method (and other related ones). | |
64 inline HeapWord* | |
65 G1CollectedHeap::allocate_from_cur_alloc_region(HeapRegion* cur_alloc_region, | |
66 size_t word_size) { | |
67 assert_heap_locked_and_not_at_safepoint(); | |
68 assert(cur_alloc_region != NULL, "pre-condition of the method"); | |
69 assert(cur_alloc_region == _cur_alloc_region, "pre-condition of the method"); | |
70 assert(cur_alloc_region->is_young(), | |
71 "we only support young current alloc regions"); | |
72 assert(!isHumongous(word_size), "allocate_from_cur_alloc_region() " | |
73 "should not be used for humongous allocations"); | |
74 assert(!cur_alloc_region->isHumongous(), "Catch a regression of this bug."); | |
342 | 75 |
1973 | 76 assert(!cur_alloc_region->is_empty(), |
77 err_msg("region ["PTR_FORMAT","PTR_FORMAT"] should not be empty", | |
78 cur_alloc_region->bottom(), cur_alloc_region->end())); | |
79 // This allocate method does BOT updates and we don't need them in | |
80 // the young generation. This will be fixed in the near future by | |
81 // CR 6994297. | |
82 HeapWord* result = cur_alloc_region->allocate(word_size); | |
83 if (result != NULL) { | |
84 assert(is_in(result), "result should be in the heap"); | |
85 Heap_lock->unlock(); | |
342 | 86 |
1973 | 87 // Do the dirtying after we release the Heap_lock. |
88 dirty_young_block(result, word_size); | |
89 return result; | |
90 } | |
91 | |
92 assert_heap_locked(); | |
93 return NULL; | |
94 } | |
342 | 95 |
1973 | 96 // See the comment in the .hpp file about the locking protocol and |
97 // assumptions of this method (and other related ones). | |
98 inline HeapWord* | |
99 G1CollectedHeap::attempt_allocation(size_t word_size) { | |
100 assert_heap_locked_and_not_at_safepoint(); | |
101 assert(!isHumongous(word_size), "attempt_allocation() should not be called " | |
102 "for humongous allocation requests"); | |
103 | |
104 HeapRegion* cur_alloc_region = _cur_alloc_region; | |
105 if (cur_alloc_region != NULL) { | |
106 HeapWord* result = allocate_from_cur_alloc_region(cur_alloc_region, | |
107 word_size); | |
108 if (result != NULL) { | |
109 assert_heap_not_locked(); | |
110 return result; | |
342 | 111 } |
1718
bb847e31b836
6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents:
1709
diff
changeset
|
112 |
1973 | 113 assert_heap_locked(); |
114 | |
115 // Since we couldn't successfully allocate into it, retire the | |
116 // current alloc region. | |
117 retire_cur_alloc_region(cur_alloc_region); | |
118 } | |
119 | |
120 // Try to get a new region and allocate out of it | |
121 HeapWord* result = replace_cur_alloc_region_and_allocate(word_size, | |
1991
016a3628c885
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents:
1973
diff
changeset
|
122 false, /* at_safepoint */ |
016a3628c885
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents:
1973
diff
changeset
|
123 true, /* do_dirtying */ |
016a3628c885
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents:
1973
diff
changeset
|
124 false /* can_expand */); |
1973 | 125 if (result != NULL) { |
126 assert_heap_not_locked(); | |
127 return result; | |
342 | 128 } |
1973 | 129 |
130 assert_heap_locked(); | |
131 return NULL; | |
132 } | |
133 | |
134 inline void | |
135 G1CollectedHeap::retire_cur_alloc_region_common(HeapRegion* cur_alloc_region) { | |
136 assert_heap_locked_or_at_safepoint(); | |
137 assert(cur_alloc_region != NULL && cur_alloc_region == _cur_alloc_region, | |
138 "pre-condition of the call"); | |
139 assert(cur_alloc_region->is_young(), | |
140 "we only support young current alloc regions"); | |
141 | |
142 // The region is guaranteed to be young | |
143 g1_policy()->add_region_to_incremental_cset_lhs(cur_alloc_region); | |
144 _summary_bytes_used += cur_alloc_region->used(); | |
145 _cur_alloc_region = NULL; | |
146 } | |
147 | |
148 // It dirties the cards that cover the block so that so that the post | |
149 // write barrier never queues anything when updating objects on this | |
150 // block. It is assumed (and in fact we assert) that the block | |
151 // belongs to a young region. | |
152 inline void | |
153 G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) { | |
154 assert_heap_not_locked(); | |
155 | |
156 // Assign the containing region to containing_hr so that we don't | |
157 // have to keep calling heap_region_containing_raw() in the | |
158 // asserts below. | |
159 DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);) | |
160 assert(containing_hr != NULL && start != NULL && word_size > 0, | |
161 "pre-condition"); | |
162 assert(containing_hr->is_in(start), "it should contain start"); | |
163 assert(containing_hr->is_young(), "it should be young"); | |
164 assert(!containing_hr->isHumongous(), "it should not be humongous"); | |
165 | |
166 HeapWord* end = start + word_size; | |
167 assert(containing_hr->is_in(end - 1), "it should also contain end - 1"); | |
168 | |
169 MemRegion mr(start, end); | |
170 ((CardTableModRefBS*)_g1h->barrier_set())->dirty(mr); | |
342 | 171 } |
172 | |
1709 | 173 inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const { |
342 | 174 return _task_queues->queue(i); |
175 } | |
176 | |
177 inline bool G1CollectedHeap::isMarkedPrev(oop obj) const { | |
178 return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj); | |
179 } | |
180 | |
181 inline bool G1CollectedHeap::isMarkedNext(oop obj) const { | |
182 return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj); | |
183 } | |
1972 | 184 |
185 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP |