src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Fri Feb 10 17:21:31 2012
--- new/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp	Fri Feb 10 17:21:30 2012

*** 1,7 **** --- 1,7 ---- /* ! * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. ! * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 245,415 **** --- 245,254 ---- if (_young_gen_is_full) { PSScavenge::set_survivor_overflow(true); } } // // This method is pretty bulky. It would be nice to split it up // into smaller submethods, but we need to be careful not to hurt // performance. // oop PSPromotionManager::copy_to_survivor_space(oop o) { assert(PSScavenge::should_scavenge(&o), "Sanity"); oop new_obj = NULL; // NOTE! We must be very careful with any methods that access the mark // in o. There may be multiple threads racing on it, and it may be forwarded // at any time. Do not use oop methods for accessing the mark! markOop test_mark = o->mark(); // The same test as "o->is_forwarded()" if (!test_mark->is_marked()) { bool new_obj_is_tenured = false; size_t new_obj_size = o->size(); // Find the objects age, MT safe. int age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? test_mark->displaced_mark_helper()->age() : test_mark->age(); // Try allocating obj in to-space (unless too old) if (age < PSScavenge::tenuring_threshold()) { new_obj = (oop) _young_lab.allocate(new_obj_size); if (new_obj == NULL && !_young_gen_is_full) { // Do we allocate directly, or flush and refill? if (new_obj_size > (YoungPLABSize / 2)) { // Allocate this object directly new_obj = (oop)young_space()->cas_allocate(new_obj_size); } else { // Flush and fill _young_lab.flush(); HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); if (lab_base != NULL) { _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); // Try the young lab allocation again. new_obj = (oop) _young_lab.allocate(new_obj_size); } else { _young_gen_is_full = true; } } } } // Otherwise try allocating obj tenured if (new_obj == NULL) { #ifndef PRODUCT if (Universe::heap()->promotion_should_fail()) { return oop_promotion_failed(o, test_mark); } #endif // #ifndef PRODUCT new_obj = (oop) _old_lab.allocate(new_obj_size); new_obj_is_tenured = true; if (new_obj == NULL) { if (!_old_gen_is_full) { // Do we allocate directly, or flush and refill? if (new_obj_size > (OldPLABSize / 2)) { // Allocate this object directly new_obj = (oop)old_gen()->cas_allocate(new_obj_size); } else { // Flush and fill _old_lab.flush(); HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); if(lab_base != NULL) { _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); // Try the old lab allocation again. new_obj = (oop) _old_lab.allocate(new_obj_size); } } } // This is the promotion failed test, and code handling. // The code belongs here for two reasons. It is slightly // different thatn the code below, and cannot share the // CAS testing code. Keeping the code here also minimizes // the impact on the common case fast path code. if (new_obj == NULL) { _old_gen_is_full = true; return oop_promotion_failed(o, test_mark); } } } assert(new_obj != NULL, "allocation should have succeeded"); // Copy obj Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); // Now we have to CAS in the header. if (o->cas_forward_to(new_obj, test_mark)) { // We won any races, we "own" this object. assert(new_obj == o->forwardee(), "Sanity"); // Increment age if obj still in new generation. Now that // we're dealing with a markOop that cannot change, it is // okay to use the non mt safe oop methods. if (!new_obj_is_tenured) { new_obj->incr_age(); assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); } // Do the size comparison first with new_obj_size, which we // already have. Hopefully, only a few objects are larger than // _min_array_size_for_chunking, and most of them will be arrays. // So, the is->objArray() test would be very infrequent. if (new_obj_size > _min_array_size_for_chunking && new_obj->is_objArray() && PSChunkLargeArrays) { // we'll chunk it oop* const masked_o = mask_chunked_array_oop(o); push_depth(masked_o); TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); } else { // we'll just push its contents new_obj->push_contents(this); } } else { // We lost, someone else "owns" this object guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); // Try to deallocate the space. If it was directly allocated we cannot // deallocate it, so we have to test. If the deallocation fails, // overwrite with a filler object. if (new_obj_is_tenured) { if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); } } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); } // don't update this before the unallocation! new_obj = o->forwardee(); } } else { assert(o->is_forwarded(), "Sanity"); new_obj = o->forwardee(); } #ifdef DEBUG // This code must come after the CAS test, or it will print incorrect // information. if (TraceScavenge) { gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}", PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", new_obj->blueprint()->internal_name(), o, new_obj, new_obj->size()); } #endif return new_obj; } template <class T> void PSPromotionManager::process_array_chunk_work( oop obj, int start, int end) { assert(start <= end, "invariant"); T* const base = (T*)objArrayOop(obj)->base();

src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File