55 void ArchivePtrMarker::mark_pointer(address* ptr_loc) {
56 assert(_ptrmap != NULL, "not initialized");
57 assert(!_compacted, "cannot mark anymore");
58
59 if (_ptr_base <= ptr_loc && ptr_loc < _ptr_end) {
60 address value = *ptr_loc;
61 // We don't want any pointer that points to very bottom of the archive, otherwise when
62 // MetaspaceShared::default_base_address()==0, we can't distinguish between a pointer
63 // to nothing (NULL) vs a pointer to an objects that happens to be at the very bottom
64 // of the archive.
65 assert(value != (address)_ptr_base, "don't point to the bottom of the archive");
66
67 if (value != NULL) {
68 assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses");
69 size_t idx = ptr_loc - _ptr_base;
70 if (_ptrmap->size() <= idx) {
71 _ptrmap->resize((idx + 1) * 2);
72 }
73 assert(idx < _ptrmap->size(), "must be");
74 _ptrmap->set_bit(idx);
75 //tty->print_cr("Marking pointer [%p] -> %p @ " SIZE_FORMAT_W(9), ptr_loc, *ptr_loc, idx);
76 }
77 }
78 }
79
80 class ArchivePtrBitmapCleaner: public BitMapClosure {
81 CHeapBitMap* _ptrmap;
82 address* _ptr_base;
83 address _relocatable_base;
84 address _relocatable_end;
85 size_t _max_non_null_offset;
86
87 public:
88 ArchivePtrBitmapCleaner(CHeapBitMap* ptrmap, address* ptr_base, address relocatable_base, address relocatable_end) :
89 _ptrmap(ptrmap), _ptr_base(ptr_base),
90 _relocatable_base(relocatable_base), _relocatable_end(relocatable_end), _max_non_null_offset(0) {}
91
92 bool do_bit(size_t offset) {
93 address* ptr_loc = _ptr_base + offset;
94 address ptr_value = *ptr_loc;
95 if (ptr_value != NULL) {
96 assert(_relocatable_base <= ptr_value && ptr_value < _relocatable_end, "do not point to arbitrary locations!");
97 if (_max_non_null_offset < offset) {
|
55 void ArchivePtrMarker::mark_pointer(address* ptr_loc) {
56 assert(_ptrmap != NULL, "not initialized");
57 assert(!_compacted, "cannot mark anymore");
58
59 if (_ptr_base <= ptr_loc && ptr_loc < _ptr_end) {
60 address value = *ptr_loc;
61 // We don't want any pointer that points to very bottom of the archive, otherwise when
62 // MetaspaceShared::default_base_address()==0, we can't distinguish between a pointer
63 // to nothing (NULL) vs a pointer to an objects that happens to be at the very bottom
64 // of the archive.
65 assert(value != (address)_ptr_base, "don't point to the bottom of the archive");
66
67 if (value != NULL) {
68 assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses");
69 size_t idx = ptr_loc - _ptr_base;
70 if (_ptrmap->size() <= idx) {
71 _ptrmap->resize((idx + 1) * 2);
72 }
73 assert(idx < _ptrmap->size(), "must be");
74 _ptrmap->set_bit(idx);
75 //tty->print_cr("Marking pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx);
76 }
77 }
78 }
79
80 void ArchivePtrMarker::clear_pointer(address* ptr_loc) {
81 assert(_ptrmap != NULL, "not initialized");
82 assert(!_compacted, "cannot clear anymore");
83
84 assert(_ptr_base <= ptr_loc && ptr_loc < _ptr_end, "must be");
85 assert(uintx(ptr_loc) % sizeof(intptr_t) == 0, "pointers must be stored in aligned addresses");
86 size_t idx = ptr_loc - _ptr_base;
87 assert(idx < _ptrmap->size(), "cannot clear pointers that have not been marked");
88 _ptrmap->clear_bit(idx);
89 //tty->print_cr("Clearing pointer [" PTR_FORMAT "] -> " PTR_FORMAT " @ " SIZE_FORMAT_W(5), p2i(ptr_loc), p2i(*ptr_loc), idx);
90 }
91
92 class ArchivePtrBitmapCleaner: public BitMapClosure {
93 CHeapBitMap* _ptrmap;
94 address* _ptr_base;
95 address _relocatable_base;
96 address _relocatable_end;
97 size_t _max_non_null_offset;
98
99 public:
100 ArchivePtrBitmapCleaner(CHeapBitMap* ptrmap, address* ptr_base, address relocatable_base, address relocatable_end) :
101 _ptrmap(ptrmap), _ptr_base(ptr_base),
102 _relocatable_base(relocatable_base), _relocatable_end(relocatable_end), _max_non_null_offset(0) {}
103
104 bool do_bit(size_t offset) {
105 address* ptr_loc = _ptr_base + offset;
106 address ptr_value = *ptr_loc;
107 if (ptr_value != NULL) {
108 assert(_relocatable_base <= ptr_value && ptr_value < _relocatable_end, "do not point to arbitrary locations!");
109 if (_max_non_null_offset < offset) {
|