342N/A/*
2346N/A * Copyright (c) 2001, 2011, 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_G1SATBCARDTABLEMODREFBS_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
1879N/A
1879N/A#include "memory/cardTableModRefBS.hpp"
1879N/A#include "memory/memRegion.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A
342N/A#ifndef SERIALGC
342N/A
342N/Aclass DirtyCardQueueSet;
342N/A
342N/A// This barrier is specialized to use a logging barrier to support
342N/A// snapshot-at-the-beginning marking.
342N/A
342N/Aclass G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS {
2346N/Apublic:
342N/A // Add "pre_val" to a set of objects that may have been disconnected from the
342N/A // pre-marking object graph.
342N/A static void enqueue(oop pre_val);
342N/A
342N/A G1SATBCardTableModRefBS(MemRegion whole_heap,
342N/A int max_covered_regions);
342N/A
342N/A bool is_a(BarrierSet::Name bsn) {
342N/A return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn);
342N/A }
342N/A
342N/A virtual bool has_write_ref_pre_barrier() { return true; }
342N/A
342N/A // This notes that we don't need to access any BarrierSet data
342N/A // structures, so this can be called from a static context.
845N/A template <class T> static void write_ref_field_pre_static(T* field, oop newVal) {
845N/A T heap_oop = oopDesc::load_heap_oop(field);
845N/A if (!oopDesc::is_null(heap_oop)) {
845N/A enqueue(oopDesc::decode_heap_oop(heap_oop));
342N/A }
342N/A }
342N/A
342N/A // We export this to make it available in cases where the static
342N/A // type of the barrier set is known. Note that it is non-virtual.
845N/A template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
342N/A write_ref_field_pre_static(field, newVal);
342N/A }
342N/A
845N/A // These are the more general virtual versions.
845N/A virtual void write_ref_field_pre_work(oop* field, oop new_val) {
845N/A inline_write_ref_field_pre(field, new_val);
845N/A }
845N/A virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {
342N/A inline_write_ref_field_pre(field, new_val);
342N/A }
845N/A virtual void write_ref_field_pre_work(void* field, oop new_val) {
845N/A guarantee(false, "Not needed");
845N/A }
342N/A
845N/A template <class T> void write_ref_array_pre_work(T* dst, int count);
2171N/A virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized) {
2171N/A if (!dest_uninitialized) {
2171N/A write_ref_array_pre_work(dst, count);
2171N/A }
845N/A }
2171N/A virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized) {
2171N/A if (!dest_uninitialized) {
2171N/A write_ref_array_pre_work(dst, count);
2171N/A }
845N/A }
342N/A};
342N/A
342N/A// Adds card-table logging to the post-barrier.
342N/A// Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.
342N/Aclass G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {
342N/A private:
342N/A DirtyCardQueueSet& _dcqs;
342N/A public:
342N/A G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
342N/A int max_covered_regions);
342N/A
342N/A bool is_a(BarrierSet::Name bsn) {
342N/A return bsn == BarrierSet::G1SATBCTLogging ||
342N/A G1SATBCardTableModRefBS::is_a(bsn);
342N/A }
342N/A
342N/A void write_ref_field_work(void* field, oop new_val);
342N/A
342N/A // Can be called from static contexts.
342N/A static void write_ref_field_static(void* field, oop new_val);
342N/A
342N/A // NB: if you do a whole-heap invalidation, the "usual invariant" defined
342N/A // above no longer applies.
342N/A void invalidate(MemRegion mr, bool whole_heap = false);
342N/A
342N/A void write_region_work(MemRegion mr) { invalidate(mr); }
342N/A void write_ref_array_work(MemRegion mr) { invalidate(mr); }
342N/A
342N/A
342N/A};
342N/A
342N/A
342N/A#endif // SERIALGC
1879N/A
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP