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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP
26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP
27
28 #include "gc/parallel/parallelScavengeHeap.hpp"
29 #include "gc/parallel/psOldGen.hpp"
30 #include "gc/parallel/psPromotionLAB.inline.hpp"
31 #include "gc/parallel/psPromotionManager.hpp"
32 #include "gc/parallel/psScavenge.hpp"
33 #include "gc/shared/taskqueue.inline.hpp"
34 #include "oops/oop.inline.hpp"
35
36 inline PSPromotionManager* PSPromotionManager::manager_array(uint index) {
37 assert(_manager_array != NULL, "access of NULL manager_array");
38 assert(index <= ParallelGCThreads, "out of range manager_array access");
39 return &_manager_array[index];
40 }
41
42 template <class T>
43 inline void PSPromotionManager::push_depth(T* p) {
44 claimed_stack_depth()->push(p);
45 }
46
47 template <class T>
48 inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) {
49 if (p != NULL) { // XXX: error if p != NULL here
50 oop o = oopDesc::load_decode_heap_oop_not_null(p);
51 if (o->is_forwarded()) {
52 o = o->forwardee();
53 // Card mark
243
244 // Try to deallocate the space. If it was directly allocated we cannot
245 // deallocate it, so we have to test. If the deallocation fails,
246 // overwrite with a filler object.
247 if (new_obj_is_tenured) {
248 if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
249 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
250 }
251 } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
252 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
253 }
254
255 // don't update this before the unallocation!
256 new_obj = o->forwardee();
257 }
258 } else {
259 assert(o->is_forwarded(), "Sanity");
260 new_obj = o->forwardee();
261 }
262
263 #ifndef PRODUCT
264 // This code must come after the CAS test, or it will print incorrect
265 // information.
266 if (TraceScavenge) {
267 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
268 should_scavenge(&new_obj) ? "copying" : "tenuring",
269 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
270 }
271 #endif
272
273 return new_obj;
274 }
275
276 // Attempt to "claim" oop at p via CAS, push the new obj if successful
277 // This version tests the oop* to make sure it is within the heap before
278 // attempting marking.
279 template <class T, bool promote_immediately>
280 inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) {
281 assert(should_scavenge(p, true), "revisiting object?");
282
283 oop o = oopDesc::load_decode_heap_oop_not_null(p);
284 oop new_obj = o->is_forwarded()
285 ? o->forwardee()
286 : copy_to_survivor_space<promote_immediately>(o);
287
288 #ifndef PRODUCT
289 // This code must come after the CAS test, or it will print incorrect
290 // information.
291 if (TraceScavenge && o->is_forwarded()) {
292 gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
293 "forwarding",
294 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
295 }
296 #endif
297
298 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
299
300 // We cannot mark without test, as some code passes us pointers
301 // that are outside the heap. These pointers are either from roots
302 // or from metadata.
303 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
304 ParallelScavengeHeap::heap()->is_in_reserved(p)) {
305 if (PSScavenge::is_obj_in_young(new_obj)) {
306 PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj);
307 }
308 }
309 }
310
311 inline void PSPromotionManager::process_popped_location_depth(StarTask p) {
312 if (is_oop_masked(p)) {
313 assert(PSChunkLargeArrays, "invariant");
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP
26 #define SHARE_VM_GC_PARALLEL_PSPROMOTIONMANAGER_INLINE_HPP
27
28 #include "gc/parallel/parallelScavengeHeap.hpp"
29 #include "gc/parallel/psOldGen.hpp"
30 #include "gc/parallel/psPromotionLAB.inline.hpp"
31 #include "gc/parallel/psPromotionManager.hpp"
32 #include "gc/parallel/psScavenge.hpp"
33 #include "gc/shared/taskqueue.inline.hpp"
34 #include "logging/log.hpp"
35 #include "oops/oop.inline.hpp"
36
37 inline PSPromotionManager* PSPromotionManager::manager_array(uint index) {
38 assert(_manager_array != NULL, "access of NULL manager_array");
39 assert(index <= ParallelGCThreads, "out of range manager_array access");
40 return &_manager_array[index];
41 }
42
43 template <class T>
44 inline void PSPromotionManager::push_depth(T* p) {
45 claimed_stack_depth()->push(p);
46 }
47
48 template <class T>
49 inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) {
50 if (p != NULL) { // XXX: error if p != NULL here
51 oop o = oopDesc::load_decode_heap_oop_not_null(p);
52 if (o->is_forwarded()) {
53 o = o->forwardee();
54 // Card mark
244
245 // Try to deallocate the space. If it was directly allocated we cannot
246 // deallocate it, so we have to test. If the deallocation fails,
247 // overwrite with a filler object.
248 if (new_obj_is_tenured) {
249 if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
250 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
251 }
252 } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
253 CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
254 }
255
256 // don't update this before the unallocation!
257 new_obj = o->forwardee();
258 }
259 } else {
260 assert(o->is_forwarded(), "Sanity");
261 new_obj = o->forwardee();
262 }
263
264 log_develop(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
265 should_scavenge(&new_obj) ? "copying" : "tenuring",
266 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
267
268 return new_obj;
269 }
270
271 // Attempt to "claim" oop at p via CAS, push the new obj if successful
272 // This version tests the oop* to make sure it is within the heap before
273 // attempting marking.
274 template <class T, bool promote_immediately>
275 inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) {
276 assert(should_scavenge(p, true), "revisiting object?");
277
278 oop o = oopDesc::load_decode_heap_oop_not_null(p);
279 oop new_obj = o->is_forwarded()
280 ? o->forwardee()
281 : copy_to_survivor_space<promote_immediately>(o);
282
283 #ifndef PRODUCT
284 // This code must come after the CAS test, or it will print incorrect
285 // information.
286 if (o->is_forwarded()) {
287 log_develop(gc, scavenge)("{forwarding %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
288 new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size());
289 }
290 #endif
291
292 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
293
294 // We cannot mark without test, as some code passes us pointers
295 // that are outside the heap. These pointers are either from roots
296 // or from metadata.
297 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
298 ParallelScavengeHeap::heap()->is_in_reserved(p)) {
299 if (PSScavenge::is_obj_in_young(new_obj)) {
300 PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj);
301 }
302 }
303 }
304
305 inline void PSPromotionManager::process_popped_location_depth(StarTask p) {
306 if (is_oop_masked(p)) {
307 assert(PSChunkLargeArrays, "invariant");
|