< prev index next >

src/share/vm/memory/metaspaceShared.hpp

Print this page




  36 #define HugeSharedArchiveSize     (800*M)
  37 #define ReadOnlyRegionPercentage  0.4
  38 #define ReadWriteRegionPercentage 0.55
  39 #define MiscDataRegionPercentage  0.03
  40 #define MiscCodeRegionPercentage  0.02
  41 #define LargeThresholdClassCount  5000
  42 #define HugeThresholdClassCount   40000
  43 
  44 #define SET_ESTIMATED_SIZE(type, region)                              \
  45   Shared ##region## Size  = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
  46     (uintx)(type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
  47 
  48 class FileMapInfo;
  49 
  50 class MetaspaceSharedStats VALUE_OBJ_CLASS_SPEC {
  51 public:
  52   MetaspaceSharedStats() {
  53     memset(this, 0, sizeof(*this));
  54   }
  55   CompactHashtableStats symbol;

  56 };
  57 
  58 // Class Data Sharing Support
  59 class MetaspaceShared : AllStatic {
  60 
  61   // CDS support
  62   static ReservedSpace* _shared_rs;
  63   static int _max_alignment;
  64   static MetaspaceSharedStats _stats;
  65   static bool _link_classes_made_progress;
  66   static bool _check_classes_made_progress;
  67   static bool _has_error_classes;
  68   static bool _archive_loading_failed;
  69  public:
  70   enum {
  71     vtbl_list_size         = 17,   // number of entries in the shared space vtable list.
  72     num_virtuals           = 200,  // maximum number of virtual functions
  73                                    // If virtual functions are added to Metadata,
  74                                    // this number needs to be increased.  Also,
  75                                    // SharedMiscCodeSize will need to be increased.
  76                                    // The following 2 sizes were based on
  77                                    // MetaspaceShared::generate_vtable_methods()
  78     vtbl_method_size       = 16,   // conservative size of the mov1 and jmp instructions
  79                                    // for the x64 platform
  80     vtbl_common_code_size  = (1*K) // conservative size of the "common_code" for the x64 platform
  81   };
  82 
  83   enum {
  84     min_ro_size = NOT_LP64(8*M) LP64_ONLY(9*M), // minimum ro and rw regions sizes based on dumping
  85     min_rw_size = NOT_LP64(7*M) LP64_ONLY(12*M) // of a shared archive using the default classlist
  86   };
  87 
  88   enum {
  89     ro = 0,  // read-only shared space in the heap
  90     rw = 1,  // read-write shared space in the heap
  91     md = 2,  // miscellaneous data for initializing tables, etc.
  92     mc = 3,  // miscellaneous code - vtable replacement.
  93     n_regions = 4



  94   };
  95 
  96   // Accessor functions to save shared space created for metadata, which has
  97   // extra space allocated at the end for miscellaneous data and code.
  98   static void set_max_alignment(int alignment) {
  99     CDS_ONLY(_max_alignment = alignment);
 100   }
 101 
 102   static int max_alignment() {
 103     CDS_ONLY(return _max_alignment);
 104     NOT_CDS(return 0);
 105   }
 106 
 107   static void prepare_for_dumping() NOT_CDS_RETURN;
 108   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
 109   static int preload_and_dump(const char * class_list_path,
 110                               GrowableArray<Klass*>* class_promote_order,
 111                               TRAPS) NOT_CDS_RETURN_(0);
 112 
 113   static ReservedSpace* shared_rs() {
 114     CDS_ONLY(return _shared_rs);
 115     NOT_CDS(return NULL);
 116   }
 117 
 118   static void set_shared_rs(ReservedSpace* rs) {
 119     CDS_ONLY(_shared_rs = rs;)
 120   }
 121 
 122   static void set_archive_loading_failed() {
 123     _archive_loading_failed = true;
 124   }
 125   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
 126   static void initialize_shared_spaces() NOT_CDS_RETURN;

 127 
 128   // Return true if given address is in the mapped shared space.
 129   static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);


 130 
 131   static void generate_vtable_methods(void** vtbl_list,
 132                                       void** vtable,
 133                                       char** md_top, char* md_end,
 134                                       char** mc_top, char* mc_end);
 135   static void serialize(SerializeClosure* sc);
 136 
 137   static MetaspaceSharedStats* stats() {
 138     return &_stats;
 139   }
 140 
 141   // JVM/TI RedefineClasses() support:
 142   // Remap the shared readonly space to shared readwrite, private if
 143   // sharing is enabled. Simply returns true if sharing is not enabled
 144   // or if the remapping has already been done by a prior call.
 145   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 146 
 147   static void print_shared_spaces();
 148 
 149   static bool try_link_class(InstanceKlass* ik, TRAPS);


  36 #define HugeSharedArchiveSize     (800*M)
  37 #define ReadOnlyRegionPercentage  0.4
  38 #define ReadWriteRegionPercentage 0.55
  39 #define MiscDataRegionPercentage  0.03
  40 #define MiscCodeRegionPercentage  0.02
  41 #define LargeThresholdClassCount  5000
  42 #define HugeThresholdClassCount   40000
  43 
  44 #define SET_ESTIMATED_SIZE(type, region)                              \
  45   Shared ##region## Size  = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
  46     (uintx)(type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
  47 
  48 class FileMapInfo;
  49 
  50 class MetaspaceSharedStats VALUE_OBJ_CLASS_SPEC {
  51 public:
  52   MetaspaceSharedStats() {
  53     memset(this, 0, sizeof(*this));
  54   }
  55   CompactHashtableStats symbol;
  56   CompactHashtableStats string;
  57 };
  58 
  59 // Class Data Sharing Support
  60 class MetaspaceShared : AllStatic {
  61 
  62   // CDS support
  63   static ReservedSpace* _shared_rs;
  64   static int _max_alignment;
  65   static MetaspaceSharedStats _stats;
  66   static bool _link_classes_made_progress;
  67   static bool _check_classes_made_progress;
  68   static bool _has_error_classes;
  69   static bool _archive_loading_failed;
  70  public:
  71   enum {
  72     vtbl_list_size         = 17,   // number of entries in the shared space vtable list.
  73     num_virtuals           = 200,  // maximum number of virtual functions
  74                                    // If virtual functions are added to Metadata,
  75                                    // this number needs to be increased.  Also,
  76                                    // SharedMiscCodeSize will need to be increased.
  77                                    // The following 2 sizes were based on
  78                                    // MetaspaceShared::generate_vtable_methods()
  79     vtbl_method_size       = 16,   // conservative size of the mov1 and jmp instructions
  80                                    // for the x64 platform
  81     vtbl_common_code_size  = (1*K) // conservative size of the "common_code" for the x64 platform
  82   };
  83 
  84   enum {
  85     min_ro_size = NOT_LP64(8*M) LP64_ONLY(9*M), // minimum ro and rw regions sizes based on dumping
  86     min_rw_size = NOT_LP64(7*M) LP64_ONLY(12*M) // of a shared archive using the default classlist
  87   };
  88 
  89   enum {
  90     ro = 0,  // read-only shared space in the heap
  91     rw = 1,  // read-write shared space in the heap
  92     md = 2,  // miscellaneous data for initializing tables, etc.
  93     mc = 3,  // miscellaneous code - vtable replacement.
  94     max_strings = 2, // max number of string regions in string space
  95     num_non_strings = 4, // number of non-string regions
  96     first_string = num_non_strings, // index of first string region
  97     n_regions = max_strings + num_non_strings // total number of regions
  98   };
  99 
 100   // Accessor functions to save shared space created for metadata, which has
 101   // extra space allocated at the end for miscellaneous data and code.
 102   static void set_max_alignment(int alignment) {
 103     CDS_ONLY(_max_alignment = alignment);
 104   }
 105 
 106   static int max_alignment() {
 107     CDS_ONLY(return _max_alignment);
 108     NOT_CDS(return 0);
 109   }
 110 
 111   static void prepare_for_dumping() NOT_CDS_RETURN;
 112   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
 113   static int preload_and_dump(const char * class_list_path,
 114                               GrowableArray<Klass*>* class_promote_order,
 115                               TRAPS) NOT_CDS_RETURN_(0);
 116 
 117   static ReservedSpace* shared_rs() {
 118     CDS_ONLY(return _shared_rs);
 119     NOT_CDS(return NULL);
 120   }
 121 
 122   static void set_shared_rs(ReservedSpace* rs) {
 123     CDS_ONLY(_shared_rs = rs;)
 124   }
 125 
 126   static void set_archive_loading_failed() {
 127     _archive_loading_failed = true;
 128   }
 129   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
 130   static void initialize_shared_spaces() NOT_CDS_RETURN;
 131   static void fixup_shared_string_regions() NOT_CDS_RETURN;
 132 
 133   // Return true if given address is in the mapped shared space.
 134   static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
 135 
 136   static bool is_string_region(int idx) NOT_CDS_RETURN_(false);
 137 
 138   static void generate_vtable_methods(void** vtbl_list,
 139                                       void** vtable,
 140                                       char** md_top, char* md_end,
 141                                       char** mc_top, char* mc_end);
 142   static void serialize(SerializeClosure* sc);
 143 
 144   static MetaspaceSharedStats* stats() {
 145     return &_stats;
 146   }
 147 
 148   // JVM/TI RedefineClasses() support:
 149   // Remap the shared readonly space to shared readwrite, private if
 150   // sharing is enabled. Simply returns true if sharing is not enabled
 151   // or if the remapping has already been done by a prior call.
 152   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 153 
 154   static void print_shared_spaces();
 155 
 156   static bool try_link_class(InstanceKlass* ik, TRAPS);
< prev index next >