hotspot/src/share/vm/memory/restore.cpp
author ysr
Thu, 17 Mar 2011 10:32:46 -0700
changeset 8688 493d12ccc6db
parent 8076 96d498ec7ae1
child 8921 14bfe81f2a9d
permissions -rw-r--r--
6668573: CMS: reference processing crash if ParallelCMSThreads > ParallelGCThreads Summary: Use _max_num_q = max(discovery_degree, processing_degree), and let balance_queues() redistribute from discovery_degree to processing_degree of queues. This should also allow a more dynamic and flexible parallelism policy in the future. Reviewed-by: jmasa, johnc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "classfile/symbolTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/filemap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "utilities/hashtable.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Closure for serializing initialization data in from a data area
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// (oop_array) read from the shared file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class ReadClosure : public SerializeOopClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  oop** _oop_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  inline oop nextOop() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    return *(*_oop_array)++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  ReadClosure(oop** oop_array) { _oop_array = oop_array; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  void do_oop(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    assert(SharedSkipVerify || *p == NULL || *p == Universe::klassKlassObj(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
           "initializing previously initialized oop.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    oop obj = nextOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    assert(SharedSkipVerify || (intptr_t)obj >= 0 || (intptr_t)obj < -100,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
           "hit tag while initializing oops.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    assert(SharedSkipVerify || obj->is_oop_or_null(), "invalid oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    *p = obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
  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
    58
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  void do_ptr(void** p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    assert(*p == NULL, "initializing previous initialized pointer.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    void* obj = nextOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    assert((intptr_t)obj >= 0 || (intptr_t)obj < -100,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
           "hit tag while initializing ptrs.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    *p = obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  void do_ptr(HeapWord** p) { do_ptr((void **) p); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  void do_int(int* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    *p = (int)(intptr_t)nextOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  void do_size_t(size_t* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    // Assumes that size_t and pointers are the same size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    *p = (size_t)nextOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  void do_tag(int tag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    int old_tag;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    do_int(&old_tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    FileMapInfo::assert_mark(tag == old_tag);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  void do_region(u_char* start, size_t size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    assert((intptr_t)start % sizeof(oop) == 0, "bad alignment");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    assert(size % sizeof(oop) == 0, "bad size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    do_tag((int)size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    while (size > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      *(oop*)start = nextOop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      start += sizeof(oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      size -= sizeof(oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  bool reading() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
// Read the oop and miscellaneous data from the shared file, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
// serialize it out to its various destinations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
void CompactingPermGenGen::initialize_oops() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  FileMapInfo *mapinfo = FileMapInfo::current_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  char* buffer = mapinfo->region_base(md);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Skip over (reserve space for) a list of addresses of C++ vtables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // for Klass objects.  They get filled in later.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   110
  void** vtbl_list = (void**)buffer;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   111
  buffer += vtbl_list_size * sizeof(void*);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   112
  Universe::init_self_patching_vtbl_list(vtbl_list, vtbl_list_size);
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   113
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // Skip over (reserve space for) dummy C++ vtables Klass objects.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // They are used as is.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  intptr_t vtable_size = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  buffer += vtable_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   121
  // Skip the recorded symbols.
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   122
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   123
  intptr_t total_symbol_size = *(intptr_t*)buffer;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   124
  buffer += sizeof(intptr_t) * 2;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   125
  buffer += total_symbol_size;
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   126
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Create the symbol table using the bucket array at this spot in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // misc data space.  Since the symbol table is often modified, this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // region (of mapped pages) will be copy-on-write.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  int symbolTableLen = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  int number_of_entries = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  SymbolTable::create_table((HashtableBucket*)buffer, symbolTableLen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
                            number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  buffer += symbolTableLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Create the string table using the bucket array at this spot in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // misc data space.  Since the string table is often modified, this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // region (of mapped pages) will be copy-on-write.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  int stringTableLen = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  number_of_entries = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  StringTable::create_table((HashtableBucket*)buffer, stringTableLen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                            number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  buffer += stringTableLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Create the shared dictionary using the bucket array at this spot in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // the misc data space.  Since the shared dictionary table is never
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // modified, this region (of mapped pages) will be (effectively, if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // not explicitly) read-only.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  int sharedDictionaryLen = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  number_of_entries = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  SystemDictionary::set_shared_dictionary((HashtableBucket*)buffer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
                                          sharedDictionaryLen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
                                          number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  buffer += sharedDictionaryLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Create the package info table using the bucket array at this spot in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // the misc data space.  Since the package info table is never
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  // modified, this region (of mapped pages) will be (effectively, if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // not explicitly) read-only.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  int pkgInfoLen = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  number_of_entries = *(intptr_t*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  ClassLoader::create_package_info_table((HashtableBucket*)buffer, pkgInfoLen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
                                         number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  buffer += pkgInfoLen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  ClassLoader::verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // The following data in the shared misc data region are the linked
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // list elements (HashtableEntry objects) for the symbol table, string
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // table, and shared dictionary.  The heap objects refered to by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // symbol table, string table, and shared dictionary are permanent and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // unmovable.  Since new entries added to the string and symbol tables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // are always added at the beginning of the linked lists, THESE LINKED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // LIST ELEMENTS ARE READ-ONLY.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  int len = *(intptr_t*)buffer; // skip over symbol table entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  buffer += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  len = *(intptr_t*)buffer;     // skip over string table entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  buffer += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  len = *(intptr_t*)buffer;     // skip over shared dictionary entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  buffer += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  len = *(intptr_t*)buffer;     // skip over package info table entries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  buffer += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  len = *(intptr_t*)buffer;     // skip over package info table char[] arrays.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  buffer += sizeof(intptr_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  buffer += len;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  oop* oop_array = (oop*)buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  ReadClosure rc(&oop_array);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  serialize_oops(&rc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}