src/share/vm/memory/metaspaceShared.hpp

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP
  25 #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP
  26 

  27 #include "memory/allocation.hpp"
  28 #include "memory/memRegion.hpp"
  29 #include "runtime/virtualspace.hpp"
  30 #include "utilities/exceptions.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 #define LargeSharedArchiveSize    (300*M)
  34 #define HugeSharedArchiveSize     (800*M)
  35 #define ReadOnlyRegionPercentage  0.4
  36 #define ReadWriteRegionPercentage 0.55
  37 #define MiscDataRegionPercentage  0.03
  38 #define MiscCodeRegionPercentage  0.02
  39 #define LargeThresholdClassCount  5000
  40 #define HugeThresholdClassCount   40000
  41 
  42 #define SET_ESTIMATED_SIZE(type, region)                              \
  43   Shared ##region## Size  = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
  44     (uintx)(type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
  45 
  46 class FileMapInfo;
  47 








  48 // Class Data Sharing Support
  49 class MetaspaceShared : AllStatic {
  50 
  51   // CDS support
  52   static ReservedSpace* _shared_rs;
  53   static int _max_alignment;

  54   static bool _link_classes_made_progress;
  55   static bool _check_classes_made_progress;
  56   static bool _has_error_classes;
  57   static bool _archive_loading_failed;
  58  public:
  59   enum {
  60     vtbl_list_size         = 17,   // number of entries in the shared space vtable list.
  61     num_virtuals           = 200,  // maximum number of virtual functions
  62                                    // If virtual functions are added to Metadata,
  63                                    // this number needs to be increased.  Also,
  64                                    // SharedMiscCodeSize will need to be increased.
  65                                    // The following 2 sizes were based on
  66                                    // MetaspaceShared::generate_vtable_methods()
  67     vtbl_method_size       = 16,   // conservative size of the mov1 and jmp instructions
  68                                    // for the x64 platform
  69     vtbl_common_code_size  = (1*K) // conservative size of the "common_code" for the x64 platform
  70   };
  71 
  72   enum {
  73     ro = 0,  // read-only shared space in the heap


 100   }
 101 
 102   static void set_shared_rs(ReservedSpace* rs) {
 103     CDS_ONLY(_shared_rs = rs;)
 104   }
 105 
 106   static void set_archive_loading_failed() {
 107     _archive_loading_failed = true;
 108   }
 109   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
 110   static void initialize_shared_spaces() NOT_CDS_RETURN;
 111 
 112   // Return true if given address is in the mapped shared space.
 113   static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
 114 
 115   static void generate_vtable_methods(void** vtbl_list,
 116                                       void** vtable,
 117                                       char** md_top, char* md_end,
 118                                       char** mc_top, char* mc_end);
 119   static void serialize(SerializeClosure* sc);




 120 
 121   // JVM/TI RedefineClasses() support:
 122   // Remap the shared readonly space to shared readwrite, private if
 123   // sharing is enabled. Simply returns true if sharing is not enabled
 124   // or if the remapping has already been done by a prior call.
 125   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 126 
 127   static void print_shared_spaces();
 128 
 129   static bool try_link_class(InstanceKlass* ik, TRAPS);
 130   static void link_one_shared_class(Klass* obj, TRAPS);
 131   static void check_one_shared_class(Klass* obj);
 132   static void link_and_cleanup_shared_classes(TRAPS);
 133 
 134   static int count_class(const char* classlist_file);
 135   static void estimate_regions_size() NOT_CDS_RETURN;
 136 };
 137 #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  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 #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP
  25 #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP
  26 
  27 #include "classfile/compactHashtable.hpp"
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "runtime/virtualspace.hpp"
  31 #include "utilities/exceptions.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 #define LargeSharedArchiveSize    (300*M)
  35 #define HugeSharedArchiveSize     (800*M)
  36 #define ReadOnlyRegionPercentage  0.4
  37 #define ReadWriteRegionPercentage 0.55
  38 #define MiscDataRegionPercentage  0.03
  39 #define MiscCodeRegionPercentage  0.02
  40 #define LargeThresholdClassCount  5000
  41 #define HugeThresholdClassCount   40000
  42 
  43 #define SET_ESTIMATED_SIZE(type, region)                              \
  44   Shared ##region## Size  = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
  45     (uintx)(type ## SharedArchiveSize *  region ## RegionPercentage) : Shared ## region ## Size
  46 
  47 class FileMapInfo;
  48 
  49 class MetaspaceSharedStats VALUE_OBJ_CLASS_SPEC {
  50 public:
  51   MetaspaceSharedStats() {
  52     memset(this, 0, sizeof(*this));
  53   }
  54   CompactHashtableStats symbol;
  55 };
  56 
  57 // Class Data Sharing Support
  58 class MetaspaceShared : AllStatic {
  59 
  60   // CDS support
  61   static ReservedSpace* _shared_rs;
  62   static int _max_alignment;
  63   static MetaspaceSharedStats _stats;
  64   static bool _link_classes_made_progress;
  65   static bool _check_classes_made_progress;
  66   static bool _has_error_classes;
  67   static bool _archive_loading_failed;
  68  public:
  69   enum {
  70     vtbl_list_size         = 17,   // number of entries in the shared space vtable list.
  71     num_virtuals           = 200,  // maximum number of virtual functions
  72                                    // If virtual functions are added to Metadata,
  73                                    // this number needs to be increased.  Also,
  74                                    // SharedMiscCodeSize will need to be increased.
  75                                    // The following 2 sizes were based on
  76                                    // MetaspaceShared::generate_vtable_methods()
  77     vtbl_method_size       = 16,   // conservative size of the mov1 and jmp instructions
  78                                    // for the x64 platform
  79     vtbl_common_code_size  = (1*K) // conservative size of the "common_code" for the x64 platform
  80   };
  81 
  82   enum {
  83     ro = 0,  // read-only shared space in the heap


 110   }
 111 
 112   static void set_shared_rs(ReservedSpace* rs) {
 113     CDS_ONLY(_shared_rs = rs;)
 114   }
 115 
 116   static void set_archive_loading_failed() {
 117     _archive_loading_failed = true;
 118   }
 119   static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
 120   static void initialize_shared_spaces() NOT_CDS_RETURN;
 121 
 122   // Return true if given address is in the mapped shared space.
 123   static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
 124 
 125   static void generate_vtable_methods(void** vtbl_list,
 126                                       void** vtable,
 127                                       char** md_top, char* md_end,
 128                                       char** mc_top, char* mc_end);
 129   static void serialize(SerializeClosure* sc);
 130 
 131   static MetaspaceSharedStats* stats() {
 132     return &_stats;
 133   }
 134 
 135   // JVM/TI RedefineClasses() support:
 136   // Remap the shared readonly space to shared readwrite, private if
 137   // sharing is enabled. Simply returns true if sharing is not enabled
 138   // or if the remapping has already been done by a prior call.
 139   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 140 
 141   static void print_shared_spaces();
 142 
 143   static bool try_link_class(InstanceKlass* ik, TRAPS);
 144   static void link_one_shared_class(Klass* obj, TRAPS);
 145   static void check_one_shared_class(Klass* obj);
 146   static void link_and_cleanup_shared_classes(TRAPS);
 147 
 148   static int count_class(const char* classlist_file);
 149   static void estimate_regions_size() NOT_CDS_RETURN;
 150 };
 151 #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP