Mercurial > hg > truffle
annotate src/share/vm/memory/metaspaceShared.hpp @ 20690:d4caf9c96afd
8035893: JVM_GetVersionInfo fails to zero structure
Reviewed-by: sla, zgu
author | igerasim |
---|---|
date | Fri, 28 Feb 2014 16:00:40 +0400 |
parents | 4cb90023bf2b |
children |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 enum { |
20586
03e6d34be1f5
8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents:
20390
diff
changeset
|
60 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
|
61 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
|
62 // 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
|
63 // 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
|
64 // 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
|
65 // 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
|
66 // 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
|
67 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
|
68 // 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
|
69 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
|
70 }; |
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 enum { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 ro = 0, // read-only shared space in the heap |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 rw = 1, // read-write shared space in the heap |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 md = 2, // miscellaneous data for initializing tables, etc. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 mc = 3, // miscellaneous code - vtable replacement. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 n_regions = 4 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
78 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
79 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
80 // 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
|
81 // 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
|
82 static void set_max_alignment(int alignment) { |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
83 CDS_ONLY(_max_alignment = alignment); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
84 } |
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 static int max_alignment() { |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
87 CDS_ONLY(return _max_alignment); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
88 NOT_CDS(return 0); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
89 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
91 static void prepare_for_dumping() NOT_CDS_RETURN; |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
92 static void preload_and_dump(TRAPS) NOT_CDS_RETURN; |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
93 static int preload_and_dump(const char * class_list_path, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
94 GrowableArray<Klass*>* class_promote_order, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
95 TRAPS) NOT_CDS_RETURN; |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
96 |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
97 static ReservedSpace* shared_rs() { |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
98 CDS_ONLY(return _shared_rs); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
99 NOT_CDS(return NULL); |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
100 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
102 static void set_shared_rs(ReservedSpace* rs) { |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
103 CDS_ONLY(_shared_rs = rs;) |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
104 } |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
105 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
106 static void set_archive_loading_failed() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
107 _archive_loading_failed = true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
108 } |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
109 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
|
110 static void initialize_shared_spaces() NOT_CDS_RETURN; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 // 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
|
113 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
|
114 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
115 static void generate_vtable_methods(void** vtbl_list, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 void** vtable, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 char** md_top, char* md_end, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 char** mc_top, char* mc_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 static void serialize(SerializeClosure* sc); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
120 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
121 // JVM/TI RedefineClasses() support: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 // 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
|
123 // 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
|
124 // 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
|
125 static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
126 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
127 static void print_shared_spaces(); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
128 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
129 static bool try_link_class(InstanceKlass* ik, TRAPS); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
130 static void link_one_shared_class(Klass* obj, TRAPS); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
131 static void check_one_shared_class(Klass* obj); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
6854
diff
changeset
|
132 static void link_and_cleanup_shared_classes(TRAPS); |
20389
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
133 |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
134 static int count_class(const char* classlist_file); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
135 static void estimate_regions_size() NOT_CDS_RETURN; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
136 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
137 #endif // SHARE_VM_MEMORY_METASPACE_SHARED_HPP |