Mercurial > hg > truffle
annotate src/share/vm/memory/space.cpp @ 20311:b1bc1af04c6e
8052081: Optimize generated by C2 code for Intel's Atom processor
Summary: Allow to execute vectorization and crc32 optimization on Atom. Enable UseFPUForSpilling by default on x86.
Reviewed-by: roland
author | kvn |
---|---|
date | Tue, 05 Aug 2014 15:02:10 -0700 |
parents | 1526a938e670 |
children | ee019285a52c |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
0 | 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:
1142
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
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:
1142
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "gc_implementation/shared/liveRange.hpp" | |
29 #include "gc_implementation/shared/markSweep.hpp" | |
30 #include "gc_implementation/shared/spaceDecorator.hpp" | |
31 #include "memory/blockOffsetTable.inline.hpp" | |
32 #include "memory/defNewGeneration.hpp" | |
33 #include "memory/genCollectedHeap.hpp" | |
34 #include "memory/space.hpp" | |
35 #include "memory/space.inline.hpp" | |
36 #include "memory/universe.inline.hpp" | |
37 #include "oops/oop.inline.hpp" | |
38 #include "oops/oop.inline2.hpp" | |
39 #include "runtime/java.hpp" | |
20198
c49dcaf78a65
8042737: Introduce umbrella header prefetch.inline.hpp
goetz
parents:
20197
diff
changeset
|
40 #include "runtime/prefetch.inline.hpp" |
20197
ce8f6bb717c9
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
17937
diff
changeset
|
41 #include "runtime/orderAccess.inline.hpp" |
1972 | 42 #include "runtime/safepoint.hpp" |
43 #include "utilities/copy.hpp" | |
44 #include "utilities/globalDefinitions.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7448
diff
changeset
|
45 #include "utilities/macros.hpp" |
0 | 46 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
47 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17467
diff
changeset
|
48 |
0 | 49 HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top, |
50 HeapWord* top_obj) { | |
51 if (top_obj != NULL) { | |
52 if (_sp->block_is_obj(top_obj)) { | |
53 if (_precision == CardTableModRefBS::ObjHeadPreciseArray) { | |
54 if (oop(top_obj)->is_objArray() || oop(top_obj)->is_typeArray()) { | |
55 // An arrayOop is starting on the dirty card - since we do exact | |
56 // store checks for objArrays we are done. | |
57 } else { | |
58 // Otherwise, it is possible that the object starting on the dirty | |
59 // card spans the entire card, and that the store happened on a | |
60 // later card. Figure out where the object ends. | |
61 // Use the block_size() method of the space over which | |
62 // the iteration is being done. That space (e.g. CMS) may have | |
63 // specific requirements on object sizes which will | |
64 // be reflected in the block_size() method. | |
65 top = top_obj + oop(top_obj)->size(); | |
66 } | |
67 } | |
68 } else { | |
69 top = top_obj; | |
70 } | |
71 } else { | |
72 assert(top == _sp->end(), "only case where top_obj == NULL"); | |
73 } | |
74 return top; | |
75 } | |
76 | |
77 void DirtyCardToOopClosure::walk_mem_region(MemRegion mr, | |
78 HeapWord* bottom, | |
79 HeapWord* top) { | |
80 // 1. Blocks may or may not be objects. | |
81 // 2. Even when a block_is_obj(), it may not entirely | |
82 // occupy the block if the block quantum is larger than | |
83 // the object size. | |
84 // We can and should try to optimize by calling the non-MemRegion | |
85 // version of oop_iterate() for all but the extremal objects | |
86 // (for which we need to call the MemRegion version of | |
87 // oop_iterate()) To be done post-beta XXX | |
88 for (; bottom < top; bottom += _sp->block_size(bottom)) { | |
89 // As in the case of contiguous space above, we'd like to | |
90 // just use the value returned by oop_iterate to increment the | |
91 // current pointer; unfortunately, that won't work in CMS because | |
92 // we'd need an interface change (it seems) to have the space | |
93 // "adjust the object size" (for instance pad it up to its | |
94 // block alignment or minimum block size restrictions. XXX | |
95 if (_sp->block_is_obj(bottom) && | |
96 !_sp->obj_allocated_since_save_marks(oop(bottom))) { | |
97 oop(bottom)->oop_iterate(_cl, mr); | |
98 } | |
99 } | |
100 } | |
101 | |
3357
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
102 // We get called with "mr" representing the dirty region |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
103 // that we want to process. Because of imprecise marking, |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
104 // we may need to extend the incoming "mr" to the right, |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
105 // and scan more. However, because we may already have |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
106 // scanned some of that extended region, we may need to |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
107 // trim its right-end back some so we do not scan what |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
108 // we (or another worker thread) may already have scanned |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
109 // or planning to scan. |
0 | 110 void DirtyCardToOopClosure::do_MemRegion(MemRegion mr) { |
111 | |
112 // Some collectors need to do special things whenever their dirty | |
113 // cards are processed. For instance, CMS must remember mutator updates | |
114 // (i.e. dirty cards) so as to re-scan mutated objects. | |
115 // Such work can be piggy-backed here on dirty card scanning, so as to make | |
116 // it slightly more efficient than doing a complete non-detructive pre-scan | |
117 // of the card table. | |
118 MemRegionClosure* pCl = _sp->preconsumptionDirtyCardClosure(); | |
119 if (pCl != NULL) { | |
120 pCl->do_MemRegion(mr); | |
121 } | |
122 | |
123 HeapWord* bottom = mr.start(); | |
124 HeapWord* last = mr.last(); | |
125 HeapWord* top = mr.end(); | |
126 HeapWord* bottom_obj; | |
127 HeapWord* top_obj; | |
128 | |
129 assert(_precision == CardTableModRefBS::ObjHeadPreciseArray || | |
130 _precision == CardTableModRefBS::Precise, | |
131 "Only ones we deal with for now."); | |
132 | |
133 assert(_precision != CardTableModRefBS::ObjHeadPreciseArray || | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
134 _cl->idempotent() || _last_bottom == NULL || |
0 | 135 top <= _last_bottom, |
136 "Not decreasing"); | |
137 NOT_PRODUCT(_last_bottom = mr.start()); | |
138 | |
139 bottom_obj = _sp->block_start(bottom); | |
140 top_obj = _sp->block_start(last); | |
141 | |
142 assert(bottom_obj <= bottom, "just checking"); | |
143 assert(top_obj <= top, "just checking"); | |
144 | |
145 // Given what we think is the top of the memory region and | |
146 // the start of the object at the top, get the actual | |
147 // value of the top. | |
148 top = get_actual_top(top, top_obj); | |
149 | |
150 // If the previous call did some part of this region, don't redo. | |
151 if (_precision == CardTableModRefBS::ObjHeadPreciseArray && | |
152 _min_done != NULL && | |
153 _min_done < top) { | |
154 top = _min_done; | |
155 } | |
156 | |
157 // Top may have been reset, and in fact may be below bottom, | |
158 // e.g. the dirty card region is entirely in a now free object | |
159 // -- something that could happen with a concurrent sweeper. | |
160 bottom = MIN2(bottom, top); | |
3357
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
161 MemRegion extended_mr = MemRegion(bottom, top); |
0 | 162 assert(bottom <= top && |
163 (_precision != CardTableModRefBS::ObjHeadPreciseArray || | |
164 _min_done == NULL || | |
165 top <= _min_done), | |
166 "overlap!"); | |
167 | |
168 // Walk the region if it is not empty; otherwise there is nothing to do. | |
3357
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
169 if (!extended_mr.is_empty()) { |
fc2b798ab316
6883834: ParNew: assert(!_g->to()->is_in_reserved(obj),"Scanning field twice?") with LargeObjects tests
ysr
parents:
2433
diff
changeset
|
170 walk_mem_region(extended_mr, bottom_obj, top); |
0 | 171 } |
172 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
173 // An idempotent closure might be applied in any order, so we don't |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
174 // record a _min_done for it. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
175 if (!_cl->idempotent()) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
176 _min_done = bottom; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
177 } else { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
178 assert(_min_done == _last_explicit_min_done, |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
179 "Don't update _min_done for idempotent cl"); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
180 } |
0 | 181 } |
182 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6008
diff
changeset
|
183 DirtyCardToOopClosure* Space::new_dcto_cl(ExtendedOopClosure* cl, |
0 | 184 CardTableModRefBS::PrecisionStyle precision, |
185 HeapWord* boundary) { | |
186 return new DirtyCardToOopClosure(this, cl, precision, boundary); | |
187 } | |
188 | |
189 HeapWord* ContiguousSpaceDCTOC::get_actual_top(HeapWord* top, | |
190 HeapWord* top_obj) { | |
191 if (top_obj != NULL && top_obj < (_sp->toContiguousSpace())->top()) { | |
192 if (_precision == CardTableModRefBS::ObjHeadPreciseArray) { | |
193 if (oop(top_obj)->is_objArray() || oop(top_obj)->is_typeArray()) { | |
194 // An arrayOop is starting on the dirty card - since we do exact | |
195 // store checks for objArrays we are done. | |
196 } else { | |
197 // Otherwise, it is possible that the object starting on the dirty | |
198 // card spans the entire card, and that the store happened on a | |
199 // later card. Figure out where the object ends. | |
200 assert(_sp->block_size(top_obj) == (size_t) oop(top_obj)->size(), | |
201 "Block size and object size mismatch"); | |
202 top = top_obj + oop(top_obj)->size(); | |
203 } | |
204 } | |
205 } else { | |
206 top = (_sp->toContiguousSpace())->top(); | |
207 } | |
208 return top; | |
209 } | |
210 | |
211 void Filtering_DCTOC::walk_mem_region(MemRegion mr, | |
212 HeapWord* bottom, | |
213 HeapWord* top) { | |
214 // Note that this assumption won't hold if we have a concurrent | |
215 // collector in this space, which may have freed up objects after | |
216 // they were dirtied and before the stop-the-world GC that is | |
217 // examining cards here. | |
218 assert(bottom < top, "ought to be at least one obj on a dirty card."); | |
219 | |
220 if (_boundary != NULL) { | |
221 // We have a boundary outside of which we don't want to look | |
222 // at objects, so create a filtering closure around the | |
223 // oop closure before walking the region. | |
224 FilteringClosure filter(_boundary, _cl); | |
225 walk_mem_region_with_cl(mr, bottom, top, &filter); | |
226 } else { | |
227 // No boundary, simply walk the heap with the oop closure. | |
228 walk_mem_region_with_cl(mr, bottom, top, _cl); | |
229 } | |
230 | |
231 } | |
232 | |
233 // We must replicate this so that the static type of "FilteringClosure" | |
234 // (see above) is apparent at the oop_iterate calls. | |
235 #define ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(ClosureType) \ | |
236 void ContiguousSpaceDCTOC::walk_mem_region_with_cl(MemRegion mr, \ | |
237 HeapWord* bottom, \ | |
238 HeapWord* top, \ | |
239 ClosureType* cl) { \ | |
240 bottom += oop(bottom)->oop_iterate(cl, mr); \ | |
241 if (bottom < top) { \ | |
242 HeapWord* next_obj = bottom + oop(bottom)->size(); \ | |
243 while (next_obj < top) { \ | |
244 /* Bottom lies entirely below top, so we can call the */ \ | |
245 /* non-memRegion version of oop_iterate below. */ \ | |
246 oop(bottom)->oop_iterate(cl); \ | |
247 bottom = next_obj; \ | |
248 next_obj = bottom + oop(bottom)->size(); \ | |
249 } \ | |
250 /* Last object. */ \ | |
251 oop(bottom)->oop_iterate(cl, mr); \ | |
252 } \ | |
253 } | |
254 | |
255 // (There are only two of these, rather than N, because the split is due | |
256 // only to the introduction of the FilteringClosure, a local part of the | |
257 // impl of this abstraction.) | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6008
diff
changeset
|
258 ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(ExtendedOopClosure) |
0 | 259 ContiguousSpaceDCTOC__walk_mem_region_with_cl_DEFN(FilteringClosure) |
260 | |
261 DirtyCardToOopClosure* | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6008
diff
changeset
|
262 ContiguousSpace::new_dcto_cl(ExtendedOopClosure* cl, |
0 | 263 CardTableModRefBS::PrecisionStyle precision, |
264 HeapWord* boundary) { | |
265 return new ContiguousSpaceDCTOC(this, cl, precision, boundary); | |
266 } | |
267 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
268 void Space::initialize(MemRegion mr, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
269 bool clear_space, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
270 bool mangle_space) { |
0 | 271 HeapWord* bottom = mr.start(); |
272 HeapWord* end = mr.end(); | |
273 assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), | |
274 "invalid space boundaries"); | |
275 set_bottom(bottom); | |
276 set_end(end); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
277 if (clear_space) clear(mangle_space); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
278 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
279 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
280 void Space::clear(bool mangle_space) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
281 if (ZapUnusedHeapArea && mangle_space) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
282 mangle_unused_area(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
283 } |
0 | 284 } |
285 | |
356 | 286 ContiguousSpace::ContiguousSpace(): CompactibleSpace(), _top(NULL), |
287 _concurrent_iteration_safe_limit(NULL) { | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
288 _mangler = new GenSpaceMangler(this); |
0 | 289 } |
290 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
291 ContiguousSpace::~ContiguousSpace() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
292 delete _mangler; |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
293 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
294 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
295 void ContiguousSpace::initialize(MemRegion mr, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
296 bool clear_space, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
297 bool mangle_space) |
0 | 298 { |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
299 CompactibleSpace::initialize(mr, clear_space, mangle_space); |
347
60fb9c4db4e6
6718086: CMS assert: _concurrent_iteration_safe_limit update missed
ysr
parents:
344
diff
changeset
|
300 set_concurrent_iteration_safe_limit(top()); |
0 | 301 } |
302 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
303 void ContiguousSpace::clear(bool mangle_space) { |
0 | 304 set_top(bottom()); |
305 set_saved_mark(); | |
356 | 306 CompactibleSpace::clear(mangle_space); |
0 | 307 } |
308 | |
309 bool ContiguousSpace::is_free_block(const HeapWord* p) const { | |
310 return p >= _top; | |
311 } | |
312 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
313 void OffsetTableContigSpace::clear(bool mangle_space) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
314 ContiguousSpace::clear(mangle_space); |
0 | 315 _offsets.initialize_threshold(); |
316 } | |
317 | |
318 void OffsetTableContigSpace::set_bottom(HeapWord* new_bottom) { | |
319 Space::set_bottom(new_bottom); | |
320 _offsets.set_bottom(new_bottom); | |
321 } | |
322 | |
323 void OffsetTableContigSpace::set_end(HeapWord* new_end) { | |
324 // Space should not advertize an increase in size | |
325 // until after the underlying offest table has been enlarged. | |
326 _offsets.resize(pointer_delta(new_end, bottom())); | |
327 Space::set_end(new_end); | |
328 } | |
329 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
330 #ifndef PRODUCT |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
331 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
332 void ContiguousSpace::set_top_for_allocations(HeapWord* v) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
333 mangler()->set_top_for_allocations(v); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
334 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
335 void ContiguousSpace::set_top_for_allocations() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
336 mangler()->set_top_for_allocations(top()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
337 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
338 void ContiguousSpace::check_mangled_unused_area(HeapWord* limit) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
339 mangler()->check_mangled_unused_area(limit); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
340 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
341 |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
342 void ContiguousSpace::check_mangled_unused_area_complete() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
343 mangler()->check_mangled_unused_area_complete(); |
0 | 344 } |
345 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
346 // Mangled only the unused space that has not previously |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
347 // been mangled and that has not been allocated since being |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
348 // mangled. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
349 void ContiguousSpace::mangle_unused_area() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
350 mangler()->mangle_unused_area(); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
351 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
352 void ContiguousSpace::mangle_unused_area_complete() { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
353 mangler()->mangle_unused_area_complete(); |
0 | 354 } |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
355 void ContiguousSpace::mangle_region(MemRegion mr) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
356 // Although this method uses SpaceMangler::mangle_region() which |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
357 // is not specific to a space, the when the ContiguousSpace version |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
358 // is called, it is always with regard to a space and this |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
359 // bounds checking is appropriate. |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
360 MemRegion space_mr(bottom(), end()); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
361 assert(space_mr.contains(mr), "Mangling outside space"); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
362 SpaceMangler::mangle_region(mr); |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
363 } |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
364 #endif // NOT_PRODUCT |
0 | 365 |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
366 void CompactibleSpace::initialize(MemRegion mr, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
367 bool clear_space, |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
368 bool mangle_space) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
369 Space::initialize(mr, clear_space, mangle_space); |
356 | 370 set_compaction_top(bottom()); |
371 _next_compaction_space = NULL; | |
372 } | |
373 | |
374 void CompactibleSpace::clear(bool mangle_space) { | |
375 Space::clear(mangle_space); | |
0 | 376 _compaction_top = bottom(); |
377 } | |
378 | |
379 HeapWord* CompactibleSpace::forward(oop q, size_t size, | |
380 CompactPoint* cp, HeapWord* compact_top) { | |
381 // q is alive | |
382 // First check if we should switch compaction space | |
383 assert(this == cp->space, "'this' should be current compaction space."); | |
384 size_t compaction_max_size = pointer_delta(end(), compact_top); | |
385 while (size > compaction_max_size) { | |
386 // switch to next compaction space | |
387 cp->space->set_compaction_top(compact_top); | |
388 cp->space = cp->space->next_compaction_space(); | |
389 if (cp->space == NULL) { | |
390 cp->gen = GenCollectedHeap::heap()->prev_gen(cp->gen); | |
391 assert(cp->gen != NULL, "compaction must succeed"); | |
392 cp->space = cp->gen->first_compaction_space(); | |
393 assert(cp->space != NULL, "generation must have a first compaction space"); | |
394 } | |
395 compact_top = cp->space->bottom(); | |
396 cp->space->set_compaction_top(compact_top); | |
397 cp->threshold = cp->space->initialize_threshold(); | |
398 compaction_max_size = pointer_delta(cp->space->end(), compact_top); | |
399 } | |
400 | |
401 // store the forwarding pointer into the mark word | |
402 if ((HeapWord*)q != compact_top) { | |
403 q->forward_to(oop(compact_top)); | |
404 assert(q->is_gc_marked(), "encoding the pointer should preserve the mark"); | |
405 } else { | |
406 // if the object isn't moving we can just set the mark to the default | |
407 // mark and handle it specially later on. | |
408 q->init_mark(); | |
409 assert(q->forwardee() == NULL, "should be forwarded to NULL"); | |
410 } | |
411 | |
412 compact_top += size; | |
413 | |
414 // we need to update the offset table so that the beginnings of objects can be | |
415 // found during scavenge. Note that we are updating the offset table based on | |
416 // where the object will be once the compaction phase finishes. | |
417 if (compact_top > cp->threshold) | |
418 cp->threshold = | |
419 cp->space->cross_threshold(compact_top - size, compact_top); | |
420 return compact_top; | |
421 } | |
422 | |
423 | |
424 bool CompactibleSpace::insert_deadspace(size_t& allowed_deadspace_words, | |
425 HeapWord* q, size_t deadlength) { | |
426 if (allowed_deadspace_words >= deadlength) { | |
427 allowed_deadspace_words -= deadlength; | |
481
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
438
diff
changeset
|
428 CollectedHeap::fill_with_object(q, deadlength); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
438
diff
changeset
|
429 oop(q)->set_mark(oop(q)->mark()->set_marked()); |
7d7a7c599c17
6578152: fill_region_with_object has usability and safety issues
jcoomes
parents:
438
diff
changeset
|
430 assert((int) deadlength == oop(q)->size(), "bad filler object size"); |
0 | 431 // Recall that we required "q == compaction_top". |
432 return true; | |
433 } else { | |
434 allowed_deadspace_words = 0; | |
435 return false; | |
436 } | |
437 } | |
438 | |
439 #define block_is_always_obj(q) true | |
440 #define obj_size(q) oop(q)->size() | |
441 #define adjust_obj_size(s) s | |
442 | |
443 void CompactibleSpace::prepare_for_compaction(CompactPoint* cp) { | |
444 SCAN_AND_FORWARD(cp, end, block_is_obj, block_size); | |
445 } | |
446 | |
447 // Faster object search. | |
448 void ContiguousSpace::prepare_for_compaction(CompactPoint* cp) { | |
449 SCAN_AND_FORWARD(cp, top, block_is_always_obj, obj_size); | |
450 } | |
451 | |
452 void Space::adjust_pointers() { | |
453 // adjust all the interior pointers to point at the new locations of objects | |
454 // Used by MarkSweep::mark_sweep_phase3() | |
455 | |
456 // First check to see if there is any work to be done. | |
457 if (used() == 0) { | |
458 return; // Nothing to do. | |
459 } | |
460 | |
461 // Otherwise... | |
462 HeapWord* q = bottom(); | |
463 HeapWord* t = end(); | |
464 | |
465 debug_only(HeapWord* prev_q = NULL); | |
466 while (q < t) { | |
467 if (oop(q)->is_gc_marked()) { | |
468 // q is alive | |
469 | |
470 // point all the oops to the new location | |
471 size_t size = oop(q)->adjust_pointers(); | |
472 | |
473 debug_only(prev_q = q); | |
474 | |
475 q += size; | |
476 } else { | |
477 // q is not a live object. But we're not in a compactible space, | |
478 // So we don't have live ranges. | |
479 debug_only(prev_q = q); | |
480 q += block_size(q); | |
481 assert(q > prev_q, "we should be moving forward through memory"); | |
482 } | |
483 } | |
484 assert(q == t, "just checking"); | |
485 } | |
486 | |
487 void CompactibleSpace::adjust_pointers() { | |
488 // Check first is there is any work to do. | |
489 if (used() == 0) { | |
490 return; // Nothing to do. | |
491 } | |
492 | |
493 SCAN_AND_ADJUST_POINTERS(adjust_obj_size); | |
494 } | |
495 | |
496 void CompactibleSpace::compact() { | |
497 SCAN_AND_COMPACT(obj_size); | |
498 } | |
499 | |
500 void Space::print_short() const { print_short_on(tty); } | |
501 | |
502 void Space::print_short_on(outputStream* st) const { | |
503 st->print(" space " SIZE_FORMAT "K, %3d%% used", capacity() / K, | |
504 (int) ((double) used() * 100 / capacity())); | |
505 } | |
506 | |
507 void Space::print() const { print_on(tty); } | |
508 | |
509 void Space::print_on(outputStream* st) const { | |
510 print_short_on(st); | |
511 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ")", | |
512 bottom(), end()); | |
513 } | |
514 | |
515 void ContiguousSpace::print_on(outputStream* st) const { | |
516 print_short_on(st); | |
517 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", | |
518 bottom(), top(), end()); | |
519 } | |
520 | |
521 void OffsetTableContigSpace::print_on(outputStream* st) const { | |
522 print_short_on(st); | |
523 st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " | |
524 INTPTR_FORMAT ", " INTPTR_FORMAT ")", | |
525 bottom(), top(), _offsets.threshold(), end()); | |
526 } | |
527 | |
6008 | 528 void ContiguousSpace::verify() const { |
0 | 529 HeapWord* p = bottom(); |
530 HeapWord* t = top(); | |
531 HeapWord* prev_p = NULL; | |
532 while (p < t) { | |
533 oop(p)->verify(); | |
534 prev_p = p; | |
535 p += oop(p)->size(); | |
536 } | |
537 guarantee(p == top(), "end of last object must match end of space"); | |
538 if (top() != end()) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
539 guarantee(top() == block_start_const(end()-1) && |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
540 top() == block_start_const(top()), |
0 | 541 "top should be start of unallocated block, if it exists"); |
542 } | |
543 } | |
544 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6008
diff
changeset
|
545 void Space::oop_iterate(ExtendedOopClosure* blk) { |
0 | 546 ObjectToOopClosure blk2(blk); |
547 object_iterate(&blk2); | |
548 } | |
549 | |
550 bool Space::obj_is_alive(const HeapWord* p) const { | |
551 assert (block_is_obj(p), "The address should point to an object"); | |
552 return true; | |
553 } | |
554 | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7448
diff
changeset
|
555 #if INCLUDE_ALL_GCS |
0 | 556 #define ContigSpace_PAR_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
557 \ | |
558 void ContiguousSpace::par_oop_iterate(MemRegion mr, OopClosureType* blk) {\ | |
559 HeapWord* obj_addr = mr.start(); \ | |
560 HeapWord* t = mr.end(); \ | |
561 while (obj_addr < t) { \ | |
562 assert(oop(obj_addr)->is_oop(), "Should be an oop"); \ | |
563 obj_addr += oop(obj_addr)->oop_iterate(blk); \ | |
564 } \ | |
565 } | |
566 | |
567 ALL_PAR_OOP_ITERATE_CLOSURES(ContigSpace_PAR_OOP_ITERATE_DEFN) | |
568 | |
569 #undef ContigSpace_PAR_OOP_ITERATE_DEFN | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
7448
diff
changeset
|
570 #endif // INCLUDE_ALL_GCS |
0 | 571 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6008
diff
changeset
|
572 void ContiguousSpace::oop_iterate(ExtendedOopClosure* blk) { |
0 | 573 if (is_empty()) return; |
574 HeapWord* obj_addr = bottom(); | |
575 HeapWord* t = top(); | |
576 // Could call objects iterate, but this is easier. | |
577 while (obj_addr < t) { | |
578 obj_addr += oop(obj_addr)->oop_iterate(blk); | |
579 } | |
580 } | |
581 | |
582 void ContiguousSpace::object_iterate(ObjectClosure* blk) { | |
583 if (is_empty()) return; | |
584 WaterMark bm = bottom_mark(); | |
585 object_iterate_from(bm, blk); | |
586 } | |
587 | |
517
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
588 // For a continguous space object_iterate() and safe_object_iterate() |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
589 // are the same. |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
590 void ContiguousSpace::safe_object_iterate(ObjectClosure* blk) { |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
591 object_iterate(blk); |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
592 } |
e9be0e04635a
6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
jmasa
parents:
481
diff
changeset
|
593 |
0 | 594 void ContiguousSpace::object_iterate_from(WaterMark mark, ObjectClosure* blk) { |
595 assert(mark.space() == this, "Mark does not match space"); | |
596 HeapWord* p = mark.point(); | |
597 while (p < top()) { | |
598 blk->do_object(oop(p)); | |
599 p += oop(p)->size(); | |
600 } | |
601 } | |
602 | |
603 HeapWord* | |
604 ContiguousSpace::object_iterate_careful(ObjectClosureCareful* blk) { | |
605 HeapWord * limit = concurrent_iteration_safe_limit(); | |
606 assert(limit <= top(), "sanity check"); | |
607 for (HeapWord* p = bottom(); p < limit;) { | |
608 size_t size = blk->do_object_careful(oop(p)); | |
609 if (size == 0) { | |
610 return p; // failed at p | |
611 } else { | |
612 p += size; | |
613 } | |
614 } | |
615 return NULL; // all done | |
616 } | |
617 | |
618 #define ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN(OopClosureType, nv_suffix) \ | |
619 \ | |
620 void ContiguousSpace:: \ | |
621 oop_since_save_marks_iterate##nv_suffix(OopClosureType* blk) { \ | |
622 HeapWord* t; \ | |
623 HeapWord* p = saved_mark_word(); \ | |
624 assert(p != NULL, "expected saved mark"); \ | |
625 \ | |
626 const intx interval = PrefetchScanIntervalInBytes; \ | |
627 do { \ | |
628 t = top(); \ | |
629 while (p < t) { \ | |
630 Prefetch::write(p, interval); \ | |
631 debug_only(HeapWord* prev = p); \ | |
632 oop m = oop(p); \ | |
633 p += m->oop_iterate(blk); \ | |
634 } \ | |
635 } while (t < top()); \ | |
636 \ | |
637 set_saved_mark_word(p); \ | |
638 } | |
639 | |
640 ALL_SINCE_SAVE_MARKS_CLOSURES(ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN) | |
641 | |
642 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN | |
643 | |
644 // Very general, slow implementation. | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
645 HeapWord* ContiguousSpace::block_start_const(const void* p) const { |
7181
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
646 assert(MemRegion(bottom(), end()).contains(p), |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
647 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
648 p, bottom(), end())); |
0 | 649 if (p >= top()) { |
650 return top(); | |
651 } else { | |
652 HeapWord* last = bottom(); | |
653 HeapWord* cur = last; | |
654 while (cur <= p) { | |
655 last = cur; | |
656 cur += oop(cur)->size(); | |
657 } | |
7181
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
658 assert(oop(last)->is_oop(), |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
659 err_msg(PTR_FORMAT " should be an object start", last)); |
0 | 660 return last; |
661 } | |
662 } | |
663 | |
664 size_t ContiguousSpace::block_size(const HeapWord* p) const { | |
7181
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
665 assert(MemRegion(bottom(), end()).contains(p), |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
666 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
667 p, bottom(), end())); |
0 | 668 HeapWord* current_top = top(); |
7181
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
669 assert(p <= current_top, |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
670 err_msg("p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT, |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
671 p, current_top)); |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
672 assert(p == current_top || oop(p)->is_oop(), |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
673 err_msg("p (" PTR_FORMAT ") is not a block start - " |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
674 "current_top: " PTR_FORMAT ", is_oop: %s", |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
675 p, current_top, BOOL_TO_STR(oop(p)->is_oop()))); |
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
676 if (p < current_top) { |
0 | 677 return oop(p)->size(); |
7181
2fc0334f613a
7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents:
6725
diff
changeset
|
678 } else { |
0 | 679 assert(p == current_top, "just checking"); |
680 return pointer_delta(end(), (HeapWord*) p); | |
681 } | |
682 } | |
683 | |
684 // This version requires locking. | |
685 inline HeapWord* ContiguousSpace::allocate_impl(size_t size, | |
686 HeapWord* const end_value) { | |
687 assert(Heap_lock->owned_by_self() || | |
20276
1526a938e670
8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents:
20267
diff
changeset
|
688 (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), |
0 | 689 "not locked"); |
690 HeapWord* obj = top(); | |
691 if (pointer_delta(end_value, obj) >= size) { | |
692 HeapWord* new_top = obj + size; | |
693 set_top(new_top); | |
694 assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); | |
695 return obj; | |
696 } else { | |
697 return NULL; | |
698 } | |
699 } | |
700 | |
701 // This version is lock-free. | |
702 inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size, | |
703 HeapWord* const end_value) { | |
704 do { | |
705 HeapWord* obj = top(); | |
706 if (pointer_delta(end_value, obj) >= size) { | |
707 HeapWord* new_top = obj + size; | |
708 HeapWord* result = (HeapWord*)Atomic::cmpxchg_ptr(new_top, top_addr(), obj); | |
709 // result can be one of two: | |
710 // the old top value: the exchange succeeded | |
711 // otherwise: the new value of the top is returned. | |
712 if (result == obj) { | |
713 assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); | |
714 return obj; | |
715 } | |
716 } else { | |
717 return NULL; | |
718 } | |
719 } while (true); | |
720 } | |
721 | |
722 // Requires locking. | |
723 HeapWord* ContiguousSpace::allocate(size_t size) { | |
724 return allocate_impl(size, end()); | |
725 } | |
726 | |
727 // Lock-free. | |
728 HeapWord* ContiguousSpace::par_allocate(size_t size) { | |
729 return par_allocate_impl(size, end()); | |
730 } | |
731 | |
732 void ContiguousSpace::allocate_temporary_filler(int factor) { | |
733 // allocate temporary type array decreasing free size with factor 'factor' | |
734 assert(factor >= 0, "just checking"); | |
735 size_t size = pointer_delta(end(), top()); | |
736 | |
737 // if space is full, return | |
738 if (size == 0) return; | |
739 | |
740 if (factor > 0) { | |
741 size -= size/factor; | |
742 } | |
743 size = align_object_size(size); | |
744 | |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1142
diff
changeset
|
745 const size_t array_header_size = typeArrayOopDesc::header_size(T_INT); |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1142
diff
changeset
|
746 if (size >= (size_t)align_object_size(array_header_size)) { |
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1142
diff
changeset
|
747 size_t length = (size - array_header_size) * (HeapWordSize / sizeof(jint)); |
0 | 748 // allocate uninitialized int array |
749 typeArrayOop t = (typeArrayOop) allocate(size); | |
750 assert(t != NULL, "allocation should succeed"); | |
751 t->set_mark(markOopDesc::prototype()); | |
752 t->set_klass(Universe::intArrayKlassObj()); | |
753 t->set_length((int)length); | |
754 } else { | |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
1142
diff
changeset
|
755 assert(size == CollectedHeap::min_fill_size(), |
0 | 756 "size for smallest fake object doesn't match"); |
757 instanceOop obj = (instanceOop) allocate(size); | |
758 obj->set_mark(markOopDesc::prototype()); | |
167
feeb96a45707
6696264: assert("narrow oop can never be zero") for GCBasher & ParNewGC
coleenp
parents:
113
diff
changeset
|
759 obj->set_klass_gap(0); |
1142 | 760 obj->set_klass(SystemDictionary::Object_klass()); |
0 | 761 } |
762 } | |
763 | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
764 void EdenSpace::clear(bool mangle_space) { |
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
765 ContiguousSpace::clear(mangle_space); |
0 | 766 set_soft_end(end()); |
767 } | |
768 | |
769 // Requires locking. | |
770 HeapWord* EdenSpace::allocate(size_t size) { | |
771 return allocate_impl(size, soft_end()); | |
772 } | |
773 | |
774 // Lock-free. | |
775 HeapWord* EdenSpace::par_allocate(size_t size) { | |
776 return par_allocate_impl(size, soft_end()); | |
777 } | |
778 | |
779 HeapWord* ConcEdenSpace::par_allocate(size_t size) | |
780 { | |
781 do { | |
782 // The invariant is top() should be read before end() because | |
783 // top() can't be greater than end(), so if an update of _soft_end | |
784 // occurs between 'end_val = end();' and 'top_val = top();' top() | |
785 // also can grow up to the new end() and the condition | |
786 // 'top_val > end_val' is true. To ensure the loading order | |
787 // OrderAccess::loadload() is required after top() read. | |
788 HeapWord* obj = top(); | |
789 OrderAccess::loadload(); | |
790 if (pointer_delta(*soft_end_addr(), obj) >= size) { | |
791 HeapWord* new_top = obj + size; | |
792 HeapWord* result = (HeapWord*)Atomic::cmpxchg_ptr(new_top, top_addr(), obj); | |
793 // result can be one of two: | |
794 // the old top value: the exchange succeeded | |
795 // otherwise: the new value of the top is returned. | |
796 if (result == obj) { | |
797 assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); | |
798 return obj; | |
799 } | |
800 } else { | |
801 return NULL; | |
802 } | |
803 } while (true); | |
804 } | |
805 | |
806 | |
807 HeapWord* OffsetTableContigSpace::initialize_threshold() { | |
808 return _offsets.initialize_threshold(); | |
809 } | |
810 | |
811 HeapWord* OffsetTableContigSpace::cross_threshold(HeapWord* start, HeapWord* end) { | |
812 _offsets.alloc_block(start, end); | |
813 return _offsets.threshold(); | |
814 } | |
815 | |
816 OffsetTableContigSpace::OffsetTableContigSpace(BlockOffsetSharedArray* sharedOffsetArray, | |
817 MemRegion mr) : | |
818 _offsets(sharedOffsetArray, mr), | |
819 _par_alloc_lock(Mutex::leaf, "OffsetTableContigSpace par alloc lock", true) | |
820 { | |
821 _offsets.set_contig_space(this); | |
263
12eea04c8b06
6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
167
diff
changeset
|
822 initialize(mr, SpaceDecorator::Clear, SpaceDecorator::Mangle); |
0 | 823 } |
824 | |
825 #define OBJ_SAMPLE_INTERVAL 0 | |
826 #define BLOCK_SAMPLE_INTERVAL 100 | |
827 | |
6008 | 828 void OffsetTableContigSpace::verify() const { |
0 | 829 HeapWord* p = bottom(); |
830 HeapWord* prev_p = NULL; | |
831 int objs = 0; | |
832 int blocks = 0; | |
833 | |
834 if (VerifyObjectStartArray) { | |
835 _offsets.verify(); | |
836 } | |
837 | |
838 while (p < top()) { | |
839 size_t size = oop(p)->size(); | |
840 // For a sampling of objects in the space, find it using the | |
841 // block offset table. | |
842 if (blocks == BLOCK_SAMPLE_INTERVAL) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
843 guarantee(p == block_start_const(p + (size/2)), |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
844 "check offset computation"); |
0 | 845 blocks = 0; |
846 } else { | |
847 blocks++; | |
848 } | |
849 | |
850 if (objs == OBJ_SAMPLE_INTERVAL) { | |
851 oop(p)->verify(); | |
852 objs = 0; | |
853 } else { | |
854 objs++; | |
855 } | |
856 prev_p = p; | |
857 p += size; | |
858 } | |
859 guarantee(p == top(), "end of last object must match end of space"); | |
860 } | |
861 | |
862 | |
438 | 863 size_t TenuredSpace::allowed_dead_ratio() const { |
0 | 864 return MarkSweepDeadRatio; |
865 } |