< prev index next >

src/hotspot/share/cds/heapShared.hpp

Print this page
@@ -23,10 +23,11 @@
   */
  
  #ifndef SHARE_CDS_HEAPSHARED_HPP
  #define SHARE_CDS_HEAPSHARED_HPP
  
+ #include "cds/cds_globals.hpp"
  #include "cds/dumpTimeClassInfo.hpp"
  #include "cds/metaspaceShared.hpp"
  #include "classfile/compactHashtable.hpp"
  #include "classfile/javaClasses.hpp"
  #include "gc/shared/gc_globals.hpp"

@@ -159,17 +160,19 @@
    }
  
    static bool is_subgraph_root_class(InstanceKlass* ik);
  
    // Scratch objects for archiving Klass::java_mirror()
-   static oop scratch_java_mirror(BasicType t) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
-   static oop scratch_java_mirror(Klass* k)    NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
+   static oop scratch_java_mirror(BasicType t)     NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
+   static oop scratch_java_mirror(Klass* k)        NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
+   static oop scratch_java_mirror(oop java_mirror) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
    static bool is_archived_boot_layer_available(JavaThread* current) NOT_CDS_JAVA_HEAP_RETURN_(false);
  
  private:
  #if INCLUDE_CDS_JAVA_HEAP
    static bool _disable_writing;
+   static bool _box_classes_inited;
    static DumpedInternedStrings *_dumped_interned_strings;
  
    // statistics
    constexpr static int ALLOC_STAT_SLOTS = 16;
    static size_t _alloc_count[ALLOC_STAT_SLOTS];

@@ -183,10 +186,12 @@
    static unsigned oop_hash(oop const& p);
    static unsigned string_oop_hash(oop const& string) {
      return java_lang_String::hash_code(string);
    }
  
+   class CopyKlassSubGraphInfoToArchive;
+ 
    class CachedOopInfo {
      // See "TEMP notes: What are these?" in archiveHeapWriter.hpp
      oop _orig_referrer;
  
      // The location of this object inside ArchiveHeapWriter::_buffer

@@ -199,13 +204,10 @@
      void set_buffer_offset(size_t offset) { _buffer_offset = offset; }
      size_t buffer_offset()          const { return _buffer_offset;   }
    };
  
  private:
-   static void check_enum_obj(int level, KlassSubGraphInfo* subgraph_info,
-                              oop orig_obj);
- 
    typedef ResourceHashtable<oop, CachedOopInfo,
        36137, // prime number
        AnyObj::C_HEAP,
        mtClassShared,
        HeapShared::oop_hash> ArchivedObjectCache;

@@ -236,10 +238,11 @@
  
    static DumpTimeKlassSubGraphInfoTable* _dump_time_subgraph_info_table;
    static RunTimeKlassSubGraphInfoTable _run_time_subgraph_info_table;
  
    static CachedOopInfo make_cached_oop_info();
+   static ArchivedKlassSubGraphInfoRecord* archive_subgraph_info(KlassSubGraphInfo* info);
    static void archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
                                         bool is_full_module_graph);
  
    // Archive object sub-graph starting from the given static field
    // in Klass k's mirror.

@@ -278,14 +281,25 @@
    // of the classes defined in the <xxx>_archive_subgraph_entry_fields[] arrays:
    //    - interned strings
    //    - Klass::java_mirror()
    //    - ConstantPool::resolved_references()
    static KlassSubGraphInfo* _default_subgraph_info;
+   static ArchivedKlassSubGraphInfoRecord* _runtime_default_subgraph_info;
  
    static GrowableArrayCHeap<oop, mtClassShared>* _pending_roots;
+   static GrowableArrayCHeap<oop, mtClassShared>* _trace; // for debugging unarchivable objects
+   static GrowableArrayCHeap<const char*, mtClassShared>* _context; // for debugging unarchivable objects
    static OopHandle _roots;
+   static int _permobj_segments;
    static OopHandle _scratch_basic_type_mirrors[T_VOID+1];
+   static OopHandle _scratch_null_ptr_exception_instance;
+   static OopHandle _scratch_arithmetic_exception_instance;
+   static OopHandle _scratch_virtual_machine_error_instance;
+   static OopHandle _scratch_array_index_oob_exception_instance;
+   static OopHandle _scratch_array_store_exception_instance;
+   static OopHandle _scratch_class_cast_exception_instance;
+ 
    static MetaspaceObjToOopHandleTable* _scratch_java_mirror_table;
    static MetaspaceObjToOopHandleTable* _scratch_references_table;
  
    static void init_seen_objects_table() {
      assert(_seen_objects_table == nullptr, "must be");

@@ -295,10 +309,13 @@
      assert(_seen_objects_table != nullptr, "must be");
      delete _seen_objects_table;
      _seen_objects_table = nullptr;
    }
  
+   class ArchivingObjectMark;
+   class ContextMark;
+ 
    // Statistics (for one round of start_recording_subgraph ... done_recording_subgraph)
    static int _num_new_walked_objs;
    static int _num_new_archived_objs;
    static int _num_old_recorded_klasses;
  

