Mercurial > hg > graal-compiler
comparison src/share/vm/memory/restore.cpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | ba764ed4b6f2 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
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 | |
53 void do_ptr(void** p) { | |
54 assert(*p == NULL, "initializing previous initialized pointer."); | |
55 void* obj = nextOop(); | |
56 assert((intptr_t)obj >= 0 || (intptr_t)obj < -100, | |
57 "hit tag while initializing ptrs."); | |
58 *p = obj; | |
59 } | |
60 | |
61 void do_ptr(HeapWord** p) { do_ptr((void **) p); } | |
62 | |
63 void do_int(int* p) { | |
64 *p = (int)(intptr_t)nextOop(); | |
65 } | |
66 | |
67 void do_size_t(size_t* p) { | |
68 // Assumes that size_t and pointers are the same size. | |
69 *p = (size_t)nextOop(); | |
70 } | |
71 | |
72 void do_tag(int tag) { | |
73 int old_tag; | |
74 do_int(&old_tag); | |
75 FileMapInfo::assert_mark(tag == old_tag); | |
76 } | |
77 | |
78 void do_region(u_char* start, size_t size) { | |
79 assert((intptr_t)start % sizeof(oop) == 0, "bad alignment"); | |
80 assert(size % sizeof(oop) == 0, "bad size"); | |
81 do_tag((int)size); | |
82 while (size > 0) { | |
83 *(oop*)start = nextOop(); | |
84 start += sizeof(oop); | |
85 size -= sizeof(oop); | |
86 } | |
87 } | |
88 | |
89 bool reading() const { return true; } | |
90 }; | |
91 | |
92 | |
93 // Read the oop and miscellaneous data from the shared file, and | |
94 // serialize it out to its various destinations. | |
95 | |
96 void CompactingPermGenGen::initialize_oops() { | |
97 FileMapInfo *mapinfo = FileMapInfo::current_info(); | |
98 | |
99 char* buffer = mapinfo->region_base(md); | |
100 | |
101 // Skip over (reserve space for) a list of addresses of C++ vtables | |
102 // for Klass objects. They get filled in later. | |
103 | |
104 // Skip over (reserve space for) dummy C++ vtables Klass objects. | |
105 // They are used as is. | |
106 | |
107 void** vtbl_list = (void**)buffer; | |
108 buffer += vtbl_list_size * sizeof(void*); | |
109 intptr_t vtable_size = *(intptr_t*)buffer; | |
110 buffer += sizeof(intptr_t); | |
111 buffer += vtable_size; | |
112 | |
113 // Create the symbol table using the bucket array at this spot in the | |
114 // misc data space. Since the symbol table is often modified, this | |
115 // region (of mapped pages) will be copy-on-write. | |
116 | |
117 int symbolTableLen = *(intptr_t*)buffer; | |
118 buffer += sizeof(intptr_t); | |
119 int number_of_entries = *(intptr_t*)buffer; | |
120 buffer += sizeof(intptr_t); | |
121 SymbolTable::create_table((HashtableBucket*)buffer, symbolTableLen, | |
122 number_of_entries); | |
123 buffer += symbolTableLen; | |
124 | |
125 // Create the string table using the bucket array at this spot in the | |
126 // misc data space. Since the string table is often modified, this | |
127 // region (of mapped pages) will be copy-on-write. | |
128 | |
129 int stringTableLen = *(intptr_t*)buffer; | |
130 buffer += sizeof(intptr_t); | |
131 number_of_entries = *(intptr_t*)buffer; | |
132 buffer += sizeof(intptr_t); | |
133 StringTable::create_table((HashtableBucket*)buffer, stringTableLen, | |
134 number_of_entries); | |
135 buffer += stringTableLen; | |
136 | |
137 // Create the shared dictionary using the bucket array at this spot in | |
138 // the misc data space. Since the shared dictionary table is never | |
139 // modified, this region (of mapped pages) will be (effectively, if | |
140 // not explicitly) read-only. | |
141 | |
142 int sharedDictionaryLen = *(intptr_t*)buffer; | |
143 buffer += sizeof(intptr_t); | |
144 number_of_entries = *(intptr_t*)buffer; | |
145 buffer += sizeof(intptr_t); | |
146 SystemDictionary::set_shared_dictionary((HashtableBucket*)buffer, | |
147 sharedDictionaryLen, | |
148 number_of_entries); | |
149 buffer += sharedDictionaryLen; | |
150 | |
151 // Create the package info table using the bucket array at this spot in | |
152 // the misc data space. Since the package info table is never | |
153 // modified, this region (of mapped pages) will be (effectively, if | |
154 // not explicitly) read-only. | |
155 | |
156 int pkgInfoLen = *(intptr_t*)buffer; | |
157 buffer += sizeof(intptr_t); | |
158 number_of_entries = *(intptr_t*)buffer; | |
159 buffer += sizeof(intptr_t); | |
160 ClassLoader::create_package_info_table((HashtableBucket*)buffer, pkgInfoLen, | |
161 number_of_entries); | |
162 buffer += pkgInfoLen; | |
163 ClassLoader::verify(); | |
164 | |
165 // The following data in the shared misc data region are the linked | |
166 // list elements (HashtableEntry objects) for the symbol table, string | |
167 // table, and shared dictionary. The heap objects refered to by the | |
168 // symbol table, string table, and shared dictionary are permanent and | |
169 // unmovable. Since new entries added to the string and symbol tables | |
170 // are always added at the beginning of the linked lists, THESE LINKED | |
171 // LIST ELEMENTS ARE READ-ONLY. | |
172 | |
173 int len = *(intptr_t*)buffer; // skip over symbol table entries | |
174 buffer += sizeof(intptr_t); | |
175 buffer += len; | |
176 | |
177 len = *(intptr_t*)buffer; // skip over string table entries | |
178 buffer += sizeof(intptr_t); | |
179 buffer += len; | |
180 | |
181 len = *(intptr_t*)buffer; // skip over shared dictionary entries | |
182 buffer += sizeof(intptr_t); | |
183 buffer += len; | |
184 | |
185 len = *(intptr_t*)buffer; // skip over package info table entries | |
186 buffer += sizeof(intptr_t); | |
187 buffer += len; | |
188 | |
189 len = *(intptr_t*)buffer; // skip over package info table char[] arrays. | |
190 buffer += sizeof(intptr_t); | |
191 buffer += len; | |
192 | |
193 oop* oop_array = (oop*)buffer; | |
194 ReadClosure rc(&oop_array); | |
195 serialize_oops(&rc); | |
196 } |