< prev index next >

src/hotspot/share/cds/archiveBuilder.hpp

Print this page

131     bool _read_only;
132     bool _has_embedded_pointer;
133     FollowMode _follow_mode;
134     int _size_in_bytes;
135     int _id; // Each object has a unique serial ID, starting from zero. The ID is assigned
136              // when the object is added into _source_objs.
137     MetaspaceObj::Type _msotype;
138     address _source_addr;    // The source object to be copied.
139     address _buffered_addr;  // The copy of this object insider the buffer.
140   public:
141     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
142       _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _has_embedded_pointer(false), _follow_mode(follow_mode),
143       _size_in_bytes(ref->size() * BytesPerWord), _id(0), _msotype(ref->msotype()),
144       _source_addr(ref->obj()) {
145       if (follow_mode == point_to_it) {
146         _buffered_addr = ref->obj();
147       } else {
148         _buffered_addr = nullptr;
149       }
150     }




151 
152     // This constructor is only used for regenerated objects (created by LambdaFormInvokers, etc).
153     //   src = address of a Method or InstanceKlass that has been regenerated.
154     //   renegerated_obj_info = info for the regenerated version of src.
155     SourceObjInfo(address src, SourceObjInfo* renegerated_obj_info) :
156       _ptrmap_start(0), _ptrmap_end(0), _read_only(false),
157       _follow_mode(renegerated_obj_info->_follow_mode),
158       _size_in_bytes(0), _msotype(renegerated_obj_info->_msotype),
159       _source_addr(src),  _buffered_addr(renegerated_obj_info->_buffered_addr) {}
160 
161     bool should_copy() const { return _follow_mode == make_a_copy; }
162     void set_buffered_addr(address addr)  {
163       assert(should_copy(), "must be");
164       assert(_buffered_addr == nullptr, "cannot be copied twice");
165       assert(addr != nullptr, "must be a valid copy");
166       _buffered_addr = addr;
167     }
168     void set_ptrmap_start(uintx v) { _ptrmap_start = v;    }
169     void set_ptrmap_end(uintx v)   { _ptrmap_end = v;      }
170     uintx ptrmap_start()  const    { return _ptrmap_start; } // inclusive

211   ReservedSpace _shared_rs;
212   VirtualSpace _shared_vs;
213 
214   // The "pz" region is used only during static dumps to reserve an unused space between SharedBaseAddress and
215   // the bottom of the rw region. During runtime, this space will be filled with a reserved area that disallows
216   // read/write/exec, so we can track for bad CompressedKlassPointers encoding.
217   // Note: this region does NOT exist in the cds archive.
218   DumpRegion _pz_region;
219 
220   DumpRegion _rw_region;
221   DumpRegion _ro_region;
222   DumpRegion _ac_region; // AOT code
223 
224   // Combined bitmap to track pointers in both RW and RO regions. This is updated
225   // as objects are copied into RW and RO.
226   CHeapBitMap _ptrmap;
227 
228   // _ptrmap is split into these two bitmaps which are written into the archive.
229   CHeapBitMap _rw_ptrmap;   // marks pointers in the RW region
230   CHeapBitMap _ro_ptrmap;   // marks pointers in the RO region

