src/share/vm/memory/metaspaceShared.hpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 8604
04d83ba48607
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

aoqi@0 1 /*
jiangli@8509 2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24 #ifndef SHARE_VM_MEMORY_METASPACE_SHARED_HPP
aoqi@0 25 #define SHARE_VM_MEMORY_METASPACE_SHARED_HPP
aoqi@0 26
aoqi@0 27 #include "memory/allocation.hpp"
aoqi@0 28 #include "memory/memRegion.hpp"
aoqi@0 29 #include "runtime/virtualspace.hpp"
aoqi@0 30 #include "utilities/exceptions.hpp"
aoqi@0 31 #include "utilities/macros.hpp"
aoqi@0 32
ccheung@7103 33 #define LargeSharedArchiveSize (300*M)
ccheung@7103 34 #define HugeSharedArchiveSize (800*M)
iklam@7322 35 #define ReadOnlyRegionPercentage 0.39
iklam@7322 36 #define ReadWriteRegionPercentage 0.50
iklam@7322 37 #define MiscDataRegionPercentage 0.09
ccheung@7103 38 #define MiscCodeRegionPercentage 0.02
ccheung@7103 39 #define LargeThresholdClassCount 5000
ccheung@7103 40 #define HugeThresholdClassCount 40000
ccheung@7103 41
ccheung@7103 42 #define SET_ESTIMATED_SIZE(type, region) \
ccheung@7103 43 Shared ##region## Size = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
ccheung@7104 44 (uintx)(type ## SharedArchiveSize * region ## RegionPercentage) : Shared ## region ## Size
ccheung@7103 45
aoqi@0 46 class FileMapInfo;
aoqi@0 47
aoqi@0 48 // Class Data Sharing Support
aoqi@0 49 class MetaspaceShared : AllStatic {
aoqi@0 50
aoqi@0 51 // CDS support
aoqi@0 52 static ReservedSpace* _shared_rs;
aoqi@0 53 static int _max_alignment;
iklam@7089 54 static bool _link_classes_made_progress;
iklam@7089 55 static bool _check_classes_made_progress;
iklam@7089 56 static bool _has_error_classes;
iklam@7089 57 static bool _archive_loading_failed;
jiangli@8509 58 static bool _remapped_readwrite;
aoqi@0 59 public:
aoqi@0 60 enum {
ccheung@7300 61 vtbl_list_size = 17, // number of entries in the shared space vtable list.
ccheung@7300 62 num_virtuals = 200, // maximum number of virtual functions
ccheung@7300 63 // If virtual functions are added to Metadata,
ccheung@7300 64 // this number needs to be increased. Also,
ccheung@7300 65 // SharedMiscCodeSize will need to be increased.
ccheung@7300 66 // The following 2 sizes were based on
ccheung@7300 67 // MetaspaceShared::generate_vtable_methods()
ccheung@7300 68 vtbl_method_size = 16, // conservative size of the mov1 and jmp instructions
ccheung@7300 69 // for the x64 platform
ccheung@7300 70 vtbl_common_code_size = (1*K) // conservative size of the "common_code" for the x64 platform
aoqi@0 71 };
aoqi@0 72
aoqi@0 73 enum {
aoqi@0 74 ro = 0, // read-only shared space in the heap
aoqi@0 75 rw = 1, // read-write shared space in the heap
aoqi@0 76 md = 2, // miscellaneous data for initializing tables, etc.
aoqi@0 77 mc = 3, // miscellaneous code - vtable replacement.
aoqi@0 78 n_regions = 4
aoqi@0 79 };
aoqi@0 80
aoqi@0 81 // Accessor functions to save shared space created for metadata, which has
aoqi@0 82 // extra space allocated at the end for miscellaneous data and code.
aoqi@0 83 static void set_max_alignment(int alignment) {
aoqi@0 84 CDS_ONLY(_max_alignment = alignment);
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 static int max_alignment() {
aoqi@0 88 CDS_ONLY(return _max_alignment);
aoqi@0 89 NOT_CDS(return 0);
aoqi@0 90 }
aoqi@0 91
iklam@7089 92 static void prepare_for_dumping() NOT_CDS_RETURN;
aoqi@0 93 static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
iklam@7089 94 static int preload_and_dump(const char * class_list_path,
iklam@7089 95 GrowableArray<Klass*>* class_promote_order,
iklam@7089 96 TRAPS) NOT_CDS_RETURN;
aoqi@0 97
aoqi@0 98 static ReservedSpace* shared_rs() {
aoqi@0 99 CDS_ONLY(return _shared_rs);
aoqi@0 100 NOT_CDS(return NULL);
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 static void set_shared_rs(ReservedSpace* rs) {
aoqi@0 104 CDS_ONLY(_shared_rs = rs;)
aoqi@0 105 }
aoqi@0 106
iklam@7089 107 static void set_archive_loading_failed() {
iklam@7089 108 _archive_loading_failed = true;
iklam@7089 109 }
aoqi@0 110 static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false);
aoqi@0 111 static void initialize_shared_spaces() NOT_CDS_RETURN;
aoqi@0 112
aoqi@0 113 // Return true if given address is in the mapped shared space.
aoqi@0 114 static bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
aoqi@0 115
aoqi@0 116 static void generate_vtable_methods(void** vtbl_list,
aoqi@0 117 void** vtable,
aoqi@0 118 char** md_top, char* md_end,
aoqi@0 119 char** mc_top, char* mc_end);
aoqi@0 120 static void serialize(SerializeClosure* sc);
aoqi@0 121
aoqi@0 122 // JVM/TI RedefineClasses() support:
aoqi@0 123 // Remap the shared readonly space to shared readwrite, private if
aoqi@0 124 // sharing is enabled. Simply returns true if sharing is not enabled
aoqi@0 125 // or if the remapping has already been done by a prior call.
aoqi@0 126 static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
jiangli@8509 127 static bool remapped_readwrite() {
jiangli@8509 128 CDS_ONLY(return _remapped_readwrite);
jiangli@8509 129 NOT_CDS(return false);
jiangli@8509 130 }
aoqi@0 131
aoqi@0 132 static void print_shared_spaces();
iklam@7089 133
iklam@7089 134 static bool try_link_class(InstanceKlass* ik, TRAPS);
iklam@7089 135 static void link_one_shared_class(Klass* obj, TRAPS);
iklam@7089 136 static void check_one_shared_class(Klass* obj);
iklam@7089 137 static void link_and_cleanup_shared_classes(TRAPS);
ccheung@7103 138
ccheung@7103 139 static int count_class(const char* classlist_file);
ccheung@7103 140 static void estimate_regions_size() NOT_CDS_RETURN;
aoqi@0 141 };
aoqi@0 142 #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP

mercurial