@@ -314,18 +331,19 @@
    static void done_recording_subgraph(InstanceKlass *k, const char* klass_name);
  
    static bool has_been_seen_during_subgraph_recording(oop obj);
    static void set_has_been_seen_during_subgraph_recording(oop obj);
    static bool archive_object(oop obj);
- 
+   static void copy_preinitialized_mirror(Klass* orig_k, oop orig_mirror, oop m);
    static void copy_interned_strings();
  
    static void resolve_classes_for_subgraphs(JavaThread* current, ArchivableStaticFieldInfo fields[]);
    static void resolve_classes_for_subgraph_of(JavaThread* current, Klass* k);
    static void clear_archived_roots_of(Klass* k);
    static const ArchivedKlassSubGraphInfoRecord*
                 resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAPS);
+   static void resolve_or_init(const char* klass_name, bool do_init, TRAPS);
    static void resolve_or_init(Klass* k, bool do_init, TRAPS);
    static void init_archived_fields_for(Klass* k, const ArchivedKlassSubGraphInfoRecord* record);
  
    static int init_loaded_regions(FileMapInfo* mapinfo, LoadedArchiveHeapRegion* loaded_regions,
                                   MemRegion& archive_space);

@@ -336,12 +354,15 @@
    static void init_loaded_heap_relocation(LoadedArchiveHeapRegion* reloc_info,
                                            int num_loaded_regions);
    static void fill_failed_loaded_region();
    static void mark_native_pointers(oop orig_obj);
    static bool has_been_archived(oop orig_obj);
+   static bool can_mirror_be_used_in_subgraph(oop orig_java_mirror);
    static void archive_java_mirrors();
    static void archive_strings();
+   static void archive_exception_instances();
+   static void exit_on_error();
   public:
    static void reset_archived_object_states(TRAPS);
    static void create_archived_object_cache() {
      _archived_object_cache =
        new (mtClass)ArchivedObjectCache();

@@ -363,10 +384,13 @@
                                               oop orig_obj);
  
    static ResourceBitMap calculate_oopmap(MemRegion region); // marks all the oop pointers
    static void add_to_dumped_interned_strings(oop string);
  
+   static OopHandle init_scratch_exception(oop orig_exception_obj, TRAPS);
+   static void track_scratch_object(oop orig_obj, oop scratch_obj);
+ 
    // Scratch objects for archiving Klass::java_mirror()
    static void set_scratch_java_mirror(Klass* k, oop mirror);
    static void remove_scratch_objects(Klass* k);
  
    // We use the HeapShared::roots() array to make sure that objects stored in the

@@ -392,33 +416,51 @@
    static objArrayOop roots();
    static oop get_root(int index, bool clear=false);
  
    // Run-time only
    static void clear_root(int index);
- 
+   static void set_permobj_segments(int n) { _permobj_segments = n; }
    static void setup_test_class(const char* test_class_name) PRODUCT_RETURN;
  #endif // INCLUDE_CDS_JAVA_HEAP
  
   public:
+   static oop orig_to_scratch_object(oop orig_obj);
    static objArrayOop scratch_resolved_references(ConstantPool* src);
    static void add_scratch_resolved_references(ConstantPool* src, objArrayOop dest) NOT_CDS_JAVA_HEAP_RETURN;
    static void init_scratch_objects(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
+   static void init_scratch_exceptions(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
+   static void init_box_classes(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
    static bool is_heap_region(int idx) {
      CDS_JAVA_HEAP_ONLY(return (idx == MetaspaceShared::hp);)
      NOT_CDS_JAVA_HEAP_RETURN_(false);
    }
  
    static void resolve_classes(JavaThread* current) NOT_CDS_JAVA_HEAP_RETURN;
    static void initialize_from_archived_subgraph(JavaThread* current, Klass* k) NOT_CDS_JAVA_HEAP_RETURN;
  
    static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
    static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN;
+   static void serialize_misc_info(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
    static void init_roots(oop roots_oop) NOT_CDS_JAVA_HEAP_RETURN;
    static void serialize_tables(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
-   static bool initialize_enum_klass(InstanceKlass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
  
    static bool is_a_test_class_in_unnamed_module(Klass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
+ 
+   static void add_to_permanent_index_table(oop obj, int index);
+   // AOT-compile time only: get a stable index for an archived object.
+   // Returns 0 if obj is not archived.
+   static int get_archived_object_permanent_index(oop obj) NOT_CDS_JAVA_HEAP_RETURN_(-1);
+   // Runtime only: get back the same object for an index returned by
+   // get_archived_object_permanent_index().
+   static oop get_archived_object(int permanent_index) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
+ 
+   static void initialize_java_lang_invoke(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
+   static void initialize_default_subgraph_classes(Handle loader, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
+ 
+   static bool is_lambda_form_klass(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
+   static bool is_lambda_proxy_klass(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
+   static bool is_archivable_hidden_klass(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
  };
  
  #if INCLUDE_CDS_JAVA_HEAP
  class DumpedInternedStrings :
    public ResourceHashtable<oop, bool,
< prev index next >