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_VM_GC_SHARED_CMBITMAP_HPP
26 #define SHARE_VM_GC_SHARED_CMBITMAP_HPP
27
28 #include "memory/memRegion.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "utilities/bitMap.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // A generic CM bit map. This is essentially a wrapper around the BitMap
34 // class, with one bit per (1<<_shifter) HeapWords.
35
36 class MarkBitMapRO VALUE_OBJ_CLASS_SPEC {
37 protected:
38 HeapWord* _bmStartWord; // base address of range covered by map
39 size_t _bmWordSize; // map size (in #HeapWords covered)
40 const int _shifter; // map to char or bit
41 BitMap _bm; // the bit map itself
42
43 public:
44 // constructor
45 MarkBitMapRO(int shifter);
46
47 // inquiries
48 HeapWord* startWord() const { return _bmStartWord; }
49 // the following is one past the last word in space
50 HeapWord* endWord() const { return _bmStartWord + _bmWordSize; }
51
52 // read marks
53
54 bool isMarked(HeapWord* addr) const {
55 assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
56 "outside underlying space?");
57 return _bm.at(heapWordToOffset(addr));
67 const HeapWord* limit = NULL) const;
68
69 // conversion utilities
70 HeapWord* offsetToHeapWord(size_t offset) const {
71 return _bmStartWord + (offset << _shifter);
72 }
73 size_t heapWordToOffset(const HeapWord* addr) const {
74 return pointer_delta(addr, _bmStartWord) >> _shifter;
75 }
76
77 // The argument addr should be the start address of a valid object
78 inline HeapWord* nextObject(HeapWord* addr);
79
80 void print_on_error(outputStream* st, const char* prefix) const;
81
82 // debugging
83 NOT_PRODUCT(bool covers(MemRegion rs) const;)
84 };
85
86 class MarkBitMap : public MarkBitMapRO {
87
88 public:
89 static size_t compute_size(size_t heap_size);
90 // Returns the amount of bytes on the heap between two marks in the bitmap.
91 static size_t mark_distance();
92 // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
93 // mark bitmap corresponds to. This is the same as the mark distance above. static size_t heap_map_factor() {
94 static size_t heap_map_factor() {
95 return mark_distance();
96 }
97
98 MarkBitMap() : MarkBitMapRO(LogMinObjAlignment) {}
99
100 // Initializes the underlying BitMap to cover the given area.
101 void initialize(MemRegion heap, MemRegion bitmap);
102
103 // Write marks.
104 inline void mark(HeapWord* addr);
105 inline void clear(HeapWord* addr);
106 inline bool parMark(HeapWord* addr);
107
108 // Clear range. For larger regions, use *_large.
109 void clear_range(MemRegion mr);
110 void clear_range_large(MemRegion mr);
111 };
112
113 #endif // SHARE_VM_GC_SHARED_CMBITMAP_HPP
|
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_VM_GC_SHARED_CMBITMAP_HPP
26 #define SHARE_VM_GC_SHARED_CMBITMAP_HPP
27
28 #include "memory/memRegion.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "utilities/bitMap.hpp"
31 #include "utilities/globalDefinitions.hpp"
32
33 // A generic CM bit map. This is essentially a wrapper around the BitMap
34 // class, with one bit per (1<<_shifter) HeapWords.
35
36 class MarkBitMapRO VALUE_OBJ_CLASS_SPEC {
37 protected:
38 MemRegion _covered; // The heap area covered by this bitmap.
39 HeapWord* _bmStartWord; // base address of range covered by map
40 size_t _bmWordSize; // map size (in #HeapWords covered)
41 const int _shifter; // map to char or bit
42 BitMap _bm; // the bit map itself
43
44 public:
45 // constructor
46 MarkBitMapRO(int shifter);
47
48 // inquiries
49 HeapWord* startWord() const { return _bmStartWord; }
50 // the following is one past the last word in space
51 HeapWord* endWord() const { return _bmStartWord + _bmWordSize; }
52
53 // read marks
54
55 bool isMarked(HeapWord* addr) const {
56 assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
57 "outside underlying space?");
58 return _bm.at(heapWordToOffset(addr));
68 const HeapWord* limit = NULL) const;
69
70 // conversion utilities
71 HeapWord* offsetToHeapWord(size_t offset) const {
72 return _bmStartWord + (offset << _shifter);
73 }
74 size_t heapWordToOffset(const HeapWord* addr) const {
75 return pointer_delta(addr, _bmStartWord) >> _shifter;
76 }
77
78 // The argument addr should be the start address of a valid object
79 inline HeapWord* nextObject(HeapWord* addr);
80
81 void print_on_error(outputStream* st, const char* prefix) const;
82
83 // debugging
84 NOT_PRODUCT(bool covers(MemRegion rs) const;)
85 };
86
87 class MarkBitMap : public MarkBitMapRO {
88 private:
89 // Clear bitmap range
90 void do_clear(MemRegion mr, bool large);
91
92 public:
93 static size_t compute_size(size_t heap_size);
94 // Returns the amount of bytes on the heap between two marks in the bitmap.
95 static size_t mark_distance();
96 // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
97 // mark bitmap corresponds to. This is the same as the mark distance above. static size_t heap_map_factor() {
98 static size_t heap_map_factor() {
99 return mark_distance();
100 }
101
102 MarkBitMap() : MarkBitMapRO(LogMinObjAlignment) {}
103
104 // Initializes the underlying BitMap to cover the given area.
105 void initialize(MemRegion heap, MemRegion bitmap);
106
107 // Write marks.
108 inline void mark(HeapWord* addr);
109 inline void clear(HeapWord* addr);
110 inline bool parMark(HeapWord* addr);
111
112 // Clear range. For larger regions, use *_large.
113 void clear() { do_clear(_covered, true); }
114 void clear_range(MemRegion mr) { do_clear(mr, false); }
115 void clear_range_large(MemRegion mr) { do_clear(mr, true); }
116 };
117
118 #endif // SHARE_VM_GC_SHARED_CMBITMAP_HPP
|