1 /* 2 * Copyright (c) 2013, 2018, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/g1/g1BarrierSet.hpp" 26 #include "gc/shenandoah/shenandoahAsserts.hpp" 27 #include "gc/shenandoah/shenandoahBarrierSet.hpp" 28 #include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" 29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" 30 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 31 #include "gc/shenandoah/shenandoahHeuristics.hpp" 32 #include "gc/shenandoah/shenandoahTraversalGC.hpp" 33 #include "memory/iterator.inline.hpp" 34 #include "runtime/interfaceSupport.inline.hpp" 35 #ifdef COMPILER1 36 #include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp" 37 #endif 38 #ifdef COMPILER2 39 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" 40 #endif 41 42 class ShenandoahBarrierSetC1; 43 class ShenandoahBarrierSetC2; 44 45 ShenandoahBarrierSet::ShenandoahBarrierSet(ShenandoahHeap* heap) : 46 ShenandoahBaseBarrierSet(make_barrier_set_assembler<ShenandoahBarrierSetAssembler>(), 47 make_barrier_set_c1<ShenandoahBarrierSetC1>(), 48 make_barrier_set_c2<ShenandoahBarrierSetC2>(), 49 BarrierSet::FakeRtti(BarrierSet::Shenandoah), 50 heap) {} 51 52 void ShenandoahBarrierSet::print_on(outputStream* st) const { 53 st->print("ShenandoahBarrierSet"); 54 } 55 56 bool ShenandoahBarrierSet::is_a(BarrierSet::Name bsn) { 57 return bsn == BarrierSet::Shenandoah; 58 } 59 60 template <class T> 61 inline void ShenandoahBarrierSet::inline_write_ref_field_pre(T* field, oop new_val) { 62 shenandoah_assert_not_in_cset_loc_except(field, _heap->cancelled_gc()); 63 if (_heap->is_concurrent_mark_in_progress()) { 64 T heap_oop = RawAccess<>::oop_load(field); 65 if (!CompressedOops::is_null(heap_oop)) { 66 enqueue(CompressedOops::decode(heap_oop)); 67 } 68 } 69 } 70 71 // These are the more general virtual versions. 72 void ShenandoahBarrierSet::write_ref_field_pre_work(oop* field, oop new_val) { 73 inline_write_ref_field_pre(field, new_val); 74 } 75 76 void ShenandoahBarrierSet::write_ref_field_pre_work(narrowOop* field, oop new_val) { 77 inline_write_ref_field_pre(field, new_val); 78 } 79 80 void ShenandoahBarrierSet::write_ref_field_pre_work(void* field, oop new_val) { 81 guarantee(false, "Not needed"); 82 } 83 84 void ShenandoahBarrierSet::write_ref_field_work(void* v, oop o, bool release) { 85 shenandoah_assert_not_in_cset_loc_except(v, _heap->cancelled_gc()); 86 shenandoah_assert_not_forwarded_except (v, o, o == NULL || _heap->cancelled_gc() || !_heap->is_concurrent_mark_in_progress()); 87 shenandoah_assert_not_in_cset_except (v, o, o == NULL || _heap->cancelled_gc() || !_heap->is_concurrent_mark_in_progress()); 88 }