g1RemSet.inline.hpp revision 1625
342N/A/*
1625N/A * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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 *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * 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
845N/Atemplate <class T> inline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, T* p) {
845N/A par_write_ref_nv(from, p, 0);
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
845N/Atemplate <class T> inline void HRInto_G1RemSet::par_write_ref_nv(HeapRegion* from, T* p, int tid) {
845N/A oop obj = oopDesc::load_decode_heap_oop(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
1625N/A
1625N/A assert(from == NULL || from->is_in_reserved(p), "p is not in from");
1625N/A
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) {
616N/A // The _par_traversal_in_progress flag is true during the collection pause,
1625N/A // false during the evacuation failure handing. This should avoid a
1625N/A // potential loop if we were to add the card containing 'p' to the DCQS
1625N/A // that's used to regenerate the remembered sets for the collection set,
1625N/A // in the event of an evacuation failure, here. The UpdateRSImmediate
1625N/A // closure will eventally call this routine.
616N/A if (_par_traversal_in_progress &&
616N/A to->in_collection_set() && !self_forwarded(obj)) {
1625N/A
1625N/A assert(_cset_rs_update_cl[tid] != NULL, "should have been set already");
1625N/A _cset_rs_update_cl[tid]->do_oop(p);
1625N/A
1625N/A // Deferred updates to the CSet are either discarded (in the normal case),
616N/A // or processed (if an evacuation failure occurs) at the end
616N/A // of the collection.
616N/A // See HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do().
677N/A } else {
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.");
677N/A to->rem_set()->add_reference(p, tid);
342N/A }
342N/A }
342N/A}
626N/A
845N/Atemplate <class T> inline void UpdateRSOopClosure::do_oop_work(T* p) {
626N/A assert(_from != NULL, "from region must be non-NULL");
626N/A _rs->par_write_ref(_from, p, _worker_i);
626N/A}
1625N/A
1625N/Atemplate <class T> inline void UpdateRSetImmediate::do_oop_work(T* p) {
1625N/A assert(_from->is_in_reserved(p), "paranoia");
1625N/A T heap_oop = oopDesc::load_heap_oop(p);
1625N/A if (!oopDesc::is_null(heap_oop) && !_from->is_survivor()) {
1625N/A _g1_rem_set->par_write_ref(_from, p, 0);
1625N/A }
1625N/A}
1625N/A