342N/A/*
3122N/A * Copyright (c) 2001, 2012, 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#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_INLINE_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_INLINE_HPP
1879N/A
1879N/A#include "gc_implementation/g1/g1RemSet.hpp"
1879N/A#include "gc_implementation/g1/heapRegionRemSet.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A
3008N/Ainline uint 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
1781N/Atemplate <class T>
1867N/Ainline void G1RemSet::write_ref(HeapRegion* from, T* p) {
1867N/A par_write_ref(from, p, 0);
342N/A}
342N/A
1781N/Atemplate <class T>
1867N/Ainline void G1RemSet::par_write_ref(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);
1867N/A if (to != NULL && from != to) {
1867N/A assert(to->rem_set() != NULL, "Need per-region 'into' remsets.");
1867N/A to->rem_set()->add_reference(p, tid);
342N/A }
342N/A}
626N/A
1781N/Atemplate <class T>
1781N/Ainline 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
1781N/Atemplate <class T>
1781N/Ainline 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
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1REMSET_INLINE_HPP