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