ysr@777: /* ysr@777: * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * ysr@777: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ysr@777: * CA 95054 USA or visit www.sun.com if you need additional information or ysr@777: * have any questions. ysr@777: * ysr@777: */ ysr@777: ysr@777: #ifndef SERIALGC ysr@777: ysr@777: class DirtyCardQueueSet; ysr@777: ysr@777: // This barrier is specialized to use a logging barrier to support ysr@777: // snapshot-at-the-beginning marking. ysr@777: ysr@777: class G1SATBCardTableModRefBS: public CardTableModRefBSForCTRS { ysr@777: private: ysr@777: // Add "pre_val" to a set of objects that may have been disconnected from the ysr@777: // pre-marking object graph. ysr@777: static void enqueue(oop pre_val); ysr@777: ysr@777: public: ysr@777: G1SATBCardTableModRefBS(MemRegion whole_heap, ysr@777: int max_covered_regions); ysr@777: ysr@777: bool is_a(BarrierSet::Name bsn) { ysr@777: return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn); ysr@777: } ysr@777: ysr@777: virtual bool has_write_ref_pre_barrier() { return true; } ysr@777: ysr@777: // This notes that we don't need to access any BarrierSet data ysr@777: // structures, so this can be called from a static context. ysr@777: static void write_ref_field_pre_static(void* field, oop newVal) { ysr@777: assert(!UseCompressedOops, "Else needs to be templatized"); ysr@777: oop preVal = *((oop*)field); ysr@777: if (preVal != NULL) { ysr@777: enqueue(preVal); ysr@777: } ysr@777: } ysr@777: ysr@777: // When we know the current java thread: ysr@777: static void write_ref_field_pre_static(void* field, oop newVal, ysr@777: JavaThread* jt); ysr@777: ysr@777: // We export this to make it available in cases where the static ysr@777: // type of the barrier set is known. Note that it is non-virtual. ysr@777: inline void inline_write_ref_field_pre(void* field, oop newVal) { ysr@777: write_ref_field_pre_static(field, newVal); ysr@777: } ysr@777: ysr@777: // This is the more general virtual version. ysr@777: void write_ref_field_pre_work(void* field, oop new_val) { ysr@777: inline_write_ref_field_pre(field, new_val); ysr@777: } ysr@777: ysr@777: virtual void write_ref_array_pre(MemRegion mr); ysr@777: ysr@777: }; ysr@777: ysr@777: // Adds card-table logging to the post-barrier. ysr@777: // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet. ysr@777: class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS { ysr@777: private: ysr@777: DirtyCardQueueSet& _dcqs; ysr@777: public: ysr@777: G1SATBCardTableLoggingModRefBS(MemRegion whole_heap, ysr@777: int max_covered_regions); ysr@777: ysr@777: bool is_a(BarrierSet::Name bsn) { ysr@777: return bsn == BarrierSet::G1SATBCTLogging || ysr@777: G1SATBCardTableModRefBS::is_a(bsn); ysr@777: } ysr@777: ysr@777: void write_ref_field_work(void* field, oop new_val); ysr@777: ysr@777: // Can be called from static contexts. ysr@777: static void write_ref_field_static(void* field, oop new_val); ysr@777: ysr@777: // NB: if you do a whole-heap invalidation, the "usual invariant" defined ysr@777: // above no longer applies. ysr@777: void invalidate(MemRegion mr, bool whole_heap = false); ysr@777: ysr@777: void write_region_work(MemRegion mr) { invalidate(mr); } ysr@777: void write_ref_array_work(MemRegion mr) { invalidate(mr); } ysr@777: ysr@777: ysr@777: }; ysr@777: ysr@777: ysr@777: #endif // SERIALGC