author | ysr |
Tue, 01 Jul 2008 11:59:44 -0700 | |
changeset 1383 | 3a216aa862b7 |
parent 360 | 21d113ecbf6a |
child 670 | ddf3e9583f2f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
# include "incls/_precompiled.incl" |
|
26 |
# include "incls/_restore.cpp.incl" |
|
27 |
||
28 |
||
29 |
// Closure for serializing initialization data in from a data area |
|
30 |
// (oop_array) read from the shared file. |
|
31 |
||
32 |
class ReadClosure : public SerializeOopClosure { |
|
33 |
private: |
|
34 |
oop** _oop_array; |
|
35 |
||
36 |
inline oop nextOop() { |
|
37 |
return *(*_oop_array)++; |
|
38 |
} |
|
39 |
||
40 |
public: |
|
41 |
ReadClosure(oop** oop_array) { _oop_array = oop_array; } |
|
42 |
||
43 |
void do_oop(oop* p) { |
|
44 |
assert(SharedSkipVerify || *p == NULL || *p == Universe::klassKlassObj(), |
|
45 |
"initializing previously initialized oop."); |
|
46 |
oop obj = nextOop(); |
|
47 |
assert(SharedSkipVerify || (intptr_t)obj >= 0 || (intptr_t)obj < -100, |
|
48 |
"hit tag while initializing oops."); |
|
49 |
assert(SharedSkipVerify || obj->is_oop_or_null(), "invalid oop"); |
|
50 |
*p = obj; |
|
51 |
} |
|
52 |
||
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
53 |
void do_oop(narrowOop* p) { ShouldNotReachHere(); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
54 |
|
1 | 55 |
void do_ptr(void** p) { |
56 |
assert(*p == NULL, "initializing previous initialized pointer."); |
|
57 |
void* obj = nextOop(); |
|
58 |
assert((intptr_t)obj >= 0 || (intptr_t)obj < -100, |
|
59 |
"hit tag while initializing ptrs."); |
|
60 |
*p = obj; |
|
61 |
} |
|
62 |
||
63 |
void do_ptr(HeapWord** p) { do_ptr((void **) p); } |
|
64 |
||
65 |
void do_int(int* p) { |
|
66 |
*p = (int)(intptr_t)nextOop(); |
|
67 |
} |
|
68 |
||
69 |
void do_size_t(size_t* p) { |
|
70 |
// Assumes that size_t and pointers are the same size. |
|
71 |
*p = (size_t)nextOop(); |
|
72 |
} |
|
73 |
||
74 |
void do_tag(int tag) { |
|
75 |
int old_tag; |
|
76 |
do_int(&old_tag); |
|
77 |
FileMapInfo::assert_mark(tag == old_tag); |
|
78 |
} |
|
79 |
||
80 |
void do_region(u_char* start, size_t size) { |
|
81 |
assert((intptr_t)start % sizeof(oop) == 0, "bad alignment"); |
|
82 |
assert(size % sizeof(oop) == 0, "bad size"); |
|
83 |
do_tag((int)size); |
|
84 |
while (size > 0) { |
|
85 |
*(oop*)start = nextOop(); |
|
86 |
start += sizeof(oop); |
|
87 |
size -= sizeof(oop); |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
bool reading() const { return true; } |
|
92 |
}; |
|
93 |
||
94 |
||
95 |
// Read the oop and miscellaneous data from the shared file, and |
|
96 |
// serialize it out to its various destinations. |
|
97 |
||
98 |
void CompactingPermGenGen::initialize_oops() { |
|
99 |
FileMapInfo *mapinfo = FileMapInfo::current_info(); |
|
100 |
||
101 |
char* buffer = mapinfo->region_base(md); |
|
102 |
||
103 |
// Skip over (reserve space for) a list of addresses of C++ vtables |
|
104 |
// for Klass objects. They get filled in later. |
|
105 |
||
106 |
// Skip over (reserve space for) dummy C++ vtables Klass objects. |
|
107 |
// They are used as is. |
|
108 |
||
109 |
void** vtbl_list = (void**)buffer; |
|
110 |
buffer += vtbl_list_size * sizeof(void*); |
|
111 |
intptr_t vtable_size = *(intptr_t*)buffer; |
|
112 |
buffer += sizeof(intptr_t); |
|
113 |
buffer += vtable_size; |
|
114 |
||
115 |
// Create the symbol table using the bucket array at this spot in the |
|
116 |
// misc data space. Since the symbol table is often modified, this |
|
117 |
// region (of mapped pages) will be copy-on-write. |
|
118 |
||
119 |
int symbolTableLen = *(intptr_t*)buffer; |
|
120 |
buffer += sizeof(intptr_t); |
|
121 |
int number_of_entries = *(intptr_t*)buffer; |
|
122 |
buffer += sizeof(intptr_t); |
|
123 |
SymbolTable::create_table((HashtableBucket*)buffer, symbolTableLen, |
|
124 |
number_of_entries); |
|
125 |
buffer += symbolTableLen; |
|
126 |
||
127 |
// Create the string table using the bucket array at this spot in the |
|
128 |
// misc data space. Since the string table is often modified, this |
|
129 |
// region (of mapped pages) will be copy-on-write. |
|
130 |
||
131 |
int stringTableLen = *(intptr_t*)buffer; |
|
132 |
buffer += sizeof(intptr_t); |
|
133 |
number_of_entries = *(intptr_t*)buffer; |
|
134 |
buffer += sizeof(intptr_t); |
|
135 |
StringTable::create_table((HashtableBucket*)buffer, stringTableLen, |
|
136 |
number_of_entries); |
|
137 |
buffer += stringTableLen; |
|
138 |
||
139 |
// Create the shared dictionary using the bucket array at this spot in |
|
140 |
// the misc data space. Since the shared dictionary table is never |
|
141 |
// modified, this region (of mapped pages) will be (effectively, if |
|
142 |
// not explicitly) read-only. |
|
143 |
||
144 |
int sharedDictionaryLen = *(intptr_t*)buffer; |
|
145 |
buffer += sizeof(intptr_t); |
|
146 |
number_of_entries = *(intptr_t*)buffer; |
|
147 |
buffer += sizeof(intptr_t); |
|
148 |
SystemDictionary::set_shared_dictionary((HashtableBucket*)buffer, |
|
149 |
sharedDictionaryLen, |
|
150 |
number_of_entries); |
|
151 |
buffer += sharedDictionaryLen; |
|
152 |
||
153 |
// Create the package info table using the bucket array at this spot in |
|
154 |
// the misc data space. Since the package info table is never |
|
155 |
// modified, this region (of mapped pages) will be (effectively, if |
|
156 |
// not explicitly) read-only. |
|
157 |
||
158 |
int pkgInfoLen = *(intptr_t*)buffer; |
|
159 |
buffer += sizeof(intptr_t); |
|
160 |
number_of_entries = *(intptr_t*)buffer; |
|
161 |
buffer += sizeof(intptr_t); |
|
162 |
ClassLoader::create_package_info_table((HashtableBucket*)buffer, pkgInfoLen, |
|
163 |
number_of_entries); |
|
164 |
buffer += pkgInfoLen; |
|
165 |
ClassLoader::verify(); |
|
166 |
||
167 |
// The following data in the shared misc data region are the linked |
|
168 |
// list elements (HashtableEntry objects) for the symbol table, string |
|
169 |
// table, and shared dictionary. The heap objects refered to by the |
|
170 |
// symbol table, string table, and shared dictionary are permanent and |
|
171 |
// unmovable. Since new entries added to the string and symbol tables |
|
172 |
// are always added at the beginning of the linked lists, THESE LINKED |
|
173 |
// LIST ELEMENTS ARE READ-ONLY. |
|
174 |
||
175 |
int len = *(intptr_t*)buffer; // skip over symbol table entries |
|
176 |
buffer += sizeof(intptr_t); |
|
177 |
buffer += len; |
|
178 |
||
179 |
len = *(intptr_t*)buffer; // skip over string table entries |
|
180 |
buffer += sizeof(intptr_t); |
|
181 |
buffer += len; |
|
182 |
||
183 |
len = *(intptr_t*)buffer; // skip over shared dictionary entries |
|
184 |
buffer += sizeof(intptr_t); |
|
185 |
buffer += len; |
|
186 |
||
187 |
len = *(intptr_t*)buffer; // skip over package info table entries |
|
188 |
buffer += sizeof(intptr_t); |
|
189 |
buffer += len; |
|
190 |
||
191 |
len = *(intptr_t*)buffer; // skip over package info table char[] arrays. |
|
192 |
buffer += sizeof(intptr_t); |
|
193 |
buffer += len; |
|
194 |
||
195 |
oop* oop_array = (oop*)buffer; |
|
196 |
ReadClosure rc(&oop_array); |
|
197 |
serialize_oops(&rc); |
|
198 |
} |