< 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"

@@ -141,17 +142,17 @@
  
  class HeapShared: AllStatic {
    friend class VerifySharedOopClosure;
  
  public:
-   // Can this VM write a heap region into the CDS archive? Currently only {G1|Parallel|Serial}+compressed_cp
+   // Can this VM write a heap region into the CDS archive? Currently only {G1|Parallel|Serial|Epsilon|Shenandoah}+compressed_cp
    static bool can_write() {
      CDS_JAVA_HEAP_ONLY(
        if (_disable_writing) {
          return false;
        }
-       return (UseG1GC || UseParallelGC || UseSerialGC) && UseCompressedClassPointers;
+       return (UseG1GC || UseParallelGC || UseSerialGC || UseEpsilonGC || UseShenandoahGC) && UseCompressedClassPointers;
      )
      NOT_CDS_JAVA_HEAP(return false;)
    }
  
    static void disable_writing() {

@@ -159,14 +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);
  
+   static void start_finding_archivable_hidden_classes() NOT_CDS_JAVA_HEAP_RETURN;
+   static void find_archivable_hidden_classes_in_object(oop o) NOT_CDS_JAVA_HEAP_RETURN;
+   static void end_finding_archivable_hidden_classes() NOT_CDS_JAVA_HEAP_RETURN;
+ 
  private:
  #if INCLUDE_CDS_JAVA_HEAP
    static bool _disable_writing;
    static DumpedInternedStrings *_dumped_interned_strings;
  

@@ -177,16 +183,19 @@
    static size_t _total_obj_count;
    static size_t _total_obj_size; // in HeapWords
  
    static void count_allocation(size_t size);
    static void print_stats();
+   static void debug_trace();
  public:
    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 {
      // Used by CDSHeapVerifier.
      oop _orig_referrer;
  
      // The location of this object inside ArchiveHeapWriter::_buffer

@@ -244,11 +253,15 @@
      > RunTimeKlassSubGraphInfoTable;
  
    static DumpTimeKlassSubGraphInfoTable* _dump_time_subgraph_info_table;
    static RunTimeKlassSubGraphInfoTable _run_time_subgraph_info_table;
  
+   class FindHiddenClassesOopClosure;
+   static void find_archivable_hidden_classes_helper(ArchivableStaticFieldInfo fields[]);
+ 
    static CachedOopInfo make_cached_oop_info(oop obj);
+   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.

@@ -286,12 +299,15 @@
    // 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<OopHandle, mtClassShared>* _pending_roots;
+   static GrowableArrayCHeap<oop, mtClassShared>* _trace; // for debugging unarchivable objects
+   static GrowableArrayCHeap<const char*, mtClassShared>* _context; // for debugging unarchivable objects
    static GrowableArrayCHeap<OopHandle, mtClassShared>* _root_segments;
    static int _root_segment_max_size_elems;
    static OopHandle _scratch_basic_type_mirrors[T_VOID+1];
    static MetaspaceObjToOopHandleTable* _scratch_java_mirror_table;
    static MetaspaceObjToOopHandleTable* _scratch_references_table;

@@ -304,10 +320,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;
  

@@ -323,18 +342,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_aot_initialized_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);

@@ -345,13 +365,16 @@
    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();
+ 
   public:
+   static void exit_on_error();
    static void reset_archived_object_states(TRAPS);
    static void create_archived_object_cache() {
      _archived_object_cache =
        new (mtClass)ArchivedObjectCache(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE);
    }

@@ -372,10 +395,12 @@
                                               KlassSubGraphInfo* subgraph_info,
                                               oop orig_obj);
  
    static void add_to_dumped_interned_strings(oop string);
  
+   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);
    static void get_pointer_info(oop src_obj, bool& has_oop_pointers, bool& has_native_pointers);
    static void set_has_native_pointers(oop src_obj);

@@ -395,28 +420,28 @@
    // Other types of roots are also cleared similarly when they become referenced.
  
    // Dump-time only. Returns the index of the root, which can be used at run time to read
    // the root using get_root(index, ...).
    static int append_root(oop obj);
-   static GrowableArrayCHeap<oop, mtClassShared>* pending_roots() { return _pending_roots; }
+   static GrowableArrayCHeap<OopHandle, mtClassShared>* pending_roots() { return _pending_roots; }
  
    // Dump-time and runtime
    static objArrayOop root_segment(int segment_idx);
    static oop get_root(int index, bool clear=false);
  
    // Run-time only
    static void clear_root(int index);
- 
    static void get_segment_indexes(int index, int& segment_index, int& internal_index);
- 
    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_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);
    }
  

@@ -429,11 +454,36 @@
    static void init_root_segment_sizes(int max_size_elems) NOT_CDS_JAVA_HEAP_RETURN;
    static void serialize_tables(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
  
  #ifndef PRODUCT
    static bool is_a_test_class_in_unnamed_module(Klass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
+   static void initialize_test_class_from_archive(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
  #endif
+ 
+   static void add_to_permanent_oop_table(oop obj, int offset);
+ 
+   // 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);
+ };
+ 
+ class CachedCodeDirectoryInternal {
+   int _permanent_oop_count;
+   int* _permanent_oop_offsets; // offset of each permanent object from the bottom of the archived heap
+ public:
+   void dumptime_init_internal();
+   void runtime_init_internal();
  };
  
  #if INCLUDE_CDS_JAVA_HEAP
  class DumpedInternedStrings :
    public ResizeableResourceHashtable<oop, bool,
< prev index next >