130 bool _read_only;
131 bool _has_embedded_pointer;
132 FollowMode _follow_mode;
133 int _size_in_bytes;
134 int _id; // Each object has a unique serial ID, starting from zero. The ID is assigned
135 // when the object is added into _source_objs.
136 MetaspaceObj::Type _msotype;
137 address _source_addr; // The source object to be copied.
138 address _buffered_addr; // The copy of this object insider the buffer.
139 public:
140 SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
141 _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _has_embedded_pointer(false), _follow_mode(follow_mode),
142 _size_in_bytes(ref->size() * BytesPerWord), _id(0), _msotype(ref->msotype()),
143 _source_addr(ref->obj()) {
144 if (follow_mode == point_to_it) {
145 _buffered_addr = ref->obj();
146 } else {
147 _buffered_addr = nullptr;
148 }
149 }
150
151 // This constructor is only used for regenerated objects (created by LambdaFormInvokers, etc).
152 // src = address of a Method or InstanceKlass that has been regenerated.
153 // renegerated_obj_info = info for the regenerated version of src.
154 SourceObjInfo(address src, SourceObjInfo* renegerated_obj_info) :
155 _ptrmap_start(0), _ptrmap_end(0), _read_only(false),
156 _follow_mode(renegerated_obj_info->_follow_mode),
157 _size_in_bytes(0), _msotype(renegerated_obj_info->_msotype),
158 _source_addr(src), _buffered_addr(renegerated_obj_info->_buffered_addr) {}
159
160 bool should_copy() const { return _follow_mode == make_a_copy; }
161 void set_buffered_addr(address addr) {
162 assert(should_copy(), "must be");
163 assert(_buffered_addr == nullptr, "cannot be copied twice");
164 assert(addr != nullptr, "must be a valid copy");
165 _buffered_addr = addr;
166 }
167 void set_ptrmap_start(uintx v) { _ptrmap_start = v; }
168 void set_ptrmap_end(uintx v) { _ptrmap_end = v; }
169 uintx ptrmap_start() const { return _ptrmap_start; } // inclusive
210 ReservedSpace _shared_rs;
211 VirtualSpace _shared_vs;
212
213 // The "pz" region is used only during static dumps to reserve an unused space between SharedBaseAddress and
214 // the bottom of the rw region. During runtime, this space will be filled with a reserved area that disallows
215 // read/write/exec, so we can track for bad CompressedKlassPointers encoding.
216 // Note: this region does NOT exist in the cds archive.
217 DumpRegion _pz_region;
218
219 DumpRegion _rw_region;
220 DumpRegion _ro_region;
221 DumpRegion _ac_region; // AOT code
222
223 // Combined bitmap to track pointers in both RW and RO regions. This is updated
224 // as objects are copied into RW and RO.
225 CHeapBitMap _ptrmap;
226
227 // _ptrmap is split into these two bitmaps which are written into the archive.
228 CHeapBitMap _rw_ptrmap; // marks pointers in the RW region
229 CHeapBitMap _ro_ptrmap; // marks pointers in the RO region
230
231 SourceObjList _rw_src_objs; // objs to put in rw region
232 SourceObjList _ro_src_objs; // objs to put in ro region
233 ResizeableHashTable<address, SourceObjInfo, AnyObj::C_HEAP, mtClassShared> _src_obj_table;
234 ResizeableHashTable<address, address, AnyObj::C_HEAP, mtClassShared> _buffered_to_src_table;
235 GrowableArray<Klass*>* _klasses;
236 GrowableArray<Symbol*>* _symbols;
237 unsigned int _entropy_seed;
238
239 // statistics
240 DumpAllocStats _alloc_stats;
241 size_t _total_heap_region_size;
242 struct {
243 size_t _num_ptrs;
244 size_t _num_tagged_ptrs;
245 size_t _num_nulled_ptrs;
246 } _relocated_ptr_info;
247
248 void print_region_stats(FileMapInfo *map_info, ArchiveHeapInfo* heap_info);
249 void print_bitmap_region_stats(size_t size, size_t total_size);
256 // Use this when you allocate space outside of ArchiveBuilder::dump_{rw,ro}_region.
257 // These are usually for misc tables that are allocated in the RO space.
258 class OtherROAllocMark {
259 char* _oldtop;
260 public:
261 OtherROAllocMark() {
262 _oldtop = _current->_ro_region.top();
263 }
264 ~OtherROAllocMark();
265 };
266
267 void count_relocated_pointer(bool tagged, bool nulled);
268
269 private:
270 FollowMode get_follow_mode(MetaspaceClosure::Ref *ref);
271
272 void iterate_sorted_roots(MetaspaceClosure* it);
273 void sort_klasses();
274 static int compare_symbols_by_address(Symbol** a, Symbol** b);
275 static int compare_klass_by_name(Klass** a, Klass** b);
276
277 void make_shallow_copies(DumpRegion *dump_region, const SourceObjList* src_objs);
278 void make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info);
279
280 void relocate_embedded_pointers(SourceObjList* src_objs);
281
282 bool is_excluded(Klass* k);
283 void clean_up_src_obj_table();
284
285 protected:
286 virtual void iterate_roots(MetaspaceClosure* it) = 0;
287 void start_dump_region(DumpRegion* next);
288
289 public:
290 address reserve_buffer();
291
292 address buffer_bottom() const { return _buffer_bottom; }
293 address buffer_top() const { return (address)current_dump_region()->top(); }
294 address requested_static_archive_bottom() const { return _requested_static_archive_bottom; }
295 address mapped_static_archive_bottom() const { return _mapped_static_archive_bottom; }
|
130 bool _read_only;
131 bool _has_embedded_pointer;
132 FollowMode _follow_mode;
133 int _size_in_bytes;
134 int _id; // Each object has a unique serial ID, starting from zero. The ID is assigned
135 // when the object is added into _source_objs.
136 MetaspaceObj::Type _msotype;
137 address _source_addr; // The source object to be copied.
138 address _buffered_addr; // The copy of this object insider the buffer.
139 public:
140 SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
141 _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _has_embedded_pointer(false), _follow_mode(follow_mode),
142 _size_in_bytes(ref->size() * BytesPerWord), _id(0), _msotype(ref->msotype()),
143 _source_addr(ref->obj()) {
144 if (follow_mode == point_to_it) {
145 _buffered_addr = ref->obj();
146 } else {
147 _buffered_addr = nullptr;
148 }
149 }
150 SourceObjInfo(address src, address buf) {
151 _source_addr = src;
152 _buffered_addr = buf;
153 }
154
155 // This constructor is only used for regenerated objects (created by LambdaFormInvokers, etc).
156 // src = address of a Method or InstanceKlass that has been regenerated.
157 // renegerated_obj_info = info for the regenerated version of src.
158 SourceObjInfo(address src, SourceObjInfo* renegerated_obj_info) :
159 _ptrmap_start(0), _ptrmap_end(0), _read_only(false),
160 _follow_mode(renegerated_obj_info->_follow_mode),
161 _size_in_bytes(0), _msotype(renegerated_obj_info->_msotype),
162 _source_addr(src), _buffered_addr(renegerated_obj_info->_buffered_addr) {}
163
164 bool should_copy() const { return _follow_mode == make_a_copy; }
165 void set_buffered_addr(address addr) {
166 assert(should_copy(), "must be");
167 assert(_buffered_addr == nullptr, "cannot be copied twice");
168 assert(addr != nullptr, "must be a valid copy");
169 _buffered_addr = addr;
170 }
171 void set_ptrmap_start(uintx v) { _ptrmap_start = v; }
172 void set_ptrmap_end(uintx v) { _ptrmap_end = v; }
173 uintx ptrmap_start() const { return _ptrmap_start; } // inclusive
214 ReservedSpace _shared_rs;
215 VirtualSpace _shared_vs;
216
217 // The "pz" region is used only during static dumps to reserve an unused space between SharedBaseAddress and
218 // the bottom of the rw region. During runtime, this space will be filled with a reserved area that disallows
219 // read/write/exec, so we can track for bad CompressedKlassPointers encoding.
220 // Note: this region does NOT exist in the cds archive.
221 DumpRegion _pz_region;
222
223 DumpRegion _rw_region;
224 DumpRegion _ro_region;
225 DumpRegion _ac_region; // AOT code
226
227 // Combined bitmap to track pointers in both RW and RO regions. This is updated
228 // as objects are copied into RW and RO.
229 CHeapBitMap _ptrmap;
230
231 // _ptrmap is split into these two bitmaps which are written into the archive.
232 CHeapBitMap _rw_ptrmap; // marks pointers in the RW region
233 CHeapBitMap _ro_ptrmap; // marks pointers in the RO region
234 CHeapBitMap _ac_ptrmap; // marks pointers in the CC region
235
236 SourceObjList _rw_src_objs; // objs to put in rw region
237 SourceObjList _ro_src_objs; // objs to put in ro region
238 ResizeableHashTable<address, SourceObjInfo, AnyObj::C_HEAP, mtClassShared> _src_obj_table;
239 ResizeableHashTable<address, address, AnyObj::C_HEAP, mtClassShared> _buffered_to_src_table;
240 GrowableArray<Klass*>* _klasses;
241 GrowableArray<Symbol*>* _symbols;
242 unsigned int _entropy_seed;
243
244 // statistics
245 DumpAllocStats _alloc_stats;
246 size_t _total_heap_region_size;
247 struct {
248 size_t _num_ptrs;
249 size_t _num_tagged_ptrs;
250 size_t _num_nulled_ptrs;
251 } _relocated_ptr_info;
252
253 void print_region_stats(FileMapInfo *map_info, ArchiveHeapInfo* heap_info);
254 void print_bitmap_region_stats(size_t size, size_t total_size);
261 // Use this when you allocate space outside of ArchiveBuilder::dump_{rw,ro}_region.
262 // These are usually for misc tables that are allocated in the RO space.
263 class OtherROAllocMark {
264 char* _oldtop;
265 public:
266 OtherROAllocMark() {
267 _oldtop = _current->_ro_region.top();
268 }
269 ~OtherROAllocMark();
270 };
271
272 void count_relocated_pointer(bool tagged, bool nulled);
273
274 private:
275 FollowMode get_follow_mode(MetaspaceClosure::Ref *ref);
276
277 void iterate_sorted_roots(MetaspaceClosure* it);
278 void sort_klasses();
279 static int compare_symbols_by_address(Symbol** a, Symbol** b);
280 static int compare_klass_by_name(Klass** a, Klass** b);
281 void update_hidden_class_loader_type(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN;
282
283 void make_shallow_copies(DumpRegion *dump_region, const SourceObjList* src_objs);
284 void make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info);
285
286 void relocate_embedded_pointers(SourceObjList* src_objs);
287
288 bool is_excluded(Klass* k);
289 void clean_up_src_obj_table();
290
291 protected:
292 virtual void iterate_roots(MetaspaceClosure* it) = 0;
293 void start_dump_region(DumpRegion* next);
294
295 public:
296 address reserve_buffer();
297
298 address buffer_bottom() const { return _buffer_bottom; }
299 address buffer_top() const { return (address)current_dump_region()->top(); }
300 address requested_static_archive_bottom() const { return _requested_static_archive_bottom; }
301 address mapped_static_archive_bottom() const { return _mapped_static_archive_bottom; }
|