Mercurial > hg > graal-compiler
annotate src/share/vm/memory/metaspaceShared.cpp @ 20591:28051f14c328
8043158: Crash in CodeSweeperSweepNoFlushTest in CompileQueue::free_all()
Summary: Acquire lock before calling notify()
Reviewed-by: twisti, thartmann
author | anoll |
---|---|
date | Fri, 20 Jun 2014 09:25:13 +0200 |
parents | 8cb56c8cb30d |
children | 4cb90023bf2b |
rev | line source |
---|---|
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
2 * Copyright (c) 2012, 2014, 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 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
25 #include "precompiled.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
26 #include "classfile/dictionary.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 #include "classfile/loaderConstraints.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
28 #include "classfile/placeholders.hpp" |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
29 #include "classfile/sharedClassUtil.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 #include "classfile/symbolTable.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 #include "classfile/systemDictionary.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 #include "code/codeCache.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 #include "memory/filemap.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 #include "memory/gcLocker.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 #include "memory/metaspace.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 #include "memory/metaspaceShared.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
37 #include "oops/objArrayOop.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 #include "oops/oop.inline.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 #include "runtime/signature.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 #include "runtime/vm_operations.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 #include "runtime/vmThread.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
42 #include "utilities/hashtable.inline.hpp" |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
43 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
44 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
46 int MetaspaceShared::_max_alignment = 0; |
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 ReservedSpace* MetaspaceShared::_shared_rs = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
50 bool MetaspaceShared::_link_classes_made_progress; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
51 bool MetaspaceShared::_check_classes_made_progress; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
52 bool MetaspaceShared::_has_error_classes; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
53 bool MetaspaceShared::_archive_loading_failed = false; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
54 // Read/write a data stream for restoring/preserving metadata pointers and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
55 // miscellaneous data from/to the shared archive file. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
56 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 void MetaspaceShared::serialize(SerializeClosure* soc) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 int tag = 0; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 soc->do_tag(--tag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
60 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
61 // Verify the sizes of various metadata in the system. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
62 soc->do_tag(sizeof(Method)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
63 soc->do_tag(sizeof(ConstMethod)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 soc->do_tag(arrayOopDesc::base_offset_in_bytes(T_BYTE)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
65 soc->do_tag(sizeof(ConstantPool)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
66 soc->do_tag(sizeof(ConstantPoolCache)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 soc->do_tag(objArrayOopDesc::base_offset_in_bytes()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
68 soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
69 soc->do_tag(sizeof(Symbol)); |
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 // Dump/restore miscellaneous metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
72 Universe::serialize(soc, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
73 soc->do_tag(--tag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
74 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 // Dump/restore references to commonly used names and signatures. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 vmSymbols::serialize(soc); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
77 soc->do_tag(--tag); |
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 soc->do_tag(666); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
80 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 // CDS code for dumping shared archive. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
84 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
85 // Global object for holding classes that have been loaded. Since this |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
86 // is run at a safepoint just before exit, this is the entire set of classes. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 static GrowableArray<Klass*>* _global_klass_objects; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 static void collect_classes(Klass* k) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
89 _global_klass_objects->append_if_missing(k); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
90 if (k->oop_is_instance()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
91 // Add in the array classes too |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 InstanceKlass* ik = InstanceKlass::cast(k); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
93 ik->array_klasses_do(collect_classes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
95 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
96 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
97 static void remove_unshareable_in_classes() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
98 for (int i = 0; i < _global_klass_objects->length(); i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 Klass* k = _global_klass_objects->at(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
100 k->remove_unshareable_info(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 // Walk all methods in the class list and assign a fingerprint. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 // so that this part of the ConstMethod* is read only. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 static void calculate_fingerprints() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 for (int i = 0; i < _global_klass_objects->length(); i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 Klass* k = _global_klass_objects->at(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
109 if (k->oop_is_instance()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
110 InstanceKlass* ik = InstanceKlass::cast(k); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
111 for (int i = 0; i < ik->methods()->length(); i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
112 Method* m = ik->methods()->at(i); |
12281
4f9a42c33738
8022887: Assertion hit while using class and redefining it with RedefineClasses simultaneously
coleenp
parents:
12056
diff
changeset
|
113 Fingerprinter fp(m); |
4f9a42c33738
8022887: Assertion hit while using class and redefining it with RedefineClasses simultaneously
coleenp
parents:
12056
diff
changeset
|
114 // The side effect of this call sets method's fingerprint field. |
4f9a42c33738
8022887: Assertion hit while using class and redefining it with RedefineClasses simultaneously
coleenp
parents:
12056
diff
changeset
|
115 fp.fingerprint(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
116 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
117 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
118 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
119 } |
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 // Patch C++ vtable pointer in metadata. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
122 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
123 // Klass and other metadata objects contain references to c++ vtables in the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
124 // JVM library. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
125 // Fix them to point to our constructed vtables. However, don't iterate |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
126 // across the space while doing this, as that causes the vtables to be |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
127 // patched, undoing our useful work. Instead, iterate to make a list, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
128 // then use the list to do the fixing. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
129 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
130 // Our constructed vtables: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
131 // Dump time: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
132 // 1. init_self_patching_vtbl_list: table of pointers to current virtual method addrs |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
133 // 2. generate_vtable_methods: create jump table, appended to above vtbl_list |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
134 // 3. patch_klass_vtables: for Klass list, patch the vtable entry in klass and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
135 // associated metadata to point to jump table rather than to current vtbl |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
136 // Table layout: NOTE FIXED SIZE |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
137 // 1. vtbl pointers |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
138 // 2. #Klass X #virtual methods per Klass |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
139 // 1 entry for each, in the order: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
140 // Klass1:method1 entry, Klass1:method2 entry, ... Klass1:method<num_virtuals> entry |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
141 // Klass2:method1 entry, Klass2:method2 entry, ... Klass2:method<num_virtuals> entry |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
142 // ... |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
143 // Klass<vtbl_list_size>:method1 entry, Klass<vtbl_list_size>:method2 entry, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
144 // ... Klass<vtbl_list_size>:method<num_virtuals> entry |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
145 // Sample entry: (Sparc): |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
146 // save(sp, -256, sp) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
147 // ba,pt common_code |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
148 // mov XXX, %L0 %L0 gets: Klass index <<8 + method index (note: max method index 255) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
149 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
150 // Restore time: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
151 // 1. initialize_shared_space: reserve space for table |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
152 // 2. init_self_patching_vtbl_list: update pointers to NEW virtual method addrs in text |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
153 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
154 // Execution time: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
155 // First virtual method call for any object of these metadata types: |
6733
fa6e618671d7
7195867: NPG: SAJDI tests fail with sun.jvm.hotspot.types.WrongTypeException: No suitable match for type
coleenp
parents:
6725
diff
changeset
|
156 // 1. object->klass |
fa6e618671d7
7195867: NPG: SAJDI tests fail with sun.jvm.hotspot.types.WrongTypeException: No suitable match for type
coleenp
parents:
6725
diff
changeset
|
157 // 2. vtable entry for that klass points to the jump table entries |
fa6e618671d7
7195867: NPG: SAJDI tests fail with sun.jvm.hotspot.types.WrongTypeException: No suitable match for type
coleenp
parents:
6725
diff
changeset
|
158 // 3. branches to common_code with %O0/klass, %L0: Klass index <<8 + method index |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
159 // 4. common_code: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
160 // Get address of new vtbl pointer for this Klass from updated table |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
161 // Update new vtbl pointer in the Klass: future virtual calls go direct |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
162 // Jump to method, using new vtbl pointer and method index |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
163 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
164 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
165 static void* find_matching_vtbl_ptr(void** vtbl_list, void* new_vtable_start, void* obj) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
166 void* old_vtbl_ptr = *(void**)obj; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
167 for (int i = 0; i < MetaspaceShared::vtbl_list_size; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
168 if (vtbl_list[i] == old_vtbl_ptr) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
169 return (void**)new_vtable_start + i * MetaspaceShared::num_virtuals; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
170 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
171 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
172 ShouldNotReachHere(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
173 return NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
175 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
176 // Assumes the vtable is in first slot in object. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
177 static void patch_klass_vtables(void** vtbl_list, void* new_vtable_start) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
178 int n = _global_klass_objects->length(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
179 for (int i = 0; i < n; i++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
180 Klass* obj = _global_klass_objects->at(i); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
181 // Note oop_is_instance() is a virtual call. After patching vtables |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
182 // all virtual calls on the dummy vtables will restore the original! |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 if (obj->oop_is_instance()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
184 InstanceKlass* ik = InstanceKlass::cast(obj); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
185 *(void**)ik = find_matching_vtbl_ptr(vtbl_list, new_vtable_start, ik); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
186 ConstantPool* cp = ik->constants(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
187 *(void**)cp = find_matching_vtbl_ptr(vtbl_list, new_vtable_start, cp); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
188 for (int j = 0; j < ik->methods()->length(); j++) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
189 Method* m = ik->methods()->at(j); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
190 *(void**)m = find_matching_vtbl_ptr(vtbl_list, new_vtable_start, m); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
191 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
192 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
193 // Array klasses |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
194 Klass* k = obj; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
195 *(void**)k = find_matching_vtbl_ptr(vtbl_list, new_vtable_start, k); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
196 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
197 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
198 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
199 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
200 // Closure for serializing initialization data out to a data area to be |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
201 // written to the shared file. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
202 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
203 class WriteClosure : public SerializeClosure { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
204 private: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
205 intptr_t* top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
206 char* end; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
207 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
208 inline void check_space() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
209 if ((char*)top + sizeof(intptr_t) > end) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
210 report_out_of_shared_space(SharedMiscData); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
211 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
212 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
213 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
214 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
215 WriteClosure(char* md_top, char* md_end) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
216 top = (intptr_t*)md_top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
217 end = md_end; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
218 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
219 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
220 char* get_top() { return (char*)top; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
221 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
222 void do_ptr(void** p) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
223 check_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
224 *top = (intptr_t)*p; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
225 ++top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
226 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
227 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
228 void do_tag(int tag) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
229 check_space(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
230 *top = (intptr_t)tag; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
231 ++top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
232 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
233 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
234 void do_region(u_char* start, size_t size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
235 if ((char*)top + size > end) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
236 report_out_of_shared_space(SharedMiscData); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
237 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
238 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
239 assert(size % sizeof(intptr_t) == 0, "bad size"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
240 do_tag((int)size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
241 while (size > 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
242 *top = *(intptr_t*)start; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
243 ++top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
244 start += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
245 size -= sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
246 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
247 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
248 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
249 bool reading() const { return false; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
250 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
251 |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
252 // This is for dumping detailed statistics for the allocations |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
253 // in the shared spaces. |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
254 class DumpAllocClosure : public Metaspace::AllocRecordClosure { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
255 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
256 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
257 // Here's poor man's enum inheritance |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
258 #define SHAREDSPACE_OBJ_TYPES_DO(f) \ |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
259 METASPACE_OBJ_TYPES_DO(f) \ |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
260 f(SymbolHashentry) \ |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
261 f(SymbolBuckets) \ |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
262 f(Other) |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
263 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
264 #define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
265 #define SHAREDSPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
266 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
267 enum Type { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
268 // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
269 SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_DECLARE) |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
270 _number_of_types |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
271 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
272 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
273 static const char * type_name(Type type) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
274 switch(type) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
275 SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_NAME_CASE) |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
276 default: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
277 ShouldNotReachHere(); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
278 return NULL; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
279 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
280 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
281 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
282 public: |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
283 enum { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
284 RO = 0, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
285 RW = 1 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
286 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
287 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
288 int _counts[2][_number_of_types]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
289 int _bytes [2][_number_of_types]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
290 int _which; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
291 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
292 DumpAllocClosure() { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
293 memset(_counts, 0, sizeof(_counts)); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
294 memset(_bytes, 0, sizeof(_bytes)); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
295 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
296 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
297 void iterate_metaspace(Metaspace* space, int which) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
298 assert(which == RO || which == RW, "sanity"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
299 _which = which; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
300 space->iterate(this); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
301 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
302 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
303 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
304 assert(int(type) >= 0 && type < MetaspaceObj::_number_of_types, "sanity"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
305 _counts[_which][type] ++; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
306 _bytes [_which][type] += byte_size; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
307 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
308 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
309 void dump_stats(int ro_all, int rw_all, int md_all, int mc_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
310 }; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
311 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
312 void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
313 rw_all += (md_all + mc_all); // md and mc are all mapped Read/Write |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
314 int other_bytes = md_all + mc_all; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
315 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
316 // Calculate size of data that was not allocated by Metaspace::allocate() |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
317 int symbol_count = _counts[RO][MetaspaceObj::SymbolType]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
318 int symhash_bytes = symbol_count * sizeof (HashtableEntry<Symbol*, mtSymbol>); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
319 int symbuck_count = SymbolTable::the_table()->table_size(); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
320 int symbuck_bytes = symbuck_count * sizeof(HashtableBucket<mtSymbol>); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
321 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
322 _counts[RW][SymbolHashentryType] = symbol_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
323 _bytes [RW][SymbolHashentryType] = symhash_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
324 other_bytes -= symhash_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
325 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
326 _counts[RW][SymbolBucketsType] = symbuck_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
327 _bytes [RW][SymbolBucketsType] = symbuck_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
328 other_bytes -= symbuck_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
329 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
330 // TODO: count things like dictionary, vtable, etc |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
331 _bytes[RW][OtherType] = other_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
332 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
333 // prevent divide-by-zero |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
334 if (ro_all < 1) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
335 ro_all = 1; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
336 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
337 if (rw_all < 1) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
338 rw_all = 1; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
339 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
340 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
341 int all_ro_count = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
342 int all_ro_bytes = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
343 int all_rw_count = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
344 int all_rw_bytes = 0; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
345 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
346 // To make fmt_stats be a syntactic constant (for format warnings), use #define. |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
347 #define fmt_stats "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f" |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
348 const char *sep = "--------------------+---------------------------+---------------------------+--------------------------"; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
349 const char *hdr = " ro_cnt ro_bytes % | rw_cnt rw_bytes % | all_cnt all_bytes %"; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
350 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
351 tty->print_cr("Detailed metadata info (rw includes md and mc):"); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
352 tty->print_cr("%s", hdr); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
353 tty->print_cr("%s", sep); |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
354 for (int type = 0; type < int(_number_of_types); type ++) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
355 const char *name = type_name((Type)type); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
356 int ro_count = _counts[RO][type]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
357 int ro_bytes = _bytes [RO][type]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
358 int rw_count = _counts[RW][type]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
359 int rw_bytes = _bytes [RW][type]; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
360 int count = ro_count + rw_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
361 int bytes = ro_bytes + rw_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
362 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
363 double ro_perc = 100.0 * double(ro_bytes) / double(ro_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
364 double rw_perc = 100.0 * double(rw_bytes) / double(rw_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
365 double perc = 100.0 * double(bytes) / double(ro_all + rw_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
366 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
367 tty->print_cr(fmt_stats, name, |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
368 ro_count, ro_bytes, ro_perc, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
369 rw_count, rw_bytes, rw_perc, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
370 count, bytes, perc); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
371 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
372 all_ro_count += ro_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
373 all_ro_bytes += ro_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
374 all_rw_count += rw_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
375 all_rw_bytes += rw_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
376 } |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
377 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
378 int all_count = all_ro_count + all_rw_count; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
379 int all_bytes = all_ro_bytes + all_rw_bytes; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
380 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
381 double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
382 double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
383 double all_perc = 100.0 * double(all_bytes) / double(ro_all + rw_all); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
384 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
385 tty->print_cr("%s", sep); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
386 tty->print_cr(fmt_stats, "Total", |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
387 all_ro_count, all_ro_bytes, all_ro_perc, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
388 all_rw_count, all_rw_bytes, all_rw_perc, |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
389 all_count, all_bytes, all_perc); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
390 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
391 assert(all_ro_bytes == ro_all, "everything should have been counted"); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
392 assert(all_rw_bytes == rw_all, "everything should have been counted"); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
393 #undef fmt_stats |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
394 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
395 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
396 // Populate the shared space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
397 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
398 class VM_PopulateDumpSharedSpace: public VM_Operation { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
399 private: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
400 ClassLoaderData* _loader_data; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
401 GrowableArray<Klass*> *_class_promote_order; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
402 VirtualSpace _md_vs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
403 VirtualSpace _mc_vs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
404 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
405 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
406 VM_PopulateDumpSharedSpace(ClassLoaderData* loader_data, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
407 GrowableArray<Klass*> *class_promote_order) : |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
408 _loader_data(loader_data) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
409 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
410 // Split up and initialize the misc code and data spaces |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
411 ReservedSpace* shared_rs = MetaspaceShared::shared_rs(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
412 int metadata_size = SharedReadOnlySize+SharedReadWriteSize; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
413 ReservedSpace shared_ro_rw = shared_rs->first_part(metadata_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
414 ReservedSpace misc_section = shared_rs->last_part(metadata_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
415 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
416 // Now split into misc sections. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
417 ReservedSpace md_rs = misc_section.first_part(SharedMiscDataSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
418 ReservedSpace mc_rs = misc_section.last_part(SharedMiscDataSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
419 _md_vs.initialize(md_rs, SharedMiscDataSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
420 _mc_vs.initialize(mc_rs, SharedMiscCodeSize); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
421 _class_promote_order = class_promote_order; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
422 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
423 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
424 VMOp_Type type() const { return VMOp_PopulateDumpSharedSpace; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
425 void doit(); // outline because gdb sucks |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
426 }; // class VM_PopulateDumpSharedSpace |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
427 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
428 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
429 void VM_PopulateDumpSharedSpace::doit() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
430 Thread* THREAD = VMThread::vm_thread(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
431 NOT_PRODUCT(SystemDictionary::verify();) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
432 // The following guarantee is meant to ensure that no loader constraints |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
433 // exist yet, since the constraints table is not shared. This becomes |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
434 // more important now that we don't re-initialize vtables/itables for |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
435 // shared classes at runtime, where constraints were previously created. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
436 guarantee(SystemDictionary::constraints()->number_of_entries() == 0, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
437 "loader constraints are not saved"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
438 guarantee(SystemDictionary::placeholders()->number_of_entries() == 0, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
439 "placeholders are not saved"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
440 // Revisit and implement this if we prelink method handle call sites: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
441 guarantee(SystemDictionary::invoke_method_table() == NULL || |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
442 SystemDictionary::invoke_method_table()->number_of_entries() == 0, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
443 "invoke method table is not saved"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
444 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
445 // At this point, many classes have been loaded. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
446 // Gather systemDictionary classes in a global array and do everything to |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
447 // that so we don't have to walk the SystemDictionary again. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
448 _global_klass_objects = new GrowableArray<Klass*>(1000); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
449 Universe::basic_type_classes_do(collect_classes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
450 SystemDictionary::classes_do(collect_classes); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
451 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
452 tty->print_cr("Number of classes %d", _global_klass_objects->length()); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
453 { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
454 int num_type_array = 0, num_obj_array = 0, num_inst = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
455 for (int i = 0; i < _global_klass_objects->length(); i++) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
456 Klass* k = _global_klass_objects->at(i); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
457 if (k->oop_is_instance()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
458 num_inst ++; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
459 } else if (k->oop_is_objArray()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
460 num_obj_array ++; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
461 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
462 assert(k->oop_is_typeArray(), "sanity"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
463 num_type_array ++; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
464 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
465 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
466 tty->print_cr(" instance classes = %5d", num_inst); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
467 tty->print_cr(" obj array classes = %5d", num_obj_array); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
468 tty->print_cr(" type array classes = %5d", num_type_array); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
469 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
470 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
471 // Update all the fingerprints in the shared methods. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
472 tty->print("Calculating fingerprints ... "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
473 calculate_fingerprints(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
474 tty->print_cr("done. "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
475 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
476 // Remove all references outside the metadata |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
477 tty->print("Removing unshareable information ... "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
478 remove_unshareable_in_classes(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
479 tty->print_cr("done. "); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
480 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
481 // Set up the share data and shared code segments. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
482 char* md_low = _md_vs.low(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
483 char* md_top = md_low; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
484 char* md_end = _md_vs.high(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
485 char* mc_low = _mc_vs.low(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
486 char* mc_top = mc_low; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
487 char* mc_end = _mc_vs.high(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
488 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
489 // Reserve space for the list of Klass*s whose vtables are used |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
490 // for patching others as needed. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
491 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
492 void** vtbl_list = (void**)md_top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
493 int vtbl_list_size = MetaspaceShared::vtbl_list_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
494 Universe::init_self_patching_vtbl_list(vtbl_list, vtbl_list_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
495 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
496 md_top += vtbl_list_size * sizeof(void*); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
497 void* vtable = md_top; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
498 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
499 // Reserve space for a new dummy vtable for klass objects in the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
500 // heap. Generate self-patching vtable entries. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
501 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
502 MetaspaceShared::generate_vtable_methods(vtbl_list, &vtable, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
503 &md_top, md_end, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
504 &mc_top, mc_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
505 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
506 // Reorder the system dictionary. (Moving the symbols affects |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
507 // how the hash table indices are calculated.) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
508 // Not doing this either. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
509 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
510 SystemDictionary::reorder_dictionary(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
511 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
512 NOT_PRODUCT(SystemDictionary::verify();) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
513 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
514 // Copy the the symbol table, and the system dictionary to the shared |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
515 // space in usable form. Copy the hastable |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
516 // buckets first [read-write], then copy the linked lists of entries |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
517 // [read-only]. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
518 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
519 SymbolTable::reverse(md_top); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
520 NOT_PRODUCT(SymbolTable::verify()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
521 SymbolTable::copy_buckets(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
522 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
523 SystemDictionary::reverse(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
524 SystemDictionary::copy_buckets(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
525 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
526 ClassLoader::verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
527 ClassLoader::copy_package_info_buckets(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
528 ClassLoader::verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
529 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
530 SymbolTable::copy_table(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
531 SystemDictionary::copy_table(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
532 ClassLoader::verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
533 ClassLoader::copy_package_info_table(&md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
534 ClassLoader::verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
535 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
536 // Write the other data to the output array. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
537 WriteClosure wc(md_top, md_end); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
538 MetaspaceShared::serialize(&wc); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
539 md_top = wc.get_top(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
540 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
541 // Print shared spaces all the time |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
542 // To make fmt_space be a syntactic constant (for format warnings), use #define. |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
543 #define fmt_space "%s space: %9d [ %4.1f%% of total] out of %9d bytes [%4.1f%% used] at " PTR_FORMAT |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
544 Metaspace* ro_space = _loader_data->ro_metaspace(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
545 Metaspace* rw_space = _loader_data->rw_metaspace(); |
7591
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
546 |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
547 // Allocated size of each space (may not be all occupied) |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
7591
diff
changeset
|
548 const size_t ro_alloced = ro_space->capacity_bytes_slow(Metaspace::NonClassType); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
7591
diff
changeset
|
549 const size_t rw_alloced = rw_space->capacity_bytes_slow(Metaspace::NonClassType); |
7591
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
550 const size_t md_alloced = md_end-md_low; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
551 const size_t mc_alloced = mc_end-mc_low; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
552 const size_t total_alloced = ro_alloced + rw_alloced + md_alloced + mc_alloced; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
553 |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
554 // Occupied size of each space. |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
7591
diff
changeset
|
555 const size_t ro_bytes = ro_space->used_bytes_slow(Metaspace::NonClassType); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
7591
diff
changeset
|
556 const size_t rw_bytes = rw_space->used_bytes_slow(Metaspace::NonClassType); |
7591
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
557 const size_t md_bytes = size_t(md_top - md_low); |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
558 const size_t mc_bytes = size_t(mc_top - mc_low); |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
559 |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
560 // Percent of total size |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
561 const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
562 const double ro_t_perc = ro_bytes / double(total_bytes) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
563 const double rw_t_perc = rw_bytes / double(total_bytes) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
564 const double md_t_perc = md_bytes / double(total_bytes) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
565 const double mc_t_perc = mc_bytes / double(total_bytes) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
566 |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
567 // Percent of fullness of each space |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
568 const double ro_u_perc = ro_bytes / double(ro_alloced) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
569 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
570 const double md_u_perc = md_bytes / double(md_alloced) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
571 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
572 const double total_u_perc = total_bytes / double(total_alloced) * 100.0; |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
573 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
574 tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, ro_space->bottom()); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
575 tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, rw_space->bottom()); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
576 tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, md_low); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
577 tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, mc_low); |
7591
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
578 tty->print_cr("total : %9d [100.0%% of total] out of %9d bytes [%4.1f%% used]", |
c793367610c1
8005467: CDS size information is incorrect and unfriendly
coleenp
parents:
7460
diff
changeset
|
579 total_bytes, total_alloced, total_u_perc); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
580 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
581 // Update the vtable pointers in all of the Klass objects in the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
582 // heap. They should point to newly generated vtable. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
583 patch_klass_vtables(vtbl_list, vtable); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
584 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
585 // dunno what this is for. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
586 char* saved_vtbl = (char*)os::malloc(vtbl_list_size * sizeof(void*), mtClass); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
587 memmove(saved_vtbl, vtbl_list, vtbl_list_size * sizeof(void*)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
588 memset(vtbl_list, 0, vtbl_list_size * sizeof(void*)); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
589 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
590 // Create and write the archive file that maps the shared spaces. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
591 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
592 FileMapInfo* mapinfo = new FileMapInfo(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
593 mapinfo->populate_header(MetaspaceShared::max_alignment()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
594 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
595 // Pass 1 - update file offsets in header. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
596 mapinfo->write_header(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
597 mapinfo->write_space(MetaspaceShared::ro, _loader_data->ro_metaspace(), true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
598 mapinfo->write_space(MetaspaceShared::rw, _loader_data->rw_metaspace(), false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
599 mapinfo->write_region(MetaspaceShared::md, _md_vs.low(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
600 pointer_delta(md_top, _md_vs.low(), sizeof(char)), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
601 SharedMiscDataSize, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
602 false, false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
603 mapinfo->write_region(MetaspaceShared::mc, _mc_vs.low(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
604 pointer_delta(mc_top, _mc_vs.low(), sizeof(char)), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
605 SharedMiscCodeSize, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
606 true, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
607 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
608 // Pass 2 - write data. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
609 mapinfo->open_for_write(); |
18096 | 610 mapinfo->set_header_crc(mapinfo->compute_header_crc()); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
611 mapinfo->write_header(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
612 mapinfo->write_space(MetaspaceShared::ro, _loader_data->ro_metaspace(), true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
613 mapinfo->write_space(MetaspaceShared::rw, _loader_data->rw_metaspace(), false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
614 mapinfo->write_region(MetaspaceShared::md, _md_vs.low(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
615 pointer_delta(md_top, _md_vs.low(), sizeof(char)), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
616 SharedMiscDataSize, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
617 false, false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
618 mapinfo->write_region(MetaspaceShared::mc, _mc_vs.low(), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
619 pointer_delta(mc_top, _mc_vs.low(), sizeof(char)), |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
620 SharedMiscCodeSize, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
621 true, true); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
622 mapinfo->close(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
623 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
624 memmove(vtbl_list, saved_vtbl, vtbl_list_size * sizeof(void*)); |
10376
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
625 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
626 if (PrintSharedSpaces) { |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
627 DumpAllocClosure dac; |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
628 dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
629 dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
630 |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
631 dac.dump_stats(int(ro_bytes), int(rw_bytes), int(md_bytes), int(mc_bytes)); |
a1ebd310d5c1
8014912: Restore PrintSharedSpaces functionality after NPG
iklam
parents:
10183
diff
changeset
|
632 } |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17876
diff
changeset
|
633 #undef fmt_space |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
634 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
635 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
636 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
637 void MetaspaceShared::link_one_shared_class(Klass* obj, TRAPS) { |
6983 | 638 Klass* k = obj; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
639 if (k->oop_is_instance()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
640 InstanceKlass* ik = (InstanceKlass*) k; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
641 // Link the class to cause the bytecodes to be rewritten and the |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
642 // cpcache to be created. Class verification is done according |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
643 // to -Xverify setting. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
644 _link_classes_made_progress |= try_link_class(ik, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
645 guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
646 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
647 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
648 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
649 void MetaspaceShared::check_one_shared_class(Klass* k) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
650 if (k->oop_is_instance() && InstanceKlass::cast(k)->check_sharing_error_state()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
651 _check_classes_made_progress = true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
652 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
653 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
654 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
655 void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
656 // We need to iterate because verification may cause additional classes |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
657 // to be loaded. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
658 do { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
659 _link_classes_made_progress = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
660 SystemDictionary::classes_do(link_one_shared_class, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
661 guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
662 } while (_link_classes_made_progress); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
663 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
664 if (_has_error_classes) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
665 // Mark all classes whose super class or interfaces failed verification. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
666 do { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
667 // Not completely sure if we need to do this iteratively. Anyway, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
668 // we should come here only if there are unverifiable classes, which |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
669 // shouldn't happen in normal cases. So better safe than sorry. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
670 _check_classes_made_progress = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
671 SystemDictionary::classes_do(check_one_shared_class); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
672 } while (_check_classes_made_progress); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
673 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
674 if (IgnoreUnverifiableClassesDuringDump) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
675 // This is useful when running JCK or SQE tests. You should not |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
676 // enable this when running real apps. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
677 SystemDictionary::remove_classes_in_error_state(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
678 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
679 tty->print_cr("Please remove the unverifiable classes from your class list and try again"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
680 exit(1); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
681 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
682 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
683 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
684 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
685 void MetaspaceShared::prepare_for_dumping() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
686 ClassLoader::initialize_shared_path(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
687 FileMapInfo::allocate_classpath_entry_table(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
688 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
689 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
690 // Preload classes from a list, populate the shared spaces and dump to a |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
691 // file. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
692 void MetaspaceShared::preload_and_dump(TRAPS) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
693 TraceTime timer("Dump Shared Spaces", TraceStartupTime); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
694 ResourceMark rm; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
695 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
696 tty->print_cr("Allocated shared space: %d bytes at " PTR_FORMAT, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
697 MetaspaceShared::shared_rs()->size(), |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
698 MetaspaceShared::shared_rs()->base()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
699 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
700 // Preload classes to be shared. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
701 // Should use some os:: method rather than fopen() here. aB. |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
702 const char* class_list_path; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
703 if (SharedClassListFile == NULL) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
704 // Construct the path to the class list (in jre/lib) |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
705 // Walk up two directories from the location of the VM and |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
706 // optionally tack on "lib" (depending on platform) |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
707 char class_list_path_str[JVM_MAXPATHLEN]; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
708 os::jvm_path(class_list_path_str, sizeof(class_list_path_str)); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
709 for (int i = 0; i < 3; i++) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
710 char *end = strrchr(class_list_path_str, *os::file_separator()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
711 if (end != NULL) *end = '\0'; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
712 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
713 int class_list_path_len = (int)strlen(class_list_path_str); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
714 if (class_list_path_len >= 3) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
715 if (strcmp(class_list_path_str + class_list_path_len - 3, "lib") != 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
716 strcat(class_list_path_str, os::file_separator()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
717 strcat(class_list_path_str, "lib"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
718 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
719 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
720 strcat(class_list_path_str, os::file_separator()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
721 strcat(class_list_path_str, "classlist"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
722 class_list_path = class_list_path_str; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
723 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
724 class_list_path = SharedClassListFile; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
725 } |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
726 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
727 int class_count = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
728 GrowableArray<Klass*>* class_promote_order = new GrowableArray<Klass*>(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
729 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
730 // sun.io.Converters |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
731 static const char obj_array_sig[] = "[[Ljava/lang/Object;"; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
732 SymbolTable::new_permanent_symbol(obj_array_sig, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
733 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
734 // java.util.HashMap |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
735 static const char map_entry_array_sig[] = "[Ljava/util/Map$Entry;"; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
736 SymbolTable::new_permanent_symbol(map_entry_array_sig, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
737 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
738 tty->print_cr("Loading classes to share ..."); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
739 _has_error_classes = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
740 class_count += preload_and_dump(class_list_path, class_promote_order, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
741 THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
742 if (ExtraSharedClassListFile) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
743 class_count += preload_and_dump(ExtraSharedClassListFile, class_promote_order, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
744 THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
745 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
746 tty->print_cr("Loading classes to share: done."); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
747 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
748 if (PrintSharedSpaces) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
749 tty->print_cr("Shared spaces: preloaded %d classes", class_count); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
750 } |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
751 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
752 // Rewrite and link classes |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
753 tty->print_cr("Rewriting and linking classes ..."); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
754 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
755 // Link any classes which got missed. This would happen if we have loaded classes that |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
756 // were not explicitly specified in the classlist. E.g., if an interface implemented by class K |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
757 // fails verification, all other interfaces that were not specified in the classlist but |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
758 // are implemented by K are not verified. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
759 link_and_cleanup_shared_classes(CATCH); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
760 tty->print_cr("Rewriting and linking classes: done"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
761 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
762 // Create and dump the shared spaces. Everything so far is loaded |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
763 // with the null class loader. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
764 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
765 VM_PopulateDumpSharedSpace op(loader_data, class_promote_order); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
766 VMThread::execute(&op); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
767 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
768 // Since various initialization steps have been undone by this process, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
769 // it is not reasonable to continue running a java process. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
770 exit(0); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
771 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
772 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
773 int MetaspaceShared::preload_and_dump(const char * class_list_path, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
774 GrowableArray<Klass*>* class_promote_order, |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
775 TRAPS) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
776 FILE* file = fopen(class_list_path, "r"); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
777 char class_name[256]; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
778 int class_count = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
779 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
780 if (file != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
781 while ((fgets(class_name, sizeof class_name, file)) != NULL) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
782 if (*class_name == '#') { // comment |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
783 continue; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
784 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
785 // Remove trailing newline |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
786 size_t name_len = strlen(class_name); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
787 if (class_name[name_len-1] == '\n') { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
788 class_name[name_len-1] = '\0'; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
789 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
790 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
791 // Got a class name - load it. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
792 TempNewSymbol class_name_symbol = SymbolTable::new_permanent_symbol(class_name, THREAD); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
793 guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol."); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
794 Klass* klass = SystemDictionary::resolve_or_null(class_name_symbol, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
795 THREAD); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
796 CLEAR_PENDING_EXCEPTION; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
797 if (klass != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
798 if (PrintSharedSpaces && Verbose && WizardMode) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
799 tty->print_cr("Shared spaces preloaded: %s", class_name); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
800 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
801 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
802 InstanceKlass* ik = InstanceKlass::cast(klass); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
803 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
804 // Should be class load order as per -XX:+TraceClassLoadingPreorder |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
805 class_promote_order->append(ik); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
806 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
807 // Link the class to cause the bytecodes to be rewritten and the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
808 // cpcache to be created. The linking is done as soon as classes |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
809 // are loaded in order that the related data structures (klass and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
810 // cpCache) are located together. |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
811 try_link_class(ik, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
812 guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
813 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
814 class_count++; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
815 } else { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
816 //tty->print_cr("Preload failed: %s", class_name); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
817 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
818 } |
20389
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
819 fclose(file); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
820 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
821 char errmsg[JVM_MAXPATHLEN]; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
822 os::lasterror(errmsg, JVM_MAXPATHLEN); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
823 tty->print_cr("Loading classlist failed: %s", errmsg); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
824 exit(1); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
825 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
826 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
827 return class_count; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
828 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
829 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
830 // Returns true if the class's status has changed |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
831 bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
832 assert(DumpSharedSpaces, "should only be called during dumping"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
833 if (ik->init_state() < InstanceKlass::linked) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
834 bool saved = BytecodeVerificationLocal; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
835 if (!SharedClassUtil::is_shared_boot_class(ik)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
836 // The verification decision is based on BytecodeVerificationRemote |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
837 // for non-system classes. Since we are using the NULL classloader |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
838 // to load non-system classes during dumping, we need to temporarily |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
839 // change BytecodeVerificationLocal to be the same as |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
840 // BytecodeVerificationRemote. Note this can cause the parent system |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
841 // classes also being verified. The extra overhead is acceptable during |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
842 // dumping. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
843 BytecodeVerificationLocal = BytecodeVerificationRemote; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
844 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
845 ik->link_class(THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
846 if (HAS_PENDING_EXCEPTION) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
847 ResourceMark rm; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
848 tty->print_cr("Preload Error: Verification failed for %s", |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
849 ik->external_name()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
850 CLEAR_PENDING_EXCEPTION; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
851 ik->set_in_error_state(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
852 _has_error_classes = true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
853 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
854 BytecodeVerificationLocal = saved; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
855 return true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
856 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
857 return false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
858 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
859 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
860 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
861 // Closure for serializing initialization data in from a data area |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
862 // (ptr_array) read from the shared file. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
863 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
864 class ReadClosure : public SerializeClosure { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
865 private: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
866 intptr_t** _ptr_array; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
867 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
868 inline intptr_t nextPtr() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
869 return *(*_ptr_array)++; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
870 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
871 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
872 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
873 ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
874 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
875 void do_ptr(void** p) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
876 assert(*p == NULL, "initializing previous initialized pointer."); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
877 intptr_t obj = nextPtr(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
878 assert((intptr_t)obj >= 0 || (intptr_t)obj < -100, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
879 "hit tag while initializing ptrs."); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
880 *p = (void*)obj; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
881 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
882 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
883 void do_tag(int tag) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
884 int old_tag; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
885 old_tag = (int)(intptr_t)nextPtr(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
886 // do_int(&old_tag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
887 assert(tag == old_tag, "old tag doesn't match"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
888 FileMapInfo::assert_mark(tag == old_tag); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
889 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
890 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
891 void do_region(u_char* start, size_t size) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
892 assert((intptr_t)start % sizeof(intptr_t) == 0, "bad alignment"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
893 assert(size % sizeof(intptr_t) == 0, "bad size"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
894 do_tag((int)size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
895 while (size > 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
896 *(intptr_t*)start = nextPtr(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
897 start += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
898 size -= sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
899 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
900 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
901 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
902 bool reading() const { return true; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
903 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
904 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
905 // Return true if given address is in the mapped shared space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
906 bool MetaspaceShared::is_in_shared_space(const void* p) { |
11056
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
907 return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_space(p); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
908 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
909 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
910 void MetaspaceShared::print_shared_spaces() { |
11056
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
911 if (UseSharedSpaces) { |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
912 FileMapInfo::current_info()->print_shared_spaces(); |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
913 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
914 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
915 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
916 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
917 // Map shared spaces at requested addresses and return if succeeded. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
918 // Need to keep the bounds of the ro and rw space for the Metaspace::contains |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
919 // call, or is_in_shared_space. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
920 bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
921 size_t image_alignment = mapinfo->alignment(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
922 |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
923 #ifndef _WINDOWS |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
924 // Map in the shared memory and then map the regions on top of it. |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
925 // On Windows, don't map the memory here because it will cause the |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
926 // mappings of the regions to fail. |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
927 ReservedSpace shared_rs = mapinfo->reserve_shared_memory(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
928 if (!shared_rs.is_reserved()) return false; |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
929 #endif |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
930 |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
931 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
932 |
11056
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
933 char* _ro_base = NULL; |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
934 char* _rw_base = NULL; |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
935 char* _md_base = NULL; |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
936 char* _mc_base = NULL; |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10376
diff
changeset
|
937 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
938 // Map each shared region |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
939 if ((_ro_base = mapinfo->map_region(ro)) != NULL && |
18096 | 940 mapinfo->verify_region_checksum(ro) && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
941 (_rw_base = mapinfo->map_region(rw)) != NULL && |
18096 | 942 mapinfo->verify_region_checksum(rw) && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
943 (_md_base = mapinfo->map_region(md)) != NULL && |
18096 | 944 mapinfo->verify_region_checksum(md) && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
945 (_mc_base = mapinfo->map_region(mc)) != NULL && |
18096 | 946 mapinfo->verify_region_checksum(mc) && |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
947 (image_alignment == (size_t)max_alignment()) && |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
948 mapinfo->validate_classpath_entry_table()) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
949 // Success (no need to do anything) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
950 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
951 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
952 // If there was a failure in mapping any of the spaces, unmap the ones |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
953 // that succeeded |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
954 if (_ro_base != NULL) mapinfo->unmap_region(ro); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
955 if (_rw_base != NULL) mapinfo->unmap_region(rw); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
956 if (_md_base != NULL) mapinfo->unmap_region(md); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
957 if (_mc_base != NULL) mapinfo->unmap_region(mc); |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
958 #ifndef _WINDOWS |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
959 // Release the entire mapped region |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
960 shared_rs.release(); |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
6983
diff
changeset
|
961 #endif |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
962 // If -Xshare:on is specified, print out the error message and exit VM, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
963 // otherwise, set UseSharedSpaces to false and continue. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
964 if (RequireSharedSpaces) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
965 vm_exit_during_initialization("Unable to use shared archive.", "Failed map_region for using -Xshare:on."); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
966 } else { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
967 FLAG_SET_DEFAULT(UseSharedSpaces, false); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
968 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
969 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
970 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
971 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
972 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
973 // Read the miscellaneous data from the shared file, and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
974 // serialize it out to its various destinations. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
975 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
976 void MetaspaceShared::initialize_shared_spaces() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
977 FileMapInfo *mapinfo = FileMapInfo::current_info(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
978 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
979 char* buffer = mapinfo->region_base(md); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
980 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
981 // Skip over (reserve space for) a list of addresses of C++ vtables |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
982 // for Klass objects. They get filled in later. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
983 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
984 void** vtbl_list = (void**)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
985 buffer += MetaspaceShared::vtbl_list_size * sizeof(void*); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
986 Universe::init_self_patching_vtbl_list(vtbl_list, vtbl_list_size); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
987 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
988 // Skip over (reserve space for) dummy C++ vtables Klass objects. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
989 // They are used as is. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
990 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
991 intptr_t vtable_size = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
992 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
993 buffer += vtable_size; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
994 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
995 // Create the symbol table using the bucket array at this spot in the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
996 // misc data space. Since the symbol table is often modified, this |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
997 // region (of mapped pages) will be copy-on-write. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
998 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
999 int symbolTableLen = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1000 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1001 int number_of_entries = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1002 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1003 SymbolTable::create_table((HashtableBucket<mtSymbol>*)buffer, symbolTableLen, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1004 number_of_entries); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1005 buffer += symbolTableLen; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1006 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1007 // Create the shared dictionary using the bucket array at this spot in |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1008 // the misc data space. Since the shared dictionary table is never |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1009 // modified, this region (of mapped pages) will be (effectively, if |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1010 // not explicitly) read-only. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1011 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1012 int sharedDictionaryLen = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1013 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1014 number_of_entries = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1015 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1016 SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1017 sharedDictionaryLen, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1018 number_of_entries); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1019 buffer += sharedDictionaryLen; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1020 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1021 // Create the package info table using the bucket array at this spot in |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1022 // the misc data space. Since the package info table is never |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1023 // modified, this region (of mapped pages) will be (effectively, if |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1024 // not explicitly) read-only. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1025 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1026 int pkgInfoLen = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1027 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1028 number_of_entries = *(intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1029 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1030 ClassLoader::create_package_info_table((HashtableBucket<mtClass>*)buffer, pkgInfoLen, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1031 number_of_entries); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1032 buffer += pkgInfoLen; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1033 ClassLoader::verify(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1034 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1035 // The following data in the shared misc data region are the linked |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1036 // list elements (HashtableEntry objects) for the symbol table, string |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1037 // table, and shared dictionary. The heap objects refered to by the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1038 // symbol table, string table, and shared dictionary are permanent and |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1039 // unmovable. Since new entries added to the string and symbol tables |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1040 // are always added at the beginning of the linked lists, THESE LINKED |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1041 // LIST ELEMENTS ARE READ-ONLY. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1042 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1043 int len = *(intptr_t*)buffer; // skip over symbol table entries |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1044 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1045 buffer += len; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1046 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1047 len = *(intptr_t*)buffer; // skip over shared dictionary entries |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1048 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1049 buffer += len; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1050 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1051 len = *(intptr_t*)buffer; // skip over package info table entries |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1052 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1053 buffer += len; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1054 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1055 len = *(intptr_t*)buffer; // skip over package info table char[] arrays. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1056 buffer += sizeof(intptr_t); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1057 buffer += len; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1058 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1059 intptr_t* array = (intptr_t*)buffer; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1060 ReadClosure rc(&array); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1061 serialize(&rc); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1062 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1063 // Close the mapinfo file |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1064 mapinfo->close(); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1065 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1066 if (PrintSharedArchiveAndExit) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1067 if (PrintSharedDictionary) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1068 tty->print_cr("\nShared classes:\n"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1069 SystemDictionary::print_shared(false); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1070 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1071 if (_archive_loading_failed) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1072 tty->print_cr("archive is invalid"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1073 vm_exit(1); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1074 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1075 tty->print_cr("archive is valid"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1076 vm_exit(0); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1077 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
1078 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1079 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1080 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1081 // JVM/TI RedefineClasses() support: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1082 bool MetaspaceShared::remap_shared_readonly_as_readwrite() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1083 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1084 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1085 if (UseSharedSpaces) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1086 // remap the shared readonly space to shared readwrite, private |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1087 FileMapInfo* mapinfo = FileMapInfo::current_info(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1088 if (!mapinfo->remap_shared_readonly_as_readwrite()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1089 return false; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1090 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1091 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1092 return true; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1093 } |
20389
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1094 |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1095 int MetaspaceShared::count_class(const char* classlist_file) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1096 if (classlist_file == NULL) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1097 return 0; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1098 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1099 char class_name[256]; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1100 int class_count = 0; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1101 FILE* file = fopen(classlist_file, "r"); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1102 if (file != NULL) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1103 while ((fgets(class_name, sizeof class_name, file)) != NULL) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1104 if (*class_name == '#') { // comment |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1105 continue; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1106 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1107 class_count++; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1108 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1109 fclose(file); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1110 } else { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1111 char errmsg[JVM_MAXPATHLEN]; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1112 os::lasterror(errmsg, JVM_MAXPATHLEN); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1113 tty->print_cr("Loading classlist failed: %s", errmsg); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1114 exit(1); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1115 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1116 |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1117 return class_count; |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1118 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1119 |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1120 // the sizes are good for typical large applications that have a lot of shared |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1121 // classes |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1122 void MetaspaceShared::estimate_regions_size() { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1123 int class_count = count_class(SharedClassListFile); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1124 class_count += count_class(ExtraSharedClassListFile); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1125 |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1126 if (class_count > LargeThresholdClassCount) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1127 if (class_count < HugeThresholdClassCount) { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1128 SET_ESTIMATED_SIZE(Large, ReadOnly); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1129 SET_ESTIMATED_SIZE(Large, ReadWrite); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1130 SET_ESTIMATED_SIZE(Large, MiscData); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1131 SET_ESTIMATED_SIZE(Large, MiscCode); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1132 } else { |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1133 SET_ESTIMATED_SIZE(Huge, ReadOnly); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1134 SET_ESTIMATED_SIZE(Huge, ReadWrite); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1135 SET_ESTIMATED_SIZE(Huge, MiscData); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1136 SET_ESTIMATED_SIZE(Huge, MiscCode); |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1137 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1138 } |
622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
20375
diff
changeset
|
1139 } |