Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp @ 20356:439f0d76cff3
8029524: Remove unsused method CollectedHeap::unsafe_max_alloc()
Reviewed-by: pliden, jmasa
author | brutisso |
---|---|
date | Tue, 26 Aug 2014 10:28:43 +0200 |
parents | ee019285a52c |
children | 7848fc12602b |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14422
diff
changeset
|
2 * Copyright (c) 2002, 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:
845
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
845
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:
845
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP | |
27 | |
5962
8a729074feae
7154517: Build error in hotspot-gc without precompiled headers
nloodin
parents:
4909
diff
changeset
|
28 #include "gc_implementation/parallelScavenge/psOldGen.hpp" |
1972 | 29 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" |
20317
ee019285a52c
8031323: Optionally align objects copied to survivor spaces
jmasa
parents:
17937
diff
changeset
|
30 #include "gc_implementation/parallelScavenge/psPromotionLAB.inline.hpp" |
1972 | 31 #include "gc_implementation/parallelScavenge/psScavenge.hpp" |
14391 | 32 #include "oops/oop.psgc.inline.hpp" |
1972 | 33 |
0 | 34 inline PSPromotionManager* PSPromotionManager::manager_array(int index) { |
35 assert(_manager_array != NULL, "access of NULL manager_array"); | |
36 assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access"); | |
12029
9766f73e770d
8022880: False sharing between PSPromotionManager instances
stefank
parents:
10405
diff
changeset
|
37 return &_manager_array[index]; |
0 | 38 } |
39 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
40 template <class T> |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
41 inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
42 if (p != NULL) { // XXX: error if p != NULL here |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
43 oop o = oopDesc::load_decode_heap_oop_not_null(p); |
0 | 44 if (o->is_forwarded()) { |
45 o = o->forwardee(); | |
46 // Card mark | |
10370
47bdfb3d010f
8015486: PSScavenge::is_obj_in_young is unnecessarily slow with UseCompressedOops
stefank
parents:
6818
diff
changeset
|
47 if (PSScavenge::is_obj_in_young(o)) { |
0 | 48 PSScavenge::card_table()->inline_write_ref_field_gc(p, o); |
49 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
50 oopDesc::encode_store_heap_oop_not_null(p, o); |
0 | 51 } else { |
52 push_depth(p); | |
53 } | |
54 } | |
55 } | |
56 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
57 template <class T> |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
58 inline void PSPromotionManager::claim_or_forward_depth(T* p) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
59 assert(PSScavenge::should_scavenge(p, true), "revisiting object?"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
60 assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
61 "Sanity"); |
0 | 62 assert(Universe::heap()->is_in(p), "pointer outside heap"); |
63 | |
64 claim_or_forward_internal_depth(p); | |
65 } | |
66 | |
4909 | 67 // |
68 // This method is pretty bulky. It would be nice to split it up | |
69 // into smaller submethods, but we need to be careful not to hurt | |
70 // performance. | |
71 // | |
72 template<bool promote_immediately> | |
73 oop PSPromotionManager::copy_to_survivor_space(oop o) { | |
74 assert(PSScavenge::should_scavenge(&o), "Sanity"); | |
75 | |
76 oop new_obj = NULL; | |
77 | |
78 // NOTE! We must be very careful with any methods that access the mark | |
79 // in o. There may be multiple threads racing on it, and it may be forwarded | |
80 // at any time. Do not use oop methods for accessing the mark! | |
81 markOop test_mark = o->mark(); | |
82 | |
83 // The same test as "o->is_forwarded()" | |
84 if (!test_mark->is_marked()) { | |
85 bool new_obj_is_tenured = false; | |
86 size_t new_obj_size = o->size(); | |
87 | |
88 if (!promote_immediately) { | |
89 // Find the objects age, MT safe. | |
6818 | 90 uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? |
4909 | 91 test_mark->displaced_mark_helper()->age() : test_mark->age(); |
92 | |
93 // Try allocating obj in to-space (unless too old) | |
94 if (age < PSScavenge::tenuring_threshold()) { | |
95 new_obj = (oop) _young_lab.allocate(new_obj_size); | |
96 if (new_obj == NULL && !_young_gen_is_full) { | |
97 // Do we allocate directly, or flush and refill? | |
98 if (new_obj_size > (YoungPLABSize / 2)) { | |
99 // Allocate this object directly | |
100 new_obj = (oop)young_space()->cas_allocate(new_obj_size); | |
101 } else { | |
102 // Flush and fill | |
103 _young_lab.flush(); | |
104 | |
105 HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); | |
106 if (lab_base != NULL) { | |
107 _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); | |
108 // Try the young lab allocation again. | |
109 new_obj = (oop) _young_lab.allocate(new_obj_size); | |
110 } else { | |
111 _young_gen_is_full = true; | |
112 } | |
113 } | |
114 } | |
115 } | |
116 } | |
117 | |
118 // Otherwise try allocating obj tenured | |
119 if (new_obj == NULL) { | |
120 #ifndef PRODUCT | |
121 if (Universe::heap()->promotion_should_fail()) { | |
122 return oop_promotion_failed(o, test_mark); | |
123 } | |
124 #endif // #ifndef PRODUCT | |
125 | |
126 new_obj = (oop) _old_lab.allocate(new_obj_size); | |
127 new_obj_is_tenured = true; | |
128 | |
129 if (new_obj == NULL) { | |
130 if (!_old_gen_is_full) { | |
131 // Do we allocate directly, or flush and refill? | |
132 if (new_obj_size > (OldPLABSize / 2)) { | |
133 // Allocate this object directly | |
134 new_obj = (oop)old_gen()->cas_allocate(new_obj_size); | |
135 } else { | |
136 // Flush and fill | |
137 _old_lab.flush(); | |
138 | |
139 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); | |
140 if(lab_base != NULL) { | |
6817 | 141 #ifdef ASSERT |
142 // Delay the initialization of the promotion lab (plab). | |
143 // This exposes uninitialized plabs to card table processing. | |
144 if (GCWorkerDelayMillis > 0) { | |
145 os::sleep(Thread::current(), GCWorkerDelayMillis, false); | |
146 } | |
147 #endif | |
4909 | 148 _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); |
149 // Try the old lab allocation again. | |
150 new_obj = (oop) _old_lab.allocate(new_obj_size); | |
151 } | |
152 } | |
153 } | |
154 | |
155 // This is the promotion failed test, and code handling. | |
156 // The code belongs here for two reasons. It is slightly | |
10405 | 157 // different than the code below, and cannot share the |
4909 | 158 // CAS testing code. Keeping the code here also minimizes |
159 // the impact on the common case fast path code. | |
160 | |
161 if (new_obj == NULL) { | |
162 _old_gen_is_full = true; | |
163 return oop_promotion_failed(o, test_mark); | |
164 } | |
165 } | |
166 } | |
167 | |
168 assert(new_obj != NULL, "allocation should have succeeded"); | |
169 | |
170 // Copy obj | |
171 Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); | |
172 | |
173 // Now we have to CAS in the header. | |
174 if (o->cas_forward_to(new_obj, test_mark)) { | |
175 // We won any races, we "own" this object. | |
176 assert(new_obj == o->forwardee(), "Sanity"); | |
177 | |
178 // Increment age if obj still in new generation. Now that | |
179 // we're dealing with a markOop that cannot change, it is | |
180 // okay to use the non mt safe oop methods. | |
181 if (!new_obj_is_tenured) { | |
182 new_obj->incr_age(); | |
183 assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); | |
184 } | |
185 | |
186 // Do the size comparison first with new_obj_size, which we | |
187 // already have. Hopefully, only a few objects are larger than | |
188 // _min_array_size_for_chunking, and most of them will be arrays. | |
189 // So, the is->objArray() test would be very infrequent. | |
190 if (new_obj_size > _min_array_size_for_chunking && | |
191 new_obj->is_objArray() && | |
192 PSChunkLargeArrays) { | |
193 // we'll chunk it | |
194 oop* const masked_o = mask_chunked_array_oop(o); | |
195 push_depth(masked_o); | |
196 TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); | |
197 } else { | |
198 // we'll just push its contents | |
199 new_obj->push_contents(this); | |
200 } | |
201 } else { | |
202 // We lost, someone else "owns" this object | |
203 guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); | |
204 | |
205 // Try to deallocate the space. If it was directly allocated we cannot | |
206 // deallocate it, so we have to test. If the deallocation fails, | |
207 // overwrite with a filler object. | |
208 if (new_obj_is_tenured) { | |
209 if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { | |
210 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); | |
211 } | |
212 } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { | |
213 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); | |
214 } | |
215 | |
216 // don't update this before the unallocation! | |
217 new_obj = o->forwardee(); | |
218 } | |
219 } else { | |
220 assert(o->is_forwarded(), "Sanity"); | |
221 new_obj = o->forwardee(); | |
222 } | |
223 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5962
diff
changeset
|
224 #ifndef PRODUCT |
4909 | 225 // This code must come after the CAS test, or it will print incorrect |
226 // information. | |
227 if (TraceScavenge) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5962
diff
changeset
|
228 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", |
4909 | 229 PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14422
diff
changeset
|
230 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); |
4909 | 231 } |
232 #endif | |
233 | |
234 return new_obj; | |
235 } | |
236 | |
237 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
238 inline void PSPromotionManager::process_popped_location_depth(StarTask p) { |
0 | 239 if (is_oop_masked(p)) { |
240 assert(PSChunkLargeArrays, "invariant"); | |
241 oop const old = unmask_chunked_array_oop(p); | |
242 process_array_chunk(old); | |
243 } else { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
244 if (p.is_narrow()) { |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
196
diff
changeset
|
245 assert(UseCompressedOops, "Error"); |
4909 | 246 PSScavenge::copy_and_push_safe_barrier<narrowOop, /*promote_immediately=*/false>(this, p); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
247 } else { |
4909 | 248 PSScavenge::copy_and_push_safe_barrier<oop, /*promote_immediately=*/false>(this, p); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
249 } |
0 | 250 } |
251 } | |
1665 | 252 |
253 #if TASKQUEUE_STATS | |
254 void PSPromotionManager::record_steal(StarTask& p) { | |
255 if (is_oop_masked(p)) { | |
256 ++_masked_steals; | |
257 } | |
258 } | |
259 #endif // TASKQUEUE_STATS | |
1972 | 260 |
261 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP |