< prev index next >

src/hotspot/share/cds/archiveBuilder.hpp

Print this page

 83   // may be different than _requested_static_archive_{bottom,top} due to ASLR
 84   address _mapped_static_archive_bottom;
 85   address _mapped_static_archive_top;
 86 
 87   intx _buffer_to_requested_delta;
 88 
 89   DumpRegion* current_dump_space() const {  return _current_dump_space;  }
 90 
 91 public:
 92   enum FollowMode {
 93     make_a_copy, point_to_it, set_to_null
 94   };
 95 
 96 private:
 97   class SpecialRefInfo {
 98     // We have a "special pointer" of the given _type at _field_offset of _src_obj.
 99     // See MetaspaceClosure::push_special().
100     MetaspaceClosure::SpecialRef _type;
101     address _src_obj;
102     size_t _field_offset;

103 
104   public:
105     SpecialRefInfo() {}
106     SpecialRefInfo(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset)
107       : _type(type), _src_obj(src_obj), _field_offset(field_offset) {}


108 
109     MetaspaceClosure::SpecialRef type() const { return _type;         }
110     address src_obj()                   const { return _src_obj;      }
111     size_t field_offset()               const { return _field_offset; }


112   };
113 
114   class SourceObjInfo {
115     MetaspaceClosure::Ref* _ref;
116     uintx _ptrmap_start;     // The bit-offset of the start of this object (inclusive)
117     uintx _ptrmap_end;       // The bit-offset of the end   of this object (exclusive)
118     bool _read_only;
119     FollowMode _follow_mode;
120     int _size_in_bytes;
121     MetaspaceObj::Type _msotype;
122     address _dumped_addr;    // Address this->obj(), as used by the dumped archive.
123     address _orig_obj;       // The value of the original object (_ref->obj()) when this
124                              // SourceObjInfo was created. Note that _ref->obj() may change
125                              // later if _ref is relocated.
126 
127   public:
128     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
129       _ref(ref), _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
130       _size_in_bytes(ref->size() * BytesPerWord), _msotype(ref->msotype()),
131       _orig_obj(ref->obj()) {

316     return (u4)offset;
317   }
318 
319   template <typename T>
320   u4 any_to_offset_u4(T p) const {
321     uintx offset = any_to_offset((address)p);
322     guarantee(offset <= MAX_SHARED_DELTA, "must be 32-bit offset");
323     return (u4)offset;
324   }
325 
326   static void assert_is_vm_thread() PRODUCT_RETURN;
327 
328 public:
329   ArchiveBuilder();
330   ~ArchiveBuilder();
331 
332   void gather_klasses_and_symbols();
333   void gather_source_objs();
334   bool gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool read_only);
335   bool gather_one_source_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref, bool read_only);
336   void add_special_ref(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset);


337   void remember_embedded_pointer_in_copied_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref);
338 
339   DumpRegion* rw_region() { return &_rw_region; }
340   DumpRegion* ro_region() { return &_ro_region; }
341 
342   static char* rw_region_alloc(size_t num_bytes) {
343     return current()->rw_region()->allocate(num_bytes);
344   }
345   static char* ro_region_alloc(size_t num_bytes) {
346     return current()->ro_region()->allocate(num_bytes);
347   }
348 
349   template <typename T>
350   static Array<T>* new_ro_array(int length) {
351     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
352     Array<T>* array = (Array<T>*)ro_region_alloc(byte_size);
353     array->initialize(length);
354     return array;
355   }
356 

 83   // may be different than _requested_static_archive_{bottom,top} due to ASLR
 84   address _mapped_static_archive_bottom;
 85   address _mapped_static_archive_top;
 86 
 87   intx _buffer_to_requested_delta;
 88 
 89   DumpRegion* current_dump_space() const {  return _current_dump_space;  }
 90 
 91 public:
 92   enum FollowMode {
 93     make_a_copy, point_to_it, set_to_null
 94   };
 95 
 96 private:
 97   class SpecialRefInfo {
 98     // We have a "special pointer" of the given _type at _field_offset of _src_obj.
 99     // See MetaspaceClosure::push_special().
100     MetaspaceClosure::SpecialRef _type;
101     address _src_obj;
102     size_t _field_offset;
103     DEBUG_ONLY(size_t _src_obj_size_in_bytes;)
104 
105   public:
106     SpecialRefInfo() {}
107     SpecialRefInfo(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset, size_t src_obj_size_in_bytes)
108       : _type(type), _src_obj(src_obj), _field_offset(field_offset) {
109       DEBUG_ONLY(_src_obj_size_in_bytes = src_obj_size_in_bytes);
110     }
111 
112     MetaspaceClosure::SpecialRef type() const { return _type;         }
113     address src_obj()                   const { return _src_obj;      }
114     size_t field_offset()               const { return _field_offset; }
115 
116     DEBUG_ONLY(size_t src_obj_size_in_bytes() const { return _src_obj_size_in_bytes; })
117   };
118 
119   class SourceObjInfo {
120     MetaspaceClosure::Ref* _ref;
121     uintx _ptrmap_start;     // The bit-offset of the start of this object (inclusive)
122     uintx _ptrmap_end;       // The bit-offset of the end   of this object (exclusive)
123     bool _read_only;
124     FollowMode _follow_mode;
125     int _size_in_bytes;
126     MetaspaceObj::Type _msotype;
127     address _dumped_addr;    // Address this->obj(), as used by the dumped archive.
128     address _orig_obj;       // The value of the original object (_ref->obj()) when this
129                              // SourceObjInfo was created. Note that _ref->obj() may change
130                              // later if _ref is relocated.
131 
132   public:
133     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
134       _ref(ref), _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
135       _size_in_bytes(ref->size() * BytesPerWord), _msotype(ref->msotype()),
136       _orig_obj(ref->obj()) {

321     return (u4)offset;
322   }
323 
324   template <typename T>
325   u4 any_to_offset_u4(T p) const {
326     uintx offset = any_to_offset((address)p);
327     guarantee(offset <= MAX_SHARED_DELTA, "must be 32-bit offset");
328     return (u4)offset;
329   }
330 
331   static void assert_is_vm_thread() PRODUCT_RETURN;
332 
333 public:
334   ArchiveBuilder();
335   ~ArchiveBuilder();
336 
337   void gather_klasses_and_symbols();
338   void gather_source_objs();
339   bool gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool read_only);
340   bool gather_one_source_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref, bool read_only);
341   void add_special_ref(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset, size_t src_obj_size_in_bytes) {
342     _special_refs->append(SpecialRefInfo(type, src_obj, field_offset, src_obj_size_in_bytes));
343   }
344   void remember_embedded_pointer_in_copied_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref);
345 
346   DumpRegion* rw_region() { return &_rw_region; }
347   DumpRegion* ro_region() { return &_ro_region; }
348 
349   static char* rw_region_alloc(size_t num_bytes) {
350     return current()->rw_region()->allocate(num_bytes);
351   }
352   static char* ro_region_alloc(size_t num_bytes) {
353     return current()->ro_region()->allocate(num_bytes);
354   }
355 
356   template <typename T>
357   static Array<T>* new_ro_array(int length) {
358     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
359     Array<T>* array = (Array<T>*)ro_region_alloc(byte_size);
360     array->initialize(length);
361     return array;
362   }
363 
< prev index next >