1 /* 2 * Copyright (c) 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 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 26 27 #include "gc_implementation/shared/markBitMap.hpp" 28 #include "memory/allocation.hpp" 29 #include "memory/memRegion.hpp" 30 #include "oops/oopsHierarchy.hpp" 31 32 class HeapWord; 33 34 /** 35 * Encapsulate a marking bitmap with a top-at-mark-start array. 36 */ 37 class ShenandoahMarkingContext : public CHeapObj<mtGC> { 38 private: 39 MarkBitMap _mark_bit_map; 40 41 HeapWord** const _top_at_mark_starts_base; 42 HeapWord** const _top_at_mark_starts; 43 44 public: 45 ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions); 46 47 /* 48 * Marks the object. Returns true if the object has not been marked before and has 49 * been marked by this thread. Returns false if the object has already been marked, 50 * or if a competing thread succeeded in marking this object. 51 */ 52 inline bool mark(oop obj); 53 54 inline bool is_marked(oop obj) const; 55 56 inline bool allocated_after_mark_start(HeapWord* addr) const; 57 58 inline MarkBitMap* mark_bit_map(); 59 HeapWord* top_at_mark_start(size_t region_number) const; 60 void set_top_at_mark_start(size_t region_number, HeapWord* tams); 61 62 void clear_bitmap(HeapWord* start, HeapWord* end); 63 64 bool is_bitmap_clear() const; 65 bool is_bitmap_clear_range(HeapWord* start, HeapWord* end) const; 66 67 }; 68 69 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP