annotate src/share/vm/memory/dump.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents 828eafbd85cc
children b099aaf51bf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/javaClasses.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "classfile/loaderConstraints.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/symbolTable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "gc_implementation/shared/spaceDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "memory/classify.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "memory/filemap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "memory/oopFactory.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "oops/methodDataOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "runtime/javaCalls.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #include "runtime/signature.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #include "runtime/vmThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 #include "runtime/vm_operations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 #include "utilities/copy.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // Closure to set up the fingerprint field for all methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class FingerprintMethodsClosure: public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (obj->is_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 methodOop mobj = (methodOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 (new Fingerprinter(mobj))->fingerprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 };
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Closure to set the hash value (String.hash field) in all of the
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // String objects in the heap. Setting the hash value is not required.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // However, setting the value in advance prevents the value from being
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // written later, increasing the likelihood that the shared page contain
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // the hash can be shared.
a61af66fc99e Initial load
duke
parents:
diff changeset
64 //
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // NOTE THAT the algorithm in StringTable::hash_string() MUST MATCH the
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // algorithm in java.lang.String.hashCode().
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 class StringHashCodeClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 Thread* THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int hash_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 StringHashCodeClosure(Thread* t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 THREAD = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 hash_offset = java_lang_String::hash_offset_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
78 void do_oop(oop* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
79 if (p != NULL) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
80 oop obj = *p;
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 714
diff changeset
81 if (obj->klass() == SystemDictionary::String_klass()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int hash;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 typeArrayOop value = java_lang_String::value(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 int length = java_lang_String::length(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (length == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 hash = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int offset = java_lang_String::offset(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 jchar* s = value->char_at_addr(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 hash = StringTable::hash_string(s, length);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 obj->int_field_put(hash_offset, hash);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
97 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 };
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Remove data from objects which should not appear in the shared file
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // (as it pertains only to the current JVM).
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 class RemoveUnshareableInfoClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Zap data from the objects which is pertains only to this JVM. We
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // want that data recreated in new JVMs when the shared file is used.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 if (obj->is_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 ((methodOop)obj)->remove_unshareable_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 else if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 Klass::cast((klassOop)obj)->remove_unshareable_info();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Don't save compiler related special oops (shouldn't be any yet).
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if (obj->is_methodData() || obj->is_compiledICHolder()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 static bool mark_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (obj != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
126 !obj->is_shared() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
127 !obj->is_forwarded() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
128 !obj->is_gc_marked()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 obj->set_mark(markOopDesc::prototype()->set_marked());
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
136
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
137 class MoveSymbols : public SymbolClosure {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
138 private:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
139 char* _start;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
140 char* _end;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
141 char* _top;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
142 int _count;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
143
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
144 bool in_shared_space(Symbol* sym) const {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
145 return (char*)sym >= _start && (char*)sym < _end;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
146 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
147
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
148 Symbol* get_shared_copy(Symbol* sym) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
149 return sym->refcount() > 0 ? NULL : (Symbol*)(_start - sym->refcount());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
150 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
151
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
152 Symbol* make_shared_copy(Symbol* sym) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
153 Symbol* new_sym = (Symbol*)_top;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
154 int size = sym->object_size();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
155 _top += size * HeapWordSize;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
156 if (_top <= _end) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
157 Copy::disjoint_words((HeapWord*)sym, (HeapWord*)new_sym, size);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
158 // Encode a reference to the copy as a negative distance from _start
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
159 // When a symbol is being copied to a shared space
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
160 // during CDS archive creation, the original symbol is marked
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
161 // as relocated by putting a negative value to its _refcount field,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
162 // This value is also used to find where exactly the shared copy is
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
163 // (see MoveSymbols::get_shared_copy), so that the other references
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
164 // to this symbol could be changed to point to the shared copy.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
165 sym->_refcount = (int)(_start - (char*)new_sym);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
166 // Mark the symbol in the shared archive as immortal so it is read only
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
167 // and not refcounted.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
168 new_sym->_refcount = -1;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
169 _count++;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
170 } else {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
171 report_out_of_shared_space(SharedMiscData);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
172 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
173 return new_sym;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
174 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
175
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
176 public:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
177 MoveSymbols(char* top, char* end) :
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
178 _start(top), _end(end), _top(top), _count(0) { }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
179
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
180 char* get_top() const { return _top; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
181 int count() const { return _count; }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
182
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
183 void do_symbol(Symbol** p) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
184 Symbol* sym = load_symbol(p);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
185 if (sym != NULL && !in_shared_space(sym)) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
186 Symbol* new_sym = get_shared_copy(sym);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
187 if (new_sym == NULL) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
188 // The symbol has not been relocated yet; copy it to _top address
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
189 assert(sym->refcount() > 0, "should have positive reference count");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
190 new_sym = make_shared_copy(sym);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
191 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
192 // Make the reference point to the shared copy of the symbol
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
193 store_symbol(p, new_sym);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
194 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
195 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
196 };
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
197
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
198
0
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Closure: mark objects closure.
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 class MarkObjectsOopClosure : public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public:
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
203 void do_oop(oop* p) { mark_object(*p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
204 void do_oop(narrowOop* p) { ShouldNotReachHere(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 };
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 class MarkObjectsSkippingKlassesOopClosure : public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
210 void do_oop(oop* pobj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 oop obj = *pobj;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (obj != NULL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
213 !obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 mark_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
217 void do_oop(narrowOop* pobj) { ShouldNotReachHere(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 };
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 static void mark_object_recursive_skipping_klasses(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 mark_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 if (obj != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 MarkObjectsSkippingKlassesOopClosure mark_all;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 obj->oop_iterate(&mark_all);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
230 // Closure: mark common read-only objects
0
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 class MarkCommonReadOnly : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
234 MarkObjectsOopClosure mark_all;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Mark all constMethod objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 if (obj->is_constMethod()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 mark_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 mark_object(constMethodOop(obj)->stackmap_data());
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Exception tables are needed by ci code during compilation.
a61af66fc99e Initial load
duke
parents:
diff changeset
244 mark_object(constMethodOop(obj)->exception_table());
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // Mark objects referenced by klass objects which are read-only.
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 else if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 Klass* k = Klass::cast((klassOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 mark_object(k->secondary_supers());
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // The METHODS() OBJARRAYS CANNOT BE MADE READ-ONLY, even though
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // it is never modified. Otherwise, they will be pre-marked; the
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // GC marking phase will skip them; and by skipping them will fail
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // to mark the methods objects referenced by the array.
a61af66fc99e Initial load
duke
parents:
diff changeset
257
a61af66fc99e Initial load
duke
parents:
diff changeset
258 if (obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 mark_object(ik->method_ordering());
a61af66fc99e Initial load
duke
parents:
diff changeset
261 mark_object(ik->local_interfaces());
a61af66fc99e Initial load
duke
parents:
diff changeset
262 mark_object(ik->transitive_interfaces());
a61af66fc99e Initial load
duke
parents:
diff changeset
263 mark_object(ik->fields());
a61af66fc99e Initial load
duke
parents:
diff changeset
264
a61af66fc99e Initial load
duke
parents:
diff changeset
265 mark_object(ik->class_annotations());
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 mark_object_recursive_skipping_klasses(ik->fields_annotations());
a61af66fc99e Initial load
duke
parents:
diff changeset
268 mark_object_recursive_skipping_klasses(ik->methods_annotations());
a61af66fc99e Initial load
duke
parents:
diff changeset
269 mark_object_recursive_skipping_klasses(ik->methods_parameter_annotations());
a61af66fc99e Initial load
duke
parents:
diff changeset
270 mark_object_recursive_skipping_klasses(ik->methods_default_annotations());
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 typeArrayOop inner_classes = ik->inner_classes();
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (inner_classes != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 mark_object(inner_classes);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 };
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
282 // Closure: find symbol references in Java Heap objects
0
a61af66fc99e Initial load
duke
parents:
diff changeset
283
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
284 class CommonSymbolsClosure : public ObjectClosure {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
285 private:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
286 SymbolClosure* _closure;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
287 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
288 CommonSymbolsClosure(SymbolClosure* closure) : _closure(closure) { }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
289
0
a61af66fc99e Initial load
duke
parents:
diff changeset
290 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
292 // Traverse symbols referenced by method objects.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 if (obj->is_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 methodOop m = methodOop(obj);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
296 constantPoolOop constants = m->constants();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
297 _closure->do_symbol(constants->symbol_at_addr(m->name_index()));
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
298 _closure->do_symbol(constants->symbol_at_addr(m->signature_index()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
301 // Traverse symbols referenced by klass objects which are read-only.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
302
a61af66fc99e Initial load
duke
parents:
diff changeset
303 else if (obj->is_klass()) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
304 Klass* k = Klass::cast((klassOop)obj);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
305 k->shared_symbols_iterate(_closure);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
309 typeArrayOop inner_classes = ik->inner_classes();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (inner_classes != NULL) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
311 constantPoolOop constants = ik->constants();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
312 int n = inner_classes->length();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
313 for (int i = 0; i < n; i += instanceKlass::inner_class_next_offset) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
314 int ioff = i + instanceKlass::inner_class_inner_name_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 int index = inner_classes->ushort_at(ioff);
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (index != 0) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
317 _closure->do_symbol(constants->symbol_at_addr(index));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
324 // Traverse symbols referenced by other constantpool entries.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
325
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
326 else if (obj->is_constantPool()) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
327 constantPoolOop(obj)->shared_symbols_iterate(_closure);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 };
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // Closure: mark char arrays used by strings
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 class MarkStringValues : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
337 MarkObjectsOopClosure mark_all;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
339 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // Character arrays referenced by String objects are read-only.
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (java_lang_String::is_instance(obj)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 mark_object(java_lang_String::value(obj));
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
347 };
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 #ifdef DEBUG
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Closure: Check for objects left in the heap which have not been moved.
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 class CheckRemainingObjects : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
355 int count;
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
358 CheckRemainingObjects() {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 if (!obj->is_shared() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
364 !obj->is_forwarded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 ++count;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (Verbose) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 tty->print("Unreferenced object: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
368 obj->print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 void status() {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 tty->print_cr("%d objects no longer referenced, not shared.", count);
a61af66fc99e Initial load
duke
parents:
diff changeset
375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
376 };
a61af66fc99e Initial load
duke
parents:
diff changeset
377 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // Closure: Mark remaining objects read-write, except Strings.
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 class MarkReadWriteObjects : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
384 MarkObjectsOopClosure mark_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
385 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
386 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // The METHODS() OBJARRAYS CANNOT BE MADE READ-ONLY, even though
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // it is never modified. Otherwise, they will be pre-marked; the
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // GC marking phase will skip them; and by skipping them will fail
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // to mark the methods objects referenced by the array.
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
394 mark_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
395 Klass* k = klassOop(obj)->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
396 mark_object(k->java_mirror());
a61af66fc99e Initial load
duke
parents:
diff changeset
397 if (obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 instanceKlass* ik = (instanceKlass*)k;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 mark_object(ik->methods());
a61af66fc99e Initial load
duke
parents:
diff changeset
400 mark_object(ik->constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 if (obj->blueprint()->oop_is_javaArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
403 arrayKlass* ak = (arrayKlass*)k;
a61af66fc99e Initial load
duke
parents:
diff changeset
404 mark_object(ak->component_mirror());
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // Mark constantPool tags and the constantPoolCache.
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 else if (obj->is_constantPool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 constantPoolOop pool = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
413 mark_object(pool->cache());
a61af66fc99e Initial load
duke
parents:
diff changeset
414 pool->shared_tags_iterate(&mark_objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // Mark all method objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 if (obj->is_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
421 mark_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424 };
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // Closure: Mark String objects read-write.
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 class MarkStringObjects : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
431 MarkObjectsOopClosure mark_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
433 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
434
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // Mark String objects referenced by constant pool entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if (obj->is_constantPool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 constantPoolOop pool = constantPoolOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 pool->shared_strings_iterate(&mark_objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443 };
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // Move objects matching specified type (ie. lock_bits) to the specified
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // space.
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 class MoveMarkedObjects : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
451 OffsetTableContigSpace* _space;
a61af66fc99e Initial load
duke
parents:
diff changeset
452 bool _read_only;
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
455 MoveMarkedObjects(OffsetTableContigSpace* space, bool read_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
456 _space = space;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 _read_only = read_only;
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 if (obj->is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
464 if (obj->is_gc_marked() && obj->forwardee() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
465 int s = obj->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 oop sh_obj = (oop)_space->allocate(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
467 if (sh_obj == NULL) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
468 report_out_of_shared_space(_read_only ? SharedReadOnly : SharedReadWrite);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
469 }
a61af66fc99e Initial load
duke
parents:
diff changeset
470 if (PrintSharedSpaces && Verbose && WizardMode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
471 tty->print_cr("\nMoveMarkedObjects: " PTR_FORMAT " -> " PTR_FORMAT " %s", obj, sh_obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
472 (_read_only ? "ro" : "rw"));
a61af66fc99e Initial load
duke
parents:
diff changeset
473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
474 Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)sh_obj, s);
a61af66fc99e Initial load
duke
parents:
diff changeset
475 obj->forward_to(sh_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
476 if (_read_only) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // Readonly objects: set hash value to self pointer and make gc_marked.
a61af66fc99e Initial load
duke
parents:
diff changeset
478 sh_obj->forward_to(sh_obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
480 sh_obj->init_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484 };
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 static void mark_and_move(oop obj, MoveMarkedObjects* move) {
a61af66fc99e Initial load
duke
parents:
diff changeset
487 if (mark_object(obj)) move->do_object(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 enum order_policy {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 OP_favor_startup = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
492 OP_balanced = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
493 OP_favor_runtime = 2
a61af66fc99e Initial load
duke
parents:
diff changeset
494 };
a61af66fc99e Initial load
duke
parents:
diff changeset
495
a61af66fc99e Initial load
duke
parents:
diff changeset
496 static void mark_and_move_for_policy(order_policy policy, oop obj, MoveMarkedObjects* move) {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 if (SharedOptimizeColdStartPolicy >= policy) mark_and_move(obj, move);
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499
a61af66fc99e Initial load
duke
parents:
diff changeset
500 class MarkAndMoveOrderedReadOnly : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
501 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
502 MoveMarkedObjects *_move_ro;
a61af66fc99e Initial load
duke
parents:
diff changeset
503
a61af66fc99e Initial load
duke
parents:
diff changeset
504 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
505 MarkAndMoveOrderedReadOnly(MoveMarkedObjects *move_ro) : _move_ro(move_ro) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
508 if (obj->is_klass() && obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
509 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 if (ik->super() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 do_object(ik->super());
a61af66fc99e Initial load
duke
parents:
diff changeset
514 }
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 objArrayOop interfaces = ik->local_interfaces();
a61af66fc99e Initial load
duke
parents:
diff changeset
517 mark_and_move_for_policy(OP_favor_startup, interfaces, _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
518 for(i = 0; i < interfaces->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 klassOop k = klassOop(interfaces->obj_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
520 do_object(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523 objArrayOop methods = ik->methods();
a61af66fc99e Initial load
duke
parents:
diff changeset
524 for(i = 0; i < methods->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
525 methodOop m = methodOop(methods->obj_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
526 mark_and_move_for_policy(OP_favor_startup, m->constMethod(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
527 mark_and_move_for_policy(OP_favor_runtime, m->constMethod()->exception_table(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
528 mark_and_move_for_policy(OP_favor_runtime, m->constMethod()->stackmap_data(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 mark_and_move_for_policy(OP_favor_startup, ik->transitive_interfaces(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
532 mark_and_move_for_policy(OP_favor_startup, ik->fields(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
533
a61af66fc99e Initial load
duke
parents:
diff changeset
534 mark_and_move_for_policy(OP_favor_runtime, ik->secondary_supers(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
535 mark_and_move_for_policy(OP_favor_runtime, ik->method_ordering(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 mark_and_move_for_policy(OP_favor_runtime, ik->class_annotations(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
537 mark_and_move_for_policy(OP_favor_runtime, ik->fields_annotations(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
538 mark_and_move_for_policy(OP_favor_runtime, ik->methods_annotations(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
539 mark_and_move_for_policy(OP_favor_runtime, ik->methods_parameter_annotations(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
540 mark_and_move_for_policy(OP_favor_runtime, ik->methods_default_annotations(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
541 mark_and_move_for_policy(OP_favor_runtime, ik->inner_classes(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
542 mark_and_move_for_policy(OP_favor_runtime, ik->secondary_supers(), _move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 };
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547 class MarkAndMoveOrderedReadWrite: public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
548 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
549 MoveMarkedObjects *_move_rw;
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
552 MarkAndMoveOrderedReadWrite(MoveMarkedObjects *move_rw) : _move_rw(move_rw) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 if (obj->is_klass() && obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
557 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 mark_and_move_for_policy(OP_favor_startup, ik->as_klassOop(), _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 if (ik->super() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
562 do_object(ik->super());
a61af66fc99e Initial load
duke
parents:
diff changeset
563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 objArrayOop interfaces = ik->local_interfaces();
a61af66fc99e Initial load
duke
parents:
diff changeset
566 for(i = 0; i < interfaces->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 klassOop k = klassOop(interfaces->obj_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
568 mark_and_move_for_policy(OP_favor_startup, k, _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 do_object(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 objArrayOop methods = ik->methods();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 mark_and_move_for_policy(OP_favor_startup, methods, _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
574 for(i = 0; i < methods->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
575 methodOop m = methodOop(methods->obj_at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
576 mark_and_move_for_policy(OP_favor_startup, m, _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
577 mark_and_move_for_policy(OP_favor_startup, ik->constants(), _move_rw); // idempotent
a61af66fc99e Initial load
duke
parents:
diff changeset
578 mark_and_move_for_policy(OP_balanced, ik->constants()->cache(), _move_rw); // idempotent
a61af66fc99e Initial load
duke
parents:
diff changeset
579 mark_and_move_for_policy(OP_balanced, ik->constants()->tags(), _move_rw); // idempotent
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 mark_and_move_for_policy(OP_favor_startup, ik->as_klassOop()->klass(), _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 mark_and_move_for_policy(OP_favor_startup, ik->constants()->klass(), _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585 // Although Java mirrors are marked in MarkReadWriteObjects,
a61af66fc99e Initial load
duke
parents:
diff changeset
586 // apparently they were never moved into shared spaces since
a61af66fc99e Initial load
duke
parents:
diff changeset
587 // MoveMarkedObjects skips marked instance oops. This may
a61af66fc99e Initial load
duke
parents:
diff changeset
588 // be a bug in the original implementation or simply the vestige
a61af66fc99e Initial load
duke
parents:
diff changeset
589 // of an abandoned experiment. Nevertheless we leave a hint
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // here in case this capability is ever correctly implemented.
a61af66fc99e Initial load
duke
parents:
diff changeset
591 //
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // mark_and_move_for_policy(OP_favor_runtime, ik->java_mirror(), _move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
593 }
a61af66fc99e Initial load
duke
parents:
diff changeset
594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596 };
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 // Adjust references in oops to refer to shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 class ResolveForwardingClosure: public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
601 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
602 void do_oop(oop* p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
603 oop obj = *p;
a61af66fc99e Initial load
duke
parents:
diff changeset
604 if (!obj->is_shared()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 if (obj != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
606 oop f = obj->forwardee();
a61af66fc99e Initial load
duke
parents:
diff changeset
607 guarantee(f->is_shared(), "Oop doesn't refer to shared space.");
a61af66fc99e Initial load
duke
parents:
diff changeset
608 *p = f;
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610 }
a61af66fc99e Initial load
duke
parents:
diff changeset
611 }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
612 void do_oop(narrowOop* pobj) { ShouldNotReachHere(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
613 };
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
616 // The methods array must be reordered by Symbol* address.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
617 // (See classFileParser.cpp where methods in a class are originally
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
618 // sorted). The addresses of symbols have been changed as a result
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
619 // of moving to the shared space.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
620
a61af66fc99e Initial load
duke
parents:
diff changeset
621 class SortMethodsClosure: public ObjectClosure {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
622 public:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
623 void do_object(oop obj) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
624 if (obj->blueprint()->oop_is_instanceKlass()) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
625 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
626 methodOopDesc::sort_methods(ik->methods(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
627 ik->methods_annotations(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
628 ik->methods_parameter_annotations(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
629 ik->methods_default_annotations(),
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
630 true /* idempotent, slow */);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
631 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
632 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
633 };
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
634
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
635 // Itable indices are calculated based on methods array order
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
636 // (see klassItable::compute_itable_index()). Must reinitialize
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
637 // after ALL methods of ALL classes have been reordered.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
638 // We assume that since checkconstraints is false, this method
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
639 // cannot throw an exception. An exception here would be
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
640 // problematic since this is the VMThread, not a JavaThread.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
641
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
642 class ReinitializeItables: public ObjectClosure {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
643 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
644 Thread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
647 ReinitializeItables(Thread* thread) : _thread(thread) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
648
a61af66fc99e Initial load
duke
parents:
diff changeset
649 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
650 if (obj->blueprint()->oop_is_instanceKlass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 instanceKlass* ik = instanceKlass::cast((klassOop)obj);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
652 ik->itable()->initialize_itable(false, _thread);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
654 }
a61af66fc99e Initial load
duke
parents:
diff changeset
655 };
a61af66fc99e Initial load
duke
parents:
diff changeset
656
a61af66fc99e Initial load
duke
parents:
diff changeset
657
a61af66fc99e Initial load
duke
parents:
diff changeset
658 // Adjust references in oops to refer to shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
659
a61af66fc99e Initial load
duke
parents:
diff changeset
660 class PatchOopsClosure: public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
661 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
662 Thread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
663 ResolveForwardingClosure resolve;
a61af66fc99e Initial load
duke
parents:
diff changeset
664
a61af66fc99e Initial load
duke
parents:
diff changeset
665 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
666 PatchOopsClosure(Thread* thread) : _thread(thread) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
667
a61af66fc99e Initial load
duke
parents:
diff changeset
668 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
669 obj->oop_iterate_header(&resolve);
a61af66fc99e Initial load
duke
parents:
diff changeset
670 obj->oop_iterate(&resolve);
a61af66fc99e Initial load
duke
parents:
diff changeset
671
a61af66fc99e Initial load
duke
parents:
diff changeset
672 assert(obj->klass()->is_shared(), "Klass not pointing into shared space.");
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674 // If the object is a Java object or class which might (in the
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // future) contain a reference to a young gen object, add it to the
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // list.
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 if (obj->is_klass() || obj->is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
679 if (obj->is_klass() ||
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 714
diff changeset
680 obj->is_a(SystemDictionary::Class_klass()) ||
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 714
diff changeset
681 obj->is_a(SystemDictionary::Throwable_klass())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // Do nothing
a61af66fc99e Initial load
duke
parents:
diff changeset
683 }
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 714
diff changeset
684 else if (obj->is_a(SystemDictionary::String_klass())) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // immutable objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
686 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // someone added an object we hadn't accounted for.
a61af66fc99e Initial load
duke
parents:
diff changeset
688 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
690 }
a61af66fc99e Initial load
duke
parents:
diff changeset
691 }
a61af66fc99e Initial load
duke
parents:
diff changeset
692 };
a61af66fc99e Initial load
duke
parents:
diff changeset
693
a61af66fc99e Initial load
duke
parents:
diff changeset
694
a61af66fc99e Initial load
duke
parents:
diff changeset
695 // Empty the young and old generations.
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697 class ClearSpaceClosure : public SpaceClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
699 void do_space(Space* s) {
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
700 s->clear(SpaceDecorator::Mangle);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
701 }
a61af66fc99e Initial load
duke
parents:
diff changeset
702 };
a61af66fc99e Initial load
duke
parents:
diff changeset
703
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 // Closure for serializing initialization data out to a data area to be
a61af66fc99e Initial load
duke
parents:
diff changeset
706 // written to the shared file.
a61af66fc99e Initial load
duke
parents:
diff changeset
707
a61af66fc99e Initial load
duke
parents:
diff changeset
708 class WriteClosure : public SerializeOopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
709 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
710 oop* top;
a61af66fc99e Initial load
duke
parents:
diff changeset
711 char* end;
a61af66fc99e Initial load
duke
parents:
diff changeset
712
a61af66fc99e Initial load
duke
parents:
diff changeset
713 inline void check_space() {
a61af66fc99e Initial load
duke
parents:
diff changeset
714 if ((char*)top + sizeof(oop) > end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
715 report_out_of_shared_space(SharedMiscData);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
717 }
a61af66fc99e Initial load
duke
parents:
diff changeset
718
a61af66fc99e Initial load
duke
parents:
diff changeset
719
a61af66fc99e Initial load
duke
parents:
diff changeset
720 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
721 WriteClosure(char* md_top, char* md_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 top = (oop*)md_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
723 end = md_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
725
a61af66fc99e Initial load
duke
parents:
diff changeset
726 char* get_top() { return (char*)top; }
a61af66fc99e Initial load
duke
parents:
diff changeset
727
a61af66fc99e Initial load
duke
parents:
diff changeset
728 void do_oop(oop* p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
729 check_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
730 oop obj = *p;
a61af66fc99e Initial load
duke
parents:
diff changeset
731 assert(obj->is_oop_or_null(), "invalid oop");
a61af66fc99e Initial load
duke
parents:
diff changeset
732 assert(obj == NULL || obj->is_shared(),
a61af66fc99e Initial load
duke
parents:
diff changeset
733 "Oop in shared space not pointing into shared space.");
a61af66fc99e Initial load
duke
parents:
diff changeset
734 *top = obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
735 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
736 }
a61af66fc99e Initial load
duke
parents:
diff changeset
737
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
738 void do_oop(narrowOop* pobj) { ShouldNotReachHere(); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
739
0
a61af66fc99e Initial load
duke
parents:
diff changeset
740 void do_int(int* p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
741 check_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
742 *top = (oop)(intptr_t)*p;
a61af66fc99e Initial load
duke
parents:
diff changeset
743 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 void do_size_t(size_t* p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
747 check_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
748 *top = (oop)(intptr_t)*p;
a61af66fc99e Initial load
duke
parents:
diff changeset
749 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
750 }
a61af66fc99e Initial load
duke
parents:
diff changeset
751
a61af66fc99e Initial load
duke
parents:
diff changeset
752 void do_ptr(void** p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
753 check_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
754 *top = (oop)*p;
a61af66fc99e Initial load
duke
parents:
diff changeset
755 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
757
a61af66fc99e Initial load
duke
parents:
diff changeset
758 void do_ptr(HeapWord** p) { do_ptr((void **) p); }
a61af66fc99e Initial load
duke
parents:
diff changeset
759
a61af66fc99e Initial load
duke
parents:
diff changeset
760 void do_tag(int tag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
761 check_space();
a61af66fc99e Initial load
duke
parents:
diff changeset
762 *top = (oop)(intptr_t)tag;
a61af66fc99e Initial load
duke
parents:
diff changeset
763 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
765
a61af66fc99e Initial load
duke
parents:
diff changeset
766 void do_region(u_char* start, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
767 if ((char*)top + size > end) {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
768 report_out_of_shared_space(SharedMiscData);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
770 assert((intptr_t)start % sizeof(oop) == 0, "bad alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
771 assert(size % sizeof(oop) == 0, "bad size");
a61af66fc99e Initial load
duke
parents:
diff changeset
772 do_tag((int)size);
a61af66fc99e Initial load
duke
parents:
diff changeset
773 while (size > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
774 *top = *(oop*)start;
a61af66fc99e Initial load
duke
parents:
diff changeset
775 ++top;
a61af66fc99e Initial load
duke
parents:
diff changeset
776 start += sizeof(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
777 size -= sizeof(oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
778 }
a61af66fc99e Initial load
duke
parents:
diff changeset
779 }
a61af66fc99e Initial load
duke
parents:
diff changeset
780
a61af66fc99e Initial load
duke
parents:
diff changeset
781 bool reading() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
782 };
a61af66fc99e Initial load
duke
parents:
diff changeset
783
a61af66fc99e Initial load
duke
parents:
diff changeset
784
a61af66fc99e Initial load
duke
parents:
diff changeset
785 class ResolveConstantPoolsClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
786 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
787 TRAPS;
a61af66fc99e Initial load
duke
parents:
diff changeset
788 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
789 ResolveConstantPoolsClosure(Thread *t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
790 __the_thread__ = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
791 }
a61af66fc99e Initial load
duke
parents:
diff changeset
792 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
793 if (obj->is_constantPool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
794 constantPoolOop cpool = (constantPoolOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 int unresolved = cpool->pre_resolve_shared_klasses(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
796 }
a61af66fc99e Initial load
duke
parents:
diff changeset
797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
798 };
a61af66fc99e Initial load
duke
parents:
diff changeset
799
a61af66fc99e Initial load
duke
parents:
diff changeset
800
a61af66fc99e Initial load
duke
parents:
diff changeset
801 // Print a summary of the contents of the read/write spaces to help
a61af66fc99e Initial load
duke
parents:
diff changeset
802 // identify objects which might be able to be made read-only. At this
a61af66fc99e Initial load
duke
parents:
diff changeset
803 // point, the objects have been written, and we can trash them as
a61af66fc99e Initial load
duke
parents:
diff changeset
804 // needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 static void print_contents() {
a61af66fc99e Initial load
duke
parents:
diff changeset
807 if (PrintSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
808 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
809 CompactingPermGenGen* gen = (CompactingPermGenGen*)gch->perm_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 // High level summary of the read-only space:
a61af66fc99e Initial load
duke
parents:
diff changeset
812
a61af66fc99e Initial load
duke
parents:
diff changeset
813 ClassifyObjectClosure coc;
a61af66fc99e Initial load
duke
parents:
diff changeset
814 tty->cr(); tty->print_cr("ReadOnly space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
815 gen->ro_space()->object_iterate(&coc);
a61af66fc99e Initial load
duke
parents:
diff changeset
816 coc.print();
a61af66fc99e Initial load
duke
parents:
diff changeset
817
a61af66fc99e Initial load
duke
parents:
diff changeset
818 // High level summary of the read-write space:
a61af66fc99e Initial load
duke
parents:
diff changeset
819
a61af66fc99e Initial load
duke
parents:
diff changeset
820 coc.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
821 tty->cr(); tty->print_cr("ReadWrite space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
822 gen->rw_space()->object_iterate(&coc);
a61af66fc99e Initial load
duke
parents:
diff changeset
823 coc.print();
a61af66fc99e Initial load
duke
parents:
diff changeset
824
a61af66fc99e Initial load
duke
parents:
diff changeset
825 // Reset counters
a61af66fc99e Initial load
duke
parents:
diff changeset
826
a61af66fc99e Initial load
duke
parents:
diff changeset
827 ClearAllocCountClosure cacc;
a61af66fc99e Initial load
duke
parents:
diff changeset
828 gen->ro_space()->object_iterate(&cacc);
a61af66fc99e Initial load
duke
parents:
diff changeset
829 gen->rw_space()->object_iterate(&cacc);
a61af66fc99e Initial load
duke
parents:
diff changeset
830 coc.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 // Lower level summary of the read-only space:
a61af66fc99e Initial load
duke
parents:
diff changeset
833
a61af66fc99e Initial load
duke
parents:
diff changeset
834 gen->ro_space()->object_iterate(&coc);
a61af66fc99e Initial load
duke
parents:
diff changeset
835 tty->cr(); tty->print_cr("ReadOnly space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
836 ClassifyInstanceKlassClosure cikc;
a61af66fc99e Initial load
duke
parents:
diff changeset
837 gen->rw_space()->object_iterate(&cikc);
a61af66fc99e Initial load
duke
parents:
diff changeset
838 cikc.print();
a61af66fc99e Initial load
duke
parents:
diff changeset
839
a61af66fc99e Initial load
duke
parents:
diff changeset
840 // Reset counters
a61af66fc99e Initial load
duke
parents:
diff changeset
841
a61af66fc99e Initial load
duke
parents:
diff changeset
842 gen->ro_space()->object_iterate(&cacc);
a61af66fc99e Initial load
duke
parents:
diff changeset
843 gen->rw_space()->object_iterate(&cacc);
a61af66fc99e Initial load
duke
parents:
diff changeset
844 coc.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 // Lower level summary of the read-write space:
a61af66fc99e Initial load
duke
parents:
diff changeset
847
a61af66fc99e Initial load
duke
parents:
diff changeset
848 gen->rw_space()->object_iterate(&coc);
a61af66fc99e Initial load
duke
parents:
diff changeset
849 cikc.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
850 tty->cr(); tty->print_cr("ReadWrite space:");
a61af66fc99e Initial load
duke
parents:
diff changeset
851 gen->rw_space()->object_iterate(&cikc);
a61af66fc99e Initial load
duke
parents:
diff changeset
852 cikc.print();
a61af66fc99e Initial load
duke
parents:
diff changeset
853 }
a61af66fc99e Initial load
duke
parents:
diff changeset
854 }
a61af66fc99e Initial load
duke
parents:
diff changeset
855
a61af66fc99e Initial load
duke
parents:
diff changeset
856
a61af66fc99e Initial load
duke
parents:
diff changeset
857 // Patch C++ vtable pointer in klass oops.
a61af66fc99e Initial load
duke
parents:
diff changeset
858
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // Klass objects contain references to c++ vtables in the JVM library.
a61af66fc99e Initial load
duke
parents:
diff changeset
860 // Fix them to point to our constructed vtables. However, don't iterate
a61af66fc99e Initial load
duke
parents:
diff changeset
861 // across the space while doing this, as that causes the vtables to be
a61af66fc99e Initial load
duke
parents:
diff changeset
862 // patched, undoing our useful work. Instead, iterate to make a list,
a61af66fc99e Initial load
duke
parents:
diff changeset
863 // then use the list to do the fixing.
408
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
864 //
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
865 // Our constructed vtables:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
866 // Dump time:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
867 // 1. init_self_patching_vtbl_list: table of pointers to current virtual method addrs
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
868 // 2. generate_vtable_methods: create jump table, appended to above vtbl_list
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
869 // 3. PatchKlassVtables: for Klass list, patch the vtable entry to point to jump table
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
870 // rather than to current vtbl
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
871 // Table layout: NOTE FIXED SIZE
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
872 // 1. vtbl pointers
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
873 // 2. #Klass X #virtual methods per Klass
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
874 // 1 entry for each, in the order:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
875 // Klass1:method1 entry, Klass1:method2 entry, ... Klass1:method<num_virtuals> entry
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
876 // Klass2:method1 entry, Klass2:method2 entry, ... Klass2:method<num_virtuals> entry
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
877 // ...
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
878 // Klass<vtbl_list_size>:method1 entry, Klass<vtbl_list_size>:method2 entry,
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
879 // ... Klass<vtbl_list_size>:method<num_virtuals> entry
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
880 // Sample entry: (Sparc):
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
881 // save(sp, -256, sp)
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
882 // ba,pt common_code
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
883 // mov XXX, %L0 %L0 gets: Klass index <<8 + method index (note: max method index 255)
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
884 //
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
885 // Restore time:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
886 // 1. initialize_oops: reserve space for table
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
887 // 2. init_self_patching_vtbl_list: update pointers to NEW virtual method addrs in text
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
888 //
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
889 // Execution time:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
890 // First virtual method call for any object of these Klass types:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
891 // 1. object->klass->klass_part
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
892 // 2. vtable entry for that klass_part points to the jump table entries
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
893 // 3. branches to common_code with %O0/klass_part, %L0: Klass index <<8 + method index
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
894 // 4. common_code:
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
895 // Get address of new vtbl pointer for this Klass from updated table
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
896 // Update new vtbl pointer in the Klass: future virtual calls go direct
52e32c8b317e 6761092: jvm crashes when CDS is enabled.
acorn
parents: 288
diff changeset
897 // Jump to method, using new vtbl pointer and method index
0
a61af66fc99e Initial load
duke
parents:
diff changeset
898
a61af66fc99e Initial load
duke
parents:
diff changeset
899 class PatchKlassVtables: public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
900 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
901 GrowableArray<klassOop>* _klass_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
902
a61af66fc99e Initial load
duke
parents:
diff changeset
903 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
904 PatchKlassVtables() {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
905 _klass_objects = new GrowableArray<klassOop>();
a61af66fc99e Initial load
duke
parents:
diff changeset
906 }
a61af66fc99e Initial load
duke
parents:
diff changeset
907
a61af66fc99e Initial load
duke
parents:
diff changeset
908 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
909 if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
910 _klass_objects->append(klassOop(obj));
a61af66fc99e Initial load
duke
parents:
diff changeset
911 }
a61af66fc99e Initial load
duke
parents:
diff changeset
912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
913
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
914 void patch(void** vtbl_list, void* new_vtable_start) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
915 int n = _klass_objects->length();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
916 for (int i = 0; i < n; i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
917 klassOop obj = (klassOop)_klass_objects->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
918 Klass* k = obj->klass_part();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
919 *(void**)k = CompactingPermGenGen::find_matching_vtbl_ptr(
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
920 vtbl_list, new_vtable_start, k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
922 }
a61af66fc99e Initial load
duke
parents:
diff changeset
923 };
a61af66fc99e Initial load
duke
parents:
diff changeset
924
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
925 // Walk through all symbols and patch their vtable pointers.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
926 // Note that symbols have vtable pointers only in non-product builds
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
927 // (see allocation.hpp).
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
928
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
929 #ifndef PRODUCT
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
930 class PatchSymbolVtables: public SymbolClosure {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
931 private:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
932 void* _new_vtbl_ptr;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
933
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
934 public:
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
935 PatchSymbolVtables(void** vtbl_list, void* new_vtable_start) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
936 Symbol s;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
937 _new_vtbl_ptr = CompactingPermGenGen::find_matching_vtbl_ptr(
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
938 vtbl_list, new_vtable_start, &s);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
939 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
940
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
941 void do_symbol(Symbol** p) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
942 Symbol* sym = load_symbol(p);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
943 *(void**)sym = _new_vtbl_ptr;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
944 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
945 };
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
946 #endif
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
947
0
a61af66fc99e Initial load
duke
parents:
diff changeset
948
a61af66fc99e Initial load
duke
parents:
diff changeset
949 // Populate the shared space.
a61af66fc99e Initial load
duke
parents:
diff changeset
950
a61af66fc99e Initial load
duke
parents:
diff changeset
951 class VM_PopulateDumpSharedSpace: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
952 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
953 GrowableArray<oop> *_class_promote_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
954 OffsetTableContigSpace* _ro_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
955 OffsetTableContigSpace* _rw_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
956 VirtualSpace* _md_vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
957 VirtualSpace* _mc_vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
958
a61af66fc99e Initial load
duke
parents:
diff changeset
959 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
960 VM_PopulateDumpSharedSpace(GrowableArray<oop> *class_promote_order,
a61af66fc99e Initial load
duke
parents:
diff changeset
961 OffsetTableContigSpace* ro_space,
a61af66fc99e Initial load
duke
parents:
diff changeset
962 OffsetTableContigSpace* rw_space,
a61af66fc99e Initial load
duke
parents:
diff changeset
963 VirtualSpace* md_vs, VirtualSpace* mc_vs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
964 _class_promote_order = class_promote_order;
a61af66fc99e Initial load
duke
parents:
diff changeset
965 _ro_space = ro_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
966 _rw_space = rw_space;
a61af66fc99e Initial load
duke
parents:
diff changeset
967 _md_vs = md_vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
968 _mc_vs = mc_vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
969 }
a61af66fc99e Initial load
duke
parents:
diff changeset
970
a61af66fc99e Initial load
duke
parents:
diff changeset
971 VMOp_Type type() const { return VMOp_PopulateDumpSharedSpace; }
a61af66fc99e Initial load
duke
parents:
diff changeset
972 void doit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
973 Thread* THREAD = VMThread::vm_thread();
a61af66fc99e Initial load
duke
parents:
diff changeset
974 NOT_PRODUCT(SystemDictionary::verify();)
a61af66fc99e Initial load
duke
parents:
diff changeset
975 // The following guarantee is meant to ensure that no loader constraints
a61af66fc99e Initial load
duke
parents:
diff changeset
976 // exist yet, since the constraints table is not shared. This becomes
a61af66fc99e Initial load
duke
parents:
diff changeset
977 // more important now that we don't re-initialize vtables/itables for
a61af66fc99e Initial load
duke
parents:
diff changeset
978 // shared classes at runtime, where constraints were previously created.
a61af66fc99e Initial load
duke
parents:
diff changeset
979 guarantee(SystemDictionary::constraints()->number_of_entries() == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
980 "loader constraints are not saved");
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 408
diff changeset
981 // Revisit and implement this if we prelink method handle call sites:
714
981375ca07b7 6831604: missing null check in guarantee
never
parents: 710
diff changeset
982 guarantee(SystemDictionary::invoke_method_table() == NULL ||
981375ca07b7 6831604: missing null check in guarantee
never
parents: 710
diff changeset
983 SystemDictionary::invoke_method_table()->number_of_entries() == 0,
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents: 408
diff changeset
984 "invoke method table is not saved");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
985 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
986
a61af66fc99e Initial load
duke
parents:
diff changeset
987 // At this point, many classes have been loaded.
a61af66fc99e Initial load
duke
parents:
diff changeset
988
a61af66fc99e Initial load
duke
parents:
diff changeset
989 // Update all the fingerprints in the shared methods.
a61af66fc99e Initial load
duke
parents:
diff changeset
990
a61af66fc99e Initial load
duke
parents:
diff changeset
991 tty->print("Calculating fingerprints ... ");
a61af66fc99e Initial load
duke
parents:
diff changeset
992 FingerprintMethodsClosure fpmc;
a61af66fc99e Initial load
duke
parents:
diff changeset
993 gch->object_iterate(&fpmc);
a61af66fc99e Initial load
duke
parents:
diff changeset
994 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
995
a61af66fc99e Initial load
duke
parents:
diff changeset
996 // Remove all references outside the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
997
a61af66fc99e Initial load
duke
parents:
diff changeset
998 tty->print("Removing unshareable information ... ");
a61af66fc99e Initial load
duke
parents:
diff changeset
999 RemoveUnshareableInfoClosure ruic;
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 gch->object_iterate(&ruic);
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1002
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 // Move the objects in three passes.
a61af66fc99e Initial load
duke
parents:
diff changeset
1004
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 MarkObjectsOopClosure mark_all;
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 MarkCommonReadOnly mark_common_ro;
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 MarkStringValues mark_string_values;
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 MarkReadWriteObjects mark_rw;
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 MarkStringObjects mark_strings;
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 MoveMarkedObjects move_ro(_ro_space, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 MoveMarkedObjects move_rw(_rw_space, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1012
a61af66fc99e Initial load
duke
parents:
diff changeset
1013 // The SharedOptimizeColdStart VM option governs the new layout
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 // algorithm for promoting classes into the shared archive.
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 // The general idea is to minimize cold start time by laying
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 // out the objects in the order they are accessed at startup time.
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 // By doing this we are trying to eliminate out-of-order accesses
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 // in the shared archive. This benefits cold startup time by making
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 // disk reads as sequential as possible during class loading and
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 // bootstrapping activities. There may also be a small secondary
a61af66fc99e Initial load
duke
parents:
diff changeset
1021 // effect of better "packing" of more commonly used data on a smaller
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 // number of pages, although no direct benefit has been measured from
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 // this effect.
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 // At the class level of granularity, the promotion order is dictated
a61af66fc99e Initial load
duke
parents:
diff changeset
1026 // by the classlist file whose generation is discussed elsewhere.
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 // At smaller granularity, optimal ordering was determined by an
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 // offline analysis of object access order in the shared archive.
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 // The dbx watchpoint facility, combined with SA post-processing,
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 // was used to observe common access patterns primarily during
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 // classloading. This information was used to craft the promotion
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 // order seen in the following closures.
a61af66fc99e Initial load
duke
parents:
diff changeset
1034 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 // The observed access order is mostly governed by what happens
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 // in SystemDictionary::load_shared_class(). NOTE WELL - care
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 // should be taken when making changes to this method, because it
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 // may invalidate assumptions made about access order!
a61af66fc99e Initial load
duke
parents:
diff changeset
1039 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 // (Ideally, there would be a better way to manage changes to
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 // the access order. Unfortunately a generic in-VM solution for
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 // dynamically observing access order and optimizing shared
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 // archive layout is pretty difficult. We go with the static
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 // analysis because the code is fairly mature at this point
a61af66fc99e Initial load
duke
parents:
diff changeset
1045 // and we're betting that the access order won't change much.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1046
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 MarkAndMoveOrderedReadOnly mark_and_move_ordered_ro(&move_ro);
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 MarkAndMoveOrderedReadWrite mark_and_move_ordered_rw(&move_rw);
a61af66fc99e Initial load
duke
parents:
diff changeset
1049
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 // Set up the share data and shared code segments.
a61af66fc99e Initial load
duke
parents:
diff changeset
1051
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 char* md_top = _md_vs->low();
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 char* md_end = _md_vs->high();
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 char* mc_top = _mc_vs->low();
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 char* mc_end = _mc_vs->high();
a61af66fc99e Initial load
duke
parents:
diff changeset
1056
a61af66fc99e Initial load
duke
parents:
diff changeset
1057 // Reserve space for the list of klassOops whose vtables are used
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 // for patching others as needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
1059
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 void** vtbl_list = (void**)md_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 int vtbl_list_size = CompactingPermGenGen::vtbl_list_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 Universe::init_self_patching_vtbl_list(vtbl_list, vtbl_list_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 md_top += vtbl_list_size * sizeof(void*);
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 void* vtable = md_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 // Reserve space for a new dummy vtable for klass objects in the
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 // heap. Generate self-patching vtable entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
1069
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 CompactingPermGenGen::generate_vtable_methods(vtbl_list,
a61af66fc99e Initial load
duke
parents:
diff changeset
1071 &vtable,
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 &md_top, md_end,
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 &mc_top, mc_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1074
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1075 // Reserve space for the total size and the number of stored symbols.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1076
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1077 md_top += sizeof(intptr_t) * 2;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1078
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1079 MoveSymbols move_symbols(md_top, md_end);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1080 CommonSymbolsClosure traverse_common_symbols(&move_symbols);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1081
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1082 // Phase 1a: remove symbols with _refcount == 0
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1083
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1084 SymbolTable::unlink();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1085
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1086 // Phase 1b: move commonly used symbols referenced by oop fields.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1087
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1088 tty->print("Moving common symbols to metadata section at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1089 move_symbols.get_top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1090 gch->object_iterate(&traverse_common_symbols);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1091 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1092
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1093 // Phase 1c: move known names and signatures.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1094
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1095 tty->print("Moving vmSymbols to metadata section at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1096 move_symbols.get_top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1097 vmSymbols::symbols_do(&move_symbols);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1098 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1099
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1100 // Phase 1d: move the remaining symbols by scanning the whole SymbolTable.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1101
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1102 void* extra_symbols = move_symbols.get_top();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1103 tty->print("Moving the remaining symbols to metadata section at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1104 move_symbols.get_top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1105 SymbolTable::symbols_do(&move_symbols);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1106 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1107
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1108 // Record the total length of all symbols at the beginning of the block.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1109 ((intptr_t*)md_top)[-2] = move_symbols.get_top() - md_top;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1110 ((intptr_t*)md_top)[-1] = move_symbols.count();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1111 tty->print_cr("Moved %d symbols, %d bytes.",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1112 move_symbols.count(), move_symbols.get_top() - md_top);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1113 // Advance the pointer to the end of symbol store.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1114 md_top = move_symbols.get_top();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1115
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1116
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1117 // Phase 2: move commonly used read-only objects to the read-only space.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1118
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1119 if (SharedOptimizeColdStart) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1120 tty->print("Moving pre-ordered read-only objects to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1121 _ro_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1122 for (int i = 0; i < _class_promote_order->length(); i++) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1123 oop obj = _class_promote_order->at(i);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1124 mark_and_move_ordered_ro.do_object(obj);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1125 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1126 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1127 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1128
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1129 tty->print("Moving read-only objects to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1130 _ro_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1131 gch->object_iterate(&mark_common_ro);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1132 gch->object_iterate(&move_ro);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1133 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1134
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1135 // Phase 3: move String character arrays to the read-only space.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1136
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1137 tty->print("Moving string char arrays to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1138 _ro_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1139 gch->object_iterate(&mark_string_values);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1140 gch->object_iterate(&move_ro);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1141 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1142
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1143 // Phase 4: move read-write objects to the read-write space, except
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1144 // Strings.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1145
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1146 if (SharedOptimizeColdStart) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1147 tty->print("Moving pre-ordered read-write objects to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1148 _rw_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1149 for (int i = 0; i < _class_promote_order->length(); i++) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1150 oop obj = _class_promote_order->at(i);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1151 mark_and_move_ordered_rw.do_object(obj);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1152 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1153 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1154 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1155 tty->print("Moving read-write objects to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1156 _rw_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1157 Universe::oops_do(&mark_all, true);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1158 SystemDictionary::oops_do(&mark_all);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1159 oop tmp = Universe::arithmetic_exception_instance();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1160 mark_object(java_lang_Throwable::message(tmp));
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1161 gch->object_iterate(&mark_rw);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1162 gch->object_iterate(&move_rw);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1163 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1164
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1165 // Phase 5: move String objects to the read-write space.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1166
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1167 tty->print("Moving String objects to shared space at " PTR_FORMAT " ... ",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1168 _rw_space->top());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1169 StringTable::oops_do(&mark_all);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1170 gch->object_iterate(&mark_strings);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1171 gch->object_iterate(&move_rw);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1172 tty->print_cr("done. ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1173 tty->print_cr("Read-write space ends at " PTR_FORMAT ", %d bytes.",
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1174 _rw_space->top(), _rw_space->used());
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1175
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1176 #ifdef DEBUG
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1177 // Check: scan for objects which were not moved.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1178
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1179 CheckRemainingObjects check_objects;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1180 gch->object_iterate(&check_objects);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1181 check_objects.status();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1182 #endif
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1183
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1184 // Resolve forwarding in objects and saved C++ structures
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1185 tty->print("Updating references to shared objects ... ");
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1186 ResolveForwardingClosure resolve;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1187 Universe::oops_do(&resolve);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1188 SystemDictionary::oops_do(&resolve);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1189 StringTable::oops_do(&resolve);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1190
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 // Fix (forward) all of the references in these shared objects (which
a61af66fc99e Initial load
duke
parents:
diff changeset
1192 // are required to point ONLY to objects in the shared spaces).
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 // Also, create a list of all objects which might later contain a
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 // reference to a younger generation object.
a61af66fc99e Initial load
duke
parents:
diff changeset
1195
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 CompactingPermGenGen* gen = (CompactingPermGenGen*)gch->perm_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 PatchOopsClosure patch(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 gen->ro_space()->object_iterate(&patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 gen->rw_space()->object_iterate(&patch);
a61af66fc99e Initial load
duke
parents:
diff changeset
1200
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 // Previously method sorting was done concurrently with forwarding
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 // pointer resolution in the shared spaces. This imposed an ordering
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 // restriction in that methods were required to be promoted/patched
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 // before their holder classes. (Because constant pool pointers in
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 // methodKlasses are required to be resolved before their holder class
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 // is visited for sorting, otherwise methods are sorted by incorrect,
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 // pre-forwarding addresses.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1208 //
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 // Now, we reorder methods as a separate step after ALL forwarding
a61af66fc99e Initial load
duke
parents:
diff changeset
1210 // pointer resolution, so that methods can be promoted in any order
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 // with respect to their holder classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
1212
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1213 SortMethodsClosure sort;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1214 gen->ro_space()->object_iterate(&sort);
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 gen->rw_space()->object_iterate(&sort);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1216
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1217 ReinitializeItables reinit_itables(THREAD);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1218 gen->ro_space()->object_iterate(&reinit_itables);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1219 gen->rw_space()->object_iterate(&reinit_itables);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1222
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 // Reorder the system dictionary. (Moving the symbols opps affects
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 // how the hash table indices are calculated.)
a61af66fc99e Initial load
duke
parents:
diff changeset
1225
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 SystemDictionary::reorder_dictionary();
a61af66fc99e Initial load
duke
parents:
diff changeset
1227
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 // Empty the non-shared heap (because most of the objects were
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 // copied out, and the remainder cannot be considered valid oops).
a61af66fc99e Initial load
duke
parents:
diff changeset
1230
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 ClearSpaceClosure csc;
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 for (int i = 0; i < gch->n_gens(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1233 gch->get_gen(i)->space_iterate(&csc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 csc.do_space(gen->the_space());
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 NOT_PRODUCT(SystemDictionary::verify();)
a61af66fc99e Initial load
duke
parents:
diff changeset
1237
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 // Copy the String table, the symbol table, and the system
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 // dictionary to the shared space in usable form. Copy the hastable
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 // buckets first [read-write], then copy the linked lists of entries
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 // [read-only].
a61af66fc99e Initial load
duke
parents:
diff changeset
1242
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 SymbolTable::reverse(extra_symbols);
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 NOT_PRODUCT(SymbolTable::verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 SymbolTable::copy_buckets(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1246
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 StringTable::reverse();
a61af66fc99e Initial load
duke
parents:
diff changeset
1248 NOT_PRODUCT(StringTable::verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 StringTable::copy_buckets(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1250
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 SystemDictionary::reverse();
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 SystemDictionary::copy_buckets(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1253
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 ClassLoader::verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 ClassLoader::copy_package_info_buckets(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 ClassLoader::verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
1257
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 SymbolTable::copy_table(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 StringTable::copy_table(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1260 SystemDictionary::copy_table(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 ClassLoader::verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 ClassLoader::copy_package_info_table(&md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 ClassLoader::verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
1264
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 // Print debug data.
a61af66fc99e Initial load
duke
parents:
diff changeset
1266
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 if (PrintSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 const char* fmt = "%s space: " PTR_FORMAT " out of " PTR_FORMAT " bytes allocated at " PTR_FORMAT ".";
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 tty->print_cr(fmt, "ro", _ro_space->used(), _ro_space->capacity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1270 _ro_space->bottom());
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 tty->print_cr(fmt, "rw", _rw_space->used(), _rw_space->capacity(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 _rw_space->bottom());
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1274
a61af66fc99e Initial load
duke
parents:
diff changeset
1275 // Write the oop data to the output array.
a61af66fc99e Initial load
duke
parents:
diff changeset
1276
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 WriteClosure wc(md_top, md_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
1278 CompactingPermGenGen::serialize_oops(&wc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 md_top = wc.get_top();
a61af66fc99e Initial load
duke
parents:
diff changeset
1280
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 // Update the vtable pointers in all of the Klass objects in the
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 // heap. They should point to newly generated vtable.
a61af66fc99e Initial load
duke
parents:
diff changeset
1283
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1284 PatchKlassVtables pkvt;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 _rw_space->object_iterate(&pkvt);
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1286 pkvt.patch(vtbl_list, vtable);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1287
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1288 #ifndef PRODUCT
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1289 // Update the vtable pointers in all symbols,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1290 // but only in non-product builds where symbols DO have virtual methods.
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1291 PatchSymbolVtables psvt(vtbl_list, vtable);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1292 SymbolTable::symbols_do(&psvt);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1293 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1294
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 char* saved_vtbl = (char*)malloc(vtbl_list_size * sizeof(void*));
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 memmove(saved_vtbl, vtbl_list, vtbl_list_size * sizeof(void*));
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 memset(vtbl_list, 0, vtbl_list_size * sizeof(void*));
a61af66fc99e Initial load
duke
parents:
diff changeset
1298
a61af66fc99e Initial load
duke
parents:
diff changeset
1299 // Create and write the archive file that maps the shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
1300
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 FileMapInfo* mapinfo = new FileMapInfo();
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 mapinfo->populate_header(gch->gen_policy()->max_alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
1303
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 // Pass 1 - update file offsets in header.
a61af66fc99e Initial load
duke
parents:
diff changeset
1305 mapinfo->write_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 mapinfo->write_space(CompactingPermGenGen::ro, _ro_space, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 _ro_space->set_saved_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 mapinfo->write_space(CompactingPermGenGen::rw, _rw_space, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 _rw_space->set_saved_mark();
a61af66fc99e Initial load
duke
parents:
diff changeset
1310 mapinfo->write_region(CompactingPermGenGen::md, _md_vs->low(),
287
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1311 pointer_delta(md_top, _md_vs->low(), sizeof(char)),
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1312 SharedMiscDataSize,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 false, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 mapinfo->write_region(CompactingPermGenGen::mc, _mc_vs->low(),
287
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1315 pointer_delta(mc_top, _mc_vs->low(), sizeof(char)),
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1316 SharedMiscCodeSize,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1318
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 // Pass 2 - write data.
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 mapinfo->open_for_write();
a61af66fc99e Initial load
duke
parents:
diff changeset
1321 mapinfo->write_header();
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 mapinfo->write_space(CompactingPermGenGen::ro, _ro_space, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 mapinfo->write_space(CompactingPermGenGen::rw, _rw_space, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 mapinfo->write_region(CompactingPermGenGen::md, _md_vs->low(),
287
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1325 pointer_delta(md_top, _md_vs->low(), sizeof(char)),
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1326 SharedMiscDataSize,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 false, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 mapinfo->write_region(CompactingPermGenGen::mc, _mc_vs->low(),
287
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1329 pointer_delta(mc_top, _mc_vs->low(), sizeof(char)),
6e76352f1f62 6459085: naked pointer subtractions in class data sharing code
xlu
parents: 196
diff changeset
1330 SharedMiscCodeSize,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 mapinfo->close();
a61af66fc99e Initial load
duke
parents:
diff changeset
1333
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 // Summarize heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 memmove(vtbl_list, saved_vtbl, vtbl_list_size * sizeof(void*));
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 print_contents();
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 }; // class VM_PopulateDumpSharedSpace
a61af66fc99e Initial load
duke
parents:
diff changeset
1339
a61af66fc99e Initial load
duke
parents:
diff changeset
1340
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 // Populate the shared spaces and dump to a file.
a61af66fc99e Initial load
duke
parents:
diff changeset
1342
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 jint CompactingPermGenGen::dump_shared(GrowableArray<oop>* class_promote_order, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1345
a61af66fc99e Initial load
duke
parents:
diff changeset
1346 // Calculate hash values for all of the (interned) strings to avoid
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 // writes to shared pages in the future.
a61af66fc99e Initial load
duke
parents:
diff changeset
1348
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 tty->print("Calculating hash values for String objects .. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 StringHashCodeClosure shcc(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1351 StringTable::oops_do(&shcc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1353
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 CompactingPermGenGen* gen = (CompactingPermGenGen*)gch->perm_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 VM_PopulateDumpSharedSpace op(class_promote_order,
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 gen->ro_space(), gen->rw_space(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1357 gen->md_space(), gen->mc_space());
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 VMThread::execute(&op);
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 return JNI_OK;
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1361
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1362 void* CompactingPermGenGen::find_matching_vtbl_ptr(void** vtbl_list,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1363 void* new_vtable_start,
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1364 void* obj) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1365 void* old_vtbl_ptr = *(void**)obj;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1366 for (int i = 0; i < vtbl_list_size; i++) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1367 if (vtbl_list[i] == old_vtbl_ptr) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1368 return (void**)new_vtable_start + i * num_virtuals;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1369 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1370 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1371 ShouldNotReachHere();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1372 return NULL;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1373 }
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1374
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1375
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 class LinkClassesClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
1378 Thread* THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
1379
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 LinkClassesClosure(Thread* thread) : THREAD(thread) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
1382
a61af66fc99e Initial load
duke
parents:
diff changeset
1383 void do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 Klass* k = Klass::cast((klassOop) obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 if (k->oop_is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 instanceKlass* ik = (instanceKlass*) k;
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 // Link the class to cause the bytecodes to be rewritten and the
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 // cpcache to be created.
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 if (ik->get_init_state() < instanceKlass::linked) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 ik->link_class(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 guarantee(!HAS_PENDING_EXCEPTION, "exception in class rewriting");
a61af66fc99e Initial load
duke
parents:
diff changeset
1393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1394
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 // Create String objects from string initializer symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 ik->constants()->resolve_string_constants(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 guarantee(!HAS_PENDING_EXCEPTION, "exception resolving string constants");
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1402
a61af66fc99e Initial load
duke
parents:
diff changeset
1403
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 // Support for a simple checksum of the contents of the class list
a61af66fc99e Initial load
duke
parents:
diff changeset
1405 // file to prevent trivial tampering. The algorithm matches that in
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 // the MakeClassList program used by the J2SE build process.
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 #define JSUM_SEED ((jlong)CONST64(0xcafebabebabecafe))
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 static jlong
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 jsum(jlong start, const char *buf, const int len)
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 jlong h = start;
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 char *p = (char *)buf, *e = p + len;
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 while (p < e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 char c = *p++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1415 if (c <= ' ') {
a61af66fc99e Initial load
duke
parents:
diff changeset
1416 /* Skip spaces and control characters */
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 h = 31 * h + c;
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1421 return h;
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1423
a61af66fc99e Initial load
duke
parents:
diff changeset
1424
a61af66fc99e Initial load
duke
parents:
diff changeset
1425
a61af66fc99e Initial load
duke
parents:
diff changeset
1426
a61af66fc99e Initial load
duke
parents:
diff changeset
1427
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 // Preload classes from a list, populate the shared spaces and dump to a
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 // file.
a61af66fc99e Initial load
duke
parents:
diff changeset
1430
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 void GenCollectedHeap::preload_and_dump(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 TraceTime timer("Dump Shared Spaces", TraceStartupTime);
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
1434
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 // Preload classes to be shared.
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
1436 // Should use some os:: method rather than fopen() here. aB.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 // Construct the path to the class list (in jre/lib)
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 // Walk up two directories from the location of the VM and
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 // optionally tack on "lib" (depending on platform)
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 char class_list_path[JVM_MAXPATHLEN];
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 os::jvm_path(class_list_path, sizeof(class_list_path));
a61af66fc99e Initial load
duke
parents:
diff changeset
1442 for (int i = 0; i < 3; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 char *end = strrchr(class_list_path, *os::file_separator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 if (end != NULL) *end = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 int class_list_path_len = (int)strlen(class_list_path);
a61af66fc99e Initial load
duke
parents:
diff changeset
1447 if (class_list_path_len >= 3) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 if (strcmp(class_list_path + class_list_path_len - 3, "lib") != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 strcat(class_list_path, os::file_separator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 strcat(class_list_path, "lib");
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1453 strcat(class_list_path, os::file_separator());
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 strcat(class_list_path, "classlist");
a61af66fc99e Initial load
duke
parents:
diff changeset
1455
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 FILE* file = fopen(class_list_path, "r");
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 if (file != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 jlong computed_jsum = JSUM_SEED;
a61af66fc99e Initial load
duke
parents:
diff changeset
1459 jlong file_jsum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1460
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 char class_name[256];
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 int class_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 GenCollectedHeap* gch = GenCollectedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 gch->_preloading_shared_classes = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
1465 GrowableArray<oop>* class_promote_order = new GrowableArray<oop>();
a61af66fc99e Initial load
duke
parents:
diff changeset
1466
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 // Preload (and intern) strings which will be used later.
a61af66fc99e Initial load
duke
parents:
diff changeset
1468
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 StringTable::intern("main", THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 StringTable::intern("([Ljava/lang/String;)V", THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 StringTable::intern("Ljava/lang/Class;", THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1472
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 StringTable::intern("I", THREAD); // Needed for StringBuffer persistence?
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 StringTable::intern("Z", THREAD); // Needed for StringBuffer persistence?
a61af66fc99e Initial load
duke
parents:
diff changeset
1475
a61af66fc99e Initial load
duke
parents:
diff changeset
1476 // sun.io.Converters
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 static const char obj_array_sig[] = "[[Ljava/lang/Object;";
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 SymbolTable::lookup(obj_array_sig, (int)strlen(obj_array_sig), THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1479
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 // java.util.HashMap
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 static const char map_entry_array_sig[] = "[Ljava/util/Map$Entry;";
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 SymbolTable::lookup(map_entry_array_sig, (int)strlen(map_entry_array_sig),
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1484
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 tty->print("Loading classes to share ... ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 while ((fgets(class_name, sizeof class_name, file)) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 if (*class_name == '#') {
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 jint fsh, fsl;
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 if (sscanf(class_name, "# %8x%8x\n", &fsh, &fsl) == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 file_jsum = ((jlong)(fsh) << 32) | (fsl & 0xffffffff);
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1492
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 // Remove trailing newline
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 size_t name_len = strlen(class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 class_name[name_len-1] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
1498
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 computed_jsum = jsum(computed_jsum, class_name, (const int)name_len - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1500
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 // Got a class name - load it.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1980
diff changeset
1502 TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name, THREAD);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 klassOop klass = SystemDictionary::resolve_or_null(class_name_symbol,
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 guarantee(!HAS_PENDING_EXCEPTION, "Exception resolving a class.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 if (klass != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 if (PrintSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 tty->print_cr("Shared spaces preloaded: %s", class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1511
a61af66fc99e Initial load
duke
parents:
diff changeset
1512
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 instanceKlass* ik = instanceKlass::cast(klass);
a61af66fc99e Initial load
duke
parents:
diff changeset
1514
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 // Should be class load order as per -XX:+TraceClassLoadingPreorder
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 class_promote_order->append(ik->as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
1517
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 // Link the class to cause the bytecodes to be rewritten and the
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 // cpcache to be created. The linking is done as soon as classes
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 // are loaded in order that the related data structures (klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 // cpCache, Sting constants) are located together.
a61af66fc99e Initial load
duke
parents:
diff changeset
1522
a61af66fc99e Initial load
duke
parents:
diff changeset
1523 if (ik->get_init_state() < instanceKlass::linked) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 ik->link_class(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 guarantee(!(HAS_PENDING_EXCEPTION), "exception in class rewriting");
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1527
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 // Create String objects from string initializer symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
1529
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 ik->constants()->resolve_string_constants(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1531
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 class_count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 if (PrintSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 tty->print_cr(" Preload failed: %s", class_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
1537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 file_jsum = 0; // Checksum must be on last line of file
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 if (computed_jsum != file_jsum) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
1543 tty->print_cr("Preload failed: checksum of class list was incorrect.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1546
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1548
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 if (PrintSharedSpaces) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1550 tty->print_cr("Shared spaces: preloaded %d classes", class_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1552
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 // Rewrite and unlink classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 tty->print("Rewriting and unlinking classes ... ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 // Make heap parsable
a61af66fc99e Initial load
duke
parents:
diff changeset
1556 ensure_parsability(false); // arg is actually don't care
a61af66fc99e Initial load
duke
parents:
diff changeset
1557
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 // Link any classes which got missed. (It's not quite clear why
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 // they got missed.) This iteration would be unsafe if we weren't
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 // single-threaded at this point; however we can't do it on the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 // thread because it requires object allocation.
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 LinkClassesClosure lcc(Thread::current());
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 object_iterate(&lcc);
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 tty->print_cr("done. ");
a61af66fc99e Initial load
duke
parents:
diff changeset
1565
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 // Create and dump the shared spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 jint err = CompactingPermGenGen::dump_shared(class_promote_order, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 if (err != JNI_OK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1569 fatal("Dumping shared spaces failed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1571
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 char errmsg[JVM_MAXPATHLEN];
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
1574 os::lasterror(errmsg, JVM_MAXPATHLEN);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 tty->print_cr("Loading classlist failed: %s", errmsg);
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1577 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1578
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 // Since various initialization steps have been undone by this process,
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 // it is not reasonable to continue running a java process.
a61af66fc99e Initial load
duke
parents:
diff changeset
1581 exit(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 }