src/share/vm/memory/restore.cpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

Initial load

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

mercurial