< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.

  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_VM_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP
 27 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP
 28 
 29 #include "memory/memRegion.hpp"
 30 #include "runtime/atomic.hpp"
 31 #include "utilities/globalDefinitions.hpp"
 32 
 33 class ShenandoahMarkBitMap {
 34 public:
 35   typedef size_t idx_t;         // Type used for bit and word indices.
 36   typedef uintptr_t bm_word_t;  // Element type of array that represents the
 37                                 // bitmap, with BitsPerWord bits per element.
 38 
 39 private:
 40   // Values for get_next_bit_impl flip parameter.
 41   static const bm_word_t find_ones_flip = 0;
 42   static const bm_word_t find_zeros_flip = ~(bm_word_t)0;
 43 
 44   int const _shift;
 45   MemRegion _covered;
 46 
 47   bm_word_t* _map;     // First word in bitmap

142   ShenandoahMarkBitMap(MemRegion heap, MemRegion storage);
143 
144   // Mark word as 'strong' if it hasn't been marked strong yet.
145   // Return true if the word has been marked strong, false if it has already been
146   // marked strong or if another thread has beat us by marking it
147   // strong.
148   // Words that have been marked final before or by a concurrent thread will be
149   // upgraded to strong. In this case, this method also returns true.
150   inline bool mark_strong(HeapWord* w, bool& was_upgraded);
151 
152   // Mark word as 'weak' if it hasn't been marked weak or strong yet.
153   // Return true if the word has been marked weak, false if it has already been
154   // marked strong or weak or if another thread has beat us by marking it
155   // strong or weak.
156   inline bool mark_weak(HeapWord* heap_addr);
157 
158   inline bool is_marked(HeapWord* addr) const;
159   inline bool is_marked_strong(HeapWord* w)  const;
160   inline bool is_marked_weak(HeapWord* addr) const;
161 


162   // Return the address corresponding to the next marked bit at or after
163   // "addr", and before "limit", if "limit" is non-null.  If there is no
164   // such bit, returns "limit" if that is non-null, or else "endWord()".
165   HeapWord* get_next_marked_addr(const HeapWord* addr,
166                                  const HeapWord* limit) const;
167 
168   bm_word_t inverted_bit_mask_for_range(idx_t beg, idx_t end) const;
169   void  clear_range_within_word    (idx_t beg, idx_t end);
170   void clear_range (idx_t beg, idx_t end);
171   void clear_range_large(MemRegion mr);
172 
173   void clear_range_of_words(idx_t beg, idx_t end);
174   void clear_large_range_of_words(idx_t beg, idx_t end);
175   static void clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end);
176 
177 };
178 
179 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP

  1 /*
  2  * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.
  4  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  6  *
  7  * This code is free software; you can redistribute it and/or modify it
  8  * under the terms of the GNU General Public License version 2 only, as
  9  * published by the Free Software Foundation.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  *
 25  */
 26 
 27 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP
 28 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP
 29 
 30 #include "memory/memRegion.hpp"
 31 #include "runtime/atomic.hpp"
 32 #include "utilities/globalDefinitions.hpp"
 33 
 34 class ShenandoahMarkBitMap {
 35 public:
 36   typedef size_t idx_t;         // Type used for bit and word indices.
 37   typedef uintptr_t bm_word_t;  // Element type of array that represents the
 38                                 // bitmap, with BitsPerWord bits per element.
 39 
 40 private:
 41   // Values for get_next_bit_impl flip parameter.
 42   static const bm_word_t find_ones_flip = 0;
 43   static const bm_word_t find_zeros_flip = ~(bm_word_t)0;
 44 
 45   int const _shift;
 46   MemRegion _covered;
 47 
 48   bm_word_t* _map;     // First word in bitmap

143   ShenandoahMarkBitMap(MemRegion heap, MemRegion storage);
144 
145   // Mark word as 'strong' if it hasn't been marked strong yet.
146   // Return true if the word has been marked strong, false if it has already been
147   // marked strong or if another thread has beat us by marking it
148   // strong.
149   // Words that have been marked final before or by a concurrent thread will be
150   // upgraded to strong. In this case, this method also returns true.
151   inline bool mark_strong(HeapWord* w, bool& was_upgraded);
152 
153   // Mark word as 'weak' if it hasn't been marked weak or strong yet.
154   // Return true if the word has been marked weak, false if it has already been
155   // marked strong or weak or if another thread has beat us by marking it
156   // strong or weak.
157   inline bool mark_weak(HeapWord* heap_addr);
158 
159   inline bool is_marked(HeapWord* addr) const;
160   inline bool is_marked_strong(HeapWord* w)  const;
161   inline bool is_marked_weak(HeapWord* addr) const;
162 
163   bool is_bitmap_clear_range(const HeapWord* start, const HeapWord* end) const;
164 
165   // Return the address corresponding to the next marked bit at or after
166   // "addr", and before "limit", if "limit" is non-null.  If there is no
167   // such bit, returns "limit" if that is non-null, or else "endWord()".
168   HeapWord* get_next_marked_addr(const HeapWord* addr,
169                                  const HeapWord* limit) const;
170 
171   bm_word_t inverted_bit_mask_for_range(idx_t beg, idx_t end) const;
172   void  clear_range_within_word    (idx_t beg, idx_t end);
173   void clear_range (idx_t beg, idx_t end);
174   void clear_range_large(MemRegion mr);
175 
176   void clear_range_of_words(idx_t beg, idx_t end);
177   void clear_large_range_of_words(idx_t beg, idx_t end);
178   static void clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end);
179 
180 };
181 
182 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKBITMAP_HPP
< prev index next >