src/share/vm/memory/restore.cpp

Wed, 01 Dec 2010 15:04:06 +0100

author
stefank
date
Wed, 01 Dec 2010 15:04:06 +0100
changeset 2325
c760f78e0a53
parent 2314
f95d63e2154a
child 2497
3582bf76420e
permissions
-rw-r--r--

7003125: precompiled.hpp is included when precompiled headers are not used
Summary: Added an ifndef DONT_USE_PRECOMPILED_HEADER to precompiled.hpp. Set up DONT_USE_PRECOMPILED_HEADER when compiling with Sun Studio or when the user specifies USE_PRECOMPILED_HEADER=0. Fixed broken include dependencies.
Reviewed-by: coleenp, kvn

     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "classfile/symbolTable.hpp"
    27 #include "classfile/systemDictionary.hpp"
    28 #include "memory/filemap.hpp"
    29 #include "oops/oop.inline.hpp"
    30 #include "utilities/hashtable.inline.hpp"
    33 // Closure for serializing initialization data in from a data area
    34 // (oop_array) read from the shared file.
    36 class ReadClosure : public SerializeOopClosure {
    37 private:
    38   oop** _oop_array;
    40   inline oop nextOop() {
    41     return *(*_oop_array)++;
    42   }
    44 public:
    45   ReadClosure(oop** oop_array) { _oop_array = oop_array; }
    47   void do_oop(oop* p) {
    48     assert(SharedSkipVerify || *p == NULL || *p == Universe::klassKlassObj(),
    49            "initializing previously initialized oop.");
    50     oop obj = nextOop();
    51     assert(SharedSkipVerify || (intptr_t)obj >= 0 || (intptr_t)obj < -100,
    52            "hit tag while initializing oops.");
    53     assert(SharedSkipVerify || obj->is_oop_or_null(), "invalid oop");
    54     *p = obj;
    55   }
    57   void do_oop(narrowOop* p) { ShouldNotReachHere(); }
    59   void do_ptr(void** p) {
    60     assert(*p == NULL, "initializing previous initialized pointer.");
    61     void* obj = nextOop();
    62     assert((intptr_t)obj >= 0 || (intptr_t)obj < -100,
    63            "hit tag while initializing ptrs.");
    64     *p = obj;
    65   }
    67   void do_ptr(HeapWord** p) { do_ptr((void **) p); }
    69   void do_int(int* p) {
    70     *p = (int)(intptr_t)nextOop();
    71   }
    73   void do_size_t(size_t* p) {
    74     // Assumes that size_t and pointers are the same size.
    75     *p = (size_t)nextOop();
    76   }
    78   void do_tag(int tag) {
    79     int old_tag;
    80     do_int(&old_tag);
    81     FileMapInfo::assert_mark(tag == old_tag);
    82   }
    84   void do_region(u_char* start, size_t size) {
    85     assert((intptr_t)start % sizeof(oop) == 0, "bad alignment");
    86     assert(size % sizeof(oop) == 0, "bad size");
    87     do_tag((int)size);
    88     while (size > 0) {
    89       *(oop*)start = nextOop();
    90       start += sizeof(oop);
    91       size -= sizeof(oop);
    92     }
    93   }
    95   bool reading() const { return true; }
    96 };
    99 // Read the oop and miscellaneous data from the shared file, and
   100 // serialize it out to its various destinations.
   102 void CompactingPermGenGen::initialize_oops() {
   103   FileMapInfo *mapinfo = FileMapInfo::current_info();
   105   char* buffer = mapinfo->region_base(md);
   107   // Skip over (reserve space for) a list of addresses of C++ vtables
   108   // for Klass objects.  They get filled in later.
   110   // Skip over (reserve space for) dummy C++ vtables Klass objects.
   111   // They are used as is.
   113   void** vtbl_list = (void**)buffer;
   114   buffer += vtbl_list_size * sizeof(void*);
   115   intptr_t vtable_size = *(intptr_t*)buffer;
   116   buffer += sizeof(intptr_t);
   117   buffer += vtable_size;
   119   // Create the symbol table using the bucket array at this spot in the
   120   // misc data space.  Since the symbol table is often modified, this
   121   // region (of mapped pages) will be copy-on-write.
   123   int symbolTableLen = *(intptr_t*)buffer;
   124   buffer += sizeof(intptr_t);
   125   int number_of_entries = *(intptr_t*)buffer;
   126   buffer += sizeof(intptr_t);
   127   SymbolTable::create_table((HashtableBucket*)buffer, symbolTableLen,
   128                             number_of_entries);
   129   buffer += symbolTableLen;
   131   // Create the string table using the bucket array at this spot in the
   132   // misc data space.  Since the string table is often modified, this
   133   // region (of mapped pages) will be copy-on-write.
   135   int stringTableLen = *(intptr_t*)buffer;
   136   buffer += sizeof(intptr_t);
   137   number_of_entries = *(intptr_t*)buffer;
   138   buffer += sizeof(intptr_t);
   139   StringTable::create_table((HashtableBucket*)buffer, stringTableLen,
   140                             number_of_entries);
   141   buffer += stringTableLen;
   143   // Create the shared dictionary using the bucket array at this spot in
   144   // the misc data space.  Since the shared dictionary table is never
   145   // modified, this region (of mapped pages) will be (effectively, if
   146   // not explicitly) read-only.
   148   int sharedDictionaryLen = *(intptr_t*)buffer;
   149   buffer += sizeof(intptr_t);
   150   number_of_entries = *(intptr_t*)buffer;
   151   buffer += sizeof(intptr_t);
   152   SystemDictionary::set_shared_dictionary((HashtableBucket*)buffer,
   153                                           sharedDictionaryLen,
   154                                           number_of_entries);
   155   buffer += sharedDictionaryLen;
   157   // Create the package info table using the bucket array at this spot in
   158   // the misc data space.  Since the package info table is never
   159   // modified, this region (of mapped pages) will be (effectively, if
   160   // not explicitly) read-only.
   162   int pkgInfoLen = *(intptr_t*)buffer;
   163   buffer += sizeof(intptr_t);
   164   number_of_entries = *(intptr_t*)buffer;
   165   buffer += sizeof(intptr_t);
   166   ClassLoader::create_package_info_table((HashtableBucket*)buffer, pkgInfoLen,
   167                                          number_of_entries);
   168   buffer += pkgInfoLen;
   169   ClassLoader::verify();
   171   // The following data in the shared misc data region are the linked
   172   // list elements (HashtableEntry objects) for the symbol table, string
   173   // table, and shared dictionary.  The heap objects refered to by the
   174   // symbol table, string table, and shared dictionary are permanent and
   175   // unmovable.  Since new entries added to the string and symbol tables
   176   // are always added at the beginning of the linked lists, THESE LINKED
   177   // LIST ELEMENTS ARE READ-ONLY.
   179   int len = *(intptr_t*)buffer; // skip over symbol table entries
   180   buffer += sizeof(intptr_t);
   181   buffer += len;
   183   len = *(intptr_t*)buffer;     // skip over string table entries
   184   buffer += sizeof(intptr_t);
   185   buffer += len;
   187   len = *(intptr_t*)buffer;     // skip over shared dictionary entries
   188   buffer += sizeof(intptr_t);
   189   buffer += len;
   191   len = *(intptr_t*)buffer;     // skip over package info table entries
   192   buffer += sizeof(intptr_t);
   193   buffer += len;
   195   len = *(intptr_t*)buffer;     // skip over package info table char[] arrays.
   196   buffer += sizeof(intptr_t);
   197   buffer += len;
   199   oop* oop_array = (oop*)buffer;
   200   ReadClosure rc(&oop_array);
   201   serialize_oops(&rc);
   202 }

mercurial