g1RemSet.inline.hpp revision 342
342N/A/*
342N/A * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
342N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
342N/A * CA 95054 USA or visit www.sun.com if you need additional information or
342N/A * have any questions.
342N/A *
342N/A */
342N/A
342N/Ainline size_t G1RemSet::n_workers() {
342N/A if (_g1->workers() != NULL) {
342N/A return _g1->workers()->total_workers();
342N/A } else {
342N/A return 1;
342N/A }
342N/A}
342N/A
342N/Ainline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, oop* p) {
342N/A oop obj = *p;
342N/A assert(from != NULL && from->is_in_reserved(p),
342N/A "p is not in a from");
342N/A HeapRegion* to = _g1->heap_region_containing(obj);
342N/A if (from != to && to != NULL) {
342N/A if (!to->popular() && !from->is_survivor()) {
342N/A#if G1_REM_SET_LOGGING
342N/A gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS"
342N/A " for region [" PTR_FORMAT ", " PTR_FORMAT ")",
342N/A p, obj,
342N/A to->bottom(), to->end());
342N/A#endif
342N/A assert(to->rem_set() != NULL, "Need per-region 'into' remsets.");
342N/A if (to->rem_set()->add_reference(p)) {
342N/A _g1->schedule_popular_region_evac(to);
342N/A }
342N/A }
342N/A }
342N/A}
342N/A
342N/Ainline void HRInto_G1RemSet::write_ref(HeapRegion* from, oop* p) {
342N/A write_ref_nv(from, p);
342N/A}
342N/A
342N/Ainline bool HRInto_G1RemSet::self_forwarded(oop obj) {
342N/A bool result = (obj->is_forwarded() && (obj->forwardee()== obj));
342N/A return result;
342N/A}
342N/A
342N/Ainline void HRInto_G1RemSet::par_write_ref(HeapRegion* from, oop* p, int tid) {
342N/A oop obj = *p;
342N/A#ifdef ASSERT
342N/A // can't do because of races
342N/A // assert(obj == NULL || obj->is_oop(), "expected an oop");
342N/A
342N/A // Do the safe subset of is_oop
342N/A if (obj != NULL) {
342N/A#ifdef CHECK_UNHANDLED_OOPS
342N/A oopDesc* o = obj.obj();
342N/A#else
342N/A oopDesc* o = obj;
342N/A#endif // CHECK_UNHANDLED_OOPS
342N/A assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
342N/A assert(Universe::heap()->is_in_reserved(obj), "must be in heap");
342N/A }
342N/A#endif // ASSERT
342N/A assert(from == NULL || from->is_in_reserved(p),
342N/A "p is not in from");
342N/A HeapRegion* to = _g1->heap_region_containing(obj);
342N/A // The test below could be optimized by applying a bit op to to and from.
342N/A if (to != NULL && from != NULL && from != to) {
342N/A if (!to->popular() && !from->is_survivor()) {
342N/A#if G1_REM_SET_LOGGING
342N/A gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS"
342N/A " for region [" PTR_FORMAT ", " PTR_FORMAT ")",
342N/A p, obj,
342N/A to->bottom(), to->end());
342N/A#endif
342N/A assert(to->rem_set() != NULL, "Need per-region 'into' remsets.");
342N/A if (to->rem_set()->add_reference(p, tid)) {
342N/A _g1->schedule_popular_region_evac(to);
342N/A }
342N/A }
342N/A // There is a tricky infinite loop if we keep pushing
342N/A // self forwarding pointers onto our _new_refs list.
342N/A if (_par_traversal_in_progress &&
342N/A to->in_collection_set() && !self_forwarded(obj)) {
342N/A _new_refs[tid]->push(p);
342N/A }
342N/A }
342N/A}