< prev index next >

src/hotspot/share/cds/archiveBuilder.hpp

Print this page

111   // may be different than _requested_static_archive_{bottom,top} due to ASLR
112   address _mapped_static_archive_bottom;
113   address _mapped_static_archive_top;
114 
115   intx _buffer_to_requested_delta;
116 
117   DumpRegion* current_dump_space() const {  return _current_dump_space;  }
118 
119 public:
120   enum FollowMode {
121     make_a_copy, point_to_it, set_to_null
122   };
123 
124 private:
125   class SpecialRefInfo {
126     // We have a "special pointer" of the given _type at _field_offset of _src_obj.
127     // See MetaspaceClosure::push_special().
128     MetaspaceClosure::SpecialRef _type;
129     address _src_obj;
130     size_t _field_offset;

131 
132   public:
133     SpecialRefInfo() {}
134     SpecialRefInfo(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset)
135       : _type(type), _src_obj(src_obj), _field_offset(field_offset) {}


136 
137     MetaspaceClosure::SpecialRef type() const { return _type;         }
138     address src_obj()                   const { return _src_obj;      }
139     size_t field_offset()               const { return _field_offset; }


140   };
141 
142   class SourceObjInfo {
143     MetaspaceClosure::Ref* _ref; // The object that's copied into the buffer
144     uintx _ptrmap_start;     // The bit-offset of the start of this object (inclusive)
145     uintx _ptrmap_end;       // The bit-offset of the end   of this object (exclusive)
146     bool _read_only;
147     FollowMode _follow_mode;
148     int _size_in_bytes;
149     MetaspaceObj::Type _msotype;
150     address _source_addr;    // The value of the source object (_ref->obj()) when this
151                              // SourceObjInfo was created. Note that _ref->obj() may change
152                              // later if _ref is relocated.
153     address _buffered_addr;  // The copy of _ref->obj() insider the buffer.
154   public:
155     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
156       _ref(ref), _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
157       _size_in_bytes(ref->size() * BytesPerWord), _msotype(ref->msotype()),
158       _source_addr(ref->obj()) {
159       if (follow_mode == point_to_it) {

344     return (u4)offset;
345   }
346 
347   template <typename T>
348   u4 any_to_offset_u4(T p) const {
349     uintx offset = any_to_offset((address)p);
350     guarantee(offset <= MAX_SHARED_DELTA, "must be 32-bit offset " INTPTR_FORMAT, offset);
351     return (u4)offset;
352   }
353 
354   static void assert_is_vm_thread() PRODUCT_RETURN;
355 
356 public:
357   ArchiveBuilder();
358   ~ArchiveBuilder();
359 
360   void gather_klasses_and_symbols();
361   void gather_source_objs();
362   bool gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool read_only);
363   bool gather_one_source_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref, bool read_only);
364   void add_special_ref(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset);


365   void remember_embedded_pointer_in_copied_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref);
366 
367   DumpRegion* rw_region() { return &_rw_region; }
368   DumpRegion* ro_region() { return &_ro_region; }
369 
370   static char* rw_region_alloc(size_t num_bytes) {
371     return current()->rw_region()->allocate(num_bytes);
372   }
373   static char* ro_region_alloc(size_t num_bytes) {
374     return current()->ro_region()->allocate(num_bytes);
375   }
376 
377   template <typename T>
378   static Array<T>* new_ro_array(int length) {
379     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
380     Array<T>* array = (Array<T>*)ro_region_alloc(byte_size);
381     array->initialize(length);
382     return array;
383   }
384 

