Mercurial > hg > graal-compiler
annotate src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp @ 6008:b632e80fc9dc
4988100: oop_verify_old_oop appears to be dead
Summary: removed oop_verify_old_oop and allow_dirty. Also reviewed by: alexlamsl@gmail.com
Reviewed-by: jmasa, jwilhelm
author | brutisso |
---|---|
date | Mon, 16 Apr 2012 08:57:18 +0200 |
parents | 8a729074feae |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
4909 | 2 * Copyright (c) 2002, 2012, 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" |
30 #include "gc_implementation/parallelScavenge/psScavenge.hpp" | |
31 | |
0 | 32 inline PSPromotionManager* PSPromotionManager::manager_array(int index) { |
33 assert(_manager_array != NULL, "access of NULL manager_array"); | |
34 assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access"); | |
35 return _manager_array[index]; | |
36 } | |
37 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
38 template <class T> |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
39 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
|
40 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
|
41 oop o = oopDesc::load_decode_heap_oop_not_null(p); |
0 | 42 if (o->is_forwarded()) { |
43 o = o->forwardee(); | |
44 // Card mark | |
45 if (PSScavenge::is_obj_in_young((HeapWord*) o)) { | |
46 PSScavenge::card_table()->inline_write_ref_field_gc(p, o); | |
47 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
48 oopDesc::encode_store_heap_oop_not_null(p, o); |
0 | 49 } else { |
50 push_depth(p); | |
51 } | |
52 } | |
53 } | |
54 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
55 template <class T> |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 "Sanity"); |
0 | 60 assert(Universe::heap()->is_in(p), "pointer outside heap"); |
61 | |
62 claim_or_forward_internal_depth(p); | |
63 } | |
64 | |
4909 | 65 // |
66 // This method is pretty bulky. It would be nice to split it up | |
67 // into smaller submethods, but we need to be careful not to hurt | |
68 // performance. | |
69 // | |
70 template<bool promote_immediately> | |
71 oop PSPromotionManager::copy_to_survivor_space(oop o) { | |
72 assert(PSScavenge::should_scavenge(&o), "Sanity"); | |
73 | |
74 oop new_obj = NULL; | |
75 | |
76 // NOTE! We must be very careful with any methods that access the mark | |
77 // in o. There may be multiple threads racing on it, and it may be forwarded | |
78 // at any time. Do not use oop methods for accessing the mark! | |
79 markOop test_mark = o->mark(); | |
80 | |
81 // The same test as "o->is_forwarded()" | |
82 if (!test_mark->is_marked()) { | |
83 bool new_obj_is_tenured = false; | |
84 size_t new_obj_size = o->size(); | |
85 | |
86 if (!promote_immediately) { | |
87 // Find the objects age, MT safe. | |
88 int age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? | |
89 test_mark->displaced_mark_helper()->age() : test_mark->age(); | |
90 | |
91 // Try allocating obj in to-space (unless too old) | |
92 if (age < PSScavenge::tenuring_threshold()) { | |
93 new_obj = (oop) _young_lab.allocate(new_obj_size); | |
94 if (new_obj == NULL && !_young_gen_is_full) { | |
95 // Do we allocate directly, or flush and refill? | |
96 if (new_obj_size > (YoungPLABSize / 2)) { | |
97 // Allocate this object directly | |
98 new_obj = (oop)young_space()->cas_allocate(new_obj_size); | |
99 } else { | |
100 // Flush and fill | |
101 _young_lab.flush(); | |
102 | |
103 HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); | |
104 if (lab_base != NULL) { | |
105 _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); | |
106 // Try the young lab allocation again. | |
107 new_obj = (oop) _young_lab.allocate(new_obj_size); | |
108 } else { | |
109 _young_gen_is_full = true; | |
110 } | |
111 } | |
112 } | |
113 } | |
114 } | |
115 | |
116 // Otherwise try allocating obj tenured | |
117 if (new_obj == NULL) { | |
118 #ifndef PRODUCT | |
119 if (Universe::heap()->promotion_should_fail()) { | |
120 return oop_promotion_failed(o, test_mark); | |
121 } | |
122 #endif // #ifndef PRODUCT | |
123 | |
124 new_obj = (oop) _old_lab.allocate(new_obj_size); | |
125 new_obj_is_tenured = true; | |
126 | |
127 if (new_obj == NULL) { | |
128 if (!_old_gen_is_full) { | |
129 // Do we allocate directly, or flush and refill? | |
130 if (new_obj_size > (OldPLABSize / 2)) { | |
131 // Allocate this object directly | |
132 new_obj = (oop)old_gen()->cas_allocate(new_obj_size); | |
133 } else { | |
134 // Flush and fill | |
135 _old_lab.flush(); | |
136 | |
137 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); | |
138 if(lab_base != NULL) { | |
139 _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); | |
140 // Try the old lab allocation again. | |
141 new_obj = (oop) _old_lab.allocate(new_obj_size); | |
142 } | |
143 } | |
144 } | |
145 | |
146 // This is the promotion failed test, and code handling. | |
147 // The code belongs here for two reasons. It is slightly | |
148 // different thatn the code below, and cannot share the | |
149 // CAS testing code. Keeping the code here also minimizes | |
150 // the impact on the common case fast path code. | |
151 | |
152 if (new_obj == NULL) { | |
153 _old_gen_is_full = true; | |
154 return oop_promotion_failed(o, test_mark); | |
155 } | |
156 } | |
157 } | |
158 | |
159 assert(new_obj != NULL, "allocation should have succeeded"); | |
160 | |
161 // Copy obj | |
162 Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); | |
163 | |
164 // Now we have to CAS in the header. | |
165 if (o->cas_forward_to(new_obj, test_mark)) { | |
166 // We won any races, we "own" this object. | |
167 assert(new_obj == o->forwardee(), "Sanity"); | |
168 | |
169 // Increment age if obj still in new generation. Now that | |
170 // we're dealing with a markOop that cannot change, it is | |
171 // okay to use the non mt safe oop methods. | |
172 if (!new_obj_is_tenured) { | |
173 new_obj->incr_age(); | |
174 assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); | |
175 } | |
176 | |
177 // Do the size comparison first with new_obj_size, which we | |
178 // already have. Hopefully, only a few objects are larger than | |
179 // _min_array_size_for_chunking, and most of them will be arrays. | |
180 // So, the is->objArray() test would be very infrequent. | |
181 if (new_obj_size > _min_array_size_for_chunking && | |
182 new_obj->is_objArray() && | |
183 PSChunkLargeArrays) { | |
184 // we'll chunk it | |
185 oop* const masked_o = mask_chunked_array_oop(o); | |
186 push_depth(masked_o); | |
187 TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); | |
188 } else { | |
189 // we'll just push its contents | |
190 new_obj->push_contents(this); | |
191 } | |
192 } else { | |
193 // We lost, someone else "owns" this object | |
194 guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); | |
195 | |
196 // Try to deallocate the space. If it was directly allocated we cannot | |
197 // deallocate it, so we have to test. If the deallocation fails, | |
198 // overwrite with a filler object. | |
199 if (new_obj_is_tenured) { | |
200 if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { | |
201 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); | |
202 } | |
203 } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { | |
204 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); | |
205 } | |
206 | |
207 // don't update this before the unallocation! | |
208 new_obj = o->forwardee(); | |
209 } | |
210 } else { | |
211 assert(o->is_forwarded(), "Sanity"); | |
212 new_obj = o->forwardee(); | |
213 } | |
214 | |
215 #ifdef DEBUG | |
216 // This code must come after the CAS test, or it will print incorrect | |
217 // information. | |
218 if (TraceScavenge) { | |
219 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}", | |
220 PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", | |
221 new_obj->blueprint()->internal_name(), o, new_obj, new_obj->size()); | |
222 } | |
223 #endif | |
224 | |
225 return new_obj; | |
226 } | |
227 | |
228 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
229 inline void PSPromotionManager::process_popped_location_depth(StarTask p) { |
0 | 230 if (is_oop_masked(p)) { |
231 assert(PSChunkLargeArrays, "invariant"); | |
232 oop const old = unmask_chunked_array_oop(p); | |
233 process_array_chunk(old); | |
234 } else { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
235 if (p.is_narrow()) { |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
196
diff
changeset
|
236 assert(UseCompressedOops, "Error"); |
4909 | 237 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
|
238 } else { |
4909 | 239 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
|
240 } |
0 | 241 } |
242 } | |
1665 | 243 |
244 #if TASKQUEUE_STATS | |
245 void PSPromotionManager::record_steal(StarTask& p) { | |
246 if (is_oop_masked(p)) { | |
247 ++_masked_steals; | |
248 } | |
249 } | |
250 #endif // TASKQUEUE_STATS | |
1972 | 251 |
252 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_INLINE_HPP |