g1OopClosures.inline.hpp revision 1261
2702N/A/*
2702N/A * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
2702N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2702N/A *
2702N/A * This code is free software; you can redistribute it and/or modify it
2702N/A * under the terms of the GNU General Public License version 2 only, as
2702N/A * published by the Free Software Foundation.
2702N/A *
2702N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2702N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2702N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2702N/A * version 2 for more details (a copy is included in the LICENSE file that
2702N/A * accompanied this code).
2702N/A *
2702N/A * You should have received a copy of the GNU General Public License version
2702N/A * 2 along with this work; if not, write to the Free Software Foundation,
2702N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2702N/A *
2702N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
2702N/A * CA 95054 USA or visit www.sun.com if you need additional information or
2702N/A * have any questions.
2702N/A *
2702N/A */
2702N/A
2702N/A/*
2702N/A * This really ought to be an inline function, but apparently the C++
2702N/A * compiler sometimes sees fit to ignore inline declarations. Sigh.
2702N/A */
2702N/A
2702N/A// This must a ifdef'ed because the counting it controls is in a
2702N/A// perf-critical inner loop.
2702N/A#define FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT 0
2702N/A
2702N/Atemplate <class T> inline void FilterIntoCSClosure::do_oop_nv(T* p) {
2702N/A T heap_oop = oopDesc::load_heap_oop(p);
2702N/A if (!oopDesc::is_null(heap_oop) &&
2702N/A _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop))) {
2702N/A _oc->do_oop(p);
2715N/A#if FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT
2715N/A _dcto_cl->incr_count();
2715N/A#endif
2715N/A }
2715N/A}
2715N/A
2715N/A#define FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT 0
2715N/A
2715N/Atemplate <class T> inline void FilterOutOfRegionClosure::do_oop_nv(T* p) {
2715N/A T heap_oop = oopDesc::load_heap_oop(p);
2715N/A if (!oopDesc::is_null(heap_oop)) {
2715N/A HeapWord* obj_hw = (HeapWord*)oopDesc::decode_heap_oop_not_null(heap_oop);
2715N/A if (obj_hw < _r_bottom || obj_hw >= _r_end) {
2715N/A _oc->do_oop(p);
2715N/A#if FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT
2715N/A _out_of_region++;
2715N/A#endif
2715N/A }
2715N/A }
2715N/A}
2715N/A
2715N/Atemplate <class T> inline void FilterInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
2715N/A T heap_oop = oopDesc::load_heap_oop(p);
2715N/A if (!oopDesc::is_null(heap_oop) &&
2715N/A _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop)))
2715N/A _oc->do_oop(p);
2715N/A}
2715N/A
2715N/Atemplate <class T> inline void FilterAndMarkInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
2715N/A T heap_oop = oopDesc::load_heap_oop(p);
2715N/A if (!oopDesc::is_null(heap_oop)) {
2715N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
2715N/A HeapRegion* hr = _g1->heap_region_containing((HeapWord*) obj);
2715N/A if (hr != NULL) {
2715N/A if (hr->in_collection_set())
2715N/A _oc->do_oop(p);
2715N/A else if (!hr->is_young())
2715N/A _cm->grayRoot(obj);
2702N/A }
2702N/A }
2702N/A}
2702N/A
2702N/A// This closure is applied to the fields of the objects that have just been copied.
2702N/Atemplate <class T> inline void G1ParScanClosure::do_oop_nv(T* p) {
2702N/A T heap_oop = oopDesc::load_heap_oop(p);
2702N/A
2715N/A if (!oopDesc::is_null(heap_oop)) {
2702N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
2702N/A if (_g1->in_cset_fast_test(obj)) {
2702N/A // We're not going to even bother checking whether the object is
2702N/A // already forwarded or not, as this usually causes an immediate
2702N/A // stall. We'll try to prefetch the object (for write, given that
2702N/A // we might need to install the forwarding reference) and we'll
2702N/A // get back to it when pop it from the queue
2702N/A Prefetch::write(obj->mark_addr(), 0);
2702N/A Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
2702N/A
2702N/A // slightly paranoid test; I'm trying to catch potential
2702N/A // problems before we go into push_on_queue to know where the
2702N/A // problem is coming from
2702N/A assert(obj == oopDesc::load_decode_heap_oop(p),
2702N/A "p should still be pointing to obj");
2702N/A _par_scan_state->push_on_queue(p);
2702N/A } else {
2702N/A _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
2702N/A }
2702N/A }
2702N/A}
2702N/A
2702N/Atemplate <class T> inline void G1ParPushHeapRSClosure::do_oop_nv(T* p) {
2702N/A T heap_oop = oopDesc::load_heap_oop(p);
2702N/A
2702N/A if (!oopDesc::is_null(heap_oop)) {
2702N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
2702N/A if (_g1->in_cset_fast_test(obj)) {
2702N/A Prefetch::write(obj->mark_addr(), 0);
2702N/A Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
2702N/A _par_scan_state->push_on_queue(p);
2702N/A }
2702N/A }
2702N/A}
2702N/A