111   // may be different than _requested_static_archive_{bottom,top} due to ASLR
112   address _mapped_static_archive_bottom;
113   address _mapped_static_archive_top;
114 
115   intx _buffer_to_requested_delta;
116 
117   DumpRegion* current_dump_space() const {  return _current_dump_space;  }
118 
119 public:
120   enum FollowMode {
121     make_a_copy, point_to_it, set_to_null
122   };
123 
124 private:
125   class SpecialRefInfo {
126     // We have a "special pointer" of the given _type at _field_offset of _src_obj.
127     // See MetaspaceClosure::push_special().
128     MetaspaceClosure::SpecialRef _type;
129     address _src_obj;
130     size_t _field_offset;
131     DEBUG_ONLY(size_t _src_obj_size_in_bytes;)
132 
133   public:
134     SpecialRefInfo() {}
135     SpecialRefInfo(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset, size_t src_obj_size_in_bytes)
136       : _type(type), _src_obj(src_obj), _field_offset(field_offset) {
137       DEBUG_ONLY(_src_obj_size_in_bytes = src_obj_size_in_bytes);
138     }
139 
140     MetaspaceClosure::SpecialRef type() const { return _type;         }
141     address src_obj()                   const { return _src_obj;      }
142     size_t field_offset()               const { return _field_offset; }
143 
144     DEBUG_ONLY(size_t src_obj_size_in_bytes() const { return _src_obj_size_in_bytes; })
145   };
146 
147   class SourceObjInfo {
148     MetaspaceClosure::Ref* _ref; // The object that's copied into the buffer
149     uintx _ptrmap_start;     // The bit-offset of the start of this object (inclusive)
150     uintx _ptrmap_end;       // The bit-offset of the end   of this object (exclusive)
151     bool _read_only;
152     FollowMode _follow_mode;
153     int _size_in_bytes;
154     MetaspaceObj::Type _msotype;
155     address _source_addr;    // The value of the source object (_ref->obj()) when this
156                              // SourceObjInfo was created. Note that _ref->obj() may change
157                              // later if _ref is relocated.
158     address _buffered_addr;  // The copy of _ref->obj() insider the buffer.
159   public:
160     SourceObjInfo(MetaspaceClosure::Ref* ref, bool read_only, FollowMode follow_mode) :
161       _ref(ref), _ptrmap_start(0), _ptrmap_end(0), _read_only(read_only), _follow_mode(follow_mode),
162       _size_in_bytes(ref->size() * BytesPerWord), _msotype(ref->msotype()),
163       _source_addr(ref->obj()) {
164       if (follow_mode == point_to_it) {

349     return (u4)offset;
350   }
351 
352   template <typename T>
353   u4 any_to_offset_u4(T p) const {
354     uintx offset = any_to_offset((address)p);
355     guarantee(offset <= MAX_SHARED_DELTA, "must be 32-bit offset " INTPTR_FORMAT, offset);
356     return (u4)offset;
357   }
358 
359   static void assert_is_vm_thread() PRODUCT_RETURN;
360 
361 public:
362   ArchiveBuilder();
363   ~ArchiveBuilder();
364 
365   void gather_klasses_and_symbols();
366   void gather_source_objs();
367   bool gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool read_only);
368   bool gather_one_source_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref, bool read_only);
369   void add_special_ref(MetaspaceClosure::SpecialRef type, address src_obj, size_t field_offset, size_t src_obj_size_in_bytes) {
370     _special_refs->append(SpecialRefInfo(type, src_obj, field_offset, src_obj_size_in_bytes));
371   }
372   void remember_embedded_pointer_in_copied_obj(MetaspaceClosure::Ref* enclosing_ref, MetaspaceClosure::Ref* ref);
373 
374   DumpRegion* rw_region() { return &_rw_region; }
375   DumpRegion* ro_region() { return &_ro_region; }
376 
377   static char* rw_region_alloc(size_t num_bytes) {
378     return current()->rw_region()->allocate(num_bytes);
379   }
380   static char* ro_region_alloc(size_t num_bytes) {
381     return current()->ro_region()->allocate(num_bytes);
382   }
383 
384   template <typename T>
385   static Array<T>* new_ro_array(int length) {
386     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
387     Array<T>* array = (Array<T>*)ro_region_alloc(byte_size);
388     array->initialize(length);
389     return array;
390   }
391 
< prev index next >