231 
232   SourceObjList _rw_src_objs;                 // objs to put in rw region
233   SourceObjList _ro_src_objs;                 // objs to put in ro region
234   ResizeableHashTable<address, SourceObjInfo, AnyObj::C_HEAP, mtClassShared> _src_obj_table;
235   ResizeableHashTable<address, address, AnyObj::C_HEAP, mtClassShared> _buffered_to_src_table;
236   GrowableArray<Klass*>* _klasses;
237   GrowableArray<Symbol*>* _symbols;
238   unsigned int _entropy_seed;
239 
240   // statistics
241   DumpAllocStats _alloc_stats;
242   size_t _total_heap_region_size;
243   struct {
244     size_t _num_ptrs;
245     size_t _num_tagged_ptrs;
246     size_t _num_nulled_ptrs;
247   } _relocated_ptr_info;
248 
249   void print_region_stats(FileMapInfo *map_info,
250                           ArchiveMappedHeapInfo* mapped_heap_info,

259   // Use this when you allocate space outside of ArchiveBuilder::dump_{rw,ro}_region.
260   // These are usually for misc tables that are allocated in the RO space.
261   class OtherROAllocMark {
262     char* _oldtop;
263   public:
264     OtherROAllocMark() {
265       _oldtop = _current->_ro_region.top();
266     }
267     ~OtherROAllocMark();
268   };
269 
270   void count_relocated_pointer(bool tagged, bool nulled);
271 
272 private:
273   FollowMode get_follow_mode(MetaspaceClosure::Ref *ref);
274 
275   void iterate_sorted_roots(MetaspaceClosure* it);
276   void sort_klasses();
277   static int compare_symbols_by_address(Symbol** a, Symbol** b);
278   static int compare_klass_by_name(Klass** a, Klass** b);

279 
280   void make_shallow_copies(DumpRegion *dump_region, const SourceObjList* src_objs);
281   void make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info);
282 
283   void relocate_embedded_pointers(SourceObjList* src_objs);
284 
285   bool is_excluded(Klass* k);
286   void clean_up_src_obj_table();
287 
288 protected:
289   virtual void iterate_roots(MetaspaceClosure* it) = 0;
290   void start_dump_region(DumpRegion* next);
291 
292 public:
293   address reserve_buffer();
294 
295   address buffer_bottom()                    const { return _buffer_bottom;                        }
296   address buffer_top()                       const { return (address)current_dump_region()->top(); }
297   address requested_static_archive_bottom()  const { return  _requested_static_archive_bottom;     }
298   address mapped_static_archive_bottom()     const { return  _mapped_static_archive_bottom;        }

131     bool _read_only;
132     bool _has_embedded_pointer;
133     FollowMode _follow_mode;
134     int _size_in_bytes;
135     int _id; // Each object has a unique serial ID, starting from zero. The ID is assigned
136              // when the object is added into _source_objs.
137     MetaspaceObj::Type _msotype;
138     address _source_addr;    // The source object to be copied.
139     address _buffered_addr;  // The copy of this object insider the buffer.
140   public:
141     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
142       _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _has_embedded_pointer(false), _follow_mode(follow_mode),
143       _size_in_bytes(ref->size() * BytesPerWord), _id(0), _msotype(ref->msotype()),
144       _source_addr(ref->obj()) {
145       if (follow_mode == point_to_it) {
146         _buffered_addr = ref->obj();
147       } else {
148         _buffered_addr = nullptr;
149       }
150     }
151     SourceObjInfo(address src, address buf) {
152       _source_addr = src;
153       _buffered_addr = buf;
154     }
155 
156     // This constructor is only used for regenerated objects (created by LambdaFormInvokers, etc).
157     //   src = address of a Method or InstanceKlass that has been regenerated.
158     //   renegerated_obj_info = info for the regenerated version of src.
159     SourceObjInfo(address src, SourceObjInfo* renegerated_obj_info) :
160       _ptrmap_start(0), _ptrmap_end(0), _read_only(false),
161       _follow_mode(renegerated_obj_info->_follow_mode),
162       _size_in_bytes(0), _msotype(renegerated_obj_info->_msotype),
163       _source_addr(src),  _buffered_addr(renegerated_obj_info->_buffered_addr) {}
164 
165     bool should_copy() const { return _follow_mode == make_a_copy; }
166     void set_buffered_addr(address addr)  {
167       assert(should_copy(), "must be");
168       assert(_buffered_addr == nullptr, "cannot be copied twice");
169       assert(addr != nullptr, "must be a valid copy");
170       _buffered_addr = addr;
171     }
172     void set_ptrmap_start(uintx v) { _ptrmap_start = v;    }
173     void set_ptrmap_end(uintx v)   { _ptrmap_end = v;      }
174     uintx ptrmap_start()  const    { return _ptrmap_start; } // inclusive

