g1OopClosures.inline.hpp revision 1625
342N/A/*
2590N/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
1879N/A/*
1879N/A * This really ought to be an inline function, but apparently the C++
1879N/A * compiler sometimes sees fit to ignore inline declarations. Sigh.
2596N/A */
1879N/A
1879N/A// This must a ifdef'ed because the counting it controls is in a
1879N/A// perf-critical inner loop.
1879N/A#define FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT 0
342N/A
342N/Atemplate <class T> inline void FilterIntoCSClosure::do_oop_nv(T* p) {
342N/A T heap_oop = oopDesc::load_heap_oop(p);
342N/A if (!oopDesc::is_null(heap_oop) &&
342N/A _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop))) {
342N/A _oc->do_oop(p);
342N/A#if FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT
342N/A if (_dcto_cl != NULL)
342N/A _dcto_cl->incr_count();
845N/A#endif
845N/A }
845N/A}
845N/A
342N/A#define FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT 0
342N/A
1625N/Atemplate <class T> inline void FilterOutOfRegionClosure::do_oop_nv(T* p) {
1625N/A T heap_oop = oopDesc::load_heap_oop(p);
342N/A if (!oopDesc::is_null(heap_oop)) {
342N/A HeapWord* obj_hw = (HeapWord*)oopDesc::decode_heap_oop_not_null(heap_oop);
342N/A if (obj_hw < _r_bottom || obj_hw >= _r_end) {
342N/A _oc->do_oop(p);
342N/A#if FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT
342N/A _out_of_region++;
845N/A#endif
845N/A }
845N/A }
845N/A}
845N/A
845N/Atemplate <class T> inline void FilterInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
342N/A T heap_oop = oopDesc::load_heap_oop(p);
845N/A if (!oopDesc::is_null(heap_oop) &&
342N/A _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop)))
845N/A _oc->do_oop(p);
342N/A}
342N/A
342N/Atemplate <class T> inline void FilterAndMarkInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
845N/A T heap_oop = oopDesc::load_heap_oop(p);
845N/A if (!oopDesc::is_null(heap_oop)) {
845N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
342N/A HeapRegion* hr = _g1->heap_region_containing((HeapWord*) obj);
845N/A if (hr != NULL) {
845N/A if (hr->in_collection_set())
845N/A _oc->do_oop(p);
845N/A else if (!hr->is_young())
845N/A _cm->grayRoot(obj);
845N/A }
845N/A }
845N/A}
845N/A
845N/A// This closure is applied to the fields of the objects that have just been copied.
845N/Atemplate <class T> inline void G1ParScanClosure::do_oop_nv(T* p) {
845N/A T heap_oop = oopDesc::load_heap_oop(p);
845N/A
845N/A if (!oopDesc::is_null(heap_oop)) {
845N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
845N/A if (_g1->in_cset_fast_test(obj)) {
845N/A // We're not going to even bother checking whether the object is
845N/A // already forwarded or not, as this usually causes an immediate
845N/A // stall. We'll try to prefetch the object (for write, given that
845N/A // we might need to install the forwarding reference) and we'll
342N/A // get back to it when pop it from the queue
342N/A Prefetch::write(obj->mark_addr(), 0);
1261N/A Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
1261N/A
1261N/A // slightly paranoid test; I'm trying to catch potential
1261N/A // problems before we go into push_on_queue to know where the
1261N/A // problem is coming from
1261N/A assert(obj == oopDesc::load_decode_heap_oop(p),
1261N/A "p should still be pointing to obj");
1261N/A _par_scan_state->push_on_queue(p);
1261N/A } else {
1625N/A _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
1625N/A }
1261N/A }
1261N/A}
1261N/A
1261N/Atemplate <class T> inline void G1ParPushHeapRSClosure::do_oop_nv(T* p) {
1625N/A T heap_oop = oopDesc::load_heap_oop(p);
2596N/A
2596N/A if (!oopDesc::is_null(heap_oop)) {
2596N/A oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
2596N/A if (_g1->in_cset_fast_test(obj)) {
2596N/A Prefetch::write(obj->mark_addr(), 0);
2596N/A Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
2596N/A
2596N/A // Place on the references queue
2596N/A _par_scan_state->push_on_queue(p);
2596N/A }
2596N/A }
2596N/A}
2596N/A
1879N/A