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