< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.hpp

Print this page

 1 /*
 2  * Copyright (c) 2018, 2021, 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/shenandoah/shenandoahMarkBitMap.hpp"
29 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
30 #include "memory/allocation.hpp"
31 #include "memory/memRegion.hpp"
32 #include "oops/oopsHierarchy.hpp"
33 
34 class ShenandoahObjToScanQueueSet;

35 
36 /**
37  * Encapsulate a marking bitmap with the top-at-mark-start and top-bitmaps array.
38  */
39 class ShenandoahMarkingContext : public CHeapObj<mtGC> {
40 private:
41   // Marking bitmap
42   ShenandoahMarkBitMap _mark_bit_map;
43 
44   HeapWord** const _top_bitmaps;
45   HeapWord** const _top_at_mark_starts_base;
46   HeapWord** const _top_at_mark_starts;
47 
48   ShenandoahSharedFlag _is_complete;
49 
50   // Marking task queues
51   ShenandoahObjToScanQueueSet* _task_queues;
52 
53 public:
54   ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions, uint max_queues);
55   ~ShenandoahMarkingContext();
56 
57   /*
58    * Marks the object. Returns true if the object has not been marked before and has
59    * been marked by this thread. Returns false if the object has already been marked,
60    * or if a competing thread succeeded in marking this object.
61    */
62   inline bool mark_strong(oop obj, bool& was_upgraded);
63   inline bool mark_weak(oop obj);
64 
65   // Simple versions of marking accessors, to be used outside of marking (e.g. no possible concurrent updates)
66   inline bool is_marked(oop) const;
67   inline bool is_marked_strong(oop obj) const;
68   inline bool is_marked_weak(oop obj) const;


69 
70   inline HeapWord* get_next_marked_addr(HeapWord* addr, HeapWord* limit) const;
71 
72   inline bool allocated_after_mark_start(oop obj) const;
73   inline bool allocated_after_mark_start(HeapWord* addr) const;
74 
75   inline HeapWord* top_at_mark_start(ShenandoahHeapRegion* r) const;
76   inline void capture_top_at_mark_start(ShenandoahHeapRegion* r);
77   inline void reset_top_at_mark_start(ShenandoahHeapRegion* r);
78   void initialize_top_at_mark_start(ShenandoahHeapRegion* r);
79 


80   inline void reset_top_bitmap(ShenandoahHeapRegion *r);
81   void clear_bitmap(ShenandoahHeapRegion *r);
82 
83   bool is_bitmap_clear() const;
84   bool is_bitmap_clear_range(HeapWord* start, HeapWord* end) const;
85 
86   bool is_complete();
87   void mark_complete();
88   void mark_incomplete();
89 
90   // Task queues
91   ShenandoahObjToScanQueueSet* task_queues() const { return _task_queues; }
92 };
93 
94 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP

 1 /*
 2  * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
 3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
 4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 5  *
 6  * This code is free software; you can redistribute it and/or modify it
 7  * under the terms of the GNU General Public License version 2 only, as
 8  * published by the Free Software Foundation.
 9  *
10  * This code is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * version 2 for more details (a copy is included in the LICENSE file that
14  * accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License version
17  * 2 along with this work; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  *
20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21  * or visit www.oracle.com if you need additional information or have any
22  * questions.
23  *
24  */
25 
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP
28 
29 #include "gc/shenandoah/shenandoahMarkBitMap.hpp"
30 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
31 #include "memory/allocation.hpp"
32 #include "memory/memRegion.hpp"
33 #include "oops/oopsHierarchy.hpp"
34 
35 class ShenandoahObjToScanQueueSet;
36 class ShenandoahHeapRegion;
37 
38 /**
39  * Encapsulate a marking bitmap with the top-at-mark-start and top-bitmaps array.
40  */
41 class ShenandoahMarkingContext : public CHeapObj<mtGC> {
42 private:
43   // Marking bitmap
44   ShenandoahMarkBitMap _mark_bit_map;
45 
46   HeapWord** const _top_bitmaps;
47   HeapWord** const _top_at_mark_starts_base;
48   HeapWord** const _top_at_mark_starts;
49 
50   ShenandoahSharedFlag _is_complete;
51 



52 public:
53   ShenandoahMarkingContext(MemRegion heap_region, MemRegion bitmap_region, size_t num_regions);

54 
55   /*
56    * Marks the object. Returns true if the object has not been marked before and has
57    * been marked by this thread. Returns false if the object has already been marked,
58    * or if a competing thread succeeded in marking this object.
59    */
60   inline bool mark_strong(oop obj, bool& was_upgraded);
61   inline bool mark_weak(oop obj);
62 
63   // Simple versions of marking accessors, to be used outside of marking (e.g. no possible concurrent updates)
64   inline bool is_marked(oop) const;
65   inline bool is_marked_strong(oop obj) const;
66   inline bool is_marked_weak(oop obj) const;
67   inline bool is_marked_or_old(oop obj) const;
68   inline bool is_marked_strong_or_old(oop obj) const;
69 
70   inline HeapWord* get_next_marked_addr(const HeapWord* addr, const HeapWord* limit) const;
71 
72   inline bool allocated_after_mark_start(oop obj) const;
73   inline bool allocated_after_mark_start(const HeapWord* addr) const;
74 
75   inline HeapWord* top_at_mark_start(const ShenandoahHeapRegion* r) const;
76   inline void capture_top_at_mark_start(ShenandoahHeapRegion* r);
77   inline void reset_top_at_mark_start(ShenandoahHeapRegion* r);
78   void initialize_top_at_mark_start(ShenandoahHeapRegion* r);
79 
80   HeapWord* top_bitmap(ShenandoahHeapRegion* r);
81 
82   inline void reset_top_bitmap(ShenandoahHeapRegion *r);
83   void clear_bitmap(ShenandoahHeapRegion *r);
84 
85   bool is_bitmap_clear() const;
86   bool is_bitmap_range_within_region_clear(const HeapWord* start, const HeapWord* end) const;
87 
88   bool is_complete();
89   void mark_complete();
90   void mark_incomplete();



91 };
92 
93 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_HPP
< prev index next >