1 /* 2 * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP 27 28 #include "gc/shared/markBitMap.hpp" 29 #include "memory/allocation.hpp" 30 #include "memory/memRegion.hpp" 31 #include "oops/oopsHierarchy.hpp" 32 33 /** 34 * Encapsulate a marking bitmap with the top-at-mark-start and top-bitmaps array. 35 */ 36 class ShenandoahMarkingContext : public CHeapObj<mtGC> { 37 private: 38 MarkBitMap _mark_bit_map; 39 40 HeapWord** const _top_bitmaps; 41 HeapWord** const _top_at_mark_starts_base; 42 HeapWord** const _top_at_mark_starts; 43 44 ShenandoahSharedFlag _is_complete; 45 46 public: 47 ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions); 48 49 /* 50 * Marks the object. Returns true if the object has not been marked before and has 51 * been marked by this thread. Returns false if the object has already been marked, 52 * or if a competing thread succeeded in marking this object. 53 */ 54 inline bool mark(oop obj); 55 56 inline bool is_marked(oop obj) const; 57 58 inline bool allocated_after_mark_start(HeapWord* addr) const; 59 60 inline MarkBitMap* mark_bit_map(); 61 62 HeapWord* top_at_mark_start(ShenandoahHeapRegion* r) const; 63 void capture_top_at_mark_start(ShenandoahHeapRegion* r); 64 void reset_top_at_mark_start(ShenandoahHeapRegion* r); 65 void initialize_top_at_mark_start(ShenandoahHeapRegion* r); 66 67 void reset_top_bitmap(ShenandoahHeapRegion *r); 68 void clear_bitmap(ShenandoahHeapRegion *r); 69 70 bool is_bitmap_clear() const; 71 bool is_bitmap_clear_range(HeapWord* start, HeapWord* end) const; 72 73 bool is_complete(); 74 void mark_complete(); 75 void mark_incomplete(); 76 77 }; 78 79 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP