1 /* 2 * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. 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_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 25 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 26 27 #include "gc/shared/markBitMap.hpp" 28 #include "memory/allocation.hpp" 29 #include "memory/memRegion.hpp" 30 #include "oops/oopsHierarchy.hpp" 31 32 /** 33 * Encapsulate a marking bitmap with the top-at-mark-start and top-bitmaps array. 34 */ 35 class ShenandoahMarkingContext : public CHeapObj<mtGC> { 36 private: 37 MarkBitMap _mark_bit_map; 38 39 HeapWord** const _top_bitmaps; 40 HeapWord** const _top_at_mark_starts_base; 41 HeapWord** const _top_at_mark_starts; 42 43 ShenandoahSharedFlag _is_complete; 44 45 public: 46 ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions); 47 48 /* 49 * Marks the object. Returns true if the object has not been marked before and has 50 * been marked by this thread. Returns false if the object has already been marked, 51 * or if a competing thread succeeded in marking this object. 52 */ 53 inline bool mark(oop obj); 54 55 inline bool is_marked(oop obj) const; 56 57 inline bool allocated_after_mark_start(HeapWord* addr) const; 58 59 inline MarkBitMap* mark_bit_map(); 60 61 HeapWord* top_at_mark_start(ShenandoahHeapRegion* r) const; 62 void capture_top_at_mark_start(ShenandoahHeapRegion* r); 63 void reset_top_at_mark_start(ShenandoahHeapRegion* r); 64 void initialize_top_at_mark_start(ShenandoahHeapRegion* r); 65 66 void reset_top_bitmap(ShenandoahHeapRegion *r); 67 void clear_bitmap(ShenandoahHeapRegion *r); 68 69 bool is_bitmap_clear() const; 70 bool is_bitmap_clear_range(HeapWord* start, HeapWord* end) const; 71 72 bool is_complete(); 73 void mark_complete(); 74 void mark_incomplete(); 75 76 }; 77 78 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP