< prev index next >

src/hotspot/share/cds/archiveUtils.hpp

Print this page

 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_ARCHIVEUTILS_HPP
 26 #define SHARE_CDS_ARCHIVEUTILS_HPP
 27 
 28 #include "cds/serializeClosure.hpp"
 29 #include "logging/log.hpp"
 30 #include "memory/virtualspace.hpp"
 31 #include "utilities/bitMap.hpp"
 32 #include "utilities/exceptions.hpp"
 33 #include "utilities/macros.hpp"
 34 
 35 class BootstrapInfo;
 36 class ReservedSpace;
 37 class VirtualSpace;
 38 



 39 // ArchivePtrMarker is used to mark the location of pointers embedded in a CDS archive. E.g., when an
 40 // InstanceKlass k is dumped, we mark the location of the k->_name pointer by effectively calling
 41 // mark_pointer(/*ptr_loc=*/&k->_name). It's required that (_prt_base <= ptr_loc < _ptr_end). _ptr_base is
 42 // fixed, but _ptr_end can be expanded as more objects are dumped.
 43 class ArchivePtrMarker : AllStatic {
 44   static CHeapBitMap*  _ptrmap;
 45   static VirtualSpace* _vs;
 46 
 47   // Once _ptrmap is compacted, we don't allow bit marking anymore. This is to
 48   // avoid unintentional copy operations after the bitmap has been finalized and written.
 49   static bool         _compacted;
 50 
 51   static address* ptr_base() { return (address*)_vs->low();  } // committed lower bound (inclusive)
 52   static address* ptr_end()  { return (address*)_vs->high(); } // committed upper bound (exclusive)
 53 
 54 public:
 55   static void initialize(CHeapBitMap* ptrmap, VirtualSpace* vs);
 56   static void mark_pointer(address* ptr_loc);
 57   static void clear_pointer(address* ptr_loc);
 58   static void compact(address relocatable_base, address relocatable_end);

215 
216   inline intptr_t nextPtr() {
217     return *(*_ptr_array)++;
218   }
219 
220 public:
221   ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; }
222 
223   void do_ptr(void** p);
224   void do_u4(u4* p);
225   void do_int(int* p);
226   void do_bool(bool *p);
227   void do_tag(int tag);
228   void do_region(u_char* start, size_t size);
229   bool reading() const { return true; }
230 };
231 
232 class ArchiveUtils {
233 public:
234   static void log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) NOT_CDS_RETURN;











235 };
236 
237 #endif // SHARE_CDS_ARCHIVEUTILS_HPP

 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_ARCHIVEUTILS_HPP
 26 #define SHARE_CDS_ARCHIVEUTILS_HPP
 27 
 28 #include "cds/serializeClosure.hpp"
 29 #include "logging/log.hpp"
 30 #include "memory/virtualspace.hpp"
 31 #include "utilities/bitMap.hpp"
 32 #include "utilities/exceptions.hpp"
 33 #include "utilities/macros.hpp"
 34 
 35 class BootstrapInfo;
 36 class ReservedSpace;
 37 class VirtualSpace;
 38 
 39 template<class E> class Array;
 40 template<class E> class GrowableArray;
 41 
 42 // ArchivePtrMarker is used to mark the location of pointers embedded in a CDS archive. E.g., when an
 43 // InstanceKlass k is dumped, we mark the location of the k->_name pointer by effectively calling
 44 // mark_pointer(/*ptr_loc=*/&k->_name). It's required that (_prt_base <= ptr_loc < _ptr_end). _ptr_base is
 45 // fixed, but _ptr_end can be expanded as more objects are dumped.
 46 class ArchivePtrMarker : AllStatic {
 47   static CHeapBitMap*  _ptrmap;
 48   static VirtualSpace* _vs;
 49 
 50   // Once _ptrmap is compacted, we don't allow bit marking anymore. This is to
 51   // avoid unintentional copy operations after the bitmap has been finalized and written.
 52   static bool         _compacted;
 53 
 54   static address* ptr_base() { return (address*)_vs->low();  } // committed lower bound (inclusive)
 55   static address* ptr_end()  { return (address*)_vs->high(); } // committed upper bound (exclusive)
 56 
 57 public:
 58   static void initialize(CHeapBitMap* ptrmap, VirtualSpace* vs);
 59   static void mark_pointer(address* ptr_loc);
 60   static void clear_pointer(address* ptr_loc);
 61   static void compact(address relocatable_base, address relocatable_end);

218 
219   inline intptr_t nextPtr() {
220     return *(*_ptr_array)++;
221   }
222 
223 public:
224   ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; }
225 
226   void do_ptr(void** p);
227   void do_u4(u4* p);
228   void do_int(int* p);
229   void do_bool(bool *p);
230   void do_tag(int tag);
231   void do_region(u_char* start, size_t size);
232   bool reading() const { return true; }
233 };
234 
235 class ArchiveUtils {
236 public:
237   static void log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) NOT_CDS_RETURN;
238 
239   template <typename T> static Array<T>* archive_array(GrowableArray<T>* tmp_array);
240 
241   // Used in logging: "boot", "boot2", "plat", "app" and "unreg";
242   static const char* class_category(Klass* k);
243 
244   static const char* builtin_loader_name_or_null(oop loader); // "boot", "platform", "app", or nullptr
245   static const char* builtin_loader_name(oop loader); // "boot", "platform", or "app". Asserts if not a built-in-loader.
246 
247   static bool builtin_loader_from_type(const char* loader_type, oop* value_ret);
248   static oop builtin_loader_from_type(int loader_type);
249 };
250 
251 #endif // SHARE_CDS_ARCHIVEUTILS_HPP
< prev index next >