duke@435: /* xdono@631: * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: inline void PSScavenge::save_to_space_top_before_gc() { duke@435: ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); duke@435: _to_space_top_before_gc = heap->young_gen()->to_space()->top(); duke@435: } duke@435: coleenp@548: template inline bool PSScavenge::should_scavenge(T* p) { coleenp@548: T heap_oop = oopDesc::load_heap_oop(p); coleenp@548: if (oopDesc::is_null(heap_oop)) return false; coleenp@548: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); coleenp@548: return PSScavenge::is_obj_in_young((HeapWord*)obj); duke@435: } duke@435: coleenp@548: template coleenp@548: inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) { duke@435: if (should_scavenge(p)) { coleenp@548: oop obj = oopDesc::load_decode_heap_oop_not_null(p); duke@435: // Skip objects copied to to_space since the scavenge started. coleenp@548: HeapWord* const addr = (HeapWord*)obj; duke@435: return addr < to_space_top_before_gc() || addr >= to_space->end(); duke@435: } duke@435: return false; duke@435: } duke@435: coleenp@548: template coleenp@548: inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) { duke@435: if (check_to_space) { coleenp@548: ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); duke@435: return should_scavenge(p, heap->young_gen()->to_space()); duke@435: } duke@435: return should_scavenge(p); duke@435: } duke@435: duke@435: // Attempt to "claim" oop at p via CAS, push the new obj if successful duke@435: // This version tests the oop* to make sure it is within the heap before duke@435: // attempting marking. coleenp@548: template duke@435: inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, coleenp@548: T* p) { coleenp@548: assert(should_scavenge(p, true), "revisiting object?"); duke@435: coleenp@548: oop o = oopDesc::load_decode_heap_oop_not_null(p); coleenp@548: oop new_obj = o->is_forwarded() coleenp@548: ? o->forwardee() coleenp@548: : pm->copy_to_survivor_space(o, pm->depth_first()); coleenp@548: oopDesc::encode_store_heap_oop_not_null(p, new_obj); duke@435: duke@435: // We cannot mark without test, as some code passes us pointers duke@435: // that are outside the heap. coleenp@548: if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && duke@435: Universe::heap()->is_in_reserved(p)) { coleenp@548: if (PSScavenge::is_obj_in_young((HeapWord*)new_obj)) { coleenp@548: card_table()->inline_write_ref_field_gc(p, new_obj); duke@435: } duke@435: } duke@435: }