215   ReservedSpace _shared_rs;
216   VirtualSpace _shared_vs;
217 
218   // The "pz" region is used only during static dumps to reserve an unused space between SharedBaseAddress and
219   // the bottom of the rw region. During runtime, this space will be filled with a reserved area that disallows
220   // read/write/exec, so we can track for bad CompressedKlassPointers encoding.
221   // Note: this region does NOT exist in the cds archive.
222   DumpRegion _pz_region;
223 
224   DumpRegion _rw_region;
225   DumpRegion _ro_region;
226   DumpRegion _ac_region; // AOT code
227 
228   // Combined bitmap to track pointers in both RW and RO regions. This is updated
229   // as objects are copied into RW and RO.
230   CHeapBitMap _ptrmap;
231 
232   // _ptrmap is split into these two bitmaps which are written into the archive.
233   CHeapBitMap _rw_ptrmap;   // marks pointers in the RW region
234   CHeapBitMap _ro_ptrmap;   // marks pointers in the RO region
235   CHeapBitMap _ac_ptrmap;   // marks pointers in the CC region
236 
237   SourceObjList _rw_src_objs;                 // objs to put in rw region
238   SourceObjList _ro_src_objs;                 // objs to put in ro region
239   ResizeableHashTable<address, SourceObjInfo, AnyObj::C_HEAP, mtClassShared> _src_obj_table;
240   ResizeableHashTable<address, address, AnyObj::C_HEAP, mtClassShared> _buffered_to_src_table;
241   GrowableArray<Klass*>* _klasses;
242   GrowableArray<Symbol*>* _symbols;
243   unsigned int _entropy_seed;
244 
245   // statistics
246   DumpAllocStats _alloc_stats;
247   size_t _total_heap_region_size;
248   struct {
249     size_t _num_ptrs;
250     size_t _num_tagged_ptrs;
251     size_t _num_nulled_ptrs;
252   } _relocated_ptr_info;
253 
254   void print_region_stats(FileMapInfo *map_info,
255                           ArchiveMappedHeapInfo* mapped_heap_info,

264   // Use this when you allocate space outside of ArchiveBuilder::dump_{rw,ro}_region.
265   // These are usually for misc tables that are allocated in the RO space.
266   class OtherROAllocMark {
267     char* _oldtop;
268   public:
269     OtherROAllocMark() {
270       _oldtop = _current->_ro_region.top();
271     }
272     ~OtherROAllocMark();
273   };
274 
275   void count_relocated_pointer(bool tagged, bool nulled);
276 
277 private:
278   FollowMode get_follow_mode(MetaspaceClosure::Ref *ref);
279 
280   void iterate_sorted_roots(MetaspaceClosure* it);
281   void sort_klasses();
282   static int compare_symbols_by_address(Symbol** a, Symbol** b);
283   static int compare_klass_by_name(Klass** a, Klass** b);
284   void update_hidden_class_loader_type(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN;
285 
286   void make_shallow_copies(DumpRegion *dump_region, const SourceObjList* src_objs);
287   void make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* src_info);
288 
289   void relocate_embedded_pointers(SourceObjList* src_objs);
290 
291   bool is_excluded(Klass* k);
292   void clean_up_src_obj_table();
293 
294 protected:
295   virtual void iterate_roots(MetaspaceClosure* it) = 0;
296   void start_dump_region(DumpRegion* next);
297 
298 public:
299   address reserve_buffer();
300 
301   address buffer_bottom()                    const { return _buffer_bottom;                        }
302   address buffer_top()                       const { return (address)current_dump_region()->top(); }
303   address requested_static_archive_bottom()  const { return  _requested_static_archive_bottom;     }
304   address mapped_static_archive_bottom()     const { return  _mapped_static_archive_bottom;        }
< prev index next >