duke@435: /* xdono@631: * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: # include "incls/_precompiled.incl" duke@435: # include "incls/_restore.cpp.incl" duke@435: duke@435: duke@435: // Closure for serializing initialization data in from a data area duke@435: // (oop_array) read from the shared file. duke@435: duke@435: class ReadClosure : public SerializeOopClosure { duke@435: private: duke@435: oop** _oop_array; duke@435: duke@435: inline oop nextOop() { duke@435: return *(*_oop_array)++; duke@435: } duke@435: duke@435: public: duke@435: ReadClosure(oop** oop_array) { _oop_array = oop_array; } duke@435: duke@435: void do_oop(oop* p) { duke@435: assert(SharedSkipVerify || *p == NULL || *p == Universe::klassKlassObj(), duke@435: "initializing previously initialized oop."); duke@435: oop obj = nextOop(); duke@435: assert(SharedSkipVerify || (intptr_t)obj >= 0 || (intptr_t)obj < -100, duke@435: "hit tag while initializing oops."); duke@435: assert(SharedSkipVerify || obj->is_oop_or_null(), "invalid oop"); duke@435: *p = obj; duke@435: } duke@435: coleenp@548: void do_oop(narrowOop* p) { ShouldNotReachHere(); } coleenp@548: duke@435: void do_ptr(void** p) { duke@435: assert(*p == NULL, "initializing previous initialized pointer."); duke@435: void* obj = nextOop(); duke@435: assert((intptr_t)obj >= 0 || (intptr_t)obj < -100, duke@435: "hit tag while initializing ptrs."); duke@435: *p = obj; duke@435: } duke@435: duke@435: void do_ptr(HeapWord** p) { do_ptr((void **) p); } duke@435: duke@435: void do_int(int* p) { duke@435: *p = (int)(intptr_t)nextOop(); duke@435: } duke@435: duke@435: void do_size_t(size_t* p) { duke@435: // Assumes that size_t and pointers are the same size. duke@435: *p = (size_t)nextOop(); duke@435: } duke@435: duke@435: void do_tag(int tag) { duke@435: int old_tag; duke@435: do_int(&old_tag); duke@435: FileMapInfo::assert_mark(tag == old_tag); duke@435: } duke@435: duke@435: void do_region(u_char* start, size_t size) { duke@435: assert((intptr_t)start % sizeof(oop) == 0, "bad alignment"); duke@435: assert(size % sizeof(oop) == 0, "bad size"); duke@435: do_tag((int)size); duke@435: while (size > 0) { duke@435: *(oop*)start = nextOop(); duke@435: start += sizeof(oop); duke@435: size -= sizeof(oop); duke@435: } duke@435: } duke@435: duke@435: bool reading() const { return true; } duke@435: }; duke@435: duke@435: duke@435: // Read the oop and miscellaneous data from the shared file, and duke@435: // serialize it out to its various destinations. duke@435: duke@435: void CompactingPermGenGen::initialize_oops() { duke@435: FileMapInfo *mapinfo = FileMapInfo::current_info(); duke@435: duke@435: char* buffer = mapinfo->region_base(md); duke@435: duke@435: // Skip over (reserve space for) a list of addresses of C++ vtables duke@435: // for Klass objects. They get filled in later. duke@435: duke@435: // Skip over (reserve space for) dummy C++ vtables Klass objects. duke@435: // They are used as is. duke@435: duke@435: void** vtbl_list = (void**)buffer; duke@435: buffer += vtbl_list_size * sizeof(void*); duke@435: intptr_t vtable_size = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: buffer += vtable_size; duke@435: duke@435: // Create the symbol table using the bucket array at this spot in the duke@435: // misc data space. Since the symbol table is often modified, this duke@435: // region (of mapped pages) will be copy-on-write. duke@435: duke@435: int symbolTableLen = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: int number_of_entries = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: SymbolTable::create_table((HashtableBucket*)buffer, symbolTableLen, duke@435: number_of_entries); duke@435: buffer += symbolTableLen; duke@435: duke@435: // Create the string table using the bucket array at this spot in the duke@435: // misc data space. Since the string table is often modified, this duke@435: // region (of mapped pages) will be copy-on-write. duke@435: duke@435: int stringTableLen = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: number_of_entries = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: StringTable::create_table((HashtableBucket*)buffer, stringTableLen, duke@435: number_of_entries); duke@435: buffer += stringTableLen; duke@435: duke@435: // Create the shared dictionary using the bucket array at this spot in duke@435: // the misc data space. Since the shared dictionary table is never duke@435: // modified, this region (of mapped pages) will be (effectively, if duke@435: // not explicitly) read-only. duke@435: duke@435: int sharedDictionaryLen = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: number_of_entries = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: SystemDictionary::set_shared_dictionary((HashtableBucket*)buffer, duke@435: sharedDictionaryLen, duke@435: number_of_entries); duke@435: buffer += sharedDictionaryLen; duke@435: duke@435: // Create the package info table using the bucket array at this spot in duke@435: // the misc data space. Since the package info table is never duke@435: // modified, this region (of mapped pages) will be (effectively, if duke@435: // not explicitly) read-only. duke@435: duke@435: int pkgInfoLen = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: number_of_entries = *(intptr_t*)buffer; duke@435: buffer += sizeof(intptr_t); duke@435: ClassLoader::create_package_info_table((HashtableBucket*)buffer, pkgInfoLen, duke@435: number_of_entries); duke@435: buffer += pkgInfoLen; duke@435: ClassLoader::verify(); duke@435: duke@435: // The following data in the shared misc data region are the linked duke@435: // list elements (HashtableEntry objects) for the symbol table, string duke@435: // table, and shared dictionary. The heap objects refered to by the duke@435: // symbol table, string table, and shared dictionary are permanent and duke@435: // unmovable. Since new entries added to the string and symbol tables duke@435: // are always added at the beginning of the linked lists, THESE LINKED duke@435: // LIST ELEMENTS ARE READ-ONLY. duke@435: duke@435: int len = *(intptr_t*)buffer; // skip over symbol table entries duke@435: buffer += sizeof(intptr_t); duke@435: buffer += len; duke@435: duke@435: len = *(intptr_t*)buffer; // skip over string table entries duke@435: buffer += sizeof(intptr_t); duke@435: buffer += len; duke@435: duke@435: len = *(intptr_t*)buffer; // skip over shared dictionary entries duke@435: buffer += sizeof(intptr_t); duke@435: buffer += len; duke@435: duke@435: len = *(intptr_t*)buffer; // skip over package info table entries duke@435: buffer += sizeof(intptr_t); duke@435: buffer += len; duke@435: duke@435: len = *(intptr_t*)buffer; // skip over package info table char[] arrays. duke@435: buffer += sizeof(intptr_t); duke@435: buffer += len; duke@435: duke@435: oop* oop_array = (oop*)buffer; duke@435: ReadClosure rc(&oop_array); duke@435: serialize_oops(&rc); duke@435: }